removed VoxelSystem::findRayIntersection() use tree directly

This commit is contained in:
ZappoMan 2014-03-02 15:46:33 -08:00
parent 9bd29bdd92
commit f0e73d2f98
5 changed files with 29 additions and 29 deletions

View file

@ -1740,7 +1740,7 @@ void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& f
if (!_mousePressed) {
PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()");
_isHoverVoxel = _voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face);
_isHoverVoxel = getVoxelTree()->findRayIntersectionDetail(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face);
}
}

View file

@ -2256,30 +2256,6 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData
}
bool VoxelSystem::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
VoxelDetail& detail, float& distance, BoxFace& face) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"VoxelSystem::findRayIntersection()");
bool result = false; // assume no intersection
if (_tree->tryLockForRead()) {
OctreeElement* element;
result = _tree->findRayIntersection(origin, direction, element, distance, face);
if (result) {
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
detail.x = voxel->getCorner().x;
detail.y = voxel->getCorner().y;
detail.z = voxel->getCorner().z;
detail.s = voxel->getScale();
detail.red = voxel->getColor()[0];
detail.green = voxel->getColor()[1];
detail.blue = voxel->getColor()[2];
}
_tree->unlock();
}
return result;
}
void VoxelSystem::copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelSystem* destination, bool rebaseToRoot) {
_tree->copySubTreeIntoNewTree(startNode, destination->_tree, rebaseToRoot);
destination->setupNewVoxelsForDrawing();

View file

@ -87,9 +87,6 @@ public:
bool hasViewChanged();
bool isViewChanging();
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
VoxelDetail& detail, float& distance, BoxFace& face);
void copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelSystem* destinationTree, bool rebaseToRoot);
void copySubTreeIntoNewTree(VoxelTreeElement* startNode, VoxelTree* destinationTree, bool rebaseToRoot);
void copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelTreeElement* destinationNode);

View file

@ -562,3 +562,28 @@ int VoxelTree::processEditPacketData(PacketType packetType, const unsigned char*
}
}
bool VoxelTree::findRayIntersectionDetail(const glm::vec3& origin, const glm::vec3& direction,
VoxelDetail& detail, float& distance, BoxFace& face) {
bool result = false; // assume no intersection
if (tryLockForRead()) {
OctreeElement* element;
result = findRayIntersection(origin, direction, element, distance, face);
if (result) {
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
detail.x = voxel->getCorner().x;
detail.y = voxel->getCorner().y;
detail.z = voxel->getCorner().z;
detail.s = voxel->getScale();
detail.red = voxel->getColor()[0];
detail.green = voxel->getColor()[1];
detail.blue = voxel->getColor()[2];
}
unlock();
}
return result;
}

View file

@ -44,7 +44,9 @@ public:
virtual bool handlesEditPacketType(PacketType packetType) const;
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
const unsigned char* editData, int maxLength, const SharedNodePointer& node);
void processSetVoxelsBitstream(const unsigned char* bitstream, int bufferSizeBytes);
bool findRayIntersectionDetail(const glm::vec3& origin, const glm::vec3& direction,
VoxelDetail& detail, float& distance, BoxFace& face);
private:
// helper functions for nudgeSubTree