mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 12:33:27 +02:00
final pass on entities import/export/overlays working as well as production
This commit is contained in:
parent
fb25314248
commit
30e00bbd69
11 changed files with 31 additions and 87 deletions
|
@ -1631,19 +1631,15 @@ void Application::importVoxels() {
|
|||
}
|
||||
|
||||
bool Application::importEntities(const QString& filename) {
|
||||
qDebug() << "Application::importEntities()...";
|
||||
_entityClipboard.eraseAllOctreeElements();
|
||||
bool success = _entityClipboard.readFromSVOFile(filename.toLocal8Bit().constData());
|
||||
qDebug() << " success=" << success;
|
||||
if (success) {
|
||||
_entityClipboard.dumpTree();
|
||||
_entityClipboard.reaverageOctreeElements();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void Application::pasteEntities(float x, float y, float z) {
|
||||
qDebug() << "Application::pasteEntities(" << x << ", " << y << ", " << z << ")";
|
||||
_entityClipboard.sendEntities(&_entityEditSender, _entities.getTree(), x, y, z);
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,6 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
|
|||
|
||||
for (uint16_t i = 0; i < numberOfEntities; i++) {
|
||||
EntityItem* entityItem = entityItems[i];
|
||||
|
||||
bool wantDebug = false;
|
||||
|
||||
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
|
||||
// when they are outside of the view frustum...
|
||||
if (args->_viewFrustum->cubeInFrustum(entityCube) != ViewFrustum::OUTSIDE) {
|
||||
|
||||
Glower* glower = NULL;
|
||||
if (entityItem->getGlowLevel() > 0.0f) {
|
||||
glower = new Glower(entityItem->getGlowLevel());
|
||||
|
|
|
@ -31,9 +31,7 @@ void LocalModelsOverlay::render() {
|
|||
Application* app = Application::getInstance();
|
||||
glm::vec3 oldTranslation = app->getViewMatrixTranslation();
|
||||
app->setViewMatrixTranslation(oldTranslation + _position);
|
||||
|
||||
_entityTreeRenderer->render();
|
||||
|
||||
Application::getInstance()->setViewMatrixTranslation(oldTranslation);
|
||||
} glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemI
|
|||
int sizeOut = 0;
|
||||
|
||||
if (EntityItemProperties::encodeEntityEditPacket(type, modelID, properties, &bufferOut[0], _maxPacketSize, sizeOut)) {
|
||||
qDebug() << "EntityItemProperties::encodeEntityEditPacket() returned TRUE.... calling queueOctreeEditMessage()....";
|
||||
queueOctreeEditMessage(type, bufferOut, sizeOut);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -431,9 +431,6 @@ void EntityItemPropertiesFromScriptValue(const QScriptValue &object, EntityItemP
|
|||
bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties,
|
||||
unsigned char* bufferOut, int sizeIn, int& sizeOut) {
|
||||
|
||||
|
||||
qDebug() << "EntityItemProperties::encodeEntityEditPacket()....";
|
||||
|
||||
OctreePacketData packetData(false, sizeIn); // create a packetData object to add out packet details too.
|
||||
|
||||
bool success = true; // assume the best
|
||||
|
@ -524,9 +521,6 @@ qDebug() << "EntityItemProperties::encodeEntityEditPacket()....";
|
|||
|
||||
if (headerFits) {
|
||||
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
|
||||
|
||||
// These items would go here once supported....
|
||||
|
@ -539,9 +533,6 @@ qDebug() << " HEADER FITS.....";
|
|||
LevelDetails propertyLevel = packetData.startLevel();
|
||||
successPropertyFits = packetData.appendPosition(properties.getPosition());
|
||||
if (successPropertyFits) {
|
||||
|
||||
qDebug() << " PROP_POSITION FITS.....";
|
||||
|
||||
propertyFlags |= PROP_POSITION;
|
||||
propertiesDidntFit -= PROP_POSITION;
|
||||
propertyCount++;
|
||||
|
@ -700,9 +691,6 @@ qDebug() << " PROP_POSITION FITS.....";
|
|||
LevelDetails propertyLevel = packetData.startLevel();
|
||||
successPropertyFits = packetData.appendValue(properties.getModelURL());
|
||||
if (successPropertyFits) {
|
||||
|
||||
qDebug() << " PROP_MODEL_URL FITS.....";
|
||||
|
||||
propertyFlags |= PROP_MODEL_URL;
|
||||
propertiesDidntFit -= PROP_MODEL_URL;
|
||||
propertyCount++;
|
||||
|
|
|
@ -117,7 +117,6 @@ public:
|
|||
void setType(EntityTypes::EntityType type) { _type = type; }
|
||||
/// set position in meter units
|
||||
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 setRotation(const glm::quat& rotation) { _rotation = rotation; _rotationChanged = true; }
|
||||
|
||||
|
|
|
@ -1049,7 +1049,6 @@ void EntityTree::dumpTree() {
|
|||
}
|
||||
|
||||
void EntityTree::sendEntities(EntityEditPacketSender* packetSender, EntityTree* localTree, float x, float y, float z) {
|
||||
qDebug() << "EntityTree::sendEntities(" << x << ", " << y << ", " << z << ")";
|
||||
SendEntitiesOperationArgs args;
|
||||
args.packetSender = packetSender;
|
||||
args.localTree = localTree;
|
||||
|
@ -1062,51 +1061,23 @@ bool EntityTree::sendEntitiesOperation(OctreeElement* element, void* extraData)
|
|||
SendEntitiesOperationArgs* args = static_cast<SendEntitiesOperationArgs*>(extraData);
|
||||
EntityTreeElement* entityTreeElement = static_cast<EntityTreeElement*>(element);
|
||||
|
||||
qDebug() << "EntityTree::sendEntitiesOperation()";
|
||||
qDebug() << " element box:" << entityTreeElement->getAACube();
|
||||
|
||||
const QList<EntityItem*>& entities = entityTreeElement->getEntities();
|
||||
for (int i = 0; i < entities.size(); i++) {
|
||||
qDebug() << " entity[" << i <<"].id" << entities[i]->getEntityItemID();
|
||||
EntityItemID newID(NEW_ENTITY, EntityItemID::getNextCreatorTokenID(), false);
|
||||
|
||||
qDebug() << " entity[" << i <<"].newID" << newID;
|
||||
|
||||
EntityItemProperties properties = entities[i]->getProperties();
|
||||
qDebug() << " entity[" << i <<"].properties...";
|
||||
properties.debugDump();
|
||||
properties.setPosition(properties.getPosition() + args->root);
|
||||
properties.markAllChanged(); // so the entire property set is considered new, since we're making a new entity
|
||||
|
||||
properties.resetPosition(properties.getPosition() + args->root);
|
||||
qDebug() << " after resetPosition()....";
|
||||
properties.debugDump();
|
||||
|
||||
properties.markAllChanged();
|
||||
|
||||
// queue the packet
|
||||
qDebug() << " calling queueEditEntityMessage....";
|
||||
// queue the packet to send to the server
|
||||
args->packetSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, newID, properties);
|
||||
|
||||
// It would be nice to also update the local tree...
|
||||
//if (_entityTree) {
|
||||
// _entityTree->lockForWrite();
|
||||
// _entityTree->addEntity(id, properties);
|
||||
// _entityTree->unlock();
|
||||
//}
|
||||
// also update the local tree instantly (note: this is not our tree, but an alternate tree)
|
||||
if (args->localTree) {
|
||||
args->localTree->lockForWrite();
|
||||
args->localTree->addEntity(newID, properties);
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ EntityItem* EntityTypes::constructEntityItem(const unsigned char* data, int byte
|
|||
|
||||
EntityItemID tempEntityID;
|
||||
EntityItemProperties tempProperties;
|
||||
return new ModelEntityItem(tempEntityID, tempProperties);
|
||||
return constructEntityItem(Model, tempEntityID, tempProperties);
|
||||
}
|
||||
|
||||
// Header bytes
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// our non-pure virtual subclass for now...
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
// 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
|
||||
|
||||
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!
|
||||
14) Make sure LOD logic honors the LOD settings for entities in "spanners/parent" cells.
|
||||
|
||||
8) memory leaks???
|
||||
|
||||
9) EntityTreeRenderer::clearModelsCache()
|
||||
|
||||
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???)
|
||||
|
||||
|
@ -25,19 +22,10 @@
|
|||
|
||||
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???
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
@ -226,8 +214,18 @@
|
|||
// SOLVED -- 2) verify shadows work
|
||||
// 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 -- 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.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -165,9 +165,7 @@ void OctreeRenderer::render(RenderMode renderMode) {
|
|||
RenderArgs args = { this, _viewFrustum, getSizeScale(), getBoundaryLevelAdjust(), renderMode, 0, 0, 0 };
|
||||
if (_tree) {
|
||||
_tree->lockForRead();
|
||||
//qDebug() << "OctreeRenderer::render() tree locked START RENDER RECURSION...";
|
||||
_tree->recurseTreeWithOperation(renderOperation, &args);
|
||||
//qDebug() << "OctreeRenderer::render() tree locked ENDED RENDER RECURSION...";
|
||||
_tree->unlock();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue