mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 18:13:29 +02:00
Compute nodes' enclosing radius in the same place.
This commit is contained in:
parent
1118c06f5d
commit
0377ca1adb
3 changed files with 8 additions and 8 deletions
|
@ -247,6 +247,10 @@ void VoxelNode::printDebugDetails(const char* label) const {
|
|||
printOctalCode(_octalCode);
|
||||
}
|
||||
|
||||
float VoxelNode::getEnclosingRadius() const {
|
||||
return getScale() * sqrtf(3.0f) / 2.0f;
|
||||
}
|
||||
|
||||
bool VoxelNode::isInView(const ViewFrustum& viewFrustum) const {
|
||||
AABox box = _box; // use temporary box so we can scale it
|
||||
box.scale(TREE_SCALE);
|
||||
|
|
|
@ -57,6 +57,8 @@ public:
|
|||
float getScale() const { return _box.getSize().x; /* voxelScale = (1 / powf(2, *node->getOctalCode())); */ };
|
||||
int getLevel() const { return *_octalCode + 1; /* one based or zero based? */ };
|
||||
|
||||
float getEnclosingRadius() const;
|
||||
|
||||
bool isColored() const { return (_trueColor[3]==1); };
|
||||
bool isInView(const ViewFrustum& viewFrustum) const;
|
||||
ViewFrustum::location inFrustum(const ViewFrustum& viewFrustum) const;
|
||||
|
|
|
@ -693,12 +693,9 @@ bool findSpherePenetrationOp(VoxelNode* node, void* extraData) {
|
|||
|
||||
// currently, we treat each node as a sphere enveloping the box
|
||||
const glm::vec3& nodeCenter = node->getCenter();
|
||||
float halfNodeScale = node->getScale() * 0.5f;
|
||||
float halfNodeScale2 = halfNodeScale * halfNodeScale;
|
||||
float nodeRadius = sqrtf(halfNodeScale2*3.0f);
|
||||
glm::vec3 vector = args->center - nodeCenter;
|
||||
float vectorLength = glm::length(vector);
|
||||
float distance = vectorLength - nodeRadius - args->radius;
|
||||
float distance = vectorLength - node->getEnclosingRadius() - args->radius;
|
||||
if (distance >= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
|
@ -748,12 +745,9 @@ bool findCapsulePenetrationOp(VoxelNode* node, void* extraData) {
|
|||
|
||||
// currently, we treat each node as a sphere enveloping the box
|
||||
const glm::vec3& nodeCenter = node->getCenter();
|
||||
float halfNodeScale = node->getScale() * 0.5f;
|
||||
float halfNodeScale2 = halfNodeScale * halfNodeScale;
|
||||
float nodeRadius = sqrtf(halfNodeScale2*3.0f);
|
||||
glm::vec3 vector = computeVectorFromPointToSegment(nodeCenter, args->start, args->end);
|
||||
float vectorLength = glm::length(vector);
|
||||
float distance = vectorLength - nodeRadius - args->radius;
|
||||
float distance = vectorLength - node->getEnclosingRadius() - args->radius;
|
||||
if (distance >= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue