Move two members of Vector to be inline.
Performance change: moved since they show up disproportionately in profiling.pull/410/head
parent
201e15e68a
commit
62aba398f7
19
src/dsc.h
19
src/dsc.h
|
@ -108,6 +108,25 @@ public:
|
|||
Vector4 Project4d() const;
|
||||
};
|
||||
|
||||
inline double Vector::Element(int i) const {
|
||||
switch (i) {
|
||||
case 0: return x;
|
||||
case 1: return y;
|
||||
case 2: return z;
|
||||
default: ssassert(false, "Unexpected vector element index");
|
||||
}
|
||||
}
|
||||
|
||||
inline bool Vector::Equals(Vector v, double tol) const {
|
||||
// Quick axis-aligned tests before going further
|
||||
const Vector dv = this->Minus(v);
|
||||
if (fabs(dv.x) > tol) return false;
|
||||
if (fabs(dv.y) > tol) return false;
|
||||
if (fabs(dv.z) > tol) return false;
|
||||
|
||||
return dv.MagSquared() < tol*tol;
|
||||
}
|
||||
|
||||
struct VectorHash {
|
||||
size_t operator()(const Vector &v) const;
|
||||
};
|
||||
|
|
19
src/util.cpp
19
src/util.cpp
|
@ -430,25 +430,6 @@ Vector Vector::From(hParam x, hParam y, hParam z) {
|
|||
return v;
|
||||
}
|
||||
|
||||
double Vector::Element(int i) const {
|
||||
switch(i) {
|
||||
case 0: return x;
|
||||
case 1: return y;
|
||||
case 2: return z;
|
||||
default: ssassert(false, "Unexpected vector element index");
|
||||
}
|
||||
}
|
||||
|
||||
bool Vector::Equals(Vector v, double tol) const {
|
||||
// Quick axis-aligned tests before going further
|
||||
const Vector dv = this->Minus(v);
|
||||
if (fabs(dv.x) > tol) return false;
|
||||
if (fabs(dv.y) > tol) return false;
|
||||
if (fabs(dv.z) > tol) return false;
|
||||
|
||||
return dv.MagSquared() < tol*tol;
|
||||
}
|
||||
|
||||
bool Vector::EqualsExactly(Vector v) const {
|
||||
return EXACT(x == v.x &&
|
||||
y == v.y &&
|
||||
|
|
Loading…
Reference in New Issue