From 373be9529760f7edf9ff42218671cb898da87658 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Fri, 6 Mar 2015 15:32:03 -0800 Subject: [PATCH] entity cubes are in meters --- interface/src/Application.cpp | 2 - interface/src/avatar/ModelReferential.cpp | 26 +++---- interface/src/octree/OctreeFade.cpp | 2 +- interface/src/ui/NodeBounds.cpp | 7 +- interface/src/ui/OctreeStatsDialog.cpp | 1 - .../src/EntityTreeRenderer.cpp | 28 +++---- .../src/RenderableBoxEntityItem.cpp | 6 +- .../src/RenderableLightEntityItem.cpp | 6 +- .../src/RenderableLightEntityItem.h | 2 +- .../src/RenderableModelEntityItem.cpp | 8 +- .../src/RenderableModelEntityItem.h | 2 +- .../src/RenderableSphereEntityItem.cpp | 6 +- .../src/RenderableTextEntityItem.cpp | 4 +- libraries/entities/src/AddEntityOperator.cpp | 4 +- libraries/entities/src/BoxEntityItem.cpp | 1 - .../entities/src/DeleteEntityOperator.cpp | 2 +- libraries/entities/src/EntityItem.cpp | 76 +++++++++---------- libraries/entities/src/EntityItem.h | 40 +++++----- .../entities/src/EntityItemProperties.cpp | 13 +--- libraries/entities/src/EntityItemProperties.h | 5 +- .../entities/src/EntityScriptingInterface.cpp | 2 +- libraries/entities/src/EntitySimulation.cpp | 4 +- libraries/entities/src/EntityTree.cpp | 18 ++--- libraries/entities/src/EntityTree.h | 2 +- libraries/entities/src/EntityTreeElement.cpp | 52 +++++-------- libraries/entities/src/EntityTreeElement.h | 3 +- libraries/entities/src/ModelEntityItem.cpp | 4 +- .../entities/src/MovingEntitiesOperator.cpp | 4 +- .../entities/src/MovingEntitiesOperator.h | 8 +- libraries/entities/src/SphereEntityItem.cpp | 6 +- libraries/entities/src/SphereEntityItem.h | 2 +- libraries/entities/src/TextEntityItem.cpp | 10 +-- libraries/entities/src/TextEntityItem.h | 4 +- .../entities/src/UpdateEntityOperator.cpp | 14 ++-- libraries/octree/src/Octree.cpp | 29 +++---- libraries/octree/src/Octree.h | 8 ++ libraries/octree/src/OctreeElement.cpp | 39 ++++------ libraries/octree/src/OctreeHeadlessViewer.cpp | 2 - libraries/octree/src/OctreeRenderer.cpp | 3 - libraries/physics/src/EntityMotionState.cpp | 12 +-- tests/octree/src/ModelTests.cpp | 40 +++++----- 41 files changed, 221 insertions(+), 286 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fea6a1fb73..49ac272b35 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2262,7 +2262,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node VoxelPositionSize rootDetails; voxelDetailsForCode(rootCode, rootDetails); AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); - serverBounds.scale(TREE_SCALE); ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds); @@ -2326,7 +2325,6 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node VoxelPositionSize rootDetails; voxelDetailsForCode(rootCode, rootDetails); AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); - serverBounds.scale(TREE_SCALE); ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds); if (serverFrustumLocation != ViewFrustum::OUTSIDE) { diff --git a/interface/src/avatar/ModelReferential.cpp b/interface/src/avatar/ModelReferential.cpp index beb378403d..b8acf78cd3 100644 --- a/interface/src/avatar/ModelReferential.cpp +++ b/interface/src/avatar/ModelReferential.cpp @@ -31,9 +31,9 @@ ModelReferential::ModelReferential(Referential* referential, EntityTree* tree, A const EntityItem* item = _tree->findEntityByID(_entityID); if (item != NULL) { - _lastRefDimension = item->getDimensionsInMeters(); + _lastRefDimension = item->getDimensions(); _refRotation = item->getRotation(); - _refPosition = item->getPositionInMeters(); + _refPosition = item->getPosition(); update(); } } @@ -50,9 +50,9 @@ ModelReferential::ModelReferential(const QUuid& entityID, EntityTree* tree, Avat return; } - _lastRefDimension = item->getDimensionsInMeters(); + _lastRefDimension = item->getDimensions(); _refRotation = item->getRotation(); - _refPosition = item->getPositionInMeters(); + _refPosition = item->getPosition(); glm::quat refInvRot = glm::inverse(_refRotation); _rotation = refInvRot * _avatar->getOrientation(); @@ -66,9 +66,9 @@ void ModelReferential::update() { } bool somethingChanged = false; - if (item->getDimensionsInMeters() != _lastRefDimension) { + if (item->getDimensions() != _lastRefDimension) { glm::vec3 oldDimension = _lastRefDimension; - _lastRefDimension = item->getDimensionsInMeters(); + _lastRefDimension = item->getDimensions(); _translation *= _lastRefDimension / oldDimension; somethingChanged = true; } @@ -77,8 +77,8 @@ void ModelReferential::update() { _avatar->setOrientation(_refRotation * _rotation, true); somethingChanged = true; } - if (item->getPositionInMeters() != _refPosition || somethingChanged) { - _refPosition = item->getPositionInMeters(); + if (item->getPosition() != _refPosition || somethingChanged) { + _refPosition = item->getPosition(); _avatar->setPosition(_refPosition + _refRotation * _translation, true); } } @@ -107,7 +107,7 @@ JointReferential::JointReferential(Referential* referential, EntityTree* tree, A const EntityItem* item = _tree->findEntityByID(_entityID); const Model* model = getModel(item); if (!isValid() || model == NULL || _jointIndex >= (uint32_t)(model->getJointStateCount())) { - _lastRefDimension = item->getDimensionsInMeters(); + _lastRefDimension = item->getDimensions(); model->getJointRotationInWorldFrame(_jointIndex, _refRotation); model->getJointPositionInWorldFrame(_jointIndex, _refPosition); } @@ -127,7 +127,7 @@ JointReferential::JointReferential(uint32_t jointIndex, const QUuid& entityID, E return; } - _lastRefDimension = item->getDimensionsInMeters(); + _lastRefDimension = item->getDimensions(); model->getJointRotationInWorldFrame(_jointIndex, _refRotation); model->getJointPositionInWorldFrame(_jointIndex, _refPosition); @@ -145,9 +145,9 @@ void JointReferential::update() { } bool somethingChanged = false; - if (item->getDimensionsInMeters() != _lastRefDimension) { + if (item->getDimensions() != _lastRefDimension) { glm::vec3 oldDimension = _lastRefDimension; - _lastRefDimension = item->getDimensionsInMeters(); + _lastRefDimension = item->getDimensions(); _translation *= _lastRefDimension / oldDimension; somethingChanged = true; } @@ -156,7 +156,7 @@ void JointReferential::update() { _avatar->setOrientation(_refRotation * _rotation, true); somethingChanged = true; } - if (item->getPositionInMeters() != _refPosition || somethingChanged) { + if (item->getPosition() != _refPosition || somethingChanged) { model->getJointPositionInWorldFrame(_jointIndex, _refPosition); _avatar->setPosition(_refPosition + _refRotation * _translation, true); } diff --git a/interface/src/octree/OctreeFade.cpp b/interface/src/octree/OctreeFade.cpp index 917bb67124..ad313bdb6d 100644 --- a/interface/src/octree/OctreeFade.cpp +++ b/interface/src/octree/OctreeFade.cpp @@ -42,7 +42,7 @@ void OctreeFade::render() { glDisable(GL_LIGHTING); glPushMatrix(); - glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE); + glScalef(1.0f, 1.0f, 1.0f); glTranslatef(voxelDetails.x + voxelDetails.s * 0.5f, voxelDetails.y + voxelDetails.s * 0.5f, voxelDetails.z + voxelDetails.s * 0.5f); diff --git a/interface/src/ui/NodeBounds.cpp b/interface/src/ui/NodeBounds.cpp index 85cbf72953..f0f4d432db 100644 --- a/interface/src/ui/NodeBounds.cpp +++ b/interface/src/ui/NodeBounds.cpp @@ -71,20 +71,19 @@ void NodeBounds::draw() { voxelDetailsForCode(rootCode, rootDetails); serverJurisdictions->unlock(); glm::vec3 location(rootDetails.x, rootDetails.y, rootDetails.z); - location *= (float)TREE_SCALE; - AACube serverBounds(location, rootDetails.s * TREE_SCALE); + AACube serverBounds(location, rootDetails.s); glm::vec3 center = serverBounds.getVertex(BOTTOM_RIGHT_NEAR) + ((serverBounds.getVertex(TOP_LEFT_FAR) - serverBounds.getVertex(BOTTOM_RIGHT_NEAR)) / 2.0f); const float ENTITY_NODE_SCALE = 0.99f; - float scaleFactor = rootDetails.s * TREE_SCALE; + float scaleFactor = rootDetails.s; // Scale by 0.92 - 1.00 depending on the scale of the node. This allows smaller nodes to scale in // a bit and not overlap larger nodes. - scaleFactor *= 0.92 + (rootDetails.s * 0.08); + scaleFactor *= 0.92f + (rootDetails.s * 0.08f); // Scale different node types slightly differently because it's common for them to overlap. if (nodeType == NodeType::EntityServer) { diff --git a/interface/src/ui/OctreeStatsDialog.cpp b/interface/src/ui/OctreeStatsDialog.cpp index d9c8124180..462811fc1c 100644 --- a/interface/src/ui/OctreeStatsDialog.cpp +++ b/interface/src/ui/OctreeStatsDialog.cpp @@ -273,7 +273,6 @@ void OctreeStatsDialog::showOctreeServersOfType(int& serverCount, NodeType_t ser VoxelPositionSize rootDetails; voxelDetailsForCode(rootCode, rootDetails); AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); - serverBounds.scale(TREE_SCALE); serverDetails << " jurisdiction: " << qPrintable(rootCodeHex) << " [" diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 1a7d9c8ca7..ebc79250cc 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -48,7 +48,6 @@ EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterf _displayModelElementProxy(false), _dontDoPrecisionPicking(false) { - std::cout << "adebug " << (void*)(this) << " EntityTreeRenderer ctor" << std::endl; // adebug REGISTER_ENTITY_TYPE_WITH_FACTORY(Model, RenderableModelEntityItem::factory) REGISTER_ENTITY_TYPE_WITH_FACTORY(Box, RenderableBoxEntityItem::factory) REGISTER_ENTITY_TYPE_WITH_FACTORY(Sphere, RenderableSphereEntityItem::factory) @@ -285,11 +284,11 @@ void EntityTreeRenderer::checkEnterLeaveEntities() { QVector entitiesContainingAvatar; // find the entities near us - static_cast(_tree)->findEntitiesInMeters(avatarPosition, radius, foundEntities); + static_cast(_tree)->findEntities(avatarPosition, radius, foundEntities); // create a list of entities that actually contain the avatar's position foreach(const EntityItem* entity, foundEntities) { - if (entity->containsInMeters(avatarPosition)) { + if (entity->contains(avatarPosition)) { entitiesContainingAvatar << entity->getEntityItemID(); } } @@ -417,8 +416,8 @@ const Model* EntityTreeRenderer::getModelForEntityItem(const EntityItem* entityI } void EntityTreeRenderer::renderElementProxy(EntityTreeElement* entityTreeElement) { - glm::vec3 elementCenter = entityTreeElement->getAACube().calcCenter() * (float) TREE_SCALE; - float elementSize = entityTreeElement->getScale() * (float) TREE_SCALE; + glm::vec3 elementCenter = entityTreeElement->getAACube().calcCenter(); + float elementSize = entityTreeElement->getScale(); glPushMatrix(); glTranslatef(elementCenter.x, elementCenter.y, elementCenter.z); DependencyManager::get()->renderWireCube(elementSize, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f)); @@ -477,10 +476,7 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg AACube maxCube = entity->getMaximumAACube(); AACube minCube = entity->getMinimumAACube(); - AABox entityBox = entity->getAABoxInMeters(); - - maxCube.scale((float) TREE_SCALE); - minCube.scale((float) TREE_SCALE); + AABox entityBox = entity->getAABox(); glm::vec3 maxCenter = maxCube.calcCenter(); glm::vec3 minCenter = minCube.calcCenter(); @@ -507,9 +503,9 @@ void EntityTreeRenderer::renderProxies(const EntityItem* entity, RenderArgs* arg glPopMatrix(); - glm::vec3 position = entity->getPositionInMeters(); - glm::vec3 center = entity->getCenterInMeters(); - glm::vec3 dimensions = entity->getDimensionsInMeters(); + glm::vec3 position = entity->getPosition(); + glm::vec3 center = entity->getCenter(); + glm::vec3 dimensions = entity->getDimensions(); glm::quat rotation = entity->getRotation(); glPushMatrix(); @@ -548,7 +544,7 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args) if (entityItem->isVisible()) { // render entityItem - AABox entityBox = entityItem->getAABoxInMeters(); + AABox entityBox = entityItem->getAABox(); // TODO: some entity types (like lights) might want to be rendered even // when they are outside of the view frustum... @@ -672,16 +668,10 @@ RayToEntityIntersectionResult EntityTreeRenderer::findRayIntersectionWorker(cons (void**)&intersectedEntity, lockType, &result.accurate, precisionPicking); if (result.intersects && intersectedEntity) { - std::cout << "adebug " << (void*)(this) << " EntityTreeRenderer's tree = " << (void*)(_tree) << std::endl; // adebug - int foo = 0; result.entityID = intersectedEntity->getEntityItemID(); - foo = 1; result.properties = intersectedEntity->getProperties(); - foo = 2; result.intersection = ray.origin + (ray.direction * result.distance); - foo = 3; result.entity = intersectedEntity; - std::cout << "adebug foo = " << foo << std::endl; // adebug } } return result; diff --git a/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp b/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp index a80fc91995..f7828806ab 100644 --- a/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableBoxEntityItem.cpp @@ -25,9 +25,9 @@ EntityItem* RenderableBoxEntityItem::factory(const EntityItemID& entityID, const void RenderableBoxEntityItem::render(RenderArgs* args) { PerformanceTimer perfTimer("RenderableBoxEntityItem::render"); assert(getType() == EntityTypes::Box); - glm::vec3 position = getPositionInMeters(); - glm::vec3 center = getCenterInMeters(); - glm::vec3 dimensions = getDimensionsInMeters(); + glm::vec3 position = getPosition(); + glm::vec3 center = getCenter(); + glm::vec3 dimensions = getDimensions(); glm::quat rotation = getRotation(); const float MAX_COLOR = 255.0f; diff --git a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp index 5889e6b34a..838c9fd8c4 100644 --- a/libraries/entities-renderer/src/RenderableLightEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableLightEntityItem.cpp @@ -26,8 +26,8 @@ EntityItem* RenderableLightEntityItem::factory(const EntityItemID& entityID, con void RenderableLightEntityItem::render(RenderArgs* args) { PerformanceTimer perfTimer("RenderableLightEntityItem::render"); assert(getType() == EntityTypes::Light); - glm::vec3 position = getPositionInMeters(); - glm::vec3 dimensions = getDimensionsInMeters(); + glm::vec3 position = getPosition(); + glm::vec3 dimensions = getDimensions(); glm::quat rotation = getRotation(); float largestDiameter = glm::max(dimensions.x, dimensions.y, dimensions.z); @@ -67,7 +67,7 @@ void RenderableLightEntityItem::render(RenderArgs* args) { #endif }; -bool RenderableLightEntityItem::findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, +bool RenderableLightEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const { diff --git a/libraries/entities-renderer/src/RenderableLightEntityItem.h b/libraries/entities-renderer/src/RenderableLightEntityItem.h index 1ea3e7e884..cfafb85983 100644 --- a/libraries/entities-renderer/src/RenderableLightEntityItem.h +++ b/libraries/entities-renderer/src/RenderableLightEntityItem.h @@ -24,7 +24,7 @@ public: virtual void render(RenderArgs* args); virtual bool supportsDetailedRayIntersection() const { return true; } - virtual bool findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, + virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const; }; diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 6c1d24b845..75c9f07881 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -114,8 +114,8 @@ void RenderableModelEntityItem::render(RenderArgs* args) { bool drawAsModel = hasModel(); - glm::vec3 position = getPositionInMeters(); - glm::vec3 dimensions = getDimensionsInMeters(); + glm::vec3 position = getPosition(); + glm::vec3 dimensions = getDimensions(); float size = glm::length(dimensions); if (drawAsModel) { @@ -254,13 +254,13 @@ EntityItemProperties RenderableModelEntityItem::getProperties() const { return properties; } -bool RenderableModelEntityItem::findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, +bool RenderableModelEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const { if (!_model) { return true; } - //qDebug() << "RenderableModelEntityItem::findDetailedRayIntersectionInMeters() precisionPicking:" << precisionPicking; + //qDebug() << "RenderableModelEntityItem::findDetailedRayIntersection() precisionPicking:" << precisionPicking; QString extraInfo; return _model->findRayIntersectionAgainstSubMeshes(origin, direction, distance, face, extraInfo, precisionPicking); diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.h b/libraries/entities-renderer/src/RenderableModelEntityItem.h index 7e20b0bd15..65cded0207 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.h +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.h @@ -44,7 +44,7 @@ public: virtual void render(RenderArgs* args); virtual bool supportsDetailedRayIntersection() const { return true; } - virtual bool findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, + virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const; diff --git a/libraries/entities-renderer/src/RenderableSphereEntityItem.cpp b/libraries/entities-renderer/src/RenderableSphereEntityItem.cpp index 4688e7cc29..083a34c02f 100644 --- a/libraries/entities-renderer/src/RenderableSphereEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableSphereEntityItem.cpp @@ -26,9 +26,9 @@ EntityItem* RenderableSphereEntityItem::factory(const EntityItemID& entityID, co void RenderableSphereEntityItem::render(RenderArgs* args) { PerformanceTimer perfTimer("RenderableSphereEntityItem::render"); assert(getType() == EntityTypes::Sphere); - glm::vec3 position = getPositionInMeters(); - glm::vec3 center = getCenterInMeters(); - glm::vec3 dimensions = getDimensionsInMeters(); + glm::vec3 position = getPosition(); + glm::vec3 center = getCenter(); + glm::vec3 dimensions = getDimensions(); glm::quat rotation = getRotation(); const float MAX_COLOR = 255.0f; diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index 097aef3b38..3586a8c8c5 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -30,8 +30,8 @@ EntityItem* RenderableTextEntityItem::factory(const EntityItemID& entityID, cons void RenderableTextEntityItem::render(RenderArgs* args) { PerformanceTimer perfTimer("RenderableTextEntityItem::render"); assert(getType() == EntityTypes::Text); - glm::vec3 position = getPositionInMeters(); - glm::vec3 dimensions = getDimensionsInMeters(); + glm::vec3 position = getPosition(); + glm::vec3 dimensions = getDimensions(); glm::vec3 halfDimensions = dimensions / 2.0f; glm::quat rotation = getRotation(); float leftMargin = 0.1f; diff --git a/libraries/entities/src/AddEntityOperator.cpp b/libraries/entities/src/AddEntityOperator.cpp index 34ccc75030..0844a10ede 100644 --- a/libraries/entities/src/AddEntityOperator.cpp +++ b/libraries/entities/src/AddEntityOperator.cpp @@ -25,7 +25,7 @@ AddEntityOperator::AddEntityOperator(EntityTree* tree, { // caller must have verified existence of newEntity assert(_newEntity); - _newEntityBox = _newEntity->getMaximumAACube().clamp(0.0f, 1.0f); + _newEntityBox = _newEntity->getMaximumAACube().clamp(0.0f, (float)TREE_SCALE); } bool AddEntityOperator::preRecursion(OctreeElement* element) { @@ -43,7 +43,7 @@ bool AddEntityOperator::preRecursion(OctreeElement* element) { if (!_foundNew && element->getAACube().contains(_newEntityBox)) { // If this element is the best fit for the new entity properties, then add/or update it - if (entityTreeElement->bestFitBounds(_newEntityBox)) { + if (entityTreeElement->bestFitBoundsInMeters(_newEntityBox)) { entityTreeElement->addEntityItem(_newEntity); _tree->setContainingElement(_newEntity->getEntityItemID(), entityTreeElement); diff --git a/libraries/entities/src/BoxEntityItem.cpp b/libraries/entities/src/BoxEntityItem.cpp index 5256877b44..1e8c811122 100644 --- a/libraries/entities/src/BoxEntityItem.cpp +++ b/libraries/entities/src/BoxEntityItem.cpp @@ -41,7 +41,6 @@ EntityItemProperties BoxEntityItem::getProperties() const { properties._glowLevel = getGlowLevel(); properties._glowLevelChanged = false; - std::cout << "adebug end of BoxEntityItem::getProperties()" << std::endl; // adebug return properties; } diff --git a/libraries/entities/src/DeleteEntityOperator.cpp b/libraries/entities/src/DeleteEntityOperator.cpp index 698ef18936..d17e1c66d6 100644 --- a/libraries/entities/src/DeleteEntityOperator.cpp +++ b/libraries/entities/src/DeleteEntityOperator.cpp @@ -60,7 +60,7 @@ bool DeleteEntityOperator::subTreeContainsSomeEntitiesToDelete(OctreeElement* el // If we don't have an old entity, then we don't contain the entity, otherwise // check the bounds if (_entitiesToDelete.size() > 0) { - AACube elementCube = element->getAACube(); + const AACube& elementCube = element->getAACube(); foreach(const EntityToDeleteDetails& details, _entitiesToDelete) { if (elementCube.contains(details.cube)) { containsEntity = true; diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index b6381f196d..5a1712a1f6 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -221,12 +221,12 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet // PROP_PAGED_PROPERTY, // PROP_CUSTOM_PROPERTIES_INCLUDED, - APPEND_ENTITY_PROPERTY(PROP_POSITION, appendPosition, getPositionInMeters()); - APPEND_ENTITY_PROPERTY(PROP_DIMENSIONS, appendValue, getDimensionsInMeters()); // NOTE: PROP_RADIUS obsolete + APPEND_ENTITY_PROPERTY(PROP_POSITION, appendPosition, getPosition()); + APPEND_ENTITY_PROPERTY(PROP_DIMENSIONS, appendValue, getDimensions()); // NOTE: PROP_RADIUS obsolete APPEND_ENTITY_PROPERTY(PROP_ROTATION, appendValue, getRotation()); APPEND_ENTITY_PROPERTY(PROP_DENSITY, appendValue, getDensity()); - APPEND_ENTITY_PROPERTY(PROP_VELOCITY, appendValue, getVelocityInMeters()); - APPEND_ENTITY_PROPERTY(PROP_GRAVITY, appendValue, getGravityInMeters()); + APPEND_ENTITY_PROPERTY(PROP_VELOCITY, appendValue, getVelocity()); + APPEND_ENTITY_PROPERTY(PROP_GRAVITY, appendValue, getGravity()); APPEND_ENTITY_PROPERTY(PROP_DAMPING, appendValue, getDamping()); APPEND_ENTITY_PROPERTY(PROP_LIFETIME, appendValue, getLifetime()); APPEND_ENTITY_PROPERTY(PROP_SCRIPT, appendValue, getScript()); @@ -503,7 +503,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef bytesRead += propertyFlags.getEncodedLength(); bool useMeters = (args.bitstreamVersion == VERSION_ENTITIES_USE_METERS); if (useMeters) { - READ_ENTITY_PROPERTY_SETTER(PROP_POSITION, glm::vec3, updatePositionInMeters); + READ_ENTITY_PROPERTY_SETTER(PROP_POSITION, glm::vec3, updatePosition); } else { READ_ENTITY_PROPERTY_SETTER(PROP_POSITION, glm::vec3, updatePositionInDomainUnits); } @@ -521,7 +521,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef } } else { if (useMeters) { - READ_ENTITY_PROPERTY_SETTER(PROP_DIMENSIONS, glm::vec3, setDimensionsInMeters); + READ_ENTITY_PROPERTY_SETTER(PROP_DIMENSIONS, glm::vec3, setDimensions); } else { READ_ENTITY_PROPERTY_SETTER(PROP_DIMENSIONS, glm::vec3, setDimensionsInDomainUnits); } @@ -530,8 +530,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef READ_ENTITY_PROPERTY_QUAT_SETTER(PROP_ROTATION, updateRotation); READ_ENTITY_PROPERTY_SETTER(PROP_DENSITY, float, updateDensity); if (useMeters) { - READ_ENTITY_PROPERTY_SETTER(PROP_VELOCITY, glm::vec3, updateVelocityInMeters); - READ_ENTITY_PROPERTY_SETTER(PROP_GRAVITY, glm::vec3, updateGravityInMeters); + READ_ENTITY_PROPERTY_SETTER(PROP_VELOCITY, glm::vec3, updateVelocity); + READ_ENTITY_PROPERTY_SETTER(PROP_GRAVITY, glm::vec3, updateGravity); } else { READ_ENTITY_PROPERTY_SETTER(PROP_VELOCITY, glm::vec3, updateVelocityInDomainUnits); READ_ENTITY_PROPERTY_SETTER(PROP_GRAVITY, glm::vec3, updateGravityInDomainUnits); @@ -726,7 +726,7 @@ void EntityItem::simulateKinematicMotion(float timeElapsed) { if (hasVelocity()) { // linear damping - glm::vec3 velocity = getVelocityInMeters(); + glm::vec3 velocity = getVelocity(); if (_damping > 0.0f) { velocity *= powf(1.0f - _damping, timeElapsed); #ifdef WANT_DEBUG @@ -738,7 +738,7 @@ void EntityItem::simulateKinematicMotion(float timeElapsed) { } // integrate position forward - glm::vec3 position = getPositionInMeters(); + glm::vec3 position = getPosition(); glm::vec3 newPosition = position + (velocity * timeElapsed); #ifdef WANT_DEBUG @@ -758,19 +758,19 @@ void EntityItem::simulateKinematicMotion(float timeElapsed) { if (hasGravity()) { // handle resting on surface case, this is definitely a bit of a hack, and it only works on the // "ground" plane of the domain, but for now it's what we've got - velocity += getGravityInMeters() * timeElapsed; + velocity += getGravity() * timeElapsed; } float speed = glm::length(velocity); const float EPSILON_LINEAR_VELOCITY_LENGTH = 0.001f; // 1mm/sec if (speed < EPSILON_LINEAR_VELOCITY_LENGTH) { - setVelocityInMeters(ENTITY_ITEM_ZERO_VEC3); + setVelocity(ENTITY_ITEM_ZERO_VEC3); if (speed > 0.0f) { _dirtyFlags |= EntityItem::DIRTY_MOTION_TYPE; } } else { - setPositionInMeters(position); - setVelocityInMeters(velocity); + setPosition(position); + setVelocity(velocity); } #ifdef WANT_DEBUG @@ -795,7 +795,6 @@ quint64 EntityItem::getExpiry() const { } EntityItemProperties EntityItem::getProperties() const { - std::cout << "adebug EntityItem::getProperties" << std::endl; // adebug EntityItemProperties properties; properties._id = getID(); properties._idSet = true; @@ -803,12 +802,12 @@ EntityItemProperties EntityItem::getProperties() const { properties._type = getType(); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(position, getPositionInMeters); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(dimensions, getDimensionsInMeters); // NOTE: radius is obsolete + COPY_ENTITY_PROPERTY_TO_PROPERTIES(position, getPosition); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(dimensions, getDimensions); // NOTE: radius is obsolete COPY_ENTITY_PROPERTY_TO_PROPERTIES(rotation, getRotation); COPY_ENTITY_PROPERTY_TO_PROPERTIES(density, getDensity); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(velocity, getVelocityInMeters); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(gravity, getGravityInMeters); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(velocity, getVelocity); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(gravity, getGravity); COPY_ENTITY_PROPERTY_TO_PROPERTIES(damping, getDamping); COPY_ENTITY_PROPERTY_TO_PROPERTIES(lifetime, getLifetime); COPY_ENTITY_PROPERTY_TO_PROPERTIES(script, getScript); @@ -825,19 +824,18 @@ EntityItemProperties EntityItem::getProperties() const { properties._defaultSettings = false; - std::cout << "adebug about to delete properties" << std::endl; // adebug return properties; } bool EntityItem::setProperties(const EntityItemProperties& properties) { bool somethingChanged = false; - SET_ENTITY_PROPERTY_FROM_PROPERTIES(position, updatePositionInMeters); // this will call recalculate collision shape if needed - SET_ENTITY_PROPERTY_FROM_PROPERTIES(dimensions, updateDimensionsInMeters); // NOTE: radius is obsolete + SET_ENTITY_PROPERTY_FROM_PROPERTIES(position, updatePosition); // this will call recalculate collision shape if needed + SET_ENTITY_PROPERTY_FROM_PROPERTIES(dimensions, updateDimensions); // NOTE: radius is obsolete SET_ENTITY_PROPERTY_FROM_PROPERTIES(rotation, updateRotation); SET_ENTITY_PROPERTY_FROM_PROPERTIES(density, updateDensity); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(velocity, updateVelocityInMeters); - SET_ENTITY_PROPERTY_FROM_PROPERTIES(gravity, updateGravityInMeters); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(velocity, updateVelocity); + SET_ENTITY_PROPERTY_FROM_PROPERTIES(gravity, updateGravity); SET_ENTITY_PROPERTY_FROM_PROPERTIES(damping, updateDamping); SET_ENTITY_PROPERTY_FROM_PROPERTIES(lifetime, updateLifetime); SET_ENTITY_PROPERTY_FROM_PROPERTIES(script, setScript); @@ -900,7 +898,7 @@ void EntityItem::recordCreationTime() { // TODO: doesn't this need to handle rotation? -glm::vec3 EntityItem::getCenterInMeters() const { +glm::vec3 EntityItem::getCenter() const { return _position + (_dimensions * (glm::vec3(0.5f,0.5f,0.5f) - _registrationPoint)); } @@ -957,7 +955,7 @@ AACube EntityItem::getMinimumAACube() const { return AACube(cornerOfCube, longestSide); } -AABox EntityItem::getAABoxInMeters() const { +AABox EntityItem::getAABox() const { // _position represents the position of the registration point. glm::vec3 registrationRemainder = glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint; @@ -973,8 +971,8 @@ AABox EntityItem::getAABoxInMeters() const { } AABox EntityItem::getAABoxInDomainUnits() const { - AABox box = getAABoxInMeters(); - box *= 1.0f / (float)TREE_SCALE; + AABox box = getAABox(); + box.scale(1.0f / (float)TREE_SCALE); return box; } @@ -1001,12 +999,12 @@ void EntityItem::setRadius(float value) { // ... radius = cornerToCornerLength / 2.0f // ... cornerToCornerLength = sqrt(3 x maxDimension ^ 2) // ... radius = sqrt(3 x maxDimension ^ 2) / 2.0f; -float EntityItem::getRadiusInMeters() const { +float EntityItem::getRadius() const { return 0.5f * glm::length(_dimensions); } void EntityItem::computeShapeInfo(ShapeInfo& info) const { - info.setParams(getShapeType(), 0.5f * getDimensionsInMeters()); + info.setParams(getShapeType(), 0.5f * getDimensions()); } const float MIN_POSITION_DELTA = 0.0001f; @@ -1019,27 +1017,25 @@ const float MIN_SPIN_DELTA = 0.0003f; void EntityItem::updatePositionInDomainUnits(const glm::vec3& value) { glm::vec3 position = value * (float)TREE_SCALE; - updatePositionInMeters(position); + updatePosition(position); } -void EntityItem::updatePositionInMeters(const glm::vec3& value) { +void EntityItem::updatePosition(const glm::vec3& value) { if (glm::distance(_position, value) > MIN_POSITION_DELTA) { _position = value; _dirtyFlags |= EntityItem::DIRTY_POSITION; - std::cout << "adebug updatePositionInMeters = " << _position << std::endl; // adebug } } void EntityItem::updateDimensionsInDomainUnits(const glm::vec3& value) { glm::vec3 dimensions = value * (float)TREE_SCALE; - updateDimensionsInMeters(dimensions); + updateDimensions(dimensions); } -void EntityItem::updateDimensionsInMeters(const glm::vec3& value) { +void EntityItem::updateDimensions(const glm::vec3& value) { if (glm::distance(_dimensions, value) > MIN_DIMENSIONS_DELTA) { _dimensions = value; _dirtyFlags |= (EntityItem::DIRTY_SHAPE | EntityItem::DIRTY_MASS); - std::cout << "adebug updateDimensionsInMeters = " << value << std::endl; // adebug } } @@ -1076,10 +1072,10 @@ void EntityItem::updateMass(float mass) { void EntityItem::updateVelocityInDomainUnits(const glm::vec3& value) { glm::vec3 velocity = value * (float)TREE_SCALE; - updateVelocityInMeters(velocity); + updateVelocity(velocity); } -void EntityItem::updateVelocityInMeters(const glm::vec3& value) { +void EntityItem::updateVelocity(const glm::vec3& value) { if (glm::distance(_velocity, value) > MIN_VELOCITY_DELTA) { if (glm::length(value) < MIN_VELOCITY_DELTA) { _velocity = ENTITY_ITEM_ZERO_VEC3; @@ -1099,10 +1095,10 @@ void EntityItem::updateDamping(float value) { void EntityItem::updateGravityInDomainUnits(const glm::vec3& value) { glm::vec3 gravity = value * (float) TREE_SCALE; - updateGravityInMeters(gravity); + updateGravity(gravity); } -void EntityItem::updateGravityInMeters(const glm::vec3& value) { +void EntityItem::updateGravity(const glm::vec3& value) { if ( glm::distance(_gravity, value) > MIN_GRAVITY_DELTA) { _gravity = value; _dirtyFlags |= EntityItem::DIRTY_VELOCITY; diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index a494831317..0f8139eea5 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -22,7 +22,6 @@ #include // for OctreeElement::AppendState #include #include -#include // adebug #include "EntityItemID.h" #include "EntityItemProperties.h" @@ -140,34 +139,33 @@ public: virtual void debugDump() const; virtual bool supportsDetailedRayIntersection() const { return false; } - virtual bool findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, + virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const { return true; } // attributes applicable to all entity types EntityTypes::EntityType getType() const { return _type; } glm::vec3 getPositionInDomainUnits() const { return _position / (float)TREE_SCALE; } /// get position in domain scale units (0.0 - 1.0) - const glm::vec3& getPositionInMeters() const { return _position; } /// get position in meters + const glm::vec3& getPosition() const { return _position; } /// get position in meters /// set position in domain scale units (0.0 - 1.0) void setPositionInDomainUnits(const glm::vec3& value) - { setPositionInMeters(glm::clamp(value, 0.0f, 1.0f) * (float)TREE_SCALE); } - void setPositionInMeters(const glm::vec3& value) { + { setPosition(glm::clamp(value, 0.0f, 1.0f) * (float)TREE_SCALE); } + void setPosition(const glm::vec3& value) { _position = value; - std::cout << "adebug setPosition = " << _position << std::endl; // adebug } - glm::vec3 getCenterInDomainUnits() const { return getCenterInMeters() / (float) TREE_SCALE; } - glm::vec3 getCenterInMeters() const; + glm::vec3 getCenterInDomainUnits() const { return getCenter() / (float) TREE_SCALE; } + glm::vec3 getCenter() const; glm::vec3 getDimensionsInDomainUnits() const { return _dimensions / (float)TREE_SCALE; } /// get dimensions in domain scale units (0.0 - 1.0) - const glm::vec3& getDimensionsInMeters() const { return _dimensions; } /// get dimensions in meters + const glm::vec3& getDimensions() const { return _dimensions; } /// get dimensions in meters /// set dimensions in domain scale units (0.0 - 1.0) virtual void setDimensionsInDomainUnits(const glm::vec3& value) { _dimensions = glm::abs(value) * (float)TREE_SCALE; } /// set dimensions in meter units (0.0 - TREE_SCALE) - virtual void setDimensionsInMeters(const glm::vec3& value) { _dimensions = glm::abs(value); } + virtual void setDimensions(const glm::vec3& value) { _dimensions = glm::abs(value); } const glm::quat& getRotation() const { return _rotation; } void setRotation(const glm::quat& rotation) { _rotation = rotation; } @@ -185,15 +183,15 @@ public: float getDensity() const { return _density; } glm::vec3 getVelocityInDomainUnits() const { return _velocity / (float)TREE_SCALE; } /// velocity in domain scale units (0.0-1.0) per second - const glm::vec3 getVelocityInMeters() const { return _velocity; } /// get velocity in meters + const glm::vec3 getVelocity() const { return _velocity; } /// get velocity in meters void setVelocityInDomainUnits(const glm::vec3& value) { _velocity = value * (float)TREE_SCALE; } /// velocity in domain scale units (0.0-1.0) per second - void setVelocityInMeters(const glm::vec3& value) { _velocity = value; } /// velocity in meters + void setVelocity(const glm::vec3& value) { _velocity = value; } /// velocity in meters bool hasVelocity() const { return _velocity != ENTITY_ITEM_ZERO_VEC3; } glm::vec3 getGravityInDomainUnits() const { return _gravity / (float)TREE_SCALE; } /// gravity in domain scale units (0.0-1.0) per second squared - const glm::vec3& getGravityInMeters() const { return _gravity; } /// get gravity in meters + const glm::vec3& getGravity() const { return _gravity; } /// get gravity in meters void setGravityInDomainUnits(const glm::vec3& value) { _gravity = value * (float)TREE_SCALE; } /// gravity in domain scale units (0.0-1.0) per second squared - void setGravityInMeters(const glm::vec3& value) { _gravity = value; } /// gravity in meters + void setGravity(const glm::vec3& value) { _gravity = value; } /// gravity in meters bool hasGravity() const { return _gravity != ENTITY_ITEM_ZERO_VEC3; } float getDamping() const { return _damping; } @@ -217,7 +215,7 @@ public: // position, size, and bounds related helpers AACube getMaximumAACube() const; AACube getMinimumAACube() const; - AABox getAABoxInMeters() const; /// axis aligned bounding box in world-frame (meters) + AABox getAABox() const; /// axis aligned bounding box in world-frame (meters) AABox getAABoxInDomainUnits() const; /// axis aligned bounding box in domain scale units (0.0 - 1.0) const QString& getScript() const { return _script; } @@ -254,9 +252,9 @@ public: void setUserData(const QString& value) { _userData = value; } // TODO: get rid of users of getRadius()... - float getRadiusInMeters() const; + float getRadius() const; - virtual bool containsInMeters(const glm::vec3& point) const { return getAABoxInMeters().contains(point); } + virtual bool contains(const glm::vec3& point) const { return getAABox().contains(point); } virtual bool containsInDomainUnits(const glm::vec3& point) const { return getAABoxInDomainUnits().contains(point); } virtual void computeShapeInfo(ShapeInfo& info) const; @@ -265,17 +263,17 @@ public: // updateFoo() methods to be used when changes need to be accumulated in the _dirtyFlags void updatePositionInDomainUnits(const glm::vec3& value); - void updatePositionInMeters(const glm::vec3& value); + void updatePosition(const glm::vec3& value); void updateDimensionsInDomainUnits(const glm::vec3& value); - void updateDimensionsInMeters(const glm::vec3& value); + void updateDimensions(const glm::vec3& value); void updateRotation(const glm::quat& rotation); void updateDensity(float value); void updateMass(float value); void updateVelocityInDomainUnits(const glm::vec3& value); - void updateVelocityInMeters(const glm::vec3& value); + void updateVelocity(const glm::vec3& value); void updateDamping(float value); void updateGravityInDomainUnits(const glm::vec3& value); - void updateGravityInMeters(const glm::vec3& value); + void updateGravity(const glm::vec3& value); void updateAngularVelocity(const glm::vec3& value); void updateAngularDamping(float value); void updateIgnoreForCollisions(bool value); diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index c6414f620b..53a39e1a99 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -80,7 +80,6 @@ EntityItemProperties::EntityItemProperties() : } EntityItemProperties::~EntityItemProperties() { - std::cout << "adebug delete properties" << std::endl; // adebug } void EntityItemProperties::setSittingPoints(const QVector& sittingPoints) { @@ -296,7 +295,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine) cons sittingPoints.setProperty("length", _sittingPoints.size()); COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(sittingPoints, sittingPoints); // gettable, but not settable - AABox aaBox = getAABoxInMeters(); + AABox aaBox = getAABox(); QScriptValue boundingBox = engine->newObject(); QScriptValue bottomRightNear = vec3toScriptValue(engine, aaBox.getCorner()); QScriptValue topFarLeft = vec3toScriptValue(engine, aaBox.calcTopFarLeft()); @@ -821,16 +820,10 @@ void EntityItemProperties::markAllChanged() { _shapeTypeChanged = true; } -AACube EntityItemProperties::getMaximumAACubeInTreeUnits() const { - AACube maxCube = getMaximumAACubeInMeters(); - maxCube.scale(1.0f / (float)TREE_SCALE); - return maxCube; -} - /// The maximum bounding cube for the entity, independent of it's rotation. /// This accounts for the registration point (upon which rotation occurs around). /// -AACube EntityItemProperties::getMaximumAACubeInMeters() const { +AACube EntityItemProperties::getMaximumAACube() const { // * we know that the position is the center of rotation glm::vec3 centerOfRotation = _position; // also where _registration point is @@ -854,7 +847,7 @@ AACube EntityItemProperties::getMaximumAACubeInMeters() const { } // The minimum bounding box for the entity. -AABox EntityItemProperties::getAABoxInMeters() const { +AABox EntityItemProperties::getAABox() const { // _position represents the position of the registration point. glm::vec3 registrationRemainder = glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint; diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index 9bf3c93c2b..bf10fd4c87 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -129,9 +129,8 @@ public: /// used by EntityScriptingInterface to return EntityItemProperties for unknown models void setIsUnknownID() { _id = UNKNOWN_ENTITY_ID; _idSet = true; } - AACube getMaximumAACubeInTreeUnits() const; - AACube getMaximumAACubeInMeters() const; - AABox getAABoxInMeters() const; + AACube getMaximumAACube() const; + AABox getAABox() const; void debugDump() const; void setLastEdited(quint64 usecTime); diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 24bad08b6b..5ef0db57ec 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -206,7 +206,7 @@ QVector EntityScriptingInterface::findEntities(const glm::vec3& ce if (_entityTree) { _entityTree->lockForRead(); QVector entities; - _entityTree->findEntitiesInMeters(center, radius, entities); + _entityTree->findEntities(center, radius, entities); _entityTree->unlock(); foreach (const EntityItem* entity, entities) { diff --git a/libraries/entities/src/EntitySimulation.cpp b/libraries/entities/src/EntitySimulation.cpp index f7d6c55803..758cd6771a 100644 --- a/libraries/entities/src/EntitySimulation.cpp +++ b/libraries/entities/src/EntitySimulation.cpp @@ -87,7 +87,7 @@ void EntitySimulation::sortEntitiesThatMoved() { // External changes to entity position/shape are expected to be sorted outside of the EntitySimulation. PerformanceTimer perfTimer("sortingEntities"); MovingEntitiesOperator moveOperator(_entityTree); - AACube domainBounds(glm::vec3(0.0f,0.0f,0.0f), 1.0f); + AACube domainBounds(glm::vec3(0.0f,0.0f,0.0f), (float)TREE_SCALE); QSet::iterator itemItr = _entitiesToBeSorted.begin(); while (itemItr != _entitiesToBeSorted.end()) { EntityItem* entity = *itemItr; @@ -150,7 +150,7 @@ void EntitySimulation::entityChanged(EntityItem* entity) { bool wasRemoved = false; uint32_t dirtyFlags = entity->getDirtyFlags(); if (dirtyFlags & EntityItem::DIRTY_POSITION) { - AACube domainBounds(glm::vec3(0.0f,0.0f,0.0f), 1.0f); + AACube domainBounds(glm::vec3(0.0f,0.0f,0.0f), (float)TREE_SCALE); AACube newCube = entity->getMaximumAACube(); if (!domainBounds.touches(newCube)) { qDebug() << "Entity " << entity->getEntityItemID() << " moved out of domain bounds."; diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 9e75615117..ba9a4c61e8 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -424,9 +424,7 @@ bool EntityTree::findNearPointOperation(OctreeElement* element, void* extraData) EntityTreeElement* entityTreeElement = static_cast(element); glm::vec3 penetration; - AACube cube = entityTreeElement->getAACube(); - cube.scale((float)TREE_SCALE); - bool sphereIntersection = cube.findSpherePenetration(args->position, args->targetRadius, penetration); + bool sphereIntersection = entityTreeElement->getAACube().findSpherePenetration(args->position, args->targetRadius, penetration); // If this entityTreeElement contains the point, then search it... if (sphereIntersection) { @@ -434,7 +432,7 @@ bool EntityTree::findNearPointOperation(OctreeElement* element, void* extraData) // we may have gotten NULL back, meaning no entity was available if (thisClosestEntity) { - glm::vec3 entityPosition = thisClosestEntity->getPositionInMeters(); + glm::vec3 entityPosition = thisClosestEntity->getPosition(); float distanceFromPointToEntity = glm::distance(entityPosition, args->position); // If we're within our target radius @@ -457,7 +455,6 @@ bool EntityTree::findNearPointOperation(OctreeElement* element, void* extraData) } const EntityItem* EntityTree::findClosestEntity(glm::vec3 position, float targetRadius) { - // position and targetRadius are in meters, so we need to convert to TreeUnits in FindNearPointArgs FindNearPointArgs args = { position, targetRadius, false, NULL, FLT_MAX }; lockForRead(); // NOTE: This should use recursion, since this is a spatial operation @@ -477,9 +474,7 @@ public: bool EntityTree::findInSphereOperation(OctreeElement* element, void* extraData) { FindAllNearPointArgs* args = static_cast(extraData); glm::vec3 penetration; - AACube cube = element->getAACube(); - cube.scale((float)TREE_SCALE); - bool sphereIntersection = cube.findSpherePenetration(args->position, args->targetRadius, penetration); + bool sphereIntersection = element->getAACube().findSpherePenetration(args->position, args->targetRadius, penetration); // If this element contains the point, then search it... if (sphereIntersection) { @@ -493,8 +488,7 @@ bool EntityTree::findInSphereOperation(OctreeElement* element, void* extraData) } // NOTE: assumes caller has handled locking -void EntityTree::findEntitiesInMeters(const glm::vec3& center, float radius, QVector& foundEntities) { - // position and targetRadius are in meters, so we need to convert to TreeUnits in FindNearPointArgs +void EntityTree::findEntities(const glm::vec3& center, float radius, QVector& foundEntities) { FindAllNearPointArgs args = { center, radius }; // NOTE: This should use recursion, since this is a spatial operation recurseTreeWithOperation(findInSphereOperation, &args); @@ -515,9 +509,7 @@ public: bool EntityTree::findInCubeOperation(OctreeElement* element, void* extraData) { FindEntitiesInCubeArgs* args = static_cast(extraData); - AACube elementCube = element->getAACube(); - elementCube.scale((float)TREE_SCALE); - if (elementCube.touches(args->_cube)) { + if (element->getAACube().touches(args->_cube)) { EntityTreeElement* entityTreeElement = static_cast(element); entityTreeElement->getEntities(args->_cube, args->_foundEntities); return true; diff --git a/libraries/entities/src/EntityTree.h b/libraries/entities/src/EntityTree.h index 852d07d20f..d897e6628e 100644 --- a/libraries/entities/src/EntityTree.h +++ b/libraries/entities/src/EntityTree.h @@ -109,7 +109,7 @@ public: /// \param radius the radius of the sphere in world-frame (meters) /// \param foundEntities[out] vector of const EntityItem* /// \remark Side effect: any initial contents in foundEntities will be lost - void findEntitiesInMeters(const glm::vec3& center, float radius, QVector& foundEntities); + void findEntities(const glm::vec3& center, float radius, QVector& foundEntities); /// finds all entities that touch a cube /// \param cube the query cube in world-frame (meters) diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index e32434b4c6..fbd377cfeb 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -22,15 +22,9 @@ EntityTreeElement::EntityTreeElement(unsigned char* octalCode) : OctreeElement() }; EntityTreeElement::~EntityTreeElement() { - int bar = 0; _octreeMemoryUsage -= sizeof(EntityTreeElement); - bar = 1; - std::cout << "adebug EntityTreeElement " << (void*)(this) << " deletes old entityItems = " << (void*)(_entityItems) << std::endl; // adebug delete _entityItems; - bar = 2; _entityItems = NULL; - bar = 3; - std::cout << "adebug bar = " << bar << std::endl; // adebug } // This will be called primarily on addChildAt(), which means we're adding a child of our @@ -45,7 +39,6 @@ OctreeElement* EntityTreeElement::createNewElement(unsigned char* octalCode) { void EntityTreeElement::init(unsigned char* octalCode) { OctreeElement::init(octalCode); _entityItems = new QList; - std::cout << "adebug EntityTreeElement " << (void*)(this) << " gets new entityItems = " << (void*)(_entityItems) << std::endl; // adebug _octreeMemoryUsage += sizeof(EntityTreeElement); } @@ -57,7 +50,7 @@ EntityTreeElement* EntityTreeElement::addChildAtIndex(int index) { void EntityTreeElement::debugExtraEncodeData(EncodeBitstreamParams& params) const { qDebug() << "EntityTreeElement::debugExtraEncodeData()... "; - qDebug() << " element:" << getAACube(); + qDebug() << " element:" << _cube; OctreeElementExtraEncodeData* extraEncodeData = params.extraEncodeData; assert(extraEncodeData); // EntityTrees always require extra encode data on their encoding passes @@ -166,7 +159,7 @@ void EntityTreeElement::elementEncodeComplete(EncodeBitstreamParams& params, Oct const bool wantDebug = false; if (wantDebug) { - qDebug() << "EntityTreeElement::elementEncodeComplete() element:" << getAACube(); + qDebug() << "EntityTreeElement::elementEncodeComplete() element:" << _cube; } OctreeElementExtraEncodeData* extraEncodeData = params.extraEncodeData; @@ -201,7 +194,7 @@ void EntityTreeElement::elementEncodeComplete(EncodeBitstreamParams& params, Oct = static_cast(extraEncodeData->value(childElement)); if (wantDebug) { - qDebug() << "checking child: " << childElement->getAACube(); + qDebug() << "checking child: " << childElement->_cube; qDebug() << " childElement->isLeaf():" << childElement->isLeaf(); qDebug() << " childExtraEncodeData->elementCompleted:" << childExtraEncodeData->elementCompleted; qDebug() << " childExtraEncodeData->subtreeCompleted:" << childExtraEncodeData->subtreeCompleted; @@ -222,7 +215,7 @@ void EntityTreeElement::elementEncodeComplete(EncodeBitstreamParams& params, Oct } if (wantDebug) { - qDebug() << "for this element: " << getAACube(); + qDebug() << "for this element: " << _cube; qDebug() << " WAS elementCompleted:" << thisExtraEncodeData->elementCompleted; qDebug() << " WAS subtreeCompleted:" << thisExtraEncodeData->subtreeCompleted; } @@ -309,7 +302,6 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData // the entity may not be in view and then in view a frame later, let the client side handle it's view // frustum culling on rendering. AACube entityCube = entity->getMaximumAACube(); - entityCube.scale(TREE_SCALE); if (params.viewFrustum->cubeInFrustum(entityCube) == ViewFrustum::OUTSIDE) { includeThisEntity = false; // out of view, don't include it } @@ -448,14 +440,14 @@ bool EntityTreeElement::bestFitBounds(const AABox& bounds) const { } bool EntityTreeElement::containsBounds(const glm::vec3& minPoint, const glm::vec3& maxPoint) const { - glm::vec3 clampedMin = glm::clamp(minPoint, 0.0f, 1.0f); - glm::vec3 clampedMax = glm::clamp(maxPoint, 0.0f, 1.0f); + glm::vec3 clampedMin = glm::clamp(minPoint, 0.0f, (float)TREE_SCALE); + glm::vec3 clampedMax = glm::clamp(maxPoint, 0.0f, (float)TREE_SCALE); return _cube.contains(clampedMin) && _cube.contains(clampedMax); } bool EntityTreeElement::bestFitBounds(const glm::vec3& minPoint, const glm::vec3& maxPoint) const { - glm::vec3 clampedMin = glm::clamp(minPoint, 0.0f, 1.0f); - glm::vec3 clampedMax = glm::clamp(maxPoint, 0.0f, 1.0f); + glm::vec3 clampedMin = glm::clamp(minPoint, 0.0f, (float)TREE_SCALE); + glm::vec3 clampedMax = glm::clamp(maxPoint, 0.0f, (float)TREE_SCALE); if (_cube.contains(clampedMin) && _cube.contains(clampedMax)) { @@ -476,7 +468,7 @@ bool EntityTreeElement::bestFitBounds(const glm::vec3& minPoint, const glm::vec3 return false; } -bool EntityTreeElement::findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, +bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking, float distanceToElementCube) { @@ -492,7 +484,7 @@ bool EntityTreeElement::findDetailedRayIntersectionInMeters(const glm::vec3& ori while(entityItr != entityEnd) { EntityItem* entity = (*entityItr); - AABox entityBox = entity->getAABoxInMeters(); + AABox entityBox = entity->getAABox(); float localDistance; BoxFace localFace; @@ -501,11 +493,11 @@ bool EntityTreeElement::findDetailedRayIntersectionInMeters(const glm::vec3& ori // extents is the entity relative, scaled, centered extents of the entity glm::mat4 rotation = glm::mat4_cast(entity->getRotation()); - glm::mat4 translation = glm::translate(entity->getPositionInMeters()); + glm::mat4 translation = glm::translate(entity->getPosition()); glm::mat4 entityToWorldMatrix = translation * rotation; glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix); - glm::vec3 dimensions = entity->getDimensionsInMeters(); + glm::vec3 dimensions = entity->getDimensions(); glm::vec3 registrationPoint = entity->getRegistrationPoint(); glm::vec3 corner = -(dimensions * registrationPoint); @@ -520,7 +512,7 @@ bool EntityTreeElement::findDetailedRayIntersectionInMeters(const glm::vec3& ori if (localDistance < distance) { // now ask the entity if we actually intersect if (entity->supportsDetailedRayIntersection()) { - if (entity->findDetailedRayIntersectionInMeters(origin, direction, keepSearching, element, localDistance, + if (entity->findDetailedRayIntersection(origin, direction, keepSearching, element, localDistance, localFace, intersectedObject, precisionPicking)) { if (localDistance < distance) { @@ -556,8 +548,8 @@ bool EntityTreeElement::findSpherePenetration(const glm::vec3& center, float rad QList::const_iterator entityEnd = _entityItems->end(); while(entityItr != entityEnd) { EntityItem* entity = (*entityItr); - glm::vec3 entityCenter = entity->getPositionInMeters(); - float entityRadius = entity->getRadiusInMeters(); + glm::vec3 entityCenter = entity->getPosition(); + float entityRadius = entity->getRadius(); // don't penetrate yourself if (entityCenter == center && entityRadius == radius) { @@ -592,7 +584,7 @@ const EntityItem* EntityTreeElement::getClosestEntity(glm::vec3 position) const float closestEntityDistance = FLT_MAX; uint16_t numberOfEntities = _entityItems->size(); for (uint16_t i = 0; i < numberOfEntities; i++) { - float distanceToEntity = glm::distance(position, (*_entityItems)[i]->getPositionInMeters()); + float distanceToEntity = glm::distance(position, (*_entityItems)[i]->getPosition()); if (distanceToEntity < closestEntityDistance) { closestEntity = (*_entityItems)[i]; } @@ -605,8 +597,8 @@ void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searc uint16_t numberOfEntities = _entityItems->size(); for (uint16_t i = 0; i < numberOfEntities; i++) { const EntityItem* entity = (*_entityItems)[i]; - float distance = glm::length(entity->getPositionInMeters() - searchPosition); - if (distance < searchRadius + entity->getRadiusInMeters()) { + float distance = glm::length(entity->getPosition() - searchPosition); + if (distance < searchRadius + entity->getRadius()) { foundEntities.push_back(entity); } } @@ -619,11 +611,11 @@ void EntityTreeElement::getEntities(const AACube& box, QVector& fou AACube entityCube; while(entityItr != entityEnd) { EntityItem* entity = (*entityItr); - float radius = entity->getRadiusInMeters(); + float radius = entity->getRadius(); // NOTE: we actually do cube-cube collision queries here, which is sloppy but good enough for now // TODO: decide whether to replace entityCube-cube query with sphere-cube (requires a square root // but will be slightly more accurate). - entityCube.setBox(entity->getPositionInMeters() - glm::vec3(radius), 2.0f * radius); + entityCube.setBox(entity->getPosition() - glm::vec3(radius), 2.0f * radius); if (entityCube.touches(box)) { foundEntities.push_back(entity); } @@ -830,9 +822,7 @@ bool EntityTreeElement::pruneChildren() { void EntityTreeElement::debugDump() { qDebug() << "EntityTreeElement..."; - AACube temp = getAACube(); - temp.scale((float)TREE_SCALE); - qDebug() << " cube:" << temp; + qDebug() << " cube:" << _cube; qDebug() << " has child elements:" << getChildCount(); if (_entityItems->size()) { qDebug() << " has entities:" << _entityItems->size(); diff --git a/libraries/entities/src/EntityTreeElement.h b/libraries/entities/src/EntityTreeElement.h index ad91010b0b..0b28dd30d0 100644 --- a/libraries/entities/src/EntityTreeElement.h +++ b/libraries/entities/src/EntityTreeElement.h @@ -73,7 +73,6 @@ public: class EntityTreeElement : public OctreeElement { friend class EntityTree; // to allow createElement to new us... - EntityTreeElement(); EntityTreeElement(unsigned char* octalCode = NULL); virtual OctreeElement* createNewElement(unsigned char* octalCode = NULL); @@ -136,7 +135,7 @@ public: virtual bool deleteApproved() const { return !hasEntities(); } virtual bool canRayIntersect() const { return hasEntities(); } - virtual bool findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, + virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking, float distanceToElementCube); diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 5a95fe4e33..f30d43c7d5 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -255,8 +255,8 @@ void ModelEntityItem::update(const quint64& now) { void ModelEntityItem::debugDump() const { qDebug() << "ModelEntityItem id:" << getEntityItemID(); qDebug() << " edited ago:" << getEditedAgo(); - qDebug() << " position:" << getPositionInMeters(); - qDebug() << " dimensions:" << getDimensionsInMeters(); + qDebug() << " position:" << getPosition(); + qDebug() << " dimensions:" << getDimensions(); qDebug() << " model URL:" << getModelURL(); } diff --git a/libraries/entities/src/MovingEntitiesOperator.cpp b/libraries/entities/src/MovingEntitiesOperator.cpp index 48ba8e4ec2..7cace205e1 100644 --- a/libraries/entities/src/MovingEntitiesOperator.cpp +++ b/libraries/entities/src/MovingEntitiesOperator.cpp @@ -51,7 +51,7 @@ MovingEntitiesOperator::~MovingEntitiesOperator() { void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACube& newCube) { EntityTreeElement* oldContainingElement = _tree->getContainingElement(entity->getEntityItemID()); - AABox newCubeClamped = newCube.clamp(0.0f, 1.0f); + AABox newCubeClamped = newCube.clamp(0.0f, (float)TREE_SCALE); if (_wantDebug) { qDebug() << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------"; @@ -114,7 +114,7 @@ bool MovingEntitiesOperator::shouldRecurseSubTree(OctreeElement* element) { // If we don't have an old entity, then we don't contain the entity, otherwise // check the bounds if (_entitiesToMove.size() > 0) { - AACube elementCube = element->getAACube(); + const AACube& elementCube = element->getAACube(); int detailIndex = 0; foreach(const EntityToMoveDetails& details, _entitiesToMove) { diff --git a/libraries/entities/src/MovingEntitiesOperator.h b/libraries/entities/src/MovingEntitiesOperator.h index fefda3328e..760b001081 100644 --- a/libraries/entities/src/MovingEntitiesOperator.h +++ b/libraries/entities/src/MovingEntitiesOperator.h @@ -15,11 +15,11 @@ class EntityToMoveDetails { public: EntityItem* entity; - AACube oldCube; - AACube newCube; - AABox newCubeClamped; + AACube oldCube; // meters + AACube newCube; // meters + AABox newCubeClamped; // meters EntityTreeElement* oldContainingElement; - AACube oldContainingElementCube; + AACube oldContainingElementCube; // meters bool oldFound; bool newFound; }; diff --git a/libraries/entities/src/SphereEntityItem.cpp b/libraries/entities/src/SphereEntityItem.cpp index e21a2573a2..49149e78ae 100644 --- a/libraries/entities/src/SphereEntityItem.cpp +++ b/libraries/entities/src/SphereEntityItem.cpp @@ -91,13 +91,13 @@ void SphereEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBi APPEND_ENTITY_PROPERTY(PROP_COLOR, appendColor, getColor()); } -bool SphereEntityItem::findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, +bool SphereEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const { // determine the ray in the frame of the entity transformed from a unit sphere - glm::mat4 translation = glm::translate(getPositionInMeters()); + glm::mat4 translation = glm::translate(getPosition()); glm::mat4 rotation = glm::mat4_cast(getRotation()); - glm::mat4 scale = glm::scale(getDimensionsInMeters()); + glm::mat4 scale = glm::scale(getDimensions()); glm::mat4 registration = glm::translate(glm::vec3(0.5f, 0.5f, 0.5f) - getRegistrationPoint()); glm::mat4 entityToWorldMatrix = translation * rotation * scale * registration; glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix); diff --git a/libraries/entities/src/SphereEntityItem.h b/libraries/entities/src/SphereEntityItem.h index f8419e75b9..f79a2db7ff 100644 --- a/libraries/entities/src/SphereEntityItem.h +++ b/libraries/entities/src/SphereEntityItem.h @@ -56,7 +56,7 @@ public: virtual ShapeType getShapeType() const { return SHAPE_TYPE_SPHERE; } virtual bool supportsDetailedRayIntersection() const { return true; } - virtual bool findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, + virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const; diff --git a/libraries/entities/src/TextEntityItem.cpp b/libraries/entities/src/TextEntityItem.cpp index d008bceccc..2b35ee9a59 100644 --- a/libraries/entities/src/TextEntityItem.cpp +++ b/libraries/entities/src/TextEntityItem.cpp @@ -42,7 +42,7 @@ TextEntityItem::TextEntityItem(const EntityItemID& entityItemID, const EntityIte const float TEXT_ENTITY_ITEM_FIXED_DEPTH = 0.01f; -void TextEntityItem::setDimensionsInMeters(const glm::vec3& value) { +void TextEntityItem::setDimensions(const glm::vec3& value) { // NOTE: Text Entities always have a "depth" of 1cm. _dimensions = glm::vec3(value.x, value.y, TEXT_ENTITY_ITEM_FIXED_DEPTH); } @@ -128,7 +128,7 @@ void TextEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits } -bool TextEntityItem::findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, +bool TextEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const { @@ -142,7 +142,7 @@ bool TextEntityItem::findDetailedRayIntersectionInMeters(const glm::vec3& origin const glm::vec3 UNROTATED_NORMAL(0.0f, 0.0f, -1.0f); glm::vec3 normal = _rotation * UNROTATED_NORMAL; plane.setNormal(normal); - plane.setPoint(getPositionInMeters()); // the position is definitely a point on our plane + plane.setPoint(getPosition()); // the position is definitely a point on our plane bool intersects = plane.findRayIntersection(rayInfo); @@ -151,11 +151,11 @@ bool TextEntityItem::findDetailedRayIntersectionInMeters(const glm::vec3& origin // now we know the point the ray hit our plane glm::mat4 rotation = glm::mat4_cast(getRotation()); - glm::mat4 translation = glm::translate(getPositionInMeters()); + glm::mat4 translation = glm::translate(getPosition()); glm::mat4 entityToWorldMatrix = translation * rotation; glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix); - glm::vec3 dimensions = getDimensionsInMeters(); + glm::vec3 dimensions = getDimensions(); glm::vec3 registrationPoint = getRegistrationPoint(); glm::vec3 corner = -(dimensions * registrationPoint); AABox entityFrameBox(corner, dimensions); diff --git a/libraries/entities/src/TextEntityItem.h b/libraries/entities/src/TextEntityItem.h index 1ee9c2c194..044975bdc8 100644 --- a/libraries/entities/src/TextEntityItem.h +++ b/libraries/entities/src/TextEntityItem.h @@ -23,7 +23,7 @@ public: ALLOW_INSTANTIATION // This class can be instantiated /// set dimensions in domain scale units (0.0 - 1.0) this will also reset radius appropriately - virtual void setDimensionsInMeters(const glm::vec3& value); + virtual void setDimensions(const glm::vec3& value); virtual void setDimensionsInDomainUnits(const glm::vec3& value); virtual ShapeType getShapeType() const { return SHAPE_TYPE_BOX; } @@ -47,7 +47,7 @@ public: EntityPropertyFlags& propertyFlags, bool overwriteLocalData); virtual bool supportsDetailedRayIntersection() const { return true; } - virtual bool findDetailedRayIntersectionInMeters(const glm::vec3& origin, const glm::vec3& direction, + virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face, void** intersectedObject, bool precisionPicking) const; diff --git a/libraries/entities/src/UpdateEntityOperator.cpp b/libraries/entities/src/UpdateEntityOperator.cpp index 43052c6a73..f93be2f563 100644 --- a/libraries/entities/src/UpdateEntityOperator.cpp +++ b/libraries/entities/src/UpdateEntityOperator.cpp @@ -46,7 +46,7 @@ UpdateEntityOperator::UpdateEntityOperator(EntityTree* tree, // which can handle all potential rotations? // the getMaximumAACube is the relaxed form. _oldEntityCube = _existingEntity->getMaximumAACube(); - _oldEntityBox = _oldEntityCube.clamp(0.0f, 1.0f); // clamp to domain bounds + _oldEntityBox = _oldEntityCube.clamp(0.0f, (float)TREE_SCALE); // clamp to domain bounds // If the old properties doesn't contain the properties required to calculate a bounding box, // get them from the existing entity. Registration point is required to correctly calculate @@ -59,8 +59,8 @@ UpdateEntityOperator::UpdateEntityOperator(EntityTree* tree, // get the old property value and set it in our properties in order for our bounds // calculations to work. if (_properties.containsPositionChange() && !_properties.containsDimensionsChange()) { - glm::vec3 oldDimensionsInMeters = _existingEntity->getDimensionsInMeters(); - _properties.setDimensions(oldDimensionsInMeters); + glm::vec3 oldDimensions= _existingEntity->getDimensions(); + _properties.setDimensions(oldDimensions); if (_wantDebug) { qDebug() << " ** setting properties dimensions - had position change, no dimension change **"; @@ -68,8 +68,8 @@ UpdateEntityOperator::UpdateEntityOperator(EntityTree* tree, } if (!_properties.containsPositionChange() && _properties.containsDimensionsChange()) { - glm::vec3 oldPositionInMeters = _existingEntity->getPositionInMeters(); - _properties.setPosition(oldPositionInMeters); + glm::vec3 oldPosition= _existingEntity->getPosition(); + _properties.setPosition(oldPosition); if (_wantDebug) { qDebug() << " ** setting properties position - had dimensions change, no position change **"; @@ -114,7 +114,7 @@ UpdateEntityOperator::UpdateEntityOperator(EntityTree* tree, } } else { - _newEntityCube = _properties.getMaximumAACubeInTreeUnits(); + _newEntityCube = _properties.getMaximumAACube(); _removeOld = true; // our properties are going to move us, so remember this for later processing if (_wantDebug) { @@ -122,7 +122,7 @@ UpdateEntityOperator::UpdateEntityOperator(EntityTree* tree, } } - _newEntityBox = _newEntityCube.clamp(0.0f, 1.0f); // clamp to domain bounds + _newEntityBox = _newEntityCube.clamp(0.0f, (float)TREE_SCALE); // clamp to domain bounds if (_wantDebug) { diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 3b43a4a5d2..6b8f8c31e8 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -274,7 +274,7 @@ int Octree::readElementData(OctreeElement* destinationElement, const unsigned ch if (destinationElement->getScale() < SCALE_AT_DANGEROUSLY_DEEP_RECURSION) { qDebug() << "UNEXPECTED: readElementData() destination element is unreasonably small [" - << destinationElement->getScale() * (float)TREE_SCALE << " meters] " + << destinationElement->getScale() << " meters] " << " Discarding " << bytesAvailable << " remaining bytes."; return bytesAvailable; // assume we read the entire buffer... } @@ -748,12 +748,8 @@ public: bool findSpherePenetrationOp(OctreeElement* element, void* extraData) { SphereArgs* args = static_cast(extraData); - // the details in args is in meters (world-frame) so we have to scale the element cube up - AACube box = element->getAACube(); - box.scale((float)TREE_SCALE); - // coarse check against bounds - if (!box.expandedContains(args->center, args->radius)) { + if (!element->getAACube().expandedContains(args->center, args->radius)) { return false; } if (element->hasContent()) { @@ -837,14 +833,12 @@ bool findCapsulePenetrationOp(OctreeElement* element, void* extraData) { CapsuleArgs* args = static_cast(extraData); // coarse check against bounds - AACube box = element->getAACube(); - box.scale((float)TREE_SCALE); - if (!box.expandedIntersectsSegment(args->start, args->end, args->radius)) { + if (!element->getAACube().expandedIntersectsSegment(args->start, args->end, args->radius)) { return false; } if (element->hasContent()) { glm::vec3 nodePenetration; - if (box.findCapsulePenetration(args->start, args->end, args->radius, nodePenetration)) { + if (element->getAACube().findCapsulePenetration(args->start, args->end, args->radius, nodePenetration)) { args->penetration = addPenetrations(args->penetration, nodePenetration); args->found = true; } @@ -872,8 +866,7 @@ bool findContentInCubeOp(OctreeElement* element, void* extraData) { ContentArgs* args = static_cast(extraData); // coarse check against bounds - AACube cube = element->getAACube(); - cube.scale(TREE_SCALE); + const AACube& cube = element->getAACube(); if (!cube.touches(args->cube)) { return false; } @@ -940,8 +933,7 @@ public: // Find the smallest colored voxel enclosing a point (if there is one) bool getElementEnclosingOperation(OctreeElement* element, void* extraData) { GetElementEnclosingArgs* args = static_cast(extraData); - AACube elementBox = element->getAACube(); - if (elementBox.contains(args->point)) { + if (element->getAACube().contains(args->point)) { if (element->hasContent() && element->isLeaf()) { // we've reached a solid leaf containing the point, return the element. args->element = element; @@ -1207,9 +1199,8 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element, // If the user also asked for occlusion culling, check if this element is occluded, but only if it's not a leaf. // leaf occlusion is handled down below when we check child nodes if (params.wantOcclusionCulling && !element->isLeaf()) { - AACube voxelBox = element->getAACube(); - voxelBox.scale(TREE_SCALE); - OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(params.viewFrustum->getProjectedPolygon(voxelBox)); + OctreeProjectedPolygon* voxelPolygon = + new OctreeProjectedPolygon(params.viewFrustum->getProjectedPolygon(element->getAACube())); // In order to check occlusion culling, the shadow has to be "all in view" otherwise, we will ignore occlusion // culling and proceed as normal @@ -1360,10 +1351,8 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element, if (params.wantOcclusionCulling && childElement->isLeaf()) { // Don't check occlusion here, just add them to our distance ordered array... - AACube voxelBox = childElement->getAACube(); - voxelBox.scale(TREE_SCALE); OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon( - params.viewFrustum->getProjectedPolygon(voxelBox)); + params.viewFrustum->getProjectedPolygon(childElement->getAACube())); // In order to check occlusion culling, the shadow has to be "all in view" otherwise, we ignore occlusion // culling and proceed as normal diff --git a/libraries/octree/src/Octree.h b/libraries/octree/src/Octree.h index 8774ebe55b..a2265e38ed 100644 --- a/libraries/octree/src/Octree.h +++ b/libraries/octree/src/Octree.h @@ -270,6 +270,9 @@ public: void recurseTreeWithOperation(RecurseOctreeOperation operation, void* extraData = NULL); void recurseTreeWithPostOperation(RecurseOctreeOperation operation, void* extraData = NULL); + /// \param operation type of operation + /// \param point point in world-frame (meters) + /// \param extraData hook for user data to be interpreted by special context void recurseTreeWithOperationDistanceSorted(RecurseOctreeOperation operation, const glm::vec3& point, void* extraData = NULL); @@ -308,8 +311,13 @@ public: bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration, Octree::lockType lockType = Octree::TryLock, bool* accurateResult = NULL); + /// \param cube query cube in world-frame (meters) + /// \param[out] cubes list of cubes (world-frame) of child elements that have content bool findContentInCube(const AACube& cube, CubeList& cubes); + /// \param point query point in world-frame (meters) + /// \param lockType how to lock the tree (Lock, TryLock, NoLock) + /// \param[out] accurateResult pointer to output result, will be set "true" or "false" if non-null OctreeElement* getElementEnclosingPoint(const glm::vec3& point, Octree::lockType lockType = Octree::TryLock, bool* accurateResult = NULL); diff --git a/libraries/octree/src/OctreeElement.cpp b/libraries/octree/src/OctreeElement.cpp index 5e6fd0dde3..c8564ee5cb 100644 --- a/libraries/octree/src/OctreeElement.cpp +++ b/libraries/octree/src/OctreeElement.cpp @@ -194,14 +194,14 @@ void OctreeElement::setShouldRender(bool shouldRender) { } void OctreeElement::calculateAACube() { - glm::vec3 corner; - // copy corner into cube - copyFirstVertexForCode(getOctalCode(),(float*)&corner); + glm::vec3 corner; + copyFirstVertexForCode(getOctalCode(), (float*)&corner); // this tells you the "size" of the voxel - float voxelScale = 1 / powf(2, numberOfThreeBitSectionsInCode(getOctalCode())); - _cube.setBox(corner,voxelScale); + float voxelScale = (float)TREE_SCALE / powf(2.0f, numberOfThreeBitSectionsInCode(getOctalCode())); + corner *= (float)TREE_SCALE; + _cube.setBox(corner, voxelScale); } void OctreeElement::deleteChildAtIndex(int childIndex) { @@ -1221,9 +1221,7 @@ float OctreeElement::getEnclosingRadius() const { } ViewFrustum::location OctreeElement::inFrustum(const ViewFrustum& viewFrustum) const { - AACube cube = _cube; // use temporary cube so we can scale it - cube.scale(TREE_SCALE); - return viewFrustum.cubeInFrustum(cube); + return viewFrustum.cubeInFrustum(_cube); } // There are two types of nodes for which we want to "render" @@ -1257,16 +1255,13 @@ bool OctreeElement::calculateShouldRender(const ViewFrustum* viewFrustum, float // does as much math as possible in voxel scale and then scales up to TREE_SCALE at end float OctreeElement::furthestDistanceToCamera(const ViewFrustum& viewFrustum) const { glm::vec3 furthestPoint; - AACube cube = getAACube(); - cube.scale((float)TREE_SCALE); - viewFrustum.getFurthestPointFromCamera(cube, furthestPoint); + viewFrustum.getFurthestPointFromCamera(_cube, furthestPoint); glm::vec3 temp = viewFrustum.getPosition() - furthestPoint; - float distanceToFurthestPoint = sqrtf(glm::dot(temp, temp)); - return distanceToFurthestPoint; + return sqrtf(glm::dot(temp, temp)); } float OctreeElement::distanceToCamera(const ViewFrustum& viewFrustum) const { - glm::vec3 center = _cube.calcCenter() * (float)TREE_SCALE; + glm::vec3 center = _cube.calcCenter(); glm::vec3 temp = viewFrustum.getPosition() - center; float distanceToVoxelCenter = sqrtf(glm::dot(temp, temp)); return distanceToVoxelCenter; @@ -1339,14 +1334,12 @@ bool OctreeElement::findRayIntersection(const glm::vec3& origin, const glm::vec3 keepSearching = true; // assume that we will continue searching after this. - AACube cube = getAACube(); - cube.scale((float)TREE_SCALE); float distanceToElementCube = std::numeric_limits::max(); float distanceToElementDetails = distance; BoxFace localFace; // if the ray doesn't intersect with our cube, we can stop searching! - if (!cube.findRayIntersection(origin, direction, distanceToElementCube, localFace)) { + if (!_cube.findRayIntersection(origin, direction, distanceToElementCube, localFace)) { keepSearching = false; // no point in continuing to search return false; // we did not intersect } @@ -1358,7 +1351,7 @@ bool OctreeElement::findRayIntersection(const glm::vec3& origin, const glm::vec3 // if the distance to the element cube is not less than the current best distance, then it's not possible // for any details inside the cube to be closer so we don't need to consider them. - if (cube.contains(origin) || distanceToElementCube < distance) { + if (_cube.contains(origin) || distanceToElementCube < distance) { if (findDetailedRayIntersection(origin, direction, keepSearching, element, distanceToElementDetails, face, intersectedObject, precisionPicking, distanceToElementCube)) { @@ -1393,9 +1386,7 @@ bool OctreeElement::findDetailedRayIntersection(const glm::vec3& origin, const g bool OctreeElement::findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration, void** penetratedObject) const { // center and radius are in meters, so we have to scale the _cube into world-frame - AACube cube = _cube; - cube.scale((float)TREE_SCALE); - return cube.findSpherePenetration(center, radius, penetration); + return _cube.findSpherePenetration(center, radius, penetration); } // TODO: consider removing this, or switching to using getOrCreateChildElementContaining(const AACube& box)... @@ -1532,15 +1523,15 @@ int OctreeElement::getMyChildContaining(const AACube& cube) const { if (cubeScale > ourScale) { qDebug() << "UNEXPECTED -- OctreeElement::getMyChildContaining() -- (cubeScale > ourScale)"; qDebug() << " cube=" << cube; - qDebug() << " elements AACube=" << getAACube(); + qDebug() << " elements AACube=" << _cube; qDebug() << " cubeScale=" << cubeScale; qDebug() << " ourScale=" << ourScale; assert(false); } // Determine which of our children the minimum and maximum corners of the cube live in... - glm::vec3 cubeCornerMinimum = glm::clamp(cube.getCorner(), 0.0f, 1.0f); - glm::vec3 cubeCornerMaximum = glm::clamp(cube.calcTopFarLeft(), 0.0f, 1.0f); + glm::vec3 cubeCornerMinimum = glm::clamp(cube.getCorner(), 0.0f, (float)TREE_SCALE); + glm::vec3 cubeCornerMaximum = glm::clamp(cube.calcTopFarLeft(), 0.0f, (float)TREE_SCALE); if (_cube.contains(cubeCornerMinimum) && _cube.contains(cubeCornerMaximum)) { int childIndexCubeMinimum = getMyChildContainingPoint(cubeCornerMinimum); diff --git a/libraries/octree/src/OctreeHeadlessViewer.cpp b/libraries/octree/src/OctreeHeadlessViewer.cpp index 8fe4fbd4d5..d47a324e07 100644 --- a/libraries/octree/src/OctreeHeadlessViewer.cpp +++ b/libraries/octree/src/OctreeHeadlessViewer.cpp @@ -101,7 +101,6 @@ void OctreeHeadlessViewer::queryOctree() { voxelDetailsForCode(rootCode, rootDetails); jurisdictions.unlock(); AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); - serverBounds.scale(TREE_SCALE); ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds); @@ -170,7 +169,6 @@ void OctreeHeadlessViewer::queryOctree() { voxelDetailsForCode(rootCode, rootDetails); jurisdictions.unlock(); AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); - serverBounds.scale(TREE_SCALE); ViewFrustum::location serverFrustumLocation = _viewFrustum.cubeInFrustum(serverBounds); if (serverFrustumLocation != ViewFrustum::OUTSIDE) { diff --git a/libraries/octree/src/OctreeRenderer.cpp b/libraries/octree/src/OctreeRenderer.cpp index c4ccd98036..187f916d35 100644 --- a/libraries/octree/src/OctreeRenderer.cpp +++ b/libraries/octree/src/OctreeRenderer.cpp @@ -22,13 +22,11 @@ OctreeRenderer::OctreeRenderer() : _managedTree(false), _viewFrustum(NULL) { - std::cout << "adebug " << (void*)(this) << " OctreeRenderer() _tree = " << (void*)(_tree) << std::endl; // adebug } void OctreeRenderer::init() { if (!_tree) { _tree = createTree(); - std::cout << "adebug " << (void*)(this) << " init _tree = " << (void*)(_tree) << std::endl; // adebug _managedTree = true; } } @@ -45,7 +43,6 @@ void OctreeRenderer::setTree(Octree* newTree) { _managedTree = false; } _tree = newTree; - std::cout << "adebug " << (void*)(this) << " setTree() _tree = " << (void*)(_tree) << std::endl; // adebug } void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode) { diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 699b4cc386..c35ace6b11 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -84,19 +84,19 @@ void EntityMotionState::getWorldTransform(btTransform& worldTrans) const { // bypass const-ness so we can remember the substep const_cast(this)->_lastKinematicSubstep = substep; } - worldTrans.setOrigin(glmToBullet(_entity->getPositionInMeters() - ObjectMotionState::getWorldOffset())); + worldTrans.setOrigin(glmToBullet(_entity->getPosition() - ObjectMotionState::getWorldOffset())); worldTrans.setRotation(glmToBullet(_entity->getRotation())); } // This callback is invoked by the physics simulation at the end of each simulation frame... // iff the corresponding RigidBody is DYNAMIC and has moved. void EntityMotionState::setWorldTransform(const btTransform& worldTrans) { - _entity->setPositionInMeters(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset()); + _entity->setPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset()); _entity->setRotation(bulletToGLM(worldTrans.getRotation())); glm::vec3 v; getVelocity(v); - _entity->setVelocityInMeters(v); + _entity->setVelocity(v); getAngularVelocity(v); // DANGER! EntityItem stores angularVelocity in degrees/sec!!! @@ -119,7 +119,7 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) { void EntityMotionState::updateObjectEasy(uint32_t flags, uint32_t frame) { if (flags & (EntityItem::DIRTY_POSITION | EntityItem::DIRTY_VELOCITY)) { if (flags & EntityItem::DIRTY_POSITION) { - _sentPosition = _entity->getPositionInMeters() - ObjectMotionState::getWorldOffset(); + _sentPosition = _entity->getPosition() - ObjectMotionState::getWorldOffset(); btTransform worldTrans; worldTrans.setOrigin(glmToBullet(_sentPosition)); @@ -156,14 +156,14 @@ void EntityMotionState::updateObjectEasy(uint32_t flags, uint32_t frame) { void EntityMotionState::updateObjectVelocities() { if (_body) { - _sentVelocity = _entity->getVelocityInMeters(); + _sentVelocity = _entity->getVelocity(); setVelocity(_sentVelocity); // DANGER! EntityItem stores angularVelocity in degrees/sec!!! _sentAngularVelocity = glm::radians(_entity->getAngularVelocity()); setAngularVelocity(_sentAngularVelocity); - _sentAcceleration = _entity->getGravityInMeters(); + _sentAcceleration = _entity->getGravity(); setGravity(_sentAcceleration); _body->setActivationState(ACTIVE_TAG); diff --git a/tests/octree/src/ModelTests.cpp b/tests/octree/src/ModelTests.cpp index e46fbc157a..e4309100af 100644 --- a/tests/octree/src/ModelTests.cpp +++ b/tests/octree/src/ModelTests.cpp @@ -66,17 +66,17 @@ void EntityTests::entityTreeTests(bool verbose) { const EntityItem* foundEntityByRadius = tree.findClosestEntity(positionAtCenter, targetRadius); const EntityItem* foundEntityByID = tree.findEntityByEntityItemID(entityID); EntityTreeElement* containingElement = tree.getContainingElement(entityID); - AACube elementCube = containingElement ? containingElement->getAACube() : AACube(); + const AACube& elementCube = containingElement ? containingElement->getAACube() : AACube(); if (verbose) { qDebug() << "foundEntityByRadius=" << foundEntityByRadius; qDebug() << "foundEntityByID=" << foundEntityByID; qDebug() << "containingElement=" << containingElement; qDebug() << "containingElement.box=" - << elementCube.getCorner().x * TREE_SCALE << "," - << elementCube.getCorner().y * TREE_SCALE << "," - << elementCube.getCorner().z * TREE_SCALE << ":" - << elementCube.getScale() * TREE_SCALE; + << elementCube.getCorner().x << "," + << elementCube.getCorner().y << "," + << elementCube.getCorner().z << ":" + << elementCube.getScale(); qDebug() << "elementCube.getScale()=" << elementCube.getScale(); //containingElement->printDebugDetails("containingElement"); } @@ -109,17 +109,17 @@ void EntityTests::entityTreeTests(bool verbose) { const EntityItem* foundEntityByRadius = tree.findClosestEntity(positionNearOrigin, targetRadius); const EntityItem* foundEntityByID = tree.findEntityByEntityItemID(entityID); EntityTreeElement* containingElement = tree.getContainingElement(entityID); - AACube elementCube = containingElement ? containingElement->getAACube() : AACube(); + const AACube& elementCube = containingElement ? containingElement->getAACube() : AACube(); if (verbose) { qDebug() << "foundEntityByRadius=" << foundEntityByRadius; qDebug() << "foundEntityByID=" << foundEntityByID; qDebug() << "containingElement=" << containingElement; qDebug() << "containingElement.box=" - << elementCube.getCorner().x * TREE_SCALE << "," - << elementCube.getCorner().y * TREE_SCALE << "," - << elementCube.getCorner().z * TREE_SCALE << ":" - << elementCube.getScale() * TREE_SCALE; + << elementCube.getCorner().x << "," + << elementCube.getCorner().y << "," + << elementCube.getCorner().z << ":" + << elementCube.getScale(); //containingElement->printDebugDetails("containingElement"); } @@ -149,17 +149,17 @@ void EntityTests::entityTreeTests(bool verbose) { const EntityItem* foundEntityByRadius = tree.findClosestEntity(positionAtCenter, targetRadius); const EntityItem* foundEntityByID = tree.findEntityByEntityItemID(entityID); EntityTreeElement* containingElement = tree.getContainingElement(entityID); - AACube elementCube = containingElement ? containingElement->getAACube() : AACube(); + const AACube& elementCube = containingElement ? containingElement->getAACube() : AACube(); if (verbose) { qDebug() << "foundEntityByRadius=" << foundEntityByRadius; qDebug() << "foundEntityByID=" << foundEntityByID; qDebug() << "containingElement=" << containingElement; qDebug() << "containingElement.box=" - << elementCube.getCorner().x * TREE_SCALE << "," - << elementCube.getCorner().y * TREE_SCALE << "," - << elementCube.getCorner().z * TREE_SCALE << ":" - << elementCube.getScale() * TREE_SCALE; + << elementCube.getCorner().x << "," + << elementCube.getCorner().y << "," + << elementCube.getCorner().z << ":" + << elementCube.getScale(); //containingElement->printDebugDetails("containingElement"); } @@ -288,7 +288,7 @@ void EntityTests::entityTreeTests(bool verbose) { totalElapsedFind += (endFind - startFind); EntityTreeElement* containingElement = tree.getContainingElement(entityID); - AACube elementCube = containingElement ? containingElement->getAACube() : AACube(); + const AACube& elementCube = containingElement ? containingElement->getAACube() : AACube(); bool elementIsBestFit = containingElement->bestFitEntityBounds(foundEntityByID); @@ -297,10 +297,10 @@ void EntityTests::entityTreeTests(bool verbose) { qDebug() << "foundEntityByID=" << foundEntityByID; qDebug() << "containingElement=" << containingElement; qDebug() << "containingElement.box=" - << elementCube.getCorner().x * TREE_SCALE << "," - << elementCube.getCorner().y * TREE_SCALE << "," - << elementCube.getCorner().z * TREE_SCALE << ":" - << elementCube.getScale() * TREE_SCALE; + << elementCube.getCorner().x << "," + << elementCube.getCorner().y << "," + << elementCube.getCorner().z << ":" + << elementCube.getScale(); qDebug() << "elementCube.getScale()=" << elementCube.getScale(); //containingElement->printDebugDetails("containingElement"); qDebug() << "elementIsBestFit=" << elementIsBestFit;