Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/GameEngine/Include/GameClient/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class View : public Snapshot
void setPosition( const Coord3D &pos ) { m_pos = pos; }
void setPosition2D( const Coord2D &pos ) { m_pos.x = pos.x; m_pos.y = pos.y; }
const Coord3D &getPosition() const { return m_pos; } ///< Returns position camera is looking at
Coord2D getPosition2D() const { Coord2D c = { m_pos.x, m_pos.y }; return c; } ///< Returns position camera is looking at
Coord2D getPosition2D() const { return m_pos.asCoord2D(); } ///< Returns position camera is looking at

virtual Coord3D get3DCameraPosition() const { Coord3D c={0,0,0}; return c; } ///< Returns the actual camera position
virtual Coord3D get3DCameraDirection() const { Coord3D c={0,0,0}; return c; } ///< Returns the actual camera view direction
Expand Down
21 changes: 3 additions & 18 deletions Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,11 @@ void GameWindow::unlinkFromTransitionWindows()
//=============================================================================
void GameWindow::normalizeWindowRegion()
{
Int temp;

if( m_region.lo.x > m_region.hi.x)
{

temp = m_region.lo.x;
m_region.lo.x = m_region.hi.x;
m_region.hi.x = temp;

}
if( m_region.lo.x > m_region.hi.x )
std::swap( m_region.lo.x, m_region.hi.x );

if( m_region.lo.y > m_region.hi.y )
{

temp = m_region.lo.y;
m_region.lo.y = m_region.hi.y;
m_region.hi.y = temp;

}

std::swap( m_region.lo.y, m_region.hi.y );
}

// GameWindow::findFirstLeaf ==================================================
Expand Down
26 changes: 9 additions & 17 deletions Core/GameEngine/Source/GameClient/Line2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,12 @@ Bool PointInsideRect3D(const Coord3D *bl, const Coord3D *tl, const Coord3D *br,
const Coord3D *inputPoint)
{
Coord2D bl2d, tl2d, br2d, tr2d, pt;
bl2d.x = bl->x;
bl2d.y = bl->y;
tl2d.x = tl->x;
tl2d.y = tl->y;
br2d.x = br->x;
br2d.y = br->y;
tr2d.x = tr->x;
tr2d.y = tr->y;

pt.x = inputPoint->x;
pt.y = inputPoint->y;
bl2d = bl->asCoord2D();
tl2d = tl->asCoord2D();
br2d = br->asCoord2D();
tr2d = tr->asCoord2D();

pt = inputPoint->asCoord2D();

return PointInsideRect2D(&bl2d, &br2d, &tl2d, &tr2d, &pt);
}
Expand All @@ -322,14 +317,11 @@ Bool PointInsideArea2D( const Coord3D *ptToTest, const Coord3D *area, Int numPoi
{
int numIntersections = 0;
Coord2D pt2D, area2D1, area2D2;
pt2D.x = ptToTest->x;
pt2D.y = ptToTest->y;
pt2D = ptToTest->asCoord2D();

for (int i = 0; i < numPointsInArea; ++i) {
area2D1.x = area[i].x;
area2D1.y = area[i].y;
area2D2.x = area[(i + 1) % numPointsInArea].x;
area2D2.y = area[(i + 1) % numPointsInArea].y;
area2D1 = area[i].asCoord2D();
area2D2 = area[(i + 1) % numPointsInArea].asCoord2D();
if (IntersectLine2D(&pt2D, &reallyFarPoint, &area2D1, &area2D2)) {
++numIntersections;
}
Expand Down
72 changes: 12 additions & 60 deletions Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2726,12 +2726,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
bounds.lo.y = globalBounds.lo.y + yBlock*ZONE_BLOCK_SIZE;
bounds.hi.x = bounds.lo.x + ZONE_BLOCK_SIZE - 1; // bounds are inclusive.
bounds.hi.y = bounds.lo.y + ZONE_BLOCK_SIZE - 1; // bounds are inclusive.
if (bounds.hi.x > globalBounds.hi.x) {
bounds.hi.x = globalBounds.hi.x;
}
if (bounds.hi.y > globalBounds.hi.y) {
bounds.hi.y = globalBounds.hi.y;
}
bounds.hi.updateMin(globalBounds.hi);
#if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING
if (bounds.lo.x>bounds.hi.x || bounds.lo.y>bounds.hi.y) {
DEBUG_CRASH(("Incorrect bounds calculation. Logic error, fix me. jba."));
Expand Down Expand Up @@ -2828,11 +2823,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
bounds.hi.x = bounds.lo.x + ZONE_BLOCK_SIZE - 1; // bounds are inclusive.
bounds.hi.y = bounds.lo.y + ZONE_BLOCK_SIZE - 1; // bounds are inclusive.

if (bounds.hi.x > globalBounds.hi.x)
bounds.hi.x = globalBounds.hi.x;

if (bounds.hi.y > globalBounds.hi.y)
bounds.hi.y = globalBounds.hi.y;
bounds.hi.updateMin(globalBounds.hi);
#if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING
if (bounds.lo.x>bounds.hi.x || bounds.lo.y>bounds.hi.y) {
DEBUG_CRASH(("Incorrect bounds calculation. Logic error, fix me. jba."));
Expand Down Expand Up @@ -3051,12 +3042,7 @@ void PathfindZoneManager::updateZonesForModify(PathfindCell **map, PathfindLayer
IRegion2D bounds = structureBounds;
bounds.hi.x++;
bounds.hi.y++;
if (bounds.hi.x > globalBounds.hi.x) {
bounds.hi.x = globalBounds.hi.x;
}
if (bounds.hi.y > globalBounds.hi.y) {
bounds.hi.y = globalBounds.hi.y;
}
bounds.hi.updateMin(globalBounds.hi);

Int xBlock, yBlock;
for (xBlock = 0; xBlock<m_zoneBlockExtent.x; xBlock++) {
Expand All @@ -3066,18 +3052,7 @@ void PathfindZoneManager::updateZonesForModify(PathfindCell **map, PathfindLayer
blockBounds.lo.y = globalBounds.lo.y + yBlock*ZONE_BLOCK_SIZE;
blockBounds.hi.x = blockBounds.lo.x + ZONE_BLOCK_SIZE - 1; // blockBounds are inclusive.
blockBounds.hi.y = blockBounds.lo.y + ZONE_BLOCK_SIZE - 1; // blockBounds are inclusive.
if (blockBounds.hi.x > bounds.hi.x) {
blockBounds.hi.x = bounds.hi.x;
}
if (blockBounds.hi.y > bounds.hi.y) {
blockBounds.hi.y = bounds.hi.y;
}
if (blockBounds.lo.x < bounds.lo.x) {
blockBounds.lo.x = bounds.lo.x;
}
if (blockBounds.lo.y < bounds.lo.y) {
blockBounds.lo.y = bounds.lo.y;
}
blockBounds.intersectWith(bounds);
if (blockBounds.lo.x>blockBounds.hi.x || blockBounds.lo.y>blockBounds.hi.y) {
continue;
}
Expand Down Expand Up @@ -3616,10 +3591,7 @@ void PathfindLayer::allocateCellsForWallLayer(const IRegion2D *extent, ObjectID
bridgeBounds = objBounds;
first = false;
} else {
if (bridgeBounds.lo.x>objBounds.lo.x) bridgeBounds.lo.x = objBounds.lo.x;
if (bridgeBounds.lo.y>objBounds.lo.y) bridgeBounds.lo.y = objBounds.lo.y;
if (bridgeBounds.hi.x<objBounds.hi.x) bridgeBounds.hi.x = objBounds.hi.x;
if (bridgeBounds.hi.y<objBounds.hi.y) bridgeBounds.hi.y = objBounds.hi.y;
bridgeBounds.uniteWith(objBounds);
}
}

Expand Down Expand Up @@ -3909,10 +3881,8 @@ void PathfindLayer::classifyLayerMapCell( Int i, Int j , PathfindCell *cell, Bri
// check against the end lines.

Region2D cellBounds;
cellBounds.lo.x = topLeftCorner.x;
cellBounds.lo.y = topLeftCorner.y;
cellBounds.hi.x = bottomRightCorner.x;
cellBounds.hi.y = bottomRightCorner.y;
cellBounds.lo = topLeftCorner.asCoord2D();
cellBounds.hi = bottomRightCorner.asCoord2D();

#if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING
if (m_bridge->isCellOnEnd(&cellBounds)) {
Expand Down Expand Up @@ -4607,21 +4577,7 @@ void Pathfinder::internal_classifyObjectFootprint( Object *obj, Bool insert )

Int i, j;

if (cellBounds.lo.x < m_extent.lo.x) {
cellBounds.lo.x = m_extent.lo.x;
}
if (cellBounds.lo.y < m_extent.lo.y) {
cellBounds.lo.y = m_extent.lo.y;
}
if (cellBounds.lo.y < m_extent.lo.y) {
cellBounds.lo.y = m_extent.lo.y;
}
if (cellBounds.hi.x > m_extent.hi.x) {
cellBounds.hi.x = m_extent.hi.x;
}
if (cellBounds.hi.y > m_extent.hi.y) {
Comment thread
xezon marked this conversation as resolved.
cellBounds.hi.y = m_extent.hi.y;
}
cellBounds.intersectWith(m_extent);

if (!insert) {
for( j=cellBounds.lo.y; j<=cellBounds.hi.y; j++ )
Expand Down Expand Up @@ -10484,10 +10440,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj,

for( node = pathToAvoid->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) {
Coord2D start, end;
start.x = node->getPosition()->x;
start.y = node->getPosition()->y;
end.x = node->getNextOptimized()->getPosition()->x;
end.y = node->getNextOptimized()->getPosition()->y;
start = node->getPosition()->asCoord2D();
end = node->getNextOptimized()->getPosition()->asCoord2D();
if (LineInRegion(&start, &end, &bounds)) {
overlap = true;
break;
Expand All @@ -10497,10 +10451,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj,
if (!overlap && pathToAvoid2) {
for( node = pathToAvoid2->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) {
Coord2D start, end;
start.x = node->getPosition()->x;
start.y = node->getPosition()->y;
end.x = node->getNextOptimized()->getPosition()->x;
end.y = node->getNextOptimized()->getPosition()->y;
start = node->getPosition()->asCoord2D();
end = node->getNextOptimized()->getPosition()->asCoord2D();
if (LineInRegion(&start, &end, &bounds)) {
overlap = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2625,8 +2625,7 @@ void W3DView::lookAt( const Coord3D *o )
}
}

Coord2D pos2D = { pos.x, pos.y };
setPosition2D(pos2D);
setPosition2D(pos.asCoord2D());

resetPivotToGround();

Expand Down
Loading
Loading