# Changes
3ds Backend: - switch to shaderProgramUse Desktop Backend - Add Pre Alpha Text Input and Keyboard Support - Move Shader Attrib Setup into a function and callit every time we need a set up vbo - Move to Mat4 api Core: - Add fquat support - Add LoadFile2Str - Move Mat4 Lib from Project n73 to Palladium - Add full supprot for vec cross types - Add Normalize, Distance and Dot to all - Add Cross to vec3 Drivers: - Add a SetViewPort func to GFX - Add Keyboard keys and Flasg to Hid Image: - Add Vertical Flipping - Add Horizontal flipping UI7: - Fix Critical Bug in IO Viewport handler - Fix library list (error on MinGW for some reason) Lazyvec: - Split into multiple source files - Generate new functions (see core updates)
This commit is contained in:
@ -23,8 +23,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
// This file is generated by lazyvec
|
||||
// This file is generated by lazyvec 2.0.0
|
||||
|
||||
#include <pd/core/common.hpp>
|
||||
// Extended includes (rename if you use other filenames/paths)
|
||||
#include <pd/core/vec2.hpp>
|
||||
|
||||
namespace PD {
|
||||
template <typename T>
|
||||
@ -34,22 +37,36 @@ class vec3 {
|
||||
T y;
|
||||
T z;
|
||||
|
||||
vec3() : x(0), y(0), z(0) {}
|
||||
// Constructors
|
||||
|
||||
constexpr vec3() : x(0), y(0), z(0) {}
|
||||
template <typename T1>
|
||||
explicit vec3(T1 v) {
|
||||
constexpr vec3(T1 v) {
|
||||
x = (T)v;
|
||||
y = (T)v;
|
||||
z = (T)v;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
explicit vec3(vec3<T1> v) {
|
||||
constexpr vec3(const vec3<T1>& v) {
|
||||
x = (T)v.x;
|
||||
y = (T)v.y;
|
||||
z = (T)v.z;
|
||||
}
|
||||
|
||||
vec3(T x, T y, T z) : x(x), y(y), z(z) {}
|
||||
constexpr explicit vec3(T x, T y, T z) : x(x), y(y), z(z) {}
|
||||
|
||||
// Extended Constructors
|
||||
template <typename T1>
|
||||
constexpr explicit vec3(const vec2<T1>& xy, T1 z) {
|
||||
{
|
||||
x = (T)xy.x;
|
||||
y = (T)xy.y;
|
||||
this->z = (T)z;
|
||||
}
|
||||
}
|
||||
|
||||
// Operations
|
||||
|
||||
template <typename T1>
|
||||
vec3<T>& operator+=(T1 v) {
|
||||
@ -155,16 +172,47 @@ class vec3 {
|
||||
return vec3<T>(x / (T)v.x, y / (T)v.y, z / (T)v.z);
|
||||
}
|
||||
|
||||
vec3 operator-() const { return vec3(-x, -y, -z); }
|
||||
// Generic Operations
|
||||
|
||||
bool operator==(const vec3& v) const {
|
||||
return x == v.x && y == v.y && z == v.z;
|
||||
vec3 operator-() const { return vec3(-x, -y, -z); }
|
||||
template <typename T1>
|
||||
bool operator==(const vec3<T1>& v) const {
|
||||
return x == (T)v.x && y == (T)v.y && z == (T)v.z;
|
||||
}
|
||||
bool operator!=(const vec3& v) const { return !(*this == v); }
|
||||
template <typename T1>
|
||||
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; }
|
||||
|
||||
template <typename T1>
|
||||
double Distance(const vec3<T1>& v) const {
|
||||
return (*this - v).Len();
|
||||
}
|
||||
|
||||
vec3<T> Normalize() const {
|
||||
double l = Len();
|
||||
if (l == 0) {
|
||||
return *this;
|
||||
}
|
||||
return *this / (T)l;
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
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 {
|
||||
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() {
|
||||
T t = x;
|
||||
x = y;
|
||||
@ -182,6 +230,6 @@ class vec3 {
|
||||
}
|
||||
};
|
||||
using fvec3 = vec3<float>;
|
||||
using dvec3 = vec3<double>;
|
||||
using ivec3 = vec3<int>;
|
||||
using dvec3 = vec3<double>;
|
||||
} // namespace PD
|
||||
|
Reference in New Issue
Block a user