removed findSpherePenetration() and findCapsulePenetration() from VoxelSystem, use VoxelTree

This commit is contained in:
ZappoMan 2014-03-02 15:34:36 -08:00
parent ded7328959
commit 9bd29bdd92
5 changed files with 31 additions and 45 deletions

View file

@ -154,6 +154,7 @@ public:
Camera* getCamera() { return &_myCamera; } Camera* getCamera() { return &_myCamera; }
ViewFrustum* getViewFrustum() { return &_viewFrustum; } ViewFrustum* getViewFrustum() { return &_viewFrustum; }
VoxelSystem* getVoxels() { return &_voxels; } VoxelSystem* getVoxels() { return &_voxels; }
VoxelTree* getVoxelTree() { return _voxels.getTree(); }
ParticleTreeRenderer* getParticles() { return &_particles; } ParticleTreeRenderer* getParticles() { return &_particles; }
MetavoxelSystem* getMetavoxels() { return &_metavoxels; } MetavoxelSystem* getMetavoxels() { return &_metavoxels; }
VoxelSystem* getSharedVoxelSystem() { return &_sharedVoxelSystem; } VoxelSystem* getSharedVoxelSystem() { return &_sharedVoxelSystem; }

View file

@ -2280,28 +2280,6 @@ bool VoxelSystem::findRayIntersection(const glm::vec3& origin, const glm::vec3&
return result; 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) { void VoxelSystem::copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelSystem* destination, bool rebaseToRoot) {
_tree->copySubTreeIntoNewTree(startNode, destination->_tree, rebaseToRoot); _tree->copySubTreeIntoNewTree(startNode, destination->_tree, rebaseToRoot);
destination->setupNewVoxelsForDrawing(); destination->setupNewVoxelsForDrawing();

View file

@ -90,9 +90,6 @@ public:
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
VoxelDetail& detail, float& distance, BoxFace& face); 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, VoxelSystem* destinationTree, bool rebaseToRoot);
void copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelTree* destinationTree, bool rebaseToRoot); void copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelTree* destinationTree, bool rebaseToRoot);
void copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelTreeElement* destinationNode); void copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelTreeElement* destinationNode);

View file

@ -810,7 +810,7 @@ void MyAvatar::updateCollisionWithVoxels(float deltaTime, float radius) {
const float VOXEL_COLLISION_FREQUENCY = 0.5f; const float VOXEL_COLLISION_FREQUENCY = 0.5f;
glm::vec3 penetration; glm::vec3 penetration;
float pelvisFloatingHeight = getPelvisFloatingHeight(); 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, pelvisFloatingHeight - radius, 0.0f),
_position + glm::vec3(0.0f, getSkeletonHeight() - pelvisFloatingHeight + radius, 0.0f), radius, penetration)) { _position + glm::vec3(0.0f, getSkeletonHeight() - pelvisFloatingHeight + radius, 0.0f), radius, penetration)) {
_lastCollisionPosition = _position; _lastCollisionPosition = _position;

View file

@ -628,18 +628,23 @@ bool findSpherePenetrationOp(OctreeElement* element, void* extraData) {
bool Octree::findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration, bool Octree::findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration,
void** penetratedObject) { void** penetratedObject) {
SphereArgs args = { bool result = false; // assume no penetration
center / (float)(TREE_SCALE), if (tryLockForRead()) {
radius / (float)(TREE_SCALE), SphereArgs args = {
penetration, center / (float)(TREE_SCALE),
false, radius / (float)(TREE_SCALE),
NULL }; penetration,
penetration = glm::vec3(0.0f, 0.0f, 0.0f); false,
recurseTreeWithOperation(findSpherePenetrationOp, &args); NULL };
if (penetratedObject) { penetration = glm::vec3(0.0f, 0.0f, 0.0f);
*penetratedObject = args.penetratedObject; recurseTreeWithOperation(findSpherePenetrationOp, &args);
if (penetratedObject) {
*penetratedObject = args.penetratedObject;
}
unlock();
result = args.found;
} }
return args.found; return result;
} }
class CapsuleArgs { 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) { bool Octree::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration) {
CapsuleArgs args = { bool result = false; // assume no penetration
start / (float)(TREE_SCALE), if (tryLockForRead()) {
end / (float)(TREE_SCALE), CapsuleArgs args = {
radius / (float)(TREE_SCALE), start / (float)(TREE_SCALE),
penetration }; end / (float)(TREE_SCALE),
penetration = glm::vec3(0.0f, 0.0f, 0.0f); radius / (float)(TREE_SCALE),
recurseTreeWithOperation(findCapsulePenetrationOp, &args); penetration };
return args.found; penetration = glm::vec3(0.0f, 0.0f, 0.0f);
recurseTreeWithOperation(findCapsulePenetrationOp, &args);
result = args.found;
unlock();
}
return result;
} }
int Octree::encodeTreeBitstream(OctreeElement* node, int Octree::encodeTreeBitstream(OctreeElement* node,