mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-29 03:33:48 +00:00
Optimize Game::getWallNormal() a bit more
Don't need dist output param.
This commit is contained in:
parent
d7bf48fc30
commit
4cb2d7ced4
5 changed files with 6 additions and 13 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue