While attempting to optimize my getHeight() function I noticed that the GrassLoader will occasionally query my getHeight() function with negative x and negative y values, which of course results in a garbage height value. I expected the values to range between the supplied bounds of Forests::TBounds(0, 0, 2500, 2500); I tried changing my terrain size, TBounds, and other PG setup parameters to powers of 2, 8, and 16 but the issue persists. Is it possible I am setting up the grassLoader incorrectly? It's not causing any fatal errors, but it is an anomaly that I thought should be reported.
These are the parameters I am using:
Page Size 180
Fade Technique GROW
Render Technique CROSSQUADS
Bounds 0 0 2500 2500
Thanks for the report, I'll take a look at this when I get a chance (probably tomorrow evening).
I found a similar issue in the precompiled "Example 4 GrassLoader" demo. Notice how the grass is positioned completely off the terrain and in some cases is stretched downwards. The tree loader seems to be better behaved, I have yet to find a tree off the terrain. If I get some time, I'll dig into the code and see if I can 1) understand it and 2) fix it. It's the understanding it part that seems to take the most time. Perhaps if the function bodies had more comments....
//Loads the given page of geometry immediately
//Note: _loadPage() does add the page to loadedList, so that will have to be done manually
void GeometryPageManager::_loadPage(GeometryPage *page)
//Calculate page info
Real halfPageSize = mainGeom->getPageSize() * 0.5f;
info.bounds.left = page->_centerPoint.x - halfPageSize;
info.bounds.right = page->_centerPoint.x + halfPageSize;
info.bounds.top = page->_centerPoint.z - halfPageSize;
info.bounds.bottom = page->_centerPoint.z + halfPageSize;
info.centerPoint = page->_centerPoint;
This is where the problem is, you should check:
if bounds.left < MapBounds.left
if bounds.right > MapBounds.right
if bounds.top < MapBounds.top
if bounds.bottom > MapBounds.bottom
because when CENTER is close to map borders, you get values out of range when you add or subtract half page size...