From 573be3e687c9db985b1cfdb670e038370ba30628 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 22 Nov 2009 00:01:52 +0000 Subject: [PATCH] BGE: Removing OB prefix from object names - This will break scripts !!!! (also removing AC and ME :: internal changes only) How it works now: whenever you have to read/write object names you can do it without the prefix "OB". (it's not hard at all to fix scripts) How it was before: It was a mess :) We had an inconsistent API where sometimes you had to input "OBname" and other "name" directly to assign object as data (usually in actuators). Justification for the change: Talking with Campbell we had since a while ago this feeling that this should be changed any time we were going to deprecate the API. So in order to deliver Blender 2.5beta0 with a more close-to-the-final API we decided that today was a good day to implement that. Remaining issues: 1) VideoTexture uses IM or MA to identify the output material/texture. I haven't touched that, but it does look a bit off. (i.e. I didn't changed any MA, IM naming) 2) I didn't see the code of dynamic mesh. It may need to be edited as well. --- .../Converter/BL_BlenderDataConversion.cpp | 9 ++++----- source/gameengine/Converter/KX_ConvertActuators.cpp | 3 --- source/gameengine/Converter/KX_IpoConvert.cpp | 2 +- source/gameengine/GameLogic/SCA_LogicManager.cpp | 6 +++--- source/gameengine/PyDoc/GameTypes.py | 13 ++++++------- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 6e26182a23f..c171ba89683 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -774,7 +774,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, } } - meshobj->SetName(mesh->id.name); + meshobj->SetName(mesh->id.name + 2); meshobj->m_sharedvertex_map.resize(totvert); RAS_IPolyMaterial* polymat = NULL; STR_String imastr; @@ -1977,7 +1977,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, bAction *curAct; for (curAct = (bAction*)maggie->action.first; curAct; curAct=(bAction*)curAct->id.next) { - logicmgr->RegisterActionName(curAct->id.name, curAct); + logicmgr->RegisterActionName(curAct->id.name + 2, curAct); } SetDefaultFaceType(blenderscene); @@ -2053,8 +2053,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer); - - gameobj->SetName(blenderobject->id.name); + gameobj->SetName(blenderobject->id.name + 2); // update children/parent hierarchy if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame)) @@ -2245,7 +2244,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer); - gameobj->SetName(blenderobject->id.name); + gameobj->SetName(blenderobject->id.name + 2); // update children/parent hierarchy if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame)) diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 1cb16acf148..a0645476063 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -304,9 +304,6 @@ void BL_ConvertActuators(char* maggiename, STR_String toPropName = (msgAct->toPropName ? (char*) msgAct->toPropName : ""); - /* BGE Wants "OB" prefix */ - if (toPropName != "") - toPropName = "OB" + toPropName; /** * Get the Message Subject to send. diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index cb823805435..359eedb1e5e 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -475,7 +475,7 @@ void BL_ConvertMaterialIpos( Material *mat = give_current_material(blenderobject, material_index); STR_HashedString matname; if(mat) { - matname= mat->id.name; + matname= mat->id.name; // who is using this name? can we remove the MA here? ConvertMaterialIpos(mat, matname.hash(), gameobj, converter); } } diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 848b7df6658..fe97add9a3f 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -119,7 +119,7 @@ void SCA_LogicManager::UnregisterGameObj(void* blendobj, CValue* gameobj) CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname) { - STR_HashedString mn = "OB"+gameobjname; + STR_HashedString mn = gameobjname; CValue** gameptr = m_mapStringToGameObjects[mn]; if (gameptr) @@ -252,7 +252,7 @@ void SCA_LogicManager::UpdateFrame(double curtime, bool frame) void* SCA_LogicManager::GetActionByName (const STR_String& actname) { - STR_HashedString an = "AC"+actname; + STR_HashedString an = actname; void** actptr = m_mapStringToActions[an]; if (actptr) @@ -265,7 +265,7 @@ void* SCA_LogicManager::GetActionByName (const STR_String& actname) void* SCA_LogicManager::GetMeshByName(const STR_String& meshname) { - STR_HashedString mn = "ME"+meshname; + STR_HashedString mn = meshname; void** meshptr = m_mapStringToMeshes[mn]; if (meshptr) diff --git a/source/gameengine/PyDoc/GameTypes.py b/source/gameengine/PyDoc/GameTypes.py index 60511f41c2b..0e4001fa669 100644 --- a/source/gameengine/PyDoc/GameTypes.py +++ b/source/gameengine/PyDoc/GameTypes.py @@ -991,7 +991,7 @@ class CListValue(CPropValue): C{val= clist[i]} CListValue supports string lookups. - C{val= scene.objects["OBCube"]} + C{val= scene.objects["Cube"]} Other operations such as C{len(clist), list(clist), clist[0:10]} are also supported. """ @@ -1504,7 +1504,6 @@ class KX_GameObject(SCA_IObject): - note: Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError, if an object may have been removed since last accessing it use the L{invalid} attribute to check. @ivar name: The object's name. (read-only) - - note: Currently (Blender 2.49) the prefix "OB" is added to all objects name. This may change in blender 2.5. @type name: string. @ivar mass: The object's mass - note: The object must have a physics controller for the mass to be applied, otherwise the mass value will be returned as 0.0 @@ -3543,7 +3542,7 @@ class KX_SCA_AddObjectActuator(SCA_IActuator): This will genereate a warning in the console: - C{ERROR: GameObject I{OBName} has a AddObjectActuator I{ActuatorName} without object (in 'nonactive' layer)} + C{ERROR: GameObject I{Name} has a AddObjectActuator I{ActuatorName} without object (in 'nonactive' layer)} """ #{Deprecated def setObject(object): @@ -3729,7 +3728,7 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator): This will generate a warning in the console: - C{ERROR: GameObject I{OBName} ReplaceMeshActuator I{ActuatorName} without object} + C{ERROR: GameObject I{Name} ReplaceMeshActuator I{ActuatorName} without object} @ivar mesh: L{KX_MeshProxy} or the name of the mesh that will replace the current one Set to None to disable actuator @@ -3782,7 +3781,7 @@ class KX_Scene(PyObjectPlus): print obj.name # get an object named 'Cube' - obj = scene.objects["OBCube"] + obj = scene.objects["Cube"] # get the first object in the scene. obj = scene.objects[0] @@ -3874,7 +3873,7 @@ class KX_SceneActuator(SCA_IActuator): This will generate a warning in the console: - C{ERROR: GameObject I{OBName} has a SceneActuator I{ActuatorName} (SetScene) without scene} + C{ERROR: GameObject I{Name} has a SceneActuator I{ActuatorName} (SetScene) without scene} @ivar scene: the name of the scene to change to/overlay/underlay/remove/suspend/resume @type scene: string. @@ -4181,7 +4180,7 @@ class KX_TrackToActuator(SCA_IActuator): This will generate a warning in the console: - C{ERROR: GameObject I{OBName} no object in EditObjectActuator I{ActuatorName}} + C{ERROR: GameObject I{Name} no object in EditObjectActuator I{ActuatorName}} @ivar object: the object this actuator tracks. @type object: KX_GameObject or None