forked from bartvdbraak/blender
more vertex weight edits,
* replace inline loops with api calls. * change constraints so verts with 0.0 weight are ignored like they are everywhere else.
This commit is contained in:
parent
3d5330f789
commit
40a2c1a292
@ -924,7 +924,6 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
|
|||||||
float contrib = 0.0f;
|
float contrib = 0.0f;
|
||||||
float armature_weight = 1.0f; /* default to 1 if no overall def group */
|
float armature_weight = 1.0f; /* default to 1 if no overall def group */
|
||||||
float prevco_weight = 1.0f; /* weight for optional cached vertexcos */
|
float prevco_weight = 1.0f; /* weight for optional cached vertexcos */
|
||||||
int j;
|
|
||||||
|
|
||||||
if(use_quaternion) {
|
if(use_quaternion) {
|
||||||
memset(&sumdq, 0, sizeof(DualQuat));
|
memset(&sumdq, 0, sizeof(DualQuat));
|
||||||
@ -971,12 +970,14 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm,
|
|||||||
mul_m4_v3(premat, co);
|
mul_m4_v3(premat, co);
|
||||||
|
|
||||||
if(use_dverts && dvert && dvert->totweight) { // use weight groups ?
|
if(use_dverts && dvert && dvert->totweight) { // use weight groups ?
|
||||||
|
MDeformWeight *dw= dvert->dw;
|
||||||
int deformed = 0;
|
int deformed = 0;
|
||||||
|
unsigned int j;
|
||||||
|
|
||||||
for(j = 0; j < dvert->totweight; j++){
|
for (j= dvert->totweight; j != 0; j--, dw++) {
|
||||||
int index = dvert->dw[j].def_nr;
|
const int index = dw->def_nr;
|
||||||
if(index < defbase_tot && (pchan= defnrToPC[index])) {
|
if(index < defbase_tot && (pchan= defnrToPC[index])) {
|
||||||
float weight = dvert->dw[j].weight;
|
float weight = dw->weight;
|
||||||
Bone *bone= pchan->bone;
|
Bone *bone= pchan->bone;
|
||||||
pdef_info= pdef_info_array + defnrToPCIndex[index];
|
pdef_info= pdef_info_array + defnrToPCIndex[index];
|
||||||
|
|
||||||
|
@ -436,15 +436,14 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat
|
|||||||
float vec[3] = {0.0f, 0.0f, 0.0f};
|
float vec[3] = {0.0f, 0.0f, 0.0f};
|
||||||
float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3];
|
float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3];
|
||||||
float imat[3][3], tmat[3][3];
|
float imat[3][3], tmat[3][3];
|
||||||
int dgroup;
|
const int defgroup= defgroup_name_index(ob, substring);
|
||||||
short freeDM = 0;
|
short freeDM = 0;
|
||||||
|
|
||||||
/* initialize target matrix using target matrix */
|
/* initialize target matrix using target matrix */
|
||||||
copy_m4_m4(mat, ob->obmat);
|
copy_m4_m4(mat, ob->obmat);
|
||||||
|
|
||||||
/* get index of vertex group */
|
/* get index of vertex group */
|
||||||
dgroup = defgroup_name_index(ob, substring);
|
if (defgroup == -1) return;
|
||||||
if (dgroup < 0) return;
|
|
||||||
|
|
||||||
/* get DerivedMesh */
|
/* get DerivedMesh */
|
||||||
if (em) {
|
if (em) {
|
||||||
@ -463,28 +462,25 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat
|
|||||||
if (dm) {
|
if (dm) {
|
||||||
MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
|
MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
|
||||||
int numVerts = dm->getNumVerts(dm);
|
int numVerts = dm->getNumVerts(dm);
|
||||||
int i, j, count = 0;
|
int i, count = 0;
|
||||||
float co[3], nor[3];
|
float co[3], nor[3];
|
||||||
|
|
||||||
/* check that dvert is a valid pointers (just in case) */
|
/* check that dvert is a valid pointers (just in case) */
|
||||||
if (dvert) {
|
if (dvert) {
|
||||||
|
MDeformVert *dv= dvert;
|
||||||
/* get the average of all verts with that are in the vertex-group */
|
/* get the average of all verts with that are in the vertex-group */
|
||||||
for (i = 0; i < numVerts; i++) {
|
for (i = 0; i < numVerts; i++, dv++) {
|
||||||
for (j = 0; j < dvert[i].totweight; j++) {
|
MDeformWeight *dw= defvert_find_index(dv, defgroup);
|
||||||
/* does this vertex belong to nominated vertex group? */
|
if (dw && dw->weight != 0.0f) {
|
||||||
if (dvert[i].dw[j].def_nr == dgroup) {
|
dm->getVertCo(dm, i, co);
|
||||||
dm->getVertCo(dm, i, co);
|
dm->getVertNo(dm, i, nor);
|
||||||
dm->getVertNo(dm, i, nor);
|
add_v3_v3(vec, co);
|
||||||
add_v3_v3(vec, co);
|
add_v3_v3(normal, nor);
|
||||||
add_v3_v3(normal, nor);
|
count++;
|
||||||
count++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* calculate averages of normal and coordinates */
|
/* calculate averages of normal and coordinates */
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
mul_v3_fl(vec, 1.0f / count);
|
mul_v3_fl(vec, 1.0f / count);
|
||||||
@ -535,43 +531,38 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float
|
|||||||
float *co = dl?dl->verts:NULL;
|
float *co = dl?dl->verts:NULL;
|
||||||
BPoint *bp = lt->def;
|
BPoint *bp = lt->def;
|
||||||
|
|
||||||
MDeformVert *dvert = lt->dvert;
|
MDeformVert *dv = lt->dvert;
|
||||||
int tot_verts= lt->pntsu*lt->pntsv*lt->pntsw;
|
int tot_verts= lt->pntsu*lt->pntsv*lt->pntsw;
|
||||||
float vec[3]= {0.0f, 0.0f, 0.0f}, tvec[3];
|
float vec[3]= {0.0f, 0.0f, 0.0f}, tvec[3];
|
||||||
int dgroup=0, grouped=0;
|
int grouped=0;
|
||||||
int i, n;
|
int i, n;
|
||||||
|
const int defgroup= defgroup_name_index(ob, substring);
|
||||||
|
|
||||||
/* initialize target matrix using target matrix */
|
/* initialize target matrix using target matrix */
|
||||||
copy_m4_m4(mat, ob->obmat);
|
copy_m4_m4(mat, ob->obmat);
|
||||||
|
|
||||||
/* get index of vertex group */
|
/* get index of vertex group */
|
||||||
dgroup = defgroup_name_index(ob, substring);
|
if (defgroup == -1) return;
|
||||||
if (dgroup < 0) return;
|
if (dv == NULL) return;
|
||||||
if (dvert == NULL) return;
|
|
||||||
|
|
||||||
/* 1. Loop through control-points checking if in nominated vertex-group.
|
/* 1. Loop through control-points checking if in nominated vertex-group.
|
||||||
* 2. If it is, add it to vec to find the average point.
|
* 2. If it is, add it to vec to find the average point.
|
||||||
*/
|
*/
|
||||||
for (i=0; i < tot_verts; i++, dvert++) {
|
for (i=0; i < tot_verts; i++, dv++) {
|
||||||
for (n= 0; n < dvert->totweight; n++) {
|
for (n= 0; n < dv->totweight; n++) {
|
||||||
/* found match - vert is in vgroup */
|
MDeformWeight *dw= defvert_find_index(dv, defgroup);
|
||||||
if (dvert->dw[n].def_nr == dgroup) {
|
if (dw && dw->weight > 0.0f) {
|
||||||
/* copy coordinates of point to temporary vector, then add to find average */
|
/* copy coordinates of point to temporary vector, then add to find average */
|
||||||
if (co)
|
memcpy(tvec, co ? co : bp->vec, 3 * sizeof(float));
|
||||||
memcpy(tvec, co, 3*sizeof(float));
|
|
||||||
else
|
|
||||||
memcpy(tvec, bp->vec, 3*sizeof(float));
|
|
||||||
|
|
||||||
add_v3_v3(vec, tvec);
|
add_v3_v3(vec, tvec);
|
||||||
grouped++;
|
grouped++;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* advance pointer to coordinate data */
|
/* advance pointer to coordinate data */
|
||||||
if (co) co+= 3;
|
if (co) co += 3;
|
||||||
else bp++;
|
else bp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find average location, then multiply by ob->obmat to find world-space location */
|
/* find average location, then multiply by ob->obmat to find world-space location */
|
||||||
@ -1106,10 +1097,10 @@ static void kinematic_new_data (void *cdata)
|
|||||||
{
|
{
|
||||||
bKinematicConstraint *data= (bKinematicConstraint *)cdata;
|
bKinematicConstraint *data= (bKinematicConstraint *)cdata;
|
||||||
|
|
||||||
data->weight= (float)1.0;
|
data->weight= 1.0f;
|
||||||
data->orientweight= (float)1.0;
|
data->orientweight= 1.0f;
|
||||||
data->iterations = 500;
|
data->iterations = 500;
|
||||||
data->dist= (float)1.0;
|
data->dist= 1.0f;
|
||||||
data->flag= CONSTRAINT_IK_TIP|CONSTRAINT_IK_STRETCH|CONSTRAINT_IK_POS;
|
data->flag= CONSTRAINT_IK_TIP|CONSTRAINT_IK_STRETCH|CONSTRAINT_IK_POS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,6 +539,12 @@ float defvert_find_weight(const struct MDeformVert *dvert, const int defgroup)
|
|||||||
return dw ? dw->weight : 0.0f;
|
return dw ? dw->weight : 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* take care with this the rationale is:
|
||||||
|
* - if the object has no vertex group. act like vertex group isnt set and return 1.0,
|
||||||
|
* - if the vertex group exists but the 'defgroup' isnt found on this vertex, _still_ return 0.0
|
||||||
|
*
|
||||||
|
* This is a bit confusing, just saves some checks from the caller.
|
||||||
|
*/
|
||||||
float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup)
|
float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup)
|
||||||
{
|
{
|
||||||
if (defgroup == -1 || dvert == NULL)
|
if (defgroup == -1 || dvert == NULL)
|
||||||
|
@ -688,57 +688,51 @@ static void vgroup_copy_active_to_sel(Object *ob)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vgroup_copy_active_to_sel_single(Object *ob, int def_nr)
|
static void vgroup_copy_active_to_sel_single(Object *ob, const int def_nr)
|
||||||
{
|
{
|
||||||
EditVert *eve_act;
|
EditVert *eve_act;
|
||||||
MDeformVert *dvert_act;
|
MDeformVert *dv_act;
|
||||||
|
|
||||||
act_vert_def(ob, &eve_act, &dvert_act);
|
act_vert_def(ob, &eve_act, &dv_act);
|
||||||
|
|
||||||
if(dvert_act==NULL) {
|
if(dv_act==NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Mesh *me= ob->data;
|
Mesh *me= ob->data;
|
||||||
EditMesh *em = BKE_mesh_get_editmesh(me);
|
EditMesh *em = BKE_mesh_get_editmesh(me);
|
||||||
EditVert *eve;
|
EditVert *eve;
|
||||||
MDeformVert *dvert;
|
MDeformVert *dv;
|
||||||
MDeformWeight *dw;
|
MDeformWeight *dw;
|
||||||
float act_weight = -1.0f;
|
float weight_act;
|
||||||
int i;
|
|
||||||
int index= 0;
|
int index= 0;
|
||||||
|
|
||||||
for(i=0, dw=dvert_act->dw; i < dvert_act->totweight; i++, dw++) {
|
dw= defvert_find_index(dv_act, def_nr);
|
||||||
if(def_nr == dw->def_nr) {
|
|
||||||
act_weight= dw->weight;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(act_weight < -0.5f)
|
if(dw == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(eve= em->verts.first; eve; eve= eve->next, index++) {
|
weight_act= dw->weight;
|
||||||
if(eve->f & SELECT && eve != eve_act) {
|
|
||||||
dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
|
|
||||||
if(dvert) {
|
|
||||||
for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) {
|
|
||||||
if(def_nr == dw->def_nr) {
|
|
||||||
dw->weight= act_weight;
|
|
||||||
|
|
||||||
if(me->editflag & ME_EDIT_MIRROR_X)
|
for (eve= em->verts.first; eve; eve= eve->next, index++) {
|
||||||
editvert_mirror_update(ob, eve, -1, index);
|
if (eve->f & SELECT && eve != eve_act) {
|
||||||
|
dv= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
|
||||||
|
if(dv) {
|
||||||
|
dw= defvert_find_index(dv, def_nr);
|
||||||
|
if (dw) {
|
||||||
|
dw->weight= weight_act;
|
||||||
|
|
||||||
break;
|
if (me->editflag & ME_EDIT_MIRROR_X) {
|
||||||
|
editvert_mirror_update(ob, eve, -1, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(me->editflag & ME_EDIT_MIRROR_X)
|
if (me->editflag & ME_EDIT_MIRROR_X) {
|
||||||
editvert_mirror_update(ob, eve_act, -1, -1);
|
editvert_mirror_update(ob, eve_act, -1, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,14 +802,15 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
|
|||||||
Object *ob= OBACT;
|
Object *ob= OBACT;
|
||||||
|
|
||||||
EditVert *eve;
|
EditVert *eve;
|
||||||
MDeformVert *dvert;
|
MDeformVert *dv;
|
||||||
|
|
||||||
act_vert_def(ob, &eve, &dvert);
|
act_vert_def(ob, &eve, &dv);
|
||||||
|
|
||||||
if(dvert && dvert->totweight) {
|
if(dv && dv->totweight) {
|
||||||
uiLayout *col;
|
uiLayout *col;
|
||||||
bDeformGroup *dg;
|
bDeformGroup *dg;
|
||||||
int i;
|
MDeformWeight *dw = dv->dw;
|
||||||
|
unsigned int i;
|
||||||
int yco = 0;
|
int yco = 0;
|
||||||
|
|
||||||
uiBlockSetHandleFunc(block, do_view3d_vgroup_buttons, NULL);
|
uiBlockSetHandleFunc(block, do_view3d_vgroup_buttons, NULL);
|
||||||
@ -825,11 +820,11 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa)
|
|||||||
|
|
||||||
uiBlockBeginAlign(block);
|
uiBlockBeginAlign(block);
|
||||||
|
|
||||||
for (i=0; i<dvert->totweight; i++){
|
for (i= dv->totweight; i != 0; i--, dw++) {
|
||||||
dg = BLI_findlink (&ob->defbase, dvert->dw[i].def_nr);
|
dg = BLI_findlink (&ob->defbase, dw->def_nr);
|
||||||
if(dg) {
|
if(dg) {
|
||||||
uiDefButF(block, NUM, B_VGRP_PNL_EDIT_SINGLE + dvert->dw[i].def_nr, dg->name, 0, yco, 180, 20, &dvert->dw[i].weight, 0.0, 1.0, 1, 3, "");
|
uiDefButF(block, NUM, B_VGRP_PNL_EDIT_SINGLE + dw->def_nr, dg->name, 0, yco, 180, 20, &dw->weight, 0.0, 1.0, 1, 3, "");
|
||||||
uiDefBut(block, BUT, B_VGRP_PNL_COPY_SINGLE + dvert->dw[i].def_nr, "C", 180,yco,20,20, NULL, 0, 0, 0, 0, "Copy this groups weight to other selected verts");
|
uiDefBut(block, BUT, B_VGRP_PNL_COPY_SINGLE + dw->def_nr, "C", 180,yco,20,20, NULL, 0, 0, 0, 0, "Copy this groups weight to other selected verts");
|
||||||
yco -= 20;
|
yco -= 20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,11 +200,11 @@ static void sphere_do(
|
|||||||
* with or w/o a vgroup. With lots of if's in the code below,
|
* with or w/o a vgroup. With lots of if's in the code below,
|
||||||
* further optimizations are possible, if needed */
|
* further optimizations are possible, if needed */
|
||||||
if (dvert) { /* with a vgroup */
|
if (dvert) { /* with a vgroup */
|
||||||
|
MDeformVert *dv= dvert;
|
||||||
float fac_orig = fac;
|
float fac_orig = fac;
|
||||||
for (i = 0; i < numVerts; i++) {
|
for (i = 0; i < numVerts; i++, dv++) {
|
||||||
MDeformWeight *dw = NULL;
|
|
||||||
int j;
|
|
||||||
float tmp_co[3];
|
float tmp_co[3];
|
||||||
|
float weight;
|
||||||
|
|
||||||
copy_v3_v3(tmp_co, vertexCos[i]);
|
copy_v3_v3(tmp_co, vertexCos[i]);
|
||||||
if(ctrl_ob) {
|
if(ctrl_ob) {
|
||||||
@ -224,15 +224,10 @@ static void sphere_do(
|
|||||||
if (len_v3(vec) > cmd->radius) continue;
|
if (len_v3(vec) > cmd->radius) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < dvert[i].totweight; ++j) {
|
weight= defvert_find_weight(dv, defgrp_index);
|
||||||
if(dvert[i].dw[j].def_nr == defgrp_index) {
|
if (weight <= 0.0f) continue;
|
||||||
dw = &dvert[i].dw[j];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!dw) continue;
|
|
||||||
|
|
||||||
fac = fac_orig * dw->weight;
|
fac = fac_orig * weight;
|
||||||
facm = 1.0f - fac;
|
facm = 1.0f - fac;
|
||||||
|
|
||||||
normalize_v3(vec);
|
normalize_v3(vec);
|
||||||
|
@ -188,7 +188,6 @@ static void meshdeformModifier_do(
|
|||||||
struct EditMesh *em = (me)? BKE_mesh_get_editmesh(me): NULL;
|
struct EditMesh *em = (me)? BKE_mesh_get_editmesh(me): NULL;
|
||||||
DerivedMesh *tmpdm, *cagedm;
|
DerivedMesh *tmpdm, *cagedm;
|
||||||
MDeformVert *dvert = NULL;
|
MDeformVert *dvert = NULL;
|
||||||
MDeformWeight *dw;
|
|
||||||
MDefInfluence *influences;
|
MDefInfluence *influences;
|
||||||
int *offsets;
|
int *offsets;
|
||||||
float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
|
float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
|
||||||
@ -293,21 +292,14 @@ static void meshdeformModifier_do(
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(dvert) {
|
if(dvert) {
|
||||||
for(dw=NULL, a=0; a<dvert[b].totweight; a++) {
|
fac= defvert_find_weight(&dvert[b], defgrp_index);
|
||||||
if(dvert[b].dw[a].def_nr == defgrp_index) {
|
|
||||||
dw = &dvert[b].dw[a];
|
if (mmd->flag & MOD_MDEF_INVERT_VGROUP) {
|
||||||
break;
|
fac= 1.0f - fac;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mmd->flag & MOD_MDEF_INVERT_VGROUP) {
|
if (fac <= 0.0) {
|
||||||
if(!dw) fac= 1.0f;
|
continue;
|
||||||
else if(dw->weight == 1.0f) continue;
|
|
||||||
else fac=1.0f-dw->weight;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(!dw) continue;
|
|
||||||
else fac= dw->weight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,24 +154,19 @@ static void smoothModifier_do(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dvert) {
|
if (dvert) {
|
||||||
for (i = 0; i < numVerts; i++) {
|
MDeformVert *dv= dvert;
|
||||||
MDeformWeight *dw = NULL;
|
for (i = 0; i < numVerts; i++, dv++) {
|
||||||
float f, fm, facw, *fp, *v;
|
float f, fm, facw, *fp, *v;
|
||||||
int k;
|
|
||||||
short flag = smd->flag;
|
short flag = smd->flag;
|
||||||
|
|
||||||
v = vertexCos[i];
|
v = vertexCos[i];
|
||||||
fp = &ftmp[i*3];
|
fp = &ftmp[i*3];
|
||||||
|
|
||||||
for (k = 0; k < dvert[i].totweight; ++k) {
|
|
||||||
if(dvert[i].dw[k].def_nr == defgrp_index) {
|
|
||||||
dw = &dvert[i].dw[k];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!dw) continue;
|
|
||||||
|
|
||||||
f = fac * dw->weight;
|
f= defvert_find_weight(dv, defgrp_index);
|
||||||
|
if (f <= 0.0f) continue;
|
||||||
|
|
||||||
|
f *= fac;
|
||||||
fm = 1.0f - f;
|
fm = 1.0f - f;
|
||||||
|
|
||||||
/* fp is the sum of uctmp[i] verts, so must be averaged */
|
/* fp is the sum of uctmp[i] verts, so must be averaged */
|
||||||
|
@ -237,12 +237,12 @@ void BL_SkinDeformer::BGEDeformVerts()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MDeformVert *dv= dverts;
|
||||||
|
|
||||||
for (int i=0; i<m_bmesh->totvert; ++i)
|
for (int i=0; i<m_bmesh->totvert; ++i, dv++)
|
||||||
{
|
{
|
||||||
float contrib = 0.f, weight, max_weight=0.f;
|
float contrib = 0.f, weight, max_weight=0.f;
|
||||||
bPoseChannel *pchan=NULL;
|
bPoseChannel *pchan=NULL;
|
||||||
MDeformVert *dvert;
|
|
||||||
Eigen::Map<Eigen::Vector3f> norm(m_transnors[i]);
|
Eigen::Map<Eigen::Vector3f> norm(m_transnors[i]);
|
||||||
Eigen::Vector4f vec(0, 0, 0, 1);
|
Eigen::Vector4f vec(0, 0, 0, 1);
|
||||||
Eigen::Matrix4f norm_chan_mat;
|
Eigen::Matrix4f norm_chan_mat;
|
||||||
@ -251,18 +251,18 @@ void BL_SkinDeformer::BGEDeformVerts()
|
|||||||
m_transverts[i][2],
|
m_transverts[i][2],
|
||||||
1.f);
|
1.f);
|
||||||
|
|
||||||
dvert = dverts+i;
|
if (!dv->totweight)
|
||||||
|
|
||||||
if (!dvert->totweight)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (int j=0; j<dvert->totweight; ++j)
|
MDeformWeight *dw= dv->dw;
|
||||||
|
|
||||||
|
for (unsigned int j= dv->totweight; j != 0; j--, dw++)
|
||||||
{
|
{
|
||||||
int index = dvert->dw[j].def_nr;
|
const int index = dw->def_nr;
|
||||||
|
|
||||||
if (index < defbase_tot && (pchan=m_dfnrToPC[index]))
|
if (index < defbase_tot && (pchan=m_dfnrToPC[index]))
|
||||||
{
|
{
|
||||||
weight = dvert->dw[j].weight;
|
weight = dw->weight;
|
||||||
|
|
||||||
if (weight)
|
if (weight)
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@ set(INC
|
|||||||
../Ketsji
|
../Ketsji
|
||||||
../SceneGraph
|
../SceneGraph
|
||||||
../../blender/makesdna
|
../../blender/makesdna
|
||||||
|
../../blender/blenkernel
|
||||||
../../../intern/container
|
../../../intern/container
|
||||||
../../../intern/guardedalloc
|
../../../intern/guardedalloc
|
||||||
../../../intern/moto/include
|
../../../intern/moto/include
|
||||||
|
@ -43,6 +43,10 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
# include "BKE_deform.h"
|
||||||
|
}
|
||||||
|
|
||||||
/* polygon sorting */
|
/* polygon sorting */
|
||||||
|
|
||||||
struct RAS_MeshObject::polygonSlot
|
struct RAS_MeshObject::polygonSlot
|
||||||
@ -573,8 +577,8 @@ void RAS_MeshObject::CheckWeightCache(Object* obj)
|
|||||||
{
|
{
|
||||||
KeyBlock *kb;
|
KeyBlock *kb;
|
||||||
int kbindex, defindex;
|
int kbindex, defindex;
|
||||||
MDeformVert *dvert= NULL;
|
MDeformVert *dv= NULL;
|
||||||
int totvert, i, j;
|
int totvert, i;
|
||||||
float *weights;
|
float *weights;
|
||||||
|
|
||||||
if (!m_mesh->key)
|
if (!m_mesh->key)
|
||||||
@ -598,19 +602,15 @@ void RAS_MeshObject::CheckWeightCache(Object* obj)
|
|||||||
kb->weights = NULL;
|
kb->weights = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dvert= m_mesh->dvert;
|
dv= m_mesh->dvert;
|
||||||
totvert= m_mesh->totvert;
|
totvert= m_mesh->totvert;
|
||||||
|
|
||||||
weights= (float*)MEM_callocN(totvert*sizeof(float), "weights");
|
weights= (float*)MEM_mallocN(totvert*sizeof(float), "weights");
|
||||||
|
|
||||||
for (i=0; i < totvert; i++, dvert++) {
|
for (i=0; i < totvert; i++, dv++) {
|
||||||
for(j=0; j<dvert->totweight; j++) {
|
weights[i]= defvert_find_weight(dv, defindex);
|
||||||
if (dvert->dw[j].def_nr == defindex) {
|
|
||||||
weights[i]= dvert->dw[j].weight;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kb->weights = weights;
|
kb->weights = weights;
|
||||||
m_cacheWeightIndex[kbindex] = defindex;
|
m_cacheWeightIndex[kbindex] = defindex;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user