Commit Graph

38 Commits

Author SHA1 Message Date
Campbell Barton d94d7a5d8f Cleanup: update curve_fit_nd (no functional changes) 2022-06-29 09:55:44 +10:00
Campbell Barton af2be110c3 Fix T72402: Decimate f-curves fails with co-linear key-frames 2019-12-24 12:20:34 +11:00
Campbell Barton 6478f90cc2 curve_fit_nd: fix assert caused by too small epsilon
Curve decimate would assert in some cases.
2019-04-12 01:01:49 +10:00
Campbell Barton 7d792976e1 doxygen: update doxygen & add balembic group 2019-02-18 11:23:40 +11:00
Campbell Barton bf8f5f5142 Cleanup: doxygen comments 2018-03-14 02:08:07 +11:00
Campbell Barton 560fa6db17 Curve Fitting: heap reinsertion optimization 2017-10-29 16:33:44 +11:00
Campbell Barton b425e94381 Correct accidental variable declaration 2017-08-01 07:55:01 +10:00
Campbell Barton 47769b5f40 Curve Fitting: minor change to re-fitting method
Avoid calculating a new split-index when re-fitting.

While checking if a knot can be removed, the index with the highest error
can be used as a candidate to replace the knot
(in the case it can't be removed).
2017-04-30 00:01:16 +10:00
Campbell Barton 6dd87f2abb Curve Fitting: re-fitting heap pre-allocated too much 2016-09-25 12:19:43 +10:00
Campbell Barton 6b5ad4a4d7 Curve Fitting: 'offset' method used sign when it shouldn't 2016-09-25 12:19:42 +10:00
Campbell Barton 05dbd65098 Curve Fitting: inline dot-product (avoid temp vector) 2016-09-25 12:19:42 +10:00
Campbell Barton d9b242f5fb Curve Fitting: de-duplicate cubic evaluation 2016-09-25 12:19:42 +10:00
Campbell Barton ff57589afc Curve Fitting: correct initial handle sign
In practice the initial values are almost never used.
2016-09-02 02:58:34 +10:00
Campbell Barton a8b3ff9e16 Curve Fitting: fix off by one error
In practice this wasn't likely to cause problems, but better fix.
2016-08-05 18:50:49 +10:00
Campbell Barton e1a4219523 Curve Fitting: sync with upstream
Correct accidental float use
2016-08-05 08:36:17 +10:00
Campbell Barton 3fe7aacdf7 Curve Fitting: circular fit could give NAN handles
Fitting lines that exactly double back on themselves could give NAN length handles.
2016-07-31 13:58:14 +10:00
Campbell Barton 3673a5adba Curve Fitting: Use normalized projection function 2016-07-28 18:33:14 +10:00
Campbell Barton d60acd0e94 Fix crash fitting single point curve 2016-07-28 14:37:55 +10:00
Campbell Barton 4da8543d0d Resolve undefined M_PI w/ MSVC2013 2016-07-26 05:28:13 +10:00
Campbell Barton a4db868092 Resolve build error on OSX 2016-07-25 20:30:24 +10:00
Campbell Barton f4cb6d45d5 Error in curve update, uninitialized var use 2016-07-25 15:12:46 +10:00
Campbell Barton 2418daede5 Curve Fitting: Add alternate 'refit' method
This is an alternative method for fitting a curve which incrementally simplifies the curve, then re-fits.

Generally gives better results, also improves corner detection.
2016-07-25 14:55:08 +10:00
Campbell Barton abb9d0b0ad Curve Fitting: add high-quality flag
When this flag is set - even when the curve error is under the threshold,
keep attempting a better fit.

Enable this for freehand drawing, since it gives nicer results and isn't noticeably slower.
2016-06-14 02:27:32 +10:00
Campbell Barton 2033f47e55 Curve Fitting: offset based fallback to calculate cubics
Add a new fallback method that uses offset distance from the curve to the line between both points,
for freehand drawing it typically only fives minor improvements (1-3% fewer points),
for curve dissolve the improvements are more noticeable.
2016-06-12 22:25:43 +10:00
Campbell Barton 2b02e03973 Cleanup: simplify checks calculating tangents 2016-05-17 02:18:11 +10:00
Campbell Barton a1a640f614 Curve Fitting: correct circular tangent length calculation
Method for scaling is still not perfect but quite close.
2016-05-16 07:45:50 +10:00
Joshua Leung d4ed5c398e A "better" (?) fix for msvc silliness - used in one other place in all of Blender 2016-05-09 01:46:18 +12:00
Joshua Leung e43ee5563b Fix compiling on MSVC - M_PI undefined 2016-05-09 01:31:13 +12:00
Campbell Barton e5b4e6b0a3 Clamp dot-product to avoid precision error
Would only happen in degenerate cases.
2016-05-08 00:04:05 +10:00
Campbell Barton a3b42d638b Cleanup: whicespace 2016-05-07 23:58:04 +10:00
Campbell Barton 68e856da03 Curve Fitting: better fallback when least-square solution fails
Take curvature into account when calculating handle length.

Gives significantly better results for curve dissolve and 10-20% more efficient freehand drawing.
2016-05-07 21:48:00 +10:00
Campbell Barton d2296cd5ec Fix error copying cubic data 2016-05-07 21:38:48 +10:00
Campbell Barton 9b8bf57361 Curve Fitting: avoid clamping fallback handles. 2016-05-05 20:31:13 +10:00
Campbell Barton ec9cb57b01 Curve Fitting: expose function for fitting a single curve 2016-05-02 18:50:04 +10:00
Campbell Barton b1f6cd5a6a Slight adjustment to curve fitting tangents
Don't let the point spacing give bias to a side.
2016-04-30 16:27:43 +10:00
Campbell Barton 2ca4d21976 Cleanup: rename cos-angle to match BLI_math 2016-04-20 07:50:48 +10:00
Campbell Barton 8ac662c77a New freehand curve drawing tool
- Access with Shift-LMB or from the 'Create' toolbar tab.
- Uses curve fitting for bezier curves, with error and corner angle options.
- Optional tablet pressure to curve radius mapping.
- Depth can use the cursor or optionally draw onto the surface,
  for the entire stroke or using the stroke start.
- Stroke plane can optionally be perpendicular to, or aligned to the surface normal.
- Optional radius tapering and for start/end points.
- Supports operator redo and calling from Python.
2016-04-15 20:36:38 +10:00
Campbell Barton e56e7bd1ec Add lib for n-dimensional cubic curve fitting
This will be used for calculating bezier curves from freehand drawing,
may be used for other areas too.

Original code from GraphicsGems, 1990 (FitCurve.c),
with updates from OpenToonz, under 3 clause BSD license.
with own minor modifications for integration with Blender:
- support adding extra custom-data.
- improved handle clamping.
2016-04-15 20:33:58 +10:00