Problem is, Irrlicht uses f32 by default, which is of type float. It doesn't provide enough precision (5.2 gets mangled to 5.199999999999), and when you have both Lua and Newton Physics using doubles, it's impossible to do:
vector = RVector3D(5.2,2,3);
if (vector.X == 5.2)
then
print("Vector.X is 5.2");
else
print("Vector.X is not 5.2");
end
This yields Vector.X is not 5.2, simply because of the precision problem in Irrlicht.
I've tried changing the typedef of f32, but unfortunately it's used in both places where it's optional (such as values Irrlicht stores), and places where it isn't (such as fetching a value from DirectX or OpenGL).
Right now, I have 4 options:
- Set both Lua and Newton Physics to use float, causing precision problems in a scripting language and a physics engine, where users also expect print(5.2) to yeild 5.2, and not 5.1999999999999
- Store seperate values for X, Y and Z in my binding classes, using and updating them when appropriate
- Go through Irrlicht manually, finding out where f32 is optional and it isn't, replacing mandatory places with float.
- Ask people here
(In case you are wondering, it is not possible to use the vector's equals function, due to Lua being the one comparing numbers, not Irrlicht)