[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20272] trunk/blender/source/gameengine: BGE bug #18762 fixed: softbody.

Benoit Bolsee benoit.bolsee at online.be
Tue May 19 08:48:37 CEST 2009


Revision: 20272
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20272
Author:   ben2610
Date:     2009-05-19 08:48:36 +0200 (Tue, 19 May 2009)

Log Message:
-----------
BGE bug #18762 fixed: softbody. An incompatibility between the soft body deformer and other types of deformer was causing the soft body to disappear in the game. This was the case when the soft body had an armature or simply vertex groups.

Modified Paths:
--------------
    trunk/blender/source/gameengine/Converter/BL_SkinDeformer.h
    trunk/blender/source/gameengine/Rasterizer/RAS_Deformer.h
    trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp

Modified: trunk/blender/source/gameengine/Converter/BL_SkinDeformer.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_SkinDeformer.h	2009-05-19 05:07:52 UTC (rev 20271)
+++ trunk/blender/source/gameengine/Converter/BL_SkinDeformer.h	2009-05-19 06:48:36 UTC (rev 20272)
@@ -90,6 +90,10 @@
 	{
 		m_lastArmaUpdate = -1.0;
 	};
+	virtual bool ShareVertexArray()
+	{
+		return false;
+	}
 
 protected:
 	BL_ArmatureObject*		m_armobj;	//	Our parent object

Modified: trunk/blender/source/gameengine/Rasterizer/RAS_Deformer.h
===================================================================
--- trunk/blender/source/gameengine/Rasterizer/RAS_Deformer.h	2009-05-19 05:07:52 UTC (rev 20271)
+++ trunk/blender/source/gameengine/Rasterizer/RAS_Deformer.h	2009-05-19 06:48:36 UTC (rev 20272)
@@ -54,6 +54,10 @@
 	{
 		return false;
 	}
+	virtual bool ShareVertexArray()
+	{
+		return true;
+	}
 	virtual bool UseVertexArray()
 	{
 		return true;

Modified: trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
===================================================================
--- trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp	2009-05-19 05:07:52 UTC (rev 20271)
+++ trunk/blender/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp	2009-05-19 06:48:36 UTC (rev 20272)
@@ -284,36 +284,56 @@
 void RAS_MeshSlot::SetDeformer(RAS_Deformer* deformer)
 {
 	if (deformer && m_pDeformer != deformer) {
-		// we create local copy of RAS_DisplayArray when we have a deformer:
-		// this way we can avoid conflict between the vertex cache of duplicates
 		RAS_DisplayArrayList::iterator it;
-		for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
-			if (deformer->UseVertexArray()) {
-				// the deformer makes use of vertex array, make sure we have our local copy
-				if ((*it)->m_users > 1) {
-					// only need to copy if there are other users
-					// note that this is the usual case as vertex arrays are held by the material base slot
-					RAS_DisplayArray *newarray = new RAS_DisplayArray(*(*it));
-					newarray->m_users = 1;
-					(*it)->m_users--;
-					*it = newarray;
-				}
-			} else {
-				// the deformer is not using vertex array (Modifier), release them
+		if (deformer->ShareVertexArray()) {
+			// this deformer uses the base vertex array, first release the current ones
+			for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
 				(*it)->m_users--;
 				if((*it)->m_users == 0)
 					delete *it;
 			}
-		}
-		if (!deformer->UseVertexArray()) {
 			m_displayArrays.clear();
-			m_startarray = 0;
-			m_startvertex = 0;
-			m_startindex = 0;
-			m_endarray = 0;
-			m_endvertex = 0;
-			m_endindex = 0;
+			// then hook to the base ones
+			RAS_MeshMaterial *mmat = m_mesh->GetMeshMaterial(m_bucket->GetPolyMaterial());
+			if (mmat && mmat->m_baseslot) {
+				m_displayArrays = mmat->m_baseslot->m_displayArrays;
+				for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+					(*it)->m_users++;
+				}
+			}
 		}
+		else {
+			// no sharing
+			// we create local copy of RAS_DisplayArray when we have a deformer:
+			// this way we can avoid conflict between the vertex cache of duplicates
+			for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+				if (deformer->UseVertexArray()) {
+					// the deformer makes use of vertex array, make sure we have our local copy
+					if ((*it)->m_users > 1) {
+						// only need to copy if there are other users
+						// note that this is the usual case as vertex arrays are held by the material base slot
+						RAS_DisplayArray *newarray = new RAS_DisplayArray(*(*it));
+						newarray->m_users = 1;
+						(*it)->m_users--;
+						*it = newarray;
+					}
+				} else {
+					// the deformer is not using vertex array (Modifier), release them
+					(*it)->m_users--;
+					if((*it)->m_users == 0)
+						delete *it;
+				}
+			}
+			if (!deformer->UseVertexArray()) {
+				m_displayArrays.clear();
+				m_startarray = 0;
+				m_startvertex = 0;
+				m_startindex = 0;
+				m_endarray = 0;
+				m_endvertex = 0;
+				m_endindex = 0;
+			}
+		}
 	}
 	m_pDeformer = deformer;
 }





More information about the Bf-blender-cvs mailing list