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;