summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc <marc.gilleron@gmail.com>2021-01-31 20:06:56 +0000
committerGitHub <noreply@github.com>2021-01-31 20:06:56 +0000
commitb400dba87534640eeddbcdb6b319335a6a7639d8 (patch)
tree286a8e2e25c18fe11f346835b3021afae2e9b77f
parentfb71edd45b2473bf0ac502c777a1850fb564087e (diff)
parent05ba977cc60653952b73dc03498ebc7a93cef120 (diff)
downloadredot-cpp-b400dba87534640eeddbcdb6b319335a6a7639d8.tar.gz
Merge branch 'master' into container_leaks
-rw-r--r--.github/dependabot.yml6
-rw-r--r--.github/workflows/ci.yml126
-rw-r--r--.travis.yml75
-rw-r--r--README.md4
-rw-r--r--SConstruct9
m---------godot_headers0
-rw-r--r--include/core/Array.hpp6
-rw-r--r--include/core/Basis.hpp5
-rw-r--r--include/core/Defs.hpp7
-rw-r--r--include/core/Godot.hpp22
-rw-r--r--include/core/Math.hpp26
-rw-r--r--include/core/Quat.hpp2
-rw-r--r--include/core/Ref.hpp40
-rw-r--r--include/core/Transform.hpp5
-rw-r--r--include/core/Transform2D.hpp4
-rw-r--r--include/core/Vector2.hpp15
-rw-r--r--include/core/Vector3.hpp13
-rw-r--r--src/core/Array.cpp6
-rw-r--r--src/core/Basis.cpp5
-rw-r--r--src/core/Quat.cpp2
-rw-r--r--src/core/String.cpp9
-rw-r--r--src/core/Transform.cpp5
-rw-r--r--src/core/Transform2D.cpp4
-rw-r--r--src/core/Vector2.cpp9
-rw-r--r--src/core/Vector3.cpp11
25 files changed, 280 insertions, 136 deletions
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..1230149
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,6 @@
+version: 2
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..9000161
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,126 @@
+name: Continuous integration
+on: [push, pull_request]
+
+jobs:
+ linux:
+ name: Build (Linux, GCC)
+ runs-on: ubuntu-16.04
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2.3.4
+ with:
+ submodules: recursive
+
+ - name: Set up Python (for SCons)
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.9.1'
+
+ - name: Install dependencies
+ run: |
+ sudo apt-get update -qq
+ sudo apt-get install -qqq build-essential pkg-config
+ python -m pip install scons
+
+ - name: Build godot-cpp
+ run: |
+ scons target=release generate_bindings=yes -j $(nproc)
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2.2.1
+ with:
+ name: godot-cpp-linux-glibc2.23-x86_64-release
+ path: bin/libgodot-cpp.linux.release.64.a
+ if-no-files-found: error
+
+ windows-msvc:
+ name: Build (Windows, MSVC)
+ runs-on: windows-2019
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2.3.4
+ with:
+ submodules: recursive
+
+ - name: Set up Python (for SCons)
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.9.1'
+
+ - name: Install dependencies
+ run: |
+ python -m pip install scons
+
+ - name: Build godot-cpp
+ run: |
+ scons target=release generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2.2.1
+ with:
+ name: godot-cpp-windows-msvc2019-x86_64-release
+ path: bin/libgodot-cpp.windows.release.64.lib
+ if-no-files-found: error
+
+ windows-mingw:
+ name: Build (Windows, MinGW)
+ runs-on: windows-2019
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2.3.4
+ with:
+ submodules: recursive
+
+ - name: Set up Python (for SCons)
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.9.1'
+
+ - name: Install dependencies
+ run: |
+ python -m pip install scons
+
+ - name: Build godot-cpp
+ # Install GCC from Scoop as the default supplied GCC doesn't work ("Error 1").
+ run: |
+ Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
+ scoop install gcc
+ g++ --version
+ gcc --version
+ scons target=release generate_bindings=yes use_mingw=yes -j $env:NUMBER_OF_PROCESSORS
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2.2.1
+ with:
+ name: godot-cpp-linux-mingw-x86_64-release
+ path: bin/libgodot-cpp.windows.release.64.a
+ if-no-files-found: error
+
+ macos:
+ name: Build (macOS, Clang)
+ runs-on: macos-11.0
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2.3.4
+ with:
+ submodules: recursive
+
+ - name: Set up Python (for SCons)
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.9.1'
+
+ - name: Install dependencies
+ run: |
+ python -m pip install scons
+
+ - name: Build godot-cpp
+ run: |
+ scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu)
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2.2.1
+ with:
+ name: godot-cpp-macos-x86_64-release
+ path: bin/libgodot-cpp.osx.release.64.a
+ if-no-files-found: error
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index c6b08f2..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,75 +0,0 @@
-language: cpp
-dist: xenial
-osx_image: xcode10.1
-
-env:
- global:
- - SCONS_CACHE="$HOME/.scons_cache"
- - SCONS_CACHE_LIMIT=1024
-
-cache:
- directories:
- - $SCONS_CACHE
-
-matrix:
- include:
- - name: Linux Debug + Static Checks
- os: linux
- compiler: gcc
- env: TARGET=debug STATIC_CHECKS=yes
- addons:
- apt:
- packages:
- - clang-format-8
- - [scons, pkg-config, build-essential, p7zip-full]
-
- - name: Linux Release
- os: linux
- compiler: gcc
- addons:
- apt:
- packages:
- - [scons, pkg-config, build-essential, p7zip-full]
- env: TARGET=release
-
- - name: macOS Debug
- os: osx
- compiler: clang
- env: TARGET=debug
-
- - name: macOS Release
- os: osx
- compiler: clang
- env: TARGET=release
-
- - name: Windows MSVC Debug
- os: windows
- env: TARGET=debug
-
- - name: Windows MSVC Release
- os: windows
- env: TARGET=release
-
-install:
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
- brew update;
- brew install scons p7zip;
- fi
-
- - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
- curl -LO https://downloads.sourceforge.net/project/scons/scons-local/3.1.2/scons-local-3.1.2.zip;
- unzip scons-local-3.1.2.zip;
- fi
-
-script:
- - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
- export SCONS="./scons.bat";
- else
- export SCONS="scons";
- fi
-
- - $SCONS target="$TARGET" bits=64 generate_bindings=yes $SCONS_FLAGS;
-
- - if [[ "$STATIC_CHECKS" == "yes" ]]; then
- sh ./misc/travis/clang-format.sh;
- fi
diff --git a/README.md b/README.md
index e960be6..301add9 100644
--- a/README.md
+++ b/README.md
@@ -292,8 +292,8 @@ platform-independent manner.
Once your GDNative library is compiled and referenced in a `.gdns` file, you can use it in GDScript or C#. Here's an example with GDScript:
```gdscript
-var simpleclass = load("res://simpleclass.gdns").new();
-simpleclass.method("Test argument");
+var simpleclass = load("res://simpleclass.gdns").new()
+simpleclass.method("Test argument")
```
### Using Godot classes in C++
diff --git a/SConstruct b/SConstruct
index d22c9a3..4659936 100644
--- a/SConstruct
+++ b/SConstruct
@@ -134,6 +134,11 @@ opts.Add(EnumVariable(
'armv7',
['armv7','arm64v8','x86','x86_64']
))
+opts.Add(
+ 'macos_deployment_target',
+ 'macOS deployment target',
+ 'default'
+)
opts.Add(EnumVariable(
'ios_arch',
'Target iOS architecture',
@@ -204,6 +209,10 @@ elif env['platform'] == 'osx':
)
env.Append(CCFLAGS=['-std=c++14', '-arch', 'x86_64'])
+
+ if env['macos_deployment_target'] != 'default':
+ env.Append(CCFLAGS=['-mmacosx-version-min=' + env['macos_deployment_target']])
+
env.Append(LINKFLAGS=[
'-arch',
'x86_64',
diff --git a/godot_headers b/godot_headers
-Subproject ddf67cc7b8274c5fb77a71c828bab2991f1ee12
+Subproject f2122198d51f230d903f9585527248f6cf41149
diff --git a/include/core/Array.hpp b/include/core/Array.hpp
index 84dc012..5913fae 100644
--- a/include/core/Array.hpp
+++ b/include/core/Array.hpp
@@ -106,9 +106,9 @@ public:
Variant back() const;
- int find(const Variant &what, const int from = 0);
+ int find(const Variant &what, const int from = 0) const;
- int find_last(const Variant &what);
+ int find_last(const Variant &what) const;
bool has(const Variant &what) const;
@@ -134,7 +134,7 @@ public:
void resize(const int size);
- int rfind(const Variant &what, const int from = -1);
+ int rfind(const Variant &what, const int from = -1) const;
void sort();
diff --git a/include/core/Basis.hpp b/include/core/Basis.hpp
index 76a345b..0fd697e 100644
--- a/include/core/Basis.hpp
+++ b/include/core/Basis.hpp
@@ -13,6 +13,11 @@ class Quat;
class Basis {
private:
+ static const Basis IDENTITY;
+ static const Basis FLIP_X;
+ static const Basis FLIP_Y;
+ static const Basis FLIP_Z;
+
// This helper template is for mimicking the behavior difference between the engine
// and script interfaces that logically script sees matrices as column major, while
// the engine stores them in row major to efficiently take advantage of SIMD
diff --git a/include/core/Defs.hpp b/include/core/Defs.hpp
index 67e3279..e90f6ce 100644
--- a/include/core/Defs.hpp
+++ b/include/core/Defs.hpp
@@ -70,9 +70,12 @@ enum class Error {
typedef float real_t;
-#define CMP_EPSILON 0.00001
+// This epsilon should match the one used by Godot for consistency.
+// Using `f` when `real_t` is float.
+#define CMP_EPSILON 0.00001f
#define CMP_EPSILON2 (CMP_EPSILON * CMP_EPSILON)
-#define Math_PI 3.14159265358979323846
+
+#define Math_PI 3.1415926535897932384626433833
#define Math_TAU 6.2831853071795864769252867666
#define _PLANE_EQ_DOT_EPSILON 0.999
diff --git a/include/core/Godot.hpp b/include/core/Godot.hpp
index 322a763..db5a871 100644
--- a/include/core/Godot.hpp
+++ b/include/core/Godot.hpp
@@ -149,7 +149,7 @@ struct _ArgCast<Variant> {
// instance and destroy funcs
template <class T>
-void *_godot_class_instance_func(godot_object *p, void *method_data) {
+void *_godot_class_instance_func(godot_object *p, void * /*method_data*/) {
T *d = new T();
d->_owner = p;
d->_type_tag = typeid(T).hash_code();
@@ -158,7 +158,7 @@ void *_godot_class_instance_func(godot_object *p, void *method_data) {
}
template <class T>
-void _godot_class_destroy_func(godot_object *p, void *method_data, void *data) {
+void _godot_class_destroy_func(godot_object * /*p*/, void * /*method_data*/, void *data) {
T *d = (T *)data;
delete d;
}
@@ -210,13 +210,13 @@ void register_tool_class() {
typedef godot_variant (*__godot_wrapper_method)(godot_object *, void *, void *, int, godot_variant **);
template <class T, class R, class... args>
-const char *___get_method_class_name(R (T::*p)(args... a)) {
+const char *___get_method_class_name(R (T::*/*p*/)(args... a)) {
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
return T::___get_class_name();
}
template <class T, class R, class... args>
-const char *___get_method_class_name(R (T::*p)(args... a) const) {
+const char *___get_method_class_name(R (T::*/*p*/)(args... a) const) {
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
return T::___get_class_name();
}
@@ -256,13 +256,13 @@ struct _WrappedMethod<T, void, As...> {
void (T::*f)(As...);
template <int... I>
- void apply(Variant *ret, T *obj, Variant **args, __Sequence<I...>) {
+ void apply(Variant * /*ret*/, T *obj, Variant **args, __Sequence<I...>) {
(obj->*f)(_ArgCast<As>::_arg_cast(*args[I])...);
}
};
template <class T, class R, class... As>
-godot_variant __wrapped_method(godot_object *, void *method_data, void *user_data, int num_args, godot_variant **args) {
+godot_variant __wrapped_method(godot_object *, void *method_data, void *user_data, int /*num_args*/, godot_variant **args) {
godot_variant v;
godot::api->godot_variant_new_nil(&v);
@@ -286,7 +286,7 @@ void *___make_wrapper_function(R (T::*f)(As...)) {
}
template <class T, class R, class... As>
-__godot_wrapper_method ___get_wrapper_function(R (T::*f)(As...)) {
+__godot_wrapper_method ___get_wrapper_function(R (T::* /*f*/)(As...)) {
return (__godot_wrapper_method)&__wrapped_method<T, R, As...>;
}
@@ -326,7 +326,7 @@ void register_method_explicit(const char *name, R (B::*method_ptr)(As...),
template <class T, class P>
struct _PropertySetFunc {
void (T::*f)(P);
- static void _wrapped_setter(godot_object *object, void *method_data, void *user_data, godot_variant *value) {
+ static void _wrapped_setter(godot_object * /*object*/, void *method_data, void *user_data, godot_variant *value) {
_PropertySetFunc<T, P> *set_func = (_PropertySetFunc<T, P> *)method_data;
T *obj = (T *)user_data;
@@ -340,7 +340,7 @@ template <class T, class P>
struct _PropertyGetFunc {
P(T::*f)
();
- static godot_variant _wrapped_getter(godot_object *object, void *method_data, void *user_data) {
+ static godot_variant _wrapped_getter(godot_object * /*object*/, void *method_data, void *user_data) {
_PropertyGetFunc<T, P> *get_func = (_PropertyGetFunc<T, P> *)method_data;
T *obj = (T *)user_data;
@@ -358,7 +358,7 @@ struct _PropertyGetFunc {
template <class T, class P>
struct _PropertyDefaultSetFunc {
P(T::*f);
- static void _wrapped_setter(godot_object *object, void *method_data, void *user_data, godot_variant *value) {
+ static void _wrapped_setter(godot_object * /*object*/, void *method_data, void *user_data, godot_variant *value) {
_PropertyDefaultSetFunc<T, P> *set_func = (_PropertyDefaultSetFunc<T, P> *)method_data;
T *obj = (T *)user_data;
@@ -371,7 +371,7 @@ struct _PropertyDefaultSetFunc {
template <class T, class P>
struct _PropertyDefaultGetFunc {
P(T::*f);
- static godot_variant _wrapped_getter(godot_object *object, void *method_data, void *user_data) {
+ static godot_variant _wrapped_getter(godot_object * /*object*/, void *method_data, void *user_data) {
_PropertyDefaultGetFunc<T, P> *get_func = (_PropertyDefaultGetFunc<T, P> *)method_data;
T *obj = (T *)user_data;
diff --git a/include/core/Math.hpp b/include/core/Math.hpp
index 4d0d32e..a971bb8 100644
--- a/include/core/Math.hpp
+++ b/include/core/Math.hpp
@@ -107,21 +107,21 @@ inline T max(T a, T b) {
template <typename T>
inline T sign(T x) {
- return x < 0 ? -1 : 1;
+ return static_cast<T>(x < 0 ? -1 : 1);
}
inline double deg2rad(double p_y) {
return p_y * Math_PI / 180.0;
}
inline float deg2rad(float p_y) {
- return p_y * Math_PI / 180.0;
+ return p_y * static_cast<float>(Math_PI) / 180.f;
}
inline double rad2deg(double p_y) {
return p_y * 180.0 / Math_PI;
}
inline float rad2deg(float p_y) {
- return p_y * 180.0 / Math_PI;
+ return p_y * 180.f / static_cast<float>(Math_PI);
}
inline double inverse_lerp(double p_from, double p_to, double p_value) {
@@ -165,7 +165,7 @@ inline bool is_zero_approx(real_t s) {
}
inline double smoothstep(double p_from, double p_to, double p_weight) {
- if (is_equal_approx(p_from, p_to)) {
+ if (is_equal_approx(static_cast<real_t>(p_from), static_cast<real_t>(p_to))) {
return p_from;
}
double x = clamp((p_weight - p_from) / (p_to - p_from), 0.0, 1.0);
@@ -205,7 +205,7 @@ inline double round(double p_val) {
return (p_val >= 0) ? floor(p_val + 0.5) : -floor(-p_val + 0.5);
}
inline float round(float p_val) {
- return (p_val >= 0) ? floor(p_val + 0.5) : -floor(-p_val + 0.5);
+ return (p_val >= 0) ? floor(p_val + 0.5f) : -floor(-p_val + 0.5f);
}
inline int64_t wrapi(int64_t value, int64_t min, int64_t max) {
@@ -213,16 +213,18 @@ inline int64_t wrapi(int64_t value, int64_t min, int64_t max) {
return range == 0 ? min : min + ((((value - min) % range) + range) % range);
}
-inline double wrapf(double value, double min, double max) {
- double range = max - min;
- return is_zero_approx(range) ? min : value - (range * floor((value - min) / range));
-}
-inline float wrapf(float value, float min, float max) {
- float range = max - min;
+inline float wrapf(real_t value, real_t min, real_t max) {
+ const real_t range = max - min;
return is_zero_approx(range) ? min : value - (range * floor((value - min) / range));
}
-inline real_t stepify(real_t p_value, real_t p_step) {
+inline float stepify(float p_value, float p_step) {
+ if (p_step != 0) {
+ p_value = floor(p_value / p_step + 0.5f) * p_step;
+ }
+ return p_value;
+}
+inline double stepify(double p_value, double p_step) {
if (p_step != 0) {
p_value = floor(p_value / p_step + 0.5) * p_step;
}
diff --git a/include/core/Quat.hpp b/include/core/Quat.hpp
index f047178..4add6be 100644
--- a/include/core/Quat.hpp
+++ b/include/core/Quat.hpp
@@ -11,6 +11,8 @@ namespace godot {
class Quat {
public:
+ static const Quat IDENTITY;
+
real_t x, y, z, w;
real_t length_squared() const;
diff --git a/include/core/Ref.hpp b/include/core/Ref.hpp
index 8cbd134..80133a1 100644
--- a/include/core/Ref.hpp
+++ b/include/core/Ref.hpp
@@ -11,6 +11,10 @@ namespace godot {
// Rewritten from f5234e70be7dec4930c2d5a0e829ff480d044b1d.
template <class T>
class Ref {
+ // TODO For this nice check to work, each class must actually #include Reference classes mentionned in its methods,
+ // which might be annoying for coders who prefer to forward-declare to reduce compile times
+ // static_assert(std::is_base_of<Reference, T>::value,
+ // "Ref<T> can only be used with classes deriving from Reference");
T *reference = nullptr;
@@ -28,7 +32,7 @@ class Ref {
void ref_pointer(T *p_ref) {
- ERR_FAIL_COND(!p_ref);
+ ERR_FAIL_COND(p_ref == nullptr);
if (p_ref->init_ref())
reference = p_ref;
@@ -90,32 +94,25 @@ public:
template <class T_Other>
void operator=(const Ref<T_Other> &p_from) {
-
- // TODO We need a safe cast
Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr()));
- if (!refb) {
+ if (refb == nullptr) {
unref();
return;
}
Ref r;
- //r.reference = Object::cast_to<T>(refb);
- r.reference = (T *)refb;
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = nullptr;
}
void operator=(const Variant &p_variant) {
-
- // TODO We need a safe cast
- Reference *refb = (Reference *)T::___get_from_variant(p_variant);
- if (!refb) {
+ Object *refb = T::___get_from_variant(p_variant);
+ if (refb == nullptr) {
unref();
return;
}
Ref r;
- // TODO We need a safe cast
- //r.reference = Object::cast_to<T>(refb);
- r.reference = (T *)refb;
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = nullptr;
}
@@ -128,18 +125,14 @@ public:
template <class T_Other>
Ref(const Ref<T_Other> &p_from) {
-
reference = nullptr;
- // TODO We need a safe cast
Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr()));
- if (!refb) {
+ if (refb == nullptr) {
unref();
return;
}
Ref r;
- // TODO We need a safe cast
- //r.reference = Object::cast_to<T>(refb);
- r.reference = (T *)refb;
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = nullptr;
}
@@ -155,16 +148,13 @@ public:
Ref(const Variant &p_variant) {
reference = nullptr;
- // TODO We need a safe cast
- Reference *refb = (Reference *)T::___get_from_variant(p_variant);
- if (!refb) {
+ Object *refb = T::___get_from_variant(p_variant);
+ if (refb == nullptr) {
unref();
return;
}
Ref r;
- // TODO We need a safe cast
- //r.reference = Object::cast_to<T>(refb);
- r.reference = (T *)refb;
+ r.reference = Object::cast_to<T>(refb);
ref(r);
r.reference = nullptr;
}
diff --git a/include/core/Transform.hpp b/include/core/Transform.hpp
index 9da6366..836792c 100644
--- a/include/core/Transform.hpp
+++ b/include/core/Transform.hpp
@@ -10,6 +10,11 @@ namespace godot {
class Transform {
public:
+ static const Transform IDENTITY;
+ static const Transform FLIP_X;
+ static const Transform FLIP_Y;
+ static const Transform FLIP_Z;
+
Basis basis;
Vector3 origin;
diff --git a/include/core/Transform2D.hpp b/include/core/Transform2D.hpp
index ae01b7f..6a5010f 100644
--- a/include/core/Transform2D.hpp
+++ b/include/core/Transform2D.hpp
@@ -10,6 +10,10 @@ typedef Vector2 Size2;
struct Rect2;
struct Transform2D {
+ static const Transform2D IDENTITY;
+ static const Transform2D FLIP_X;
+ static const Transform2D FLIP_Y;
+
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper":
// M = (elements[0][0] elements[1][0])
// (elements[0][1] elements[1][1])
diff --git a/include/core/Vector2.hpp b/include/core/Vector2.hpp
index 031d47f..3c2a403 100644
--- a/include/core/Vector2.hpp
+++ b/include/core/Vector2.hpp
@@ -12,6 +12,21 @@ namespace godot {
class String;
struct Vector2 {
+ enum Axis {
+ AXIS_X = 0,
+ AXIS_Y,
+ AXIS_COUNT
+ };
+
+ static const Vector2 ZERO;
+ static const Vector2 ONE;
+ static const Vector2 INF;
+
+ // Coordinate system of the 2D engine
+ static const Vector2 LEFT;
+ static const Vector2 RIGHT;
+ static const Vector2 UP;
+ static const Vector2 DOWN;
union {
real_t x;
diff --git a/include/core/Vector3.hpp b/include/core/Vector3.hpp
index 5971787..cbd4f75 100644
--- a/include/core/Vector3.hpp
+++ b/include/core/Vector3.hpp
@@ -19,8 +19,21 @@ struct Vector3 {
AXIS_X,
AXIS_Y,
AXIS_Z,
+ AXIS_COUNT
};
+ static const Vector3 ZERO;
+ static const Vector3 ONE;
+ static const Vector3 INF;
+
+ // Coordinate system of the 3D engine
+ static const Vector3 LEFT;
+ static const Vector3 RIGHT;
+ static const Vector3 UP;
+ static const Vector3 DOWN;
+ static const Vector3 FORWARD;
+ static const Vector3 BACK;
+
union {
struct {
real_t x;
diff --git a/src/core/Array.cpp b/src/core/Array.cpp
index 04b4a3d..dee4a5f 100644
--- a/src/core/Array.cpp
+++ b/src/core/Array.cpp
@@ -94,11 +94,11 @@ Variant Array::back() const {
return Variant(v);
}
-int Array::find(const Variant &what, const int from) {
+int Array::find(const Variant &what, const int from) const {
return godot::api->godot_array_find(&_godot_array, (godot_variant *)&what, from);
}
-int Array::find_last(const Variant &what) {
+int Array::find_last(const Variant &what) const {
return godot::api->godot_array_find_last(&_godot_array, (godot_variant *)&what);
}
@@ -148,7 +148,7 @@ void Array::resize(const int size) {
godot::api->godot_array_resize(&_godot_array, size);
}
-int Array::rfind(const Variant &what, const int from) {
+int Array::rfind(const Variant &what, const int from) const {
return godot::api->godot_array_rfind(&_godot_array, (godot_variant *)&what, from);
}
diff --git a/src/core/Basis.cpp b/src/core/Basis.cpp
index 368afa1..903566c 100644
--- a/src/core/Basis.cpp
+++ b/src/core/Basis.cpp
@@ -7,6 +7,11 @@
namespace godot {
+const Basis Basis::IDENTITY = Basis();
+const Basis Basis::FLIP_X = Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1);
+const Basis Basis::FLIP_Y = Basis(1, 0, 0, 0, -1, 0, 0, 0, 1);
+const Basis Basis::FLIP_Z = Basis(1, 0, 0, 0, 1, 0, 0, 0, -1);
+
Basis::Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) {
elements[0] = row0;
elements[1] = row1;
diff --git a/src/core/Quat.cpp b/src/core/Quat.cpp
index 00fa43d..dc179e2 100644
--- a/src/core/Quat.cpp
+++ b/src/core/Quat.cpp
@@ -7,6 +7,8 @@
namespace godot {
+const Quat Quat::IDENTITY = Quat();
+
// set_euler_xyz expects a vector containing the Euler angles in the format
// (ax,ay,az), where ax is the angle of rotation around x axis,
// and similar for other axes.
diff --git a/src/core/String.cpp b/src/core/String.cpp
index 552ebfe..9db8462 100644
--- a/src/core/String.cpp
+++ b/src/core/String.cpp
@@ -392,17 +392,20 @@ float String::similarity(String text) const {
return godot::api->godot_string_similarity(&_godot_string, &text._godot_string);
}
-PoolStringArray String::split(String divisor, bool allow_empty) const {
+// TODO Suport allow_empty
+PoolStringArray String::split(String divisor, bool /*allow_empty*/) const {
godot_array arr = godot::api->godot_string_split(&_godot_string, &divisor._godot_string);
return Array(arr);
}
-PoolIntArray String::split_ints(String divisor, bool allow_empty) const {
+// TODO Suport allow_empty
+PoolIntArray String::split_ints(String divisor, bool /*allow_empty*/) const {
godot_array arr = godot::api->godot_string_split_floats(&_godot_string, &divisor._godot_string);
return Array(arr);
}
-PoolRealArray String::split_floats(String divisor, bool allow_empty) const {
+// TODO Suport allow_empty
+PoolRealArray String::split_floats(String divisor, bool /*allow_empty*/) const {
// TODO The GDNative API returns godot_array, when according to the doc, it should have been godot_pool_real_array
godot_array arr = godot::api->godot_string_split_floats(&_godot_string, &divisor._godot_string);
Array wrapped_array(arr);
diff --git a/src/core/Transform.cpp b/src/core/Transform.cpp
index d32de8d..1eca983 100644
--- a/src/core/Transform.cpp
+++ b/src/core/Transform.cpp
@@ -9,6 +9,11 @@
namespace godot {
+const Transform Transform::IDENTITY = Transform();
+const Transform Transform::FLIP_X = Transform(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0);
+const Transform Transform::FLIP_Y = Transform(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0);
+const Transform Transform::FLIP_Z = Transform(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0);
+
Transform Transform::inverse_xform(const Transform &t) const {
Vector3 v = t.origin - origin;
diff --git a/src/core/Transform2D.cpp b/src/core/Transform2D.cpp
index acd6af1..6395c3d 100644
--- a/src/core/Transform2D.cpp
+++ b/src/core/Transform2D.cpp
@@ -7,6 +7,10 @@
namespace godot {
+const Transform2D Transform2D::IDENTITY;
+const Transform2D Transform2D::FLIP_X = Transform2D(-1, 0, 0, 1, 0, 0);
+const Transform2D Transform2D::FLIP_Y = Transform2D(1, 0, 0, -1, 0, 0);
+
Transform2D::Transform2D(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) {
elements[0][0] = xx;
diff --git a/src/core/Vector2.cpp b/src/core/Vector2.cpp
index 44dc001..eeeeb85 100644
--- a/src/core/Vector2.cpp
+++ b/src/core/Vector2.cpp
@@ -6,6 +6,15 @@
namespace godot {
+const Vector2 Vector2::ZERO;
+const Vector2 Vector2::ONE;
+const Vector2 Vector2::INF;
+
+const Vector2 Vector2::LEFT = Vector2(-1, 0);
+const Vector2 Vector2::RIGHT = Vector2(1, 0);
+const Vector2 Vector2::UP = Vector2(0, -1);
+const Vector2 Vector2::DOWN = Vector2(0, 1);
+
bool Vector2::operator==(const Vector2 &p_vec2) const {
return x == p_vec2.x && y == p_vec2.y;
}
diff --git a/src/core/Vector3.cpp b/src/core/Vector3.cpp
index 879de0b..f4db462 100644
--- a/src/core/Vector3.cpp
+++ b/src/core/Vector3.cpp
@@ -8,6 +8,17 @@
namespace godot {
+const Vector3 Vector3::ZERO = Vector3();
+const Vector3 Vector3::ONE = Vector3();
+const Vector3 Vector3::INF = Vector3(INFINITY, INFINITY, INFINITY);
+
+const Vector3 Vector3::LEFT = Vector3(-1, 0, 0);
+const Vector3 Vector3::RIGHT = Vector3(1, 0, 0);
+const Vector3 Vector3::UP = Vector3(0, 1, 0);
+const Vector3 Vector3::DOWN = Vector3(0, -1, 0);
+const Vector3 Vector3::FORWARD = Vector3(0, 0, -1);
+const Vector3 Vector3::BACK = Vector3(0, 0, 1);
+
bool Vector3::operator<(const Vector3 &p_v) const {
if (x == p_v.x) {
if (y == p_v.y)