diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2011-01-23 20:17:21 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2011-01-23 20:17:21 +0300 |
commit | fc66b3f2efcb5b7579f06c1966900b2ecf3c1310 (patch) | |
tree | 029fa673af575ff1f3fce63e49c29fa2359be360 /source/gameengine/Converter/BL_ModifierDeformer.cpp | |
parent | fa38da021cd08409f1bda4722a6cf8a607f86838 (diff) |
BGE: support modifiers without mapping to original mesh both graphically and physically, fixes bug #24942 and #25286.
Support for physics is done by skiping the modifiers that
don't support mapping to original mesh. This mapping is
required to report the hit polygon to the application
by the rayCast() function.
Support for graphics is done by using the same render
function that blender uses for the 3D view. This guantees
equal result.
Limitation: there is still a known bug if all these conditions are met:
- Display list enabled
- Old tex face with a several textures mapped to the same material
- no armature or shape keys
- active modifiers
In this case, only a part of the mesh will be rendered
with the wrong texture. To avoid this bug, use the GLSL
materials or make sure to have 1 material=1 texture in
your old tex face objects.
Diffstat (limited to 'source/gameengine/Converter/BL_ModifierDeformer.cpp')
-rw-r--r-- | source/gameengine/Converter/BL_ModifierDeformer.cpp | 24 |
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(); |