Carpenter Engine
A C++ game engine with a build once run anywhere solution
Loading...
Searching...
No Matches
Utils.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5 */
6
13#ifndef ENGINE_UTILS
14#define ENGINE_UTILS
15
16namespace Engine {
29 typedef enum {
30 FAILURE = -1,
31 SUCCESS = -2,
32 WARNING = -3
33 } Success;
34
38 struct Vec2f {
39 float x;
40 float y;
41
42 // /**
43 // * Assign a Vec2f
44 // */
45 // Vec2f operator=(const Vec2f& rhs);
46
50 Vec2f operator+(const Vec2f& rhs);
51
52 // /**
53 // * Subtract two Vec2f objects
54 // */
55 // Vec2f operator-(const Vec2f& rhs);
56
60 Vec2f operator*(const float& rhs);
61
65 Vec2f operator*(const Vec2f& rhs);
66
67 // /**
68 // * Dot product calculation
69 // */
70 // Vec2f operator*(const Vec2f& rhs);
71
72 // /**
73 // * Scalar division
74 // */
75 // Vec2f operator/(const float& rhs);
76
77 // /**
78 // * Negate a Vec2f
79 // */
80 // Vec2f operator-();
81 };
82
86 struct Vec3f {
87 float x;
88 float y;
89 float z;
90
94 Vec3f operator+(const Vec3f& rhs);
95
99 Vec3f operator*(const float& rhs);
100
104 Vec3f operator*(const Vec3f& rhs);
105
109 float lengthSquared();
110
111 bool operator==(const Vec3f& rhs);
112 };
113
117 struct Color {
118 unsigned char r;
119 unsigned char g;
120 unsigned char b;
121 unsigned char a;
122 };
123
131 Vec2f Rotate(Vec2f v, float angle);
132
140 Vec3f Rotate(Vec3f v, Vec3f angle);
141
150 float InvSQRT(float x);
151}
152
153#endif
float InvSQRT(float x)
returns the inverse square root of a float
Definition Utils.cpp:69
Vec2f Rotate(Vec2f v, float angle)
Rotates a 2D vector by an angle.
Definition Utils.cpp:50
A color struct with 4 components: RGBA.
Definition Utils.hpp:117
A 2D vector struct with overloaded operators.
Definition Utils.hpp:38
Vec2f operator+(const Vec2f &rhs)
Add two Vec2f objects together.
Definition Utils.cpp:14
Vec2f operator*(const float &rhs)
Compute scalar multiplication.
Definition Utils.cpp:18
A 3D vector struct with overloaded operators.
Definition Utils.hpp:86
Vec3f operator*(const float &rhs)
Compute scalar multiplication.
Definition Utils.cpp:32
Vec3f operator+(const Vec3f &rhs)
Adds two Vec3f objects.
Definition Utils.cpp:28
float lengthSquared()
Returns the length of the vector.
Definition Utils.cpp:40