CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
TransformShape.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 "ShapeVertex.hpp"
11#include "Utility.hpp"
12
14
16
18 template<typename Shape> class TransformShape {
19 private:
20 using Impl = Shape;
22
23 public:
24 class Vertices {
25 public:
27 auto temp = vertices_.generate();
29 return temp;
30 }
31
32 [[nodiscard]] bool done() const noexcept { return vertices_.done(); }
33
34 void next() { vertices_.next(); }
35
36 private:
38
40
41 Vertices(const TransformShape& shape) : mShape{&shape}, vertices_{shape.mShape.vertices()} {}
42
43 friend class TransformShape;
44 };
45
48 TransformShape(Shape shape, Function<void(ShapeVertex&) const> mutate) : mShape{std::move(shape)}, mutate_{mutate} {}
49
50 using Edges = typename Impl::Edges;
51
52 [[nodiscard]] Edges edges() const noexcept { return mShape.edges(); }
53
54 [[nodiscard]] Vertices vertices() const noexcept { return *this; }
55
56 private:
58 };
59
60 template<typename Shape> TransformShape<Shape> transformShape(Shape shape, Function<void(ShapeVertex&) const> mutate) {
61 return TransformShape<Shape>{std::move(shape), std::move(mutate)};
62 }
63
64} // namespace CeresEngine::MeshGenerator
A point on a path.
Definition ShapeVertex.hpp:16
void next()
Definition TransformShape.hpp:34
Vertices(const TransformShape &shape)
Definition TransformShape.hpp:41
ShapeVertex generate() const
Definition TransformShape.hpp:26
bool done() const noexcept
Definition TransformShape.hpp:32
VertexGeneratorType< Shape >::Type vertices_
Definition TransformShape.hpp:39
const TransformShape * mShape
Definition TransformShape.hpp:37
Apply a mutator function to each vertex.
Definition TransformShape.hpp:18
Edges edges() const noexcept
Definition TransformShape.hpp:52
typename Impl::Edges Edges
Definition TransformShape.hpp:50
Impl mShape
Definition TransformShape.hpp:21
TransformShape(Shape shape, Function< void(ShapeVertex &) const > mutate)
Definition TransformShape.hpp:48
Vertices vertices() const noexcept
Definition TransformShape.hpp:54
Function< void(ShapeVertex &) const > mutate_
Definition TransformShape.hpp:57
decltype(std::declval< const Primitive * >() ->vertices()) Type
Definition Utility.hpp:39
A type that describes a conjunction of shapes that can be filled and stroked.
Definition Shape.hpp:198
Definition AnyGenerator.hpp:12
TransformShape< Shape > transformShape(Shape shape, Function< void(ShapeVertex &) const > mutate)
Definition TransformShape.hpp:60
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
FunctionBase< true, true, fu2::capacity_default, true, false, Signatures... > Function
An owning copyable function wrapper for arbitrary callable types.
Definition Function.hpp:54
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668