Small OgreBites bug?

Minor issues with the Ogre API that can be trivial to fix
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Small OgreBites bug?

Post by lingfors »

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);
}
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: Small OgreBites bug?

Post by Mind Calamity »

Aren't those two code blocks you just posted exactly the same ?
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Small OgreBites bug?

Post by syedhs »

I think lingfors forget to multiply the return value by the screen dimension - which is what the patch is all about. :mrgreen:

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
User avatar
spacegaier
OGRE Team Member
OGRE Team Member
Posts: 4304
Joined: Mon Feb 04, 2008 2:02 pm
Location: Germany
x 136

Re: Small OgreBites bug?

Post by spacegaier »

Then please add it to the patch tracker. Otherwise it will get lot here...
Ogre Admin [Admin, Dev, PR, Finance, Wiki, etc.] | BasicOgreFramework | AdvancedOgreFramework
Don't know what to do in your spare time? Help the Ogre wiki grow! Or squash a bug...
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58

Re: Small OgreBites bug?

Post by CABAListic »

The difference is in the placement of the - sign before result.y.
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Re: Small OgreBites bug?

Post by Mind Calamity »

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.
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
User avatar
lingfors
Hobgoblin
Posts: 525
Joined: Mon Apr 02, 2007 12:18 am
Location: Sweden
x 79

Re: Small OgreBites bug?

Post by lingfors »

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...