diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 5132650..95ed063 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -700,11 +700,10 @@ void Game::dilateGrid(unsigned int radius, ObsType test, ObsType set, ObsType al } } -Vector Game::getWallNormal(Vector pos, int sampleArea, float *dist, int obs) +Vector Game::getWallNormal(Vector pos, int sampleArea, int obs) { const TileVector t(pos); // snap to grid Vector avg; - float mindist = HUGE_VALF; const float szf = (TILE_SIZE*(sampleArea-1)); int c = 0; for (int x = t.x-sampleArea; x <= t.x+sampleArea; x++) @@ -717,8 +716,6 @@ Vector Game::getWallNormal(Vector pos, int sampleArea, float *dist, int obs) { Vector v = pos - ct.worldVector(); const float d = v.getLength2D(); - if (d < mindist) - mindist = d; if (d < szf) { v.setLength2D(szf - d); @@ -729,8 +726,6 @@ Vector Game::getWallNormal(Vector pos, int sampleArea, float *dist, int obs) } } } - if(dist) - *dist = c ? mindist : -1.0f; avg.normalize2D(); return avg; } diff --git a/Aquaria/Game.h b/Aquaria/Game.h index 5d216e6..eee2a42 100644 --- a/Aquaria/Game.h +++ b/Aquaria/Game.h @@ -237,7 +237,7 @@ public: Vector positionToAvatar; - Vector getWallNormal(Vector pos, int sampleArea = 5, float *dist=0, int obs = -1); + Vector getWallNormal(Vector pos, int sampleArea = 5, int obs = -1); void updateMiniMapHintPosition(); EntitySaveData *getEntitySaveDataForEntity(Entity *e, Vector pos); diff --git a/Aquaria/PathFinding.cpp b/Aquaria/PathFinding.cpp index 5adc264..578935d 100644 --- a/Aquaria/PathFinding.cpp +++ b/Aquaria/PathFinding.cpp @@ -78,11 +78,10 @@ void PathFinding::molestPath(VectorPath &path) for (i = 0; i < sz; i++) { Vector node = path.getPathNode(i)->value; - float dist; const int sample = 20; { - Vector n = dsq->game->getWallNormal(node, sample, &dist); - if (dist != -1 && (n.x != 0 || n.y != 0)) + Vector n = dsq->game->getWallNormal(node, sample); + if (!n.isZero()) { n.setLength2D(200); TileVector test(node + n); diff --git a/Aquaria/SceneEditor.cpp b/Aquaria/SceneEditor.cpp index 0db3901..0cf4451 100644 --- a/Aquaria/SceneEditor.cpp +++ b/Aquaria/SceneEditor.cpp @@ -1539,8 +1539,7 @@ void SceneEditor::skinLevel(int minX, int minY, int maxX, int maxY) ) ) { - float dist=0; - wallNormal = dsq->game->getWallNormal(t.worldVector(), 5, &dist, OT_MASK_BLACK); + wallNormal = dsq->game->getWallNormal(t.worldVector(), 5, OT_MASK_BLACK); offset = wallNormal*(-TILE_SIZE*0.6f); MathFunctions::calculateAngleBetweenVectorsInDegrees(Vector(0,0,0), wallNormal, rot); rot = 180-(360-rot); diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 8591cb5..8a629ce 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -5195,7 +5195,7 @@ luaFunc(getWallNormal) if (!obs) obs = OT_BLOCKING; - Vector n = dsq->game->getWallNormal(Vector(x, y), range, NULL, obs); + Vector n = dsq->game->getWallNormal(Vector(x, y), range, obs); luaReturnVec2(n.x, n.y); }