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.
This commit is contained in:
@@ -1694,12 +1694,16 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA
|
||||
return false;
|
||||
|
||||
RAS_Deformer *deformer= gameobj ? gameobj->GetDeformer():NULL;
|
||||
DerivedMesh* dm = NULL;
|
||||
|
||||
if (deformer)
|
||||
dm = deformer->GetPhysicsMesh();
|
||||
|
||||
/* get the mesh from the object if not defined */
|
||||
if(meshobj==NULL) {
|
||||
|
||||
/* modifier mesh */
|
||||
if(deformer && deformer->GetFinalMesh())
|
||||
if(dm)
|
||||
meshobj= deformer->GetRasMesh();
|
||||
|
||||
/* game object first mesh */
|
||||
@@ -1710,14 +1714,12 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA
|
||||
}
|
||||
}
|
||||
|
||||
if(deformer && deformer->GetFinalMesh() && deformer->GetRasMesh() == meshobj)
|
||||
if(dm && deformer->GetRasMesh() == meshobj)
|
||||
{ /*
|
||||
* Derived Mesh Update
|
||||
*
|
||||
* */
|
||||
|
||||
DerivedMesh* dm= gameobj->GetDeformer()->GetFinalMesh();
|
||||
|
||||
MVert *mvert = dm->getVertArray(dm);
|
||||
MFace *mface = dm->getFaceArray(dm);
|
||||
numpolys = dm->getNumFaces(dm);
|
||||
@@ -1977,6 +1979,10 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA
|
||||
|
||||
m_meshObject= meshobj;
|
||||
|
||||
if (dm) {
|
||||
dm->needsFree = 1;
|
||||
dm->release(dm);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user