Minor issues with the Ogre API that can be trivial to fix
lingfors
Hobgoblin
Posts: 525 Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79
Post
by lingfors » Sun Jan 22, 2012 1:50 am
I think I just found a small bug in OgreBites/SdkTrays:
Code: Select all
/*-----------------------------------------------------------------------------
| Converts a 3D scene position to a 2D screen coordinate (in pixels).
-----------------------------------------------------------------------------*/
static Ogre::Vector2 sceneToScreen(const Ogre::Camera* cam, const Ogre::Vector3& pt)
{
Ogre::Vector3 result = cam->getProjectionMatrix() * cam->getViewMatrix() * pt;
return Ogre::Vector2((result.x + 1) / 2, -(result.y + 1) / 2);
}
should be
Code: Select all
/*-----------------------------------------------------------------------------
| Converts a 3D scene position to a 2D screen coordinate (in pixels).
-----------------------------------------------------------------------------*/
static Ogre::Vector2 sceneToScreen(const Ogre::Camera* cam, const Ogre::Vector3& pt)
{
Ogre::Vector3 result = cam->getProjectionMatrix() * cam->getViewMatrix() * pt;
return Ogre::Vector2((result.x + 1) / 2, (-result.y + 1) / 2);
}
Mind Calamity
Ogre Magi
Posts: 1255 Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81
Post
by Mind Calamity » Sun Jan 29, 2012 6:22 pm
Aren't those two code blocks you just posted exactly the same ?
syedhs
Silver Sponsor
Posts: 2703 Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51
Post
by syedhs » Sun Jan 29, 2012 6:36 pm
I think lingfors forget to multiply the return value by the screen dimension - which is what the patch is all about.
Edit: Or maybe the code simply returns the 0.00 to 1.00 which works okay, but it is the comment that should be changed. I don't read actual source code though.
Last edited by syedhs on Sun Jan 29, 2012 6:38 pm, edited 1 time in total.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
spacegaier
OGRE Team Member
Posts: 4304 Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 136
Post
by spacegaier » Sun Jan 29, 2012 6:37 pm
Then please add it to the patch tracker. Otherwise it will get lot here...
CABAListic
OGRE Retired Team Member
Posts: 2903 Joined: Thu Jan 18, 2007 2:48 pm
x 58
Post
by CABAListic » Sun Jan 29, 2012 6:38 pm
The difference is in the placement of the - sign before result.y.
Mind Calamity
Ogre Magi
Posts: 1255 Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81
Post
by Mind Calamity » Sun Jan 29, 2012 6:51 pm
CABAListic wrote: The difference is in the placement of the - sign before result.y.
Oh, I missed that! The lengths of the return lines were exactly the same so I didn't even bother to read it.
lingfors
Hobgoblin
Posts: 525 Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79
Post
by lingfors » Sun Jan 29, 2012 9:46 pm
Mind Calamity wrote: CABAListic wrote: The difference is in the placement of the - sign before result.y.
Oh, I missed that! The lengths of the return lines were exactly the same so I didn't even bother to read it.
The devil is in the detail.
Added to the bug tracker.
Although, as has been pointed out, the comment isn't correct either...