Update lazyvec / vec api as well as rect are mostly constexpr now
This commit is contained in:
+26
-26
@@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
// This file is generated by lazyvec 2.0.0
|
||||
// This file is generated by lazyvec 2.1.0
|
||||
|
||||
#include <pd/common.hpp>
|
||||
// Extended includes (rename if you use other filenames/paths)
|
||||
@@ -69,7 +69,7 @@ class vec3 {
|
||||
// Operations
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator+=(T1 v) {
|
||||
constexpr vec3<T>& operator+=(T1 v) {
|
||||
x += (T)v;
|
||||
y += (T)v;
|
||||
z += (T)v;
|
||||
@@ -77,7 +77,7 @@ class vec3 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator+=(const vec3<T1>& v) {
|
||||
constexpr vec3<T>& operator+=(const vec3<T1>& v) {
|
||||
x += (T)v.x;
|
||||
y += (T)v.y;
|
||||
z += (T)v.z;
|
||||
@@ -85,17 +85,17 @@ class vec3 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> operator+(T1 v) const {
|
||||
constexpr vec3<T> operator+(T1 v) const {
|
||||
return vec3<T>(x + (T)v, y + (T)v, z + (T)v);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> operator+(const vec3<T1>& v) const {
|
||||
constexpr vec3<T> operator+(const vec3<T1>& v) const {
|
||||
return vec3<T>(x + (T)v.x, y + (T)v.y, z + (T)v.z);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator-=(T1 v) {
|
||||
constexpr vec3<T>& operator-=(T1 v) {
|
||||
x -= (T)v;
|
||||
y -= (T)v;
|
||||
z -= (T)v;
|
||||
@@ -103,7 +103,7 @@ class vec3 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator-=(const vec3<T1>& v) {
|
||||
constexpr vec3<T>& operator-=(const vec3<T1>& v) {
|
||||
x -= (T)v.x;
|
||||
y -= (T)v.y;
|
||||
z -= (T)v.z;
|
||||
@@ -111,17 +111,17 @@ class vec3 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> operator-(T1 v) const {
|
||||
constexpr vec3<T> operator-(T1 v) const {
|
||||
return vec3<T>(x - (T)v, y - (T)v, z - (T)v);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> operator-(const vec3<T1>& v) const {
|
||||
constexpr vec3<T> operator-(const vec3<T1>& v) const {
|
||||
return vec3<T>(x - (T)v.x, y - (T)v.y, z - (T)v.z);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator*=(T1 v) {
|
||||
constexpr vec3<T>& operator*=(T1 v) {
|
||||
x *= (T)v;
|
||||
y *= (T)v;
|
||||
z *= (T)v;
|
||||
@@ -129,7 +129,7 @@ class vec3 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator*=(const vec3<T1>& v) {
|
||||
constexpr vec3<T>& operator*=(const vec3<T1>& v) {
|
||||
x *= (T)v.x;
|
||||
y *= (T)v.y;
|
||||
z *= (T)v.z;
|
||||
@@ -137,17 +137,17 @@ class vec3 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> operator*(T1 v) const {
|
||||
constexpr vec3<T> operator*(T1 v) const {
|
||||
return vec3<T>(x * (T)v, y * (T)v, z * (T)v);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> operator*(const vec3<T1>& v) const {
|
||||
constexpr vec3<T> operator*(const vec3<T1>& v) const {
|
||||
return vec3<T>(x * (T)v.x, y * (T)v.y, z * (T)v.z);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator/=(T1 v) {
|
||||
constexpr vec3<T>& operator/=(T1 v) {
|
||||
x /= (T)v;
|
||||
y /= (T)v;
|
||||
z /= (T)v;
|
||||
@@ -155,7 +155,7 @@ class vec3 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator/=(const vec3<T1>& v) {
|
||||
constexpr vec3<T>& operator/=(const vec3<T1>& v) {
|
||||
x /= (T)v.x;
|
||||
y /= (T)v.y;
|
||||
z /= (T)v.z;
|
||||
@@ -163,31 +163,31 @@ class vec3 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> operator/(T1 v) const {
|
||||
constexpr vec3<T> operator/(T1 v) const {
|
||||
return vec3<T>(x / (T)v, y / (T)v, z / (T)v);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> operator/(const vec3<T1>& v) const {
|
||||
constexpr vec3<T> operator/(const vec3<T1>& v) const {
|
||||
return vec3<T>(x / (T)v.x, y / (T)v.y, z / (T)v.z);
|
||||
}
|
||||
|
||||
// Generic Operations
|
||||
|
||||
vec3 operator-() const { return vec3(-x, -y, -z); }
|
||||
constexpr vec3 operator-() const { return vec3(-x, -y, -z); }
|
||||
template <typename T1>
|
||||
bool operator==(const vec3<T1>& v) const {
|
||||
constexpr bool operator==(const vec3<T1>& v) const {
|
||||
return x == (T)v.x && y == (T)v.y && z == (T)v.z;
|
||||
}
|
||||
template <typename T1>
|
||||
bool operator!=(const vec3<T1>& v) const {
|
||||
constexpr bool operator!=(const vec3<T1>& v) const {
|
||||
return !(*this == v);
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
double Len() const { return std::sqrt(SqLen()); }
|
||||
double SqLen() const { return x * x + y * y + z * z; }
|
||||
constexpr double SqLen() const { return x * x + y * y + z * z; }
|
||||
|
||||
template <typename T1>
|
||||
double Distance(const vec3<T1>& v) const {
|
||||
@@ -203,27 +203,27 @@ class vec3 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
T Dot(const vec3<T1>& v) const {
|
||||
constexpr T Dot(const vec3<T1>& v) const {
|
||||
return x * (T)v.x + y * (T)v.y + z * (T)v.z;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec3<T> Cross(const vec3<T1>& v) const {
|
||||
constexpr vec3<T> Cross(const vec3<T1>& v) const {
|
||||
return vec3<T>(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
|
||||
}
|
||||
|
||||
// Swap Functions
|
||||
void SwapXY() {
|
||||
constexpr void SwapXY() {
|
||||
T t = x;
|
||||
x = y;
|
||||
y = t;
|
||||
}
|
||||
void SwapXZ() {
|
||||
constexpr void SwapXZ() {
|
||||
T t = x;
|
||||
x = z;
|
||||
z = t;
|
||||
}
|
||||
void SwapYZ() {
|
||||
constexpr void SwapYZ() {
|
||||
T t = y;
|
||||
y = z;
|
||||
z = t;
|
||||
|
||||
Reference in New Issue
Block a user