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"
16#include "pxr/base/ts/segment.h"
21PXR_NAMESPACE_OPEN_SCOPE
46 enum TS_API InteractiveMode
50 ModeLimitActive = 100,
71 bool preActiveAdjusted =
false;
72 TsTime preActiveAdjustedWidth = 0;
73 bool preOppositeAdjusted =
false;
74 TsTime preOppositeAdjustedWidth = 0;
78 bool postActiveAdjusted =
false;
79 TsTime postActiveAdjustedWidth = 0;
80 bool postOppositeAdjusted =
false;
81 TsTime postOppositeAdjustedWidth = 0;
85 std::string GetDebugDescription(
int precision = 6)
const;
99 TsTime activeKnotTime,
109 TsTime activeKnotTime,
110 InteractiveMode mode,
148 const TsKnot &proposedActiveKnot,
152 friend struct Ts_RegressionPreventerBatchAccess;
157 _ModeNone = TsAntiRegressionNone,
158 _ModeContain = TsAntiRegressionContain,
159 _ModeKeepRatio = TsAntiRegressionKeepRatio,
160 _ModeKeepStart = TsAntiRegressionKeepStart,
161 _ModeLimitActive = ModeLimitActive,
162 _ModeLimitOpposite = ModeLimitOpposite
168 TsTime activeKnotTime,
185 const TsKnot &originalKnot);
188 void RestoreOriginal();
192 void RemoveCurrent();
203 const TsKnot originalKnot;
206 Ts_KnotData currentParams;
212 struct _WorkingKnotState
219 _KnotState *parentState,
220 const TsKnot &proposedKnot);
226 _KnotState *parentState);
232 const Ts_KnotData &originalParams);
236 void WriteProposed();
244 _KnotState*
const parentState;
247 const TsKnot proposedKnot;
250 const Ts_KnotData proposedParams;
253 Ts_KnotData workingParams;
269 WhichSegment whichSegment,
271 _WorkingKnotState* activeKnotState,
272 _WorkingKnotState* oppositeKnotState,
287 bool _AdjustWithContain();
288 bool _AdjustWithKeepRatio();
289 bool _AdjustWithKeepStart();
290 bool _AdjustWithLimitActive();
291 bool _AdjustWithLimitOpposite();
296 TsTime _GetProposedActiveWidth()
const;
297 TsTime _GetProposedOppositeWidth()
const;
298 void _SetActiveWidth(TsTime width);
299 void _SetOppositeWidth(TsTime width);
303 TsTime _GetProposedStartWidth()
const;
304 TsTime _GetProposedEndWidth()
const;
305 void _SetStartWidth(TsTime width);
306 void _SetEndWidth(TsTime width);
309 TsTime _GetSegmentWidth()
const;
312 const WhichSegment _whichSegment;
315 _WorkingKnotState*
const _activeKnotState;
316 _WorkingKnotState*
const _oppositeKnotState;
317 SetResult*
const _result;
323 const TsKnot &proposedActiveKnot,
324 SetResult *resultOut)
const;
325 void _HandleInitialAdjustment(
326 const TsKnot &proposedActiveKnot,
327 SetResult* resultOut);
328 void _HandleTimeChange(TsTime proposedActiveTime);
330 const TsKnot &proposedActiveKnot,
332 SetResult* resultOut);
340 bool _initialAdjustmentDone;
342 std::optional<_KnotState> _activeKnotState;
343 std::optional<_KnotState> _preKnotState;
344 std::optional<_KnotState> _postKnotState;
345 std::optional<_KnotState> _overwrittenKnotState;
348struct Ts_RegressionPreventerBatchAccess
354 static bool IsSegmentRegressive(
355 const Ts_KnotData *startKnot,
356 const Ts_KnotData *endKnot,
357 TsAntiRegressionMode mode);
361 static bool IsSegmentRegressive(
363 TsAntiRegressionMode mode);
368 static bool ProcessSegment(
369 Ts_KnotData *startKnot,
370 Ts_KnotData *endKnot,
371 TsAntiRegressionMode mode);
375 static bool ProcessSegment(
377 TsAntiRegressionMode mode);
381PXR_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.
Ts_Segment represents one section of a spline.