diff options
Diffstat (limited to 'source/gameengine')
4 files changed, 26 insertions, 45 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index d27c544ccb4..5b03bbbbc4e 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2520,7 +2520,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for (i=0;i<sumolist->GetCount();i++) { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); - struct Object* blenderobject = converter->FindBlenderObject(gameobj); + struct Object* blenderobject = gameobj->GetBlenderObject(); int nummeshes = gameobj->GetMeshCount(); RAS_MeshObject* meshobj = 0; if (nummeshes > 0) @@ -2536,7 +2536,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for (i=0;i<sumolist->GetCount();i++) { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); - struct Object* blenderobject = converter->FindBlenderObject(gameobj); + struct Object* blenderobject = gameobj->GetBlenderObject(); int nummeshes = gameobj->GetMeshCount(); RAS_MeshObject* meshobj = 0; if (nummeshes > 0) @@ -2564,7 +2564,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for (i=0;i<sumolist->GetCount();i++) { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); - struct Object* blenderobject = converter->FindBlenderObject(gameobj); + struct Object* blenderobject = gameobj->GetBlenderObject(); ListBase *conlist; bConstraint *curcon; conlist = get_active_constraints2(blenderobject); @@ -2661,7 +2661,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for (i=0;i<logicbrick_conversionlist->GetCount();i++) { KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i)); - struct Object* blenderobj = converter->FindBlenderObject(gameobj); + struct Object* blenderobj = gameobj->GetBlenderObject(); int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; BL_ConvertActuators(maggie->name, blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,layerMask,isInActiveLayer,rendertools,converter); @@ -2669,7 +2669,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for ( i=0;i<logicbrick_conversionlist->GetCount();i++) { KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i)); - struct Object* blenderobj = converter->FindBlenderObject(gameobj); + struct Object* blenderobj = gameobj->GetBlenderObject(); int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; BL_ConvertControllers(blenderobj,gameobj,logicmgr,pythondictionary,layerMask,isInActiveLayer,converter); @@ -2677,7 +2677,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for ( i=0;i<logicbrick_conversionlist->GetCount();i++) { KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i)); - struct Object* blenderobj = converter->FindBlenderObject(gameobj); + struct Object* blenderobj = gameobj->GetBlenderObject(); int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,layerMask,isInActiveLayer,canvas,converter); diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index d817999393c..59c073c2b1f 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -375,10 +375,6 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene, //This cache mecanism is buggy so I leave it disable and the memory leak //that would result from this is fixed in RemoveScene() m_map_mesh_to_gamemesh.clear(); - //Don't clear this lookup, it is needed for the baking physics into ipo animation - //To avoid it's infinite grows, object will be unregister when they are deleted - //see KX_Scene::NewRemoveObject - //m_map_gameobject_to_blender.clear(); } // This function removes all entities stored in the converter for that scene @@ -492,27 +488,28 @@ void KX_BlenderSceneConverter::RegisterGameObject( KX_GameObject *gameobject, struct Object *for_blenderobject) { - m_map_gameobject_to_blender.insert(CHashedPtr(gameobject),for_blenderobject); + /* only maintained while converting, freed during game runtime */ m_map_blender_to_gameobject.insert(CHashedPtr(for_blenderobject),gameobject); } void KX_BlenderSceneConverter::UnregisterGameObject( KX_GameObject *gameobject) { - CHashedPtr gptr(gameobject); - struct Object **bobp= m_map_gameobject_to_blender[gptr]; +#if 0 + struct Object *bobp= gameobject->GetBlenderObject(); if (bobp) { - CHashedPtr bptr(*bobp); + CHashedPtr bptr(bobp); KX_GameObject **gobp= m_map_blender_to_gameobject[bptr]; if (gobp && *gobp == gameobject) + { // also maintain m_map_blender_to_gameobject if the gameobject // being removed is matching the blender object m_map_blender_to_gameobject.remove(bptr); - m_map_gameobject_to_blender.remove(gptr); + } } +#endif } - KX_GameObject *KX_BlenderSceneConverter::FindGameObject( struct Object *for_blenderobject) { @@ -521,18 +518,6 @@ KX_GameObject *KX_BlenderSceneConverter::FindGameObject( return obp?*obp:NULL; } - - -struct Object *KX_BlenderSceneConverter::FindBlenderObject( - KX_GameObject *for_gameobject) -{ - struct Object **obp= m_map_gameobject_to_blender[CHashedPtr(for_gameobject)]; - - return obp?*obp:NULL; -} - - - void KX_BlenderSceneConverter::RegisterGameMesh( RAS_MeshObject *gamemesh, struct Mesh *for_blendermesh) @@ -717,7 +702,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo) { //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); - Object* blenderObject = FindBlenderObject(gameObj); + Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject) { //erase existing ipo's @@ -781,7 +766,7 @@ void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo(){ for (int ix=0;ix<parentList->GetCount();ix++){ KX_GameObject* gameobj = (KX_GameObject*)parentList->GetValue(ix); if (!gameobj->IsDynamic()){ - Object* blenderobject = FindBlenderObject(gameobj); + Object* blenderobject = gameobj->GetBlenderObject(); if (!blenderobject) continue; if (blenderobject->type==OB_ARMATURE) @@ -835,7 +820,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) { //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); - Object* blenderObject = FindBlenderObject(gameObj); + Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject && blenderObject->ipo) { const MT_Point3& position = gameObj->NodeGetWorldPosition(); @@ -933,7 +918,7 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo() { //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); - Object* blenderObject = FindBlenderObject(gameObj); + Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject && blenderObject->ipo) { Ipo* ipo = blenderObject->ipo; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index cc93a953533..e8a958a310a 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -56,16 +56,12 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter // Should also have a list of collision shapes. // For the time being this is held in KX_Scene::m_shapes - GEN_Map<CHashedPtr,struct Object*> m_map_gameobject_to_blender; - GEN_Map<CHashedPtr,KX_GameObject*> m_map_blender_to_gameobject; - - GEN_Map<CHashedPtr,RAS_MeshObject*> m_map_mesh_to_gamemesh; -// GEN_Map<CHashedPtr,DT_ShapeHandle> m_map_gamemesh_to_sumoshape; - - GEN_Map<CHashedPtr,SCA_IActuator*> m_map_blender_to_gameactuator; - GEN_Map<CHashedPtr,SCA_IController*> m_map_blender_to_gamecontroller; + GEN_Map<CHashedPtr,KX_GameObject*> m_map_blender_to_gameobject; /* cleared after conversion */ + GEN_Map<CHashedPtr,RAS_MeshObject*> m_map_mesh_to_gamemesh; /* cleared after conversion */ + GEN_Map<CHashedPtr,SCA_IActuator*> m_map_blender_to_gameactuator; /* cleared after conversion */ + GEN_Map<CHashedPtr,SCA_IController*>m_map_blender_to_gamecontroller; /* cleared after conversion */ - GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameipolist; + GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameipolist; /* kept, should be freed, TODO */ Main* m_maggie; @@ -107,14 +103,10 @@ public: void RegisterGameObject(KX_GameObject *gameobject, struct Object *for_blenderobject); void UnregisterGameObject(KX_GameObject *gameobject); KX_GameObject *FindGameObject(struct Object *for_blenderobject); - struct Object *FindBlenderObject(KX_GameObject *for_gameobject); void RegisterGameMesh(RAS_MeshObject *gamemesh, struct Mesh *for_blendermesh); RAS_MeshObject *FindGameMesh(struct Mesh *for_blendermesh/*, unsigned int onlayer*/); -// void RegisterSumoShape(DT_ShapeHandle shape, RAS_MeshObject *for_gamemesh); -// DT_ShapeHandle FindSumoShape(RAS_MeshObject *for_gamemesh); - void RegisterPolyMaterial(RAS_IPolyMaterial *polymat); void RegisterBlenderMaterial(BL_Material *mat); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 0aeccbcaaad..dce2f2d8930 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1008,8 +1008,12 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) // in case this is a camera m_cameras.remove((KX_Camera*)newobj); + /* currently does nothing, keep incase we need to Unregister something */ +#if 0 if (m_sceneConverter) m_sceneConverter->UnregisterGameObject(newobj); +#endif + // return value will be 0 if the object is actually deleted (all reference gone) return ret; |