Hmm, I'm in a pickle. Long story short: is there anything bad I should look out for if I lower this variable (in irrtonewt.hpp) to something lower?
Code: Select all
//!Convert a position from newton to irrlicht
const irr::f32 NewtonToIrr = 32.0f;
Or, would recompiling IrrNewt with a different NewtonToIrr value (say, 8.0f or 4.0f) be a horrible idea? I ask because I set each Irrlicht unit to 1 meter, and then Newton couldn't handle a 2m x 2m x 2m cube!
If anyone's had problems or experience with Newton's and Irrlicht's units' precision, any advice would be great! Of course it depends on my specific project though, so here are some details:
- In a nutshell, it's a first-person platformer with shooting.
- You're a human-sized character, but you're usually quite fast, and can jump very high.
- I'd prefer to have 1 Irrlicht unit = 1 meter, but having physics that actually work is the priority =p
- Environments will range from very open to somewhat cramped. I have in mind areas that are really huge, but don't have a lot of detail (trying to keep a low polygon count).
- It's pretty darn important that the player can't go through walls.
- At times the player will travel extremely fast (think "Speed Booster" from Metroid games) - I'll probably have to do some unconventional things to prevent a speed-boosting player from going through walls.
- Some weapons will need to use ray-casting for collision, others will shoot out Newton bodies at high speeds.
- Generally there won't be a whole lot of physics going on unless you're shooting... the most physics-intensive thing I can forsee is if there are lots of small enemies in one room, or a room with many destructable walls (though the destructable peices won't really interact with each other).
- Various special effects (bits of stuff flying around) might be as small as 5 cm (we'll see), but it's not important if these effects aren't really accurate.
- Although I'm coding the game to accept any reasonable framerate, I'm thinking the game will ultimately update 60 times a second (and the game will slow down if Newton can't handle it).
And for those who are bored and want to read the full story:
In Irrlicht, I was previously using 1 unit = 1 centimeter. But I'm going to be dealing with huge velocities and distances, and I read that Newton can't handle large distances very well, so I changed it to 1 unit = 1 meter. This change also made part of my code a lot easier to read!
Just today though I made a 2-meter-cubed cube and a 2-meter-diameter sphere, and applied a 9.81 m/s2 gravity force to them... holy precision errors Batman! Skip the rest of the paragraph if you don't care to read exactly what happened

The cube would slide around on the ground, and instead of stopping, it would kind of roll around in slow motion for a while, and then when it finally begins to stop it would start sinking though the ground and then drop right through the floor! The sphere wasn't much better; it wouldn't roll, it would just rotate slowly, and kind of slide along the ground, with the bottom of it sticking through the floor. Unacceptable!! =p
So, I take this sphere and cube and make them 10 times bigger (20 m), and make the force of gravity 10 times stronger... and of course they work perfectly!
I noticed IrrNewt must be converting to/from Irrlicht units to Newton units here in irrtonewt.hpp:
Code: Select all
//!Convert a position from newton to irrlicht
const irr::f32 NewtonToIrr = 32.0f;
//!Convert a position from irrlicht to newton
const irr::f32 IrrToNewton = ( 1.0f / NewtonToIrr ) ;
I really want to continue using 1 unit = 1 meter... not because it would be hard to change my code, but because meters are so much nicer to work with than centimeters, or *shudder* decimeters. At the same time, I don't know the consequences of having gigantic levels in Newton. Thanks for reading =)