mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
parent
e299bf9b62
commit
0d48cfe8c0
@ -129,11 +129,13 @@ NiPoint3 NiPoint3::operator+(const NiPoint3& point) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! Operator for addition of vectors
|
//! Operator for addition of vectors
|
||||||
NiPoint3 NiPoint3::operator+=(const NiPoint3& point) const {
|
NiPoint3& NiPoint3::operator+=(const NiPoint3& point) {
|
||||||
return NiPoint3(this->x + point.x, this->y + point.y, this->z + point.z);
|
this->x += point.x;
|
||||||
|
this->y += point.y;
|
||||||
|
this->z += point.z;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Operator for subtraction of vectors
|
//! Operator for subtraction of vectors
|
||||||
NiPoint3 NiPoint3::operator-(const NiPoint3& point) const {
|
NiPoint3 NiPoint3::operator-(const NiPoint3& point) const {
|
||||||
return NiPoint3(this->x - point.x, this->y - point.y, this->z - point.z);
|
return NiPoint3(this->x - point.x, this->y - point.y, this->z - point.z);
|
||||||
|
@ -136,7 +136,7 @@ public:
|
|||||||
NiPoint3 operator+(const NiPoint3& point) const;
|
NiPoint3 operator+(const NiPoint3& point) const;
|
||||||
|
|
||||||
//! Operator for addition of vectors
|
//! Operator for addition of vectors
|
||||||
NiPoint3 operator+=(const NiPoint3& point) const;
|
NiPoint3& operator+=(const NiPoint3& point);
|
||||||
|
|
||||||
//! Operator for subtraction of vectors
|
//! Operator for subtraction of vectors
|
||||||
NiPoint3 operator-(const NiPoint3& point) const;
|
NiPoint3 operator-(const NiPoint3& point) const;
|
||||||
|
@ -12,3 +12,12 @@ TEST(dCommonTests, NiPoint3Test) {
|
|||||||
// Check what unitize does to a vector of length 0
|
// Check what unitize does to a vector of length 0
|
||||||
ASSERT_EQ(NiPoint3::ZERO.Unitize(), NiPoint3::ZERO);
|
ASSERT_EQ(NiPoint3::ZERO.Unitize(), NiPoint3::ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(dCommonTests, NiPoint3OperatorTest) {
|
||||||
|
NiPoint3 a(1, 2, 3);
|
||||||
|
NiPoint3 b(4, 5, 6);
|
||||||
|
a += b;
|
||||||
|
EXPECT_FLOAT_EQ(a.x, 5);
|
||||||
|
EXPECT_FLOAT_EQ(a.y, 7);
|
||||||
|
EXPECT_FLOAT_EQ(a.z, 9);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user