Game.Viewport.GetPickRay

Feb 22, 2011 at 1:29 AM
Edited Feb 22, 2011 at 2:08 AM

Hi all,

I noticed that Game.ViewPort.GetPickRay has changed.  I'm using that to determine what face the mouse is over in my game.  Since an update this is no longer working.  All things being equal (I pass the same point into the get pick ray method, I'm getting different rays back out.  Both the position and direciton are different.  When I use this new pickray to test for intersections I'm getting very large distances when I get an intersection at all. 

Has the use of this method changed?  Could anyone shed some light on how it works differently than it used to so I can fix up my code?

To reproduce the issue I downloaded the latest code, then added a new method named GetPickRayOld, which I copied from an older version.  Then I ran the app, plugged in common X,Y values into both GetPickRay and GetPickRayOld but noticed I got different Rays back out.  Shouldn't both methods, the old and new version return the same value given the same inputs? 

Thanks!


Coordinator
Feb 22, 2011 at 9:59 AM

It does work a bit differently. I noticed it after a while. The problem was getting a general solution that worked for both perspective cameras and orthographic. Now its accurate on ortho but lost its accuracy on perspective. 

The plan is put a method on the IView interface for the cameras to implement that takes care of creating the correct pick ray.  Hopefully get it done soon. In the mean time, you can just go pick the "old" version of that method.