Skip to content

Commit

Permalink
UPBGE: Forbid setParent to an object in an inactive layer
Browse files Browse the repository at this point in the history
Previously object was able to be parented between active
and inactive objects. But this was introducing big troubles
when adding an inactive object with active object children.

To solve this issue the inter layer parenting is disallowed.
Only active objects can be parented to active objects and
the same for inactive objects.
  • Loading branch information
youle31 authored and panzergame committed Oct 19, 2016
1 parent cf38701 commit a616424
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion source/gameengine/Ketsji/KX_GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,13 @@ void KX_GameObject::SetParent(KX_GameObject* obj, bool addToCompound, bool ghost
obj->GetSGNode() && // object is not zombi
GetSGNode()->GetSGParent() != obj->GetSGNode() && // not already parented to same object
!GetSGNode()->IsAncessor(obj->GetSGNode()) && // no parenting loop
this != obj) // not the object itself
this != obj) // not the object itself
{
if (!(GetScene()->GetInactiveList()->SearchValue(obj) != GetScene()->GetObjectList()->SearchValue(this))) {
std::cout << "Warning: Child and Parent are not in the same gameobjects list (active or inactive).\n" <<
"This operation is forbidden." << std::endl;
return;
}
// Make sure the objects have some scale
MT_Vector3 scale1 = NodeGetWorldScaling();
MT_Vector3 scale2 = obj->NodeGetWorldScaling();
Expand Down Expand Up @@ -3530,6 +3535,7 @@ PyObject *KX_GameObject::PySetParent(PyObject *args)
}
if (!ConvertPythonToGameObject(logicmgr, pyobj, &obj, true, "gameOb.setParent(obj): KX_GameObject"))
return NULL;

if (obj)
SetParent(obj, addToCompound, ghost);
Py_RETURN_NONE;
Expand Down

0 comments on commit a616424

Please sign in to comment.