TrinityCore
Loading...
Searching...
No Matches
SplineImpl.h
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
namespace
Movement
19
{
20
template
<
typename
length_type>
void
Spline<length_type>::evaluate_percent
(
float
t, Vector3 & c )
const
21
{
22
index_type
Index;
23
float
u;
24
computeIndex(t, Index, u);
25
evaluate_percent(Index, u, c);
26
}
27
28
template
<
typename
length_type>
void
Spline<length_type>::evaluate_derivative
(
float
t, Vector3& hermite)
const
29
{
30
index_type
Index;
31
float
u;
32
computeIndex(t, Index, u);
33
evaluate_derivative(Index, u, hermite);
34
}
35
36
template
<
typename
length_type>
SplineBase::index_type
Spline<length_type>::computeIndexInBoundsAtLength
(length_type length_)
const
37
{
38
// Temporary disabled: causes infinite loop with t = 1.f
39
/*
40
index_type hi = index_hi;
41
index_type lo = index_lo;
42
43
index_type i = lo + (float)(hi - lo) * t;
44
45
while ((lengths[i] > length) || (lengths[i + 1] <= length))
46
{
47
if (lengths[i] > length)
48
hi = i - 1; // too big
49
else if (lengths[i + 1] <= length)
50
lo = i + 1; // too small
51
52
i = (hi + lo) / 2;
53
}*/
54
55
index_type
i = index_lo;
56
index_type
N = index_hi;
57
while
(i+1 < N && lengths[i+1] < length_)
58
++i;
59
60
return
i;
61
}
62
63
template
<
typename
length_type>
void
Spline<length_type>::computeIndex
(
float
t,
index_type
& out_idx,
float
& out_u)
const
64
{
65
ASSERT
(t >= 0.f && t <= 1.f);
66
length_type length_ = t * length();
67
out_idx = computeIndexInBoundsAtLength(length_);
68
ASSERT
(out_idx < index_hi);
69
out_u = (length_ - length(out_idx)) / (
float
)length(out_idx, out_idx+1);
70
}
71
72
template
<
typename
length_type>
SplineBase::index_type
Spline<length_type>::computeIndexInBounds
(
float
t )
const
73
{
74
ASSERT
(t >= 0.f && t <= 1.f);
75
return
computeIndexInBoundsAtLength(t * length());
76
}
77
78
template
<
typename
length_type>
void
Spline<length_type>::initLengths
()
79
{
80
index_type
i = index_lo;
81
length_type length = 0;
82
lengths.resize(index_hi+1);
83
while
(i < index_hi)
84
{
85
length += SegLength(i);
86
lengths[++i] = length;
87
}
88
}
89
90
template
<
typename
length_type>
void
Spline<length_type>::clear
()
91
{
92
SplineBase::clear
();
93
lengths.clear();
94
}
95
96
}
ASSERT
#define ASSERT
Definition
Errors.h:80
Movement::SplineBase::clear
virtual void clear()
Definition
Spline.cpp:291
Movement::SplineBase::index_type
int index_type
Definition
Spline.h:32
Movement::Spline::computeIndex
void computeIndex(float t, index_type &out_idx, float &out_u) const
Definition
SplineImpl.h:63
Movement::Spline::clear
void clear() override
Definition
SplineImpl.h:90
Movement::Spline::computeIndexInBounds
index_type computeIndexInBounds(float t) const
Definition
SplineImpl.h:72
Movement::Spline::initLengths
void initLengths()
Definition
SplineImpl.h:78
Movement::Spline::evaluate_derivative
void evaluate_derivative(float t, Vector3 &hermite) const
Definition
SplineImpl.h:28
Movement::Spline::evaluate_percent
void evaluate_percent(float t, Vector3 &c) const
Definition
SplineImpl.h:20
Movement::Spline::computeIndexInBoundsAtLength
index_type computeIndexInBoundsAtLength(length_type length) const
Definition
SplineImpl.h:36
Movement
Definition
AreaTrigger.h:37
server
game
Movement
Spline
SplineImpl.h
Generated on Sun May 10 2026 02:09:01 for TrinityCore by
1.9.8