Cleanups: Small changes to armature deform
Use const pointers, remove unused data member for parallel callback, use listbase macro.
This commit is contained in:
parent
ada6012518
commit
7a4a6ccad7
|
@ -159,9 +159,9 @@ float distfactor_to_bone(
|
|||
}
|
||||
|
||||
static float dist_bone_deform(
|
||||
bPoseChannel *pchan, float vec[3], DualQuat *dq, float mat[3][3], const float co[3])
|
||||
const bPoseChannel *pchan, float vec[3], DualQuat *dq, float mat[3][3], const float co[3])
|
||||
{
|
||||
Bone *bone = pchan->bone;
|
||||
const Bone *bone = pchan->bone;
|
||||
float fac, contrib = 0.0;
|
||||
|
||||
if (bone == NULL) {
|
||||
|
@ -188,7 +188,7 @@ static float dist_bone_deform(
|
|||
return contrib;
|
||||
}
|
||||
|
||||
static void pchan_bone_deform(bPoseChannel *pchan,
|
||||
static void pchan_bone_deform(const bPoseChannel *pchan,
|
||||
float weight,
|
||||
float vec[3],
|
||||
DualQuat *dq,
|
||||
|
@ -196,7 +196,7 @@ static void pchan_bone_deform(bPoseChannel *pchan,
|
|||
const float co[3],
|
||||
float *contrib)
|
||||
{
|
||||
Bone *bone = pchan->bone;
|
||||
const Bone *bone = pchan->bone;
|
||||
|
||||
if (!weight) {
|
||||
return;
|
||||
|
@ -223,7 +223,6 @@ static void pchan_bone_deform(bPoseChannel *pchan,
|
|||
|
||||
typedef struct ArmatureUserdata {
|
||||
const Object *ob_arm;
|
||||
const Object *ob_target;
|
||||
const Mesh *me_target;
|
||||
float (*vert_coords)[3];
|
||||
float (*vert_deform_mats)[3][3];
|
||||
|
@ -264,7 +263,7 @@ static void armature_vert_task_with_dvert(const ArmatureUserdata *data,
|
|||
const int armature_def_nr = data->armature_def_nr;
|
||||
|
||||
DualQuat sumdq, *dq = NULL;
|
||||
bPoseChannel *pchan;
|
||||
const bPoseChannel *pchan;
|
||||
float *co, dco[3];
|
||||
float sumvec[3], summat[3][3];
|
||||
float *vec = NULL, (*smat)[3] = NULL;
|
||||
|
@ -319,7 +318,7 @@ static void armature_vert_task_with_dvert(const ArmatureUserdata *data,
|
|||
const uint index = dw->def_nr;
|
||||
if (index < data->defbase_len && (pchan = data->pchan_from_defbase[index])) {
|
||||
float weight = dw->weight;
|
||||
Bone *bone = pchan->bone;
|
||||
const Bone *bone = pchan->bone;
|
||||
|
||||
deformed = 1;
|
||||
|
||||
|
@ -434,7 +433,7 @@ static void armature_vert_task_editmesh(void *__restrict userdata,
|
|||
{
|
||||
const ArmatureUserdata *data = userdata;
|
||||
BMVert *v = (BMVert *)iter;
|
||||
MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(v, data->bmesh.cd_dvert_offset);
|
||||
const MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(v, data->bmesh.cd_dvert_offset);
|
||||
armature_vert_task_with_dvert(data, BM_elem_index_get(v), dvert);
|
||||
}
|
||||
|
||||
|
@ -459,15 +458,14 @@ static void armature_deform_coords_impl(const Object *ob_arm,
|
|||
BMEditMesh *em_target,
|
||||
bGPDstroke *gps_target)
|
||||
{
|
||||
bArmature *arm = ob_arm->data;
|
||||
const bArmature *arm = ob_arm->data;
|
||||
bPoseChannel **pchan_from_defbase = NULL;
|
||||
const MDeformVert *dverts = NULL;
|
||||
bDeformGroup *dg;
|
||||
const bool use_envelope = (deformflag & ARM_DEF_ENVELOPE) != 0;
|
||||
const bool use_quaternion = (deformflag & ARM_DEF_QUATERNION) != 0;
|
||||
const bool invert_vgroup = (deformflag & ARM_DEF_INVERT_VGROUP) != 0;
|
||||
int defbase_len = 0; /* safety for vertexgroup index overflow */
|
||||
int i, dverts_len = 0; /* safety for vertexgroup overflow */
|
||||
int defbase_len = 0; /* safety for vertexgroup index overflow */
|
||||
int dverts_len = 0; /* safety for vertexgroup overflow */
|
||||
bool use_dverts = false;
|
||||
int armature_def_nr = -1;
|
||||
int cd_dvert_offset = -1;
|
||||
|
@ -492,7 +490,7 @@ static void armature_deform_coords_impl(const Object *ob_arm,
|
|||
|
||||
if (ob_target->type == OB_MESH) {
|
||||
if (em_target == NULL) {
|
||||
Mesh *me = ob_target->data;
|
||||
const Mesh *me = ob_target->data;
|
||||
dverts = me->dvert;
|
||||
if (dverts) {
|
||||
dverts_len = me->totvert;
|
||||
|
@ -500,7 +498,7 @@ static void armature_deform_coords_impl(const Object *ob_arm,
|
|||
}
|
||||
}
|
||||
else if (ob_target->type == OB_LATTICE) {
|
||||
Lattice *lt = ob_target->data;
|
||||
const Lattice *lt = ob_target->data;
|
||||
dverts = lt->dvert;
|
||||
if (dverts) {
|
||||
dverts_len = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
|
@ -534,7 +532,8 @@ static void armature_deform_coords_impl(const Object *ob_arm,
|
|||
* - Check whether keeping this consistent across frames gives speedup.
|
||||
*/
|
||||
const ListBase *defbase = BKE_object_defgroup_list(ob_target);
|
||||
for (i = 0, dg = defbase->first; dg; i++, dg = dg->next) {
|
||||
int i;
|
||||
LISTBASE_FOREACH_INDEX (bDeformGroup *, dg, defbase, i) {
|
||||
pchan_from_defbase[i] = BKE_pose_channel_find_name(ob_arm->pose, dg->name);
|
||||
/* exclude non-deforming bones */
|
||||
if (pchan_from_defbase[i]) {
|
||||
|
@ -549,7 +548,6 @@ static void armature_deform_coords_impl(const Object *ob_arm,
|
|||
|
||||
ArmatureUserdata data = {
|
||||
.ob_arm = ob_arm,
|
||||
.ob_target = ob_target,
|
||||
.me_target = me_target,
|
||||
.vert_coords = vert_coords,
|
||||
.vert_deform_mats = vert_deform_mats,
|
||||
|
|
Loading…
Reference in New Issue