Merge branch 'master' into blender2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 2 Feb 2018 11:21:24 +0000 (12:21 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 2 Feb 2018 11:21:24 +0000 (12:21 +0100)
1  2 
source/blender/blenkernel/intern/armature_update.c
source/blender/collada/DocumentExporter.cpp
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.h

index 1b8bf3feb10e8f988500df1bb0c821cc42f24eb9,cc1bd9716b1d50ecc20cb2c3383a595fe40a9091..de0dfe2530d14402bf7c7fafbe7833d4156b557a
@@@ -588,13 -587,15 +588,15 @@@ void BKE_pose_eval_init_ik(const struc
                             Object *ob,
                             bPose *UNUSED(pose))
  {
-       float ctime = BKE_scene_frame_get(scene); /* not accurate... */
        DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
+       BLI_assert(ob->type == OB_ARMATURE);
+       const float ctime = BKE_scene_frame_get(scene); /* not accurate... */
+       bArmature *arm = (bArmature *)ob->data;
+       if (arm->flag & ARM_RESTPOS) {
+               return;
+       }
        /* 2a. construct the IK tree (standard IK) */
 -      BIK_initialize_tree(scene, ob, ctime);
 +      BIK_initialize_tree(eval_ctx, scene, ob, ctime);
        /* 2b. construct the Spline IK trees
         *  - this is not integrated as an IK plugin, since it should be able
         *        to function in conjunction with standard IK
@@@ -674,22 -675,32 +676,32 @@@ void BKE_pose_iktree_evaluate(const str
                                Object *ob,
                                bPoseChannel *rootchan)
  {
-       float ctime = BKE_scene_frame_get(scene); /* not accurate... */
        DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name);
 -      BIK_execute_tree(scene, ob, rootchan, ctime);
+       BLI_assert(ob->type == OB_ARMATURE);
+       const float ctime = BKE_scene_frame_get(scene); /* not accurate... */
+       bArmature *arm = (bArmature *)ob->data;
+       if (arm->flag & ARM_RESTPOS) {
+               return;
+       }
 +      BIK_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
  }
  
 -void BKE_pose_splineik_evaluate(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx,
                                  Scene *scene,
                                  Object *ob,
                                  bPoseChannel *rootchan)
  {
-       float ctime = BKE_scene_frame_get(scene); /* not accurate... */
        DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name);
 -      BKE_splineik_execute_tree(scene, ob, rootchan, ctime);
+       BLI_assert(ob->type == OB_ARMATURE);
+       const float ctime = BKE_scene_frame_get(scene); /* not accurate... */
+       bArmature *arm = (bArmature *)ob->data;
+       if (arm->flag & ARM_RESTPOS) {
+               return;
+       }
 +      BKE_splineik_execute_tree(eval_ctx, scene, ob, rootchan, ctime);
  }
  
 -void BKE_pose_eval_flush(EvaluationContext *UNUSED(eval_ctx),
 +void BKE_pose_eval_flush(const struct EvaluationContext *UNUSED(eval_ctx),
                           Scene *scene,
                           Object *ob,
                           bPose *UNUSED(pose))
index 6e84c3baccb4a3f8e6921c4cafe9594f7ea003a0,957fec50e4ba0173bfe2936700e657bd7a6ffb24..179644db9b3ab37fbab7bea128cf08b539a8f89b
@@@ -302,9 -304,9 +302,9 @@@ int DocumentExporter::exportCurrentScen
  
        // <library_animations>
        AnimationExporter ae(writer, this->export_settings);
-       bool has_animations = ae.exportAnimations(eval_ctx, sce);
  
  #if 0
 -      bool has_animations = ae.exportAnimations(sce);
++      bool has_animations = ae.exportAnimations(eval_ctx, sce);
        /* The following code seems to be an obsolete workaround
        Comment out until it proofs correct that we no longer need it.
        */
                se.setExportTransformationType(this->export_settings->export_transformation_type);
        }
  #else
+       ae.exportAnimations(sce);
        se.setExportTransformationType(this->export_settings->export_transformation_type);
  #endif
 -      se.exportScene(sce);
 +      se.exportScene(eval_ctx, sce);
        
        // <scene>
        std::string scene_name(translate_id(id_name(sce)));
index ddae761cea0c32b2f76c99fa4a556cfac34326d1,1d18d6def8d3da2d7f492a63848d6014d63312d1..7de3c1697373fe769215aed6a8dca4f9e4f89e6c
@@@ -853,69 -661,44 +853,79 @@@ void DepsgraphNodeBuilder::build_partic
         *     blackbox evaluation step for one particle system referenced by
         *     the particle systems stack. All dependencies link to this operation.
         */
-       /* component for all particle systems */
+       /* Component for all particle systems. */
        ComponentDepsNode *psys_comp =
                add_component_node(&object->id, DEG_NODE_TYPE_EVAL_PARTICLES);
 +
 +      /* TODO(sergey): Need to get COW of PSYS. */
 +      Scene *scene_cow = get_cow_datablock(scene_);
 +      Object *ob_cow = get_cow_datablock(object);
 +
        add_operation_node(psys_comp,
                           function_bind(BKE_particle_system_eval_init,
                                         _1,
 -                                       scene_,
 -                                       object),
 +                                       scene_cow,
 +                                       ob_cow),
                           DEG_OPCODE_PARTICLE_SYSTEM_EVAL_INIT);
-       /* particle systems */
+       /* Build all particle systems. */
        BLI_LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
                ParticleSettings *part = psys->part;
 -              /* Particle settings. */
 -              // XXX: what if this is used more than once!
 -              build_animdata(&part->id);
 -              /* This particle system evaluation. */
 -              // TODO: for now, this will just be a placeholder "ubereval" node
 +              /* Build particle settings operations.
 +               *
 +               * NOTE: The call itself ensures settings are only build once.
 +               */
 +              build_particle_settings(part);
 +              /* Update on particle settings change. */
 +              add_operation_node(psys_comp,
 +                                 function_bind(BKE_particle_system_settings_eval,
 +                                               _1,
 +                                               psys),
 +                                 DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
 +                                 psys->name);
 +              /* Particle system evaluation. */
                add_operation_node(psys_comp,
                                   NULL,
                                   DEG_OPCODE_PARTICLE_SYSTEM_EVAL,
                                   psys->name);
 -                                      build_object(NULL, part->dup_ob);
+               /* Visualization of particle system. */
+               switch (part->ren_as) {
+                       case PART_DRAW_OB:
+                               if (part->dup_ob != NULL) {
 -                                      build_group(NULL, part->dup_group);
++                                      build_object(NULL,
++                                                   part->dup_ob,
++                                                   DEG_ID_LINKED_INDIRECTLY);
+                               }
+                               break;
+                       case PART_DRAW_GR:
+                               if (part->dup_group != NULL) {
++                                      build_group(part->dup_group);
+                               }
+                               break;
+               }
        }
  
 -      /* pointcache */
 -      // TODO...
 +      /* TODO(sergey): Do we need a point cache operations here? */
 +}
 +
 +void DepsgraphNodeBuilder::build_particle_settings(ParticleSettings *part) {
 +      ID *part_id = &part->id;
 +      if (part_id->tag & LIB_TAG_DOIT) {
 +              return;
 +      }
 +      part_id->tag |= LIB_TAG_DOIT;
 +      /* Animation data. */
 +      build_animdata(part_id);
 +      /* Parameters change. */
 +      add_operation_node(part_id,
 +                         DEG_NODE_TYPE_PARAMETERS,
 +                         NULL,
 +                         DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
 +      add_operation_node(part_id,
 +                         DEG_NODE_TYPE_PARAMETERS,
 +                         function_bind(BKE_particle_system_settings_recalc_clear,
 +                                       _1,
 +                                       part),
 +                         DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR);
  }
  
  void DepsgraphNodeBuilder::build_cloth(Object *object)
index 281e58cf38a6cbdbc6fb5d007b774154a8d064cd,c30d3fecdd527a8373a5ecf1e663efd0faec27c0..8afb23f08fa2c214d5f5c400cb03c2616db6b77e
@@@ -423,29 -427,24 +424,29 @@@ void DepsgraphRelationBuilder::build_gr
  {
        ID *group_id = &group->id;
        bool group_done = (group_id->tag & LIB_TAG_DOIT) != 0;
-       OperationKey object_local_transform_key(&object->id,
+       OperationKey object_local_transform_key(object != NULL ? &object->id : NULL,
                                                DEG_NODE_TYPE_TRANSFORM,
                                                DEG_OPCODE_TRANSFORM_LOCAL);
 -      BLI_LISTBASE_FOREACH (GroupObject *, go, &group->gobject) {
 -              if (!group_done) {
 -                      build_object(go->ob);
 +      if (!group_done) {
 +              BLI_LISTBASE_FOREACH (Base *, base, &group->view_layer->object_bases) {
 +                      build_object(NULL, base->object);
                }
 -              if (object != NULL) {
 -                      ComponentKey dupli_transform_key(&go->ob->id, DEG_NODE_TYPE_TRANSFORM);
 +              group_id->tag |= LIB_TAG_DOIT;
 +      }
-       BLI_LISTBASE_FOREACH (Base *, base, &group->view_layer->object_bases) {
-               ComponentKey dupli_transform_key(&base->object->id, DEG_NODE_TYPE_TRANSFORM);
-               add_relation(dupli_transform_key, object_local_transform_key, "Dupligroup");
++      if (object != NULL) {
++              BLI_LISTBASE_FOREACH (Base *, base, &group->view_layer->object_bases) {
++                      ComponentKey dupli_transform_key(&base->object->id, DEG_NODE_TYPE_TRANSFORM);
+                       add_relation(dupli_transform_key, object_local_transform_key, "Dupligroup");
+               }
        }
 -      group_id->tag |= LIB_TAG_DOIT;
  }
  
 -void DepsgraphRelationBuilder::build_object(Object *object)
 +void DepsgraphRelationBuilder::build_object(Base *base, Object *object)
  {
        if (object->id.tag & LIB_TAG_DOIT) {
 +              if (base != NULL) {
 +                      build_object_flags(base, object);
 +              }
                return;
        }
        object->id.tag |= LIB_TAG_DOIT;
@@@ -1413,46 -1363,17 +1414,40 @@@ void DepsgraphRelationBuilder::build_pa
                                   DEG_NODE_TYPE_EVAL_PARTICLES,
                                   DEG_OPCODE_PARTICLE_SYSTEM_EVAL_INIT);
  
-       /* particle systems */
+       /* Particle systems. */
        BLI_LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
                ParticleSettings *part = psys->part;
 -              /* Animation of particle settings, */
 -              build_animdata(&part->id);
 +
 +              /* Build particle settings relations.
 +               *
 +               * NOTE: The call itself ensures settings are only build once.
 +               */
 +              build_particle_settings(part);
 +
                /* This particle system. */
                OperationKey psys_key(&object->id,
                                      DEG_NODE_TYPE_EVAL_PARTICLES,
                                      DEG_OPCODE_PARTICLE_SYSTEM_EVAL,
                                      psys->name);
-               /* XXX: if particle system is later re-enabled, we must do full rebuild? */
-               if (!psys_check_enabled(object, psys, G.is_rendering))
-                       continue;
 +
 +              /* Update particle system when settings changes. */
 +              OperationKey particle_settings_key(&part->id,
 +                                                 DEG_NODE_TYPE_PARAMETERS,
 +                                                 DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
 +              OperationKey particle_settings_recalc_clear_key(
 +                      &part->id,
 +                      DEG_NODE_TYPE_PARAMETERS,
 +                      DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR);
 +              OperationKey psys_settings_key(&object->id,
 +                                             DEG_NODE_TYPE_EVAL_PARTICLES,
 +                                             DEG_OPCODE_PARTICLE_SETTINGS_EVAL,
 +                                             psys->name);
 +              add_relation(particle_settings_key, psys_settings_key, "Particle Settings Change");
 +              add_relation(psys_settings_key, psys_key, "Particle Settings Update");
 +              add_relation(psys_key,
 +                           particle_settings_recalc_clear_key,
 +                           "Particle Settings Recalc Clear");
                add_relation(eval_init_key, psys_key, "Init -> PSys");
                /* TODO(sergey): Currently particle update is just a placeholder,
                 * hook it to the ubereval node so particle system is getting updated
                 * on playback.
                                         part->effector_weights,
                                         part->type == PART_HAIR,
                                         "Particle Field");
-               /* boids */
 -              /* Boids. */
++              /* Boids .*/
                if (part->boids) {
                        BLI_LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
                                BLI_LISTBASE_FOREACH (BoidRule *, rule, &state->rules) {
                                }
                        }
                }
--
-               if (part->ren_as == PART_DRAW_OB && part->dup_ob) {
-                       ComponentKey dup_ob_key(&part->dup_ob->id, DEG_NODE_TYPE_TRANSFORM);
-                       add_relation(dup_ob_key, psys_key, "Particle Object Visualization");
-                       if (part->dup_ob->type == OB_MBALL) {
-                               ComponentKey dup_geometry_key(&part->dup_ob->id,
-                                                             DEG_NODE_TYPE_GEOMETRY);
-                               add_relation(obdata_ubereval_key,
-                                            dup_geometry_key,
-                                            "Particle MBall Visualization");
-                       }
+               switch (part->ren_as) {
+                       case PART_DRAW_OB:
+                               if (part->dup_ob != NULL) {
+                                       /* Make sure object's relations are all built.  */
 -                                      build_object(part->dup_ob);
++                                      build_object(NULL, part->dup_ob);
+                                       /* Build relation for the particle visualization. */
+                                       build_particles_visualization_object(object,
+                                                                            psys,
+                                                                            part->dup_ob);
+                               }
+                               break;
+                       case PART_DRAW_GR:
+                               if (part->dup_group != NULL) {
+                                       build_group(NULL, part->dup_group);
+                                       BLI_LISTBASE_FOREACH (GroupObject *, go, &part->dup_group->gobject) {
+                                               build_particles_visualization_object(object,
+                                                                                    psys,
+                                                                                    go->ob);
+                                       }
+                               }
+                               break;
                }
        }
  
        ComponentKey transform_key(&object->id, DEG_NODE_TYPE_TRANSFORM);
        add_relation(transform_key, obdata_ubereval_key, "Partcile Eval");
  
 -      /* pointcache */
 -      // TODO...
 +      /* TODO(sergey): Do we need a point cache operations here? */
 +}
 +
 +void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part)
 +{
 +      ID *part_id = &part->id;
 +      if (part_id->tag & LIB_TAG_DOIT) {
 +              return;
 +      }
 +      part_id->tag |= LIB_TAG_DOIT;
 +
 +      /* Animation data relations. */
 +      build_animdata(&part->id);
 +
 +      OperationKey eval_key(part_id,
 +                            DEG_NODE_TYPE_PARAMETERS,
 +                            DEG_OPCODE_PARTICLE_SETTINGS_EVAL);
 +      OperationKey recalc_clear_key(part_id,
 +                                   DEG_NODE_TYPE_PARAMETERS,
 +                                   DEG_OPCODE_PARTICLE_SETTINGS_RECALC_CLEAR);
 +      add_relation(eval_key, recalc_clear_key, "Particle Settings Clear Recalc");
  }
  
+ void DepsgraphRelationBuilder::build_particles_visualization_object(
+         Object *object,
+         ParticleSystem *psys,
+         Object *draw_object)
+ {
+       OperationKey psys_key(&object->id,
+                             DEG_NODE_TYPE_EVAL_PARTICLES,
+                             DEG_OPCODE_PARTICLE_SYSTEM_EVAL,
+                             psys->name);
+       OperationKey obdata_ubereval_key(&object->id,
+                                        DEG_NODE_TYPE_GEOMETRY,
+                                        DEG_OPCODE_GEOMETRY_UBEREVAL);
+       ComponentKey dup_ob_key(&draw_object->id, DEG_NODE_TYPE_TRANSFORM);
+       add_relation(dup_ob_key, psys_key, "Particle Object Visualization");
+       if (draw_object->type == OB_MBALL) {
+               ComponentKey dup_geometry_key(&draw_object->id, DEG_NODE_TYPE_GEOMETRY);
+               add_relation(obdata_ubereval_key,
+                            dup_geometry_key,
+                            "Particle MBall Visualization");
+       }
+ }
  void DepsgraphRelationBuilder::build_cloth(Object *object,
                                             ModifierData * /*md*/)
  {
index 4fcb2acc5f3011f0ee53f0fc0979161f6d764b2d,aa8dc2a4982233a7011cc4a187d5865a8175fa96..ea7e23eca798c0cec14097d5d3d40b9ec8c4802e
@@@ -67,8 -66,8 +67,10 @@@ struct bNodeTree
  struct Object;
  struct bPoseChannel;
  struct bConstraint;
+ struct ParticleSystem;
++struct ParticleSettings;
  struct Scene;
 +struct ViewLayer;
  struct Tex;
  struct World;
  struct EffectorWeights;
@@@ -220,7 -216,9 +220,10 @@@ struct DepsgraphRelationBuilde
        void build_world(World *world);
        void build_rigidbody(Scene *scene);
        void build_particles(Object *object);
 +      void build_particle_settings(ParticleSettings *part);
+       void build_particles_visualization_object(Object *object,
+                                                 ParticleSystem *psys,
+                                                 Object *draw_object);
        void build_cloth(Object *object, ModifierData *md);
        void build_ik_pose(Object *object,
                           bPoseChannel *pchan,