Skip to content

Commit 9df76f7

Browse files
authored
fix(heightmap): Fix CENTER_LIMIT condition in HeightMapRenderObjClass::updateCenter (TheSuperHackers#2078)
1 parent aa07366 commit 9df76f7

1 file changed

Lines changed: 57 additions & 59 deletions

File tree

Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,68 +1777,66 @@ void HeightMapRenderObjClass::updateCenter(CameraClass *camera , RefRenderObjLis
17771777
return;
17781778
}
17791779

1780-
if (abs(deltaX)>CENTER_LIMIT || abs(deltaY)>CENTER_LIMIT) {
1781-
if (abs(deltaY) >= CENTER_LIMIT) {
1782-
if (m_map->setDrawOrg(m_map->getDrawOrgX(), newOrgY)) {
1783-
Int minY = 0;
1784-
Int maxY = 0;
1785-
deltaY -= newOrgY - m_map->getDrawOrgY();
1786-
m_originY += deltaY;
1787-
if (m_originY >= m_y-1) m_originY -= m_y-1;
1788-
if (deltaY<0) {
1789-
minY = m_originY;
1790-
maxY = m_originY-deltaY;
1791-
} else {
1792-
minY = m_originY - deltaY;
1793-
maxY = m_originY;
1794-
}
1795-
minY-=cellOffset;
1796-
if (m_originY < 0) m_originY += m_y-1;
1797-
if (minY<0) {
1798-
minY += m_y-1;
1799-
if (minY<0) minY = 0;
1800-
updateBlock(0, minY, m_x-1, m_y-1, m_map, pLightsIterator);
1801-
updateBlock(0, 0, m_x-1, maxY, m_map, pLightsIterator);
1802-
} else {
1803-
updateBlock(0, minY, m_x-1, maxY, m_map, pLightsIterator);
1804-
}
1780+
if (abs(deltaY) > CENTER_LIMIT) {
1781+
if (m_map->setDrawOrg(m_map->getDrawOrgX(), newOrgY)) {
1782+
Int minY = 0;
1783+
Int maxY = 0;
1784+
deltaY -= newOrgY - m_map->getDrawOrgY();
1785+
m_originY += deltaY;
1786+
if (m_originY >= m_y-1) m_originY -= m_y-1;
1787+
if (deltaY<0) {
1788+
minY = m_originY;
1789+
maxY = m_originY-deltaY;
1790+
} else {
1791+
minY = m_originY - deltaY;
1792+
maxY = m_originY;
18051793
}
1806-
// It is much more efficient to update a cople of columns one frame, and then
1807-
// a couple of rows. So if we aren't "jumping" to a new view, and have done X
1808-
// recently, return.
1809-
if (abs(deltaX) < BIG_JUMP && !m_doXNextTime) {
1810-
m_updating = false;
1811-
m_doXNextTime = true;
1812-
return; // Only do the y this frame. Do x next frame. jba.
1794+
minY-=cellOffset;
1795+
if (m_originY < 0) m_originY += m_y-1;
1796+
if (minY<0) {
1797+
minY += m_y-1;
1798+
if (minY<0) minY = 0;
1799+
updateBlock(0, minY, m_x-1, m_y-1, m_map, pLightsIterator);
1800+
updateBlock(0, 0, m_x-1, maxY, m_map, pLightsIterator);
1801+
} else {
1802+
updateBlock(0, minY, m_x-1, maxY, m_map, pLightsIterator);
18131803
}
18141804
}
1815-
if (abs(deltaX) > CENTER_LIMIT) {
1816-
m_doXNextTime = false;
1817-
newOrgX = m_map->getDrawOrgX() + deltaX;
1818-
if (m_map->setDrawOrg(newOrgX, m_map->getDrawOrgY())) {
1819-
Int minX = 0;
1820-
Int maxX = 0;
1821-
deltaX -= newOrgX - m_map->getDrawOrgX();
1822-
m_originX += deltaX;
1823-
if (m_originX >= m_x-1) m_originX -= m_x-1;
1824-
if (deltaX<0) {
1825-
minX = m_originX;
1826-
maxX = m_originX-deltaX;
1827-
} else {
1828-
minX = m_originX - deltaX;
1829-
maxX = m_originX;
1830-
}
1831-
minX-=cellOffset;
1832-
maxX+=cellOffset;
1833-
if (m_originX < 0) m_originX += m_x-1;
1834-
if (minX<0) {
1835-
minX += m_x-1;
1836-
if (minX<0) minX = 0;
1837-
updateBlock(minX,0,m_x-1, m_y-1, m_map, pLightsIterator);
1838-
updateBlock(0,0,maxX, m_y-1, m_map, pLightsIterator);
1839-
} else {
1840-
updateBlock(minX,0,maxX, m_y-1, m_map, pLightsIterator);
1841-
}
1805+
// It is much more efficient to update a couple of columns one frame, and then
1806+
// a couple of rows. So if we aren't "jumping" to a new view, and have done X
1807+
// recently, return.
1808+
if (abs(deltaX) < BIG_JUMP && !m_doXNextTime) {
1809+
m_updating = false;
1810+
m_doXNextTime = true;
1811+
return; // Only do the y this frame. Do x next frame. jba.
1812+
}
1813+
}
1814+
if (abs(deltaX) > CENTER_LIMIT) {
1815+
m_doXNextTime = false;
1816+
newOrgX = m_map->getDrawOrgX() + deltaX;
1817+
if (m_map->setDrawOrg(newOrgX, m_map->getDrawOrgY())) {
1818+
Int minX = 0;
1819+
Int maxX = 0;
1820+
deltaX -= newOrgX - m_map->getDrawOrgX();
1821+
m_originX += deltaX;
1822+
if (m_originX >= m_x-1) m_originX -= m_x-1;
1823+
if (deltaX<0) {
1824+
minX = m_originX;
1825+
maxX = m_originX-deltaX;
1826+
} else {
1827+
minX = m_originX - deltaX;
1828+
maxX = m_originX;
1829+
}
1830+
minX-=cellOffset;
1831+
maxX+=cellOffset;
1832+
if (m_originX < 0) m_originX += m_x-1;
1833+
if (minX<0) {
1834+
minX += m_x-1;
1835+
if (minX<0) minX = 0;
1836+
updateBlock(minX,0,m_x-1, m_y-1, m_map, pLightsIterator);
1837+
updateBlock(0,0,maxX, m_y-1, m_map, pLightsIterator);
1838+
} else {
1839+
updateBlock(minX,0,maxX, m_y-1, m_map, pLightsIterator);
18421840
}
18431841
}
18441842
}

0 commit comments

Comments
 (0)