8#ifndef PXR_BASE_TS_REGRESSION_PREVENTER_H
9#define PXR_BASE_TS_REGRESSION_PREVENTER_H
12#include "pxr/base/ts/api.h"
13#include "pxr/base/ts/types.h"
14#include "pxr/base/ts/knot.h"
15#include "pxr/base/ts/knotData.h"
20PXR_NAMESPACE_OPEN_SCOPE
45 enum TS_API InteractiveMode
49 ModeLimitActive = 100,
70 bool preActiveAdjusted =
false;
71 TsTime preActiveAdjustedWidth = 0;
72 bool preOppositeAdjusted =
false;
73 TsTime preOppositeAdjustedWidth = 0;
77 bool postActiveAdjusted =
false;
78 TsTime postActiveAdjustedWidth = 0;
79 bool postOppositeAdjusted =
false;
80 TsTime postOppositeAdjustedWidth = 0;
84 std::string GetDebugDescription(
int precision = 6)
const;
98 TsTime activeKnotTime,
108 TsTime activeKnotTime,
109 InteractiveMode mode,
147 const TsKnot &proposedActiveKnot,
151 friend struct Ts_RegressionPreventerBatchAccess;
156 _ModeNone = TsAntiRegressionNone,
157 _ModeContain = TsAntiRegressionContain,
158 _ModeKeepRatio = TsAntiRegressionKeepRatio,
159 _ModeKeepStart = TsAntiRegressionKeepStart,
160 _ModeLimitActive = ModeLimitActive,
161 _ModeLimitOpposite = ModeLimitOpposite
167 TsTime activeKnotTime,
184 const TsKnot &originalKnot);
187 void RestoreOriginal();
191 void RemoveCurrent();
202 const TsKnot originalKnot;
205 Ts_KnotData currentParams;
211 struct _WorkingKnotState
218 _KnotState *parentState,
219 const TsKnot &proposedKnot);
225 _KnotState *parentState);
231 const Ts_KnotData &originalParams);
235 void WriteProposed();
243 _KnotState*
const parentState;
246 const TsKnot proposedKnot;
249 const Ts_KnotData proposedParams;
252 Ts_KnotData workingParams;
268 WhichSegment whichSegment,
270 _WorkingKnotState *activeKnotState,
271 _WorkingKnotState *oppositeKnotState,
281 bool _AdjustWithContain();
282 bool _AdjustWithKeepRatio();
283 bool _AdjustWithKeepStart();
284 bool _AdjustWithLimitActive();
285 bool _AdjustWithLimitOpposite();
290 TsTime _GetProposedActiveWidth()
const;
291 TsTime _GetProposedOppositeWidth()
const;
292 void _SetActiveWidth(TsTime width);
293 void _SetOppositeWidth(TsTime width);
297 TsTime _GetProposedStartWidth()
const;
298 TsTime _GetProposedEndWidth()
const;
299 void _SetStartWidth(TsTime width);
300 void _SetEndWidth(TsTime width);
303 TsTime _GetSegmentWidth()
const;
306 const WhichSegment _whichSegment;
308 _WorkingKnotState*
const _activeKnotState;
309 _WorkingKnotState*
const _oppositeKnotState;
310 SetResult*
const _result;
316 const TsKnot &proposedActiveKnot,
317 SetResult *resultOut)
const;
318 void _HandleInitialAdjustment(
319 const TsKnot &proposedActiveKnot,
320 SetResult* resultOut);
321 void _HandleTimeChange(TsTime proposedActiveTime);
323 const TsKnot &proposedActiveKnot,
325 SetResult* resultOut);
333 bool _initialAdjustmentDone;
335 std::optional<_KnotState> _activeKnotState;
336 std::optional<_KnotState> _preKnotState;
337 std::optional<_KnotState> _postKnotState;
338 std::optional<_KnotState> _overwrittenKnotState;
342struct Ts_RegressionPreventerBatchAccess
347 static bool IsSegmentRegressive(
348 const Ts_KnotData *startKnot,
349 const Ts_KnotData *endKnot,
350 TsAntiRegressionMode mode);
354 static bool ProcessSegment(
355 Ts_KnotData *startKnot,
356 Ts_KnotData *endKnot,
357 TsAntiRegressionMode mode);
361PXR_NAMESPACE_CLOSE_SCOPE
A knot belonging to a TsSpline.
Details of the result of an interactive Set call.
bool havePostSegment
If there is a post-segment, what adjustments were made to it.
bool havePreSegment
If there is a pre-segment, what adjustments were made to it.
bool adjusted
Whether any adjustments were made.
An authoring helper class that enforces non-regression in splines.
TS_API TsRegressionPreventer(TsSpline *spline, TsTime activeKnotTime, bool limit=true)
Constructor for interactive use (repeated calls to Set).
TS_API TsRegressionPreventer(TsSpline *spline, TsTime activeKnotTime, InteractiveMode mode, bool limit=true)
Same as the above, but with an InteractiveMode.
TS_API bool Set(const TsKnot &proposedActiveKnot, SetResult *resultOut=nullptr)
Set an edited version of the active knot into the spline, adjusting tangent widths if needed,...
A mathematical description of a curved function from time to value.