Update lazyvec / vec api as well as rect are mostly constexpr now
This commit is contained in:
+23
-23
@@ -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>
|
||||
|
||||
@@ -54,117 +54,117 @@ class vec2 {
|
||||
// Operations
|
||||
|
||||
template <typename T1>
|
||||
vec2<T>& operator+=(T1 v) {
|
||||
constexpr vec2<T>& operator+=(T1 v) {
|
||||
x += (T)v;
|
||||
y += (T)v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T>& operator+=(const vec2<T1>& v) {
|
||||
constexpr vec2<T>& operator+=(const vec2<T1>& v) {
|
||||
x += (T)v.x;
|
||||
y += (T)v.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T> operator+(T1 v) const {
|
||||
constexpr vec2<T> operator+(T1 v) const {
|
||||
return vec2<T>(x + (T)v, y + (T)v);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T> operator+(const vec2<T1>& v) const {
|
||||
constexpr vec2<T> operator+(const vec2<T1>& v) const {
|
||||
return vec2<T>(x + (T)v.x, y + (T)v.y);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T>& operator-=(T1 v) {
|
||||
constexpr vec2<T>& operator-=(T1 v) {
|
||||
x -= (T)v;
|
||||
y -= (T)v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T>& operator-=(const vec2<T1>& v) {
|
||||
constexpr vec2<T>& operator-=(const vec2<T1>& v) {
|
||||
x -= (T)v.x;
|
||||
y -= (T)v.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T> operator-(T1 v) const {
|
||||
constexpr vec2<T> operator-(T1 v) const {
|
||||
return vec2<T>(x - (T)v, y - (T)v);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T> operator-(const vec2<T1>& v) const {
|
||||
constexpr vec2<T> operator-(const vec2<T1>& v) const {
|
||||
return vec2<T>(x - (T)v.x, y - (T)v.y);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T>& operator*=(T1 v) {
|
||||
constexpr vec2<T>& operator*=(T1 v) {
|
||||
x *= (T)v;
|
||||
y *= (T)v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T>& operator*=(const vec2<T1>& v) {
|
||||
constexpr vec2<T>& operator*=(const vec2<T1>& v) {
|
||||
x *= (T)v.x;
|
||||
y *= (T)v.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T> operator*(T1 v) const {
|
||||
constexpr vec2<T> operator*(T1 v) const {
|
||||
return vec2<T>(x * (T)v, y * (T)v);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T> operator*(const vec2<T1>& v) const {
|
||||
constexpr vec2<T> operator*(const vec2<T1>& v) const {
|
||||
return vec2<T>(x * (T)v.x, y * (T)v.y);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T>& operator/=(T1 v) {
|
||||
constexpr vec2<T>& operator/=(T1 v) {
|
||||
x /= (T)v;
|
||||
y /= (T)v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T>& operator/=(const vec2<T1>& v) {
|
||||
constexpr vec2<T>& operator/=(const vec2<T1>& v) {
|
||||
x /= (T)v.x;
|
||||
y /= (T)v.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T> operator/(T1 v) const {
|
||||
constexpr vec2<T> operator/(T1 v) const {
|
||||
return vec2<T>(x / (T)v, y / (T)v);
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
vec2<T> operator/(const vec2<T1>& v) const {
|
||||
constexpr vec2<T> operator/(const vec2<T1>& v) const {
|
||||
return vec2<T>(x / (T)v.x, y / (T)v.y);
|
||||
}
|
||||
|
||||
// Generic Operations
|
||||
|
||||
vec2 operator-() const { return vec2(-x, -y); }
|
||||
constexpr vec2 operator-() const { return vec2(-x, -y); }
|
||||
template <typename T1>
|
||||
bool operator==(const vec2<T1>& v) const {
|
||||
constexpr bool operator==(const vec2<T1>& v) const {
|
||||
return x == (T)v.x && y == (T)v.y;
|
||||
}
|
||||
template <typename T1>
|
||||
bool operator!=(const vec2<T1>& v) const {
|
||||
constexpr bool operator!=(const vec2<T1>& v) const {
|
||||
return !(*this == v);
|
||||
}
|
||||
|
||||
// Functions
|
||||
|
||||
double Len() const { return std::sqrt(SqLen()); }
|
||||
double SqLen() const { return x * x + y * y; }
|
||||
constexpr double SqLen() const { return x * x + y * y; }
|
||||
|
||||
template <typename T1>
|
||||
double Distance(const vec2<T1>& v) const {
|
||||
@@ -180,12 +180,12 @@ class vec2 {
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
T Dot(const vec2<T1>& v) const {
|
||||
constexpr T Dot(const vec2<T1>& v) const {
|
||||
return x * (T)v.x + y * (T)v.y;
|
||||
}
|
||||
|
||||
// Swap Functions
|
||||
void SwapXY() {
|
||||
constexpr void SwapXY() {
|
||||
T t = x;
|
||||
x = y;
|
||||
y = t;
|
||||
|
||||
Reference in New Issue
Block a user