Floating point innacuracy or something else?

Blitz3D Forums/Blitz3D Programming/Floating point innacuracy or something else?

OrcSlayer(Posted 2005) [#1]
Ok, on my now very tiny starship (it's a little over a unit long), I am trying out the method which I plan to use for marking hardpoints and projectile exits. Using pivots (which will be in the model as bones when I get my own models), parented to the entity in the right spot for the projectile to come out, I copy the position and rotation of the pivots to every projectile created that belongs to that port. The problem is...

If the ship has not moved at all, it looks fine. But once I start to move it (turn, accelerate, anything), the positioning screws up. The result is very obvious, as they are created sometimes several tenths of a unit away from their needed location (which is big error at this scale).

However, I also tested making the projectiles at the starship entity position, then using move entity to manually place them at the exact same spot as the hardpoints should be (rather than copying from the pivots), and simply copying the rotation of the starship entity. The result is exactly what it's supposed to be. The first though I had was that this is related to floating point innacuracy, but if that is the case, why is it not affecting the other method as well?

If anyone has any ideas, please, let me know...


Chevron(Posted 2005) [#2]
I think making the players ship tiny to overcome your problem is the wrong way to go about it as you will create other problems in the process as you have now found.
Keep your objects at a reasonable size and use other methods to allow the player to fly around a huge area. I guess this is what you are wanting to acheive?

I would sugest keeping the player at the same position inside a texured shpere and rotate the sphere to give the impression of roll etc. Stars can be added within the sphere to give the impression of speed.

This is only a very basic explanation but hope you get the idea.


OrcSlayer(Posted 2005) [#3]
Actually the scale isn't overwhelmingly large...the view distance is 50000 and I do take advantage of a skybox, but there has to be a certain amount of scale to it to allow for the fairly large multi-planet systems, etc...

I suppose I can try increasing the scale of everything to the maximum I can work with, and then using a 'lock object at view range and scale' trick to make the planets and in-system stars still be visible beyond visual range.

I guess this will make the whole game easier to work with, as long as it fixes this rather tacky problem...I just can't figure out why the one option worked and the other didn't. The pivots were staying in place so the coordinates should have been correct, I would think.


WendellM(Posted 2005) [#4]
Actually the scale isn't overwhelmingly large...the view distance is 50000

That seems pretty large for a ship that's only one unit long, with weapons needing fractional-unit accuracy. Also, what's your minimum view distance? The ratio of maximum:minimum is what matters. Going below 1 for minimum effectively multiplies the effect of maximum view distance (so that "CameraRange 0.1, 100" is the effectively the same as "CameraRange 1, 1000", I believe).


Rob Farley(Posted 2005) [#5]
I'm guessing that you're doing a moveentity, turnentity or something AFTER getting the positions of the bones...

Make sure you get the positions of the bones after you have done all your turning and moving and it'll be fine.

ie

WRONG:
get bone positions
get input control
move player
create stuff based on bone positions

RIGHT:
get input control
move player
get bone positions
create stuff based on bone positions


OrcSlayer(Posted 2005) [#6]
Well, my minimum view distance is currently set to 1, but I'm starting to get the idea it needs to be something else...

The reason view distance is so big is because there will be much, much larger entities as well (dreadnaught class ships will be immense), and I need room for big cap-ship to cap-ship battles. The ship that was between 1-2 units long was a mere test fighter.

However, I did as you suggested, and increased the size of my player ship tenfold. Now, the accuracy is perfect and my problem with the hardpoints is solved. So, I'll just make planets bigger, and use tricks to keep them in view past viewdistance.

Thanks for the help guys!