more mad attempts to squeeze better performance

This commit is contained in:
Mark Vejvoda
2013-06-11 06:44:26 +00:00
parent 267dc7534f
commit 668b34db8e
8 changed files with 148 additions and 76 deletions

View File

@@ -213,16 +213,19 @@ public:
return x < v.x || (x == v.x && y < v.y);
}
inline float length() const{
inline float length(bool requireAccuracy=true) const {
#ifdef USE_STREFLOP
return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y)));
if(requireAccuracy == true) {
return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y)));
}
return static_cast<float>(std::sqrt(static_cast<float>(x*x + y*y)));
#else
return static_cast<float>(sqrt(static_cast<float>(x*x + y*y)));
#endif
}
inline void normalize(){
T m= length();
inline void normalize(bool requireAccuracy=true){
T m= length(requireAccuracy);
x/= m;
y/= m;
}
@@ -444,16 +447,19 @@ public:
return Vec3<T>(v-*this).length();
}
inline float length() const{
inline float length(bool requireAccuracy=true) const {
#ifdef USE_STREFLOP
return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y + z*z)));
if(requireAccuracy == true) {
return static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x*x + y*y + z*z)));
}
return static_cast<float>(std::sqrt(x*x + y*y + z*z));
#else
return static_cast<float>(sqrt(x*x + y*y + z*z));
#endif
}
inline void normalize(){
T m= length();
inline void normalize(bool requireAccuracy=true){
T m= length(requireAccuracy);
x/= m;
y/= m;
z/= m;

View File

@@ -244,12 +244,13 @@ void ParticleRendererGl::renderModel(GameParticleSystem *ps, ModelRenderer *mr){
Vec3f flatDirection= Vec3f(direction.x, 0.f, direction.z);
Vec3f rotVector= Vec3f(0.f, 1.f, 0.f).cross(flatDirection);
#ifdef USE_STREFLOP
float angleV= radToDeg(streflop::atan2(static_cast<streflop::Simple>(flatDirection.length()), static_cast<streflop::Simple>(direction.y))) - 90.f;
#else
float angleV= radToDeg(atan2(flatDirection.length(), direction.y)) - 90.f;
#endif
//#ifdef USE_STREFLOP
// float angleV= radToDeg(streflop::atan2(static_cast<streflop::Simple>(flatDirection.length()), static_cast<streflop::Simple>(direction.y))) - 90.f;
//#else
// float angleV= radToDeg(atan2(flatDirection.length(), direction.y)) - 90.f;
//#endif
float angleV= radToDeg(std::atan2(flatDirection.length(false), direction.y)) - 90.f;
glRotatef(angleV, rotVector.x, rotVector.y, rotVector.z);
#ifdef USE_STREFLOP