Skip to content

Commit 6ff0e62

Browse files
committed
CVector moved to shared
1 parent 363e38a commit 6ff0e62

File tree

25 files changed

+258
-1515
lines changed

25 files changed

+258
-1515
lines changed

examples/UnitTests/source/Main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ struct Main
1010
{
1111
Main()
1212
{
13+
gInstance.RunTests(); // run now. In future some tests might require the game to be initialized
1314
// register event callbacks
14-
Events::menuDrawingEvent += []{ gInstance.RunTests(); };
15+
//Events::menuDrawingEvent += []{ gInstance.RunTests(); };
1516
}
1617

1718
void RunTests()

examples/UnitTests/source/Test_CVector.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ UTEST(CVector, ctor_CVector)
4848
EXPECT_EQ(v.z, 3.0f);
4949
}
5050

51+
#ifdef RW
5152
UTEST(CVector, ctor_RwV3d)
5253
{
5354
RwV3d src;
@@ -60,6 +61,7 @@ UTEST(CVector, ctor_RwV3d)
6061
EXPECT_EQ(v.y, 2.0f);
6162
EXPECT_EQ(v.z, 3.0f);
6263
}
64+
#endif
6365

6466
UTEST(CVector, ctor_CVector2D)
6567
{
@@ -108,6 +110,7 @@ UTEST(CVector, operator_assign)
108110
EXPECT_EQ(v.z, 3.0f);
109111
}
110112

113+
#ifdef RW
111114
UTEST(CVector, FromRwV3d)
112115
{
113116
RwV3d src;
@@ -121,6 +124,7 @@ UTEST(CVector, FromRwV3d)
121124
EXPECT_EQ(v.y, 2.0f);
122125
EXPECT_EQ(v.z, 3.0f);
123126
}
127+
#endif
124128

125129
UTEST(CVector, From2D)
126130
{
@@ -193,6 +197,7 @@ UTEST(CVector, FromCross)
193197
EXPECT_NEAR(v.z, 1.0f, F_EPS);
194198
}
195199

200+
#ifdef HAS_CMATRIX
196201
UTEST(CVector, FromMultiply)
197202
{
198203
CMatrix m;
@@ -220,9 +225,11 @@ UTEST(CVector, FromMultiply3x3)
220225
EXPECT_NEAR(v.y, 1.0f, F_EPS);
221226
EXPECT_NEAR(v.z, 0.0f, F_EPS);
222227
}
228+
#endif
223229

224230
// conversions
225231

232+
#ifdef RW
226233
UTEST(CVector, ToRwV3d)
227234
{
228235
CVector src;
@@ -235,6 +242,7 @@ UTEST(CVector, ToRwV3d)
235242
EXPECT_EQ(v.y, 2.0f);
236243
EXPECT_EQ(v.z, 3.0f);
237244
}
245+
#endif
238246

239247
UTEST(CVector, To2D)
240248
{
@@ -676,6 +684,7 @@ UTEST(CVector, Cross_CVectorCVector)
676684
EXPECT_NEAR(1.0f, v.z, F_EPS);
677685
}
678686

687+
#ifdef HAS_CMATRIX
679688
UTEST(CVector, Multiply)
680689
{
681690
CMatrix m;
@@ -701,6 +710,7 @@ UTEST(CVector, Multiply3x3)
701710
EXPECT_NEAR(v.y, 1.0f, F_EPS);
702711
EXPECT_NEAR(v.z, 0.0f, F_EPS);
703712
}
713+
#endif
704714

705715
// static operators
706716

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
Do not delete this comment block. Respect others' work!
66
*/
77

8-
#include "CVector.h"
8+
#include "CVector2D.h"
9+
#include <CVector.h>
910

1011
CEncodedVector::CEncodedVector() {
1112
x = 0; y = 0; z = 0;
@@ -96,69 +97,3 @@ void CVector2D::operator/=(float divisor) {
9697
CEncodedVector2D CVector2D::ToInt16() {
9798
return CEncodedVector2D((int)(this->x * 16384), (int)(this->y * 16384));
9899
}
99-
100-
CVector::CVector() {
101-
x = 0.0f; y = 0.0f; z = 0.0f;
102-
}
103-
104-
CVector::CVector(float X, float Y, float Z) {
105-
x = X; y = Y; z = Z;
106-
}
107-
108-
CVector::CVector(CVector const& src) {
109-
x = src.x; y = src.y; z = src.z;
110-
}
111-
112-
float CVector::Magnitude() {
113-
return sqrtf(this->x * this->x + this->y * this->y + this->z * this->z);
114-
}
115-
116-
float CVector::Magnitude2D() {
117-
return sqrtf(this->x * this->x + this->y * this->y);
118-
}
119-
120-
void CVector::Sum(CVector& a, CVector& b) {
121-
this->x = a.x + b.x;
122-
this->y = a.y + b.y;
123-
this->z = a.z + b.z;
124-
}
125-
126-
void CVector::Difference(CVector& a, CVector& b) {
127-
this->x = a.x - b.x;
128-
this->y = a.y - b.y;
129-
this->z = a.z - b.z;
130-
}
131-
132-
void CVector::operator=(const CVector& right) {
133-
this->x = right.x;
134-
this->y = right.y;
135-
this->z = right.z;
136-
}
137-
138-
void CVector::operator+=(const CVector& right) {
139-
this->x += right.x;
140-
this->y += right.y;
141-
this->z += right.z;
142-
}
143-
144-
void CVector::operator-=(const CVector& right) {
145-
this->x -= right.x;
146-
this->y -= right.y;
147-
this->z -= right.z;
148-
}
149-
150-
void CVector::operator *= (float multiplier) {
151-
this->x *= multiplier;
152-
this->y *= multiplier;
153-
this->z *= multiplier;
154-
}
155-
156-
void CVector::operator/=(float divisor) {
157-
this->x /= divisor;
158-
this->y /= divisor;
159-
this->z /= divisor;
160-
}
161-
162-
CEncodedVector CVector::ToInt16() {
163-
return CEncodedVector((int)(this->x * 16384), (int)(this->y * 16384), (int)(this->z * 16384));
164-
}
Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -66,39 +66,6 @@ inline CVector2D operator*(const CVector2D& left, float right) {
6666
return CVector2D(left.x * right, left.y * right);
6767
}
6868

69-
class CVector {
70-
public:
71-
float x, y, z;
72-
73-
public:
74-
CVector();
75-
CVector(float X, float Y, float Z);
76-
CVector(CVector const& src);
77-
float Magnitude();
78-
float Magnitude2D();
79-
80-
void Sum(CVector& a, CVector& b);
81-
void Difference(CVector& a, CVector& b);
82-
void operator=(const CVector& right);
83-
void operator+=(const CVector& right);
84-
void operator-=(const CVector& right);
85-
void operator*=(float multiplier);
86-
void operator/=(float divisor);
87-
CEncodedVector ToInt16();
88-
};
89-
90-
inline CVector operator+(const CVector& left, const CVector& right) {
91-
return CVector(left.x + right.x, left.y + right.y, left.z + right.z);
92-
}
93-
94-
inline CVector operator-(const CVector& left, const CVector& right) {
95-
return CVector(left.x - right.x, left.y - right.y, left.z - right.z);
96-
}
97-
98-
inline CVector operator-(const CVector& left, const CVector2D& right) {
99-
return CVector(left.x - right.x, left.y - right.y, left.z);
100-
}
101-
102-
inline CVector2D operator-(const CVector2D& left, const CVector& right) {
69+
inline CVector2D operator-(const CVector2D& left, const CVector2D& right) {
10370
return CVector2D(left.x - right.x, left.y - right.y);
10471
}

plugin_III/game_III/CVector.h

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)