mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 03:53:52 +02:00
client decides on new entity-ids, keep EntityItemID class
This commit is contained in:
parent
b32e069f1d
commit
a769cfdaf2
68 changed files with 509 additions and 358 deletions
|
@ -1975,7 +1975,7 @@ void Application::toggleFaceTrackerMute() {
|
|||
}
|
||||
}
|
||||
|
||||
bool Application::exportEntities(const QString& filename, const QVector<QUuid>& entityIDs) {
|
||||
bool Application::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs) {
|
||||
QVector<EntityItem*> entities;
|
||||
|
||||
auto entityTree = _entities.getTree();
|
||||
|
@ -2006,7 +2006,7 @@ bool Application::exportEntities(const QString& filename, const QVector<QUuid>&
|
|||
auto properties = entityItem->getProperties();
|
||||
|
||||
properties.setPosition(properties.getPosition() - root);
|
||||
exportTree.addEntity(entityItem->getID(), properties);
|
||||
exportTree.addEntity(entityItem->getEntityItemID(), properties);
|
||||
}
|
||||
|
||||
exportTree.writeToJSONFile(filename.toLocal8Bit().constData());
|
||||
|
@ -2026,7 +2026,7 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
|
|||
|
||||
for (int i = 0; i < entities.size(); i++) {
|
||||
EntityItemProperties properties = entities.at(i)->getProperties();
|
||||
QUuid id = entities.at(i)->getID();
|
||||
EntityItemID id = entities.at(i)->getEntityItemID();
|
||||
properties.setPosition(properties.getPosition() - root);
|
||||
exportTree.addEntity(id, properties);
|
||||
}
|
||||
|
@ -2075,7 +2075,7 @@ bool Application::importEntities(const QString& urlOrFilename) {
|
|||
return success;
|
||||
}
|
||||
|
||||
QVector<QUuid> Application::pasteEntities(float x, float y, float z) {
|
||||
QVector<EntityItemID> Application::pasteEntities(float x, float y, float z) {
|
||||
return _entityClipboard.sendEntities(&_entityEditSender, _entities.getTree(), x, y, z);
|
||||
}
|
||||
|
||||
|
|
|
@ -383,8 +383,8 @@ public slots:
|
|||
void nodeKilled(SharedNodePointer node);
|
||||
void packetSent(quint64 length);
|
||||
|
||||
QVector<QUuid> pasteEntities(float x, float y, float z);
|
||||
bool exportEntities(const QString& filename, const QVector<QUuid>& entityIDs);
|
||||
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
||||
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
|
||||
bool exportEntities(const QString& filename, float x, float y, float z, float scale);
|
||||
bool importEntities(const QString& url);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ float ClipboardScriptingInterface::getClipboardContentsLargestDimension() {
|
|||
return Application::getInstance()->getEntityClipboard()->getContentsLargestDimension();
|
||||
}
|
||||
|
||||
bool ClipboardScriptingInterface::exportEntities(const QString& filename, const QVector<QUuid>& entityIDs) {
|
||||
bool ClipboardScriptingInterface::exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs) {
|
||||
return Application::getInstance()->exportEntities(filename, entityIDs);
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,6 @@ bool ClipboardScriptingInterface::importEntities(const QString& filename) {
|
|||
return Application::getInstance()->importEntities(filename);
|
||||
}
|
||||
|
||||
QVector<QUuid> ClipboardScriptingInterface::pasteEntities(glm::vec3 position) {
|
||||
QVector<EntityItemID> ClipboardScriptingInterface::pasteEntities(glm::vec3 position) {
|
||||
return Application::getInstance()->pasteEntities(position.x, position.y, position.z);
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ signals:
|
|||
public slots:
|
||||
float getClipboardContentsLargestDimension(); /// returns the largest dimension of everything on the clipboard
|
||||
bool importEntities(const QString& filename);
|
||||
bool exportEntities(const QString& filename, const QVector<QUuid>& entityIDs);
|
||||
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
|
||||
bool exportEntities(const QString& filename, float x, float y, float z, float s);
|
||||
QVector<QUuid> pasteEntities(glm::vec3 position);
|
||||
QVector<EntityItemID> pasteEntities(glm::vec3 position);
|
||||
};
|
||||
|
||||
#endif // hifi_ClipboardScriptingInterface_h
|
||||
|
|
|
@ -66,8 +66,8 @@ EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterf
|
|||
REGISTER_ENTITY_TYPE_WITH_FACTORY(Zone, RenderableZoneEntityItem::factory)
|
||||
REGISTER_ENTITY_TYPE_WITH_FACTORY(Line, RenderableLineEntityItem::factory)
|
||||
|
||||
_currentHoverOverEntityID = QUuid(); // makes it the unknown ID
|
||||
_currentClickingOnEntityID = QUuid(); // makes it the unknown ID
|
||||
_currentHoverOverEntityID = UNKNOWN_ENTITY_ID;
|
||||
_currentClickingOnEntityID = UNKNOWN_ENTITY_ID;
|
||||
}
|
||||
|
||||
EntityTreeRenderer::~EntityTreeRenderer() {
|
||||
|
@ -86,7 +86,7 @@ EntityTreeRenderer::~EntityTreeRenderer() {
|
|||
|
||||
void EntityTreeRenderer::clear() {
|
||||
leaveAllEntities();
|
||||
foreach (const QUuid& entityID, _entityScripts.keys()) {
|
||||
foreach (const EntityItemID& entityID, _entityScripts.keys()) {
|
||||
checkAndCallUnload(entityID);
|
||||
}
|
||||
OctreeRenderer::clear();
|
||||
|
@ -123,9 +123,9 @@ void EntityTreeRenderer::shutdown() {
|
|||
|
||||
void EntityTreeRenderer::scriptContentsAvailable(const QUrl& url, const QString& scriptContents) {
|
||||
if (_waitingOnPreload.contains(url)) {
|
||||
QList<QUuid> entityIDs = _waitingOnPreload.values(url);
|
||||
QList<EntityItemID> entityIDs = _waitingOnPreload.values(url);
|
||||
_waitingOnPreload.remove(url);
|
||||
foreach(QUuid entityID, entityIDs) {
|
||||
foreach(EntityItemID entityID, entityIDs) {
|
||||
checkAndCallPreload(entityID);
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ void EntityTreeRenderer::errorInLoadingScript(const QUrl& url) {
|
|||
}
|
||||
}
|
||||
|
||||
QScriptValue EntityTreeRenderer::loadEntityScript(const QUuid& entityItemID, bool isPreload) {
|
||||
QScriptValue EntityTreeRenderer::loadEntityScript(const EntityItemID& entityItemID, bool isPreload) {
|
||||
EntityItem* entity = static_cast<EntityTree*>(_tree)->findEntityByEntityItemID(entityItemID);
|
||||
return loadEntityScript(entity, isPreload);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity, bool isPre
|
|||
// application event loop, which may cause our entity to be deleted on
|
||||
// us. We don't really need access the entity after this point, can
|
||||
// can accomplish all we need to here with just the script "text" and the ID.
|
||||
QUuid entityID = entity->getID();
|
||||
EntityItemID entityID = entity->getEntityItemID();
|
||||
QString entityScript = entity->getScript();
|
||||
|
||||
if (_entityScripts.contains(entityID)) {
|
||||
|
@ -282,7 +282,7 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity, bool isPre
|
|||
return entityScriptObject; // newly constructed
|
||||
}
|
||||
|
||||
QScriptValue EntityTreeRenderer::getPreviouslyLoadedEntityScript(const QUuid& entityID) {
|
||||
QScriptValue EntityTreeRenderer::getPreviouslyLoadedEntityScript(const EntityItemID& entityID) {
|
||||
if (_entityScripts.contains(entityID)) {
|
||||
EntityScriptDetails details = _entityScripts[entityID];
|
||||
return details.scriptObject; // previously loaded
|
||||
|
@ -306,7 +306,7 @@ void EntityTreeRenderer::update() {
|
|||
// Even if we're not moving the mouse, if we started clicking on an entity and we have
|
||||
// not yet released the hold then this is still considered a holdingClickOnEntity event
|
||||
// and we want to simulate this message here as well as in mouse move
|
||||
if (_lastMouseEventValid && !_currentClickingOnEntityID.isNull()) {
|
||||
if (_lastMouseEventValid && !_currentClickingOnEntityID.isInvalidID()) {
|
||||
emit holdingClickOnEntity(_currentClickingOnEntityID, _lastMouseEvent);
|
||||
QScriptValueList currentClickingEntityArgs = createMouseEventArgs(_currentClickingOnEntityID, _lastMouseEvent);
|
||||
QScriptValue currentClickingEntity = loadEntityScript(_currentClickingOnEntityID);
|
||||
|
@ -325,7 +325,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
|||
if (avatarPosition != _lastAvatarPosition) {
|
||||
float radius = 1.0f; // for now, assume 1 meter radius
|
||||
QVector<const EntityItem*> foundEntities;
|
||||
QVector<QUuid> entitiesContainingAvatar;
|
||||
QVector<EntityItemID> entitiesContainingAvatar;
|
||||
|
||||
// find the entities near us
|
||||
_tree->lockForRead(); // don't let someone else change our tree while we search
|
||||
|
@ -334,7 +334,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
|||
// create a list of entities that actually contain the avatar's position
|
||||
foreach(const EntityItem* entity, foundEntities) {
|
||||
if (entity->contains(avatarPosition)) {
|
||||
entitiesContainingAvatar << entity->getID();
|
||||
entitiesContainingAvatar << entity->getEntityItemID();
|
||||
}
|
||||
}
|
||||
_tree->unlock();
|
||||
|
@ -344,7 +344,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
|||
// for entity IDs that no longer exist.
|
||||
|
||||
// for all of our previous containing entities, if they are no longer containing then send them a leave event
|
||||
foreach(const QUuid& entityID, _currentEntitiesInside) {
|
||||
foreach(const EntityItemID& entityID, _currentEntitiesInside) {
|
||||
if (!entitiesContainingAvatar.contains(entityID)) {
|
||||
emit leaveEntity(entityID);
|
||||
QScriptValueList entityArgs = createEntityArgs(entityID);
|
||||
|
@ -357,7 +357,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
|||
}
|
||||
|
||||
// for all of our new containing entities, if they weren't previously containing then send them an enter event
|
||||
foreach(const QUuid& entityID, entitiesContainingAvatar) {
|
||||
foreach(const EntityItemID& entityID, entitiesContainingAvatar) {
|
||||
if (!_currentEntitiesInside.contains(entityID)) {
|
||||
emit enterEntity(entityID);
|
||||
QScriptValueList entityArgs = createEntityArgs(entityID);
|
||||
|
@ -377,7 +377,7 @@ void EntityTreeRenderer::leaveAllEntities() {
|
|||
if (_tree && !_shuttingDown) {
|
||||
|
||||
// for all of our previous containing entities, if they are no longer containing then send them a leave event
|
||||
foreach(const QUuid& entityID, _currentEntitiesInside) {
|
||||
foreach(const EntityItemID& entityID, _currentEntitiesInside) {
|
||||
emit leaveEntity(entityID);
|
||||
QScriptValueList entityArgs = createEntityArgs(entityID);
|
||||
QScriptValue entityScript = loadEntityScript(entityID);
|
||||
|
@ -704,7 +704,7 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
|
|||
} else {
|
||||
// in the case of the volume being equal, we will use the
|
||||
// EntityItemID to deterministically pick one entity over the other
|
||||
if (entityItem->getID() < _bestZone->getID()) {
|
||||
if (entityItem->getEntityItemID() < _bestZone->getEntityItemID()) {
|
||||
_bestZoneVolume = entityVolumeEstimate;
|
||||
_bestZone = dynamic_cast<const ZoneEntityItem*>(entityItem);
|
||||
}
|
||||
|
@ -840,7 +840,7 @@ RayToEntityIntersectionResult EntityTreeRenderer::findRayIntersectionWorker(cons
|
|||
(void**)&intersectedEntity, lockType, &result.accurate,
|
||||
precisionPicking);
|
||||
if (result.intersects && intersectedEntity) {
|
||||
result.entityID = intersectedEntity->getID();
|
||||
result.entityID = intersectedEntity->getEntityItemID();
|
||||
result.properties = intersectedEntity->getProperties();
|
||||
result.intersection = ray.origin + (ray.direction * result.distance);
|
||||
result.entity = intersectedEntity;
|
||||
|
@ -875,24 +875,24 @@ void EntityTreeRenderer::connectSignalsToSlots(EntityScriptingInterface* entityS
|
|||
connect(this, &EntityTreeRenderer::leaveEntity, entityScriptingInterface, &EntityScriptingInterface::leaveEntity);
|
||||
}
|
||||
|
||||
QScriptValueList EntityTreeRenderer::createMouseEventArgs(const QUuid& entityID, QMouseEvent* event, unsigned int deviceID) {
|
||||
QScriptValueList EntityTreeRenderer::createMouseEventArgs(const EntityItemID& entityID, QMouseEvent* event, unsigned int deviceID) {
|
||||
QScriptValueList args;
|
||||
args << quuidToScriptValue(_entitiesScriptEngine, entityID);
|
||||
args << entityID.toScriptValue(_entitiesScriptEngine);
|
||||
args << MouseEvent(*event, deviceID).toScriptValue(_entitiesScriptEngine);
|
||||
return args;
|
||||
}
|
||||
|
||||
QScriptValueList EntityTreeRenderer::createMouseEventArgs(const QUuid& entityID, const MouseEvent& mouseEvent) {
|
||||
QScriptValueList EntityTreeRenderer::createMouseEventArgs(const EntityItemID& entityID, const MouseEvent& mouseEvent) {
|
||||
QScriptValueList args;
|
||||
args << quuidToScriptValue(_entitiesScriptEngine, entityID);
|
||||
args << entityID.toScriptValue(_entitiesScriptEngine);
|
||||
args << mouseEvent.toScriptValue(_entitiesScriptEngine);
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
QScriptValueList EntityTreeRenderer::createEntityArgs(const QUuid& entityID) {
|
||||
QScriptValueList EntityTreeRenderer::createEntityArgs(const EntityItemID& entityID) {
|
||||
QScriptValueList args;
|
||||
args << quuidToScriptValue(_entitiesScriptEngine, entityID);
|
||||
args << entityID.toScriptValue(_entitiesScriptEngine);
|
||||
return args;
|
||||
}
|
||||
|
||||
|
@ -950,7 +950,7 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event, unsigned int devi
|
|||
|
||||
// Even if we're no longer intersecting with an entity, if we started clicking on it, and now
|
||||
// we're releasing the button, then this is considered a clickOn event
|
||||
if (!_currentClickingOnEntityID.isNull()) {
|
||||
if (!_currentClickingOnEntityID.isInvalidID()) {
|
||||
emit clickReleaseOnEntity(_currentClickingOnEntityID, MouseEvent(*event, deviceID));
|
||||
|
||||
QScriptValueList currentClickingEntityArgs = createMouseEventArgs(_currentClickingOnEntityID, event, deviceID);
|
||||
|
@ -961,7 +961,7 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event, unsigned int devi
|
|||
}
|
||||
|
||||
// makes it the unknown ID, we just released so we can't be clicking on anything
|
||||
_currentClickingOnEntityID = QUuid();
|
||||
_currentClickingOnEntityID = UNKNOWN_ENTITY_ID;
|
||||
_lastMouseEvent = MouseEvent(*event, deviceID);
|
||||
_lastMouseEventValid = true;
|
||||
}
|
||||
|
@ -997,7 +997,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
|
||||
// if we were previously hovering over an entity, and this new entity is not the same as our previous entity
|
||||
// then we need to send the hover leave.
|
||||
if (!_currentHoverOverEntityID.isNull() && rayPickResult.entityID != _currentHoverOverEntityID) {
|
||||
if (!_currentHoverOverEntityID.isInvalidID() && rayPickResult.entityID != _currentHoverOverEntityID) {
|
||||
emit hoverLeaveEntity(_currentHoverOverEntityID, MouseEvent(*event, deviceID));
|
||||
|
||||
QScriptValueList currentHoverEntityArgs = createMouseEventArgs(_currentHoverOverEntityID, event, deviceID);
|
||||
|
@ -1031,7 +1031,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
// handle the hover logic...
|
||||
// if we were previously hovering over an entity, and we're no longer hovering over any entity then we need to
|
||||
// send the hover leave for our previous entity
|
||||
if (!_currentHoverOverEntityID.isNull()) {
|
||||
if (!_currentHoverOverEntityID.isInvalidID()) {
|
||||
emit hoverLeaveEntity(_currentHoverOverEntityID, MouseEvent(*event, deviceID));
|
||||
|
||||
QScriptValueList currentHoverEntityArgs = createMouseEventArgs(_currentHoverOverEntityID, event, deviceID);
|
||||
|
@ -1041,13 +1041,13 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
currentHoverEntity.property("hoverLeaveEntity").call(currentHoverEntity, currentHoverEntityArgs);
|
||||
}
|
||||
|
||||
_currentHoverOverEntityID = QUuid(); // makes it the unknown ID
|
||||
_currentHoverOverEntityID = UNKNOWN_ENTITY_ID; // makes it the unknown ID
|
||||
}
|
||||
}
|
||||
|
||||
// Even if we're no longer intersecting with an entity, if we started clicking on an entity and we have
|
||||
// not yet released the hold then this is still considered a holdingClickOnEntity event
|
||||
if (!_currentClickingOnEntityID.isNull()) {
|
||||
if (!_currentClickingOnEntityID.isInvalidID()) {
|
||||
emit holdingClickOnEntity(_currentClickingOnEntityID, MouseEvent(*event, deviceID));
|
||||
|
||||
QScriptValueList currentClickingEntityArgs = createMouseEventArgs(_currentClickingOnEntityID, event, deviceID);
|
||||
|
@ -1061,25 +1061,25 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
_lastMouseEventValid = true;
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::deletingEntity(const QUuid& entityID) {
|
||||
void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) {
|
||||
if (_tree && !_shuttingDown) {
|
||||
checkAndCallUnload(entityID);
|
||||
}
|
||||
_entityScripts.remove(entityID);
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::addingEntity(const QUuid& entityID) {
|
||||
void EntityTreeRenderer::addingEntity(const EntityItemID& entityID) {
|
||||
checkAndCallPreload(entityID);
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::entitySciptChanging(const QUuid& entityID) {
|
||||
void EntityTreeRenderer::entitySciptChanging(const EntityItemID& entityID) {
|
||||
if (_tree && !_shuttingDown) {
|
||||
checkAndCallUnload(entityID);
|
||||
checkAndCallPreload(entityID);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::checkAndCallPreload(const QUuid& entityID) {
|
||||
void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID) {
|
||||
if (_tree && !_shuttingDown) {
|
||||
// load the entity script if needed...
|
||||
QScriptValue entityScript = loadEntityScript(entityID, true); // is preload!
|
||||
|
@ -1090,7 +1090,7 @@ void EntityTreeRenderer::checkAndCallPreload(const QUuid& entityID) {
|
|||
}
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::checkAndCallUnload(const QUuid& entityID) {
|
||||
void EntityTreeRenderer::checkAndCallUnload(const EntityItemID& entityID) {
|
||||
if (_tree && !_shuttingDown) {
|
||||
QScriptValue entityScript = getPreviouslyLoadedEntityScript(entityID);
|
||||
if (entityScript.property("unload").isValid()) {
|
||||
|
@ -1101,7 +1101,7 @@ void EntityTreeRenderer::checkAndCallUnload(const QUuid& entityID) {
|
|||
}
|
||||
|
||||
|
||||
void EntityTreeRenderer::changingEntityID(const QUuid& oldEntityID, const QUuid& newEntityID) {
|
||||
void EntityTreeRenderer::changingEntityID(const EntityItemID& oldEntityID, const EntityItemID& newEntityID) {
|
||||
if (_entityScripts.contains(oldEntityID)) {
|
||||
EntityScriptDetails details = _entityScripts[oldEntityID];
|
||||
_entityScripts.remove(oldEntityID);
|
||||
|
@ -1109,8 +1109,7 @@ void EntityTreeRenderer::changingEntityID(const QUuid& oldEntityID, const QUuid&
|
|||
}
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::playEntityCollisionSound(const QUuid& myNodeID, EntityTree* entityTree,
|
||||
const QUuid& id, const Collision& collision) {
|
||||
void EntityTreeRenderer::playEntityCollisionSound(const QUuid& myNodeID, EntityTree* entityTree, const EntityItemID& id, const Collision& collision) {
|
||||
EntityItem* entity = entityTree->findEntityByEntityItemID(id);
|
||||
if (!entity) {
|
||||
return;
|
||||
|
@ -1168,8 +1167,8 @@ void EntityTreeRenderer::playEntityCollisionSound(const QUuid& myNodeID, EntityT
|
|||
injectorThread->start();
|
||||
}
|
||||
|
||||
void EntityTreeRenderer::entityCollisionWithEntity(const QUuid& idA, const QUuid& idB,
|
||||
const Collision& collision) {
|
||||
void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB,
|
||||
const Collision& collision) {
|
||||
// If we don't have a tree, or we're in the process of shutting down, then don't
|
||||
// process these events.
|
||||
if (!_tree || _shuttingDown) {
|
||||
|
@ -1199,8 +1198,8 @@ void EntityTreeRenderer::entityCollisionWithEntity(const QUuid& idA, const QUuid
|
|||
QScriptValue entityScriptA = loadEntityScript(idA);
|
||||
if (entityScriptA.property("collisionWithEntity").isValid()) {
|
||||
QScriptValueList args;
|
||||
args << quuidToScriptValue(_entitiesScriptEngine, idA);
|
||||
args << quuidToScriptValue(_entitiesScriptEngine, idB);
|
||||
args << idA.toScriptValue(_entitiesScriptEngine);
|
||||
args << idB.toScriptValue(_entitiesScriptEngine);
|
||||
args << collisionToScriptValue(_entitiesScriptEngine, collision);
|
||||
entityScriptA.property("collisionWithEntity").call(entityScriptA, args);
|
||||
}
|
||||
|
@ -1208,8 +1207,8 @@ void EntityTreeRenderer::entityCollisionWithEntity(const QUuid& idA, const QUuid
|
|||
QScriptValue entityScriptB = loadEntityScript(idB);
|
||||
if (entityScriptB.property("collisionWithEntity").isValid()) {
|
||||
QScriptValueList args;
|
||||
args << quuidToScriptValue(_entitiesScriptEngine, idA);
|
||||
args << quuidToScriptValue(_entitiesScriptEngine, idB);
|
||||
args << idB.toScriptValue(_entitiesScriptEngine);
|
||||
args << idA.toScriptValue(_entitiesScriptEngine);
|
||||
args << collisionToScriptValue(_entitiesScriptEngine, collision);
|
||||
entityScriptB.property("collisionWithEntity").call(entityScriptA, args);
|
||||
}
|
||||
|
|
|
@ -97,23 +97,23 @@ signals:
|
|||
void mouseMoveOnEntity(const RayToEntityIntersectionResult& entityItemID, const QMouseEvent* event, unsigned int deviceId);
|
||||
void mouseReleaseOnEntity(const RayToEntityIntersectionResult& entityItemID, const QMouseEvent* event, unsigned int deviceId);
|
||||
|
||||
void clickDownOnEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void holdingClickOnEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void clickReleaseOnEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void clickDownOnEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void holdingClickOnEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void clickReleaseOnEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
|
||||
void hoverEnterEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void hoverOverEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void hoverLeaveEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void hoverEnterEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void hoverOverEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void hoverLeaveEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
|
||||
void enterEntity(const QUuid& entityItemID);
|
||||
void leaveEntity(const QUuid& entityItemID);
|
||||
void enterEntity(const EntityItemID& entityItemID);
|
||||
void leaveEntity(const EntityItemID& entityItemID);
|
||||
|
||||
public slots:
|
||||
void addingEntity(const QUuid& entityID);
|
||||
void deletingEntity(const QUuid& entityID);
|
||||
void changingEntityID(const QUuid& oldEntityID, const QUuid& newEntityID);
|
||||
void entitySciptChanging(const QUuid& entityID);
|
||||
void entityCollisionWithEntity(const QUuid& idA, const QUuid& idB, const Collision& collision);
|
||||
void addingEntity(const EntityItemID& entityID);
|
||||
void deletingEntity(const EntityItemID& entityID);
|
||||
void changingEntityID(const EntityItemID& oldEntityID, const EntityItemID& newEntityID);
|
||||
void entitySciptChanging(const EntityItemID& entityID);
|
||||
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||
|
||||
// optional slots that can be wired to menu items
|
||||
void setDisplayElementChildProxies(bool value) { _displayElementChildProxies = value; }
|
||||
|
@ -126,37 +126,37 @@ protected:
|
|||
|
||||
private:
|
||||
void renderElementProxy(EntityTreeElement* entityTreeElement);
|
||||
void checkAndCallPreload(const QUuid& entityID);
|
||||
void checkAndCallUnload(const QUuid& entityID);
|
||||
void checkAndCallPreload(const EntityItemID& entityID);
|
||||
void checkAndCallUnload(const EntityItemID& entityID);
|
||||
|
||||
QList<Model*> _releasedModels;
|
||||
void renderProxies(const EntityItem* entity, RenderArgs* args);
|
||||
RayToEntityIntersectionResult findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType,
|
||||
bool precisionPicking);
|
||||
|
||||
QUuid _currentHoverOverEntityID;
|
||||
QUuid _currentClickingOnEntityID;
|
||||
EntityItemID _currentHoverOverEntityID;
|
||||
EntityItemID _currentClickingOnEntityID;
|
||||
|
||||
QScriptValueList createEntityArgs(const QUuid& entityID);
|
||||
QScriptValueList createEntityArgs(const EntityItemID& entityID);
|
||||
void checkEnterLeaveEntities();
|
||||
void leaveAllEntities();
|
||||
glm::vec3 _lastAvatarPosition;
|
||||
QVector<QUuid> _currentEntitiesInside;
|
||||
QVector<EntityItemID> _currentEntitiesInside;
|
||||
|
||||
bool _wantScripts;
|
||||
ScriptEngine* _entitiesScriptEngine;
|
||||
ScriptEngine* _sandboxScriptEngine;
|
||||
|
||||
QScriptValue loadEntityScript(EntityItem* entity, bool isPreload = false);
|
||||
QScriptValue loadEntityScript(const QUuid& entityItemID, bool isPreload = false);
|
||||
QScriptValue getPreviouslyLoadedEntityScript(const QUuid& entityItemID);
|
||||
QScriptValue loadEntityScript(const EntityItemID& entityItemID, bool isPreload = false);
|
||||
QScriptValue getPreviouslyLoadedEntityScript(const EntityItemID& entityItemID);
|
||||
QString loadScriptContents(const QString& scriptMaybeURLorText, bool& isURL, bool& isPending, QUrl& url);
|
||||
QScriptValueList createMouseEventArgs(const QUuid& entityID, QMouseEvent* event, unsigned int deviceID);
|
||||
QScriptValueList createMouseEventArgs(const QUuid& entityID, const MouseEvent& mouseEvent);
|
||||
QScriptValueList createMouseEventArgs(const EntityItemID& entityID, QMouseEvent* event, unsigned int deviceID);
|
||||
QScriptValueList createMouseEventArgs(const EntityItemID& entityID, const MouseEvent& mouseEvent);
|
||||
|
||||
QHash<QUuid, EntityScriptDetails> _entityScripts;
|
||||
QHash<EntityItemID, EntityScriptDetails> _entityScripts;
|
||||
|
||||
void playEntityCollisionSound(const QUuid& myNodeID, EntityTree* entityTree, const QUuid& id, const Collision& collision);
|
||||
void playEntityCollisionSound(const QUuid& myNodeID, EntityTree* entityTree, const EntityItemID& id, const Collision& collision);
|
||||
AbstractAudioInterface* _localAudioInterface; // So we can render collision sounds
|
||||
|
||||
bool _lastMouseEventValid;
|
||||
|
@ -170,7 +170,7 @@ private:
|
|||
|
||||
bool _shuttingDown = false;
|
||||
|
||||
QMultiMap<QUrl, QUuid> _waitingOnPreload;
|
||||
QMultiMap<QUrl, EntityItemID> _waitingOnPreload;
|
||||
|
||||
bool _hasPreviousZone = false;
|
||||
const ZoneEntityItem* _bestZone;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "RenderableBoxEntityItem.h"
|
||||
|
||||
EntityItem* RenderableBoxEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* RenderableBoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableBoxEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
class RenderableBoxEntityItem : public BoxEntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
RenderableBoxEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
RenderableBoxEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
BoxEntityItem(entityItemID, properties)
|
||||
{ }
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "RenderableLightEntityItem.h"
|
||||
|
||||
EntityItem* RenderableLightEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* RenderableLightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableLightEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
class RenderableLightEntityItem : public LightEntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
RenderableLightEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
RenderableLightEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
LightEntityItem(entityItemID, properties)
|
||||
{ }
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "RenderableLineEntityItem.h"
|
||||
|
||||
EntityItem* RenderableLineEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* RenderableLineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableLineEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
class RenderableLineEntityItem : public LineEntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
RenderableLineEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
RenderableLineEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
LineEntityItem(entityItemID, properties) { }
|
||||
|
||||
virtual void render(RenderArgs* args);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "EntitiesRendererLogging.h"
|
||||
#include "RenderableModelEntityItem.h"
|
||||
|
||||
EntityItem* RenderableModelEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* RenderableModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableModelEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ class EntityTreeRenderer;
|
|||
|
||||
class RenderableModelEntityItem : public ModelEntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
RenderableModelEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
RenderableModelEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
ModelEntityItem(entityItemID, properties),
|
||||
_model(NULL),
|
||||
_needsInitialSimulation(true),
|
||||
|
|
|
@ -20,12 +20,11 @@
|
|||
|
||||
#include "RenderableParticleEffectEntityItem.h"
|
||||
|
||||
EntityItem* RenderableParticleEffectEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* RenderableParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableParticleEffectEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
RenderableParticleEffectEntityItem::RenderableParticleEffectEntityItem(const QUuid& entityItemID,
|
||||
const EntityItemProperties& properties) :
|
||||
RenderableParticleEffectEntityItem::RenderableParticleEffectEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
ParticleEffectEntityItem(entityItemID, properties) {
|
||||
_cacheID = DependencyManager::get<GeometryCache>()->allocateID();
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
class RenderableParticleEffectEntityItem : public ParticleEffectEntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
RenderableParticleEffectEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
RenderableParticleEffectEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
virtual void render(RenderArgs* args);
|
||||
|
||||
void renderUntexturedQuads(RenderArgs* args);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "RenderableSphereEntityItem.h"
|
||||
|
||||
EntityItem* RenderableSphereEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* RenderableSphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableSphereEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
class RenderableSphereEntityItem : public SphereEntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
RenderableSphereEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
RenderableSphereEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
SphereEntityItem(entityItemID, properties)
|
||||
{ }
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
const int FIXED_FONT_POINT_SIZE = 40;
|
||||
|
||||
EntityItem* RenderableTextEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* RenderableTextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableTextEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ void RenderableTextEntityItem::render(RenderArgs* args) {
|
|||
float leftMargin = 0.1f;
|
||||
float topMargin = 0.1f;
|
||||
|
||||
//qCDebug(entitytree) << "RenderableTextEntityItem::render() id:" << getID() << "text:" << getText();
|
||||
//qCDebug(entitytree) << "RenderableTextEntityItem::render() id:" << getEntityItemID() << "text:" << getText();
|
||||
|
||||
glPushMatrix();
|
||||
{
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
class RenderableTextEntityItem : public TextEntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
RenderableTextEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
RenderableTextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
TextEntityItem(entityItemID, properties)
|
||||
{ }
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ const int FIXED_FONT_POINT_SIZE = 40;
|
|||
const float DPI = 30.47;
|
||||
const float METERS_TO_INCHES = 39.3701;
|
||||
|
||||
EntityItem* RenderableWebEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* RenderableWebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableWebEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
RenderableWebEntityItem::RenderableWebEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
RenderableWebEntityItem::RenderableWebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
WebEntityItem(entityItemID, properties) {
|
||||
qDebug() << "Created web entity " << getID();
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (intersection.entityID == getID()) {
|
||||
if (intersection.entityID.id == getID()) {
|
||||
if (event->button() == Qt::MouseButton::RightButton) {
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
AbstractViewStateInterface::instance()->postLambdaEvent([this] {
|
||||
|
|
|
@ -17,9 +17,9 @@ class OffscreenQmlSurface;
|
|||
|
||||
class RenderableWebEntityItem : public WebEntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
RenderableWebEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
RenderableWebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
~RenderableWebEntityItem();
|
||||
|
||||
virtual void render(RenderArgs* args);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <GeometryCache.h>
|
||||
#include <PerfStat.h>
|
||||
|
||||
EntityItem* RenderableZoneEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* RenderableZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new RenderableZoneEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ class NetworkGeometry;
|
|||
|
||||
class RenderableZoneEntityItem : public ZoneEntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
RenderableZoneEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
RenderableZoneEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
ZoneEntityItem(entityItemID, properties),
|
||||
_model(NULL),
|
||||
_needsInitialSimulation(true)
|
||||
|
|
|
@ -46,7 +46,7 @@ bool AddEntityOperator::preRecursion(OctreeElement* element) {
|
|||
if (entityTreeElement->bestFitBounds(_newEntityBox)) {
|
||||
|
||||
entityTreeElement->addEntityItem(_newEntity);
|
||||
_tree->setContainingElement(_newEntity->getID(), entityTreeElement);
|
||||
_tree->setContainingElement(_newEntity->getEntityItemID(), entityTreeElement);
|
||||
|
||||
_foundNew = true;
|
||||
keepSearching = false;
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
#include "EntityTreeElement.h"
|
||||
|
||||
|
||||
EntityItem* BoxEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* BoxEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* result = new BoxEntityItem(entityID, properties);
|
||||
return result;
|
||||
}
|
||||
|
||||
BoxEntityItem::BoxEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
BoxEntityItem::BoxEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
EntityItem(entityItemID)
|
||||
{
|
||||
_type = EntityTypes::Box;
|
||||
|
@ -99,7 +99,7 @@ void BoxEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
|
|||
|
||||
void BoxEntityItem::debugDump() const {
|
||||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << " BOX EntityItem id:" << getID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " BOX EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
class BoxEntityItem : public EntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
BoxEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
BoxEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
|
||||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "EntitiesLogging.h"
|
||||
#include "DeleteEntityOperator.h"
|
||||
|
||||
DeleteEntityOperator::DeleteEntityOperator(EntityTree* tree, const QUuid& searchEntityID) :
|
||||
DeleteEntityOperator::DeleteEntityOperator(EntityTree* tree, const EntityItemID& searchEntityID) :
|
||||
_tree(tree),
|
||||
_changeTime(usecTimestampNow()),
|
||||
_foundCount(0),
|
||||
|
@ -36,7 +36,7 @@ DeleteEntityOperator::DeleteEntityOperator(EntityTree* tree) :
|
|||
{
|
||||
}
|
||||
|
||||
void DeleteEntityOperator::addEntityIDToDeleteList(const QUuid& searchEntityID) {
|
||||
void DeleteEntityOperator::addEntityIDToDeleteList(const EntityItemID& searchEntityID) {
|
||||
// check our tree, to determine if this entity is known
|
||||
EntityToDeleteDetails details;
|
||||
details.containingElement = _tree->getContainingElement(searchEntityID);
|
||||
|
@ -95,7 +95,7 @@ bool DeleteEntityOperator::preRecursion(OctreeElement* element) {
|
|||
EntityItem* theEntity = details.entity;
|
||||
bool entityDeleted = entityTreeElement->removeEntityItem(theEntity); // remove it from the element
|
||||
assert(entityDeleted);
|
||||
_tree->setContainingElement(details.entity->getID(), NULL); // update or id to element lookup
|
||||
_tree->setContainingElement(details.entity->getEntityItemID(), NULL); // update or id to element lookup
|
||||
_foundCount++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,20 +22,20 @@ public:
|
|||
typedef QSet<EntityToDeleteDetails> RemovedEntities;
|
||||
|
||||
inline uint qHash(const EntityToDeleteDetails& a, uint seed) {
|
||||
return qHash(a.entity->getID(), seed);
|
||||
return qHash(a.entity->getEntityItemID(), seed);
|
||||
}
|
||||
|
||||
inline bool operator==(const EntityToDeleteDetails& a, const EntityToDeleteDetails& b) {
|
||||
return a.entity->getID() == b.entity->getID();
|
||||
return a.entity->getEntityItemID() == b.entity->getEntityItemID();
|
||||
}
|
||||
|
||||
class DeleteEntityOperator : public RecurseOctreeOperator {
|
||||
public:
|
||||
DeleteEntityOperator(EntityTree* tree);
|
||||
DeleteEntityOperator(EntityTree* tree, const QUuid& searchEntityID);
|
||||
DeleteEntityOperator(EntityTree* tree, const EntityItemID& searchEntityID);
|
||||
~DeleteEntityOperator();
|
||||
|
||||
void addEntityIDToDeleteList(const QUuid& searchEntityID);
|
||||
void addEntityIDToDeleteList(const EntityItemID& searchEntityID);
|
||||
virtual bool preRecursion(OctreeElement* element);
|
||||
virtual bool postRecursion(OctreeElement* element);
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ void EntityEditPacketSender::adjustEditPacketForClockSkew(PacketType type,
|
|||
}
|
||||
}
|
||||
|
||||
void EntityEditPacketSender::queueEditEntityMessage(PacketType type, QUuid modelID,
|
||||
const EntityItemProperties& properties) {
|
||||
void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemID modelID,
|
||||
const EntityItemProperties& properties) {
|
||||
if (!_shouldSend) {
|
||||
return; // bail early
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, QUuid model
|
|||
}
|
||||
}
|
||||
|
||||
void EntityEditPacketSender::queueEraseEntityMessage(const QUuid& entityItemID) {
|
||||
void EntityEditPacketSender::queueEraseEntityMessage(const EntityItemID& entityItemID) {
|
||||
if (!_shouldSend) {
|
||||
return; // bail early
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ public:
|
|||
/// which voxel-server node or nodes the packet should be sent to. Can be called even before voxel servers are known, in
|
||||
/// which case up to MaxPendingMessages will be buffered and processed when voxel servers are known.
|
||||
/// NOTE: EntityItemProperties assumes that all distances are in meter units
|
||||
void queueEditEntityMessage(PacketType type, QUuid modelID, const EntityItemProperties& properties);
|
||||
void queueEditEntityMessage(PacketType type, EntityItemID modelID, const EntityItemProperties& properties);
|
||||
|
||||
void queueEraseEntityMessage(const QUuid& entityItemID);
|
||||
void queueEraseEntityMessage(const EntityItemID& entityItemID);
|
||||
|
||||
// My server type is the model server
|
||||
virtual char getMyNodeType() const { return NodeType::EntityServer; }
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
|
||||
bool EntityItem::_sendPhysicsUpdates = true;
|
||||
|
||||
EntityItem::EntityItem(const QUuid& entityItemID) :
|
||||
EntityItem::EntityItem(const EntityItemID& entityItemID) :
|
||||
_type(EntityTypes::Unknown),
|
||||
_id(entityItemID),
|
||||
_id(entityItemID.id),
|
||||
_lastSimulated(0),
|
||||
_lastUpdated(0),
|
||||
_lastEdited(0),
|
||||
|
@ -76,7 +76,7 @@ EntityItem::EntityItem(const QUuid& entityItemID) :
|
|||
_lastUpdated = now;
|
||||
}
|
||||
|
||||
EntityItem::EntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) : EntityItem(entityItemID)
|
||||
EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : EntityItem(entityItemID)
|
||||
{
|
||||
setProperties(properties);
|
||||
}
|
||||
|
@ -156,8 +156,8 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
|||
|
||||
// If we are being called for a subsequent pass at appendEntityData() that failed to completely encode this item,
|
||||
// then our entityTreeElementExtraEncodeData should include data about which properties we need to append.
|
||||
if (entityTreeElementExtraEncodeData && entityTreeElementExtraEncodeData->entities.contains(getID())) {
|
||||
requestedProperties = entityTreeElementExtraEncodeData->entities.value(getID());
|
||||
if (entityTreeElementExtraEncodeData && entityTreeElementExtraEncodeData->entities.contains(getEntityItemID())) {
|
||||
requestedProperties = entityTreeElementExtraEncodeData->entities.value(getEntityItemID());
|
||||
}
|
||||
|
||||
LevelDetails entityLevel = packetData->startLevel();
|
||||
|
@ -167,7 +167,7 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
|||
#ifdef WANT_DEBUG
|
||||
float editedAgo = getEditedAgo();
|
||||
QString agoAsString = formatSecondsElapsed(editedAgo);
|
||||
qCDebug(entities) << "Writing entity " << getID() << " to buffer, lastEdited =" << lastEdited
|
||||
qCDebug(entities) << "Writing entity " << getEntityItemID() << " to buffer, lastEdited =" << lastEdited
|
||||
<< " ago=" << editedAgo << "seconds - " << agoAsString;
|
||||
#endif
|
||||
|
||||
|
@ -284,7 +284,7 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
|||
// If any part of the model items didn't fit, then the element is considered partial
|
||||
if (appendState != OctreeElement::COMPLETED) {
|
||||
// add this item into our list for the next appendElementData() pass
|
||||
entityTreeElementExtraEncodeData->entities.insert(getID(), propertiesDidntFit);
|
||||
entityTreeElementExtraEncodeData->entities.insert(getEntityItemID(), propertiesDidntFit);
|
||||
}
|
||||
|
||||
return appendState;
|
||||
|
@ -308,6 +308,16 @@ int EntityItem::expectedBytes() {
|
|||
|
||||
|
||||
int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args) {
|
||||
|
||||
if (args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU) {
|
||||
|
||||
// NOTE: This shouldn't happen. The only versions of the bit stream that didn't support split mtu buffers should
|
||||
// be handled by the model subclass and shouldn't call this routine.
|
||||
qCDebug(entities) << "EntityItem::readEntityDataFromBuffer()... "
|
||||
"ERROR CASE...args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if this bitstream indicates that this node is the simulation owner, ignore any physics-related updates.
|
||||
glm::vec3 savePosition = _position;
|
||||
glm::quat saveRotation = _rotation;
|
||||
|
@ -375,7 +385,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
QString agoAsString = formatSecondsElapsed(editedAgo);
|
||||
QString ageAsString = formatSecondsElapsed(getAge());
|
||||
qCDebug(entities) << "------------------------------------------";
|
||||
qCDebug(entities) << "Loading entity " << getID() << " from buffer...";
|
||||
qCDebug(entities) << "Loading entity " << getEntityItemID() << " from buffer...";
|
||||
qCDebug(entities) << "------------------------------------------";
|
||||
debugDump();
|
||||
qCDebug(entities) << "------------------------------------------";
|
||||
|
@ -402,7 +412,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
|
||||
#ifdef WANT_DEBUG
|
||||
qCDebug(entities) << "data from server **************** ";
|
||||
qCDebug(entities) << " entityItemID:" << getID();
|
||||
qCDebug(entities) << " entityItemID:" << getEntityItemID();
|
||||
qCDebug(entities) << " now:" << now;
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
qCDebug(entities) << " lastEditedFromBuffer:" << debugTime(lastEditedFromBuffer, now);
|
||||
|
@ -492,7 +502,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
|
||||
#ifdef WANT_DEBUG
|
||||
if (overwriteLocalData) {
|
||||
qCDebug(entities) << "EntityItem::readEntityDataFromBuffer()... changed entity:" << getID();
|
||||
qCDebug(entities) << "EntityItem::readEntityDataFromBuffer()... changed entity:" << getEntityItemID();
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
qCDebug(entities) << " getLastSimulated:" << debugTime(getLastSimulated(), now);
|
||||
qCDebug(entities) << " getLastUpdated:" << debugTime(getLastUpdated(), now);
|
||||
|
@ -626,7 +636,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
}
|
||||
|
||||
void EntityItem::debugDump() const {
|
||||
qCDebug(entities) << "EntityItem id:" << getID();
|
||||
qCDebug(entities) << "EntityItem id:" << getEntityItemID();
|
||||
qCDebug(entities, " edited ago:%f", getEditedAgo());
|
||||
qCDebug(entities, " position:%f,%f,%f", _position.x, _position.y, _position.z);
|
||||
qCDebug(entities) << " dimensions:" << _dimensions;
|
||||
|
@ -700,7 +710,7 @@ void EntityItem::simulate(const quint64& now) {
|
|||
|
||||
#ifdef WANT_DEBUG
|
||||
qCDebug(entities) << "********** EntityItem::simulate()";
|
||||
qCDebug(entities) << " entity ID=" << getID();
|
||||
qCDebug(entities) << " entity ID=" << getEntityItemID();
|
||||
qCDebug(entities) << " simulator ID=" << getSimulatorID();
|
||||
qCDebug(entities) << " now=" << now;
|
||||
qCDebug(entities) << " _lastSimulated=" << _lastSimulated;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <OctreePacketData.h>
|
||||
#include <ShapeInfo.h>
|
||||
|
||||
#include "EntityItemID.h"
|
||||
#include "EntityItemProperties.h"
|
||||
#include "EntityItemPropertiesDefaults.h"
|
||||
#include "EntityTypes.h"
|
||||
|
@ -88,13 +89,14 @@ public:
|
|||
|
||||
DONT_ALLOW_INSTANTIATION // This class can not be instantiated directly
|
||||
|
||||
EntityItem(const QUuid& entityItemID);
|
||||
EntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
EntityItem(const EntityItemID& entityItemID);
|
||||
EntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
virtual ~EntityItem();
|
||||
|
||||
// ID and EntityItemID related methods
|
||||
const QUuid& getID() const { return _id; }
|
||||
void setID(const QUuid& id) { _id = id; }
|
||||
EntityItemID getEntityItemID() const { return EntityItemID(_id); }
|
||||
|
||||
// methods for getting/setting all properties of an entity
|
||||
virtual EntityItemProperties getProperties() const;
|
||||
|
@ -138,8 +140,8 @@ public:
|
|||
int& propertyCount,
|
||||
OctreeElement::AppendState& appendState) const { /* do nothing*/ };
|
||||
|
||||
static QUuid readEntityItemIDFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args);
|
||||
static EntityItemID readEntityItemIDFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args);
|
||||
|
||||
virtual int readEntityDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args);
|
||||
|
||||
|
|
57
libraries/entities/src/EntityItemID.cpp
Normal file
57
libraries/entities/src/EntityItemID.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// EntityItemID.cpp
|
||||
// libraries/entities/src
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/4/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QDebug>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "RegisteredMetaTypes.h"
|
||||
#include "EntityItemID.h"
|
||||
|
||||
|
||||
EntityItemID::EntityItemID() :
|
||||
id(UNKNOWN_ENTITY_ID)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
EntityItemID::EntityItemID(const QUuid& id) :
|
||||
id(id)
|
||||
{
|
||||
}
|
||||
|
||||
EntityItemID::EntityItemID(const EntityItemID& other) : id(other.id)
|
||||
{
|
||||
}
|
||||
|
||||
EntityItemID EntityItemID::readEntityItemIDFromBuffer(const unsigned char* data, int bytesLeftToRead) {
|
||||
EntityItemID result;
|
||||
|
||||
if (bytesLeftToRead >= NUM_BYTES_RFC4122_UUID) {
|
||||
// id
|
||||
QByteArray encodedID((const char*)data, NUM_BYTES_RFC4122_UUID);
|
||||
result.id = QUuid::fromRfc4122(encodedID);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QScriptValue EntityItemID::toScriptValue(QScriptEngine* engine) const {
|
||||
return EntityItemIDtoScriptValue(engine, *this);
|
||||
}
|
||||
|
||||
QScriptValue EntityItemIDtoScriptValue(QScriptEngine* engine, const EntityItemID& id) {
|
||||
return quuidToScriptValue(engine, id.id);
|
||||
}
|
||||
|
||||
void EntityItemIDfromScriptValue(const QScriptValue &object, EntityItemID& id) {
|
||||
quuidFromScriptValue(object, id.id);
|
||||
}
|
71
libraries/entities/src/EntityItemID.h
Normal file
71
libraries/entities/src/EntityItemID.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
//
|
||||
// EntityItemID.h
|
||||
// libraries/entities/src
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 12/4/13.
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_EntityItemID_h
|
||||
#define hifi_EntityItemID_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QScriptEngine>
|
||||
#include <QUuid>
|
||||
|
||||
// const uint32_t UNKNOWN_ENTITY_TOKEN = 0xFFFFFFFF;
|
||||
// const uint32_t NEW_ENTITY = 0xFFFFFFFF;
|
||||
// const uint32_t UNKNOWN_ENTITY_ID = 0xFFFFFFFF;
|
||||
|
||||
const QUuid NEW_ENTITY;
|
||||
const QUuid UNKNOWN_ENTITY_ID;
|
||||
|
||||
|
||||
/// Abstract ID for editing model items. Used in EntityItem JS API.
|
||||
class EntityItemID {
|
||||
public:
|
||||
EntityItemID();
|
||||
EntityItemID(const QUuid& id);
|
||||
EntityItemID(const EntityItemID& other);
|
||||
static EntityItemID readEntityItemIDFromBuffer(const unsigned char* data, int bytesLeftToRead);
|
||||
QScriptValue toScriptValue(QScriptEngine* engine) const;
|
||||
|
||||
bool isInvalidID() const { return id == UNKNOWN_ENTITY_ID; }
|
||||
|
||||
QUuid id;
|
||||
};
|
||||
|
||||
inline bool operator<(const EntityItemID& a, const EntityItemID& b) {
|
||||
return a.id == b.id;
|
||||
}
|
||||
|
||||
inline bool operator==(const EntityItemID& a, const EntityItemID& b) {
|
||||
return a.id == b.id;
|
||||
}
|
||||
|
||||
inline bool operator!=(const EntityItemID& a, const EntityItemID& b) {
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
inline uint qHash(const EntityItemID& a, uint seed) {
|
||||
return qHash(a.id, seed);
|
||||
}
|
||||
|
||||
inline QDebug operator<<(QDebug debug, const EntityItemID& id) {
|
||||
debug << "[entity-id:" << id.id << "]";
|
||||
return debug;
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(EntityItemID);
|
||||
Q_DECLARE_METATYPE(QVector<EntityItemID>);
|
||||
QScriptValue EntityItemIDtoScriptValue(QScriptEngine* engine, const EntityItemID& properties);
|
||||
void EntityItemIDfromScriptValue(const QScriptValue &object, EntityItemID& properties);
|
||||
|
||||
#endif // hifi_EntityItemID_h
|
|
@ -91,7 +91,7 @@ EntityItemProperties::EntityItemProperties() :
|
|||
CONSTRUCT_PROPERTY(backgroundMode, BACKGROUND_MODE_INHERIT),
|
||||
CONSTRUCT_PROPERTY(sourceUrl, ""),
|
||||
|
||||
_id(QUuid()),
|
||||
_id(UNKNOWN_ENTITY_ID),
|
||||
_idSet(false),
|
||||
_lastEdited(0),
|
||||
_created(UNKNOWN_CREATED_TIME),
|
||||
|
@ -557,7 +557,7 @@ void EntityItemPropertiesFromScriptValue(const QScriptValue &object, EntityItemP
|
|||
//
|
||||
// TODO: Implement support for script and visible properties.
|
||||
//
|
||||
bool EntityItemProperties::encodeEntityEditPacket(PacketType command, QUuid id, const EntityItemProperties& properties,
|
||||
bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties,
|
||||
unsigned char* bufferOut, int sizeIn, int& sizeOut) {
|
||||
OctreePacketData ourDataPacket(false, sizeIn); // create a packetData object to add out packet details too.
|
||||
OctreePacketData* packetData = &ourDataPacket; // we want a pointer to this so we can use our APPEND_ENTITY_PROPERTY macro
|
||||
|
@ -586,7 +586,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, QUuid id,
|
|||
|
||||
// id
|
||||
// encode our ID as a byte count coded byte stream
|
||||
QByteArray encodedID = id.toRfc4122(); // NUM_BYTES_RFC4122_UUID
|
||||
QByteArray encodedID = id.id.toRfc4122(); // NUM_BYTES_RFC4122_UUID
|
||||
|
||||
// encode our ID as a byte count coded byte stream
|
||||
ByteCountCoded<quint32> tokenCoder;
|
||||
|
@ -818,7 +818,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, QUuid id,
|
|||
// TODO: Implement support for script and visible properties.
|
||||
//
|
||||
bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes,
|
||||
QUuid& entityID, EntityItemProperties& properties) {
|
||||
EntityItemID& entityID, EntityItemProperties& properties) {
|
||||
bool valid = false;
|
||||
|
||||
const unsigned char* dataAt = data;
|
||||
|
@ -975,7 +975,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
|||
// NOTE: This version will only encode the portion of the edit message immediately following the
|
||||
// header it does not include the send times and sequence number because that is handled by the
|
||||
// edit packet sender...
|
||||
bool EntityItemProperties::encodeEraseEntityMessage(const QUuid& entityItemID,
|
||||
bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityItemID,
|
||||
unsigned char* outputBuffer, size_t maxLength, size_t& outputLength) {
|
||||
|
||||
unsigned char* copyAt = outputBuffer;
|
||||
|
@ -990,7 +990,7 @@ bool EntityItemProperties::encodeEraseEntityMessage(const QUuid& entityItemID,
|
|||
copyAt += sizeof(numberOfIds);
|
||||
outputLength = sizeof(numberOfIds);
|
||||
|
||||
QUuid entityID = entityItemID;
|
||||
QUuid entityID = entityItemID.id;
|
||||
QByteArray encodedEntityID = entityID.toRfc4122();
|
||||
|
||||
memcpy(copyAt, encodedEntityID.constData(), NUM_BYTES_RFC4122_UUID);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <ShapeInfo.h>
|
||||
|
||||
#include "AtmospherePropertyGroup.h"
|
||||
#include "EntityItemID.h"
|
||||
#include "EntityItemPropertiesMacros.h"
|
||||
#include "EntityTypes.h"
|
||||
#include "EntityPropertyFlags.h"
|
||||
|
@ -162,20 +163,20 @@ public:
|
|||
void setGlowLevel(float value) { _glowLevel = value; _glowLevelChanged = true; }
|
||||
void setLocalRenderAlpha(float value) { _localRenderAlpha = value; _localRenderAlphaChanged = true; }
|
||||
|
||||
static bool encodeEntityEditPacket(PacketType command, QUuid id, const EntityItemProperties& properties,
|
||||
unsigned char* bufferOut, int sizeIn, int& sizeOut);
|
||||
static bool encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties,
|
||||
unsigned char* bufferOut, int sizeIn, int& sizeOut);
|
||||
|
||||
static bool encodeEraseEntityMessage(const QUuid& entityItemID,
|
||||
static bool encodeEraseEntityMessage(const EntityItemID& entityItemID,
|
||||
unsigned char* outputBuffer, size_t maxLength, size_t& outputLength);
|
||||
|
||||
|
||||
static bool decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes,
|
||||
QUuid& entityID, EntityItemProperties& properties);
|
||||
EntityItemID& entityID, EntityItemProperties& properties);
|
||||
|
||||
bool glowLevelChanged() const { return _glowLevelChanged; }
|
||||
bool localRenderAlphaChanged() const { return _localRenderAlphaChanged; }
|
||||
|
||||
void clearID() { _id = QUuid(); _idSet = false; }
|
||||
void clearID() { _id = UNKNOWN_ENTITY_ID; _idSet = false; }
|
||||
void markAllChanged();
|
||||
|
||||
void setSittingPoints(const QVector<SittingPoint>& sittingPoints);
|
||||
|
|
|
@ -28,7 +28,7 @@ EntityScriptingInterface::EntityScriptingInterface() :
|
|||
}
|
||||
|
||||
void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
|
||||
QUuid entityID, const EntityItemProperties& properties) {
|
||||
EntityItemID entityID, const EntityItemProperties& properties) {
|
||||
getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,6 @@ void EntityScriptingInterface::setEntityTree(EntityTree* modelTree) {
|
|||
if (_entityTree) {
|
||||
disconnect(_entityTree, &EntityTree::addingEntity, this, &EntityScriptingInterface::addingEntity);
|
||||
disconnect(_entityTree, &EntityTree::deletingEntity, this, &EntityScriptingInterface::deletingEntity);
|
||||
disconnect(_entityTree, &EntityTree::changingEntityID, this, &EntityScriptingInterface::changingEntityID);
|
||||
disconnect(_entityTree, &EntityTree::clearingEntities, this, &EntityScriptingInterface::clearingEntities);
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,6 @@ void EntityScriptingInterface::setEntityTree(EntityTree* modelTree) {
|
|||
if (_entityTree) {
|
||||
connect(_entityTree, &EntityTree::addingEntity, this, &EntityScriptingInterface::addingEntity);
|
||||
connect(_entityTree, &EntityTree::deletingEntity, this, &EntityScriptingInterface::deletingEntity);
|
||||
connect(_entityTree, &EntityTree::changingEntityID, this, &EntityScriptingInterface::changingEntityID);
|
||||
connect(_entityTree, &EntityTree::clearingEntities, this, &EntityScriptingInterface::clearingEntities);
|
||||
}
|
||||
}
|
||||
|
@ -70,10 +68,11 @@ void bidForSimulationOwnership(EntityItemProperties& properties) {
|
|||
|
||||
|
||||
|
||||
QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties) {
|
||||
EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& properties) {
|
||||
|
||||
EntityItemProperties propertiesWithSimID = properties;
|
||||
QUuid id = QUuid::createUuid();
|
||||
|
||||
EntityItemID id = EntityItemID(QUuid::createUuid());
|
||||
|
||||
// If we have a local entity tree set, then also update it.
|
||||
bool success = true;
|
||||
|
@ -99,11 +98,11 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
|
|||
return id;
|
||||
}
|
||||
|
||||
EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identity) {
|
||||
EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID identity) {
|
||||
EntityItemProperties results;
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForRead();
|
||||
EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(identity));
|
||||
EntityItem* entity = const_cast<EntityItem*>(_entityTree->findEntityByEntityItemID(EntityItemID(identity)));
|
||||
|
||||
if (entity) {
|
||||
results = entity->getProperties();
|
||||
|
@ -127,7 +126,8 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit
|
|||
return results;
|
||||
}
|
||||
|
||||
QUuid EntityScriptingInterface::editEntity(QUuid entityID, const EntityItemProperties& properties) {
|
||||
EntityItemID EntityScriptingInterface::editEntity(EntityItemID id, const EntityItemProperties& properties) {
|
||||
EntityItemID entityID(id);
|
||||
// If we have a local entity tree set, then also update it.
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForWrite();
|
||||
|
@ -145,16 +145,16 @@ QUuid EntityScriptingInterface::editEntity(QUuid entityID, const EntityItemPrope
|
|||
modifiedProperties.setType(entity->getType());
|
||||
bidForSimulationOwnership(modifiedProperties);
|
||||
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, modifiedProperties);
|
||||
return entityID;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
|
||||
return entityID;
|
||||
return id;
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::deleteEntity(QUuid entityID) {
|
||||
|
||||
void EntityScriptingInterface::deleteEntity(EntityItemID id) {
|
||||
EntityItemID entityID(id);
|
||||
bool shouldDelete = true;
|
||||
|
||||
// If we have a local entity tree set, then also update it.
|
||||
|
@ -179,14 +179,14 @@ void EntityScriptingInterface::deleteEntity(QUuid entityID) {
|
|||
}
|
||||
}
|
||||
|
||||
QUuid EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {
|
||||
EntityItemID EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {
|
||||
QUuid result;
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForRead();
|
||||
const EntityItem* closestEntity = _entityTree->findClosestEntity(center, radius);
|
||||
_entityTree->unlock();
|
||||
if (closestEntity) {
|
||||
result = closestEntity->getID();
|
||||
result = closestEntity->getEntityItemID().id;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -201,8 +201,8 @@ void EntityScriptingInterface::dumpTree() const {
|
|||
}
|
||||
}
|
||||
|
||||
QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const {
|
||||
QVector<QUuid> result;
|
||||
QVector<EntityItemID> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const {
|
||||
QVector<EntityItemID> result;
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForRead();
|
||||
QVector<const EntityItem*> entities;
|
||||
|
@ -210,14 +210,14 @@ QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, f
|
|||
_entityTree->unlock();
|
||||
|
||||
foreach (const EntityItem* entity, entities) {
|
||||
result << entity->getID();
|
||||
result << entity->getEntityItemID();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const {
|
||||
QVector<QUuid> result;
|
||||
QVector<EntityItemID> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const {
|
||||
QVector<EntityItemID> result;
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForRead();
|
||||
AABox box(corner, dimensions);
|
||||
|
@ -226,7 +226,7 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corn
|
|||
_entityTree->unlock();
|
||||
|
||||
foreach (const EntityItem* entity, entities) {
|
||||
result << entity->getID();
|
||||
result << entity->getEntityItemID();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -253,7 +253,7 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke
|
|||
(void**)&intersectedEntity, lockType, &result.accurate,
|
||||
precisionPicking);
|
||||
if (result.intersects && intersectedEntity) {
|
||||
result.entityID = intersectedEntity->getID();
|
||||
result.entityID = intersectedEntity->getEntityItemID().id;
|
||||
result.properties = intersectedEntity->getProperties();
|
||||
result.intersection = ray.origin + (ray.direction * result.distance);
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c
|
|||
QScriptValue obj = engine->newObject();
|
||||
obj.setProperty("intersects", value.intersects);
|
||||
obj.setProperty("accurate", value.accurate);
|
||||
QScriptValue entityItemValue = quuidToScriptValue(engine, value.entityID);
|
||||
QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
|
||||
obj.setProperty("entityID", entityItemValue);
|
||||
|
||||
QScriptValue propertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties);
|
||||
|
@ -353,7 +353,7 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra
|
|||
value.intersects = object.property("intersects").toVariant().toBool();
|
||||
value.accurate = object.property("accurate").toVariant().toBool();
|
||||
QScriptValue entityIDValue = object.property("entityID");
|
||||
quuidFromScriptValue(entityIDValue, value.entityID);
|
||||
EntityItemIDfromScriptValue(entityIDValue, value.entityID);
|
||||
QScriptValue entityPropertiesValue = object.property("properties");
|
||||
if (entityPropertiesValue.isValid()) {
|
||||
EntityItemPropertiesFromScriptValue(entityPropertiesValue, value.properties);
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
RayToEntityIntersectionResult();
|
||||
bool intersects;
|
||||
bool accurate;
|
||||
QUuid entityID;
|
||||
EntityItemID entityID;
|
||||
EntityItemProperties properties;
|
||||
float distance;
|
||||
BoxFace face;
|
||||
|
@ -70,31 +70,31 @@ public slots:
|
|||
Q_INVOKABLE bool canRez();
|
||||
|
||||
/// adds a model with the specific properties
|
||||
Q_INVOKABLE QUuid addEntity(const EntityItemProperties& properties);
|
||||
Q_INVOKABLE EntityItemID addEntity(const EntityItemProperties& properties);
|
||||
|
||||
/// gets the current model properties for a specific model
|
||||
/// this function will not find return results in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE EntityItemProperties getEntityProperties(QUuid entityID);
|
||||
Q_INVOKABLE EntityItemProperties getEntityProperties(EntityItemID entityID);
|
||||
|
||||
/// edits a model updating only the included properties, will return the identified QUuid in case of
|
||||
/// edits a model updating only the included properties, will return the identified EntityItemID in case of
|
||||
/// successful edit, if the input entityID is for an unknown model this function will have no effect
|
||||
Q_INVOKABLE QUuid editEntity(QUuid entityID, const EntityItemProperties& properties);
|
||||
Q_INVOKABLE EntityItemID editEntity(EntityItemID entityID, const EntityItemProperties& properties);
|
||||
|
||||
/// deletes a model
|
||||
Q_INVOKABLE void deleteEntity(QUuid entityID);
|
||||
Q_INVOKABLE void deleteEntity(EntityItemID entityID);
|
||||
|
||||
/// finds the closest model to the center point, within the radius
|
||||
/// will return a QUuid.isKnownID = false if no models are in the radius
|
||||
/// will return a EntityItemID.isKnownID = false if no models are in the radius
|
||||
/// this function will not find any models in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE QUuid findClosestEntity(const glm::vec3& center, float radius) const;
|
||||
Q_INVOKABLE EntityItemID findClosestEntity(const glm::vec3& center, float radius) const;
|
||||
|
||||
/// finds models within the search sphere specified by the center point and radius
|
||||
/// this function will not find any models in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE QVector<QUuid> findEntities(const glm::vec3& center, float radius) const;
|
||||
Q_INVOKABLE QVector<EntityItemID> findEntities(const glm::vec3& center, float radius) const;
|
||||
|
||||
/// finds models within the search sphere specified by the center point and radius
|
||||
/// this function will not find any models in script engine contexts which don't have access to models
|
||||
Q_INVOKABLE QVector<QUuid> findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const;
|
||||
Q_INVOKABLE QVector<EntityItemID> findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const;
|
||||
|
||||
/// If the scripting context has visible entities, this will determine a ray intersection, the results
|
||||
/// may be inaccurate if the engine is unable to access the visible entities, in which case result.accurate
|
||||
|
@ -120,33 +120,33 @@ public slots:
|
|||
Q_INVOKABLE void dumpTree() const;
|
||||
|
||||
signals:
|
||||
void entityCollisionWithEntity(const QUuid& idA, const QUuid& idB, const Collision& collision);
|
||||
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||
|
||||
void canAdjustLocksChanged(bool canAdjustLocks);
|
||||
void canRezChanged(bool canRez);
|
||||
|
||||
void mousePressOnEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void mouseMoveOnEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void mouseReleaseOnEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void mousePressOnEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void mouseMoveOnEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void mouseReleaseOnEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
|
||||
void clickDownOnEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void holdingClickOnEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void clickReleaseOnEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void clickDownOnEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void holdingClickOnEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void clickReleaseOnEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
|
||||
void hoverEnterEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void hoverOverEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void hoverLeaveEntity(const QUuid& entityItemID, const MouseEvent& event);
|
||||
void hoverEnterEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void hoverOverEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
void hoverLeaveEntity(const EntityItemID& entityItemID, const MouseEvent& event);
|
||||
|
||||
void enterEntity(const QUuid& entityItemID);
|
||||
void leaveEntity(const QUuid& entityItemID);
|
||||
void enterEntity(const EntityItemID& entityItemID);
|
||||
void leaveEntity(const EntityItemID& entityItemID);
|
||||
|
||||
void deletingEntity(const QUuid& entityID);
|
||||
void addingEntity(const QUuid& entityID);
|
||||
void changingEntityID(const QUuid& oldEntityID, const QUuid& newEntityID);
|
||||
void deletingEntity(const EntityItemID& entityID);
|
||||
void addingEntity(const EntityItemID& entityID);
|
||||
void changingEntityID(const EntityItemID& oldEntityID, const EntityItemID& newEntityID);
|
||||
void clearingEntities();
|
||||
|
||||
private:
|
||||
void queueEntityMessage(PacketType packetType, QUuid entityID, const EntityItemProperties& properties);
|
||||
void queueEntityMessage(PacketType packetType, EntityItemID entityID, const EntityItemProperties& properties);
|
||||
|
||||
/// actually does the work of finding the ray intersection, can be called in locking mode or tryLock mode
|
||||
RayToEntityIntersectionResult findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType,
|
||||
|
|
|
@ -121,7 +121,7 @@ void EntitySimulation::sortEntitiesThatMoved() {
|
|||
// check to see if this movement has sent the entity outside of the domain.
|
||||
AACube newCube = entity->getMaximumAACube();
|
||||
if (!domainBounds.touches(newCube)) {
|
||||
qCDebug(entities) << "Entity " << entity->getID() << " moved out of domain bounds.";
|
||||
qCDebug(entities) << "Entity " << entity->getEntityItemID() << " moved out of domain bounds.";
|
||||
_entitiesToDelete.insert(entity);
|
||||
_mortalEntities.remove(entity);
|
||||
_entitiesToUpdate.remove(entity);
|
||||
|
@ -198,7 +198,7 @@ void EntitySimulation::changeEntity(EntityItem* entity) {
|
|||
AACube domainBounds(glm::vec3(0.0f,0.0f,0.0f), (float)TREE_SCALE);
|
||||
AACube newCube = entity->getMaximumAACube();
|
||||
if (!domainBounds.touches(newCube)) {
|
||||
qCDebug(entities) << "Entity " << entity->getID() << " moved out of domain bounds.";
|
||||
qCDebug(entities) << "Entity " << entity->getEntityItemID() << " moved out of domain bounds.";
|
||||
_entitiesToDelete.insert(entity);
|
||||
_mortalEntities.remove(entity);
|
||||
_entitiesToUpdate.remove(entity);
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
void getEntitiesToDelete(VectorOfEntities& entitiesToDelete);
|
||||
|
||||
signals:
|
||||
void entityCollisionWithEntity(const QUuid& idA, const QUuid& idB, const Collision& collision);
|
||||
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -83,11 +83,10 @@ void EntityTree::postAddEntity(EntityItem* entity) {
|
|||
_simulation->unlock();
|
||||
}
|
||||
_isDirty = true;
|
||||
emit addingEntity(entity->getID());
|
||||
emit addingEntity(entity->getEntityItemID());
|
||||
}
|
||||
|
||||
bool EntityTree::updateEntity(const QUuid& entityID, const EntityItemProperties& properties,
|
||||
const SharedNodePointer& senderNode) {
|
||||
bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode) {
|
||||
EntityTreeElement* containingElement = getContainingElement(entityID);
|
||||
if (!containingElement) {
|
||||
qCDebug(entities) << "UNEXPECTED!!!! EntityTree::updateEntity() entityID doesn't exist!!! entityID=" << entityID;
|
||||
|
@ -104,10 +103,10 @@ bool EntityTree::updateEntity(const QUuid& entityID, const EntityItemProperties&
|
|||
}
|
||||
|
||||
bool EntityTree::updateEntity(EntityItem* entity, const EntityItemProperties& properties, const SharedNodePointer& senderNode) {
|
||||
EntityTreeElement* containingElement = getContainingElement(entity->getID());
|
||||
EntityTreeElement* containingElement = getContainingElement(entity->getEntityItemID());
|
||||
if (!containingElement) {
|
||||
qCDebug(entities) << "UNEXPECTED!!!! EntityTree::updateEntity() entity-->element lookup failed!!! entityID="
|
||||
<< entity->getID();
|
||||
<< entity->getEntityItemID();
|
||||
return false;
|
||||
}
|
||||
return updateEntityWithElement(entity, properties, containingElement, senderNode);
|
||||
|
@ -205,22 +204,22 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro
|
|||
|
||||
QString entityScriptAfter = entity->getScript();
|
||||
if (entityScriptBefore != entityScriptAfter) {
|
||||
emitEntityScriptChanging(entity->getID()); // the entity script has changed
|
||||
emitEntityScriptChanging(entity->getEntityItemID()); // the entity script has changed
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: this final containingElement check should eventually be removed (or wrapped in an #ifdef DEBUG).
|
||||
containingElement = getContainingElement(entity->getID());
|
||||
containingElement = getContainingElement(entity->getEntityItemID());
|
||||
if (!containingElement) {
|
||||
qCDebug(entities) << "UNEXPECTED!!!! after updateEntity() we no longer have a containing element??? entityID="
|
||||
<< entity->getID();
|
||||
<< entity->getEntityItemID();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityItem* EntityTree::addEntity(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* EntityTree::addEntity(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* result = NULL;
|
||||
|
||||
if (getIsClient()) {
|
||||
|
@ -263,7 +262,7 @@ EntityItem* EntityTree::addEntity(const QUuid& entityID, const EntityItemPropert
|
|||
return result;
|
||||
}
|
||||
|
||||
void EntityTree::emitEntityScriptChanging(const QUuid& entityItemID) {
|
||||
void EntityTree::emitEntityScriptChanging(const EntityItemID& entityItemID) {
|
||||
emit entityScriptChanging(entityItemID);
|
||||
}
|
||||
|
||||
|
@ -282,7 +281,7 @@ void EntityTree::setSimulation(EntitySimulation* simulation) {
|
|||
_simulation = simulation;
|
||||
}
|
||||
|
||||
void EntityTree::deleteEntity(const QUuid& entityID, bool force, bool ignoreWarnings) {
|
||||
void EntityTree::deleteEntity(const EntityItemID& entityID, bool force, bool ignoreWarnings) {
|
||||
EntityTreeElement* containingElement = getContainingElement(entityID);
|
||||
if (!containingElement) {
|
||||
if (!ignoreWarnings) {
|
||||
|
@ -316,10 +315,10 @@ void EntityTree::deleteEntity(const QUuid& entityID, bool force, bool ignoreWarn
|
|||
_isDirty = true;
|
||||
}
|
||||
|
||||
void EntityTree::deleteEntities(QSet<QUuid> entityIDs, bool force, bool ignoreWarnings) {
|
||||
void EntityTree::deleteEntities(QSet<EntityItemID> entityIDs, bool force, bool ignoreWarnings) {
|
||||
// NOTE: callers must lock the tree before using this method
|
||||
DeleteEntityOperator theOperator(this);
|
||||
foreach(const QUuid& entityID, entityIDs) {
|
||||
foreach(const EntityItemID& entityID, entityIDs) {
|
||||
EntityTreeElement* containingElement = getContainingElement(entityID);
|
||||
if (!containingElement) {
|
||||
if (!ignoreWarnings) {
|
||||
|
@ -368,7 +367,7 @@ void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator)
|
|||
// set up the deleted entities ID
|
||||
quint64 deletedAt = usecTimestampNow();
|
||||
_recentlyDeletedEntitiesLock.lockForWrite();
|
||||
_recentlyDeletedEntityItemIDs.insert(deletedAt, theEntity->getID());
|
||||
_recentlyDeletedEntityItemIDs.insert(deletedAt, theEntity->getEntityItemID().id);
|
||||
_recentlyDeletedEntitiesLock.unlock();
|
||||
}
|
||||
|
||||
|
@ -383,6 +382,7 @@ void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator)
|
|||
}
|
||||
|
||||
void EntityTree::handleAddEntityResponse(const QByteArray& packet) {
|
||||
|
||||
if (!getIsClient()) {
|
||||
qCDebug(entities) << "UNEXPECTED!!! EntityTree::handleAddEntityResponse() with !getIsClient() ***";
|
||||
return;
|
||||
|
@ -537,10 +537,11 @@ void EntityTree::findEntities(const AABox& box, QVector<EntityItem*>& foundEntit
|
|||
}
|
||||
|
||||
EntityItem* EntityTree::findEntityByID(const QUuid& id) {
|
||||
return findEntityByEntityItemID(id);
|
||||
EntityItemID entityID(id);
|
||||
return findEntityByEntityItemID(entityID);
|
||||
}
|
||||
|
||||
EntityItem* EntityTree::findEntityByEntityItemID(const QUuid& entityID) /*const*/ {
|
||||
EntityItem* EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) /*const*/ {
|
||||
EntityItem* foundEntity = NULL;
|
||||
EntityTreeElement* containingElement = getContainingElement(entityID);
|
||||
if (containingElement) {
|
||||
|
@ -567,32 +568,29 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char
|
|||
}
|
||||
|
||||
case PacketTypeEntityAddOrEdit: {
|
||||
QUuid entityItemID;
|
||||
EntityItemID entityItemID;
|
||||
EntityItemProperties properties;
|
||||
bool validEditPacket = EntityItemProperties::decodeEntityEditPacket(editData, maxLength,
|
||||
processedBytes, entityItemID, properties);
|
||||
processedBytes, entityItemID, properties);
|
||||
|
||||
// If we got a valid edit packet, then it could be a new entity or it could be an update to
|
||||
// an existing entity... handle appropriately
|
||||
if (validEditPacket) {
|
||||
// search for the entity by EntityItemID
|
||||
EntityItem* existingEntity = findEntityByEntityItemID(entityItemID);
|
||||
|
||||
|
||||
// If this is a knownID, then it should exist in our tree
|
||||
if (existingEntity) {
|
||||
// if the EntityItem exists, then update it
|
||||
if (existingEntity) {
|
||||
if (wantEditLogging()) {
|
||||
qCDebug(entities) << "User [" << senderNode->getUUID() << "] editing entity. ID:" << entityItemID;
|
||||
qCDebug(entities) << " properties:" << properties;
|
||||
}
|
||||
updateEntity(entityItemID, properties, senderNode);
|
||||
existingEntity->markAsChangedOnServer();
|
||||
} else {
|
||||
qCDebug(entities) << "User attempted to edit an unknown entity. ID:" << entityItemID;
|
||||
if (wantEditLogging()) {
|
||||
qCDebug(entities) << "User [" << senderNode->getUUID() << "] editing entity. ID:" << entityItemID;
|
||||
qCDebug(entities) << " properties:" << properties;
|
||||
}
|
||||
updateEntity(entityItemID, properties, senderNode);
|
||||
existingEntity->markAsChangedOnServer();
|
||||
} else {
|
||||
if (senderNode->getCanRez()) {
|
||||
// this is a new entity... assign a new entityID
|
||||
if (wantEditLogging()) {
|
||||
qCDebug(entities) << "User [" << senderNode->getUUID() << "] adding entity.";
|
||||
qCDebug(entities) << " properties:" << properties;
|
||||
|
@ -603,13 +601,13 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char
|
|||
notifyNewlyCreatedEntity(*newEntity, senderNode);
|
||||
if (wantEditLogging()) {
|
||||
qCDebug(entities) << "User [" << senderNode->getUUID() << "] added entity. ID:"
|
||||
<< newEntity->getID();
|
||||
<< newEntity->getEntityItemID();
|
||||
qCDebug(entities) << " properties:" << properties;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
qCDebug(entities) << "User without 'rez rights' ["
|
||||
<< senderNode->getUUID() << "] attempted to add an entity.";
|
||||
qCDebug(entities) << "User without 'rez rights' [" << senderNode->getUUID() << "] attempted to add an entity.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -677,11 +675,11 @@ void EntityTree::update() {
|
|||
|
||||
if (pendingDeletes.size() > 0) {
|
||||
// translate into list of ID's
|
||||
QSet<QUuid> idsToDelete;
|
||||
QSet<EntityItemID> idsToDelete;
|
||||
for (auto entityItr : pendingDeletes) {
|
||||
EntityItem* entity = &(*entityItr);
|
||||
assert(!entity->getPhysicsInfo()); // TODO: Andrew to remove this after testing
|
||||
idsToDelete.insert(entity->getID());
|
||||
idsToDelete.insert(entity->getEntityItemID());
|
||||
}
|
||||
// delete these things the roundabout way
|
||||
deleteEntities(idsToDelete, true);
|
||||
|
@ -841,7 +839,7 @@ int EntityTree::processEraseMessage(const QByteArray& dataByteArray, const Share
|
|||
processedBytes += sizeof(numberOfIds);
|
||||
|
||||
if (numberOfIds > 0) {
|
||||
QSet<QUuid> entityItemIDsToDelete;
|
||||
QSet<EntityItemID> entityItemIDsToDelete;
|
||||
|
||||
for (size_t i = 0; i < numberOfIds; i++) {
|
||||
|
||||
|
@ -855,10 +853,11 @@ int EntityTree::processEraseMessage(const QByteArray& dataByteArray, const Share
|
|||
dataAt += encodedID.size();
|
||||
processedBytes += encodedID.size();
|
||||
|
||||
entityItemIDsToDelete << entityID;
|
||||
EntityItemID entityItemID(entityID);
|
||||
entityItemIDsToDelete << entityItemID;
|
||||
|
||||
if (wantEditLogging()) {
|
||||
qCDebug(entities) << "User [" << sourceNode->getUUID() << "] deleting entity. ID:" << entityID;
|
||||
qCDebug(entities) << "User [" << sourceNode->getUUID() << "] deleting entity. ID:" << entityItemID;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -883,7 +882,7 @@ int EntityTree::processEraseMessageDetails(const QByteArray& dataByteArray, cons
|
|||
processedBytes += sizeof(numberOfIds);
|
||||
|
||||
if (numberOfIds > 0) {
|
||||
QSet<QUuid> entityItemIDsToDelete;
|
||||
QSet<EntityItemID> entityItemIDsToDelete;
|
||||
|
||||
for (size_t i = 0; i < numberOfIds; i++) {
|
||||
|
||||
|
@ -898,10 +897,11 @@ int EntityTree::processEraseMessageDetails(const QByteArray& dataByteArray, cons
|
|||
dataAt += encodedID.size();
|
||||
processedBytes += encodedID.size();
|
||||
|
||||
entityItemIDsToDelete << entityID;
|
||||
EntityItemID entityItemID(entityID);
|
||||
entityItemIDsToDelete << entityItemID;
|
||||
|
||||
if (wantEditLogging()) {
|
||||
qCDebug(entities) << "User [" << sourceNode->getUUID() << "] deleting entity. ID:" << entityID;
|
||||
qCDebug(entities) << "User [" << sourceNode->getUUID() << "] deleting entity. ID:" << entityItemID;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -910,14 +910,13 @@ int EntityTree::processEraseMessageDetails(const QByteArray& dataByteArray, cons
|
|||
return processedBytes;
|
||||
}
|
||||
|
||||
EntityTreeElement* EntityTree::getContainingElement(const QUuid& entityItemID) /*const*/ {
|
||||
EntityTreeElement* EntityTree::getContainingElement(const EntityItemID& entityItemID) /*const*/ {
|
||||
// TODO: do we need to make this thread safe? Or is it acceptable as is
|
||||
EntityTreeElement* element = _entityToElementMap.value(entityItemID);
|
||||
return element;
|
||||
}
|
||||
|
||||
|
||||
void EntityTree::setContainingElement(const QUuid& entityItemID, EntityTreeElement* element) {
|
||||
void EntityTree::setContainingElement(const EntityItemID& entityItemID, EntityTreeElement* element) {
|
||||
// TODO: do we need to make this thread safe? Or is it acceptable as is
|
||||
if (element) {
|
||||
_entityToElementMap[entityItemID] = element;
|
||||
|
@ -926,11 +925,9 @@ void EntityTree::setContainingElement(const QUuid& entityItemID, EntityTreeEleme
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EntityTree::debugDumpMap() {
|
||||
qCDebug(entities) << "EntityTree::debugDumpMap() --------------------------";
|
||||
QHashIterator<QUuid, EntityTreeElement*> i(_entityToElementMap);
|
||||
QHashIterator<EntityItemID, EntityTreeElement*> i(_entityToElementMap);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
qCDebug(entities) << i.key() << ": " << i.value();
|
||||
|
@ -994,13 +991,12 @@ void EntityTree::pruneTree() {
|
|||
recurseTreeWithOperator(&theOperator);
|
||||
}
|
||||
|
||||
QVector<QUuid> EntityTree::sendEntities(EntityEditPacketSender* packetSender,
|
||||
EntityTree* localTree, float x, float y, float z) {
|
||||
QVector<EntityItemID> EntityTree::sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z) {
|
||||
SendEntitiesOperationArgs args;
|
||||
args.packetSender = packetSender;
|
||||
args.localTree = localTree;
|
||||
args.root = glm::vec3(x, y, z);
|
||||
QVector<QUuid> newEntityIDs;
|
||||
QVector<EntityItemID> newEntityIDs;
|
||||
args.newEntityIDs = &newEntityIDs;
|
||||
recurseTreeWithOperation(sendEntitiesOperation, &args);
|
||||
packetSender->releaseQueuedMessages();
|
||||
|
@ -1014,7 +1010,7 @@ bool EntityTree::sendEntitiesOperation(OctreeElement* element, void* extraData)
|
|||
|
||||
const QList<EntityItem*>& entities = entityTreeElement->getEntities();
|
||||
for (int i = 0; i < entities.size(); i++) {
|
||||
QUuid newID = QUuid::createUuid();
|
||||
EntityItemID newID(QUuid::createUuid());
|
||||
args->newEntityIDs->append(newID);
|
||||
EntityItemProperties properties = entities[i]->getProperties();
|
||||
properties.setPosition(properties.getPosition() + args->root);
|
||||
|
@ -1057,11 +1053,11 @@ bool EntityTree::readFromMap(QVariantMap& map) {
|
|||
EntityItemProperties properties;
|
||||
EntityItemPropertiesFromScriptValue(entityScriptValue, properties);
|
||||
|
||||
QUuid entityItemID;
|
||||
EntityItemID entityItemID;
|
||||
if (entityMap.contains("id")) {
|
||||
entityItemID = QUuid(entityMap["id"].toString());
|
||||
entityItemID = EntityItemID(QUuid(entityMap["id"].toString()));
|
||||
} else {
|
||||
entityItemID = QUuid::createUuid();
|
||||
entityItemID = EntityItemID(QUuid::createUuid());
|
||||
}
|
||||
|
||||
EntityItem* entity = addEntity(entityItemID, properties);
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
glm::vec3 root;
|
||||
EntityTree* localTree;
|
||||
EntityEditPacketSender* packetSender;
|
||||
QVector<QUuid>* newEntityIDs;
|
||||
QVector<EntityItemID>* newEntityIDs;
|
||||
};
|
||||
|
||||
|
||||
|
@ -85,25 +85,24 @@ public:
|
|||
// The newer API...
|
||||
void postAddEntity(EntityItem* entityItem);
|
||||
|
||||
EntityItem* addEntity(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
EntityItem* addEntity(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
// use this method if you only know the entityID
|
||||
bool updateEntity(const QUuid& entityID, const EntityItemProperties& properties,
|
||||
const SharedNodePointer& senderNode = SharedNodePointer(nullptr));
|
||||
bool updateEntity(const EntityItemID& entityID, const EntityItemProperties& properties, const SharedNodePointer& senderNode = SharedNodePointer(nullptr));
|
||||
|
||||
// use this method if you have a pointer to the entity (avoid an extra entity lookup)
|
||||
bool updateEntity(EntityItem* entity, const EntityItemProperties& properties, const SharedNodePointer& senderNode = SharedNodePointer(nullptr));
|
||||
|
||||
void deleteEntity(const QUuid& entityID, bool force = false, bool ignoreWarnings = false);
|
||||
void deleteEntities(QSet<QUuid> entityIDs, bool force = false, bool ignoreWarnings = false);
|
||||
void deleteEntity(const EntityItemID& entityID, bool force = false, bool ignoreWarnings = false);
|
||||
void deleteEntities(QSet<EntityItemID> entityIDs, bool force = false, bool ignoreWarnings = false);
|
||||
|
||||
/// \param position point of query in world-frame (meters)
|
||||
/// \param targetRadius radius of query (meters)
|
||||
const EntityItem* findClosestEntity(glm::vec3 position, float targetRadius);
|
||||
EntityItem* findEntityByID(const QUuid& id);
|
||||
EntityItem* findEntityByEntityItemID(const QUuid& entityID);
|
||||
EntityItem* findEntityByEntityItemID(const EntityItemID& entityID);
|
||||
|
||||
QUuid assignEntityID(const QUuid& entityItemID); /// Assigns a known ID for a creator token ID
|
||||
EntityItemID assignEntityID(const EntityItemID& entityItemID); /// Assigns a known ID for a creator token ID
|
||||
|
||||
|
||||
/// finds all entities that touch a sphere
|
||||
|
@ -147,17 +146,17 @@ public:
|
|||
return _fbxService ? _fbxService->getModelForEntityItem(entityItem) : NULL;
|
||||
}
|
||||
|
||||
EntityTreeElement* getContainingElement(const QUuid& entityItemID) /*const*/;
|
||||
void setContainingElement(const QUuid& entityItemID, EntityTreeElement* element);
|
||||
EntityTreeElement* getContainingElement(const EntityItemID& entityItemID) /*const*/;
|
||||
void setContainingElement(const EntityItemID& entityItemID, EntityTreeElement* element);
|
||||
void debugDumpMap();
|
||||
virtual void dumpTree();
|
||||
virtual void pruneTree();
|
||||
|
||||
QVector<QUuid> sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z);
|
||||
QVector<EntityItemID> sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z);
|
||||
|
||||
void entityChanged(EntityItem* entity);
|
||||
|
||||
void emitEntityScriptChanging(const QUuid& entityItemID);
|
||||
void emitEntityScriptChanging(const EntityItemID& entityItemID);
|
||||
|
||||
void setSimulation(EntitySimulation* simulation);
|
||||
|
||||
|
@ -170,10 +169,10 @@ public:
|
|||
float getContentsLargestDimension();
|
||||
|
||||
signals:
|
||||
void deletingEntity(const QUuid& entityID);
|
||||
void addingEntity(const QUuid& entityID);
|
||||
void entityScriptChanging(const QUuid& entityItemID);
|
||||
void changingEntityID(const QUuid& oldEntityID, const QUuid& newEntityID);
|
||||
void deletingEntity(const EntityItemID& entityID);
|
||||
void addingEntity(const EntityItemID& entityID);
|
||||
void entityScriptChanging(const EntityItemID& entityItemID);
|
||||
void changingEntityID(const EntityItemID& oldEntityID, const EntityItemID& newEntityID);
|
||||
void clearingEntities();
|
||||
|
||||
private:
|
||||
|
@ -197,7 +196,7 @@ private:
|
|||
QMultiMap<quint64, QUuid> _recentlyDeletedEntityItemIDs;
|
||||
EntityItemFBXService* _fbxService;
|
||||
|
||||
QHash<QUuid, EntityTreeElement*> _entityToElementMap;
|
||||
QHash<EntityItemID, EntityTreeElement*> _entityToElementMap;
|
||||
|
||||
EntitySimulation* _simulation;
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ void EntityTreeElement::initializeExtraEncodeData(EncodeBitstreamParams& params)
|
|||
}
|
||||
for (uint16_t i = 0; i < _entityItems->size(); i++) {
|
||||
EntityItem* entity = (*_entityItems)[i];
|
||||
entityTreeElementExtraEncodeData->entities.insert(entity->getID(), entity->getEntityProperties(params));
|
||||
entityTreeElementExtraEncodeData->entities.insert(entity->getEntityItemID(), entity->getEntityProperties(params));
|
||||
}
|
||||
|
||||
// TODO: some of these inserts might be redundant!!!
|
||||
|
@ -258,14 +258,13 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
|||
if (child->hasEntities()) {
|
||||
entityTreeElementExtraEncodeData->childCompleted[i] = false;
|
||||
} else {
|
||||
// if the child doesn't have enities, it is completed
|
||||
entityTreeElementExtraEncodeData->childCompleted[i] = true;
|
||||
entityTreeElementExtraEncodeData->childCompleted[i] = true; // if the child doesn't have enities, it is completed
|
||||
}
|
||||
}
|
||||
}
|
||||
for (uint16_t i = 0; i < _entityItems->size(); i++) {
|
||||
EntityItem* entity = (*_entityItems)[i];
|
||||
entityTreeElementExtraEncodeData->entities.insert(entity->getID(), entity->getEntityProperties(params));
|
||||
entityTreeElementExtraEncodeData->entities.insert(entity->getEntityItemID(), entity->getEntityProperties(params));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,7 +293,7 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
|||
|
||||
if (hadElementExtraData) {
|
||||
includeThisEntity = includeThisEntity &&
|
||||
entityTreeElementExtraEncodeData->entities.contains(entity->getID());
|
||||
entityTreeElementExtraEncodeData->entities.contains(entity->getEntityItemID());
|
||||
}
|
||||
|
||||
if (includeThisEntity && params.viewFrustum) {
|
||||
|
@ -339,7 +338,7 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
|||
|
||||
// If the entity item got completely appended, then we can remove it from the extra encode data
|
||||
if (appendEntityState == OctreeElement::COMPLETED) {
|
||||
entityTreeElementExtraEncodeData->entities.remove(entity->getID());
|
||||
entityTreeElementExtraEncodeData->entities.remove(entity->getEntityItemID());
|
||||
}
|
||||
|
||||
// If any part of the entity items didn't fit, then the element is considered partial
|
||||
|
@ -612,11 +611,11 @@ void EntityTreeElement::getEntities(const AACube& box, QVector<EntityItem*>& fou
|
|||
}
|
||||
}
|
||||
|
||||
const EntityItem* EntityTreeElement::getEntityWithEntityItemID(const QUuid& id) const {
|
||||
const EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id) const {
|
||||
const EntityItem* foundEntity = NULL;
|
||||
uint16_t numberOfEntities = _entityItems->size();
|
||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||
if ((*_entityItems)[i]->getID() == id) {
|
||||
if ((*_entityItems)[i]->getEntityItemID() == id) {
|
||||
foundEntity = (*_entityItems)[i];
|
||||
break;
|
||||
}
|
||||
|
@ -624,11 +623,11 @@ const EntityItem* EntityTreeElement::getEntityWithEntityItemID(const QUuid& id)
|
|||
return foundEntity;
|
||||
}
|
||||
|
||||
EntityItem* EntityTreeElement::getEntityWithEntityItemID(const QUuid& id) {
|
||||
EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id) {
|
||||
EntityItem* foundEntity = NULL;
|
||||
uint16_t numberOfEntities = _entityItems->size();
|
||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||
if ((*_entityItems)[i]->getID() == id) {
|
||||
if ((*_entityItems)[i]->getEntityItemID() == id) {
|
||||
foundEntity = (*_entityItems)[i];
|
||||
break;
|
||||
}
|
||||
|
@ -646,11 +645,11 @@ void EntityTreeElement::cleanupEntities() {
|
|||
_entityItems->clear();
|
||||
}
|
||||
|
||||
bool EntityTreeElement::removeEntityWithEntityItemID(const QUuid& id) {
|
||||
bool EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) {
|
||||
bool foundEntity = false;
|
||||
uint16_t numberOfEntities = _entityItems->size();
|
||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||
if ((*_entityItems)[i]->getID() == id) {
|
||||
if ((*_entityItems)[i]->getEntityItemID() == id) {
|
||||
foundEntity = true;
|
||||
(*_entityItems)[i]->_element = NULL;
|
||||
_entityItems->removeAt(i);
|
||||
|
@ -706,12 +705,16 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
|||
if (bytesLeftToRead >= (int)(numberOfEntities * expectedBytesPerEntity)) {
|
||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||
int bytesForThisEntity = 0;
|
||||
QUuid entityItemID;
|
||||
EntityItemID entityItemID;
|
||||
EntityItem* entityItem = NULL;
|
||||
|
||||
QByteArray encodedID((const char*)dataAt, NUM_BYTES_RFC4122_UUID);
|
||||
entityItemID = QUuid::fromRfc4122(encodedID);
|
||||
entityItem = _myTree->findEntityByEntityItemID(entityItemID);
|
||||
// Old model files don't have UUIDs in them. So we don't want to try to read those IDs from the stream.
|
||||
// Since this can only happen on loading an old file, we can safely treat these as new entity cases,
|
||||
// which will correctly handle the case of creating models and letting them parse the old format.
|
||||
if (args.bitstreamVersion >= VERSION_ENTITIES_SUPPORT_SPLIT_MTU) {
|
||||
entityItemID = EntityItemID::readEntityItemIDFromBuffer(dataAt, bytesLeftToRead);
|
||||
entityItem = _myTree->findEntityByEntityItemID(entityItemID);
|
||||
}
|
||||
|
||||
// If the item already exists in our tree, we want do the following...
|
||||
// 1) allow the existing item to read from the databuffer
|
||||
|
@ -752,7 +755,7 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
|||
if (entityItem) {
|
||||
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
||||
addEntityItem(entityItem); // add this new entity to this elements entities
|
||||
entityItemID = entityItem->getID();
|
||||
entityItemID = entityItem->getEntityItemID();
|
||||
_myTree->setContainingElement(entityItemID, this);
|
||||
_myTree->postAddEntity(entityItem);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
bool elementCompleted;
|
||||
bool subtreeCompleted;
|
||||
bool childCompleted[NUMBER_OF_CHILDREN];
|
||||
QMap<QUuid, EntityPropertyFlags> entities;
|
||||
QMap<EntityItemID, EntityPropertyFlags> entities;
|
||||
};
|
||||
|
||||
inline QDebug operator<<(QDebug debug, const EntityTreeElementExtraEncodeData* data) {
|
||||
|
@ -165,13 +165,13 @@ public:
|
|||
void getEntities(const AACube& box, QVector<EntityItem*>& foundEntities);
|
||||
|
||||
const EntityItem* getEntityWithID(uint32_t id) const;
|
||||
const EntityItem* getEntityWithEntityItemID(const QUuid& id) const;
|
||||
const EntityItem* getEntityWithEntityItemID(const EntityItemID& id) const;
|
||||
void getEntitiesInside(const AACube& box, QVector<EntityItem*>& foundEntities);
|
||||
|
||||
EntityItem* getEntityWithEntityItemID(const QUuid& id);
|
||||
EntityItem* getEntityWithEntityItemID(const EntityItemID& id);
|
||||
|
||||
void cleanupEntities(); /// called by EntityTree on cleanup this will free all entities
|
||||
bool removeEntityWithEntityItemID(const QUuid& id);
|
||||
bool removeEntityWithEntityItemID(const EntityItemID& id);
|
||||
bool removeEntityItem(EntityItem* entity);
|
||||
|
||||
bool containsEntityBounds(const EntityItem* entity) const;
|
||||
|
|
|
@ -76,8 +76,8 @@ bool EntityTypes::registerEntityType(EntityType entityType, const char* name, En
|
|||
return false;
|
||||
}
|
||||
|
||||
EntityItem* EntityTypes::constructEntityItem(EntityType entityType, const QUuid& entityID,
|
||||
const EntityItemProperties& properties) {
|
||||
EntityItem* EntityTypes::constructEntityItem(EntityType entityType, const EntityItemID& entityID,
|
||||
const EntityItemProperties& properties) {
|
||||
EntityItem* newEntityItem = NULL;
|
||||
EntityTypeFactory factory = NULL;
|
||||
if (entityType >= 0 && entityType <= LAST) {
|
||||
|
@ -91,7 +91,15 @@ EntityItem* EntityTypes::constructEntityItem(EntityType entityType, const QUuid&
|
|||
return newEntityItem;
|
||||
}
|
||||
|
||||
EntityItem* EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead, ReadBitstreamToTreeParams& args) {
|
||||
EntityItem* EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead,
|
||||
ReadBitstreamToTreeParams& args) {
|
||||
|
||||
if (args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU) {
|
||||
EntityItemID tempEntityID;
|
||||
EntityItemProperties tempProperties;
|
||||
return constructEntityItem(Model, tempEntityID, tempProperties);
|
||||
}
|
||||
|
||||
// Header bytes
|
||||
// object ID [16 bytes]
|
||||
// ByteCountCoded(type code) [~1 byte]
|
||||
|
@ -119,8 +127,9 @@ EntityItem* EntityTypes::constructEntityItem(const unsigned char* data, int byte
|
|||
quint32 type = typeCoder;
|
||||
EntityTypes::EntityType entityType = (EntityTypes::EntityType)type;
|
||||
|
||||
EntityItemID tempEntityID(actualID);
|
||||
EntityItemProperties tempProperties;
|
||||
return constructEntityItem(entityType, actualID, tempProperties);
|
||||
return constructEntityItem(entityType, tempEntityID, tempProperties);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -14,17 +14,17 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <QUuid>
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
|
||||
#include <OctreeRenderer.h> // for RenderArgs
|
||||
|
||||
class EntityItem;
|
||||
class EntityItemID;
|
||||
class EntityItemProperties;
|
||||
class ReadBitstreamToTreeParams;
|
||||
|
||||
typedef EntityItem* (*EntityTypeFactory)(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
typedef EntityItem* (*EntityTypeFactory)(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
class EntityTypes {
|
||||
public:
|
||||
|
@ -45,8 +45,7 @@ public:
|
|||
static const QString& getEntityTypeName(EntityType entityType);
|
||||
static EntityTypes::EntityType getEntityTypeFromName(const QString& name);
|
||||
static bool registerEntityType(EntityType entityType, const char* name, EntityTypeFactory factoryMethod);
|
||||
static EntityItem* constructEntityItem(EntityType entityType,
|
||||
const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* constructEntityItem(EntityType entityType, const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* constructEntityItem(const unsigned char* data, int bytesToRead, ReadBitstreamToTreeParams& args);
|
||||
|
||||
private:
|
||||
|
@ -60,7 +59,7 @@ private:
|
|||
/// Macro for registering entity types. Make sure to add an element to the EntityType enum with your name, and your class should be
|
||||
/// named NameEntityItem and must of a static method called factory that takes an EnityItemID, and EntityItemProperties and return a newly
|
||||
/// constructed (heap allocated) instance of your type. e.g. The following prototype:
|
||||
// static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
// static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
#define REGISTER_ENTITY_TYPE(x) static bool x##Registration = \
|
||||
EntityTypes::registerEntityType(EntityTypes::x, #x, x##EntityItem::factory);
|
||||
|
||||
|
@ -68,7 +67,7 @@ private:
|
|||
/// an element to the EntityType enum with your name. But unlike REGISTER_ENTITY_TYPE, your class can be named anything
|
||||
/// so long as you provide a static method passed to the macro, that takes an EnityItemID, and EntityItemProperties and
|
||||
/// returns a newly constructed (heap allocated) instance of your type. e.g. The following prototype:
|
||||
// static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
// static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
#define REGISTER_ENTITY_TYPE_WITH_FACTORY(x,y) static bool x##Registration = \
|
||||
EntityTypes::registerEntityType(EntityTypes::x, #x, y); \
|
||||
if (!x##Registration) { \
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <ByteCountCoding.h>
|
||||
|
||||
#include "EntityItemID.h"
|
||||
#include "EntityTree.h"
|
||||
#include "EntityTreeElement.h"
|
||||
#include "EntitiesLogging.h"
|
||||
|
@ -21,12 +22,12 @@
|
|||
|
||||
bool LightEntityItem::_lightsArePickable = false;
|
||||
|
||||
EntityItem* LightEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* LightEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new LightEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
// our non-pure virtual subclass for now...
|
||||
LightEntityItem::LightEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
LightEntityItem::LightEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
EntityItem(entityItemID, properties)
|
||||
{
|
||||
_type = EntityTypes::Light;
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
class LightEntityItem : public EntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
LightEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
LightEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
|
||||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
#include "EntityTreeElement.h"
|
||||
|
||||
|
||||
EntityItem* LineEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* LineEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* result = new LineEntityItem(entityID, properties);
|
||||
return result;
|
||||
}
|
||||
|
||||
LineEntityItem::LineEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
LineEntityItem::LineEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
EntityItem(entityItemID)
|
||||
{
|
||||
_type = EntityTypes::Line;
|
||||
|
@ -99,7 +99,7 @@ void LineEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
|
|||
|
||||
void LineEntityItem::debugDump() const {
|
||||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << " LINE EntityItem id:" << getID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " LINE EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
class LineEntityItem : public EntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
LineEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
LineEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
|
||||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ const bool ModelEntityItem::DEFAULT_ANIMATION_IS_PLAYING = false;
|
|||
const float ModelEntityItem::DEFAULT_ANIMATION_FPS = 30.0f;
|
||||
|
||||
|
||||
EntityItem* ModelEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* ModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new ModelEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
ModelEntityItem::ModelEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
ModelEntityItem::ModelEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
EntityItem(entityItemID, properties)
|
||||
{
|
||||
_type = EntityTypes::Model;
|
||||
|
@ -267,7 +267,7 @@ void ModelEntityItem::update(const quint64& now) {
|
|||
}
|
||||
|
||||
void ModelEntityItem::debugDump() const {
|
||||
qCDebug(entities) << "ModelEntityItem id:" << getID();
|
||||
qCDebug(entities) << "ModelEntityItem id:" << getEntityItemID();
|
||||
qCDebug(entities) << " edited ago:" << getEditedAgo();
|
||||
qCDebug(entities) << " position:" << getPosition();
|
||||
qCDebug(entities) << " dimensions:" << getDimensions();
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
class ModelEntityItem : public EntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
ModelEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
ModelEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
|
||||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
|
|
|
@ -25,11 +25,11 @@ public:
|
|||
};
|
||||
|
||||
inline uint qHash(const EntityToMoveDetails& a, uint seed) {
|
||||
return qHash(a.entity->getID(), seed);
|
||||
return qHash(a.entity, seed);
|
||||
}
|
||||
|
||||
inline bool operator==(const EntityToMoveDetails& a, const EntityToMoveDetails& b) {
|
||||
return a.entity->getID() == b.entity->getID();
|
||||
return a.entity == b.entity;
|
||||
}
|
||||
|
||||
class MovingEntitiesOperator : public RecurseOctreeOperator {
|
||||
|
|
|
@ -55,12 +55,12 @@ const float ParticleEffectEntityItem::DEFAULT_PARTICLE_RADIUS = 0.025f;
|
|||
const QString ParticleEffectEntityItem::DEFAULT_TEXTURES = "";
|
||||
|
||||
|
||||
EntityItem* ParticleEffectEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new ParticleEffectEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
// our non-pure virtual subclass for now...
|
||||
ParticleEffectEntityItem::ParticleEffectEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
ParticleEffectEntityItem::ParticleEffectEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
EntityItem(entityItemID, properties),
|
||||
_maxParticles(DEFAULT_MAX_PARTICLES),
|
||||
_lifespan(DEFAULT_LIFESPAN),
|
||||
|
@ -274,7 +274,7 @@ void ParticleEffectEntityItem::update(const quint64& now) {
|
|||
|
||||
void ParticleEffectEntityItem::debugDump() const {
|
||||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << "PA EFFECT EntityItem id:" << getID() << "---------------------------------------------";
|
||||
qCDebug(entities) << "PA EFFECT EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
class ParticleEffectEntityItem : public EntityItem {
|
||||
public:
|
||||
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
ParticleEffectEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
ParticleEffectEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
virtual ~ParticleEffectEntityItem();
|
||||
|
||||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
#include "SphereEntityItem.h"
|
||||
|
||||
|
||||
EntityItem* SphereEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* SphereEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
return new SphereEntityItem(entityID, properties);
|
||||
}
|
||||
|
||||
// our non-pure virtual subclass for now...
|
||||
SphereEntityItem::SphereEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
SphereEntityItem::SphereEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
EntityItem(entityItemID, properties)
|
||||
{
|
||||
_type = EntityTypes::Sphere;
|
||||
|
@ -117,7 +117,7 @@ bool SphereEntityItem::findDetailedRayIntersection(const glm::vec3& origin, cons
|
|||
|
||||
void SphereEntityItem::debugDump() const {
|
||||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << "SHPERE EntityItem id:" << getID() << "---------------------------------------------";
|
||||
qCDebug(entities) << "SHPERE EntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " color:" << _color[0] << "," << _color[1] << "," << _color[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
class SphereEntityItem : public EntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
SphereEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
SphereEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
|
||||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ const float TextEntityItem::DEFAULT_LINE_HEIGHT = 0.1f;
|
|||
const xColor TextEntityItem::DEFAULT_TEXT_COLOR = { 255, 255, 255 };
|
||||
const xColor TextEntityItem::DEFAULT_BACKGROUND_COLOR = { 0, 0, 0};
|
||||
|
||||
EntityItem* TextEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* TextEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* result = new TextEntityItem(entityID, properties);
|
||||
return result;
|
||||
}
|
||||
|
||||
TextEntityItem::TextEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
TextEntityItem::TextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
EntityItem(entityItemID)
|
||||
{
|
||||
_type = EntityTypes::Text;
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
class TextEntityItem : public EntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
TextEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
TextEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
|
||||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ UpdateEntityOperator::UpdateEntityOperator(EntityTree* tree,
|
|||
_containingElement(containingElement),
|
||||
_containingElementCube(containingElement->getAACube()),
|
||||
_properties(properties),
|
||||
_entityItemID(existingEntity->getID()),
|
||||
_entityItemID(existingEntity->getEntityItemID()),
|
||||
_foundOld(false),
|
||||
_foundNew(false),
|
||||
_removeOld(false),
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
class UpdateEntityOperator : public RecurseOctreeOperator {
|
||||
public:
|
||||
UpdateEntityOperator(EntityTree* tree, EntityTreeElement* containingElement,
|
||||
EntityItem* existingEntity, const EntityItemProperties& properties);
|
||||
EntityItem* existingEntity, const EntityItemProperties& properties);
|
||||
~UpdateEntityOperator();
|
||||
|
||||
virtual bool preRecursion(OctreeElement* element);
|
||||
|
@ -27,7 +27,7 @@ private:
|
|||
EntityTreeElement* _containingElement;
|
||||
AACube _containingElementCube; // we temporarily store our cube here in case we need to delete the containing element
|
||||
EntityItemProperties _properties;
|
||||
QUuid _entityItemID;
|
||||
EntityItemID _entityItemID;
|
||||
bool _foundOld;
|
||||
bool _foundNew;
|
||||
bool _removeOld;
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
|
||||
const QString WebEntityItem::DEFAULT_SOURCE_URL("http://www.google.com");
|
||||
|
||||
EntityItem* WebEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* result = new WebEntityItem(entityID, properties);
|
||||
return result;
|
||||
}
|
||||
|
||||
WebEntityItem::WebEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
WebEntityItem::WebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
EntityItem(entityItemID)
|
||||
{
|
||||
_type = EntityTypes::Web;
|
||||
|
@ -150,4 +150,4 @@ void WebEntityItem::setSourceUrl(const QString& value) {
|
|||
}
|
||||
}
|
||||
|
||||
const QString& WebEntityItem::getSourceUrl() const { return _sourceUrl; }
|
||||
const QString& WebEntityItem::getSourceUrl() const { return _sourceUrl; }
|
|
@ -15,9 +15,9 @@ class WebEntityItem : public EntityItem {
|
|||
public:
|
||||
static const QString DEFAULT_SOURCE_URL;
|
||||
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
WebEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
WebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
|
||||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
|
|
|
@ -29,12 +29,12 @@ const glm::vec3 ZoneEntityItem::DEFAULT_KEYLIGHT_DIRECTION = { 0.0f, -1.0f, 0.0f
|
|||
const ShapeType ZoneEntityItem::DEFAULT_SHAPE_TYPE = SHAPE_TYPE_BOX;
|
||||
const QString ZoneEntityItem::DEFAULT_COMPOUND_SHAPE_URL = "";
|
||||
|
||||
EntityItem* ZoneEntityItem::factory(const QUuid& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* ZoneEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
EntityItem* result = new ZoneEntityItem(entityID, properties);
|
||||
return result;
|
||||
}
|
||||
|
||||
ZoneEntityItem::ZoneEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties) :
|
||||
ZoneEntityItem::ZoneEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) :
|
||||
EntityItem(entityItemID)
|
||||
{
|
||||
_type = EntityTypes::Zone;
|
||||
|
@ -216,9 +216,8 @@ void ZoneEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
|
|||
|
||||
void ZoneEntityItem::debugDump() const {
|
||||
quint64 now = usecTimestampNow();
|
||||
qCDebug(entities) << " ZoneEntityItem id:" << getID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " keyLightColor:" << _keyLightColor[0] << ","
|
||||
<< _keyLightColor[1] << "," << _keyLightColor[2];
|
||||
qCDebug(entities) << " ZoneEntityItem id:" << getEntityItemID() << "---------------------------------------------";
|
||||
qCDebug(entities) << " keyLightColor:" << _keyLightColor[0] << "," << _keyLightColor[1] << "," << _keyLightColor[2];
|
||||
qCDebug(entities) << " position:" << debugTreeVector(_position);
|
||||
qCDebug(entities) << " dimensions:" << debugTreeVector(_dimensions);
|
||||
qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now);
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
class ZoneEntityItem : public EntityItem {
|
||||
public:
|
||||
static EntityItem* factory(const QUuid& entityID, const EntityItemProperties& properties);
|
||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
ZoneEntityItem(const QUuid& entityItemID, const EntityItemProperties& properties);
|
||||
ZoneEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
|
||||
ALLOW_INSTANTIATION // This class can be instantiated
|
||||
|
||||
|
|
|
@ -427,7 +427,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q
|
|||
}
|
||||
|
||||
if (EntityItem::getSendPhysicsUpdates()) {
|
||||
QUuid id(_entity->getID());
|
||||
EntityItemID id(_entity->getID());
|
||||
EntityEditPacketSender* entityPacketSender = static_cast<EntityEditPacketSender*>(packetSender);
|
||||
#ifdef WANT_DEBUG
|
||||
qCDebug(physics) << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()...";
|
||||
|
|
|
@ -40,7 +40,8 @@ void EntityTests::entityTreeTests(bool verbose) {
|
|||
|
||||
// Tree, id, and entity properties used in many tests below...
|
||||
EntityTree tree;
|
||||
QUuid entityID = QUuid::createUuid();
|
||||
QUuid id = QUuid::createUuid();
|
||||
EntityItemID entityID(id);
|
||||
EntityItemProperties properties;
|
||||
float oneMeter = 1.0f;
|
||||
float halfOfDomain = TREE_SCALE * 0.5f;
|
||||
|
@ -247,7 +248,8 @@ void EntityTests::entityTreeTests(bool verbose) {
|
|||
quint64 totalElapsedAdd = 0;
|
||||
quint64 totalElapsedFind = 0;
|
||||
for (int i = 0; i < TEST_ITERATIONS; i++) {
|
||||
QUuid entityID = QUuid::createUuid();// make sure it doesn't collide with previous entity ids
|
||||
QUuid id = QUuid::createUuid();// make sure it doesn't collide with previous entity ids
|
||||
EntityItemID entityID(id);
|
||||
|
||||
float randomX = randFloatInRange(1.0f ,(float)TREE_SCALE - 1.0f);
|
||||
float randomY = randFloatInRange(1.0f ,(float)TREE_SCALE - 1.0f);
|
||||
|
@ -349,7 +351,8 @@ void EntityTests::entityTreeTests(bool verbose) {
|
|||
quint64 totalElapsedDelete = 0;
|
||||
quint64 totalElapsedFind = 0;
|
||||
for (int i = 0; i < TEST_ITERATIONS; i++) {
|
||||
QUuid entityID = QUuid::createUuid();// make sure it doesn't collide with previous entity ids
|
||||
QUuid id = QUuid::createUuid();// make sure it doesn't collide with previous entity ids
|
||||
EntityItemID entityID(id);
|
||||
|
||||
if (extraVerbose) {
|
||||
qDebug() << "before:" << i << "getOctreeElementsCount()=" << tree.getOctreeElementsCount();
|
||||
|
@ -428,9 +431,11 @@ void EntityTests::entityTreeTests(bool verbose) {
|
|||
quint64 totalElapsedFind = 0;
|
||||
for (int i = 0; i < TEST_ITERATIONS; i++) {
|
||||
|
||||
QSet<QUuid> entitiesToDelete;
|
||||
QSet<EntityItemID> entitiesToDelete;
|
||||
for (int j = 0; j < ENTITIES_PER_ITERATION; j++) {
|
||||
//uint32_t id = 2 + (i * ENTITIES_PER_ITERATION) + j; // These are the entities we added above
|
||||
QUuid id = QUuid::createUuid();// make sure it doesn't collide with previous entity ids
|
||||
EntityItemID entityID(id);
|
||||
entitiesToDelete << entityID;
|
||||
}
|
||||
|
||||
|
@ -450,7 +455,8 @@ void EntityTests::entityTreeTests(bool verbose) {
|
|||
quint64 startFind = usecTimestampNow();
|
||||
for (int j = 0; j < ENTITIES_PER_ITERATION; j++) {
|
||||
//uint32_t id = 2 + (i * ENTITIES_PER_ITERATION) + j; // These are the entities we added above
|
||||
QUuid entityID = QUuid::createUuid();// make sure it doesn't collide with previous entity ids
|
||||
QUuid id = QUuid::createUuid();// make sure it doesn't collide with previous entity ids
|
||||
EntityItemID entityID(id);
|
||||
const EntityItem* foundEntityByID = tree.findEntityByEntityItemID(entityID);
|
||||
EntityTreeElement* containingElement = tree.getContainingElement(entityID);
|
||||
|
||||
|
|
Loading…
Reference in a new issue