Align generated regions at custom bounds?

msteiger

Active Member
Contributor
World
Architecture
Logistics
Hi,
I have the following problem and could need some inspiration on how to approach it best. PolyWorld generates terrain information in large chunks (512 x 512 blocks called sectors) but at a coarse level.

When integrated in WorldProvider's generating strategy, it needs to provide information at given region sizes (by GeneratingRegion). These regions are (in general) not aligned at the 512x512 grid. See this example:


Now, to be able to provide content for the red rectangle, every facet provider needs to know about the 4 sectors it overlaps. But again, the providers provide info for full 512x512 sectors. This info is put in a cache to be ready when other parts of the sector are requested later. Every facet type now contains a list of sectors it overlaps and a map that points from sector to the actual info.

As you can see this is quite cumbersome. Is there a smarter way? I thought about cutting GeneratingRegion into parts that are aligned along sector bounds, but unsure if that's doable and if it makes sense.

Any thoughts?
 

msteiger

Active Member
Contributor
World
Architecture
Logistics
I rejected the thought of GeneratingRegion.getSubRegion() as I think that's not possible to implement it.
As a consequence, the GeneratingRegion cannot be modified, so I guess the entire region must be provided as a whole.

This is how it currently works:
There's GraphFacet that provides a collection of (Voronoi) graphs for a given GeneratingRegions. Depending on the intersection with sectors, this is between 1 and 4 graphs.
WaterFacetProvider basically is a simple HashMap (1-4 entries) that links a Voronoi graph to their respective water models.
Similarly, MoistureFacetProvider, ElevationFacetProvider, etc. use GraphFacet to get the graph and a HashMap to derive block-based information.
 
Top