Skip to content

Commit

Permalink
Minor fixes before switching to raylib
Browse files Browse the repository at this point in the history
  • Loading branch information
tristankpka committed Jul 29, 2024
1 parent 78acb2e commit c5d313d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions include/NodeSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class NodeSystem : public System {

private:
QueryFunction m_query;
std::unordered_set<Entity::Id> m_rootNodes;
std::unordered_map<Entity::Id, sf::Transform> m_nodeTransforms;
std::unordered_map<Entity::Id, Entity::Id> m_parentMap;
std::unordered_map<Entity::Id, std::vector<Entity::Id>> m_childNodes;

void onEventEntityChildAdded(Entity::Id parentId, Entity::Id childId) const;
};
Expand Down
2 changes: 1 addition & 1 deletion include/RenderingSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "components/Node.h" // for Node
#include "components/Shape.h" // for Shape
class World;
namespace sf { class Drawable; }
namespace sf { class Shape; }
namespace sf { class RenderWindow; }
namespace sf { class Transform; }

Expand Down
3 changes: 2 additions & 1 deletion include/components/Shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
#ifndef DRAWABLE_H
#define DRAWABLE_H

#include <memory>
#include <SFML/Graphics/Shape.hpp>

struct Shape {
std::unique_ptr<sf::Shape> shape;
std::unique_ptr<sf::Shape> shape{};
};

#endif //DRAWABLE_H
3 changes: 1 addition & 2 deletions src/RenderingSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <memory> // for unique_ptr
#include "ComponentManager.h" // for ComponentManager::getCompo...
#include "World.h" // for World
#include "World.h" // for World::getComponentQuery

RenderingSystem::RenderingSystem(World& world, sf::RenderWindow& window)
: m_query(world.getComponentQuery<Node, Shape>()), m_window(window) {}
Expand All @@ -23,7 +22,7 @@ void RenderingSystem::update() {
}

void RenderingSystem::doDraw(const Entity::Id id, const sf::Transform& parentTransform) {
m_query([this, parentTransform](Entity::Id, const Node& node, const Shape& renderable) {
m_query([this, parentTransform](Entity::Id, Node& node, Shape& renderable) {
m_window.draw(*renderable.shape, node.transform * parentTransform);
for (const auto child: node.children) {
doDraw(child, node.transform * parentTransform);
Expand Down

0 comments on commit c5d313d

Please sign in to comment.