BGE patch: Relink actuators with target within group when duplicating group; generalize protection against object deletion for all actuators that point to objects.
Certain actuators hold a pointer to an objects: Property, SceneCamera, AddObject, Camera, Parent, TractTo. When a group is duplicated, the actuators that point to objects within the group will be relinked to point to the replicated objects and not to the original objects. This helps to setup self-contained group with a camera following a character for example. This feature also works when adding a single object (and all its children) with the AddObject actuator. The second part of the patch extends the protection against object deletion to all the actuators of the above list (previously, only the TrackTo, AddObject and Property actuators were protected). In case the target object of these actuators is deleted, the BGE won't crash.
This commit is contained in:
@@ -137,6 +137,17 @@ bool KX_SCA_AddObjectActuator::UnlinkObject(SCA_IObject* clientobj)
|
||||
return false;
|
||||
}
|
||||
|
||||
void KX_SCA_AddObjectActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
|
||||
{
|
||||
void **h_obj = (*obj_map)[m_OriginalObject];
|
||||
if (h_obj) {
|
||||
if (m_OriginalObject)
|
||||
m_OriginalObject->UnregisterActuator(this);
|
||||
m_OriginalObject = (SCA_IObject*)(*h_obj);
|
||||
m_OriginalObject->RegisterActuator(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Python functions */
|
||||
|
||||
Reference in New Issue
Block a user