Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions include/weird-engine/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ namespace WeirdEngine

void get2DShapesData(WeirdRenderer::Dot2D*& data, uint32_t& size);

Scene(const Scene&) = default; // Deleted copy constructor
Scene(const Scene&) = default; // Deleted copy constructor
Scene& operator=(const Scene&) = default; // Deleted copy assignment operator
Scene(Scene&&) = default; // Defaulted move constructor
Scene& operator=(Scene&&) = default; // Defaulted move assignment operator
Scene(Scene&&) = default; // Defaulted move constructor
Scene& operator=(Scene&&) = default; // Defaulted move assignment operator

WeirdRenderer::Camera& getCamera();
std::vector<WeirdRenderer::Light>& getLigths();
Expand Down Expand Up @@ -64,8 +64,7 @@ namespace WeirdEngine

std::vector<std::shared_ptr<IMathExpression>> m_sdfs;

Entity addShape(int shapeId, float* variables);
Entity addScreenSpaceShape(int shapeId, float* variables);
Entity addShape(ShapeId shapeId, float* variables, CombinationType combination = CombinationType::Addition, bool hasCollision = true, int group = 0);

void lookAt(Entity entity);

Expand Down
22 changes: 21 additions & 1 deletion include/weird-engine/ecs/Components/CustomShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,27 @@

namespace WeirdEngine
{
using ShapeId = std::uint16_t;

enum class CombinationType : uint16_t
{
Addition,
Subtraction,
Intersection,
SmoothAddition
};

struct CustomShape : public Component
{
public:

uint16_t m_distanceFieldId;
CombinationType m_combination;
float m_parameters[8];
bool m_isDirty;
bool m_screenSpace;
bool m_hasCollision;
uint16_t m_groupId;

CustomShape() : m_distanceFieldId(0), m_isDirty(true), m_screenSpace(false)
{
Expand All @@ -22,5 +35,12 @@ namespace WeirdEngine
std::copy(params, params + 8, m_parameters);
}

static constexpr ShapeId CIRCLE = 2;
static constexpr ShapeId BOX = 3;
static constexpr ShapeId SINE = 0;
static constexpr ShapeId STAR = 1;

static constexpr uint16_t GLOBAL_GROUP = std::numeric_limits<uint16_t>::max();

};
}
}
2 changes: 1 addition & 1 deletion include/weird-engine/ecs/Systems/SDFRenderSystem2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace WeirdEngine
return closestIndex;
}

bool shaderNeedsUpdate() const
bool& shaderNeedsUpdate()
{
return m_customShapesNeedUpdate;
}
Expand Down
4 changes: 3 additions & 1 deletion include/weird-physics/Simulation2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ namespace WeirdEngine
{
Entity owner;
uint16_t distanceFieldId;
CombinationType combinationId;
uint16_t groupId;
float parameters[11];

DistanceFieldObject2D(Entity owner, uint16_t id, float* params) : distanceFieldId(id), owner(owner)
DistanceFieldObject2D(Entity owner, uint16_t id, CombinationType combinationId, uint16_t groupId, float* params) : distanceFieldId(id), combinationId(combinationId), groupId(groupId), owner(owner)
{
std::copy(params, params + 8, parameters); // Copy params into parameters
}
Expand Down
Loading