Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
SplineImpl.h
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
namespace
Movement
7
{
8
template
<
typename
length_type>
void
Spline<length_type>::evaluate_percent
(
float
t, Vector3& c)
const
9
{
10
index_type
Index;
11
float
u;
12
computeIndex
(t, Index, u);
13
evaluate_percent
(Index, u, c);
14
}
15
16
template
<
typename
length_type>
void
Spline<length_type>::evaluate_derivative
(
float
t, Vector3& hermite)
const
17
{
18
index_type
Index;
19
float
u;
20
computeIndex
(t, Index, u);
21
evaluate_derivative
(Index, u, hermite);
22
}
23
24
template
<
typename
length_type>
SplineBase::index_type
Spline<length_type>::computeIndexInBounds
(length_type length_)
const
25
{
26
// Temporary disabled: causes infinite loop with t = 1.f
27
/*
28
index_type hi = index_hi;
29
index_type lo = index_lo;
30
31
index_type i = lo + (float)(hi - lo) * t;
32
33
while ((lengths[i] > length) || (lengths[i + 1] <= length))
34
{
35
if (lengths[i] > length)
36
hi = i - 1; // too big
37
else if (lengths[i + 1] <= length)
38
lo = i + 1; // too small
39
40
i = (hi + lo) / 2;
41
}*/
42
43
index_type
i =
index_lo
;
44
index_type
N =
index_hi
;
45
while
(i + 1 < N &&
lengths
[i + 1] < length_)
46
++i;
47
48
return
i;
49
}
50
51
template
<
typename
length_type>
void
Spline<length_type>::computeIndex
(
float
t,
index_type
& index,
float
& u)
const
52
{
53
ASSERT
(t >= 0.f && t <= 1.f);
54
length_type length_ = t *
length
();
55
index =
computeIndexInBounds
(length_);
56
ASSERT
(index <
index_hi
);
57
u = (length_ -
length
(index)) / (
float
)
length
(index, index + 1);
58
}
59
60
template
<
typename
length_type>
SplineBase::index_type
Spline<length_type>::computeIndexInBounds
(
float
t)
const
61
{
62
ASSERT
(t >= 0.f && t <= 1.f);
63
return
computeIndexInBounds
(t *
length
());
64
}
65
66
template
<
typename
length_type>
void
Spline<length_type>::initLengths
()
67
{
68
index_type
i =
index_lo
;
69
length_type
length
= 0;
70
lengths
.resize(
index_hi
+ 1);
71
while
(i <
index_hi
)
72
{
73
length
+=
SegLength
(i);
74
lengths
[++i] =
length
;
75
}
76
}
77
78
template
<
typename
length_type>
void
Spline<length_type>::clear
()
79
{
80
SplineBase::clear
();
81
lengths
.clear();
82
}
83
84
}
ASSERT
#define ASSERT
Definition
Errors.h:29
Movement::SplineBase::clear
void clear()
Definition
Spline.cpp:271
Movement::SplineBase::index_type
int index_type
Definition
Spline.h:18
Movement::SplineBase::SegLength
float SegLength(index_type i) const
Definition
Spline.h:115
Movement::SplineBase::index_hi
index_type index_hi
Definition
Spline.h:34
Movement::SplineBase::index_lo
index_type index_lo
Definition
Spline.h:33
Movement::Spline::clear
void clear()
Definition
SplineImpl.h:78
Movement::Spline::lengths
LengthArray lengths
Definition
Spline.h:128
Movement::Spline::computeIndex
void computeIndex(float t, index_type &out_idx, float &out_u) const
Definition
SplineImpl.h:51
Movement::Spline::computeIndexInBounds
index_type computeIndexInBounds(length_type length) const
Definition
SplineImpl.h:24
Movement::Spline::length
length_type length() const
Definition
Spline.h:184
Movement::Spline::initLengths
void initLengths()
Definition
SplineImpl.h:66
Movement::Spline::evaluate_derivative
void evaluate_derivative(float t, Vector3 &hermite) const
Definition
SplineImpl.h:16
Movement::Spline::evaluate_percent
void evaluate_percent(float t, Vector3 &c) const
Definition
SplineImpl.h:8
Movement
Definition
Unit.h:365
src
server
game
Movement
Spline
SplineImpl.h
Generated on
for Project SkyFire Core by
1.17.0