1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-22 17:41:33 +00:00

Fix some hardcoded literals

This commit is contained in:
scrawl 2014-02-13 11:15:55 +01:00
parent c6fb0f2d9b
commit d4a755d1aa
2 changed files with 13 additions and 9 deletions

View file

@ -168,7 +168,8 @@ QuadTreeNode::QuadTreeNode(World* terrain, ChildDirection dir, float size, const
if (mParent) if (mParent)
pos = mParent->getCenter(); pos = mParent->getCenter();
pos = mCenter - pos; pos = mCenter - pos;
mSceneNode->setPosition(Ogre::Vector3(pos.x*8192, pos.y*8192, 0)); float cellWorldSize = mTerrain->getStorage()->getCellWorldSize();
mSceneNode->setPosition(Ogre::Vector3(pos.x*cellWorldSize, pos.y*cellWorldSize, 0));
mMaterialGenerator = new MaterialGenerator(mTerrain->getShadersEnabled()); mMaterialGenerator = new MaterialGenerator(mTerrain->getShadersEnabled());
} }
@ -203,6 +204,7 @@ void QuadTreeNode::initNeighbours()
void QuadTreeNode::initAabb() void QuadTreeNode::initAabb()
{ {
float cellWorldSize = mTerrain->getStorage()->getCellWorldSize();
if (hasChildren()) if (hasChildren())
{ {
for (int i=0; i<4; ++i) for (int i=0; i<4; ++i)
@ -210,11 +212,11 @@ void QuadTreeNode::initAabb()
mChildren[i]->initAabb(); mChildren[i]->initAabb();
mBounds.merge(mChildren[i]->getBoundingBox()); mBounds.merge(mChildren[i]->getBoundingBox());
} }
mBounds = Ogre::AxisAlignedBox (Ogre::Vector3(-mSize/2*8192, -mSize/2*8192, mBounds.getMinimum().z), mBounds = Ogre::AxisAlignedBox (Ogre::Vector3(-mSize/2*cellWorldSize, -mSize/2*cellWorldSize, mBounds.getMinimum().z),
Ogre::Vector3(mSize/2*8192, mSize/2*8192, mBounds.getMaximum().z)); Ogre::Vector3(mSize/2*cellWorldSize, mSize/2*cellWorldSize, mBounds.getMaximum().z));
} }
mWorldBounds = Ogre::AxisAlignedBox(mBounds.getMinimum() + Ogre::Vector3(mCenter.x*8192, mCenter.y*8192, 0), mWorldBounds = Ogre::AxisAlignedBox(mBounds.getMinimum() + Ogre::Vector3(mCenter.x*cellWorldSize, mCenter.y*cellWorldSize, 0),
mBounds.getMaximum() + Ogre::Vector3(mCenter.x*8192, mCenter.y*8192, 0)); mBounds.getMaximum() + Ogre::Vector3(mCenter.x*cellWorldSize, mCenter.y*cellWorldSize, 0));
} }
void QuadTreeNode::setBoundingBox(const Ogre::AxisAlignedBox &box) void QuadTreeNode::setBoundingBox(const Ogre::AxisAlignedBox &box)

View file

@ -113,9 +113,10 @@ namespace Terrain
// We arrived at a leaf // We arrived at a leaf
float minZ,maxZ; float minZ,maxZ;
Ogre::Vector2 center = node->getCenter(); Ogre::Vector2 center = node->getCenter();
float cellWorldSize = getStorage()->getCellWorldSize();
if (mStorage->getMinMaxHeights(node->getSize(), center, minZ, maxZ)) if (mStorage->getMinMaxHeights(node->getSize(), center, minZ, maxZ))
node->setBoundingBox(Ogre::AxisAlignedBox(Ogre::Vector3(-halfSize*8192, -halfSize*8192, minZ), node->setBoundingBox(Ogre::AxisAlignedBox(Ogre::Vector3(-halfSize*cellWorldSize, -halfSize*cellWorldSize, minZ),
Ogre::Vector3(halfSize*8192, halfSize*8192, maxZ))); Ogre::Vector3(halfSize*cellWorldSize, halfSize*cellWorldSize, maxZ)));
else else
node->markAsDummy(); // no data available for this node, skip it node->markAsDummy(); // no data available for this node, skip it
return; return;
@ -168,8 +169,9 @@ namespace Terrain
return Ogre::AxisAlignedBox::BOX_NULL; return Ogre::AxisAlignedBox::BOX_NULL;
QuadTreeNode* node = findNode(center, mRootNode); QuadTreeNode* node = findNode(center, mRootNode);
Ogre::AxisAlignedBox box = node->getBoundingBox(); Ogre::AxisAlignedBox box = node->getBoundingBox();
box.setExtents(box.getMinimum() + Ogre::Vector3(center.x, center.y, 0) * 8192, float cellWorldSize = getStorage()->getCellWorldSize();
box.getMaximum() + Ogre::Vector3(center.x, center.y, 0) * 8192); box.setExtents(box.getMinimum() + Ogre::Vector3(center.x, center.y, 0) * cellWorldSize,
box.getMaximum() + Ogre::Vector3(center.x, center.y, 0) * cellWorldSize);
return box; return box;
} }