Simsilica pager: Paged grids must be square in the x, z plane. - Why?

I’m using @pspeed’s pager to implement an infinite surface of hexagons. Due to the nature of equilateral hexagons a chunk of them will never have the same size in the x and z dimension. My first attempt was to define the grid spacing as a rectangle and not a square to bypass the size issue of a hexagon chunk.

rootGrid = new Grid(new Vector3f(1f, 0f, 0.8f), new Vector3f(0, 0, 0));

As a result, I got this exception:

java.lang.IllegalArgumentException: Paged grids must be square in the x, z plane.
    at com.simsilica.pager.PagedGrid.<init>(PagedGrid.java:115)
    at com.simsilica.pager.PagedGrid.<init>(PagedGrid.java:100)

I manged to use a square based grid in the end by using some ugly offset calculations for the chunks. It works very well out but I’m curious why the grid have to be a square. For block worlds like minecraft it seems reasonable to me but in my use-case it isn’t the simplest solution.

All in all I want to say thanks for this great pager library. It performs very well after sorting this issue out.
Greetings, Jan

Glancing through the code, it might have been an older limitation. I see only one place that even queries those values and it isn’t even using the value.

So it could be that you can simply remove the check and see if everything still works.

“Radius” will still be constant in the xz plane as far as grid cells go. So if your grid is non-square then so will be your visible area. Meaning that the visible area is center +/- radius number of grid cells.

1 Like

I thought so. Thanks for clarifying this.

I wont test it in the near time because I got it working with square girds. When my game is decent working I will try rectangular grids to remove the ugly math.