CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
TransformPath.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 "PathVertex.hpp"
11#include "Utility.hpp"
12
14
16
18 template<typename Path> class TransformPath {
19 private:
20 using Impl = Path;
22
23 public:
24 class Vertices {
25 public:
27 auto vertex = vertices_.generate();
28 mPath->mutate_(vertex);
29 return vertex;
30 }
31
32 [[nodiscard]] bool done() const noexcept { return vertices_.done(); }
33
34 void next() { vertices_.next(); }
35
36 private:
37 Vertices(const TransformPath& path) : mPath{&path}, vertices_{path.mPath.vertices()} {}
38
40
42
43 friend class TransformPath;
44 };
45
48 TransformPath(Path path, Function<void(PathVertex&) const> mutate) : mPath{std::move(path)}, mutate_{mutate} {}
49
50 [[nodiscard]] Vertices vertices() const noexcept { return *this; }
51
52 using Edges = typename Impl::Edges;
53
54 [[nodiscard]] Edges edges() const noexcept { return mPath.edges(); }
55
56 private:
58 };
59
60 template<typename Path> TransformPath<Path> transformPath(Path path, Function<void(PathVertex&) const> mutate) {
61 return TransformPath<Path>{std::move(path), std::move(mutate)};
62 }
63
64} // namespace CeresEngine::MeshGenerator
Definition PathVertex.hpp:14
const TransformPath * mPath
Definition TransformPath.hpp:39
Vertices(const TransformPath &path)
Definition TransformPath.hpp:37
VertexGeneratorType< Path >::Type vertices_
Definition TransformPath.hpp:41
void next()
Definition TransformPath.hpp:34
PathVertex generate() const
Definition TransformPath.hpp:26
bool done() const noexcept
Definition TransformPath.hpp:32
Apply a mutator function to each vertex.
Definition TransformPath.hpp:18
Edges edges() const noexcept
Definition TransformPath.hpp:54
typename Impl::Edges Edges
Definition TransformPath.hpp:52
TransformPath(Path path, Function< void(PathVertex &) const > mutate)
Definition TransformPath.hpp:48
Path Impl
Definition TransformPath.hpp:20
Function< void(PathVertex &) const > mutate_
Definition TransformPath.hpp:57
Impl mPath
Definition TransformPath.hpp:21
Vertices vertices() const noexcept
Definition TransformPath.hpp:50
decltype(std::declval< const Primitive * >() ->vertices()) Type
Definition Utility.hpp:39
Definition AnyGenerator.hpp:12
TransformPath< Path > transformPath(Path path, Function< void(PathVertex &) const > mutate)
Definition TransformPath.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