Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/armature_deform.c
| Show First 20 Lines • Show All 477 Lines • ▼ Show 20 Lines | static void armature_deform_coords_impl(const Object *ob_arm, | ||||
| if ((ob_arm->pose->flag & POSE_RECALC) != 0) { | if ((ob_arm->pose->flag & POSE_RECALC) != 0) { | ||||
| CLOG_ERROR(&LOG, | CLOG_ERROR(&LOG, | ||||
| "Trying to evaluate influence of armature '%s' which needs Pose recalc!", | "Trying to evaluate influence of armature '%s' which needs Pose recalc!", | ||||
| ob_arm->id.name); | ob_arm->id.name); | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| } | } | ||||
| if (BKE_object_supports_vertex_groups(ob_target)) { | if (BKE_object_supports_vertex_groups(ob_target)) { | ||||
| /* get the def_nr for the overall armature vertex group if present */ | const ID *target_id = NULL; | ||||
angavrilov: Maybe call it target_data_id to be clear? | |||||
| armature_def_nr = BKE_object_defgroup_name_index(ob_target, defgrp_name); | |||||
| defbase_len = BKE_object_defgroup_count(ob_target); | |||||
| if (ob_target->type == OB_MESH) { | if (ob_target->type == OB_MESH) { | ||||
| target_id = me_target == NULL ? (const ID *)ob_target->data : &me_target->id; | |||||
| if (em_target == NULL) { | if (em_target == NULL) { | ||||
| const Mesh *me = ob_target->data; | const Mesh *me = (const Mesh *)target_id; | ||||
| dverts = me->dvert; | dverts = me->dvert; | ||||
| if (dverts) { | if (dverts) { | ||||
| dverts_len = me->totvert; | dverts_len = me->totvert; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (ob_target->type == OB_LATTICE) { | else if (ob_target->type == OB_LATTICE) { | ||||
| const Lattice *lt = ob_target->data; | const Lattice *lt = ob_target->data; | ||||
| target_id = (const ID *)ob_target->data; | |||||
| dverts = lt->dvert; | dverts = lt->dvert; | ||||
| if (dverts) { | if (dverts) { | ||||
| dverts_len = lt->pntsu * lt->pntsv * lt->pntsw; | dverts_len = lt->pntsu * lt->pntsv * lt->pntsw; | ||||
| } | } | ||||
| } | } | ||||
| else if (ob_target->type == OB_GPENCIL) { | else if (ob_target->type == OB_GPENCIL) { | ||||
| target_id = (const ID *)ob_target->data; | |||||
| dverts = gps_target->dvert; | dverts = gps_target->dvert; | ||||
| if (dverts) { | if (dverts) { | ||||
| dverts_len = gps_target->totpoints; | dverts_len = gps_target->totpoints; | ||||
| } | } | ||||
| } | } | ||||
angavrilovUnsubmitted Done Inline ActionsAdd a newline and a comment here maybe? angavrilov: Add a newline and a comment here maybe? | |||||
| armature_def_nr = BKE_id_defgroup_name_index(target_id, defgrp_name); | |||||
| const ListBase *defbase = BKE_id_defgroup_list_get(target_id); | |||||
| defbase_len = BLI_listbase_count(defbase); | |||||
| /* get a vertex-deform-index to posechannel array */ | /* get a vertex-deform-index to posechannel array */ | ||||
| if (deformflag & ARM_DEF_VGROUP) { | if (deformflag & ARM_DEF_VGROUP) { | ||||
| /* if we have a Mesh, only use dverts if it has them */ | /* if we have a Mesh, only use dverts if it has them */ | ||||
| if (em_target) { | if (em_target) { | ||||
| cd_dvert_offset = CustomData_get_offset(&em_target->bm->vdata, CD_MDEFORMVERT); | cd_dvert_offset = CustomData_get_offset(&em_target->bm->vdata, CD_MDEFORMVERT); | ||||
| use_dverts = (cd_dvert_offset != -1); | use_dverts = (cd_dvert_offset != -1); | ||||
| } | } | ||||
| else if (me_target) { | else if (me_target) { | ||||
| use_dverts = (me_target->dvert != NULL); | use_dverts = (me_target->dvert != NULL); | ||||
| } | } | ||||
| else if (dverts) { | else if (dverts) { | ||||
| use_dverts = true; | use_dverts = true; | ||||
| } | } | ||||
| if (use_dverts) { | if (use_dverts) { | ||||
| pchan_from_defbase = MEM_callocN(sizeof(*pchan_from_defbase) * defbase_len, "defnrToBone"); | pchan_from_defbase = MEM_callocN(sizeof(*pchan_from_defbase) * defbase_len, "defnrToBone"); | ||||
| /* TODO(sergey): Some considerations here: | /* TODO(sergey): Some considerations here: | ||||
| * | * | ||||
| * - Check whether keeping this consistent across frames gives speedup. | * - Check whether keeping this consistent across frames gives speedup. | ||||
| */ | */ | ||||
| const ListBase *defbase = BKE_object_defgroup_list(ob_target); | |||||
| int i; | int i; | ||||
| LISTBASE_FOREACH_INDEX (bDeformGroup *, dg, defbase, i) { | LISTBASE_FOREACH_INDEX (bDeformGroup *, dg, defbase, i) { | ||||
| pchan_from_defbase[i] = BKE_pose_channel_find_name(ob_arm->pose, dg->name); | pchan_from_defbase[i] = BKE_pose_channel_find_name(ob_arm->pose, dg->name); | ||||
| /* exclude non-deforming bones */ | /* exclude non-deforming bones */ | ||||
| if (pchan_from_defbase[i]) { | if (pchan_from_defbase[i]) { | ||||
| if (pchan_from_defbase[i]->bone->flag & BONE_NO_DEFORM) { | if (pchan_from_defbase[i]->bone->flag & BONE_NO_DEFORM) { | ||||
| pchan_from_defbase[i] = NULL; | pchan_from_defbase[i] = NULL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines | |||||
Maybe call it target_data_id to be clear?