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
This commit is contained in:
parent
7334c481c0
commit
e71408d0d7
Notes:
blender-bot
2023-02-14 09:02:40 +01:00
Referenced by issue #84623, Regression: Curve force with hair system late update
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue