diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-04 10:54:50 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-04 10:54:50 +0300 |
commit | eaf8608ba5e949f0bc81a57bc54822d4283a312a (patch) | |
tree | d9919e7ece856389778a8d14532688615f760235 /source | |
parent | cd6daea7d32d306a427e97427cb135d1589cc309 (diff) | |
parent | 4674e02562637f36a9900bff5f5f4acc9aff482d (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source')
6 files changed, 77 insertions, 44 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 192690c074c..bf37224c85f 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -171,41 +171,39 @@ void BKE_splineik_execute_tree( void BKE_pose_eval_init(const struct EvaluationContext *eval_ctx, struct Scene *scene, - struct Object *ob, - struct bPose *pose); + struct Object *ob); void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx, struct Scene *scene, - struct Object *ob, - struct bPose *pose); + struct Object *ob); void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, - struct bPoseChannel *pchan); + int pchan_index); void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, - struct bPoseChannel *pchan); + int pchan_index); void BKE_pose_bone_done(const struct EvaluationContext *eval_ctx, - struct bPoseChannel *pchan); + struct Object *ob, + int pchan_index); void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, - struct bPoseChannel *rootchan); + int rootchan_index); void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob, - struct bPoseChannel *rootchan); + int rootchan_index); void BKE_pose_eval_flush(const struct EvaluationContext *eval_ctx, struct Scene *scene, - struct Object *ob, - struct bPose *pose); + struct Object *ob); void BKE_pose_eval_proxy_copy(const struct EvaluationContext *eval_ctx, struct Object *ob); diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index 8058dbef577..54f1a353486 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -560,10 +560,10 @@ void BKE_splineik_execute_tree( void BKE_pose_eval_init(const struct EvaluationContext *UNUSED(eval_ctx), Scene *UNUSED(scene), - Object *ob, - bPose *pose) + Object *ob) { - bPoseChannel *pchan; + bPose *pose = ob->pose; + BLI_assert(pose != NULL); DEG_debug_print_eval(__func__, ob->id.name, ob); @@ -576,16 +576,21 @@ void BKE_pose_eval_init(const struct EvaluationContext *UNUSED(eval_ctx), /* imat is needed for solvers. */ invert_m4_m4(ob->imat, ob->obmat); - /* 1. clear flags */ - for (pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) { + const int num_channels = BLI_listbase_count(&pose->chanbase); + pose->chan_array = MEM_malloc_arrayN( + num_channels, sizeof(bPoseChannel*), "pose->chan_array"); + + /* clear flags */ + int pchan_index = 0; + for (bPoseChannel *pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) { pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE); + pose->chan_array[pchan_index++] = pchan; } } void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx, Scene *scene, - Object *ob, - bPose *UNUSED(pose)) + Object *ob) { DEG_debug_print_eval(__func__, ob->id.name, ob); BLI_assert(ob->type == OB_ARMATURE); @@ -594,11 +599,11 @@ void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx, if (arm->flag & ARM_RESTPOS) { return; } - /* 2a. construct the IK tree (standard IK) */ + /* construct the IK tree (standard IK) */ BIK_initialize_tree(eval_ctx, scene, ob, ctime); - /* 2b. construct the Spline IK trees + /* 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 + * to function in conjunction with standard IK */ BKE_pose_splineik_init_tree(scene, ob, ctime); } @@ -606,8 +611,10 @@ void BKE_pose_eval_init_ik(const struct EvaluationContext *eval_ctx, void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, - bPoseChannel *pchan) + int pchan_index) { + BLI_assert(ob->pose != NULL); + bPoseChannel *pchan = ob->pose->chan_array[pchan_index]; DEG_debug_print_eval_subdata( __func__, ob->id.name, ob, "pchan", pchan->name, pchan); BLI_assert(ob->type == OB_ARMATURE); @@ -642,8 +649,10 @@ void BKE_pose_eval_bone(const struct EvaluationContext *eval_ctx, void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, - bPoseChannel *pchan) + int pchan_index) { + BLI_assert(ob->pose != NULL); + bPoseChannel *pchan = ob->pose->chan_array[pchan_index]; DEG_debug_print_eval_subdata( __func__, ob->id.name, ob, "pchan", pchan->name, pchan); bArmature *arm = (bArmature *)ob->data; @@ -662,8 +671,11 @@ void BKE_pose_constraints_evaluate(const struct EvaluationContext *eval_ctx, } void BKE_pose_bone_done(const struct EvaluationContext *UNUSED(eval_ctx), - bPoseChannel *pchan) + struct Object *ob, + int pchan_index) { + BLI_assert(ob->pose != NULL); + bPoseChannel *pchan = ob->pose->chan_array[pchan_index]; float imat[4][4]; DEG_debug_print_eval(__func__, pchan->name, pchan); if (pchan->bone) { @@ -675,8 +687,10 @@ void BKE_pose_bone_done(const struct EvaluationContext *UNUSED(eval_ctx), void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, - bPoseChannel *rootchan) + int rootchan_index) { + BLI_assert(ob->pose != NULL); + bPoseChannel *rootchan = ob->pose->chan_array[rootchan_index]; DEG_debug_print_eval_subdata( __func__, ob->id.name, ob, "rootchan", rootchan->name, rootchan); BLI_assert(ob->type == OB_ARMATURE); @@ -691,9 +705,11 @@ void BKE_pose_iktree_evaluate(const struct EvaluationContext *eval_ctx, void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx, Scene *scene, Object *ob, - bPoseChannel *rootchan) + int rootchan_index) { + BLI_assert(ob->pose != NULL); + bPoseChannel *rootchan = ob->pose->chan_array[rootchan_index]; DEG_debug_print_eval_subdata( __func__, ob->id.name, ob, "rootchan", rootchan->name, rootchan); BLI_assert(ob->type == OB_ARMATURE); @@ -707,15 +723,21 @@ void BKE_pose_splineik_evaluate(const struct EvaluationContext *eval_ctx, void BKE_pose_eval_flush(const struct EvaluationContext *UNUSED(eval_ctx), Scene *scene, - Object *ob, - bPose *UNUSED(pose)) + Object *ob) { + bPose *pose = ob->pose; + BLI_assert(pose != NULL); + float ctime = BKE_scene_frame_get(scene); /* not accurate... */ DEG_debug_print_eval(__func__, ob->id.name, ob); BLI_assert(ob->type == OB_ARMATURE); - /* 6. release the IK tree */ + /* release the IK tree */ BIK_release_tree(scene, ob, ctime); + + BLI_assert(pose->chan_array != NULL); + MEM_freeN(pose->chan_array); + pose->chan_array = NULL; } void BKE_pose_eval_proxy_copy(const struct EvaluationContext *UNUSED(eval_ctx), Object *ob) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 97d132a3e40..1f37eaf390b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5181,6 +5181,7 @@ static void direct_link_pose(FileData *fd, bPose *pose) link_list(fd, &pose->agroups); pose->chanhash = NULL; + pose->chan_array = NULL; for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) { pchan->bone = NULL; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 49cccb60843..8dfbc4fa37c 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -180,7 +180,7 @@ struct DepsgraphNodeBuilder { void build_object_data(Object *object); void build_object_transform(Object *object); void build_object_constraints(Object *object); - void build_pose_constraints(Object *object, bPoseChannel *pchan); + void build_pose_constraints(Object *object, bPoseChannel *pchan, int pchan_index); void build_rigidbody(Scene *scene); void build_particles(Object *object); void build_particle_settings(ParticleSettings *part); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc index aabcbd1c6d4..328d23a2ced 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_rig.cc @@ -67,7 +67,8 @@ extern "C" { namespace DEG { void DepsgraphNodeBuilder::build_pose_constraints(Object *object, - bPoseChannel *pchan) + bPoseChannel *pchan, + int pchan_index) { /* create node for constraint stack */ add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name, @@ -75,7 +76,7 @@ void DepsgraphNodeBuilder::build_pose_constraints(Object *object, _1, get_cow_datablock(scene_), get_cow_datablock(object), - pchan), + pchan_index), DEG_OPCODE_BONE_CONSTRAINTS); } @@ -98,13 +99,14 @@ void DepsgraphNodeBuilder::build_ik_pose(Object *object, return; } + int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan); /* Operation node for evaluating/running IK Solver. */ add_operation_node(&object->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name, function_bind(BKE_pose_iktree_evaluate, _1, get_cow_datablock(scene_), get_cow_datablock(object), - rootchan), + rootchan_index), DEG_OPCODE_POSE_IK_SOLVER); } @@ -122,12 +124,13 @@ void DepsgraphNodeBuilder::build_splineik_pose(Object *object, * Store the "root bone" of this chain in the solver, so it knows where to * start. */ + int rootchan_index = BLI_findindex(&object->pose->chanbase, rootchan); add_operation_node(&object->id, DEG_NODE_TYPE_EVAL_POSE, rootchan->name, function_bind(BKE_pose_splineik_evaluate, _1, get_cow_datablock(scene_), get_cow_datablock(object), - rootchan), + rootchan_index), DEG_OPCODE_POSE_SPLINE_IK_SOLVER); } @@ -220,8 +223,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object) function_bind(BKE_pose_eval_init, _1, scene_cow, - object_cow, - object_cow->pose), + object_cow), DEG_OPCODE_POSE_INIT); op_node->set_as_entry(); @@ -230,8 +232,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object) function_bind(BKE_pose_eval_init_ik, _1, scene_cow, - object_cow, - object_cow->pose), + object_cow), DEG_OPCODE_POSE_INIT_IK); op_node = add_operation_node(&object->id, @@ -239,12 +240,12 @@ void DepsgraphNodeBuilder::build_rig(Object *object) function_bind(BKE_pose_eval_flush, _1, scene_cow, - object_cow, - object_cow->pose), + object_cow), DEG_OPCODE_POSE_DONE); op_node->set_as_exit(); /* bones */ + int pchan_index = 0; LISTBASE_FOREACH (bPoseChannel *, pchan, &object_cow->pose->chanbase) { /* Node for bone evaluation. */ op_node = add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name, NULL, @@ -255,7 +256,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object) function_bind(BKE_pose_eval_bone, _1, scene_cow, object_cow, - pchan), + pchan_index), DEG_OPCODE_BONE_POSE_PARENT); /* NOTE: Dedicated noop for easier relationship construction. */ @@ -264,7 +265,10 @@ void DepsgraphNodeBuilder::build_rig(Object *object) DEG_OPCODE_BONE_READY); op_node = add_operation_node(&object->id, DEG_NODE_TYPE_BONE, pchan->name, - function_bind(BKE_pose_bone_done, _1, pchan), + function_bind(BKE_pose_bone_done, + _1, + object, + pchan_index), DEG_OPCODE_BONE_DONE); op_node->set_as_exit(); /* Custom properties. */ @@ -277,7 +281,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object) } /* Build constraints. */ if (pchan->constraints.first != NULL) { - build_pose_constraints(object, pchan); + build_pose_constraints(object, pchan, pchan_index); } /** * IK Solvers. @@ -305,6 +309,7 @@ void DepsgraphNodeBuilder::build_rig(Object *object) break; } } + /* Custom shape. */ /* NOTE: Custom shape datablock is already remapped to CoW version. */ if (pchan->custom != NULL) { @@ -312,6 +317,8 @@ void DepsgraphNodeBuilder::build_rig(Object *object) get_orig_datablock(pchan->custom), DEG_ID_LINKED_INDIRECTLY); } + + pchan_index++; } } diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index c8780c6b4b8..95cbdeadf87 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -393,7 +393,12 @@ typedef enum eRotationModes { typedef struct bPose { ListBase chanbase; /* list of pose channels, PoseBones in RNA */ struct GHash *chanhash; /* ghash for quicker string lookups */ - + + /* Flat array of pose channels. It references pointers from + * chanbase. Used for quick pose channel lookup from an index. + */ + bPoseChannel **chan_array; + short flag, pad; unsigned int proxy_layer; /* proxy layer: copy from armature, gets synced */ int pad1; |