@@ -40,6 +40,7 @@
|
|||||||
#include "KX_KetsjiEngine.h"
|
#include "KX_KetsjiEngine.h"
|
||||||
#include "KX_IPhysicsController.h"
|
#include "KX_IPhysicsController.h"
|
||||||
#include "BL_Material.h"
|
#include "BL_Material.h"
|
||||||
|
#include "BL_ActionActuator.h"
|
||||||
#include "KX_BlenderMaterial.h"
|
#include "KX_BlenderMaterial.h"
|
||||||
#include "KX_PolygonMaterial.h"
|
#include "KX_PolygonMaterial.h"
|
||||||
|
|
||||||
@@ -960,7 +961,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha
|
|||||||
static char err_local[255];
|
static char err_local[255];
|
||||||
|
|
||||||
/* only scene and mesh supported right now */
|
/* only scene and mesh supported right now */
|
||||||
if(idcode!=ID_SCE && idcode!=ID_ME) {
|
if(idcode!=ID_SCE && idcode!=ID_ME &&idcode!=ID_AC) {
|
||||||
snprintf(err_local, sizeof(err_local), "invalid ID type given \"%s\"\n", group);
|
snprintf(err_local, sizeof(err_local), "invalid ID type given \"%s\"\n", group);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1018,6 +1019,16 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha
|
|||||||
kx_scene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
|
kx_scene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(idcode==ID_AC) {
|
||||||
|
/* Convert all actions */
|
||||||
|
ID *action;
|
||||||
|
KX_Scene *kx_scene= m_currentScene;
|
||||||
|
|
||||||
|
for(action= (ID *)main_newlib->action.first; action; action= (ID *)action->next) {
|
||||||
|
printf("ActionName: %s\n", action->name);
|
||||||
|
kx_scene->GetLogicManager()->RegisterActionName(action->name+2, action);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(idcode==ID_SCE) {
|
else if(idcode==ID_SCE) {
|
||||||
/* Merge all new linked in scene into the existing one */
|
/* Merge all new linked in scene into the existing one */
|
||||||
ID *scene;
|
ID *scene;
|
||||||
@@ -1092,6 +1103,23 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now unregister actions */
|
||||||
|
{
|
||||||
|
GEN_Map<STR_HashedString,void*> &mapStringToActions = scene->GetLogicManager()->GetActionMap();
|
||||||
|
|
||||||
|
for(int i=0; i<mapStringToActions.size(); i++)
|
||||||
|
{
|
||||||
|
ID *action= (ID*) *mapStringToActions.at(i);
|
||||||
|
|
||||||
|
if(IS_TAGGED(action))
|
||||||
|
{
|
||||||
|
STR_HashedString an = action->name+2;
|
||||||
|
mapStringToActions.remove(an);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//scene->FreeTagged(); /* removed tagged objects and meshes*/
|
//scene->FreeTagged(); /* removed tagged objects and meshes*/
|
||||||
CListValue *obj_lists[] = {scene->GetObjectList(), scene->GetInactiveList(), NULL};
|
CListValue *obj_lists[] = {scene->GetObjectList(), scene->GetInactiveList(), NULL};
|
||||||
@@ -1128,6 +1156,17 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* make sure action actuators are not referencing tagged actions */
|
||||||
|
for (int act_idx=0; act_idx<gameobj->GetActuators().size(); act_idx++)
|
||||||
|
{
|
||||||
|
if (gameobj->GetActuators()[act_idx]->IsType(SCA_IActuator::KX_ACT_ACTION))
|
||||||
|
{
|
||||||
|
BL_ActionActuator *act = (BL_ActionActuator*)gameobj->GetActuators()[act_idx];
|
||||||
|
if(IS_TAGGED(act->GetAction()))
|
||||||
|
act->SetAction(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -127,6 +127,7 @@ public:
|
|||||||
void RegisterMeshName(const STR_String& meshname,void* mesh);
|
void RegisterMeshName(const STR_String& meshname,void* mesh);
|
||||||
void UnregisterMeshName(const STR_String& meshname,void* mesh);
|
void UnregisterMeshName(const STR_String& meshname,void* mesh);
|
||||||
GEN_Map<STR_HashedString,void*>& GetMeshMap() { return m_mapStringToMeshes; };
|
GEN_Map<STR_HashedString,void*>& GetMeshMap() { return m_mapStringToMeshes; };
|
||||||
|
GEN_Map<STR_HashedString,void*>& GetActionMap() { return m_mapStringToActions; };
|
||||||
|
|
||||||
void RegisterActionName(const STR_String& actname,void* action);
|
void RegisterActionName(const STR_String& actname,void* action);
|
||||||
|
|
||||||
|
@@ -179,7 +179,7 @@ General functions
|
|||||||
|
|
||||||
:arg blend: The path to the blend file (or the name to use for the library if data is supplied)
|
:arg blend: The path to the blend file (or the name to use for the library if data is supplied)
|
||||||
:type blend: string
|
:type blend: string
|
||||||
:arg type: The datablock type (currently only "Scene" and "Mesh" are supported)
|
:arg type: The datablock type (currently only "Action", "Mesh" and "Scene" are supported)
|
||||||
:type type: string
|
:type type: string
|
||||||
:arg data: Binary data from a blend file (optional)
|
:arg data: Binary data from a blend file (optional)
|
||||||
:type data: bytes
|
:type data: bytes
|
||||||
|
Reference in New Issue
Block a user