diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-08-07 08:41:15 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-08-07 08:41:15 +0400 |
commit | bc093b4cc485757cd07875a9b5576cbb2567696f (patch) | |
tree | a054ba0c70f2645845a261d4fe9b899f8b36986e /source | |
parent | 77d79ffb5d1c4d214f2aa8decfe8e5a53138369a (diff) | |
parent | e7c53e20a18573e05970beb93184fc32b88c98c9 (diff) |
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22205:22290
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_library.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 14 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 12 | ||||
-rw-r--r-- | source/gameengine/Converter/KX_BlenderSceneConverter.cpp | 37 | ||||
-rw-r--r-- | source/gameengine/Converter/KX_BlenderSceneConverter.h | 16 | ||||
-rw-r--r-- | source/gameengine/Expressions/PyObjectPlus.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 4 |
7 files changed, 41 insertions, 45 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index ce182267b93..4e7db115168 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -58,6 +58,7 @@ int set_listbasepointers(struct Main *main, struct ListBase **lb); void free_libblock(struct ListBase *lb, void *idv); void free_libblock_us(struct ListBase *lb, void *idv); void free_main(struct Main *mainvar); +void tag_main(struct Main *mainvar, int tag); void splitIDname(char *name, char *left, int *nr); void rename_id(struct ID *id, char *name); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 90ab4e05d44..ff065fd4bf6 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1030,6 +1030,20 @@ static void lib_indirect_test_id(ID *id) } } +void tag_main(struct Main *mainvar, int tag) +{ + ListBase *lbarray[MAX_LIBARRAY]; + ID *id; + int a; + + a= set_listbasepointers(mainvar, lbarray); + while(a--) { + for(id= lbarray[a]->first; id; id= id->next) { + if(tag) id->flag |= LIB_DOIT; + else id->flag &= ~LIB_DOIT; + } + } +} /* if lib!=NULL, only all from lib local */ void all_local(Library *lib, int untagged_only) 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; |