diff options
author | Pushkar Joshi | 2012-04-19 14:12:45 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-04-19 14:12:45 -0700 |
commit | 9f32d7e5454db3189209fc68a286a7fdb0c31fe8 (patch) | |
tree | a51c2bf67839a25158c30752b44fdea0eac28b9d /js/helper-classes/3D/hit-record.js | |
parent | dc1e8dde18c40cf740bd2fe09165784e0d415fab (diff) | |
parent | 6d33345a9e609e36539d2efa25569f5eeb04a2af (diff) | |
download | ninja-9f32d7e5454db3189209fc68a286a7fdb0c31fe8.tar.gz |
Merge branch 'master' into pentool
Conflicts:
js/helper-classes/3D/view-utils.js
Diffstat (limited to 'js/helper-classes/3D/hit-record.js')
-rwxr-xr-x | js/helper-classes/3D/hit-record.js | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js index 265bf2a4..d72e33bd 100755 --- a/js/helper-classes/3D/hit-record.js +++ b/js/helper-classes/3D/hit-record.js | |||
@@ -292,6 +292,59 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype, | |||
292 | 292 | ||
293 | return str; | 293 | return str; |
294 | } | 294 | } |
295 | } | 295 | }, |
296 | |||
297 | test: | ||
298 | { | ||
299 | value: function() | ||
300 | { | ||
301 | var elt = this.getElement(); | ||
302 | var stage = viewUtils.getStage(); | ||
303 | if (elt === stage) return; | ||
304 | |||
305 | var localPt = this.calculateElementPreTransformScreenPoint(); | ||
306 | var stageWorldPt = this.calculateStageWorldPoint(); | ||
307 | var globalPt = this.getScreenPoint(); | ||
308 | var err = false; | ||
309 | |||
310 | var test1 = viewUtils.localToGlobal( localPt, elt ); | ||
311 | var dist = vecUtils.vecDist(3, test1, globalPt); | ||
312 | if (MathUtils.fpSign(dist) != 0) | ||
313 | { | ||
314 | err = true; | ||
315 | console.log( "**** transform error 1 ***** " + dist + ", localPt: " + localPt ); | ||
316 | } | ||
317 | |||
318 | var stageWorldToGlobal = viewUtils.getStageWorldToGlobalMatrix(); | ||
319 | var test2 = MathUtils.transformAndDivideHomogeneousPoint( stageWorldPt, stageWorldToGlobal ); | ||
320 | dist = vecUtils.vecDist(3, test2, globalPt); | ||
321 | if (MathUtils.fpSign(dist) != 0) | ||
322 | { | ||
323 | err = true; | ||
324 | console.log( "**** transform error 2 ***** " + dist + ", localPt: " + localPt ); | ||
325 | } | ||
326 | |||
327 | var localToGlobal = viewUtils.getLocalToGlobalMatrix( elt ); | ||
328 | var globalToLocal = glmat4.inverse( localToGlobal, [] ); | ||
329 | var test3 = MathUtils.transformAndDivideHomogeneousPoint( globalPt, globalToLocal ); | ||
330 | dist = vecUtils.vecDist(3, test3, localPt); | ||
331 | if (MathUtils.fpSign(dist) != 0) | ||
332 | { | ||
333 | err = true; | ||
334 | console.log( "**** transform error 3 ***** " + dist + ", localPt: " + localPt ); | ||
335 | } | ||
336 | |||
337 | var objToStageWorld = viewUtils.getObjToStageWorldMatrix( elt, true ); | ||
338 | var test4 = MathUtils.transformAndDivideHomogeneousPoint( localPt, objToStageWorld ); | ||
339 | dist = vecUtils.vecDist(3, test4, stageWorldPt); | ||
340 | if (MathUtils.fpSign(dist) != 0) | ||
341 | { | ||
342 | err = true; | ||
343 | console.log( "**** transform error 4 ***** " + dist + ", localPt: " + localPt ); | ||
344 | } | ||
345 | |||
346 | //if (!err) console.log( "no hitRecord error" ); | ||
347 | } | ||
348 | } | ||
296 | }); | 349 | }); |
297 | 350 | ||