CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
AnyShape.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 "AnyGenerator.hpp"
11#include "Edge.hpp"
12#include "ShapeVertex.hpp"
13
15
17
19 class AnyShape {
20 public:
21 template<typename Shape> AnyShape(Shape shape) : mBase{new Derived<Shape>{std::move(shape)}} {}
22
24
25 AnyShape(AnyShape&&) = default;
26
28
30
32
34
35 private:
37 public:
38 virtual ~Base();
39 virtual UPtr<Base> clone() const = 0;
40 virtual AnyGenerator<Edge> edges() const = 0;
42 };
43
44 template<typename Shape> class Derived : public Base {
45 public:
46 Derived(Shape shape) : mShape(std::move(shape)) {}
47
48 virtual UPtr<Base> clone() const override { return UPtr<Base>{new Derived{mShape}}; }
49
50 virtual AnyGenerator<Edge> edges() const override { return mShape.edges(); }
51
52 virtual AnyGenerator<ShapeVertex> vertices() const override { return mShape.vertices(); }
53
55 };
56
58 };
59
60} // namespace CeresEngine::MeshGenerator
A type erasing container that can store any generator that generates type T.
Definition AnyGenerator.hpp:16
virtual AnyGenerator< Edge > edges() const =0
virtual AnyGenerator< ShapeVertex > vertices() const =0
virtual UPtr< Base > clone() const =0
virtual UPtr< Base > clone() const override
Definition AnyShape.hpp:48
virtual AnyGenerator< ShapeVertex > vertices() const override
Definition AnyShape.hpp:52
virtual AnyGenerator< Edge > edges() const override
Definition AnyShape.hpp:50
Derived(Shape shape)
Definition AnyShape.hpp:46
Shape mShape
Definition AnyShape.hpp:54
A type erasing container that can store any shape.
Definition AnyShape.hpp:19
AnyGenerator< Edge > edges() const noexcept
AnyShape & operator=(const AnyShape &that)
AnyShape(Shape shape)
Definition AnyShape.hpp:21
UPtr< Base > mBase
Definition AnyShape.hpp:57
AnyShape & operator=(AnyShape &&)=default
A point on a path.
Definition ShapeVertex.hpp:16
A type that describes a conjunction of shapes that can be filled and stroked.
Definition Shape.hpp:198
Definition AnyGenerator.hpp:12
std::unique_ptr< T, Deleter > UPtr
UPtr is a smart pointer that owns and manages another object through a pointer and disposes of that o...
Definition SmartPtr.hpp:28
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