Does anyone know if there have been any significant changes to the mathutils.geometry.intersect_point_line code (or code that it relies on) between Blender 2.83 and 2.9? I’ve done a search on Github and can’t see any particularly recent changes.
I’m running a simple piece of code to check whether a point of intersection actually lies on an edge. It works consistently in 2.83 but seems to fail frequently in 2.9.
My guess is that the failure is due to something else in the API or Blender itself having changed. Mind sharing the code?
Thanks Joseph. I agree with you, just finding it really hard to track down. I’ve put some of the code below. I’ve tried to edit as much as I can so that it makes sense outside of my main code. Let me know if you think any other info would be useful.
…This is from the calling function which simply takes a 2d vector (mouse location), converts to a 3D point and checks to see if it intersects with a given edge (defined as two vector3s), if there’s an intersection I return that value as co and check to see if co is actually on the edge, which is where I’m getting False returned often in Blender 2.9 where I’d normally get True in 2.83. It’s difficult to test because there’s no error returned, I’m simply getting far more False values from Blender 2.9 than 2.83, for the same check.
depth_location = return_furthest_point_in_view(ray_origin, sg.w_loc, sg.w_loc)
pt3d = region_2d_to_location_3d(region, rv3d, pt, depth_location)
# w_loc is an edge (2x vector3)
# draw ray from pt3d from ray_origin and see if intersects with edge
co = clg.find_edge_edge_intersection_verts(
[ray_origin, pt3d, w_loc, w_loc]
if clg.point_on_edge(co, [w_loc, w_loc]):
These are the supporting functions
# returns true if point lies on edge
def point_on_edge(pt, edge):
p, _percent = intersect_point_line(pt, *edge)
on_line = (pt - p).length < 1.0e-5
return on_line and (0.0 <= _percent <= 1.001)
# check edge edge intersection from vertex coords
l_is = intersect_line_line(verts, verts, verts, verts)
if not l_is:
return (l_is + l_is) / 2