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)

This commit is contained in:
Benoit Bolsee 2008-06-14 20:42:15 +00:00
parent 13d081c62c
commit 89c1875bc9
2 changed files with 11 additions and 6 deletions

@ -53,7 +53,7 @@ struct RenderData;
}
/* 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);

@ -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 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
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 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
}
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 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
if (gameobj)
gameobj->Release();
base = base->next;
}
if (blenderscene->camera) {
@ -2048,7 +2053,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
}
// 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;