mirror of
https://github.com/g-truc/glm.git
synced 2024-11-16 06:44:35 +00:00
Fixed intermittent segfault in test-gtx_fast_trigonometry.cpp
The fastAbs() function was accessing its argument as if it were a vec4 but it was being called with a float. Also, it relied onundefined behavior. I replaced it with glm::abs().
This commit is contained in:
parent
ac21d7bdad
commit
8e742a4d07
@ -233,21 +233,10 @@ namespace taylorCos
|
|||||||
- Powed6 * static_cast<T>(0.00138888888888888888888888888889);
|
- Powed6 * static_cast<T>(0.00138888888888888888888888888889);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <glm::precision P, template <typename, glm::precision> class vecType>
|
|
||||||
GLM_FUNC_QUALIFIER vecType<float, P> fastAbs(vecType<float, P> x)
|
|
||||||
{
|
|
||||||
int* Pointer = reinterpret_cast<int*>(&x[0]);
|
|
||||||
*(((int *) &Pointer[0]) + 1) &= 0x7fffffff;
|
|
||||||
*(((int *) &Pointer[1]) + 1) &= 0x7fffffff;
|
|
||||||
*(((int *) &Pointer[2]) + 1) &= 0x7fffffff;
|
|
||||||
*(((int *) &Pointer[3]) + 1) &= 0x7fffffff;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
|
template <typename T, glm::precision P, template <typename, glm::precision> class vecType>
|
||||||
GLM_FUNC_QUALIFIER vecType<T, P> fastCosNew(vecType<T, P> const & x)
|
GLM_FUNC_QUALIFIER vecType<T, P> fastCosNew(vecType<T, P> const & x)
|
||||||
{
|
{
|
||||||
vecType<T, P> const Angle0_PI(fastAbs(fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
|
vecType<T, P> const Angle0_PI(glm::abs(fmod(x + glm::pi<T>(), glm::two_pi<T>()) - glm::pi<T>()));
|
||||||
return taylorSeriesNewCos6(x);
|
return taylorSeriesNewCos6(x);
|
||||||
/*
|
/*
|
||||||
vecType<bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType<T, P>(glm::half_pi<T>())));
|
vecType<bool, P> const FirstQuarterPi(lessThanEqual(Angle0_PI, vecType<T, P>(glm::half_pi<T>())));
|
||||||
|
Loading…
Reference in New Issue
Block a user