Take the absolute value of the dot product between the reference normal and each point. That way there is not an issue if the reference normal becomes negative.
Details
- Reviewers
Hans Goudey (HooglyBoogly) Jacques Lucke (JacquesLucke) Lukas Tönne (lukastoenne) - Maniphest Tasks
- T98718: Face Is Planar Node: Rotating a plane makes it non-planar
- Commits
- rB09501c121540: Fix T98718: Face Is Planar Node Not handling Certain Conditions
rB6737f89e4916: Fix T98718: Face Is Planar Node Not handling Certain Conditions
Diff Detail
- Repository
- rB Blender
- Branch
- fix_planar (branched from master)
- Build Status
Buildable 22480 Build 22480: arc lint + arc unit
Event Timeline
This doesn't really solve the problem. The issue is that the dot product as it stands will calculate distance from the object center wrt. the optimal plane. Instead we need to compute the distance from the polygon centroid:
diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc index c400760f902..b32f1f44beb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc @@ -63,13 +63,16 @@ class PlanarFieldInput final : public GeometryFieldInput { const int loops = mesh->mpoly[i_poly].totloop; Span<MLoop> poly_loops(&mesh->mloop[loopstart], loops); float3 reference_normal = poly_normals[i_poly]; + float3 poly_center; + BKE_mesh_calc_poly_center( + &mesh->mpoly[i_poly], &mesh->mloop[loopstart], mesh->mvert, poly_center); float min = FLT_MAX; float max = FLT_MIN; for (const int i_loop : poly_loops.index_range()) { const float3 vert = mesh->mvert[poly_loops[i_loop].v].co; - float dot = math::dot(reference_normal, vert); + float dot = math::dot(reference_normal, vert - poly_center); if (dot > max) { max = dot; }
| source/blender/nodes/geometry/nodes/node_geo_input_mesh_face_is_planar.cc | ||
|---|---|---|
| 68 | The issue is probably that this is not -FLT_MAX. | |
The issue is that the dot product as it stands will calculate distance from the object center wrt. the optimal plane. Instead we need to compute the distance from the polygon centroid.
Afaik, this is wrong. You should be able to add any constant vector to vert without changing the result (so subtracting poly_center does not make a difference). Also see the discussion in D13906.
- Merge branch 'master' into fix_planar
- Use -FLT_MAX rather than FLT_MIN for initial comparison values.
You should be able to add any constant vector to vert without changing the result
You're right, i didn't realize it compares the range and not min/max separately.
