HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CL_SimpleChannel.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: Channel Library (C++)
7  *
8  * COMMENTS: Simplified version of a channel which can be used without
9  * requiring the full CH library
10  *
11 */
12 
13 #ifndef __CL_SimpleChannel_h__
14 #define __CL_SimpleChannel_h__
15 
16 #include "CL_API.h"
17 #include "CL_Types.h"
18 
19 #include <SYS/SYS_Types.h>
20 #include <UT/UT_Array.h>
21 #include <UT/UT_Interval.h>
22 #include <UT/UT_StringHolder.h>
23 #include <UT/UT_SharedPtr.h>
24 
25 class CL_SegmentValues;
26 class CL_SimpleSegment;
27 class CL_Cubic;
28 
29 class CL_SimpleChannel;
32 
33 class UT_RLEBitArray;
34 
36 {
37 public:
38  fpreal x[4];
39  fpreal y[4];
40 
41  CL_Bezier() {}
42 
43  CL_Bezier(const CL_SegmentValues &sv);
44  CL_Bezier(CL_SegmentValues sv, fpreal vscale, fpreal voff);
45  // This constructor can be used to convert segment values to a bezier
46  // without applying the clamp to the control points which is meant to fix
47  // curves that back in on themselves. We want to prevent this clamping when
48  // converting the end_segment. As it has has a length of 0, clamping will
49  // cause us to lose its control points/acceleration handles.
50  CL_Bezier(const CL_SegmentValues &sv, bool clamp_slopes);
51 
52  void init(const CL_SegmentValues &sv);
53 
54  void fromSegmentValues(const CL_SegmentValues &sv,
55  bool clamp_slopes = true);
56 
57  void getValues( CL_SegmentValues &v ) const;
58 
59  static void getCubicFromCVs( const fpreal x[4], CL_Cubic &c );
60  static void getCubicFromCVs( const fpreal x[4], fpreal c[4] );
61 
62  static void splitInternal( fpreal t, const fpreal xin[4],
63  fpreal xout1[4], fpreal xout2[4] );
64 
65  void splitP( fpreal u, CL_Bezier &a, CL_Bezier &b ) const;
66 
67  void split( fpreal t, CL_Bezier &a, CL_Bezier &b ) const;
68 
69  void splitAndFindSlopeLengths( fpreal t,
70  fpreal &left_in, fpreal &left_out,
71  fpreal &right_in, fpreal &right_out ) const;
72 
73  // Calculates an acceleration ratio for a key to try and ease
74  // the curve if it's at the corner of a steep gradient
75  static fpreal getAdjustedAccelRatio(fpreal v0, fpreal v1, fpreal v2,
76  fpreal t0, fpreal t1, fpreal t2,
77  fpreal slope, bool is_in);
78 
79  fpreal timeToParametric( fpreal t ) const;
80 
81  fpreal evalP( fpreal u ) const;
82 
83  fpreal eval( fpreal t ) const; // t is local
84 
85  void display() const;
86 };
87 
89 {
90 public:
91  fpreal t0, t1;
92  fpreal x0, x1, x2, x3;
93 
94  CL_Cubic() {};
95  CL_Cubic(const CL_SegmentValues &sv);
96  CL_Cubic(fpreal iv, fpreal ov, fpreal im, fpreal om, fpreal it, fpreal ot);
97 
98  void init(const CL_SegmentValues &sv);
99  void getValues(CL_SegmentValues &v) const;
100 
101  fpreal timeToParametric( fpreal t ) const; // t -> u
102 
103  static fpreal reverseEvalP( const fpreal x[4], fpreal y ); // y -> u
104  static fpreal reverseEvalP( const CL_SimpleSegment &seg, fpreal y ); // y -> u
105  fpreal reverseEvalP( fpreal y ) const; // y -> u
106 
107  fpreal evalP( fpreal u ) const // u -> y
108  {
109  return x0 + u*(x1 + u*(x2 + u*x3));
110  }
111 
112  fpreal eval( fpreal t ) const; // t -> y
113 
114  fpreal calculateSlopeP( fpreal u ) const;
115 
116  fpreal calculateAccelP( fpreal u ) const;
117 
118  // If lock_in = true, this computes the range of out slopes that produce
119  // a monotonic curve assuming the in slope is fixed. false does the same
120  // for the in slope assuming the out slope is fixed.
121  // If no such interval exists, sets range to (-CL_MAX_SLOPE, CL_MAX_SLOPE)
122  // and returns false. Returns true if there's a valid interval
123  bool getMonotoneInterval(UT_IntervalR &range, bool lock_in);
124  // Same as getMonotoneInterval, but if the interval doesn't exist then
125  // it is recalculated with the locked slope being clamped to a range where
126  // the interval must be non-empty.
127  // This is useful to find slopes that get as close as possible to
128  // monotonicity, which helps prevent snapping in some cases.
129  void getWeakMonotoneInterval(UT_IntervalR &range, bool lock_in);
130 
131 
132  static bool isMonotone(fpreal iv, fpreal ov, fpreal im, fpreal om, fpreal dt);
133  static void clampSlopesToMonotone(fpreal &in, fpreal &out,
134  fpreal in_val, fpreal out_val, fpreal dt);
135  /// Second derivative discontinuity minimizing method suggested by
136  /// Wolberg. Given the slopes at the surrounding knots, picks a
137  /// slope that gets as close to C2 continuity as possible while
138  /// preserving monotonicity. To be used on keys whose neighbours have
139  /// pre-determined slopes, like local extrema or non-auto slopes
140  static fpreal getMonotoneSlopeSDDE(fpreal v0, fpreal v1, fpreal v2,
141  fpreal t0, fpreal t1, fpreal t2,
142  fpreal m0, fpreal m2);
143  // An extension of getMonotoneSlopeSDDE that operates on a group of
144  // 2 keys sandwiched between knots with fixed slopes. Picks slopes for
145  // to approach C2 continuity at both knots simultaneously while
146  // preserving monotonicity
147  static void getMonotoneSlopeSDDE2(fpreal v0, fpreal v1, fpreal v2, fpreal v3,
148  fpreal t0, fpreal t1, fpreal t2, fpreal t3,
149  fpreal m0, fpreal &m1, fpreal &m2, fpreal m3);
150 
151  // An unstable extension of getMonotoneSlopeSDDE2 that uses conic intersections
152  // to resolve cases where the segments are non monotonic.
153  #if 0
154  static void getMonotoneSlopeSDDE2ViaConic
156  fpreal t0, fpreal t1, fpreal t2, fpreal t3,
157  fpreal m0, fpreal &m1, fpreal &m2, fpreal m3);
158  #endif
159 
160 
161  void display() const;
162 };
163 
164 // Supported SimpleSegment Types.
166 {
176  // Custom means an expression that is unsupported by
177  // the simple channel. The custom expression will be stored
178  // on the simpleSegment for purposes of preserving it when
179  // round-tripping back to a CH_Segment, but it will be
180  // evaluated as a Bezier instead of the actual type.
182 };
183 
184 class CL_SimpleChannel;
185 
186 enum class CL_KeyHalf
187 {
188  In,
189  Out,
190  InOut,
191 };
192 
194 {
195 public:
196  fpreal t0, t1;
197  fpreal iv, ov, im, om, isl, osl;
198 
200 
201  void display();
202 };
203 
204 // It is designed for fast evaluation of the supported segment types.
205 // with focus on the bezier segments.
207 {
208 public:
209  fpreal getStart() const { return myBezierX[0]; }
210  fpreal getEnd() const { return myBezierX[3]; }
211  fpreal getStartValue() const { return myBezierY[0]; }
212  fpreal getEndValue() const { return myBezierY[3]; }
213  fpreal getLength() const { return myBezierX[3] - myBezierX[0]; }
214 
215  void setType(CL_SimpleSegmentType type) { myType = type; }
216  CL_SimpleSegmentType getType() const { return myType; }
217 
218  void setExtraData(int index, fpreal data) { myExtra[index] = data; }
219  fpreal *getExtraData() { return myExtra; }
220 
221 private:
222 
223  //x[0] is the start time
224  //x[3] is the end time
225  //y[0] is the start value
226  //y[3] is the end value
227  fpreal myBezierX[4]; // x[] data member of CL_Bezier
228  fpreal myBezierY[4]; // y[] data member of CL_Bezier
229 
230  CL_SimpleSegmentType myType; // Simple Segment Type
231 
232  // Extra data for Bezier/Cubic/Quintic
233  // Bezier stores UT_BezierRootFinder precomputed coefficients
234  // Cubic stores InSlope and OutSlope
235  // Quintic stores InSlope, OutSlope, InAccel and OutAcce
236  fpreal myExtra[16];
237 
238  friend class CL_SimpleChannel;
239  friend class CL_Cubic;
240 };
241 
242 /// A specialized channel for fast evaluation.
243 /// Should be created from an existing CH_Channel using
244 /// CH_Channel->asSimpleChannel().
245 /// Can be copied using the copy constructor.
246 /// Doesn't store the in/out value/slope/accel directly.
247 /// It stores precomputed bezier coefficient to avoid doing the conversion at
248 /// each evaluation.
249 /// Also uses UT_BezierRootFinder with precomputed coefficients to speed up
250 /// CL_Cubic::reverseEvalP.
252 {
253 public:
254  // Create an empty channel
256 
258  fpreal start,
259  int num_segments,
260  fpreal length,
261  CL_ChannelBehavior left_type,
262  CL_ChannelBehavior right_type,
263  fpreal default_value,
264  fpreal default_slope);
265 
266  // Deprecated, use the variant without tolerance instead
267  SYS_DEPRECATED(20.0)
269  fpreal start,
270  int num_segments,
271  fpreal length,
272  CL_ChannelBehavior left_type,
273  CL_ChannelBehavior right_type,
274  fpreal default_value,
275  fpreal default_slope,
276  fpreal tolerance);
277 
278  ~CL_SimpleChannel() = default;
279 
280  CL_SimpleChannel(const CL_SimpleChannel &other) = default;
281  CL_SimpleChannel(CL_SimpleChannel &&other) = default;
282 
283  CL_SimpleChannel &operator=(const CL_SimpleChannel &other) = default;
284  CL_SimpleChannel &operator=(CL_SimpleChannel &&other) = default;
285 
286  /// Simple channels can only evaluate certain types of segments.
287  /// This scans the channel to see if there is anything that can't
288  /// be eval'ed and returns true if everything is safe for eval()
289  bool canEval() const;
290 
291  // Evaluate the channel at global time.
292  fpreal eval(fpreal gtime) const;
293 
294  // Evaluate the channel at global time using a segment hint.
295  // Start with an hint of -1 if you don't have a previous evaluation.
296  fpreal eval(fpreal gtime, int &segment_idx_hint) const;
297 
298  // Evaluate the segment at local time using a segment hint.
299  fpreal eval(const CL_SimpleSegment &seg, fpreal ltime) const;
300 
301  fpreal evalSlope(fpreal gtime) const;
302  // Evaluate the slope at local time using a segment hint.
303  fpreal evalSlope(const CL_SimpleSegment &seg, fpreal ltime) const;
304 
305  fpreal evalAccel(fpreal gtime) const;
306  // Evaluate the slope at local time using a segment hint.
307  fpreal evalAccel(const CL_SimpleSegment &seg, fpreal ltime) const;
308 
309  bool isAtHardKey(fpreal gtime) const;
310 
311  int getSegmentIdx(fpreal ltime) const;
312  CL_SimpleSegment &getSegment(int index) { return mySegments[index]; }
313  const CL_SimpleSegment &getSegment(int index) const { return mySegments[index]; }
314  const UT_Array<CL_SimpleSegment> &getSegments() const { return mySegments; }
315 
316  UT_StringHolder getSegmentExpression(int index) const { return mySegmentExpressions[index]; }
317  const UT_Array<UT_StringHolder> &getSegmentExpressions() const { return mySegmentExpressions; }
319  { mySegmentExpressions[index] = expr; }
320 
322  { return mySegmentInSlopesAuto[index]; }
324  { return mySegmentOutSlopesAuto[index]; }
325 
327  { mySegmentInSlopesAuto[index] = value; }
329  { mySegmentOutSlopesAuto[index] = value; }
330 
331  void setSegmentInSlope(int index, fpreal slope);
332  void setSegmentOutSlope(int index, fpreal slope);
333  void setSegmentInAccel(int index, fpreal accel, bool ratio = false);
334  void setSegmentOutAccel(int index, fpreal accel, bool ratio = false);
335 
336  /// Set the type of the segment
337  /// Note that this differs from the setSegmentExpression, which is used
338  /// only for custom expressions.
339  /// @param index The index of the segment to modify
340  /// @param type The type to change the segment to.
341  void setSegmentType(int index, CL_SimpleSegmentType type);
342 
343  CL_SimpleSegmentType getSegmentType(int index) const;
344 
345  /// Insert a key frame at the given global time.
346  /// Returns true if a key frame was added, or false if it failed, or if
347  /// there was already a key frame at the given time.
348  bool insertKeyFrame(fpreal global_time, bool auto_slope = true);
349 
350  /// Destroy the key frame at the given global time
351  /// Returns true if a key was deleted, or false if there was no key at this
352  /// time
353  bool destroyKeyFrame(fpreal global_time);
354 
355  /// Destroys all key frames in the given global time range, inclusive.
356  /// Returns true if a key was deleted, or false if there were no keys in this
357  /// range
358  bool destroyKeyFrames(fpreal gtime_start, fpreal gtime_end);
359 
360  /// Destroys all segments from start_idx to end_idx.
361  /// Returns true if a key was deleted, or false if there were no keys in this
362  /// range
363  /// This keeps all the values/times in sync.
364  /// start_idx and end_idx are inclusive
365  /// end_idx of -1 means the last segment.
366  bool destroySegments(int start_idx, int end_idx);
367 
368  /// Set the value of the key at the given time
369  /// @param gtime Global time of the key to change
370  /// @param value New value to set for the key
371  /// @param half Which half of the key to set. Defaults to both (tied)
372  /// @returns true if successful, or false if there is no key at the given time
373  bool setKeyValue(fpreal gtime, fpreal value,
375 
376  /// Set the slope of the key at the given time
377  /// @param gtime Global time of the key to change
378  /// @param slope New slope to set for the key
379  /// @param half Which half of the key to set. Defaults to both (tied)
380  /// @returns true if successful, or false if there is no key at the given time
381  bool setKeySlope(fpreal gtime, fpreal slope,
383 
384  /// Set the accel of the key at the given time
385  /// @param gtime Global time of the key to change
386  /// @param accel New value to set for the key
387  /// @param half Which half of the key to set. Defaults to both (tied)
388  /// @returns true if successful, or false if there is no key at the given time
389  bool setKeyAccel(fpreal gtime, fpreal accel,
391 
392  fpreal getKeyValue(fpreal gtime, CL_KeyHalf half = CL_KeyHalf::InOut) const;
393  fpreal getKeySlope(fpreal gtime, CL_KeyHalf half = CL_KeyHalf::InOut) const;
394  fpreal getKeyAccel(fpreal gtime, CL_KeyHalf half = CL_KeyHalf::InOut) const;
395 
396  /// Set the auto_slope property of the key at the given time
397  /// @param gtime Global time of the key to change
398  /// @param auto_slope New auto_slope to set for the key
399  /// @param half Which half of the key to set. Defaults to both (tied)
400  /// @returns true if successful, or false if there is no key at the given
401  /// time
402  bool setKeyAutoSlope(fpreal gtime, bool auto_slope,
404 
405  /// Sets data evenly spaced between from and to
406  bool setRawValues(fpreal from,
407  fpreal to,
408  fpreal *data,
409  int num_samples,
410  bool auto_slope = true);
411  /// Sets data at the specified times
412  bool setRawValues(fpreal *times, fpreal *data, int num_samples);
413 
414  /// clears the channel, erasing all segments
415  void clear();
416 
417  /// Set the default value. This is the value returned when evaluating
418  /// an empty channel.
419  void setDefaultValue(fpreal value) { myDefaultValue = value; }
420 
421  void setPreValue(fpreal value) { myPreValue = value; }
422  void setPreSlope(fpreal slope) { myPreSlope = slope; }
423  void setPreType(CL_ChannelBehavior type) { myPreType = type; }
424 
425  void setPostValue(fpreal value) { myPostValue = value; }
426  void setPostSlope(fpreal slope) { myPostSlope = slope; }
427  void setPostType(CL_ChannelBehavior type) { myPostType = type; }
428 
429  fpreal getDefaultValue() const { return myDefaultValue; }
430 
431  fpreal getPreValue() const { return myPreValue; }
432  fpreal getPreSlope() const { return myPreSlope; }
433  CL_ChannelBehavior getPreType() const { return myPreType; }
434 
435  fpreal getPostValue() const { return myPostValue; }
436  fpreal getPostSlope() const { return myPostSlope; }
437  CL_ChannelBehavior getPostType() const { return myPostType; }
438 
441 
442  SYS_DEPRECATED(20.0)
443  void setTolerance(fpreal tolerance) { myTolerance = tolerance; }
444 
445 
446  // map collection time to channel time...
447  inline fpreal localTime(fpreal t) const { return (t-myStart); }
448 
449  // map channel time to global time...
450  inline fpreal globalTime(fpreal t) const { return t + myStart; }
451 
452  fpreal getStart() const { return myStart; }
453  fpreal getEnd() const { return myStart + myLength; }
454  fpreal getLength() const { return myLength; }
455  void setStart(fpreal start) { myStart = start; }
456 
457  /// Returns the number of segments including the end segment
458  int getNSegments() const { return mySegments.size(); }
459 
460  UT_Array<fpreal> getKeyTimes() const;
461  UT_Array<fpreal> getKeyValues(CL_KeyHalf half = CL_KeyHalf::InOut) const;
462  UT_Array<fpreal> getKeySlopes(CL_KeyHalf half = CL_KeyHalf::InOut) const;
463  UT_Array<fpreal> getKeyAccels(CL_KeyHalf half = CL_KeyHalf::InOut) const;
464 
465  /// Returns the start and end global times of the first and last keys.
466  /// This is different than myStart and myStart+myLength because myStart
467  /// is set to 0.0 almost all the time.
468  /// Returns true and a valid range if there is at least one key.
469  /// Returns false if there is no key and start and end get the myStart value.
470  bool getKeyTimeRange(fpreal &start, fpreal &end) const;
471 
472  void setKeys(const UT_Array<fpreal> *values = nullptr,
473  const UT_Array<fpreal> *slopes = nullptr,
474  const UT_Array<fpreal> *accels = nullptr,
476  void setKeyValues(const UT_Array<fpreal> &values,
478  void setKeySlopes(const UT_Array<fpreal> &slopes,
480  void setKeyAccels(const UT_Array<fpreal> &accels,
482 
483  bool getSurroundingSegs(fpreal gtime, CL_SimpleSegment *&left,
485 
486  bool getSurroundingSegs(fpreal gtime, const CL_SimpleSegment *&left,
487  const CL_SimpleSegment *&right) const;
488 
489  /// Shift the specified keys by the given time offsets.
490  /// Time offsets must either match the size of indices, or be an array
491  /// of 1 element to shift all keys by the same offset.
492  bool moveKeysWithDeltas(const UT_IntArray &indices,
493  const UT_Array<fpreal> &time_offsets);
494 
495  /// Move a list of keys using a list of time offset and value offsets.
496  /// Do the same as CHmoveKeysWithDeltas for CH_Channel
497  void moveKeysWithDeltas(
498  const UT_Array<fpreal> &key_times,
499  const UT_Array<fpreal> &time_offsets,
500  const UT_Array<fpreal> &value_offsets);
501 
502  void smoothAutoSlopesForSegments(
503  UT_RLEBitArray &slope_flags,
504  bool force = false,
505  fpreal max_delta = -1);
506 
507  void smoothAutoSlopes(bool force = false);
508 
509  /// inserts a key at gtime and destroys all keys before it.
510  /// does nothing if gtime is before the channel start.
511  void trimStart(float gtime);
512  /// inserts a key at gtime and destroys all keys after it.
513  /// does nothing if gtime is after the channel end.
514  void trimEnd(float gtime);
515 
516  // The following four functions are called by the CH_Manager to ensure
517  // simple channels share the same default animation preferences that
518  // regular channels do.
519  static void setChannelTolerance(fpreal tol) { theTolerance = tol; }
520  /// Set the segment type used for the first key in a channel
521  static void setDefaultSegmentType(CL_SimpleSegmentType type);
522  /// Set the segment type used when splitting a segment if auto split is
523  /// false
524  static void setDefaultSegmentSplitType(CL_SimpleSegmentType type);
525  /// Set the segment type behaviour when splitting a segment. If true,
526  /// The type of the split segment will be applied to the new segment,
527  /// otherwise, theDefaultSplitSegmentType will be used
528  static void setAutoSplit(bool onoff);
529 
530  static fpreal getChannelTolerance() { return theTolerance; }
531 
533  { return theDefaultSegmentType; }
534 
536  { return theDefaultSplitSegmentType; }
537 
538  static bool getAutoSplit() { return theAutoSplit; }
539 
540 private:
541  static fpreal theTolerance;
542  static constexpr fpreal theDefaultAccelRatio = 1.0 / 3.0;
543  static CL_SimpleSegmentType theDefaultSegmentType;
544  static CL_SimpleSegmentType theDefaultSplitSegmentType;
545  static bool theAutoSplit;
546 
547  // should be kept in sync with CH_Segment::getAccelFromRatio
548  static fpreal getAccelFromRatio(fpreal slope, fpreal ratio,
549  fpreal length)
550  {
551  if( length==0.0 )
552  length = 1.0;
553  return length * ratio * SYSsqrt( slope*slope + 1 );
554  }
555 
556  // These methods are adapted from CH_Segment::clamp{In,Out}Accel. They
557  // serve as an alternative to the clamp_slopes option in
558  // CL_Bezier::fromSegmentValues, clamping the acceleration instead of the
559  // slope.
560  /// Clamp a SegmentValues' in acceleration to fix a curve that would
561  /// back in on itself.
562  static fpreal clampSegmentValuesInAccel(const CL_SegmentValues &sv,
563  bool is_end_segment);
564  /// Clamp a SegmentValues' out acceleration to fix a curve that would
565  /// back in on itself.
566  static fpreal clampSegmentValuesOutAccel(const CL_SegmentValues &sv,
567  bool is_end_segment);
568 
569  bool extend(fpreal t, int &i, fpreal &ret) const;
570 
571  void splitSegment(fpreal gtime, bool auto_slope = true);
572  /// Change a segment's length, preserving its start time and in/out slopes
573  void changeSegmentLength(int index,
574  fpreal new_length,
575  bool scale_accels = true);
576 
577  // Methods for manipulating the segments array.
578  // Note that the following 4 functions do not change the segment data,
579  // But rather just ensure that the various arrays (segment, expression,
580  // in/out slope) are kept in sync when segments are moved.
581  // It is up to the caller to ensure that the segment values/times are
582  // correct when calling these methods.
583  void appendSegment(const CL_SimpleSegment &segment,
584  const UT_StringHolder &expr,
585  bool auto_slope);
586  void insertSegment(int index,
587  const CL_SimpleSegment &segment,
588  const UT_StringHolder &expr,
589  bool auto_slope);
590  void removeSegment(int index);
591 
592  CL_SegmentValues getValuesFromSegment(CL_SimpleSegment &segment);
593  void setSegmentFromValues(CL_SimpleSegment &segment,
594  const CL_SegmentValues &sv,
595  bool clamp_slopes = true);
596 
597  /// Call removeRange on the segment arrays
598  /// end_index is inclusive unlike UT_Array::removeRange.
599  void removeSegments(int start_index, int end_index);
600 
601  /// Recompute the bezier coeffs for each segment, in the given range
602  void recomputeBezierCoeffs(int start_index = 0, int end_index = -1);
603  void recomputeBezierCoeffs(CL_SimpleSegment &segment);
604 
605  /// Sets the extra data for the segment, based on its type.
606  void setSegmentExtraData(CL_SimpleSegment &segment);
607 
608  /// Moves a key/segment by the given time delta.
609  /// Requires that the new time does NOT have a key at it already
610  void shiftKey(int index, fpreal t, bool recompute_coeffs = true);
611 
612  /// Returns whether or not a segment is an end segment (ie, has length == 0)
613  bool isEndSegment(const CL_SimpleSegment &segment) const;
614 
615  // Compact array of segments.
616  // This data layout currently works well when evaluating a single channel
617  // many times across its whole time range.
618  // We might have to change the data layout to be more efficient
619  // at evaluating many channels at the same global time.
620  // This could involve a page system where segments from the same time range
621  // are from the same area in a memory pool.
622  UT_Array<CL_SimpleSegment> mySegments;
623 
624  // Custom expressions for each segment with a type of CUSTOM.
625  // Stored for purposes of round-tripping back to CH_Channel only - these
626  // segments will still be evaluated as Beziers here.
627  UT_Array<UT_StringHolder> mySegmentExpressions;
628 
629  // Whether the in/out slope for each segment is auto calculated or not
630  // Stored for purposes of round-tripping back to a CH_Channel. These
631  // are currently not used when setting the key value of a simple channel.
632  // TODO(michaelf): Do we want to support auto-slope calculation when setting
633  // keys of simplechannels?
634  UT_Array<bool> mySegmentInSlopesAuto;
635  UT_Array<bool> mySegmentOutSlopesAuto;
636 
637  fpreal myTolerance; // Global floating point tolerance.
638  fpreal myLength; // Channel Length in time.
639  fpreal myStart; // Channel Start global time.
640 
641  // Constant value to be used if the channel is empty.
642  fpreal myDefaultValue;
643  // Precomputed values for pre/post extend.
644  fpreal myPreValue;
645  fpreal myPostValue;
646 
647  // Precomputed slope (or extra) for pre/post extend.
648  fpreal myPreSlope;
649  fpreal myPostSlope;
650 
651  // Pre/right types, used by extend()
652  CL_ChannelBehavior myPreType;
653  CL_ChannelBehavior myPostType;
654 };
655 
656 #endif
type
Definition: core.h:556
const UT_Array< CL_SimpleSegment > & getSegments() const
fpreal getPostSlope() const
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
GLenum GLint * range
Definition: glcorearb.h:1925
#define SYS_DEPRECATED(__V__)
GA_API const UT_StringHolder accel
imath_half_bits_t half
if we're in a C-only context, alias the half bits type to half
Definition: half.h:266
void
Definition: png.h:1083
GLint left
Definition: glcorearb.h:2005
GLboolean * data
Definition: glcorearb.h:131
const UT_Array< UT_StringHolder > & getSegmentExpressions() const
const GLdouble * v
Definition: glcorearb.h:837
CL_ChannelBehavior getPreType() const
GLuint start
Definition: glcorearb.h:475
int getNSegments() const
Returns the number of segments including the end segment.
GLsizei const GLfloat * value
Definition: glcorearb.h:824
void setPostType(CL_ChannelBehavior type)
GLdouble right
Definition: glad.h:2817
static CL_SimpleSegmentType getDefaultSegmentType()
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
UT_StringHolder getSegmentExpression(int index) const
void setPreType(CL_ChannelBehavior type)
GLint y
Definition: glcorearb.h:103
fpreal getLength() const
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:819
void setStart(fpreal start)
fpreal getEndValue() const
constexpr auto in(type t, int set) -> bool
Definition: core.h:611
GLdouble GLdouble x2
Definition: glad.h:2349
UT_SharedPtr< const CL_SimpleChannel > CL_SimpleChannelConstPtr
CL_SimpleSegmentType
const CL_SimpleSegment & getSegment(int index) const
void setType(CL_SimpleSegmentType type)
#define CL_API
Definition: CL_API.h:10
fpreal getEnd() const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
void setDefaultValue(fpreal value)
fpreal * getExtraData()
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
int getSegmentInSlopeAuto(int index) const
void setSegmentInSlopeAuto(int index, bool value)
fpreal getStart() const
GLuint GLuint end
Definition: glcorearb.h:475
void setSegmentOutSlopeAuto(int index, bool value)
void setSegmentExpression(int index, const UT_StringHolder &expr)
fpreal localTime(fpreal t) const
fpreal getTolerance() const
CL_KeyHalf
void setExtraData(int index, fpreal data)
void setPreSlope(fpreal slope)
HUSD_API bool eval(VtValue &val, T &ret_val)
fpreal getEnd() const
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
CL_SimpleSegmentType getType() const
fpreal getDefaultValue() const
GLdouble t
Definition: glad.h:2397
GLfloat v0
Definition: glcorearb.h:816
CL_ChannelBehavior
Definition: CL_Types.h:18
void setPreValue(fpreal value)
UT_SharedPtr< CL_SimpleChannel > CL_SimpleChannelPtr
static CL_SimpleSegmentType getDefaultSegmentSplitType()
fpreal getLength() const
fpreal evalP(fpreal u) const
SIM_API const UT_StringHolder force
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
static void setChannelTolerance(fpreal tol)
fpreal64 fpreal
Definition: SYS_Types.h:278
CL_ChannelBehavior getPostType() const
fpreal getPreValue() const
static fpreal getChannelTolerance()
LeafData & operator=(const LeafData &)=delete
void setPostSlope(fpreal slope)
GLuint index
Definition: glcorearb.h:786
GLfloat GLfloat v1
Definition: glcorearb.h:817
fpreal globalTime(fpreal t) const
int getSegmentOutSlopeAuto(int index) const
fpreal getPreSlope() const
fpreal getStart() const
void OIIO_UTIL_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
fpreal getPostValue() const
static bool getAutoSplit()
CL_SimpleSegment & getSegment(int index)
Definition: format.h:1821
void setPostValue(fpreal value)
fpreal getStartValue() const