moved a bunch around

This commit is contained in:
Yggdrasil75
2025-11-17 14:44:24 -05:00
parent a7183256cc
commit e7bf6adfa6
5 changed files with 400 additions and 510 deletions

View File

@@ -73,7 +73,9 @@ public:
void clear() {
Positions.clear();
Positions.rehash(0);
ƨnoiƚiƨoꟼ.clear();
ƨnoiƚiƨoꟼ.rehash(0);
next_id = 0;
}
@@ -165,6 +167,7 @@ public:
void clear() {
grid.clear();
grid.rehash(0);
}
};
@@ -767,6 +770,9 @@ public:
Sizes.clear();
spatialGrid.clear();
neighborMap.clear();
Colors.rehash(0);
Sizes.rehash(0);
neighborMap.rehash(0);
}
// neighbor map

34
util/grid/sprite2.hpp Normal file
View File

@@ -0,0 +1,34 @@
#ifndef SPRITE2_HPP
#define SPRITE2_HPP
#include "grid2.hpp"
#include "../output/frame.hpp"
class SpriteMap2 : public Grid2 {
private:
// id, sprite
//std::unordered_map<size_t, std::shared_ptr<Grid2>> Sprites;
std::unordered_map<size_t, frame> spritesComped;
std::unordered_map<size_t, int> Layers;
std::unordered_map<size_t, float> Orientations;
public:
using Grid2::Grid2;
size_t addSprite(const Vec2& pos, frame sprite, int layer = 0, float orientation = 0.0f) {
size_t id = addObject(pos, Vec4(0,0,0,0));
spritesComped[id] = sprite;
Layers[id] = layer;
Orientations[id] = orientation;
}
frame getSprite(size_t id) {
return spritesComped.at(id);
}
};
#endif