[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15227] trunk/blender/source: BGE patch: support Set Scene in BGE.

Benoit Bolsee benoit.bolsee at online.be
Sat Jun 14 22:42:16 CEST 2008


Revision: 15227
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15227
Author:   ben2610
Date:     2008-06-14 22:42:15 +0200 (Sat, 14 Jun 2008)

Log Message:
-----------
BGE patch: support Set Scene in BGE. Linked Set Scene should have no name conflict in Object, Object data and Action of the main scene to avoid confusion in Python scripting. Nested Set Scene are supported. You will need Python scripting to create cross references between objects in the main scene and the Set (e.g TrackTo actuator)

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_scene.h
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp

Modified: trunk/blender/source/blender/blenkernel/BKE_scene.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_scene.h	2008-06-14 20:34:40 UTC (rev 15226)
+++ trunk/blender/source/blender/blenkernel/BKE_scene.h	2008-06-14 20:42:15 UTC (rev 15227)
@@ -53,7 +53,7 @@
 }
 
 /* note; doesn't work when scene is empty */
-#define SETLOOPER(s, b) sce= s, b= sce->base.first; b; b= (b->next?b->next:sce->set?(sce=sce->set)->base.first:NULL)
+#define SETLOOPER(s, b) sce= s, b= (Base*)sce->base.first; b; b= (Base*)(b->next?b->next:sce->set?(sce=sce->set)->base.first:NULL)
 
 
 void free_avicodecdata(struct AviCodecData *acd);

Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2008-06-14 20:34:40 UTC (rev 15226)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2008-06-14 20:42:15 UTC (rev 15227)
@@ -88,6 +88,7 @@
 #include "BKE_main.h"
 #include "BKE_global.h"
 #include "BKE_object.h"
+#include "BKE_scene.h"
 #include "BL_SkinMeshObject.h"
 #include "BL_SkinDeformer.h"
 #include "BL_MeshDeformer.h"
@@ -1808,6 +1809,9 @@
 {	
 
 	Scene *blenderscene = GetSceneForName(maggie, scenename);
+	// for SETLOOPER
+	Scene *sce;
+	Base *base;
 
 	// Get the frame settings of the canvas.
 	// Get the aspect ratio of the canvas as designed by the user.
@@ -1881,9 +1885,11 @@
 	}
 
 	SetDefaultFaceType(blenderscene);
-	
-	Base *base = static_cast<Base*>(blenderscene->base.first);
-	while(base)
+	// Let's support scene set.
+	// Beware of name conflict in linked data, it will not crash but will create confusion
+	// in Python scripting and in certain actuators (replace mesh). Linked scene *should* have
+	// no conflicting name for Object, Object data and Action.
+	for (SETLOOPER(blenderscene, base))
 	{
 		Object* blenderobject = base->object;
 		KX_GameObject* gameobj = gameobject_from_blenderobject(
@@ -2038,7 +2044,6 @@
 		if (gameobj)
 			gameobj->Release();
 
-		base = base->next;
 	}
 
 	if (blenderscene->camera) {
@@ -2048,7 +2053,7 @@
 	}
 
 	//	Set up armatures
-	for (base = static_cast<Base*>(blenderscene->base.first); base; base=base->next){
+	for(SETLOOPER(blenderscene, base)){
 		if (base->object->type==OB_MESH){
 			Mesh *me = (Mesh*)base->object->data;
 	





More information about the Bf-blender-cvs mailing list