diff options
author | hwc487 | 2012-04-05 17:09:51 -0700 |
---|---|---|
committer | hwc487 | 2012-04-05 17:09:51 -0700 |
commit | 2d21b01d6dd64af643f5f38818b57fcace05ea0b (patch) | |
tree | 44fac83294dae2efad48389ddb44cb1dbe06caad /js/helper-classes/3D/hit-record.js | |
parent | 7656b6eac7aec59697c6cddbe2a507fe9e4aa187 (diff) | |
parent | 96bfeee2e6b735b87e8482d6e2cf24d5224c6417 (diff) | |
download | ninja-2d21b01d6dd64af643f5f38818b57fcace05ea0b.tar.gz |
Merge branch 'Snapping' of github.com:ericmueller/ninja-internal into Snapping_II
Diffstat (limited to 'js/helper-classes/3D/hit-record.js')
-rwxr-xr-x | js/helper-classes/3D/hit-record.js | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js index 2c60adc6..96f87c24 100755 --- a/js/helper-classes/3D/hit-record.js +++ b/js/helper-classes/3D/hit-record.js | |||
@@ -284,6 +284,50 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, | |||
284 | 284 | ||
285 | return str; | 285 | return str; |
286 | } | 286 | } |
287 | } | 287 | }, |
288 | |||
289 | test: | ||
290 | { | ||
291 | value: function() | ||
292 | { | ||
293 | var elt = this.getElement(); | ||
294 | var stage = viewUtils.getStage(); | ||
295 | if (elt === stage) return; | ||
296 | |||
297 | var localPt = this.calculateElementPreTransformScreenPoint(); | ||
298 | var stageWorldPt = this.calculateStageWorldPoint(); | ||
299 | var globalPt = this.getScreenPoint(); | ||
300 | var err = false; | ||
301 | |||
302 | var test1 = viewUtils.localToGlobal( localPt, elt ); | ||
303 | var dist = vecUtils.vecDist(3, test1, globalPt); | ||
304 | if (MathUtils.fpSign(dist) != 0) | ||
305 | { | ||
306 | err = true; | ||
307 | console.log( "**** transform error 1 ***** " + dist + ", localPt: " + localPt ); | ||
308 | } | ||
309 | |||
310 | var stageWorldToGlobal = viewUtils.getStageWorldToGlobalMatrix(); | ||
311 | var test2 = MathUtils.transformAndDivideHomogeneousPoint( stageWorldPt, stageWorldToGlobal ); | ||
312 | dist = vecUtils.vecDist(3, test2, globalPt); | ||
313 | if (MathUtils.fpSign(dist) != 0) | ||
314 | { | ||
315 | err = true; | ||
316 | console.log( "**** transform error 2 ***** " + dist + ", localPt: " + localPt ); | ||
317 | } | ||
318 | |||
319 | var localToGlobal = viewUtils.getLocalToGlobalMatrix( elt ); | ||
320 | var globalToLocal = glmat4.inverse( localToGlobal, [] ); | ||
321 | var test3 = MathUtils.transformAndDivideHomogeneousPoint( globalPt, globalToLocal ); | ||
322 | dist = vecUtils.vecDist(3, test3, localPt); | ||
323 | if (MathUtils.fpSign( vecUtils.vecDist(3, test3, localPt)) != 0) | ||
324 | { | ||
325 | err = true; | ||
326 | console.log( "**** transform error 3 ***** " + dist + ", localPt: " + localPt ); | ||
327 | } | ||
328 | |||
329 | if (!err) console.log( "no hitRecord error" ); | ||
330 | } | ||
331 | } | ||
288 | }); | 332 | }); |
289 | 333 | ||