A bit of optimization to keep from generating the sorted sprite list over and over. Also tried to solve the problem of tombstone covering everything but no luck.
This commit is contained in:
parent
077f0e84ea
commit
9bf6926dc3
9 changed files with 36 additions and 32 deletions
|
@ -98,10 +98,13 @@ inline void update_sorted(SortedEntities& sprite_distance, PointEntityMap& table
|
|||
|
||||
for(const auto &rec : table) {
|
||||
Point sprite = rec.first;
|
||||
|
||||
int inside = (from.x - sprite.x) * (from.x - sprite.x) +
|
||||
(from.y - sprite.y) * (from.y - sprite.y);
|
||||
|
||||
if(sprite == seen && from != sprite) {
|
||||
if(from == sprite || rec.second.collision) {
|
||||
wiggle = 0.0f;
|
||||
} else if(sprite == seen) {
|
||||
wiggle += 0.02f;
|
||||
} else {
|
||||
wiggle = 0.0f;
|
||||
|
@ -114,14 +117,12 @@ inline void update_sorted(SortedEntities& sprite_distance, PointEntityMap& table
|
|||
}
|
||||
}
|
||||
|
||||
SortedEntities SpatialMap::distance_sorted(Point from, int max_dist) {
|
||||
SortedEntities sprite_distance;
|
||||
void SpatialMap::distance_sorted(SortedEntities& sprite_distance, Point from, int max_dist) {
|
||||
sprite_distance.clear();
|
||||
|
||||
update_sorted(sprite_distance, $collision, from, max_dist);
|
||||
|
||||
std::sort(sprite_distance.begin(), sprite_distance.end(), [](auto &a, auto &b) {
|
||||
return a.dist_square > b.dist_square;
|
||||
});
|
||||
|
||||
return sprite_distance;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue