From 77f6b15e2c697fd0fb31ff3c4c70a57aedf5b17d Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Sat, 22 Feb 2020 16:25:55 +0900 Subject: [PATCH 1/3] Added VectorAngles to mathlib. Reference: https://developer.valvesoftware.com/wiki/AngleVectors() --- src/core/modules/mathlib/mathlib_wrap.cpp | 6 ++++++ 1 file changed, 6 insertions(+) mode change 100644 => 100755 src/core/modules/mathlib/mathlib_wrap.cpp diff --git a/src/core/modules/mathlib/mathlib_wrap.cpp b/src/core/modules/mathlib/mathlib_wrap.cpp old mode 100644 new mode 100755 index 45a5b9f93..10a81772b --- a/src/core/modules/mathlib/mathlib_wrap.cpp +++ b/src/core/modules/mathlib/mathlib_wrap.cpp @@ -211,6 +211,12 @@ void export_vector(scope _mathlib) "Returns True if the vector is within the given box coordinates." ) + .def("get_vector_angles", + GET_FUNCTION(void, VectorAngles, const Vector &, QAngle &), + "Forward direction vector -> Euler angles", + arg("angles") + ) + .def("get_distance", &Vector::DistTo, args("other"), From 2be52a71180a3b53373adcaf053074f217554206 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Mon, 24 Feb 2020 11:47:57 +0900 Subject: [PATCH 2/3] Added VectorAngles and VectorVectors. --- src/core/modules/mathlib/mathlib_wrap.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/modules/mathlib/mathlib_wrap.cpp b/src/core/modules/mathlib/mathlib_wrap.cpp index 10a81772b..07b31c7b4 100755 --- a/src/core/modules/mathlib/mathlib_wrap.cpp +++ b/src/core/modules/mathlib/mathlib_wrap.cpp @@ -211,10 +211,21 @@ void export_vector(scope _mathlib) "Returns True if the vector is within the given box coordinates." ) + .def("get_vector_vectors", + &VectorVectors, + (arg("right"), arg("up")) + ) + .def("get_vector_angles", GET_FUNCTION(void, VectorAngles, const Vector &, QAngle &), - "Forward direction vector -> Euler angles", - arg("angles") + arg("angles"), + "Forward direction vector -> Euler angles." + ) + + .def("get_vector_angles", + GET_FUNCTION(void, VectorAngles, const Vector &, const Vector &, QAngle &), + (arg("pseudoup"), arg("angles")), + "Forward direction vector with a reference up vector -> Euler angles." ) .def("get_distance", From 49ad3d87adaf8a4afa6b79d09421a043721b2988 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Tue, 25 Feb 2020 07:14:13 +0900 Subject: [PATCH 3/3] Added unary negative operation to Vector. --- src/core/modules/mathlib/mathlib.h | 6 ++++++ src/core/modules/mathlib/mathlib_wrap.cpp | 2 ++ 2 files changed, 8 insertions(+) mode change 100644 => 100755 src/core/modules/mathlib/mathlib.h diff --git a/src/core/modules/mathlib/mathlib.h b/src/core/modules/mathlib/mathlib.h old mode 100644 new mode 100755 index c83b7a536..c2cac3d89 --- a/src/core/modules/mathlib/mathlib.h +++ b/src/core/modules/mathlib/mathlib.h @@ -94,6 +94,12 @@ class VectorExt vecCopy -= val; return vecCopy; } + + static inline Vector __neg__(Vector vecCopy) + { + vecCopy.Negate(); + return vecCopy; + } }; diff --git a/src/core/modules/mathlib/mathlib_wrap.cpp b/src/core/modules/mathlib/mathlib_wrap.cpp index 07b31c7b4..5628ccdeb 100755 --- a/src/core/modules/mathlib/mathlib_wrap.cpp +++ b/src/core/modules/mathlib/mathlib_wrap.cpp @@ -158,6 +158,8 @@ void export_vector(scope _mathlib) .def("__radd__", &VectorExt::__add__) .def(float() * self) + .def("__neg__", &VectorExt::__neg__) + .def("negate", &Vector::Negate, "Negates the vector."