Fixes for particle system and physics
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 19 Dec 2018 14:36:09 +0000 (15:36 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 19 Dec 2018 14:36:09 +0000 (15:36 +0100)
- Silence harmless error print about relation.

  Object with particle system which doesn't use physics will
  not have point cache component.

- Tag relations for update when particle system physics type
  change.

  This ensures correct state of point cache component.

This is all part of T59258.

source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/editors/object/object_relations.c
source/blender/makesrna/intern/rna_particle.c

index 23328721e2cf358eaf21e774c89c752db2ff1295..c8822df28e6188084e10d2da2c6c3fd3d7fab303 100644 (file)
@@ -1714,8 +1714,10 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object)
                                   DEG_NODE_TYPE_PARTICLE_SYSTEM,
                                   DEG_OPCODE_PARTICLE_SYSTEM_DONE);
        ComponentKey eval_key(&object->id, DEG_NODE_TYPE_PARTICLE_SYSTEM);
                                   DEG_NODE_TYPE_PARTICLE_SYSTEM,
                                   DEG_OPCODE_PARTICLE_SYSTEM_DONE);
        ComponentKey eval_key(&object->id, DEG_NODE_TYPE_PARTICLE_SYSTEM);
-       ComponentKey point_cache_key(&object->id, DEG_NODE_TYPE_POINT_CACHE);
-       add_relation(eval_key, point_cache_key, "Particle Point Cache");
+       if (BKE_ptcache_object_has(scene_, object, 0)) {
+               ComponentKey point_cache_key(&object->id, DEG_NODE_TYPE_POINT_CACHE);
+               add_relation(eval_key, point_cache_key, "Particle Point Cache");
+       }
        /* Particle systems. */
        LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
                ParticleSettings *part = psys->part;
        /* Particle systems. */
        LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
                ParticleSettings *part = psys->part;
index d61c5334ee681f646fbcdc6c2f93fdd85882ace1..867b807c908d58e3efefb4629f871c3922d3d2fe 100644 (file)
@@ -1872,6 +1872,9 @@ static void single_mat_users(Main *bmain, Scene *scene, ViewLayer *view_layer, V
                                        if (ma->id.us > 1) {
                                                man = BKE_material_copy(bmain, ma);
                                                BKE_animdata_copy_id_action(bmain, &man->id, false);
                                        if (ma->id.us > 1) {
                                                man = BKE_material_copy(bmain, ma);
                                                BKE_animdata_copy_id_action(bmain, &man->id, false);
+                                               if (man->nodetree != NULL) {
+                                                       BKE_animdata_copy_id_action(bmain, &man->nodetree->id, false);
+                                               }
 
                                                man->id.us = 0;
                                                assign_material(bmain, ob, man, a, BKE_MAT_ASSIGN_USERPREF);
 
                                                man->id.us = 0;
                                                assign_material(bmain, ob, man, a, BKE_MAT_ASSIGN_USERPREF);
index bc6c6917ed3f7901062cc7a4e7279263f0379d5c..1eb96860c3e49a3229ad5a4bf8b9ee8661f413f4 100644 (file)
@@ -670,6 +670,8 @@ static void rna_Particle_change_physics_type(Main *bmain, Scene *scene, PointerR
                part->fluid = MEM_callocN(sizeof(SPHFluidSettings), "SPH Fluid Settings");
                BKE_particlesettings_fluid_default_settings(part);
        }
                part->fluid = MEM_callocN(sizeof(SPHFluidSettings), "SPH Fluid Settings");
                BKE_particlesettings_fluid_default_settings(part);
        }
+
+       DEG_relations_tag_update(bmain);
 }
 
 static void rna_Particle_redo_child(Main *bmain, Scene *scene, PointerRNA *ptr)
 }
 
 static void rna_Particle_redo_child(Main *bmain, Scene *scene, PointerRNA *ptr)