Skip to content

Commit

Permalink
UPBGE: Avoid merge object of a batch group into an other batch group.
Browse files Browse the repository at this point in the history
Previously this behaviour was totally allowed but it is not aprecated.
Firstly it can hide a recursion merge which could do a high usage of
memory.
Secondly merging a object already used in a batch group to an other
batch group is like merging the both group, but if the first batch group
split or merge one object, the compound ot the batch group will be not
update and very hard to update.

Fix issue #416.
  • Loading branch information
panzergame committed Mar 9, 2017
1 parent fd8ef93 commit d1beb87
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/gameengine/Ketsji/KX_BatchGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ void KX_BatchGroup::MergeObjects(const std::vector<KX_GameObject *>& objects)
continue;
}

if (meshUser->GetBatchGroup()) {
CM_Error("object \"" << gameobj->GetName() << "\" already used in a batch group");
continue;
}

MT_Transform trans(gameobj->NodeGetWorldPosition(), gameobj->NodeGetWorldOrientation());
const MT_Vector3& scale = gameobj->NodeGetWorldScaling();
trans.scale(scale.x(), scale.y(), scale.z());
Expand Down Expand Up @@ -133,7 +138,7 @@ static PyObject *py_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
KX_BatchGroup *batchGroup = new KX_BatchGroup();
batchGroup->MergeObjects(objects);
if (batchGroup->GetObjects()->GetCount() == 0) {
PyErr_SetString(PyExc_SystemError, "KX_BatchGroup(objects): none objects was merged.");
PyErr_SetString(PyExc_SystemError, "KX_BatchGroup(objects): none objects were merged.");
delete batchGroup;
return nullptr;
}
Expand Down

0 comments on commit d1beb87

Please sign in to comment.