Commit Graph

214 Commits (f58a2f25a2ac9f1af4964c047f30461f4ed4f40e)

Author SHA1 Message Date
Hrishikesh 8558d2360a Removed redundant function definitions in CameraMatrix and used the ones in Math.hpp 2021-02-03 06:32:44 +05:30
Marc Gilleron 4c0763cd88 Revert comment, this raised another warning, and I could not find a pattern that works 2021-01-31 22:36:01 +00:00
Marc b400dba875
Merge branch 'master' into container_leaks 2021-01-31 20:06:56 +00:00
Marc 05ba977cc6
Merge pull request #485 from colugomusic/fix-array-const
Fix constness of Array::find, Array::find_last and Array::rfind
2021-01-31 20:03:47 +00:00
Marc e76efdd3ab
Merge pull request #481 from Zylann/vec_constants
Added missing constants to Vector2, Vector3, Basis and Quat
2021-01-31 20:02:06 +00:00
Marc 18e1b262ff
Merge pull request #480 from Zylann/ref_safer_cast
Use safer casts in Ref<T>
2021-01-31 20:01:12 +00:00
Marc ffcdef965e
Merge pull request #479 from Zylann/fix_math_warnings
Fix some Math warnings
2021-01-31 19:58:10 +00:00
Marc 1aab5e3962
Merge branch 'master' into master 2021-01-31 19:32:56 +00:00
Marc Gilleron fb71edd45b Fix container and string leaks
Some functions return a new instance of such containers,
but instead we made a copy of them, without taking ownership of the
original created by the function.
Now we use a specific constructor taking ownership on the godot_* struct.
2021-01-07 01:05:12 +00:00
Colugo 38c9b624db Fix constness of Array::find, Array::find_last and Array::rfind 2020-12-20 16:53:40 +00:00
Marc Gilleron 8e1cc29c66 Added missing constants to Vector2, Vector3, Basis and Quat 2020-12-08 23:35:17 +00:00
Marc Gilleron 2893c883f8 Use safer casts in Ref<T> 2020-12-08 22:10:59 +00:00
Marc Gilleron deddacd6f7 Fix some Math warnings 2020-12-08 20:47:42 +00:00
Marc 43828ebb39
Merge pull request #459 from Silver1063/master
Added some missing Vector3 functions and Fixed Vector3 slide
2020-12-08 20:00:06 +00:00
Silver1063 96ae052e06 Added missing Vector3 slerp and Vector3 project
Vector3 slerp and Vector3 project were missing from godot cpp so I added them.
2020-10-11 17:31:23 -07:00
Silver1063 a733457285 Update Vector3 slide to match godot implementation
It wasn't the same before and resulted in weird behavior, its better now.
2020-10-11 15:47:01 -07:00
Marc Gilleron 67976ee47d Remove the need to use GODOT_SUBCLASS 2020-09-12 17:38:46 +01:00
Marc c9a740be34
Merge pull request #451 from Zylann/math
Added Godot's math functions
2020-09-08 19:31:54 +01:00
Marc Gilleron 0d1511695d Added Godot's math functions 2020-09-04 02:14:45 +01:00
Marc e5334579db
Merge branch 'master' into arcore_support 2020-08-31 15:05:09 +01:00
Marc 3f72f5a842
Merge pull request #447 from Zylann/rename_rid_get_id
Rename `RID::get_rid()` => `get_id()` to match Godot
2020-08-30 22:45:17 +01:00
Fredia Huya-Kouadio 31b0ca80d5 Additions to the library to support the ARCore plugin 2020-08-23 14:11:47 -07:00
Marc ca800d63c8
Merge pull request #371 from NHodgesVFX/VectorBounceReflectFix
Fix Vector's Bounce Reflect
2020-08-23 22:04:31 +01:00
Marc Gilleron 469e9da86c Rename `RID::get_rid()` => `get_id()` to match Godot 2020-08-23 21:32:05 +01:00
Marc 19fa40591b
Merge pull request #365 from sheepandshepherd/class_ptr
Fix `cast_to` for non-exposed engine types
2020-08-16 23:30:52 +01:00
sheepandshepherd 33f9de16e4 Use godot_object_cast_to instead of TagDB to cast engine types 2020-08-17 00:05:57 +02:00
Marc 16000199c5
Merge pull request #415 from DuncanSparks/alloca_fix
Fix alloca.h error in Defs.h
2020-08-16 20:16:36 +01:00
Marc 756c1e1c79
Merge pull request #307 from aqnuep/string_memory_leak_fix
Fixed memory leak with String objects
2020-08-15 17:57:02 +01:00
Daniel Rakos 0939d0f6d1 Fixed memory leak with String objects
The member _godot_string should never be straight out overwritten ever without
first destroying the underlying string object's memory. This change solves the
problem through the introduction of a new private constructor to create String
objects with a pre-existing godot_string handle.
2020-08-15 09:46:23 +02:00
Jummit 20fdc09c96 Add missing move_toward to Vector2 and Vector3 2020-07-15 17:05:54 +02:00
Duncan Sparks 5c96e5ede5
Fix alloca.h error in Defs.h 2020-06-17 15:24:08 -07:00
raymoo 6f8d3d2c2a Allow registering base class methods for derived classes
Adds register_class_method, a variant of register_method where the user can
specify a derived class to register the method for.
2020-06-10 22:09:05 -05:00
Bastiaan Olij 2bb3a7e19c
Merge pull request #412 from Zylann/direction_to
Add missing Vector3::direction_to() and Vector2::direction_to()
2020-06-09 17:24:04 +10:00
Marc ceae5be727
Merge pull request #356 from sheepandshepherd/variantleak2
Add C conversion constructors and fix new leak
2020-06-05 21:16:37 +01:00
Marc Gilleron 78f5496f4b Add missing Vector3::direction_to() and Vector2::direction_to() 2020-06-05 19:07:56 +01:00
Marc Gilleron 09c8bf94df Rework the way custom class instances are created from C++ 2020-06-02 19:33:56 +01:00
Bastiaan Olij 165f1f30e8
Merge pull request #383 from Zylann/fix_alloca
Fix alloca() not being included on some platforms
2020-06-02 20:53:42 +10:00
Marc Gilleron 0f4ea6cc35 Added missing Color operators 2020-05-29 20:38:14 +01:00
Marc Gilleron 9e37b873af Fix alloca() not being included on some platforms 2020-03-31 19:16:45 +01:00
Mika Pi 2559c70e27 Fix compilation warnings about unused vars 2020-02-23 07:40:54 -08:00
NHodgesVFX 82476108ba Fix Style Issues 2020-02-06 18:44:50 -05:00
NHodgesVFX a2e6f7a5ef Fix Vector's Bounce Reflect
Fixes Vector 2 and 3 bounce and reflect methods to match gdscript

Co-Authored-By: Bruno Campos <brunocu@msn.com>

Move calculation to reflect

fix commit

squash

fix style
2020-02-06 18:38:39 -05:00
sheepandshepherd 66c671b59d Add C conversion constructors to fix leak of default-constructed empty arrays 2020-01-31 00:08:02 +01:00
2shady4u 9e573b6947 Added bounce to vector2.hpp 2019-12-27 14:28:42 +01:00
Fabio Alessandrelli 91e9262210 Add godot namespace to references in Defs macros.
Was causing failed builds when used outside of the godot namespace.
2019-10-24 13:52:23 +02:00
Bastiaan Olij fc1fe720c3 Store all main entry points to the currently available APIs 2019-08-12 19:55:29 +10:00
Thomas Herzog c2ec46f64a
Merge pull request #296 from lupoDharkael/missing
Add missing class methods
2019-08-05 10:39:56 +02:00
lupoDharkael b895d3c326 Add missing class methods 2019-08-05 00:23:42 +02:00
Daniel Rakos bb4a837ad3 Error message improvements
Changed error message macros to actually use Godot's error reporting
facilities instead of outputting straight to stderr. This enables
GDNative errors to actually show up inside the editor.

Messages and set of available macros now also better matches that of
the engine itself.
2019-05-15 14:45:09 +02:00
Bastiaan Olij 12732b5391
Merge pull request #270 from Windfisch/add-variant-cast
Add a type conversion to Variant for anything that supports ___get_from_variant()
2019-05-02 23:03:06 +10:00
Bastiaan Olij 7defa6f77e
Merge pull request #271 from Windfisch/fix-register-property
Fix registering properties of reference-types by applying bruvzg's patch
2019-05-02 23:00:47 +10:00
RameshRavone ca85ab244f
Fix snapped from Vector2 2019-05-02 09:57:28 +05:30
RameshRavone 761d62c9c8
Fix #272 2019-04-21 06:55:49 +05:30
Bastiaan Olij 971adbd955
Merge pull request #266 from RameshRavone/pathch-1
fix shadows template parameter
2019-04-14 21:25:38 +10:00
Florian Jung 0b4be7bbfa Fix registering properties of reference-types by applying bruvzg's patch
bruvzg's original comment with the patch is here:
https://github.com/GodotNativeTools/godot-cpp/issues/237#issuecomment-465170294

Fixes #237.
2019-04-12 13:56:22 +02:00
Florian Jung c5199a2fbf Add a type conversion to Variant for anything that supports ___get_from_variant() 2019-04-12 13:55:56 +02:00
RameshRavone eb7a75b71e
fix shadows template parameter 2019-04-12 14:52:37 +05:30
Daniel Rakos 4be7fcdde5 Fix bug in Basis [] operator and add missing Transform-Vector3 * operator
The [] operator of Basis was returning a reference to a temporary, so fixed it.
There was no * operator in Transform equivalent to the xform function, which is
not in line with GDScript behavior.

Also fixed remaining cases where Transform relied on the old behavior of the
[] operator of Basis (i.e. that it returns the row, not the column).
2019-04-11 19:59:34 +02:00
Daniel Rakos abccf9a050 Make Basis look column-major while retaining a row-major representation
Per https://github.com/godotengine/godot/issues/14553:
Godot stores Basis in row-major layout for more change for efficiently
taking advantage of SIMD instructions, but in scripts Basis looks like and
is accessible in a column-major format.

This change modifies the C++ binding so that from the script's perspective
Basis does look like if it was column-major while retaining a row-major
in-memory representation. This is achieved using a set of helper template
classes which allow accessing individual columns whose components are
non-continues in memory as if it was a Vector3 type. This ensures script
interface compatibility without needing to transpose the Basis every time
it is passed over the script-engine boundary.

Also made most of the Vector2 and Vector3 class interfaces inlined in the
process for increased performance.

While unrelated (but didn't want to file a separate PR for it), this change
adds the necessary flags to have debug symbol information under MSVC.

Fixes #241.
2019-04-08 16:28:41 +02:00
bruvzg aad175aa09
Renamed Rect2::pos to Rect2::position 2018-12-13 11:10:25 +02:00
bruvzg 0af05a45ce
Fix tags/cast_to for custom subclasses. 2018-11-28 00:08:45 +02:00
Marcelo Fernandez 209dd56cb0 Profiling support 2018-11-27 09:45:56 -03:00
bruvzg be5a012ff7
Fix NULL dereferencing in get_from_variant and cast_to 2018-11-26 08:11:31 +02:00
Bastiaan Olij fc20fa3fce Implementing clang-format and applying it to all classes 2018-11-24 09:09:41 +11:00
Bastiaan Olij d7982cfac3 Redid PR 190 for master now that nativescript 1.1 has been merged 2018-11-22 22:14:28 +11:00
bruvzg 39445f144c
Add missing String::(r)find(n) form argument
Add missing String::(*)casecmp_to functions
2018-11-18 14:37:06 +02:00
karroffel 200bf226bf Nativescript 1.1
implemented instance binding data usage

This commit changes the way C++ wrapper classes work.
Previously, wrapper classes were merely wrapper *interfaces*.
They used the `this` pointer to store the actual foreign Godot
Object.

With the NativeScript 1.1 extension it is now possible to have
low-overhead language binding data attached to Objects.

The C++ bindings use that feature to implement *proper* wrappers
and enable regular C++ inheritance usage that way.

Some things might still be buggy and untested, but the C++
SimpleDemo works with those changes.

new and free change, custom free will crash engine, be wary

fix exporting of non-object types

fix free() crash with custom resources

added type tags and safe object casting

fix global type registration order

fix cast_to

changed build system to be more self contained

updated .gitignore

use typeid() for type tags now

fix indentation in bindings generator

remove accidentally added files

fix gitignore

Fixed up registering tool and updated godot_headers

Fix crash when calling String::split/split_floats

Was casting to the wrong object type.
Also adds parse_ints function to String with the same logic

Better warning/error macros

Change gitignore so we get our gen folders

New documentation based on nativescript 1.1

Fixed GODOT_SUBCLASS macro

Preventing crash when function returned null ptr

Adds needed include <typeinfo>

 Solves this issue #168 due to not having the include of typeinfo

Fix compile error of 'WARN_PRINT' and 'ERR_PRINT'.

cannot pass non-trivial object of type 'godot::String' to variadic function; expected type from format string was 'char *' [-Wnon-pod-varargs]

update vector3::distance_to

Remove godot_api.json as its now in the godot_headers submodule (api.json)
2018-11-07 21:23:08 +11:00
Marcelo Fernandez baddc2ae66 Fix clang warning: 'const' type qualifier on return type has no effect 2018-06-23 12:15:53 -03:00
Timothy Werquin 1a32997a0f Fix const for += operator in string 2018-05-15 22:24:53 +02:00
Timothy Werquin 1803ca43fa Fix String const operators.
Added const to various operators.
2018-05-15 22:23:03 +02:00
Nickolai Korshunov ef37d8d76e Merge branch 'master' of https://github.com/GodotNativeTools/godot-cpp 2018-04-25 11:40:49 +03:00
Gary Oberbrunner a6689b2132 Make all Pool*Array::operator[] as const
This is needed since that operator returns a local copy, not
an lvalue. Attempting to write to the return value of these operators
wouldn't change the array element. PoolVectors need locking when
writing, so this operator can't return a writable reference.

To update a Pool*Array, use the `set()` method which locks and unlocks
the array. For multiple writes, use the `write()` method which returns
a locked writable view, and unlocks when it goes out of scope.
2018-03-13 11:00:25 -04:00
danielytics e74b8f593e adds variadic printing function, makes String.format custom placeholder work 2018-03-07 12:21:33 +00:00
danielytics 01db553c49 adds Array::make and Dictionary::make static methods and has variadic template functions use those 2018-03-07 10:27:34 +00:00
danielytics c7b03c4132 make register_signal and auto-generated variadic funcitons use variadic templates to streamline their use 2018-03-06 21:36:20 +00:00
karroffel 2343a8a54c fix #101 2018-03-02 19:04:57 +01:00
Nickolai Korshunov a049a34f28 fixed forward decl 2018-02-24 11:13:22 +03:00
Nickolai Korshunov f1c35f24f6 NULL -> nullptr 2018-02-23 16:08:36 +03:00
Nickolai Korshunov e123650d76 Strict enums 2018-02-23 15:50:41 +03:00
Nickolai Korshunov 73a67b16b1 fixed some includes. replace cycle include with forward declaration 2018-02-23 14:56:36 +03:00
Nickolai Korshunov 7adae4673c fixed forward declarations 2018-02-23 14:39:35 +03:00
lupoDharkael 756510563b Add const qualifier to PoolArray's size() 2018-02-12 22:38:25 +01:00
Thomas Herzog d7d814f861
Merge pull request #88 from Zylann/fix_ref_return_leak
Fix Ref leak when using Godot getters
2018-01-26 10:36:58 +01:00
Marc Gilleron ac0679eb1a Fix Ref leak when using Godot getters 2018-01-25 20:55:56 +01:00
Marc Gilleron 8a89a447b2 Fix RID::is_valid() 2018-01-25 01:10:55 +01:00
Marc Gilleron 4f4bb8deff String and math fixes
- Added missing static String constructors
- Implemented String operator for math types
- Added XYZ and YXZ euler angles methods
- Fixed wrong det checks in Basis
- Fixed operator Quat in Basis
2018-01-23 00:24:23 +01:00
Marc Gilleron 3197c3dce3 Rewrite Ref<T> to behave like Godot again 2018-01-22 22:27:10 +01:00
Marc Gilleron 06c61b6535 Added RID::is_valid() and comparison operators
- is_valid() is worked around by comparing a default RID()
2018-01-20 19:37:23 +01:00
karroffel 8c053fc35f allow const getter functions 2018-01-19 11:49:28 +01:00
karroffel 2e4de7b67d Don't leak memory from Ref<>() 2018-01-19 11:40:50 +01:00
Marc Gilleron 07a36732f1 Added copy constructors to PoolArray Read and Write 2018-01-18 22:49:13 +01:00
Marc Gilleron 835233fb71 Added missing copy constructors and assign operators to PoolVectors 2018-01-17 23:58:28 +01:00
Thomas Herzog 02b9b2592a
Merge pull request #67 from Zylann/rename_aabb_position
Renamed AABB::pos --> AABB::position
2018-01-17 08:46:19 +01:00
Thomas Herzog 4eea068b1b
Merge pull request #68 from Zylann/ref_instance
Added Ref<T>::instance()
2018-01-17 08:44:24 +01:00
Thomas Herzog dc2896dc89
Merge pull request #70 from Zylann/fix_register_signal
Fix potential malloc(0)
2018-01-17 08:43:14 +01:00
Marc Gilleron e7202cef8b Fix potential malloc(0) 2018-01-17 02:00:55 +01:00
Marc Gilleron 00f089d7ed Added copy constructors and assignment operators to Array and Dictionary 2018-01-17 01:57:01 +01:00
Marc Gilleron 74e3b4ae23 Added Ref<T>::instance() 2018-01-17 01:54:02 +01:00
Marc Gilleron b9ba10a717 Renamed AABB::pos --> AABB::position 2018-01-17 01:45:48 +01:00
karroffel 7dde412e26 custom types can now be used as method parameters 2018-01-14 23:03:57 +01:00