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.
This commit is contained in:
Dalai Felinto 2009-11-22 00:01:52 +00:00
parent 1dfbf3a9f6
commit 573be3e687
5 changed files with 14 additions and 19 deletions

@ -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); meshobj->m_sharedvertex_map.resize(totvert);
RAS_IPolyMaterial* polymat = NULL; RAS_IPolyMaterial* polymat = NULL;
STR_String imastr; STR_String imastr;
@ -1977,7 +1977,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
bAction *curAct; bAction *curAct;
for (curAct = (bAction*)maggie->action.first; curAct; curAct=(bAction*)curAct->id.next) 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); SetDefaultFaceType(blenderscene);
@ -2053,8 +2053,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer); BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer);
gameobj->SetName(blenderobject->id.name + 2);
gameobj->SetName(blenderobject->id.name);
// update children/parent hierarchy // update children/parent hierarchy
if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame)) if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame))
@ -2245,7 +2244,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer); BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer);
gameobj->SetName(blenderobject->id.name); gameobj->SetName(blenderobject->id.name + 2);
// update children/parent hierarchy // update children/parent hierarchy
if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame)) if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame))

@ -304,9 +304,6 @@ void BL_ConvertActuators(char* maggiename,
STR_String toPropName = (msgAct->toPropName STR_String toPropName = (msgAct->toPropName
? (char*) msgAct->toPropName ? (char*) msgAct->toPropName
: ""); : "");
/* BGE Wants "OB" prefix */
if (toPropName != "")
toPropName = "OB" + toPropName;
/** /**
* Get the Message Subject to send. * Get the Message Subject to send.

@ -475,7 +475,7 @@ void BL_ConvertMaterialIpos(
Material *mat = give_current_material(blenderobject, material_index); Material *mat = give_current_material(blenderobject, material_index);
STR_HashedString matname; STR_HashedString matname;
if(mat) { 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); ConvertMaterialIpos(mat, matname.hash(), gameobj, converter);
} }
} }

@ -119,7 +119,7 @@ void SCA_LogicManager::UnregisterGameObj(void* blendobj, CValue* gameobj)
CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname) CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname)
{ {
STR_HashedString mn = "OB"+gameobjname; STR_HashedString mn = gameobjname;
CValue** gameptr = m_mapStringToGameObjects[mn]; CValue** gameptr = m_mapStringToGameObjects[mn];
if (gameptr) if (gameptr)
@ -252,7 +252,7 @@ void SCA_LogicManager::UpdateFrame(double curtime, bool frame)
void* SCA_LogicManager::GetActionByName (const STR_String& actname) void* SCA_LogicManager::GetActionByName (const STR_String& actname)
{ {
STR_HashedString an = "AC"+actname; STR_HashedString an = actname;
void** actptr = m_mapStringToActions[an]; void** actptr = m_mapStringToActions[an];
if (actptr) if (actptr)
@ -265,7 +265,7 @@ void* SCA_LogicManager::GetActionByName (const STR_String& actname)
void* SCA_LogicManager::GetMeshByName(const STR_String& meshname) void* SCA_LogicManager::GetMeshByName(const STR_String& meshname)
{ {
STR_HashedString mn = "ME"+meshname; STR_HashedString mn = meshname;
void** meshptr = m_mapStringToMeshes[mn]; void** meshptr = m_mapStringToMeshes[mn];
if (meshptr) if (meshptr)

@ -991,7 +991,7 @@ class CListValue(CPropValue):
C{val= clist[i]} C{val= clist[i]}
CListValue supports string lookups. 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. 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. - 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) @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. @type name: string.
@ivar mass: The object's mass @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 - 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: 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 #{Deprecated
def setObject(object): def setObject(object):
@ -3729,7 +3728,7 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator):
This will generate a warning in the console: 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 @ivar mesh: L{KX_MeshProxy} or the name of the mesh that will replace the current one
Set to None to disable actuator Set to None to disable actuator
@ -3782,7 +3781,7 @@ class KX_Scene(PyObjectPlus):
print obj.name print obj.name
# get an object named 'Cube' # get an object named 'Cube'
obj = scene.objects["OBCube"] obj = scene.objects["Cube"]
# get the first object in the scene. # get the first object in the scene.
obj = scene.objects[0] obj = scene.objects[0]
@ -3874,7 +3873,7 @@ class KX_SceneActuator(SCA_IActuator):
This will generate a warning in the console: 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 @ivar scene: the name of the scene to change to/overlay/underlay/remove/suspend/resume
@type scene: string. @type scene: string.
@ -4181,7 +4180,7 @@ class KX_TrackToActuator(SCA_IActuator):
This will generate a warning in the console: 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. @ivar object: the object this actuator tracks.
@type object: KX_GameObject or None @type object: KX_GameObject or None