Fixed bug in rayPlane test

This commit is contained in:
PhilipRosedale 2016-02-28 15:44:23 -08:00
parent e9aed83920
commit cee79c8274
2 changed files with 8 additions and 4 deletions

View file

@ -728,9 +728,10 @@ function rayPlaneIntersection2(pickRay, point, normal) {
// This version of the test returns false if the ray is directed away from the plane // This version of the test returns false if the ray is directed away from the plane
// //
var collides = Vec3.dot(pickRay.direction, normal); var collides = Vec3.dot(pickRay.direction, normal);
if (collides > 0.0) return false;
var d = -Vec3.dot(point, normal); var d = -Vec3.dot(point, normal);
if (((collides > 0.0) && (d > 0.0)) || ((collides < 0.0) && (d < 0.0))) {
return false;
}
var t = -(Vec3.dot(pickRay.origin, normal) + d) / collides; var t = -(Vec3.dot(pickRay.origin, normal) + d) / collides;
return Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction, t)); return Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction, t));

View file

@ -2334,10 +2334,13 @@ SelectionDisplay = (function() {
// If the mouse is too close to the horizon of the pick plane, stop moving // If the mouse is too close to the horizon of the pick plane, stop moving
var MIN_AZIMUTH = 0.02; // Radians var MIN_AZIMUTH = 0.02; // Radians
var azimuth = translateXZTool.azimuth(pickRay.origin, pick); var azimuth = translateXZTool.azimuth(pickRay.origin, pick);
if (wantDebug) {
print("Start Azimuth: " + translateXZTool.startingAzimuth + ", Azimuth: " + azimuth);
}
if ((translateXZTool.startingAzimuth > 0.0 && azimuth < MIN_AZIMUTH) || if ((translateXZTool.startingAzimuth > 0.0 && azimuth < MIN_AZIMUTH) ||
(translateXZTool.startingAzimuth < 0.0 && azimuth > MIN_AZIMUTH)) { (translateXZTool.startingAzimuth < 0.0 && azimuth > -MIN_AZIMUTH)) {
if (wantDebug) { if (wantDebug) {
print("Azimuth = " + azimuth); print("too close to horizon!");
} }
return; return;
} }