]> git.localhorst.tv Git - gworm.git/blobdiff - src/world/World.h
speed up rendering by caching world texture
[gworm.git] / src / world / World.h
index 8a00f60541302a489d8e34565c916eecea3f7b5d..9953e465901f3d2bca329fbdbb6d55a40f1395aa 100644 (file)
@@ -24,12 +24,19 @@ public:
 
        bool InBounds(Vector<int> pos) const
                { return pos.x > 0 && pos.y > 0 && pos.x < size.x && pos.y < size.y; }
-       int Index(Vector<int> pos) const { return pos.x * size.y + pos.y; }
+       int Index(Vector<int> pos) const { return pos.y * size.x + pos.x; }
 
        float MassAt(Vector<int> pos) const { return masses[Index(pos)]; }
        void SetMass(Vector<int> pos, float m) { masses[Index(pos)] = m; }
+
        Color ColorAt(Vector<int> pos) const { return colors[Index(pos)]; }
-       void SetColor(Vector<int> pos, Color c) { colors[Index(pos)] = c; }
+       const Color *GetColors() const { return colors.data(); }
+       void SetColor(Vector<int> pos, Color c) {
+               colors[Index(pos)] = c;
+               colorDirty = true;
+       }
+       bool ColorDirty() const { return colorDirty; }
+       void CleanColor() { colorDirty = false; }
 
        const std::list<Entity> &Entities() const { return entities; }
        Entity &AddEntity(const Entity &);
@@ -45,6 +52,7 @@ private:
 
        std::vector<float> masses;
        std::vector<Color> colors;
+       bool colorDirty;
 
        std::list<Entity> entities;