11 {
return std::sqrt(v.x * v.x + v.y * v.y + v.z * v.z); }
16 if (
length <= 0.00001F)
return {};
17 return v * (1.0F /
length);
21 const std::array<InterpolationVec3, 4>&
p)
noexcept
23 const float u = 1.0F - ratio;
24 const float b0 = u * u * u;
25 const float b1 = 3.0F * ratio * u * u;
26 const float b2 = 3.0F * ratio * ratio * u;
27 const float b3 = ratio * ratio * ratio;
33 ratio = std::clamp(ratio, 0.0F, 1.0F);
37 constexpr float Pi = 3.14159265358979323846F;
39 return 0.5F - 0.5F * std::cos(ratio *
Pi);
40 return 0.5F + 0.5F * std::sin((ratio - 0.5F) *
Pi);
66 if (
index < 1)
return false;
76 std::size_t used =
path.used;
78 if (used == 0)
return result;
83 const auto current = tick <
path.startTick ?
path.startTick : tick;
84 ratio =
static_cast<float>(current -
path.startTick) /
85 static_cast<float>(
path.endTick -
path.startTick);
91 for (std::size_t
i = 0;
i < used; ++
i)
total +=
path.lengths[
i];
92 if (
total == 0.0F)
total =
static_cast<float>(used);
94 std::size_t segment{};
97 for (; segment < used; ++segment)
99 end +=
path.lengths[segment] == 0.0F ? 1.0F :
path.lengths[segment];
100 if ((end /
total + 0.000001F) >= ratio)
break;
103 if (segment >= used) segment = used - 1;
113 result.segment = segment;
117 const auto tangent =
nearby - result.location;
120 result.up = {0.0F, 1.0F, 0.0F};
PieceInterpolationSample samplePieceInterpolation(const PieceInterpolationPath &path, std::uint64_t tick) noexcept
constexpr std::size_t BezierMaxSegments
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