Request: real template-class vector

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Manawenuz
Posts: 22
Joined: Wed Jun 10, 2009 12:42 am
Location: France

Request: real template-class vector

Post by Manawenuz »

Hi everybody,

I suggest that the vector2d and vector3d classes be really template classes.
Indeed, the ISceneNode::setPosition method takes as an argument a 'vector3df', whereas I would like to pass a vector3d<double>...
Why isn't there templates everywhere?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Because the gfx APIs (OpenGL and D3D) cannot handle doubles. This would increase the render time due to too many conversions. And most people woulnd't gain a thing from this extra precision. Most of the basic class methods are already templated and should work as expected.
Manawenuz
Posts: 22
Joined: Wed Jun 10, 2009 12:42 am
Location: France

Post by Manawenuz »

OK Thanks for the answer.
But it would have been useful for me, because I need to draw space vessels and planets at the scale, with a precision of 1 cm...
But I will do it in an other way.
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

Little Hint: keep in mind that the mantissa of a float is 7 and for a double 15 digits. So you can not easily add i.e. 0.00124 to 1234^10. So i guess none of the basic data types will fullfill your requirements.

P.S: think about seperating space into different blocks :)
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Anyway, if you want a specific range, you do not want float, since the quality of float will vary. You integet want integer, based on your smallest unit (a very big integer, called, guess what, big int), or a fixed point system built again on the same integer. But better yet, you can split your game's world in sections or bucket, and consider everything in one such section as being from point 0.0 in the middle of it. That way you can mix and match integer and floats. Lots of documentation on that specific subject, look around m8.
Post Reply