diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-07-18 23:56:56 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-07-18 23:56:56 +0400 |
commit | 5e2ee191877d1073a20da32c52d9e97cfab8f5c8 (patch) | |
tree | a9e07ed9c74ea52334f2059e2511a15f84888776 /source/gameengine/SceneGraph | |
parent | a397b4b82fb9c658bb9e034e96692b9e5af5819a (diff) |
BGE patch: support for partial hierarchy in dupligroup instantiation; removal of links that point to inactive objects during group instantiation.
This situation corresponds to a group containing only a portion
of a parent hierarchy (the Apricot team needed that to avoid
logic duplication). The BGE will instantiate only the
children that are in the group so that it follows the 3D view
more closely.
As a result, the logic links to the objects in the portion of the
hierarchy that was not replicated will point to inactive objects
(if the groups are stored in inactive layers as they should be).
To keep the logic system consistent, these links are automatically
removed.
This last part of the patch is a general fix that could go in
2.47 but as this situation does not normally occurs in pre-2.47
games, it is not needed.
Diffstat (limited to 'source/gameengine/SceneGraph')
-rw-r--r-- | source/gameengine/SceneGraph/SG_IObject.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_IObject.h | 2 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Node.cpp | 29 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Node.h | 2 |
4 files changed, 29 insertions, 10 deletions
diff --git a/source/gameengine/SceneGraph/SG_IObject.cpp b/source/gameengine/SceneGraph/SG_IObject.cpp index c347bbc6d9a..d0bdac5c8f0 100644 --- a/source/gameengine/SceneGraph/SG_IObject.cpp +++ b/source/gameengine/SceneGraph/SG_IObject.cpp @@ -104,7 +104,7 @@ SetSGClientObject( } - void + bool SG_IObject:: ActivateReplicationCallback( SG_IObject *replica @@ -112,8 +112,10 @@ ActivateReplicationCallback( if (m_callbacks.m_replicafunc) { // Call client provided replication func - m_callbacks.m_replicafunc(replica,m_SGclientObject,m_SGclientInfo); + if (m_callbacks.m_replicafunc(replica,m_SGclientObject,m_SGclientInfo) == NULL) + return false; } + return true; }; void diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index 438ab48c556..7f6bdfbbb1c 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -202,7 +202,7 @@ public: protected : - void + bool ActivateReplicationCallback( SG_IObject *replica ); diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index 4e90d7c4653..8de7ac83477 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -68,7 +68,7 @@ SG_Node* SG_Node::GetSGReplica() SG_Node* replica = new SG_Node(*this); if (replica == NULL) return NULL; - ProcessSGReplica(replica); + ProcessSGReplica(&replica); return replica; } @@ -76,25 +76,42 @@ SG_Node* SG_Node::GetSGReplica() void SG_Node:: ProcessSGReplica( - SG_Node* replica + SG_Node** replica ){ // Apply the replication call back function. - ActivateReplicationCallback(replica); + if (!ActivateReplicationCallback(*replica)) + { + delete (*replica); + *replica = NULL; + return; + } // clear the replica node of it's parent. - static_cast<SG_Node*>(replica)->m_SGparent = NULL; + static_cast<SG_Node*>(*replica)->m_SGparent = NULL; if (m_children.begin() != m_children.end()) { // if this node has children, the replica has too, so clear and clone children - replica->ClearSGChildren(); + (*replica)->ClearSGChildren(); NodeList::iterator childit; for (childit = m_children.begin();childit!=m_children.end();++childit) { - replica->AddChild((*childit)->GetSGReplica()); + SG_Node* childnode = (*childit)->GetSGReplica(); + if (childnode) + (*replica)->AddChild(childnode); } } + // Nodes without children and without client object are + // not worth to keep, they will just take up CPU + // This can happen in partial replication of hierarchy + // during group duplication. + if ((*replica)->m_children.empty() && + (*replica)->GetSGClientObject() == NULL) + { + delete (*replica); + *replica = NULL; + } } diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index f86e3046d93..ffaaad861e2 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -205,7 +205,7 @@ private: void ProcessSGReplica( - SG_Node* replica + SG_Node** replica ); /** |