mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-25 15:34:29 +02:00
namechange planeNormal --> faceNormal
This commit is contained in:
parent
4e7a7667b1
commit
32b07027d3
1 changed files with 11 additions and 11 deletions
|
@ -15,7 +15,7 @@
|
||||||
#include "AACubeShape.h"
|
#include "AACubeShape.h"
|
||||||
#include "SharedUtil.h" // for SQUARE_ROOT_OF_3
|
#include "SharedUtil.h" // for SQUARE_ROOT_OF_3
|
||||||
|
|
||||||
glm::vec3 planeNormals[3] = { glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f) };
|
glm::vec3 faceNormals[3] = { glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f) };
|
||||||
|
|
||||||
bool AACubeShape::findRayIntersection(RayIntersectionInfo& intersection) const {
|
bool AACubeShape::findRayIntersection(RayIntersectionInfo& intersection) const {
|
||||||
// A = ray point
|
// A = ray point
|
||||||
|
@ -48,23 +48,23 @@ bool AACubeShape::findRayIntersection(RayIntersectionInfo& intersection) const {
|
||||||
bool hit = false;
|
bool hit = false;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
for (float sign = -1.0f; sign < 2.0f; sign += 2.0f) {
|
for (float sign = -1.0f; sign < 2.0f; sign += 2.0f) {
|
||||||
glm::vec3 planeNormal = sign * planeNormals[i];
|
glm::vec3 faceNormal = sign * faceNormals[i];
|
||||||
float rayDotPlane = glm::dot(intersection._rayDirection, planeNormal);
|
float rayDotPlane = glm::dot(intersection._rayDirection, faceNormal);
|
||||||
if (glm::abs(rayDotPlane) > EPSILON) {
|
if (glm::abs(rayDotPlane) > EPSILON) {
|
||||||
float distanceToPlane = (halfSide + glm::dot(BA, planeNormal)) / rayDotPlane;
|
float distanceToFace = (halfSide + glm::dot(BA, faceNormal)) / rayDotPlane;
|
||||||
if (distanceToPlane >= 0.0f) {
|
if (distanceToFace >= 0.0f) {
|
||||||
glm::vec3 point = distanceToPlane * intersection._rayDirection - BA;
|
glm::vec3 point = distanceToFace * intersection._rayDirection - BA;
|
||||||
int j = (i + 1) % 3;
|
int j = (i + 1) % 3;
|
||||||
int k = (i + 2) % 3;
|
int k = (i + 2) % 3;
|
||||||
glm::vec3 secondNormal = planeNormals[j];
|
glm::vec3 secondNormal = faceNormals[j];
|
||||||
glm::vec3 thirdNormal = planeNormals[k];
|
glm::vec3 thirdNormal = faceNormals[k];
|
||||||
if (glm::abs(glm::dot(point, secondNormal)) > halfSide ||
|
if (glm::abs(glm::dot(point, secondNormal)) > halfSide ||
|
||||||
glm::abs(glm::dot(point, thirdNormal)) > halfSide) {
|
glm::abs(glm::dot(point, thirdNormal)) > halfSide) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (distanceToPlane < intersection._hitDistance && distanceToPlane < intersection._rayLength) {
|
if (distanceToFace < intersection._hitDistance && distanceToFace < intersection._rayLength) {
|
||||||
intersection._hitDistance = distanceToPlane;
|
intersection._hitDistance = distanceToFace;
|
||||||
intersection._hitNormal = planeNormal;
|
intersection._hitNormal = faceNormal;
|
||||||
intersection._hitShape = const_cast<AACubeShape*>(this);
|
intersection._hitShape = const_cast<AACubeShape*>(this);
|
||||||
hit = true;
|
hit = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue