I'm building a game with a very large infinite world and I load in chunks as I go.
However a slight issue with this is that the further you get the less precise locations get due to losing precision (since coordinates are 32 bit floating point values)
I load in my chunks as a chunk offset by an integer coordinate system (stored as 64 bit integers), each chunk has its own local integer system for storing its blocks and this is working fine (and incidentally gives me a world volume of 5.02*10^55 kilometers^3, this is incidentally 3.56*10^37 times larger than the sun which is a "measly" 1.41*10^18 kilometers^3 (1.3M times earth), more than enough space in other words), however the precision of a 32 bit floating point value runs out long before I get the ability to reach these far reaches of my world.
So really, my question boils down to: How would I go about storing locations relative to these sectors (chunks) of the world?
Essentially I want this to happen:
as entity X moves from chunk A to chunk B it should now treat its location relative to chunk B's local space instead of chunk A's local space.
entity X can of course be anything from an NPC to a physics entity bouncing around to the player or anything else.
World space does not matter here, none of my code currently depends on it, everything would be done in a per chunk local space.
Is this a capability irrlicht has or would I have to modify the internals of the engine to accomplish it?
store entity locations relative to world sectors?
-
Cube_
- Posts: 1010
- Joined: Mon Oct 24, 2011 10:03 pm
- Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d
store entity locations relative to world sectors?
"this is not the bottleneck you are looking for"
Re: store entity locations relative to world sectors?
It's a limitation with any system.
Maybe scale your world by 1000 or more? What I means is making it smaller.
Or just build and update your world relative to camera position. E.g. camera position always at (0,0,0)
regards
thanh
Maybe scale your world by 1000 or more? What I means is making it smaller.
Or just build and update your world relative to camera position. E.g. camera position always at (0,0,0)
regards
thanh
-
Cube_
- Posts: 1010
- Joined: Mon Oct 24, 2011 10:03 pm
- Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d
Re: store entity locations relative to world sectors?
I was hoping I could avoid that, I don't wish to perform transformations on thousands of entities as that's a performance hog.
the only way I can think of doing that well is to have a chunk marked as the origin chunk where the camera resides and have every other entity be owned by the chunk it currently resides in/was created in (I still wish to have the ownership change but for non-player entities I could probably just save the metadata to a swap region in ram and then re-create the entity, re-apply the metadata and move on, might cause weirdness with physics though).
I was really hoping I could find another solution to this (on the bright side I don't ever have to worry about running out of coordinate space, so long I can keep allocating unique ID's for chunks).
the only way I can think of doing that well is to have a chunk marked as the origin chunk where the camera resides and have every other entity be owned by the chunk it currently resides in/was created in (I still wish to have the ownership change but for non-player entities I could probably just save the metadata to a swap region in ram and then re-create the entity, re-apply the metadata and move on, might cause weirdness with physics though).
I was really hoping I could find another solution to this (on the bright side I don't ever have to worry about running out of coordinate space, so long I can keep allocating unique ID's for chunks).
"this is not the bottleneck you are looking for"
Re: store entity locations relative to world sectors?
I'm working on a project that required the same thing the only reliable way I found was using double precision in the physic engine and translating back to irrlicht
are you using only irrlicht or is there anything else used there?
Also placing the camera at (0,0,0) will save you a lot of headache with zfighting
also realize that even if you create regions you will still need to move those region around when moving the camera or the precision issue will show up anyway and if you move the region all it's children move to turning the region thing into an other way to waste cpu
are you using only irrlicht or is there anything else used there?
Also placing the camera at (0,0,0) will save you a lot of headache with zfighting
also realize that even if you create regions you will still need to move those region around when moving the camera or the precision issue will show up anyway and if you move the region all it's children move to turning the region thing into an other way to waste cpu