diff options
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-x | js/helper-classes/3D/StageLine.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/js/helper-classes/3D/StageLine.js b/js/helper-classes/3D/StageLine.js index 17021e91..38bd80ef 100755 --- a/js/helper-classes/3D/StageLine.js +++ b/js/helper-classes/3D/StageLine.js | |||
@@ -240,8 +240,9 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { | |||
240 | } | 240 | } |
241 | 241 | ||
242 | // boundary points (line points: lPt0, lPt1) | 242 | // boundary points (line points: lPt0, lPt1) |
243 | var bPt0, bPt1, bPt2, bVec, bVec0, bVec1, lVec; | 243 | var bPt0, bPt1, bPt2, bVec, bVec0, bVec1, lVec, d; |
244 | 244 | ||
245 | var planeEq = plane.getPlaneEq(); | ||
245 | if (MathUtils.fpSign(t) == 0) | 246 | if (MathUtils.fpSign(t) == 0) |
246 | { | 247 | { |
247 | // get the 3 relevant points. The line goes through pt1. | 248 | // get the 3 relevant points. The line goes through pt1. |
@@ -260,6 +261,9 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { | |||
260 | rtnVal = true; | 261 | rtnVal = true; |
261 | else if (plane.isBackFacing() && (MathUtils.fpSign(c0) > 0) && (MathUtils.fpSign(c1) > 0)) | 262 | else if (plane.isBackFacing() && (MathUtils.fpSign(c0) > 0) && (MathUtils.fpSign(c1) > 0)) |
262 | rtnVal = true; | 263 | rtnVal = true; |
264 | |||
265 | d = vecUtils.vecDot(3, lPt1, planeEq) + planeEq[3]; | ||
266 | if (rtnVal && (MathUtils.fpSign(d) > 0)) rtnVal = false; | ||
263 | } | 267 | } |
264 | else | 268 | else |
265 | { | 269 | { |
@@ -268,13 +272,12 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { | |||
268 | bVec = vecUtils.vecSubtract(3, bPt1, bPt0); | 272 | bVec = vecUtils.vecSubtract(3, bPt1, bPt0); |
269 | lVec = vecUtils.vecSubtract(3, lPt1, lPt0); | 273 | lVec = vecUtils.vecSubtract(3, lPt1, lPt0); |
270 | 274 | ||
271 | var planeEq = plane.getPlaneEq(); | 275 | var backFacing = plane.isBackFacing(); |
272 | var bNormal = vecUtils.vecCross(3, planeEq, bVec); | 276 | var bNormal = vecUtils.vecCross(3, planeEq, bVec); |
273 | var dot = vecUtils.vecDot(3, bNormal, lVec); | 277 | var dot = vecUtils.vecDot(3, bNormal, lVec); |
274 | if (MathUtils.fpSign(dot) < 0) | 278 | if ((!backFacing && (MathUtils.fpSign(dot) < 0)) || (backFacing && (MathUtils.fpSign(dot) > 0))) |
275 | { | 279 | { |
276 | var d = vecUtils.vecDot(3, lPt1, planeEq) + planeEq[3]; | 280 | d = vecUtils.vecDot(3, lPt1, planeEq) + planeEq[3]; |
277 | if (plane.isBackFacing()) d = -d; | ||
278 | if (MathUtils.fpSign(d) < 0) rtnVal = true; | 281 | if (MathUtils.fpSign(d) < 0) rtnVal = true; |
279 | } | 282 | } |
280 | } | 283 | } |