preserve volume for armature modifier does not work #27472

Closed
opened 2011-05-24 17:02:01 +02:00 by Sergey Kurdakov · 4 comments

%%% In Blender 2.57b when applying armature 'preserve volume' option preview with character works just fine, but in game engine it does not work (works as if no preserve volume).

see example
http://www.sim-ai.org/Armature.blend or attachment

proposed fix ( just to show how to fix example):

add
short deformflag;

to class BL_SkinDeformer : public BL_MeshDeformer

modified constructor for BL_SkinDeformer should init deformflag

BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGame Object *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 ( see modified armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, deformflag /ARM_DEF_VGROUP/, NULL, NULL ); ) :

bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
{
/* See if the armature has been updated for this frame */
if (PoseUpdated()){
float obmat- [x]- [x]; // 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- [x], m_bmesh->mvert- [x].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;
}

%%%

%%% In Blender 2.57b when applying armature 'preserve volume' option preview with character works just fine, but in game engine it does not work (works as if no preserve volume). see example http://www.sim-ai.org/Armature.blend or attachment proposed fix ( just to show how to fix example): add short deformflag; to class BL_SkinDeformer : public BL_MeshDeformer modified constructor for BL_SkinDeformer should init deformflag BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGame Object *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 ( see modified armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, deformflag /*ARM_DEF_VGROUP*/, NULL, NULL ); ) : bool BL_SkinDeformer::UpdateInternal(bool shape_applied) { /* See if the armature has been updated for this frame */ if (PoseUpdated()){ float obmat- [x]- [x]; // 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- [x], m_bmesh->mvert- [x].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; } %%%

Changed status to: 'Open'

Changed status to: 'Open'

%%%I've committed a fix as r47304. Thanks for code! Although, next time could you please post a diff instead? Also, could you verify that r47304 solves your problem?%%%

%%%I've committed a fix as r47304. Thanks for code! Although, next time could you please post a diff instead? Also, could you verify that r47304 solves your problem?%%%

%%%It has been over a week without a response, so I'm going to consider this fixed. If you still have problems, please open a new report.%%%

%%%It has been over a week without a response, so I'm going to consider this fixed. If you still have problems, please open a new report.%%%

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#27472
No description provided.