mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-18 01:36:25 +02:00
Octree::findCapsulePenetration() uses meters
This commit is contained in:
parent
ca1c9b4105
commit
d7d25a6509
4 changed files with 10 additions and 22 deletions
|
@ -425,7 +425,7 @@ bool EntityTree::findNearPointOperation(OctreeElement* element, void* extraData)
|
|||
|
||||
glm::vec3 penetration;
|
||||
AACube cube = entityTreeElement->getAACube();
|
||||
cube *= (float)TREE_SCALE;
|
||||
cube.scale((float)TREE_SCALE);
|
||||
bool sphereIntersection = cube.findSpherePenetration(args->position, args->targetRadius, penetration);
|
||||
|
||||
// If this entityTreeElement contains the point, then search it...
|
||||
|
@ -478,7 +478,7 @@ bool EntityTree::findInSphereOperation(OctreeElement* element, void* extraData)
|
|||
FindAllNearPointArgs* args = static_cast<FindAllNearPointArgs*>(extraData);
|
||||
glm::vec3 penetration;
|
||||
AACube cube = element->getAACube();
|
||||
cube *= (float)TREE_SCALE;
|
||||
cube.scale((float)TREE_SCALE);
|
||||
bool sphereIntersection = cube.findSpherePenetration(args->position, args->targetRadius, penetration);
|
||||
|
||||
// If this element contains the point, then search it...
|
||||
|
@ -516,7 +516,7 @@ public:
|
|||
bool EntityTree::findInCubeOperation(OctreeElement* element, void* extraData) {
|
||||
FindEntitiesInCubeArgs* args = static_cast<FindEntitiesInCubeArgs*>(extraData);
|
||||
AACube elementCube = element->getAACube();
|
||||
elementCube *= (float)TREE_SCALE;
|
||||
elementCube.scale((float)TREE_SCALE);
|
||||
if (elementCube.touches(args->_cube)) {
|
||||
EntityTreeElement* entityTreeElement = static_cast<EntityTreeElement*>(element);
|
||||
entityTreeElement->getEntities(args->_cube, args->_foundEntities);
|
||||
|
|
|
@ -750,7 +750,7 @@ bool findSpherePenetrationOp(OctreeElement* element, void* extraData) {
|
|||
|
||||
// the details in args is in meters (world-frame) so we have to scale the element cube up
|
||||
AACube box = element->getAACube();
|
||||
box *= (float)TREE_SCALE;
|
||||
box.scale((float)TREE_SCALE);
|
||||
|
||||
// coarse check against bounds
|
||||
if (!box.expandedContains(args->center, args->radius)) {
|
||||
|
@ -837,14 +837,15 @@ bool findCapsulePenetrationOp(OctreeElement* element, void* extraData) {
|
|||
CapsuleArgs* args = static_cast<CapsuleArgs*>(extraData);
|
||||
|
||||
// coarse check against bounds
|
||||
const AACube& box = element->getAACube();
|
||||
AACube box = element->getAACube();
|
||||
box.scale((float)TREE_SCALE);
|
||||
if (!box.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)) {
|
||||
args->penetration = addPenetrations(args->penetration, nodePenetration * (float)(TREE_SCALE));
|
||||
args->penetration = addPenetrations(args->penetration, nodePenetration);
|
||||
args->found = true;
|
||||
}
|
||||
}
|
||||
|
@ -891,12 +892,7 @@ bool findContentInCubeOp(OctreeElement* element, void* extraData) {
|
|||
bool Octree::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius,
|
||||
glm::vec3& penetration, Octree::lockType lockType, bool* accurateResult) {
|
||||
|
||||
CapsuleArgs args = {
|
||||
start / (float)(TREE_SCALE),
|
||||
end / (float)(TREE_SCALE),
|
||||
radius / (float)(TREE_SCALE),
|
||||
penetration,
|
||||
false };
|
||||
CapsuleArgs args = { start, end, radius, penetration, false };
|
||||
penetration = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
bool gotLock = false;
|
||||
|
|
|
@ -1338,7 +1338,7 @@ bool OctreeElement::findRayIntersection(const glm::vec3& origin, const glm::vec3
|
|||
keepSearching = true; // assume that we will continue searching after this.
|
||||
|
||||
AACube cube = getAACube();
|
||||
cube *= (float)TREE_SCALE;
|
||||
cube.scale((float)TREE_SCALE);
|
||||
float distanceToElementCube = std::numeric_limits<float>::max();
|
||||
float distanceToElementDetails = distance;
|
||||
BoxFace localFace;
|
||||
|
@ -1392,7 +1392,7 @@ 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 *= (float)TREE_SCALE;
|
||||
cube.scale((float)TREE_SCALE);
|
||||
return cube.findSpherePenetration(center, radius, penetration);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@ public:
|
|||
AABox clamp(const glm::vec3& min, const glm::vec3& max) const;
|
||||
AABox clamp(float min, float max) const;
|
||||
|
||||
AACube& operator *= (float scale);
|
||||
|
||||
private:
|
||||
glm::vec3 getClosestPointOnFace(const glm::vec3& point, BoxFace face) const;
|
||||
glm::vec3 getClosestPointOnFace(const glm::vec4& origin, const glm::vec4& direction, BoxFace face) const;
|
||||
|
@ -76,12 +74,6 @@ private:
|
|||
float _scale;
|
||||
};
|
||||
|
||||
inline AACube& AACube::operator *= (float scale) {
|
||||
_corner *= scale;
|
||||
_scale *= scale;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool operator==(const AACube& a, const AACube& b) {
|
||||
return a.getCorner() == b.getCorner() && a.getScale() == b.getScale();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue