Skip to content

Commit 60eaa1c

Browse files
committed
Align Y position better, as positive y is down
1 parent 95ef947 commit 60eaa1c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Source/System/PathFinder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ int PathFinder::CalculatePath(Vector start, Vector end, std::list<Vector>& pathR
154154
g_SceneMan.ForceBounds(end);
155155

156156
// Convert from absolute scene pixel coordinates to path node indices.
157-
int startNodeX = std::floor(start.m_X / static_cast<float>(m_NodeDimension));
158-
int startNodeY = std::floor(start.m_Y / static_cast<float>(m_NodeDimension));
159-
int endNodeX = std::floor(end.m_X / static_cast<float>(m_NodeDimension));
160-
int endNodeY = std::floor(end.m_Y / static_cast<float>(m_NodeDimension));
157+
int startNodeX = std::floor( start.m_X / static_cast<float>(m_NodeDimension));
158+
int startNodeY = std::max(0.0F, std::floor((start.m_Y / static_cast<float>(m_NodeDimension) - 0.5f)));
159+
int endNodeX = std::floor( end.m_X / static_cast<float>(m_NodeDimension));
160+
int endNodeY = std::max(0.0F, std::floor((end.m_Y / static_cast<float>(m_NodeDimension) - 0.5f)));
161161

162162
// Clear out the results if it happens to contain anything
163163
pathResult.clear();

0 commit comments

Comments
 (0)