Problem with ogre.math.abs function

Tom

31-08-2008 10:46:07

I'm trying to create a vector with absolute values, but ogre.Math.Abs keeps returning radians, instead of floats (as it should be, as I'm passing it floats). Here is an example:

entitySize = ogre.Vector3(ogre.Math.Abs(boundingBoxMax.x-boundingBoxMin.x),ogre.Math.Abs(boundingBoxMax.y-boundingBoxMin.y),ogre.Math.Abs(boundingBoxMax.z-boundingBoxMin.z))

This is the error I'm getting:

ArgumentError: Python argument types in
Vector3.__init__(Vector3, Radian, Radian, Radian)
did not match C++ signature:
__init__(struct _object *, float scaler)
__init__(struct _object *, float * r)
__init__(struct _object *, int const * afCoordinate)
__init__(struct _object *, float const * afCoordinate)
__init__(struct _object *, float fX, float fY, float fZ)
__init__(struct _object *)
__init__(struct _object *)

So for some reason or another ogre.Math.Abs() is returning Radians instead of floats like it should be. I've double checked to make sure boundingBoxMin and Max are both Vector's and they are. Also to be sure I printed ogre.Math.Abs(boundingBoxMax.x-boundingBoxMin.x) and it is indeed returning a Radian object. Printing just boundingBoxMax.x-boundingBoxMin.x returns a float, if that helps at all.
Oh and I'm using Python-Ogre 1.2 rc2

andy

31-08-2008 13:39:54

Short answer is to use the python abs or round function...

The issue you are seeing is the issue of multiple "abs" C++ functions that are overridden in strange ways :)

Basically there is an auto conversion from float to radians, when you call abs(float) boost is auto converting the float to a radian as that the first version of abs it finds and hence you get a radian returned...

I'll fix this in a future version with some aliasing..

Andy

Tom

01-09-2008 02:17:22

Ah, that's what I figured the problem was :) The other library I'm using has an abs function (and as you mentioned so does python), so it wasn't a huge issue, just thought I'd mention it.