From e8c1cb7db80507b14d95718fd440765b4f2b7443 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 12 Sep 2014 09:38:35 -0700 Subject: [PATCH] read old format files correctly --- interface/src/entities/EntityTreeRenderer.cpp | 19 +++++++++-- libraries/entities/src/EntityItem.cpp | 34 ++++++++++++++++++- libraries/entities/src/EntityItem.h | 5 --- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/interface/src/entities/EntityTreeRenderer.cpp b/interface/src/entities/EntityTreeRenderer.cpp index 86aa4b7622..095277d960 100644 --- a/interface/src/entities/EntityTreeRenderer.cpp +++ b/interface/src/entities/EntityTreeRenderer.cpp @@ -244,8 +244,6 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg glTranslatef(position.x, position.y, position.z); glm::vec3 axis = glm::axis(rotation); glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z); - - glPushMatrix(); glm::vec3 positionToCenter = center - position; glTranslatef(positionToCenter.x, positionToCenter.y, positionToCenter.z); @@ -257,6 +255,8 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg } void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args) { + bool wantDebug = false; + args->_elementsTouched++; // actually render it here... // we need to iterate the actual entityItems of the element @@ -288,6 +288,21 @@ 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... float distance = distanceToCamera(entityBox.calcCenter(), *args->_viewFrustum); + + if (wantDebug) { + qDebug() << "------- renderElement() ----------"; + qDebug() << " type:" << EntityTypes::getEntityTypeName(entityItem->getType()); + if (entityItem->getType() == EntityTypes::Model) { + ModelEntityItem* modelEntity = static_cast(entityItem); + qDebug() << " url:" << modelEntity->getModelURL(); + } + qDebug() << " entityBox:" << entityBox; + qDebug() << " dimensions:" << entityItem->getDimensionsInMeters() << "in meters"; + qDebug() << " largestDimension:" << entityBox.getLargestDimension() << "in meters"; + qDebug() << " shouldRender:" << shouldRenderEntity(entityBox.getLargestDimension(), distance); + qDebug() << " in frustum:" << (args->_viewFrustum->boxInFrustum(entityBox) != ViewFrustum::OUTSIDE); + } + if (shouldRenderEntity(entityBox.getLargestDimension(), distance) && args->_viewFrustum->boxInFrustum(entityBox) != ViewFrustum::OUTSIDE) { diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index ac405feebf..1406239f23 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -206,6 +206,11 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet APPEND_ENTITY_PROPERTY(PROP_POSITION, appendPosition, getPosition()); APPEND_ENTITY_PROPERTY(PROP_DIMENSIONS, appendValue, getDimensions()); // NOTE: PROP_RADIUS obsolete + + if (wantDebug) { + qDebug() << " APPEND_ENTITY_PROPERTY() PROP_DIMENSIONS:" << getDimensions(); + } + APPEND_ENTITY_PROPERTY(PROP_ROTATION, appendValue, getRotation()); APPEND_ENTITY_PROPERTY(PROP_MASS, appendValue, getMass()); APPEND_ENTITY_PROPERTY(PROP_VELOCITY, appendValue, getVelocity()); @@ -447,12 +452,25 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef dataAt += sizeof(fromBuffer); bytesRead += sizeof(fromBuffer); if (overwriteLocalData) { - setRadiusInMeters(fromBuffer); + setRadius(fromBuffer); } + + if (wantDebug) { + qDebug() << " readEntityDataFromBuffer() OLD FORMAT... found PROP_RADIUS"; + } + } } else { READ_ENTITY_PROPERTY(PROP_DIMENSIONS, glm::vec3, _dimensions); + if (wantDebug) { + qDebug() << " readEntityDataFromBuffer() NEW FORMAT... look for PROP_DIMENSIONS"; + } } + + if (wantDebug) { + qDebug() << " readEntityDataFromBuffer() _dimensions:" << getDimensionsInMeters() << " in meters"; + } + READ_ENTITY_PROPERTY_QUAT(PROP_ROTATION, _rotation); READ_ENTITY_PROPERTY(PROP_MASS, float, _mass); READ_ENTITY_PROPERTY(PROP_VELOCITY, glm::vec3, _velocity); @@ -465,6 +483,11 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef READ_ENTITY_PROPERTY(PROP_ANGULAR_DAMPING, float, _angularDamping); READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, _visible); + if (wantDebug) { + qDebug() << " readEntityDataFromBuffer() _registrationPoint:" << _registrationPoint; + qDebug() << " readEntityDataFromBuffer() _visible:" << _visible; + } + bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, propertyFlags, overwriteLocalData); } @@ -855,6 +878,15 @@ void EntityItem::setRadius(float value) { float diameter = value * 2.0f; float maxDimension = sqrt((diameter * diameter) / 3.0f); _dimensions = glm::vec3(maxDimension, maxDimension, maxDimension); + + bool wantDebug = false; + if (wantDebug) { + qDebug() << "EntityItem::setRadius()..."; + qDebug() << " radius:" << value; + qDebug() << " diameter:" << diameter; + qDebug() << " maxDimension:" << maxDimension; + qDebug() << " _dimensions:" << _dimensions; + } } // TODO: get rid of all users of this function... diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index d82b254e8a..e689ec1b25 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -257,11 +257,6 @@ protected: /// set radius in domain scale units (0.0 - 1.0) this will also reset dimensions to be equal for each axis void setRadius(float value); - /// set radius in meter units (0.0 - TREE_SCALE), this will also reset dimensions to be equal for each axis - void setRadiusInMeters(float value) { - float valueInTreeUnits = value / (float) TREE_SCALE; - setRadius(valueInTreeUnits); - } private: // TODO: We need to get rid of these users of getRadius()... but for now, we'll make them friends