mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:18:52 +02:00
Implement dimensions test for 3D planar overlay intersection
This commit is contained in:
parent
056365932b
commit
2f6749ff69
1 changed files with 7 additions and 4 deletions
|
@ -93,7 +93,6 @@ QScriptValue Planar3DOverlay::getProperty(const QString& property) {
|
||||||
|
|
||||||
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
float& distance, BoxFace& face) {
|
float& distance, BoxFace& face) {
|
||||||
|
|
||||||
RayIntersectionInfo rayInfo;
|
RayIntersectionInfo rayInfo;
|
||||||
rayInfo._rayStart = origin;
|
rayInfo._rayStart = origin;
|
||||||
rayInfo._rayDirection = direction;
|
rayInfo._rayDirection = direction;
|
||||||
|
@ -110,9 +109,13 @@ bool Planar3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::ve
|
||||||
|
|
||||||
if (intersects) {
|
if (intersects) {
|
||||||
distance = rayInfo._hitDistance;
|
distance = rayInfo._hitDistance;
|
||||||
// TODO: if it intersects, we want to check to see if the intersection point is within our dimensions
|
|
||||||
// glm::vec3 hitAt = origin + direction * distance;
|
glm::vec3 hitPosition = origin + (distance * direction);
|
||||||
// _dimensions
|
glm::vec3 localHitPosition = glm::inverse(_rotation) * (hitPosition - _position);
|
||||||
|
glm::vec2 halfDimensions = _dimensions / 2.0f;
|
||||||
|
|
||||||
|
intersects = -halfDimensions.x <= localHitPosition.x && localHitPosition.x <= halfDimensions.x
|
||||||
|
&& -halfDimensions.y <= localHitPosition.y && localHitPosition.y <= halfDimensions.y;
|
||||||
}
|
}
|
||||||
return intersects;
|
return intersects;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue