so I added short deformflag; to class BL_SkinDeformer : public BL_MeshDeformer
and modified constructor
BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject gameobj,
struct Object bmeshobj,
class RAS_MeshObject mesh,
BL_ArmatureObject arma)
: //
BL_MeshDeformer(gameobj, bmeshobj, mesh),
m_armobj(arma),
m_lastArmaUpdate(-1),
//m_defbase(&bmeshobj->defbase),
m_releaseobject(false),
m_poseApplied(false),
m_recalcNormal(true)
{
copy_m4_m4(m_obmat, bmeshobj->obmat);
deformflag = ARM_DEF_VGROUP;
ModifierData md;
for (md = (ModifierData)bmeshobj->modifiers.first; md; md = (ModifierData*)md->next) {
/* armature modifier are handled by SkinDeformer, not ModifierDeformer /
if (md->type == eModifierType_Armature )
{
//continue;
deformflag |= ((ArmatureModifierData)md)->deformflag;
break;
}
}
};
now bool BL_SkinDeformer::UpdateInternal(bool shape_applied) looks like:
bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
{
/* See if the armature has been updated for this frame */
if (PoseUpdated()){
float obmat[4][4]; // the original object matrice
/* XXX note: where_is_pose() (from BKE_armature.h) calculates all matrices needed to start deforming */
/* but it requires the blender object pointer... */
Object* par_arma = m_armobj->GetArmatureObject();
//ArmatureModifierData *amd = (ArmatureModifierData*) md;
if(!shape_applied) {
/* store verts locally */
VerifyStorage();
/* duplicate */
for (int v =0; v<m_bmesh->totvert; v++)
VECCOPY(m_transverts[v], m_bmesh->mvert[v].co);
}
m_armobj->ApplyPose();
// save matrix first
copy_m4_m4(obmat, m_objMesh->obmat);
// set reference matrix
copy_m4_m4(m_objMesh->obmat, m_obmat);
armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, deformflag /*ARM_DEF_VGROUP*/, NULL, NULL );
// restore matrix
copy_m4_m4(m_objMesh->obmat, obmat);
#ifdef __NLA_DEFNORMALS
if (m_recalcNormal)
RecalcNormals();
#endif
/* Update the current frame */
m_lastArmaUpdate=m_armobj->GetLastFrame();
m_armobj->RestorePose();
/* dynamic vertex, cannot use display list */
m_bDynamic = true;
/* indicate that the m_transverts and normals are up to date */
return true;
}
return false;
}
now I have properly preserved volume.
But not sure if this is correct way to make things - so if someone of devs could look into issue, that will be fine