Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/armature.c
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "BIK_api.h" | #include "BIK_api.h" | ||||
| #include "atomic_ops.h" | #include "atomic_ops.h" | ||||
| #include "CLG_log.h" | |||||
| static CLG_LogRef LOG = {"bke.armature"}; | |||||
| /* **************** Generic Functions, data level *************** */ | /* **************** Generic Functions, data level *************** */ | ||||
| bArmature *BKE_armature_add(Main *bmain, const char *name) | bArmature *BKE_armature_add(Main *bmain, const char *name) | ||||
| { | { | ||||
| bArmature *arm; | bArmature *arm; | ||||
| arm = BKE_libblock_alloc(bmain, ID_AR, name, 0); | arm = BKE_libblock_alloc(bmain, ID_AR, name, 0); | ||||
| arm->deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE; | arm->deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE; | ||||
| ▲ Show 20 Lines • Show All 1,062 Lines • ▼ Show 20 Lines | void armature_deform_verts( | ||||
| int armature_def_nr; | int armature_def_nr; | ||||
| /* in editmode, or not an armature */ | /* in editmode, or not an armature */ | ||||
| if (arm->edbo || (armOb->pose == NULL)) { | if (arm->edbo || (armOb->pose == NULL)) { | ||||
| return; | return; | ||||
| } | } | ||||
| if ((armOb->pose->flag & POSE_RECALC) != 0) { | if ((armOb->pose->flag & POSE_RECALC) != 0) { | ||||
| printf("ERROR! Trying to evaluate influence of armature '%s' which needs Pose recalc!\n", armOb->id.name); | CLOG_ERROR(&LOG, "Trying to evaluate influence of armature '%s' which needs Pose recalc!", armOb->id.name); | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| } | } | ||||
| invert_m4_m4(obinv, target->obmat); | invert_m4_m4(obinv, target->obmat); | ||||
| copy_m4_m4(premat, target->obmat); | copy_m4_m4(premat, target->obmat); | ||||
| mul_m4_m4m4(postmat, obinv, armOb->obmat); | mul_m4_m4m4(postmat, obinv, armOb->obmat); | ||||
| invert_m4_m4(premat, postmat); | invert_m4_m4(premat, postmat); | ||||
| /* Use pre-calculated bbone deformation. | /* Use pre-calculated bbone deformation. | ||||
| * | * | ||||
| * TODO(sergey): Make this code robust somehow when there are dependency | * TODO(sergey): Make this code robust somehow when there are dependency | ||||
| * cycles involved. */ | * cycles involved. */ | ||||
| ObjectBBoneDeform *bbone_deform = | ObjectBBoneDeform *bbone_deform = | ||||
| BKE_armature_cached_bbone_deformation_get(armOb); | BKE_armature_cached_bbone_deformation_get(armOb); | ||||
| if (bbone_deform == NULL || bbone_deform->pdef_info_array == NULL) { | if (bbone_deform == NULL || bbone_deform->pdef_info_array == NULL) { | ||||
| fprintf(stderr, | CLOG_ERROR(&LOG, | ||||
| "Armature does not have bbone cache %s, " | "Armature does not have bbone cache %s, " | ||||
| "usually happens due to a dependency cycle.\n", | "usually happens due to a dependency cycle.\n", | ||||
| armOb->id.name + 2); | armOb->id.name + 2); | ||||
| return; | return; | ||||
| } | } | ||||
| const bPoseChanDeform *pdef_info_array = bbone_deform->pdef_info_array; | const bPoseChanDeform *pdef_info_array = bbone_deform->pdef_info_array; | ||||
| /* get the def_nr for the overall armature vertex group if present */ | /* get the def_nr for the overall armature vertex group if present */ | ||||
| ▲ Show 20 Lines • Show All 811 Lines • ▼ Show 20 Lines | static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected) | ||||
| if (frompose == NULL) | if (frompose == NULL) | ||||
| return; | return; | ||||
| /* in some cases when rigs change, we cant synchronize | /* in some cases when rigs change, we cant synchronize | ||||
| * to avoid crashing check for possible errors here */ | * to avoid crashing check for possible errors here */ | ||||
| for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | ||||
| if (pchan->bone->layer & layer_protected) { | if (pchan->bone->layer & layer_protected) { | ||||
| if (BKE_pose_channel_find_name(frompose, pchan->name) == NULL) { | if (BKE_pose_channel_find_name(frompose, pchan->name) == NULL) { | ||||
| printf("failed to sync proxy armature because '%s' is missing pose channel '%s'\n", | CLOG_ERROR(&LOG, "failed to sync proxy armature because '%s' is missing pose channel '%s'", | ||||
| from->id.name, pchan->name); | from->id.name, pchan->name); | ||||
| error = 1; | error = 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (error) | if (error) | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 644 Lines • Show Last 20 Lines | |||||