Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
PieceInterpolation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstddef>
5#include <cstdint>
6
7namespace monopoly::pieces
8{
10 {
11 float x{};
12 float y{};
13 float z{};
14
15 friend constexpr bool operator==(const InterpolationVec3&, const InterpolationVec3&) = default;
16 };
17
20 { return {a.x + b.x, a.y + b.y, a.z + b.z}; }
23 { return {a.x - b.x, a.y - b.y, a.z - b.z}; }
25 InterpolationVec3 a, float s) noexcept
26 { return {a.x * s, a.y * s, a.z * s}; }
28 float s, InterpolationVec3 a) noexcept
29 { return a * s; }
30
31 inline constexpr std::size_t BezierMaxSegments = 10;
32 inline constexpr float BezierTangentDelta = 0.0005F;
33
34 enum class InterpolationSpeed : std::uint8_t
35 {
36 Linear = 1,
39 };
40
42 {
43 std::array<std::array<InterpolationVec3, 4>, BezierMaxSegments> segments{};
44 std::array<float, BezierMaxSegments> lengths{};
45 std::array<float, BezierMaxSegments> tangentDeltas{};
46 std::size_t used{};
47 std::uint64_t startTick{};
48 std::uint64_t endTick{};
50 };
51
53 {
55 InterpolationVec3 forward{0.0F, 0.0F, 1.0F};
56 InterpolationVec3 up{0.0F, 1.0F, 0.0F};
57 float ratio{};
58 std::size_t segment{};
59 };
60
61 bool addBezierSegment(PieceInterpolationPath& path, std::size_t index,
62 InterpolationVec3 a, InterpolationVec3 b,
63 InterpolationVec3 c, InterpolationVec3 d,
64 float tangentDelta = BezierTangentDelta) noexcept;
65 bool addBezierSegmentSmooth(PieceInterpolationPath& path, std::size_t index,
66 InterpolationVec3 c, InterpolationVec3 d,
67 float tangentDelta = BezierTangentDelta) noexcept;
68 [[nodiscard]] PieceInterpolationSample samplePieceInterpolation(
69 const PieceInterpolationPath& path, std::uint64_t tick) noexcept;
70}
unsigned index
std::string path
PieceInterpolationSample samplePieceInterpolation(const PieceInterpolationPath &path, std::uint64_t tick) noexcept
constexpr std::size_t BezierMaxSegments
constexpr InterpolationVec3 operator+(InterpolationVec3 a, InterpolationVec3 b) noexcept
constexpr float BezierTangentDelta
constexpr InterpolationVec3 operator-(InterpolationVec3 a, InterpolationVec3 b) noexcept
bool addBezierSegmentSmooth(PieceInterpolationPath &path, std::size_t index, InterpolationVec3 c, InterpolationVec3 d, float tangentDelta) noexcept
bool addBezierSegment(PieceInterpolationPath &path, std::size_t index, InterpolationVec3 a, InterpolationVec3 b, InterpolationVec3 c, InterpolationVec3 d, float tangentDelta) noexcept
constexpr InterpolationVec3 operator*(InterpolationVec3 a, float s) noexcept
friend constexpr bool operator==(const InterpolationVec3 &, const InterpolationVec3 &)=default
std::array< std::array< InterpolationVec3, 4 >, BezierMaxSegments > segments
std::array< float, BezierMaxSegments > lengths
std::array< float, BezierMaxSegments > tangentDeltas