mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 12:54:00 +00:00
Fix bounding box calculation for terrain shapes
This commit is contained in:
parent
e0cf460ba3
commit
36fa51b6ad
@ -188,7 +188,7 @@ osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Ve
|
||||
geometry->setUseDisplayList(false);
|
||||
geometry->setUseVertexBufferObjects(true);
|
||||
|
||||
if (chunkSize <= 2.f)
|
||||
if (chunkSize <= 1.f)
|
||||
geometry->setLightListCallback(new SceneUtil::LightListCallback);
|
||||
|
||||
unsigned int numVerts = (mStorage->getCellVertices()-1) * chunkSize / (1 << lod) + 1;
|
||||
|
@ -173,10 +173,10 @@ public:
|
||||
node->setLodCallback(parent->getLodCallback());
|
||||
node->setViewDataMap(mViewDataMap);
|
||||
|
||||
if (center.x() - size > mMaxX
|
||||
|| center.x() + size < mMinX
|
||||
|| center.y() - size > mMaxY
|
||||
|| center.y() + size < mMinY )
|
||||
if (center.x() - halfSize > mMaxX
|
||||
|| center.x() + halfSize < mMinX
|
||||
|| center.y() - halfSize > mMaxY
|
||||
|| center.y() + halfSize < mMinY )
|
||||
// Out of bounds of the actual terrain - this will happen because
|
||||
// we rounded the size up to the next power of two
|
||||
{
|
||||
@ -191,8 +191,8 @@ public:
|
||||
if (mStorage->getMinMaxHeights(size, center, minZ, maxZ))
|
||||
{
|
||||
float cellWorldSize = mStorage->getCellWorldSize();
|
||||
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-size)*cellWorldSize, (center.y()-size)*cellWorldSize, minZ),
|
||||
osg::Vec3f((center.x()+size)*cellWorldSize, (center.y()+size)*cellWorldSize, maxZ));
|
||||
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-halfSize)*cellWorldSize, (center.y()-halfSize)*cellWorldSize, minZ),
|
||||
osg::Vec3f((center.x()+halfSize)*cellWorldSize, (center.y()+halfSize)*cellWorldSize, maxZ));
|
||||
node->setBoundingBox(boundingBox);
|
||||
}
|
||||
return node;
|
||||
|
Loading…
Reference in New Issue
Block a user