Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/Converter/BL_ModifierDeformer.cpp')
-rw-r--r--source/gameengine/Converter/BL_ModifierDeformer.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp
index 5eb25b05567..205892f5c77 100644
--- a/source/gameengine/Converter/BL_ModifierDeformer.cpp
+++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp
@@ -135,6 +135,30 @@ bool BL_ModifierDeformer::HasArmatureDeformer(Object *ob)
return false;
}
+// return a deformed mesh that supports mapping (with a valid CD_ORIGINDEX layer)
+struct DerivedMesh* BL_ModifierDeformer::GetPhysicsMesh()
+{
+ // we need to compute the deformed mesh taking into account the current
+ // shape and skin deformers, we cannot just call mesh_create_derived_physics()
+ // because that would use the m_transvers already deformed previously by BL_ModifierDeformer::Update(),
+ // so restart from scratch by forcing a full update the shape/skin deformers
+ // (will do nothing if there is no such deformer)
+ BL_ShapeDeformer::ForceUpdate();
+ BL_ShapeDeformer::Update();
+ // now apply the modifiers but without those that don't support mapping
+ Object* blendobj = m_gameobj->GetBlendObject();
+ /* hack: the modifiers require that the mesh is attached to the object
+ It may not be the case here because of replace mesh actuator */
+ Mesh *oldmesh = (Mesh*)blendobj->data;
+ blendobj->data = m_bmesh;
+ DerivedMesh *dm = mesh_create_derived_physics(m_scene, blendobj, m_transverts, CD_MASK_MESH);
+ /* restore object data */
+ blendobj->data = oldmesh;
+ /* m_transverts is correct here (takes into account deform only modifiers) */
+ /* the derived mesh returned by this function must be released by the caller !!! */
+ return dm;
+}
+
bool BL_ModifierDeformer::Update(void)
{
bool bShapeUpdate = BL_ShapeDeformer::Update();