Fix T50938: Cache not being reset when changing simulation settings with new depsgraph
The thing i'm really starting to hate is the requirement to specify both operation code and node type. Seems to be duplicated enums without real need for that.
This commit is contained in:
parent
6a5487e021
commit
9ad252d157
Notes:
blender-bot
2023-02-14 07:08:28 +01:00
Referenced by issue #50938, Cache not being reset when changing simulation settings with new depsgraph
|
@ -200,6 +200,11 @@ void BKE_object_eval_uber_data(struct EvaluationContext *eval_ctx,
|
|||
struct Scene *scene,
|
||||
struct Object *ob);
|
||||
|
||||
void BKE_object_eval_cloth(struct EvaluationContext *eval_ctx,
|
||||
struct Scene *scene,
|
||||
struct Object *object);
|
||||
|
||||
|
||||
void BKE_object_handle_data_update(struct EvaluationContext *eval_ctx,
|
||||
struct Scene *scene,
|
||||
struct Object *ob);
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "BKE_editmesh.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_particle.h"
|
||||
#include "BKE_pointcache.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_image.h"
|
||||
|
@ -347,3 +348,9 @@ void BKE_object_eval_uber_data(EvaluationContext *eval_ctx,
|
|||
|
||||
ob->recalc &= ~(OB_RECALC_DATA | OB_RECALC_TIME);
|
||||
}
|
||||
|
||||
void BKE_object_eval_cloth(EvaluationContext *UNUSED(eval_ctx), Scene *scene, Object *object)
|
||||
{
|
||||
DEBUG_PRINT("%s on %s\n", __func__, object->id.name);
|
||||
BKE_ptcache_object_reset(scene, object, PTCACHE_RESET_DEPSGRAPH);
|
||||
}
|
||||
|
|
|
@ -734,7 +734,8 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob)
|
|||
*/
|
||||
|
||||
/* component for all particle systems */
|
||||
ComponentDepsNode *psys_comp = add_component_node(&ob->id, DEPSNODE_TYPE_EVAL_PARTICLES);
|
||||
ComponentDepsNode *psys_comp =
|
||||
add_component_node(&ob->id, DEPSNODE_TYPE_EVAL_PARTICLES);
|
||||
|
||||
/* particle systems */
|
||||
LINKLIST_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
|
||||
|
@ -747,11 +748,12 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob)
|
|||
/* this particle system */
|
||||
// TODO: for now, this will just be a placeholder "ubereval" node
|
||||
add_operation_node(psys_comp,
|
||||
DEPSOP_TYPE_EXEC, function_bind(BKE_particle_system_eval,
|
||||
_1,
|
||||
scene,
|
||||
ob,
|
||||
psys),
|
||||
DEPSOP_TYPE_EXEC,
|
||||
function_bind(BKE_particle_system_eval,
|
||||
_1,
|
||||
scene,
|
||||
ob,
|
||||
psys),
|
||||
DEG_OPCODE_PSYS_EVAL,
|
||||
psys->name);
|
||||
}
|
||||
|
@ -760,6 +762,20 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob)
|
|||
// TODO...
|
||||
}
|
||||
|
||||
void DepsgraphNodeBuilder::build_cloth(Scene *scene, Object *object)
|
||||
{
|
||||
ComponentDepsNode *cache_comp = add_component_node(&object->id,
|
||||
DEPSNODE_TYPE_CACHE);
|
||||
add_operation_node(cache_comp,
|
||||
DEPSOP_TYPE_EXEC,
|
||||
function_bind(BKE_object_eval_cloth,
|
||||
_1,
|
||||
scene,
|
||||
object),
|
||||
DEG_OPCODE_PLACEHOLDER,
|
||||
"Cloth Modifier");
|
||||
}
|
||||
|
||||
/* Shapekeys */
|
||||
void DepsgraphNodeBuilder::build_shapekeys(Key *key)
|
||||
{
|
||||
|
@ -821,6 +837,9 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
|
|||
md),
|
||||
DEG_OPCODE_GEOMETRY_MODIFIER,
|
||||
md->name);
|
||||
if (md->type == eModifierType_Cloth) {
|
||||
build_cloth(scene, ob);
|
||||
}
|
||||
}
|
||||
|
||||
/* materials */
|
||||
|
|
|
@ -133,6 +133,7 @@ struct DepsgraphNodeBuilder {
|
|||
void build_pose_constraints(Object *ob, bPoseChannel *pchan);
|
||||
void build_rigidbody(Scene *scene);
|
||||
void build_particles(Scene *scene, Object *ob);
|
||||
void build_cloth(Scene *scene, Object *object);
|
||||
void build_animdata(ID *id);
|
||||
OperationDepsNode *build_driver(ID *id, FCurve *fcurve);
|
||||
void build_ik_pose(Scene *scene,
|
||||
|
|
|
@ -1312,6 +1312,25 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob)
|
|||
// TODO...
|
||||
}
|
||||
|
||||
void DepsgraphRelationBuilder::build_cloth(Scene *scene,
|
||||
Object *object,
|
||||
ModifierData *md)
|
||||
{
|
||||
OperationKey cache_key(&object->id,
|
||||
DEPSNODE_TYPE_CACHE,
|
||||
DEG_OPCODE_PLACEHOLDER,
|
||||
"Cloth Modifier");
|
||||
/* Cache component affects on modifier. */
|
||||
OperationKey modifier_key(&object->id,
|
||||
DEPSNODE_TYPE_GEOMETRY,
|
||||
DEG_OPCODE_GEOMETRY_MODIFIER,
|
||||
md->name);
|
||||
add_relation(cache_key,
|
||||
modifier_key,
|
||||
DEPSREL_TYPE_TIME,
|
||||
"Cloth Cache -> Cloth");
|
||||
}
|
||||
|
||||
/* Shapekeys */
|
||||
void DepsgraphRelationBuilder::build_shapekeys(ID *obdata, Key *key)
|
||||
{
|
||||
|
@ -1413,6 +1432,10 @@ void DepsgraphRelationBuilder::build_obdata_geom(Main *bmain, Scene *scene, Obje
|
|||
}
|
||||
}
|
||||
|
||||
if (md->type == eModifierType_Cloth) {
|
||||
build_cloth(scene, ob, md);
|
||||
}
|
||||
|
||||
prev_mod_key = mod_key;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ struct Main;
|
|||
struct Mask;
|
||||
struct Material;
|
||||
struct MTex;
|
||||
struct ModifierData;
|
||||
struct MovieClip;
|
||||
struct bNodeTree;
|
||||
struct Object;
|
||||
|
@ -205,6 +206,7 @@ struct DepsgraphRelationBuilder
|
|||
void build_world(World *world);
|
||||
void build_rigidbody(Scene *scene);
|
||||
void build_particles(Scene *scene, Object *ob);
|
||||
void build_cloth(Scene *scene, Object *object, ModifierData *md);
|
||||
void build_ik_pose(Object *ob,
|
||||
bPoseChannel *pchan,
|
||||
bConstraint *con,
|
||||
|
|
Loading…
Reference in New Issue