BGE modifier: generate correct physic shape, share static derived mesh, share display...
[blender.git] / source / gameengine / Converter / BL_SkinDeformer.cpp
index e92c3b29543a6d8e3e099ae541e2ce5b8361d655..a13f78e1b27ef5175bcd71b18221f9bc1495feca 100644 (file)
@@ -127,24 +127,26 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
        if (!Update())
                return false;
 
-       // the vertex cache is unique to this deformer, no need to update it
-       // if it wasn't updated! We must update all the materials at once
-       // because we will not get here again for the other material
-       nmat = m_pMeshObject->NumMaterials();
-       for (imat=0; imat<nmat; imat++) {
-               mmat = m_pMeshObject->GetMeshMaterial(imat);
-               if(!mmat->m_slots[(void*)m_gameobj])
-                       continue;
-
-               slot = *mmat->m_slots[(void*)m_gameobj];
-
-               // for each array
-               for(slot->begin(it); !slot->end(it); slot->next(it)) {
-                       // for each vertex
-                       // copy the untransformed data from the original mvert
-                       for(i=it.startvertex; i<it.endvertex; i++) {
-                               RAS_TexVert& v = it.vertex[i];
-                               v.SetXYZ(m_transverts[v.getOrigIndex()]);
+       if (m_transverts) {
+               // the vertex cache is unique to this deformer, no need to update it
+               // if it wasn't updated! We must update all the materials at once
+               // because we will not get here again for the other material
+               nmat = m_pMeshObject->NumMaterials();
+               for (imat=0; imat<nmat; imat++) {
+                       mmat = m_pMeshObject->GetMeshMaterial(imat);
+                       if(!mmat->m_slots[(void*)m_gameobj])
+                               continue;
+
+                       slot = *mmat->m_slots[(void*)m_gameobj];
+
+                       // for each array
+                       for(slot->begin(it); !slot->end(it); slot->next(it)) {
+                               // for each vertex
+                               // copy the untransformed data from the original mvert
+                               for(i=it.startvertex; i<it.endvertex; i++) {
+                                       RAS_TexVert& v = it.vertex[i];
+                                       v.SetXYZ(m_transverts[v.getOrigIndex()]);
+                               }
                        }
                }
        }
@@ -161,6 +163,13 @@ RAS_Deformer *BL_SkinDeformer::GetReplica()
        return result;
 }
 
+void BL_SkinDeformer::ProcessReplica()
+{
+       BL_MeshDeformer::ProcessReplica();
+       m_lastArmaUpdate = -1;
+       m_releaseobject = false;
+}
+
 //void where_is_pose (Object *ob);
 //void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], int numVerts, int deformflag); 
 bool BL_SkinDeformer::Update(void)