mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:29:32 +02:00
add entities to simulation after unpacking
This commit is contained in:
parent
d84f57fafa
commit
3781c23480
3 changed files with 11 additions and 25 deletions
|
@ -76,25 +76,14 @@ EntityItem* EntityTree::getOrCreateEntityItem(const EntityItemID& entityID, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a new entity item to the tree
|
/// Adds a new entity item to the tree
|
||||||
void EntityTree::addEntityItem(EntityItem* entityItem) {
|
void EntityTree::postAddEntity(EntityItem* entity) {
|
||||||
// You should not call this on existing entities that are already part of the tree! Call updateEntity()
|
assert(entity);
|
||||||
EntityItemID entityID = entityItem->getEntityItemID();
|
|
||||||
EntityTreeElement* containingElement = getContainingElement(entityID);
|
|
||||||
if (containingElement) {
|
|
||||||
qDebug() << "UNEXPECTED!!!! don't call addEntityItem() on existing EntityItems. entityID=" << entityID;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recurse the tree and store the entity in the correct tree element
|
|
||||||
AddEntityOperator theOperator(this, entityItem);
|
|
||||||
recurseTreeWithOperator(&theOperator);
|
|
||||||
|
|
||||||
// check to see if we need to simulate this entity..
|
// check to see if we need to simulate this entity..
|
||||||
if (_simulation) {
|
if (_simulation) {
|
||||||
_simulation->addEntity(entityItem);
|
_simulation->addEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
_isDirty = true;
|
_isDirty = true;
|
||||||
|
emit addingEntity(entity->getEntityItemID());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
|
@ -177,9 +166,11 @@ EntityItem* EntityTree::addEntity(const EntityItemID& entityID, const EntityItem
|
||||||
result = EntityTypes::constructEntityItem(type, entityID, properties);
|
result = EntityTypes::constructEntityItem(type, entityID, properties);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
// this does the actual adding of the entity
|
// Recurse the tree and store the entity in the correct tree element
|
||||||
addEntityItem(result);
|
AddEntityOperator theOperator(this, result);
|
||||||
emitAddingEntity(entityID);
|
recurseTreeWithOperator(&theOperator);
|
||||||
|
|
||||||
|
postAddEntity(result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -199,10 +190,6 @@ void EntityTree::trackDeletedEntity(EntityItem* entity) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::emitAddingEntity(const EntityItemID& entityItemID) {
|
|
||||||
emit addingEntity(entityItemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EntityTree::emitEntityScriptChanging(const EntityItemID& entityItemID) {
|
void EntityTree::emitEntityScriptChanging(const EntityItemID& entityItemID) {
|
||||||
emit entityScriptChanging(entityItemID);
|
emit entityScriptChanging(entityItemID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
// The newer API...
|
// The newer API...
|
||||||
EntityItem* getOrCreateEntityItem(const EntityItemID& entityID, const EntityItemProperties& properties);
|
EntityItem* getOrCreateEntityItem(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
void addEntityItem(EntityItem* entityItem);
|
void postAddEntity(EntityItem* entityItem);
|
||||||
|
|
||||||
EntityItem* addEntity(const EntityItemID& entityID, const EntityItemProperties& properties);
|
EntityItem* addEntity(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
bool updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties);
|
bool updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
|
@ -142,7 +142,6 @@ public:
|
||||||
|
|
||||||
void trackDeletedEntity(EntityItem* entity);
|
void trackDeletedEntity(EntityItem* entity);
|
||||||
|
|
||||||
void emitAddingEntity(const EntityItemID& entityItemID);
|
|
||||||
void emitEntityScriptChanging(const EntityItemID& entityItemID);
|
void emitEntityScriptChanging(const EntityItemID& entityItemID);
|
||||||
|
|
||||||
void setSimulation(EntitySimulation* simulation);
|
void setSimulation(EntitySimulation* simulation);
|
||||||
|
|
|
@ -768,7 +768,7 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
||||||
addEntityItem(entityItem); // add this new entity to this elements entities
|
addEntityItem(entityItem); // add this new entity to this elements entities
|
||||||
entityItemID = entityItem->getEntityItemID();
|
entityItemID = entityItem->getEntityItemID();
|
||||||
_myTree->setContainingElement(entityItemID, this);
|
_myTree->setContainingElement(entityItemID, this);
|
||||||
_myTree->emitAddingEntity(entityItemID); // we just added an entity
|
_myTree->postAddEntity(entityItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Move the buffer forward to read more entities
|
// Move the buffer forward to read more entities
|
||||||
|
|
Loading…
Reference in a new issue