Commit graph

209 commits

Author SHA1 Message Date
Rémi Verschelde 46beaacec3
Merge pull request #51017 from vnen/extension-fixes 2021-08-10 16:42:31 +02:00
Rémi Verschelde 16d73fefdb
Merge pull request #50682 from aaronfranke/basis-looking-at
Move code for looking_at to Basis
2021-08-10 11:28:12 +02:00
bruvzg 7c3c5603d0 [Text Server] Improve object (image/table) inline alignment. 2021-08-08 22:35:47 +03:00
George Marques 3f362cec68
Improve extension system
- Fix library loading and initialization.
- Add extra methods/parameters in the interface needed by extenstions.
- Add Variant destructors and functions for extracting values and
  creating Variants from values.
2021-08-05 14:57:31 -03:00
George Marques 97947bc063
Fix a few default parameters in bindings
They have the wrong type and cause issues with extensions.
2021-08-05 14:57:29 -03:00
Aaron Franke 9f3ae0adcd
Move code for looking_at to Basis 2021-08-01 12:49:02 -05:00
Rémi Verschelde d7b61838b1
Merge pull request #51084 from aaronfranke/no-dectime
Remove obsolete `dectime` method
2021-07-31 10:20:29 +02:00
Aaron Franke 2733b9abd8
Remove obsolete "dectime" method
Replaced by "move_toward"
2021-07-30 16:41:28 -05:00
Rémi Verschelde f3aaa713d9
VariantParser: Fix uninitialized ResourceParser funcs
They could cause a segfault when parsing values with ID "Resource"
as apparently we never set a valid `func` for it.

Fixes crash part of #42115.
2021-07-30 23:23:31 +02:00
Fabio Alessandrelli 324636473a [Net] Fix Marshalls infinite recursion crash.
Variants like dictionaries and arrays can have cyclic references, which
caused `encode_variant` to run an infinite recursion.
Instead of keeping a stack and looking for cyclic references which would
make serialization slower, this commit adds a `MAX_RECURSION_DEPTH`
constant to Variant, and have `encode_variant` keep track of the current
recursion depth, bailing when it's too high since this likely means a
cyclic reference has been encountered.
2021-07-30 16:13:43 +02:00
Rémi Verschelde b4778082d1
Merge pull request #50939 from vnen/fix-variant-bool-conversion
Change Variant bool conversion to uint8_t
2021-07-27 15:04:20 +02:00
George Marques 84c37423fb
Change Variant bool conversion to uint8_t
This ensures more portable conversion since not every path assume bool
is 32-bits and there's no loss converting to 8-bits anyway.
2021-07-27 09:00:56 -03:00
Fabio Alessandrelli 95088f6bfa [Core] Make enum variant cast and encoding 64 bits
This should fix various issues where retrieving enum values from
scripting languages would result in corrupted values (where 32 bits
were valid, and the other 32 random data).
2021-07-27 12:29:03 +02:00
Rémi Verschelde ff0b5f8fa1
Merge pull request #50809 from akien-mga/iterators-const-references 2021-07-25 12:52:58 +02:00
Rémi Verschelde ac3322b0af
Use const references where possible for List range iterators 2021-07-25 12:22:25 +02:00
luz paz 3564c16cb8
Fix various typos with codespell
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-25 11:21:51 +02:00
Rémi Verschelde fb821b8398
Merge pull request #50535 from ChristopheClaustre/packedbytearray_decode_api
Change in PackedByteArray decode api and docs
2021-07-24 21:54:48 +02:00
ChristopheClaustre 20818c12b7 New to_***_array method to decode PackedByteArray to Packed***Array
Documentation for new PackedByteArray::to_***_array methods
Documentation for to_byte_array method for PackedInt32/Int64/Float32/Float64Array
2021-07-24 21:06:47 +02:00
Aaron Franke 4e6efd1b07
Use C++ iterators for Lists in many situations 2021-07-23 17:38:28 -04:00
Hugo Locurcio 4bd5e4fd9b
Use the standard C INFINITY and NAN constants directly
The `Math_INF` and `Math_NAN` defines were just aliases for those
constants, so we might as well use them directly.

Some portions of the code were already using `INFINITY` directly.
2021-07-21 10:41:08 +02:00
Rémi Verschelde b4baec08cf
Merge pull request #50206 from groud/undoredo_increase_args_count
Increase the number of arguments accepted by UndoRedo methods
2021-07-20 09:50:01 +02:00
George Marques 7bc52e56c0
Merge pull request #50056 from Blackiris/fix-in-operator
Fix 'in' operator to check if an object member exists
2021-07-13 14:25:42 -03:00
Gilles Roudière 2f9a0268dd Increase the number of arguments accepted by UndoRedo methods 2021-07-06 18:52:28 +02:00
bruvzg eca4d2fccc Fix Variant tags parsing. 2021-07-05 15:46:41 +03:00
reduz 379b90fd33 Force String as Dictionary key instead of StringName
* Lua table syntax uses named indexing: `{ mykey = myvalue }`
* Python style syntax uses string indexing: `{ "mykey" : myvalue }`
* Both are incompatible since a StringName key wont fetch a String key, hence confusing.
* This PR proposes always using String for indexing at a very minimal performance cost. Always indexing with StringNames will be faster, but they are considerably more expensive to create.
2021-07-01 16:03:37 -03:00
Julien Nguyen 0a823e85d2 Fix 'in' operator to check if an object member exists 2021-07-01 20:59:26 +02:00
Lyuma 8f1efa656b Add Callable.is_valid() analogous to FuncRef.is_valid() from 3.x 2021-07-01 02:54:01 -07:00
reduz b1d15c51bc Implement native extension system
* Deprecates GDNative in favor of a simpler, lower level interface.
* New extension system allows registering core engine classes.
* Simple header interface in gdnative_interace.h
2021-06-25 17:32:45 -03:00
Aaron Franke e919d894f8
Move many input enums to their own file 2021-06-20 11:53:01 -04:00
Lightning_A e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Rémi Verschelde d88be9b70c
Merge pull request #44806 from madmiraal/consolidate_json
Consolidate JSON, JSONParseResults and JSONParser into JSON
2021-06-19 21:45:34 +02:00
Marcel Admiraal 2bafcd3422 Consolidate JSON, JSONParseResults and JSONParser into JSON
Renames JSON.parse_string() to parse()
Renames JSON.decode_data() to stringify()
2021-06-19 08:01:40 +01:00
Rémi Verschelde a9c53fa599
Merge pull request #49287 from reduz/expose-variant-internal-binders
Make some Variant internal functions public.
2021-06-19 01:11:03 +02:00
Rémi Verschelde 92f20fd70e
Merge pull request #49659 from LightningAA/string-valid-integer-to-int 2021-06-18 16:14:14 +02:00
Rémi Verschelde 7aebb8f81c
Merge pull request #44156 from aaronfranke/quat-angle-to
Add Quaternion angle_to method
2021-06-18 12:35:58 +02:00
Rémi Verschelde 3fc39954ec
Merge pull request #49638 from aaronfranke/multiply-transforms
Allow multiplying Transforms and Basis by numbers
2021-06-18 12:35:14 +02:00
Aaron Franke 93b494d4ae
Add Quaternion angle_to method 2021-06-17 23:57:00 -04:00
Michael Alexsander Silva Dias 0ff4095b36 Better format arguments in variant parser 2021-06-18 00:06:40 -03:00
reduz 2c81e5fa0e Make some variant internal functions public.
-Make constructors, ops and setget inline functions public
-Should help optimizing the GDScript VM
2021-06-17 19:59:28 -03:00
Lightning_A b6af2a29eb Rename is_valid_integer() to is_valid_int()
Method from `String`
2021-06-16 10:32:22 -06:00
Aaron Franke bd6ed3fb09
Allow multiplying Transforms and Basis by numbers 2021-06-15 22:26:29 -04:00
Haoyu Qiu b3bd54001f Fix json dump and print of circular structure 2021-06-14 20:48:49 +08:00
Rémi Verschelde 600b4c9c7b
Merge pull request #34668 from aaronfranke/to-string
[Core] Reformat structure string operators
2021-06-13 11:58:24 +02:00
Rémi Verschelde 326e483ef3
VariantParser: Fix reading StringNames with '&'.
Keep support for '@' for now for compatibility.

Fixes #49535.
Fixes #49542.
2021-06-12 22:13:35 +02:00
Pedro J. Estébanez 04688b92ff Rename Reference to RefCounted 2021-06-11 18:48:42 +02:00
Aaron Franke 554c776e08
Reformat structure string operators
The order of numbers is not changed except for Transform2D. All logic is done inside of their structures (and not in Variant).

For the number of decimals printed, they now use String::num_real which works best with real_t, except for Color which is fixed at 4 decimals (this is a reliable number of float digits when converting from 16-bpc so it seems like a good choice)
2021-06-11 10:53:20 -04:00
Rémi Verschelde 8d4046929c
Merge pull request #49511 from akien-mga/core-diraccess-fileaccess-io
Core: Move DirAccess and FileAccess to `core/io`
2021-06-11 16:51:10 +02:00
Rémi Verschelde 6b0183ec89
Merge pull request #49279 from Calinou/rename-string-is-abs-path-method
Rename `String.is_abs_path()` to `String.is_absolute_path()`
2021-06-11 15:58:16 +02:00
Rémi Verschelde 9e328bb5b7
Core: Move DirAccess and FileAccess to core/io
File handling APIs are typically considered part of I/O, and we did have most
`FileAccess` implementations in `core/io` already.
2021-06-11 14:52:39 +02:00
Jonathan Gollnick 6710ad1737
Let var2str display StringName with correct sigil 2021-06-10 16:30:28 -05:00
TwistedTwigleg 8aa3c2f091 New and improved IK system for Skeleton2D
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.

This work was sponsored by GSoC 2020 and TwistedTwigleg.

Full list of changes:
* Adds a SkeletonModifier2D resource
  * This resource is the base where all IK code is written and executed
  * Has a function for clamping angles, since it is so commonly used
  * Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
  * This resource manages a series of SkeletonModification2Ds
  * This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
  * Each modification is in its own file
  * There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
  * Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
  * Skeleton2D now holds a single SkeletonModificationStack2D for IK
  * Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
  * The default_length property has been changed to length. Length is the length of the bone to its child bone node
  * New bone_angle property, which is the angle the bone has to its first child bone node
  * Bone2D caches its transform when not modified by IK for IK interpolation purposes
  * Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
  * Bone2D gizmo drawing code removed
  * The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
  * These notifications only are called in the editor right before and after saving a scene
  * Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
2021-06-05 15:19:51 -04:00
Marcel Admiraal 8acd13a456 Rename Quat to Quaternion 2021-06-04 18:14:32 +01:00
Aaron Franke 028d9fa2bd
Add "Transform" compatibility name for "Transform3D" in VariantParser 2021-06-04 08:07:08 -04:00
Rémi Verschelde 5d9cab3aeb
Merge pull request #38430 from aaronfranke/transform3d 2021-06-03 23:07:21 +02:00
Aaron Franke 2e13e3ed4a
Allow clamping vectors and colors 2021-06-03 12:05:20 -04:00
Aaron Franke 94bc0bd919
Rename Vector2 clamped to limit_length and add limit_length to Vector3 2021-06-03 12:04:57 -04:00
Hugo Locurcio 5ea1c75d63
Rename String.is_abs_path() to String.is_absolute_path()
This is more consistent with `NodePath.is_absolute()`.
2021-06-03 16:00:06 +02:00
Aaron Franke a3c29ed899
Rename files and the exposed name for Transform3D 2021-06-03 07:30:01 -04:00
Aaron Franke 08a85352fb
Rename Variant TRANSFORM to TRANSFORM3D
Also _transform to _transform3d
2021-06-03 07:30:01 -04:00
Aaron Franke de3f6699a5
Rename Transform to Transform3D in core 2021-06-03 07:30:01 -04:00
Paweł Fertyk ee8c9bb614 Return error when decompressing empty PoolByteArray 2021-05-25 18:43:26 +02:00
Rémi Verschelde 215e43242c
Merge pull request #49037 from vnen/fix-callable-freed-crash 2021-05-24 19:52:32 +02:00
George Marques ea44744e2d
Make Callable not crash on call when the object has been freed
Also add a GDScript test for this case.
2021-05-24 14:23:02 -03:00
Marcel Admiraal afdc5edb2a Remove alloca from loop and use a single fixed size array declaration 2021-05-21 13:04:55 +01:00
JohnM666 b19544e91d Fix #46282 Executing RigidBody3D.get_inverse_inertia_tensor() crashes Godot 2021-05-20 10:46:24 +03:00
Rémi Verschelde ed11756d26
GDNative: Fix size mismatch on 32-bit platforms for Signal and Callable
Fixes #48645.
2021-05-11 20:25:01 +02:00
Rémi Verschelde 01f80201bf
Merge pull request #38645 from KoBeWi/FMR
Add filter, map and reduce to Array
2021-05-06 20:44:01 +02:00
Hugo Locurcio 3f078c99f6
Rename IP_Unix, IP_Address and TCP_Server to remove underscores 2021-05-06 02:52:01 +02:00
Tomasz Chabora c50acc7339 Add filter, map and reduce to Array 2021-05-05 15:54:57 +02:00
Rémi Verschelde c9e874b62d
Merge pull request #48442 from akien-mga/posmod-int64_t
Re-bind posmod, use int64_t instead of int
2021-05-04 15:15:52 +02:00
Rémi Verschelde e196733e88
Re-bind posmod, use int64_t instead of int
Fixes #48420, fixes #48421.
The binding was missed when moving GDScript built-in to Global Scope it seems.

Co-authored-by: kleonc <9283098+kleonc@users.noreply.github.com>
2021-05-04 13:25:08 +02:00
reduz c76acf6890 Add RPC to Callable
-Up to each scripting language to implement this
-If not supported for the function, it will just error when you try to call
2021-05-03 19:21:37 -03:00
Rémi Verschelde f9b9992c25
Merge pull request #35245 from qarmin/unsigned_bit_shift
Don't allow to use in bit shift negative operands
2021-05-03 15:48:49 +02:00
Rémi Verschelde 9e9ac9f6ad
Merge pull request #46476 from DarknessCatt/master
Add fill method to Arrays and PackedArrays
2021-04-28 16:52:31 +02:00
Rémi Verschelde 305b2a15bf
Merge pull request #48239 from akien-mga/goodbye-copymem
Core: Drop custom `copymem`/`zeromem` defines
2021-04-28 11:04:05 +02:00
Florian Kothmeier 054d8852b9
Add error_string function 2021-04-27 22:02:35 +02:00
Florian Kothmeier a2c419bdc9
Raise error if Resource is of wrong type as function argument 2021-04-27 21:24:08 +02:00
Rémi Verschelde 8247667a3e
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.
2021-04-27 16:26:27 +02:00
Matheus Lima Cunha efd27a63c1 Add fill method to Arrays and PackedArrays 2021-04-21 11:33:53 -03:00
George Marques a6c5938909
Remove return value type adjust of builtin method calls
Make calls faster with the caveat that the caller needs to make sure
that the return value type is already correct.
2021-04-16 12:04:34 -03:00
Julien Nguyen 026b8497d1 Fix PackedFloat32Array get index not working 2021-04-12 23:33:06 +02:00
reduz e67c63108b Add marshalling to PackedByteArray
-Decode/Encode functions for u8,s8,u16,s16,u32,s32,u64,s64,half,float,double,variant
-Improved binder template to allow this

Given in Godot 4.0 PackedByteArray is passed as reference, it is now possible to have these functions there, which makes the most sense.
2021-04-10 13:09:22 -03:00
Rémi Verschelde d83761ba80
Style: Apply clang-tidy's readability-braces-around-statements 2021-04-05 14:09:59 +02:00
Rémi Verschelde 4b6e9f3157
Merge pull request #46991 from madmiraal/rename-invert-reverse
Rename Array.invert() to Array.reverse()
2021-04-01 13:32:22 +02:00
Rémi Verschelde aba03110ba
Merge pull request #46830 from vnen/gdscript-typed-arrays
GDScript typed arrays
2021-03-29 16:47:38 +02:00
mashumafi c2d1c1c3ee Array::insert consistent with Pool*Array::insert 2021-03-27 17:27:19 -04:00
Marcel Admiraal 755c70b871 Rename Array.invert() to Array.reverse()
Does the same internally for List and Vector<>, which includes all
PackedArray types.
2021-03-21 10:20:08 +00:00
Aaron Franke affe3c817a
Use real_t in GridMap and VariantParser 2021-03-19 00:56:34 -04:00
George Marques 997a8ae9e8
Make Variant setget use set() method of Array
This ensure that typed arrays are properly checked when setting an
element.

Moved the macro to a straight declaration since the macro was only used
for Array and it now is quite specific to the Array class.
2021-03-18 10:18:59 -03:00
George Marques fbfdd5e110
Add functions to retrieve type of a typed Array 2021-03-18 10:18:58 -03:00
George Marques 497dab94be
Don't check type when assigning Array
The array should just assimilate the type of the other one since
assignment in this case means a change in the reference.

This also adds a `typed_assign` function for the cases where type
validation is wanted.
2021-03-18 10:18:58 -03:00
Rémi Verschelde 224f5cab99
Merge pull request #46378 from reduz/static-method-in-variant-types
Add static method support to core Variant types
2021-03-16 15:44:04 +01:00
reduz ecfa570ccb Add static method support to core Variant types
* Properly exposed, including validated and variant call
* Bound static functions in String and Color
* Did not add support for scripting languages, will have to be added manually.
2021-03-16 10:53:05 -03:00
Anshul7sp1 91181c2086 Fixes small typos and grammar correction 2021-03-12 19:05:16 +05:30
Rémi Verschelde 83b1acdc60
Merge pull request #45545 from abaire/relaxes_gltf_name_sanitization
Relaxes node name sanitization in gltf documents.
2021-03-09 14:54:33 +01:00
Alex Hirsch 6985967c3b Add missing ERR_FAIL_INDEX check to Variant::construct
Other functions in the same file validate parameters using the ERR_FAIL
macros. This validation was missing for Variant::construct resulting in
a crash when called with invalid data (p_type < 0).

fix #46067
2021-03-04 18:50:37 +01:00
Rafał Mikrut 2cbdcb03a1 Don't allow to use in bit shift negative operands 2021-03-04 16:25:40 +01:00
abaire 61cc1c8624 Relaxes Node naming constraints in glTF documents to match the Editor. 2021-02-24 08:22:27 -08:00
George Marques f1088e1b70
Bind ClockDirection enum
It's the only enum in math_defs.h not bound, and it's used by Plane.
2021-02-23 13:56:28 -03:00
Aaron Franke 7d9ad2b845
Use Vector3.UP as a default value for look_at's up vector 2021-02-16 18:33:23 -05:00