Commit Graph

300 Commits

Author SHA1 Message Date
Campbell Barton 2d589e8549 Math Lib: avoid char > int conversion w/ line plot 2016-09-02 02:54:16 +10:00
Germano Cavalcante b01a56ee5c Transform Snap: Optimize edge-snap using BVH tree
changes in BLI_kdopbvh:

- `BLI_bvhtree_find_nearest_to_ray` now takes is_ray_normalized and scale argument.
- `BLI_bvhtree_find_nearest_to_ray_angle` has been added (use for perspective view).

changes in BLI_bvhutils:

- `bvhtree_from_editmesh_edges_ex` was added.

changes in math_geom:

- `dist_squared_ray_to_seg_v3` was added.

other changes:

- `do_ray_start_correction` is no longer necessary to snap to verts.
- the way in which the test of depth was done before is being simulated in callbacks.
2016-06-30 17:52:03 +10:00
Joshua Leung 14f056144e Bendy Bones Instability Fix - Second Attempt
So the error seems to be in cubic_tangent_factor_circle_v3(),
which was introduced with D2001.

I've tweaked the most obvious culprit here - the epsilon factor.
It used to be 10^-7, but I've reduced it down to 10^-5 now,
and it's looking a lot more stable now :)

---------

BTW, about the derivation of the magic 0.390464 factor I briefly subbed back
as a workaround for this bug, see:
    http://www.whizkidtech.redprince.net/bezier/circle/
2016-06-28 02:52:20 +12:00
Campbell Barton c7a6ff0981 Docs: arg names 2016-06-27 13:21:14 +10:00
Campbell Barton a17cba339c BLI_math: Add function to calculate circular cubic curve tangents 2016-05-23 21:35:54 +10:00
Campbell Barton 8ed746683a Remove redundant abs ray/line point functions 2016-04-14 13:04:35 +10:00
Campbell Barton 416064cd5b Math Lib: ray_point_factor_v3 functions
Gives a bit better precision than creating a line in some cases,
use for ED_view3d_win_to_3d.
2016-04-14 12:00:16 +10:00
Campbell Barton 50f9681e15 Docs: comment on line-sphere intersection 2016-04-10 22:46:12 +10:00
Campbell Barton da9f0a507c Minor improvement to last commit
Sign is known in this case, no need  to check for either direction.
2016-03-12 01:12:51 +11:00
Campbell Barton 8accc19d5d Math Lib: less complex convex quad check 2016-03-11 23:41:50 +11:00
Campbell Barton 4e500101a7 Cleanup: quiet -Wcomma, cast to void where needed 2016-03-05 09:16:12 +11:00
Germano Cavalcante 86725667d4 Cleanup: naming for NearestRayToAABB_Precalc 2016-02-11 18:21:10 +11:00
Campbell Barton b336124a13 Correct commented printfs 2016-01-26 09:08:40 +11:00
Germano Cavalcante bfabb9d3c5 Math Lib: Add dist_squared_ray_to_aabb_v3 utility 2016-01-25 19:01:42 +11:00
Campbell Barton 90293a8da3 Math Lib: optimize segment-plane clipping
Calculate the clipped min/max factor along the segment,
only applying to the coordinates at the end (will give better precision too).

Also make split input/output args.
2016-01-23 13:48:31 +11:00
Campbell Barton 18ffeb689d error in last commit 2016-01-20 17:09:18 +11:00
Campbell Barton e25b113694 Cleanup: naming convention
Follow isect_ray_tri_watertight_v3 naming.
2016-01-20 17:03:10 +11:00
Campbell Barton e830334357 Math Lib: use x-span for fill_poly_v2i_n callback
Instead of running the callback per-pixel,
pass the x-span to the callback.
2016-01-08 23:35:34 +11:00
Campbell Barton 36f916f200 Math Lib: clamp closest_to_line_segment_v# when segment has no length
For a line this makes sense but segments should clamp,
avoids assert in edge-rip.
2015-12-23 22:08:15 +11:00
Campbell Barton fa3fe2ee10 Cleanup: math lib naming
Distinguish between line / line_segment
2015-12-15 18:16:41 +11:00
Campbell Barton a7c7ae5bf7 Cleanup: math lib naming
Rename not-very-descriptive (p1, d) -> (ray_origin, ray_direction)
2015-12-15 18:15:10 +11:00
Campbell Barton 87791c611d Cleanup: consistent naming for closest_to_line api 2015-12-15 17:49:31 +11:00
Campbell Barton becc85c5d4 Math Lib: 2d ray-segment intersection function 2015-12-11 11:27:00 +11:00
Campbell Barton 8c453b5995 Remove redundant zero area face check 2015-12-03 22:45:33 +11:00
Campbell Barton a4e151704f Fix isect_point_tri_v3 w/ degenerate faces
Ensure point_in_slice returns false when zero area faces are passed.
2015-12-03 22:37:46 +11:00
Campbell Barton a7ac59414b Cleanup: rename line to segments, avoids confusion
Differentiate between lines and segments.
2015-11-13 07:48:05 +11:00
Sergey Sharybin 0d54aa9c02 Fix T46521: Python: bvh.ray_cast doesn't find a plane facing in the other direction under certain circumstances
The issue was caused by wrong sign check. It originally came from more optimized
Cycles code where because of other reasons it wasn't visible yet. But in fact it
should be solved there as well.
2015-10-22 20:34:51 +05:00
Campbell Barton 99142ec7e0 BLI_math: isect_ray_plane_v3 now takes 4d plane
Was taking a triangle and doing ray-tri intersect.
2015-10-16 03:06:12 +11:00
Campbell Barton b333a7570f Cleanup: spelling 2015-10-07 15:02:06 +11:00
Campbell Barton 9a62164d94 Cleanup: indentation 2015-09-22 15:02:11 +10:00
Campbell Barton b8e0b2db56 Math Lib: isect_plane_*_v3 avoid negation
Unmeasurable speedup for plane intersection.
2015-09-05 17:44:02 +10:00
Campbell Barton ba188cf98d Math Lib: simplify isect_plane_plane_v3
Unlike the 3 plane method, the 2 planes squared cross-product _is_ the determinant.
2015-09-05 17:10:07 +10:00
Campbell Barton 39752eb912 Fix for isect_tri_tri_epsilon_v3 w/ small faces
tris with ~1e-05 edge lengths would fail
2015-09-04 22:29:12 +10:00
Campbell Barton 1d71ad2eaa Math Lib: Use plane intersect from graphics-gems 2015-09-04 22:13:20 +10:00
Campbell Barton d0e7ba3fd1 Math Lib: avoid sqrt w/ triangle intersection 2015-09-04 22:06:36 +10:00
Campbell Barton 2ea96df159 Correct own error in line_point_factor
Passing zero epsilon allowed divide by zero.
2015-09-04 22:06:36 +10:00
Campbell Barton 54ad576666 Small tri intersect fails when not normalized
Logic was ok, but would run into precision issues.
2015-09-04 01:59:44 +10:00
Campbell Barton a603a3470c Revert fix for T45849 (part 2, tsk!) 2015-08-31 22:47:14 +10:00
Campbell Barton 06b14aa5f9 error in comments 2015-08-31 22:26:05 +10:00
Campbell Barton 6a53e658d3 Alternate fix for T45849: tri-tri intersect error
Project both triangles onto the same plane to simplify calculations.
2015-08-31 22:15:27 +10:00
Campbell Barton e503e37333 Revert fix for T45849, alternate fix coming up
epsilon check here didn't account for scale, causing T45919
2015-08-31 22:12:19 +10:00
Campbell Barton 96fa58e22c Math Lib: Add closest_to_plane helper functions
- closest_to_plane3 (for float3 planes)
- closest_to_plane*_normalized_v3 (for unit length planes)

Use when the plane is known to be unit length
2015-08-31 20:10:36 +10:00
Campbell Barton 50917edad5 Fix T45853: Edge-slide UV-correct jitter 2015-08-25 22:57:03 +10:00
Campbell Barton e7775833a7 Math Lib: Use same logic for 2d/3d functions
dist_squared_to_line_v2, dist_to_line_v2
2015-08-23 19:10:37 +10:00
Campbell Barton 0cb23fafe7 Math Lib: minor optimization interp_weights_poly 2015-08-23 17:07:35 +10:00
Campbell Barton 58c9a0b11a Cleanup: spelling 2015-08-22 21:17:32 +10:00
Campbell Barton c1c07b68b8 Use epsilon for line-intersect collinear test
Also remove 2x vector normalize since other parts of the code already check this.

Fixes T45849
2015-08-22 21:12:46 +10:00
Campbell Barton 71919efd78 Math Lib: watertight intersection function
From Cycles with some very minor differences.
2015-08-21 17:45:04 +10:00
Campbell Barton a6457f283e Cleanup: comment out isect_ray_tri_threshold_v3
Also define epsilon var for ray-cast functions.
2015-08-20 12:50:39 +10:00
Campbell Barton cd8581af8e Fix T45706: Axis aligned tri-tri intersection 2015-08-19 12:20:39 +10:00