CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
FlipShape.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Edge.hpp"
11#include "TransformShape.hpp"
12
14
16 template<typename Shape> class FlipShape {
17 private:
20
21 public:
22 class Edges {
23 public:
24 [[nodiscard]] Edge generate() const {
25 Edge edge = mEdges.generate();
26 std::swap(edge.vertices[0], edge.vertices[1]);
27 return edge;
28 }
29
30 [[nodiscard]] bool done() const noexcept { return mEdges.done(); }
31
32 void next() { mEdges.next(); }
33
34 private:
36
37 Edges(const TransformShape<Shape>& shape) : mEdges{shape.edges()} {}
38
39 friend class FlipShape;
40 };
41
44 : mTransformShape{std::move(shape), [](ShapeVertex& vertex) {
45 vertex.tangent *= -1.0;
46 }} {}
47
48 [[nodiscard]] Edges edges() const noexcept { return {*this}; }
49
50 using Vertices = typename Impl::Vertices;
51 [[nodiscard]] Vertices vertices() const noexcept { return mTransformShape.vertices(); }
52 };
53
54 template<typename Shape> FlipShape<Shape> flipShape(Shape shape) { return FlipShape<Shape>{std::move(shape)}; }
55
56} // namespace CeresEngine::MeshGenerator
Will have a type named "Type" that has same type as value returned by method edges() for type Primiti...
Definition Utility.hpp:23
Definition Edge.hpp:14
Edge generate() const
Definition FlipShape.hpp:24
void next()
Definition FlipShape.hpp:32
EdgeGeneratorType< TransformShape< Shape > >::Type mEdges
Definition FlipShape.hpp:35
Edges(const TransformShape< Shape > &shape)
Definition FlipShape.hpp:37
bool done() const noexcept
Definition FlipShape.hpp:30
Flips shape direction. Reverses edges and tangents.
Definition FlipShape.hpp:16
typename Impl::Vertices Vertices
Definition FlipShape.hpp:50
Impl mTransformShape
Definition FlipShape.hpp:19
Vertices vertices() const noexcept
Definition FlipShape.hpp:51
FlipShape(Shape shape)
Definition FlipShape.hpp:43
Edges edges() const noexcept
Definition FlipShape.hpp:48
A point on a path.
Definition ShapeVertex.hpp:16
Apply a mutator function to each vertex.
Definition TransformShape.hpp:18
A type that describes a conjunction of shapes that can be filled and stroked.
Definition Shape.hpp:198
Definition AnyGenerator.hpp:12
FlipShape< Shape > flipShape(Shape shape)
Definition FlipShape.hpp:54
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668