Research the ground mesh's boundary box (stored in the RSW file)
rdw-software opened this issue · 5 comments
Is it actually the bounding box? If so, what is it used for?
The default values appear to be [-500, 500]
for both dimensions. Does this need to be scaled in order to get the units in actual world coordinates?
I looked into this briefly today - it looks like the quad trees embedded in the RSW files are used to help reduce memory usage and speed up the client by only loading objects near the player.
Resources that should help kickstart more thorough research:
Thanks, I actually have some notes about the culling performed by the client. There were some odd tree models that the creator of RoBrowser noticed weren't actually visible because they were outside the bounding box and therefore culled, despite being present in the map files.
They may actually serve as a boundary of sorts? I didn't spend much time on it yet. I'd like to verify what I've read and document the findings, though it's not a very high priority issue since it's not exactly critical to rendering the maps.
I suppose the exact connection between the ground mesh's bounding box and that of the individual models would still need to be verified; I'd expect them to perform a basic "collision" check using the quad tree nodes and the model's bounding box to determine which objects to remove from the scene graph.
Quad-tree visualization (Source: BrowEdit Discord):
A picture says it all. Coupled with some explanation/references regarding the culling this should be more than enough info to help people understand the basic idea behind quad-tree nodes and its relation to scene graphs.
I didn't even use them myself, so I guess it's somewhat optional if not writing a renderer from scratch.
I just looked into this again, and I noticed two things:
- This issue was originally supposed to be about the bounding box, not the scene graph/quad tree. Whoops?
- The BrowEdit screenshot shows the scene graph nodes, but the Y axis is inverted (bounding area of the trees is underground)
The oddity with the actual bounding box is that its dimensions seem all over the place. Often, they're just zero, or some arbitrarily large number, which makes me wonder what the deal is with it. I know GRF Editor also reads the same values, so it can't just be a decoding error on my part... 🤔
My current guess is that this is simply the boundaries of the map's coordinate system, based on some post by curiosity (no idea where, it's been ages since I read it) claiming that the maximum map size is 1000x1000 in RO's coordinate system.
Why the stored values are so weird at times, I can't yet explain.
I think this is just the boundary of the visible world (scene), and if the value is garbage they might just clamp it to the default?
Either way, I doubt anyone wants to implement their ancient rendering logic when stellar engines exist that do it better.