diff options
Diffstat (limited to 'source/gameengine')
5 files changed, 26 insertions, 45 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index b27c44615f1..e148861ca5a 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2504,7 +2504,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) @@ -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) @@ -2548,7 +2548,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); @@ -2645,7 +2645,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); @@ -2653,7 +2653,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); @@ -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_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 85d178385b8..ebabaa55e21 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -345,10 +345,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 @@ -462,27 +458,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) { @@ -491,18 +488,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) @@ -689,7 +674,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 @@ -753,7 +738,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) @@ -807,7 +792,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(); @@ -908,7 +893,7 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo() { //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); - Object* blenderObject = FindBlenderObject(gameObj); + Object* blenderObject = gameObj->GetBlenderObject(); if (blenderObject && blenderObject->ipo) { // XXX animato diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index 50ce8d61336..7b5351344ae 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -56,14 +56,10 @@ 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_gameAdtList; @@ -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/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 729fff31052..04454f8232a 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -87,8 +87,8 @@ PyTypeObject PyObjectPlus::Type = { PyObjectPlus::~PyObjectPlus() { if(m_proxy) { - Py_DECREF(m_proxy); /* Remove own reference, python may still have 1 */ BGE_PROXY_REF(m_proxy)= NULL; + Py_DECREF(m_proxy); /* Remove own reference, python may still have 1 */ } // assert(ob_refcnt==0); } diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 63d23f5af31..12df262df56 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; |