1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-22 11:09:40 +00:00

Fix bounding box calculation for terrain shapes

This commit is contained in:
bzzt 2019-02-20 13:37:00 +00:00 committed by Andrei Kortunov
parent e0cf460ba3
commit 36fa51b6ad
2 changed files with 7 additions and 7 deletions

View file

@ -188,7 +188,7 @@ osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Ve
geometry->setUseDisplayList(false); geometry->setUseDisplayList(false);
geometry->setUseVertexBufferObjects(true); geometry->setUseVertexBufferObjects(true);
if (chunkSize <= 2.f) if (chunkSize <= 1.f)
geometry->setLightListCallback(new SceneUtil::LightListCallback); geometry->setLightListCallback(new SceneUtil::LightListCallback);
unsigned int numVerts = (mStorage->getCellVertices()-1) * chunkSize / (1 << lod) + 1; unsigned int numVerts = (mStorage->getCellVertices()-1) * chunkSize / (1 << lod) + 1;

View file

@ -173,10 +173,10 @@ public:
node->setLodCallback(parent->getLodCallback()); node->setLodCallback(parent->getLodCallback());
node->setViewDataMap(mViewDataMap); node->setViewDataMap(mViewDataMap);
if (center.x() - size > mMaxX if (center.x() - halfSize > mMaxX
|| center.x() + size < mMinX || center.x() + halfSize < mMinX
|| center.y() - size > mMaxY || center.y() - halfSize > mMaxY
|| center.y() + size < mMinY ) || center.y() + halfSize < mMinY )
// Out of bounds of the actual terrain - this will happen because // Out of bounds of the actual terrain - this will happen because
// we rounded the size up to the next power of two // we rounded the size up to the next power of two
{ {
@ -191,8 +191,8 @@ public:
if (mStorage->getMinMaxHeights(size, center, minZ, maxZ)) if (mStorage->getMinMaxHeights(size, center, minZ, maxZ))
{ {
float cellWorldSize = mStorage->getCellWorldSize(); float cellWorldSize = mStorage->getCellWorldSize();
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-size)*cellWorldSize, (center.y()-size)*cellWorldSize, minZ), osg::BoundingBox boundingBox(osg::Vec3f((center.x()-halfSize)*cellWorldSize, (center.y()-halfSize)*cellWorldSize, minZ),
osg::Vec3f((center.x()+size)*cellWorldSize, (center.y()+size)*cellWorldSize, maxZ)); osg::Vec3f((center.x()+halfSize)*cellWorldSize, (center.y()+halfSize)*cellWorldSize, maxZ));
node->setBoundingBox(boundingBox); node->setBoundingBox(boundingBox);
} }
return node; return node;