final pass on entities import/export/overlays working as well as production

This commit is contained in:
ZappoMan 2014-08-27 11:34:50 -07:00
parent fb25314248
commit 30e00bbd69
11 changed files with 31 additions and 87 deletions

View file

@ -1631,19 +1631,15 @@ void Application::importVoxels() {
} }
bool Application::importEntities(const QString& filename) { bool Application::importEntities(const QString& filename) {
qDebug() << "Application::importEntities()...";
_entityClipboard.eraseAllOctreeElements(); _entityClipboard.eraseAllOctreeElements();
bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData()); bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData());
qDebug() << " success=" << success;
if (success) { if (success) {
_entityClipboard.dumpTree();
_entityClipboard.reaverageOctreeElements(); _entityClipboard.reaverageOctreeElements();
} }
return success; return success;
} }
void Application::pasteEntities(float x, float y, float z) { void Application::pasteEntities(float x, float y, float z) {
qDebug() << "Application::pasteEntities(" << x << ", " << y << ", " << z << ")";
_entityClipboard.sendEntities(&_entityEditSender, _entities.getTree(), x, y, z); _entityClipboard.sendEntities(&_entityEditSender, _entities.getTree(), x, y, z);
} }

View file

@ -186,7 +186,6 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
for (uint16_t i = 0; i < numberOfEntities; i++) { for (uint16_t i = 0; i < numberOfEntities; i++) {
EntityItem* entityItem = entityItems[i]; EntityItem* entityItem = entityItems[i];
bool wantDebug = false; bool wantDebug = false;
if (wantDebug) { if (wantDebug) {
@ -205,7 +204,6 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
// TODO: some entity types (like lights) might want to be rendered even // TODO: some entity types (like lights) might want to be rendered even
// when they are outside of the view frustum... // when they are outside of the view frustum...
if (args->_viewFrustum->cubeInFrustum(entityCube) != ViewFrustum::OUTSIDE) { if (args->_viewFrustum->cubeInFrustum(entityCube) != ViewFrustum::OUTSIDE) {
Glower* glower = NULL; Glower* glower = NULL;
if (entityItem->getGlowLevel() > 0.0f) { if (entityItem->getGlowLevel() > 0.0f) {
glower = new Glower(entityItem->getGlowLevel()); glower = new Glower(entityItem->getGlowLevel());

View file

@ -31,9 +31,7 @@ void LocalModelsOverlay::render() {
Application* app = Application::getInstance(); Application* app = Application::getInstance();
glm::vec3 oldTranslation = app->getViewMatrixTranslation(); glm::vec3 oldTranslation = app->getViewMatrixTranslation();
app->setViewMatrixTranslation(oldTranslation + _position); app->setViewMatrixTranslation(oldTranslation + _position);
_entityTreeRenderer->render(); _entityTreeRenderer->render();
Application::getInstance()->setViewMatrixTranslation(oldTranslation); Application::getInstance()->setViewMatrixTranslation(oldTranslation);
} glPopMatrix(); } glPopMatrix();
} }

View file

@ -36,7 +36,6 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemI
int sizeOut = 0; int sizeOut = 0;
if (EntityItemProperties::encodeEntityEditPacket(type, modelID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) { if (EntityItemProperties::encodeEntityEditPacket(type, modelID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) {
qDebug() << "EntityItemProperties::encodeEntityEditPacket() returned TRUE.... calling queueOctreeEditMessage()....";
queueOctreeEditMessage(type, bufferOut, sizeOut); queueOctreeEditMessage(type, bufferOut, sizeOut);
} }
} }

View file

@ -431,9 +431,6 @@ void EntityItemPropertiesFromScriptValue(const QScriptValue &object, EntityItemP
bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties, bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties,
unsigned char* bufferOut, int sizeIn, int& sizeOut) { unsigned char* bufferOut, int sizeIn, int& sizeOut) {
qDebug() << "EntityItemProperties::encodeEntityEditPacket()....";
OctreePacketData packetData(false, sizeIn); // create a packetData object to add out packet details too. OctreePacketData packetData(false, sizeIn); // create a packetData object to add out packet details too.
bool success = true; // assume the best bool success = true; // assume the best
@ -524,9 +521,6 @@ qDebug() << "EntityItemProperties::encodeEntityEditPacket()....";
if (headerFits) { if (headerFits) {
bool successPropertyFits; bool successPropertyFits;
qDebug() << " HEADER FITS.....";
propertyFlags -= PROP_LAST_ITEM; // clear the last item for now, we may or may not set it as the actual item propertyFlags -= PROP_LAST_ITEM; // clear the last item for now, we may or may not set it as the actual item
// These items would go here once supported.... // These items would go here once supported....
@ -539,9 +533,6 @@ qDebug() << " HEADER FITS.....";
LevelDetails propertyLevel = packetData.startLevel(); LevelDetails propertyLevel = packetData.startLevel();
successPropertyFits = packetData.appendPosition(properties.getPosition()); successPropertyFits = packetData.appendPosition(properties.getPosition());
if (successPropertyFits) { if (successPropertyFits) {
qDebug() << " PROP_POSITION FITS.....";
propertyFlags |= PROP_POSITION; propertyFlags |= PROP_POSITION;
propertiesDidntFit -= PROP_POSITION; propertiesDidntFit -= PROP_POSITION;
propertyCount++; propertyCount++;
@ -700,9 +691,6 @@ qDebug() << " PROP_POSITION FITS.....";
LevelDetails propertyLevel = packetData.startLevel(); LevelDetails propertyLevel = packetData.startLevel();
successPropertyFits = packetData.appendValue(properties.getModelURL()); successPropertyFits = packetData.appendValue(properties.getModelURL());
if (successPropertyFits) { if (successPropertyFits) {
qDebug() << " PROP_MODEL_URL FITS.....";
propertyFlags |= PROP_MODEL_URL; propertyFlags |= PROP_MODEL_URL;
propertiesDidntFit -= PROP_MODEL_URL; propertiesDidntFit -= PROP_MODEL_URL;
propertyCount++; propertyCount++;

View file

@ -117,7 +117,6 @@ public:
void setType(EntityTypes::EntityType type) { _type = type; } void setType(EntityTypes::EntityType type) { _type = type; }
/// set position in meter units /// set position in meter units
void setPosition(const glm::vec3& value) { _position = value; _positionChanged = true; } void setPosition(const glm::vec3& value) { _position = value; _positionChanged = true; }
void resetPosition(const glm::vec3& value) { _position = value; } /// changes the position without marking it as changed
void setRadius(float value) { _radius = value; _radiusChanged = true; } void setRadius(float value) { _radius = value; _radiusChanged = true; }
void setRotation(const glm::quat& rotation) { _rotation = rotation; _rotationChanged = true; } void setRotation(const glm::quat& rotation) { _rotation = rotation; _rotationChanged = true; }

View file

@ -1049,7 +1049,6 @@ void EntityTree::dumpTree() {
} }
void EntityTree::sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z) { void EntityTree::sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z) {
qDebug() << "EntityTree::sendEntities(" << x << ", " << y << ", " << z << ")";
SendEntitiesOperationArgs args; SendEntitiesOperationArgs args;
args.packetSender = packetSender; args.packetSender = packetSender;
args.localTree = localTree; args.localTree = localTree;
@ -1062,51 +1061,23 @@ bool EntityTree::sendEntitiesOperation(OctreeElement* element, void* extraData)
SendEntitiesOperationArgs* args = static_cast<SendEntitiesOperationArgs*>(extraData); SendEntitiesOperationArgs* args = static_cast<SendEntitiesOperationArgs*>(extraData);
EntityTreeElement* entityTreeElement = static_cast<EntityTreeElement*>(element); EntityTreeElement* entityTreeElement = static_cast<EntityTreeElement*>(element);
qDebug() << "EntityTree::sendEntitiesOperation()";
qDebug() << " element box:" << entityTreeElement->getAACube();
const QList<EntityItem*>& entities = entityTreeElement->getEntities(); const QList<EntityItem*>& entities = entityTreeElement->getEntities();
for (int i = 0; i < entities.size(); i++) { for (int i = 0; i < entities.size(); i++) {
qDebug() << " entity[" << i <<"].id" << entities[i]->getEntityItemID();
EntityItemID newID(NEW_ENTITY, EntityItemID::getNextCreatorTokenID(), false); EntityItemID newID(NEW_ENTITY, EntityItemID::getNextCreatorTokenID(), false);
qDebug() << " entity[" << i <<"].newID" << newID;
EntityItemProperties properties = entities[i]->getProperties(); EntityItemProperties properties = entities[i]->getProperties();
qDebug() << " entity[" << i <<"].properties..."; properties.setPosition(properties.getPosition() + args->root);
properties.debugDump(); properties.markAllChanged(); // so the entire property set is considered new, since we're making a new entity
properties.resetPosition(properties.getPosition() + args->root); // queue the packet to send to the server
qDebug() << " after resetPosition()....";
properties.debugDump();
properties.markAllChanged();
// queue the packet
qDebug() << " calling queueEditEntityMessage....";
args->packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, newID, properties); args->packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, newID, properties);
// It would be nice to also update the local tree... // also update the local tree instantly (note: this is not our tree, but an alternate tree)
//if (_entityTree) { if (args->localTree) {
// _entityTree->lockForWrite(); args->localTree->lockForWrite();
// _entityTree->addEntity(id, properties); args->localTree->addEntity(newID, properties);
// _entityTree->unlock(); args->localTree->unlock();
//}
} }
/** --- OLD WAY ---
const QList<ModelItem>& modelList = modelTreeElement->getModels();
for (int i = 0; i < modelList.size(); i++) {
uint32_t creatorTokenID = ModelItem::getNextCreatorTokenID();
ModelItemID id(NEW_MODEL, creatorTokenID, false);
ModelItemProperties properties;
properties.copyFromNewModelItem(modelList.at(i));
properties.setPosition(properties.getPosition() + args->root);
args->packetSender->queueModelEditMessage(PacketTypeModelAddOrEdit, id, properties);
} }
**/
return true; return true;
} }

View file

@ -104,7 +104,7 @@ EntityItem* EntityTypes::constructEntityItem(const unsigned char* data, int byte
EntityItemID tempEntityID; EntityItemID tempEntityID;
EntityItemProperties tempProperties; EntityItemProperties tempProperties;
return new ModelEntityItem(tempEntityID, tempProperties); return constructEntityItem(Model, tempEntityID, tempProperties);
} }
// Header bytes // Header bytes

View file

@ -18,7 +18,6 @@
EntityItem* ModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItem* ModelEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
//qDebug() << "ModelEntityItem::factory(const EntityItemID& entityItemID, const EntityItemProperties& properties)...";
return new ModelEntityItem(entityID, properties); return new ModelEntityItem(entityID, properties);
} }

View file

@ -1,20 +1,17 @@
// REQUIRED: // REQUIRED:
1) Import/Export Models - verify it works. /copy/paste?? 7) Test file save load for case where two siblings have more than MTU amount of data. I wonder if the fact that file save
doesn't include the extra exists bits will break something.
22b) Local Entities Overlay - from Local Models Overlay 14) Make sure LOD logic honors the LOD settings for entities in "spanners/parent" cells.
DONE -- 22d) void ModelTree::findModelsInCube(const AACube& cube, QVector<ModelItem*>& foundModels)... 8) memory leaks???
DONE -- 22e) void ModelTreeElement::getModelsInside(const AACube& box, QVector<ModelItem*>& foundModels)...
DONE -- 22f) Application::exportEntities() tested/works 9) EntityTreeRenderer::clearModelsCache()
DONE -- 22g) Application::pasteEntities() tested/works
DONE -- 22c) void ModelTree::sendModels(ModelEditPacketSender* packetSender, float x, float y, float z)....
bool EntityTree::sendEntitiesOperation(OctreeElement* element, void* extraData) {...
RESOLVED -- 22a) void ModelItemProperties::copyFromNewModelItem(const ModelItem& modelItem); // Do we need this? NO!
3) Don't allow models to be "edited" to be outside of domain. clamp them to the domain. 3) Don't allow models to be "edited" to be outside of domain. clamp them to the domain.
4) if velocity sends a model out of the domain - delete it
4) if velocity sends a model out of the domain - delete it
3) random crashes on moving (I think things going out of bounds???) 3) random crashes on moving (I think things going out of bounds???)
@ -25,19 +22,10 @@
6) clear all entities when changing domains? 6) clear all entities when changing domains?
7) Test file save load for case where two siblings have more than MTU amount of data. I wonder if the fact that file save
doesn't include the extra exists bits will break something.
8) memory leaks???
9) EntityTreeRenderer::clearModelsCache()
11) What happens if the edit properties don't fit in a single message MTU??? 11) What happens if the edit properties don't fit in a single message MTU???
13) EntityItemProperties::decodeEntityEditPacket() doesn't include PROP_SCRIPT 13) EntityItemProperties::decodeEntityEditPacket() doesn't include PROP_SCRIPT
14) Make sure LOD logic honors the LOD settings for entities in "spanners/parent" cells.
15) quickly do some edits... then change domains... watch the entities continue to exist in new domain and move around. 15) quickly do some edits... then change domains... watch the entities continue to exist in new domain and move around.
@ -226,8 +214,18 @@
// SOLVED -- 2) verify shadows work // SOLVED -- 2) verify shadows work
// SOLVED -- 9) Handle the ID -> UUID swap in old files to new files - verify old files read correctly // SOLVED -- 9) Handle the ID -> UUID swap in old files to new files - verify old files read correctly
// SOLVED -- 2) Test models -> attachments logic --- TESTED/WORKS // SOLVED -- 2) Test models -> attachments logic --- TESTED/WORKS
// SOLVED -- 1) Import/Export Models - verify it works. /copy/paste??
// DONE -- 22d) void ModelTree::findModelsInCube(const AACube& cube, QVector<ModelItem*>& foundModels)...
// DONE -- 22e) void ModelTreeElement::getModelsInside(const AACube& box, QVector<ModelItem*>& foundModels)...
// DONE -- 22f) Application::exportEntities() tested/works
// DONE -- 22g) Application::pasteEntities() tested/works
// DONE -- 22c) void ModelTree::sendModels(ModelEditPacketSender* packetSender, float x, float y, float z)....
// bool EntityTree::sendEntitiesOperation(OctreeElement* element, void* extraData) {...
// RESOLVED -- 22a) void ModelItemProperties::copyFromNewModelItem(const ModelItem& modelItem); // Do we need this? NO!
// WORKS AS PRODUCTION -- 22b) Local Entities Overlay - from Local Models Overlay
// Note: there's a bug in production related to the overlay correctly rendering when
// the original (non-translated positions) of the models are out of view. This is a bug
// not introduced byt this PR.

View file

@ -165,9 +165,7 @@ void OctreeRenderer::render(RenderMode renderMode) {
RenderArgs args = { this, _viewFrustum, getSizeScale(), getBoundaryLevelAdjust(), renderMode, 0, 0, 0 }; RenderArgs args = { this, _viewFrustum, getSizeScale(), getBoundaryLevelAdjust(), renderMode, 0, 0, 0 };
if (_tree) { if (_tree) {
_tree->lockForRead(); _tree->lockForRead();
//qDebug() << "OctreeRenderer::render() tree locked START RENDER RECURSION...";
_tree->recurseTreeWithOperation(renderOperation, &args); _tree->recurseTreeWithOperation(renderOperation, &args);
//qDebug() << "OctreeRenderer::render() tree locked ENDED RENDER RECURSION...";
_tree->unlock(); _tree->unlock();
} }
} }