mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 22:27:13 +02:00
CubicHermiteSplineWithArcLength optimization
This commit is contained in:
parent
a959d69554
commit
708309fa63
1 changed files with 5 additions and 3 deletions
|
@ -60,7 +60,7 @@ protected:
|
|||
|
||||
class CubicHermiteSplineFunctorWithArcLength : public CubicHermiteSplineFunctor {
|
||||
public:
|
||||
enum Constants { NUM_SUBDIVISIONS = 30 };
|
||||
enum Constants { NUM_SUBDIVISIONS = 15 };
|
||||
|
||||
CubicHermiteSplineFunctorWithArcLength() : CubicHermiteSplineFunctor() {
|
||||
memset(_values, 0, sizeof(float) * (NUM_SUBDIVISIONS + 1));
|
||||
|
@ -71,11 +71,13 @@ public:
|
|||
float alpha = 0.0f;
|
||||
float accum = 0.0f;
|
||||
_values[0] = 0.0f;
|
||||
glm::vec3 prevValue = this->operator()(alpha);
|
||||
for (int i = 1; i < NUM_SUBDIVISIONS + 1; i++) {
|
||||
accum += glm::distance(this->operator()(alpha),
|
||||
this->operator()(alpha + DELTA));
|
||||
glm::vec3 nextValue = this->operator()(alpha + DELTA);
|
||||
accum += glm::distance(prevValue, nextValue);
|
||||
alpha += DELTA;
|
||||
_values[i] = accum;
|
||||
prevValue = nextValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue