Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Oeser <info@graphics-engineer.com>2021-01-12 17:14:48 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2021-04-06 12:06:24 +0300
commite71408d0d7dea93304476fb6a92e92fb469f73af (patch)
treea60c11e64f2ed5dbbab4c5ddcac8a66e9f5e1fb6 /source/blender/makesrna/intern/rna_object_force.c
parent7334c481c03d0b89810925495cec3620760fc7c3 (diff)
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
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_force.c')
-rw-r--r--source/blender/makesrna/intern/rna_object_force.c7
1 files changed, 7 insertions, 0 deletions
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);
}