mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 01:17:14 +02:00
Fixed bug in rayPlane test
This commit is contained in:
parent
e9aed83920
commit
cee79c8274
2 changed files with 8 additions and 4 deletions
|
@ -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));
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue