[Bf-blender-cvs] [e71408d0d7d] master: Fix T84623: Curve/Surface force not working in normal direction

Philipp Oeser noreply at git.blender.org
Tue Apr 6 11:11:16 CEST 2021


Commit: e71408d0d7dea93304476fb6a92e92fb469f73af
Author: Philipp Oeser
Date:   Tue Jan 12 15:14:48 2021 +0100
Branches: master
https://developer.blender.org/rBe71408d0d7dea93304476fb6a92e92fb469f73af

Fix T84623: Curve/Surface force not working in normal direction

Tweaking e.g. a field strength would then not use the curve/surface
normal anymore [but the object center instead].

If a curve has a forcefield with effector shape Curve (in code its shape
is PFIELD_SHAPE_SURFACE then), it wil get a SurfaceModifier.

Changing properties will free the SurfaceModifierData's bvhtree and mesh
And these dont get copied along when doing the CoW copy, these are
explicitly set to NULL. So this was also failing for meshes, not just
curves.

Without the mesh & bvhtree though, get_effector_data() will not set the
EffectorData's normal correctly (it is closest_point_on_surface() which
does this). And without the right EffectorData's normal, the effector
will of course work unexpected.

Going in and out of editmode made this work because that goes down this
route:
- BKE_object_handle_data_update
- BKE_displist_make_curveTypes
- do_makeDispListCurveTypes
- curve_calc_modifiers_post
-- BKE_mesh_new_nomain_from_curve_displist
-- we then have our desired updated mesh from the curve
-- this will also call the SurfaceModifiers deformVerts [which - given we
have a valid mesh - will update the bvhtree properly]

Also note that _animating_ the effector actually works, (have not done
the deep dive why this works, assume the curve geometry is updated in
this case)

So, now just carefully tag the curve ID_RECALC_GEOMETRY in
rna_FieldSettings_update for this specific case.

Maniphest Tasks: T84623

Differential Revision: https://developer.blender.org/D10092

===================================================================

M	source/blender/makesrna/intern/rna_object_force.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c
index 14dd8a68fee..488f177946a 100644
--- a/source/blender/makesrna/intern/rna_object_force.c
+++ b/source/blender/makesrna/intern/rna_object_force.c
@@ -648,6 +648,13 @@ static void rna_FieldSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scene),
       ob->pd->tex = NULL;
     }
 
+    /* In the case of specific forcefields that are using the EffectorData's normal, we need to
+     * rebuild mesh and bhvtree for SurfaceModifier to work correctly. */
+    if (ELEM(ob->pd->shape, PFIELD_SHAPE_SURFACE, PFIELD_SHAPE_POINTS) ||
+        ob->pd->forcefield == PFIELD_GUIDE) {
+      DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+    }
+
     DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM);
     WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
   }



More information about the Bf-blender-cvs mailing list