From 9bd29bdd92d7422805e47655ad32642a3cd97fb7 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sun, 2 Mar 2014 15:34:36 -0800 Subject: [PATCH] removed findSpherePenetration() and findCapsulePenetration() from VoxelSystem, use VoxelTree --- interface/src/Application.h | 1 + interface/src/VoxelSystem.cpp | 22 -------------- interface/src/VoxelSystem.h | 3 -- interface/src/avatar/MyAvatar.cpp | 2 +- libraries/octree/src/Octree.cpp | 48 +++++++++++++++++++------------ 5 files changed, 31 insertions(+), 45 deletions(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index ed6e8be166..91ccdaa02e 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -154,6 +154,7 @@ public: Camera* getCamera() { return &_myCamera; } ViewFrustum* getViewFrustum() { return &_viewFrustum; } VoxelSystem* getVoxels() { return &_voxels; } + VoxelTree* getVoxelTree() { return _voxels.getTree(); } ParticleTreeRenderer* getParticles() { return &_particles; } MetavoxelSystem* getMetavoxels() { return &_metavoxels; } VoxelSystem* getSharedVoxelSystem() { return &_sharedVoxelSystem; } diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 8b43491a46..7110dde688 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -2280,28 +2280,6 @@ bool VoxelSystem::findRayIntersection(const glm::vec3& origin, const glm::vec3& return result; } -bool VoxelSystem::findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration) { - PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), - "VoxelSystem::findSpherePenetration()"); - bool result = false; // assume no penetration - if (_tree->tryLockForRead()) { - result = _tree->findSpherePenetration(center, radius, penetration); - _tree->unlock(); - } - return result; -} - -bool VoxelSystem::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration) { - PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), - "VoxelSystem::findCapsulePenetration()"); - bool result = false; // assume no penetration - if (_tree->tryLockForRead()) { - result = _tree->findCapsulePenetration(start, end, radius, penetration); - _tree->unlock(); - } - return result; -} - void VoxelSystem::copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelSystem* destination, bool rebaseToRoot) { _tree->copySubTreeIntoNewTree(startNode, destination->_tree, rebaseToRoot); destination->setupNewVoxelsForDrawing(); diff --git a/interface/src/VoxelSystem.h b/interface/src/VoxelSystem.h index 7fa6746330..17c6dc8bff 100644 --- a/interface/src/VoxelSystem.h +++ b/interface/src/VoxelSystem.h @@ -90,9 +90,6 @@ public: bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, VoxelDetail& detail, float& distance, BoxFace& face); - bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration); - bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration); - void copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelSystem* destinationTree, bool rebaseToRoot); void copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelTree* destinationTree, bool rebaseToRoot); void copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelTreeElement* destinationNode); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 02d14b7a2c..51fcad20ae 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -810,7 +810,7 @@ void MyAvatar::updateCollisionWithVoxels(float deltaTime, float radius) { const float VOXEL_COLLISION_FREQUENCY = 0.5f; glm::vec3 penetration; float pelvisFloatingHeight = getPelvisFloatingHeight(); - if (Application::getInstance()->getVoxels()->findCapsulePenetration( + if (Application::getInstance()->getVoxelTree()->findCapsulePenetration( _position - glm::vec3(0.0f, pelvisFloatingHeight - radius, 0.0f), _position + glm::vec3(0.0f, getSkeletonHeight() - pelvisFloatingHeight + radius, 0.0f), radius, penetration)) { _lastCollisionPosition = _position; diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index e63424d92b..49f1bc9c3a 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -628,18 +628,23 @@ bool findSpherePenetrationOp(OctreeElement* element, void* extraData) { bool Octree::findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration, void** penetratedObject) { - SphereArgs args = { - center / (float)(TREE_SCALE), - radius / (float)(TREE_SCALE), - penetration, - false, - NULL }; - penetration = glm::vec3(0.0f, 0.0f, 0.0f); - recurseTreeWithOperation(findSpherePenetrationOp, &args); - if (penetratedObject) { - *penetratedObject = args.penetratedObject; + bool result = false; // assume no penetration + if (tryLockForRead()) { + SphereArgs args = { + center / (float)(TREE_SCALE), + radius / (float)(TREE_SCALE), + penetration, + false, + NULL }; + penetration = glm::vec3(0.0f, 0.0f, 0.0f); + recurseTreeWithOperation(findSpherePenetrationOp, &args); + if (penetratedObject) { + *penetratedObject = args.penetratedObject; + } + unlock(); + result = args.found; } - return args.found; + return result; } class CapsuleArgs { @@ -673,14 +678,19 @@ bool findCapsulePenetrationOp(OctreeElement* node, void* extraData) { } bool Octree::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration) { - CapsuleArgs args = { - start / (float)(TREE_SCALE), - end / (float)(TREE_SCALE), - radius / (float)(TREE_SCALE), - penetration }; - penetration = glm::vec3(0.0f, 0.0f, 0.0f); - recurseTreeWithOperation(findCapsulePenetrationOp, &args); - return args.found; + bool result = false; // assume no penetration + if (tryLockForRead()) { + CapsuleArgs args = { + start / (float)(TREE_SCALE), + end / (float)(TREE_SCALE), + radius / (float)(TREE_SCALE), + penetration }; + penetration = glm::vec3(0.0f, 0.0f, 0.0f); + recurseTreeWithOperation(findCapsulePenetrationOp, &args); + result = args.found; + unlock(); + } + return result; } int Octree::encodeTreeBitstream(OctreeElement* node,