Add some static casts

This commit is contained in:
Pavel Krajcevski 2014-03-12 02:41:23 -04:00
parent ebfd8f8f81
commit ce99d79bab
2 changed files with 4 additions and 4 deletions

View File

@ -94,7 +94,7 @@ namespace FasTC {
} }
T LengthSq() const { return this->Dot(*this); } T LengthSq() const { return this->Dot(*this); }
T Length() const { return sqrt(LengthSq()); } T Length() const { return static_cast<T>(sqrt(LengthSq())); }
void Normalize() { void Normalize() {
T len = Length(); T len = Length();
@ -110,7 +110,7 @@ namespace FasTC {
const VectorTypeTwo &v2) { const VectorTypeTwo &v2) {
VectorTypeOne a(v1); VectorTypeOne a(v1);
for(int i = 0; i < VectorTypeOne::Size; i++) { for(int i = 0; i < VectorTypeOne::Size; i++) {
a(i) += v2[i]; a(i) += static_cast<VectorTypeOne::ScalarType>(v2[i]);
} }
return a; return a;
} }
@ -132,7 +132,7 @@ namespace FasTC {
const VectorTypeTwo &v2) { const VectorTypeTwo &v2) {
VectorTypeOne a(v1); VectorTypeOne a(v1);
for(int i = 0; i < VectorTypeOne::Size; i++) { for(int i = 0; i < VectorTypeOne::Size; i++) {
a(i) -= v2[i]; a(i) -= static_cast<VectorTypeOne::ScalarType>(v2[i]);
} }
return a; return a;
} }

View File

@ -225,7 +225,7 @@ TEST(VectorBase, Addition) {
EXPECT_NEAR(af[1], 5.2f, kEpsilon); EXPECT_NEAR(af[1], 5.2f, kEpsilon);
au = v2u - v2f; au = v2u - v2f;
EXPECT_EQ(au[0], 3); EXPECT_EQ(au[0], 4);
EXPECT_EQ(au[1], -1); EXPECT_EQ(au[1], -1);
af = v2f - v2u; af = v2f - v2u;