Cleanup: various minor changes BKE_object_modifier_update_subframe

- Rename `parent_recursion` to `parent_recursion_limit`.
- Use a define for the recursion default.
- Use const arguments.
This commit is contained in:
Campbell Barton
2025-08-21 12:00:55 +00:00
parent f5ba4dbfe6
commit cc553739d8
5 changed files with 37 additions and 21 deletions

View File

@@ -650,6 +650,15 @@ void BKE_object_groups_clear(Main *bmain, Scene *scene, Object *object);
*/
KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot);
/**
* The number of times to recurse parents for evaluation.
*
* NOTE(@ideasman42): This value was picked to avoid infinite recursion.
* 5 is arbitrary but changing it would change behavior in some corner cases.
* See code comments in #BKE_object_modifier_update_subframe_only_callback for details.
*/
#define OBJECT_MODIFIER_UPDATE_SUBFRAME_RECURSION_DEFAULT 5
/**
* \note this function should eventually be replaced by depsgraph functionality.
* Avoid calling this in new code unless there is a very good reason for it!
@@ -658,9 +667,9 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
bool update_mesh,
int parent_recursion,
int parent_recursion_limit,
float frame,
int type);
int /*ModifierType*/ modifier_type);
bool BKE_object_empty_image_frame_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d);
bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d);

View File

@@ -103,7 +103,7 @@ static int neighStraightX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
static int neighStraightY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
/* subframe_updateObject() flags */
#define SUBFRAME_RECURSION 5
#define SUBFRAME_RECURSION OBJECT_MODIFIER_UPDATE_SUBFRAME_RECURSION_DEFAULT
/* #surface_getBrushFlags() return values. */
#define BRUSH_USES_VELOCITY (1 << 0)
/* Brush mesh ray-cast status. */

View File

@@ -1259,8 +1259,13 @@ static void compute_obstaclesemission(Scene *scene,
* BLI_mutex_lock() called in manta_step(), so safe to update subframe here
* TODO(sebbas): Using BKE_scene_ctime_get(scene) instead of new DEG_get_ctime(depsgraph)
* as subframes don't work with the latter yet. */
BKE_object_modifier_update_subframe(
depsgraph, scene, effecobj, true, 5, BKE_scene_ctime_get(scene), eModifierType_Fluid);
BKE_object_modifier_update_subframe(depsgraph,
scene,
effecobj,
true,
OBJECT_MODIFIER_UPDATE_SUBFRAME_RECURSION_DEFAULT,
BKE_scene_ctime_get(scene),
eModifierType_Fluid);
if (subframes) {
obstacles_from_mesh(effecobj, fds, fes, &bb_temp, subframe_dt);

View File

@@ -5216,15 +5216,15 @@ static void object_cacheIgnoreClear(Object *ob, const bool state)
bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
bool update_mesh,
int parent_recursion,
float frame,
int type)
const bool update_mesh,
const int parent_recursion_limit,
const float frame,
const /*ModifierType*/ int modifier_type)
{
const bool flush_to_original = DEG_is_active(depsgraph);
ModifierData *md = BKE_modifiers_findby_type(ob, (ModifierType)type);
ModifierData *md = BKE_modifiers_findby_type(ob, ModifierType(modifier_type));
if (type == eModifierType_DynamicPaint) {
if (modifier_type == eModifierType_DynamicPaint) {
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
/* if other is dynamic paint canvas, don't update */
@@ -5232,7 +5232,7 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
return true;
}
}
else if (type == eModifierType_Fluid) {
else if (modifier_type == eModifierType_Fluid) {
FluidModifierData *fmd = (FluidModifierData *)md;
if (fmd && (fmd->type & MOD_FLUID_TYPE_DOMAIN) != 0) {
@@ -5241,16 +5241,16 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
}
/* if object has parents, update them too */
if (parent_recursion) {
int recursion = parent_recursion - 1;
if (parent_recursion_limit) {
const int recursion = parent_recursion_limit - 1;
bool no_update = false;
if (ob->parent) {
no_update |= BKE_object_modifier_update_subframe(
depsgraph, scene, ob->parent, false, recursion, frame, type);
depsgraph, scene, ob->parent, false, recursion, frame, modifier_type);
}
if (ob->track) {
no_update |= BKE_object_modifier_update_subframe(
depsgraph, scene, ob->track, false, recursion, frame, type);
depsgraph, scene, ob->track, false, recursion, frame, modifier_type);
}
/* Skip sub-frame if object is parented to vertex of a dynamic paint canvas. */
@@ -5266,7 +5266,7 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph,
LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
if (ct->tar) {
BKE_object_modifier_update_subframe(
depsgraph, scene, ct->tar, false, recursion, frame, type);
depsgraph, scene, ct->tar, false, recursion, frame, modifier_type);
}
}
/* free temp targets */

View File

@@ -101,12 +101,14 @@ void DEG_add_collision_relations(DepsNodeHandle *handle,
if (ob1 == object) {
continue;
}
if (filter_function == nullptr ||
filter_function(ob1, BKE_modifiers_findby_type(ob1, (ModifierType)modifier_type)))
if (filter_function &&
!filter_function(ob1, BKE_modifiers_findby_type(ob1, (ModifierType)modifier_type)))
{
DEG_add_object_pointcache_relation(handle, ob1, DEG_OB_COMP_TRANSFORM, name);
DEG_add_object_pointcache_relation(handle, ob1, DEG_OB_COMP_GEOMETRY, name);
continue;
}
DEG_add_object_pointcache_relation(handle, ob1, DEG_OB_COMP_TRANSFORM, name);
DEG_add_object_pointcache_relation(handle, ob1, DEG_OB_COMP_GEOMETRY, name);
}
}