Commit graph

351 commits

Author SHA1 Message Date
kobewi
7006f7d693 Add some missing Vector4 methods 2022-07-26 02:35:42 +02:00
Rémi Verschelde
3084a48ace
Merge pull request #63219 from reduz/implement-vector4-projection 2022-07-25 11:13:27 +02:00
Jcrespo
1a3d57f319 Solve discrepancy between code and class reference for Plane
On #43310, class reference was automatically updated from source,
causing xml documentation to disagree with parameter naming
description on Plane.intersects_segment().

Weirdly, it also changed the parameter for Plane.is_point_over()
from point to plane, when only the first has sense (and it is
defined on math.Plane as "const Vector3 &p_point"). Manual
mistake?

* Update begin/end to from/to on Plane.intersects_segment(...)
  docs description to match source
* Update Plane bindings to use points instread of plane for
  is_point_over(...)
* Change Plane.is_point_over(plane) to Plane.is_point_over(point)
  AND its description on docs

Fixes godotengine/godot-docs#5976
2022-07-24 18:21:25 +02:00
reduz
455c06ecd4 Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.

* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.

These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.

**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-23 14:00:01 +02:00
Yuri Rubinsky
ccc56cc6d4 Rename epsilon to tolerance in the Plane::has_point method 2022-07-21 20:15:15 +03:00
cdemirer
dae5edf41c Fix the argcount when generating error message for CallableComparator 2022-07-18 00:57:20 +03:00
bruvzg
cbe3a2dcb7
Use BitField hint for the TextServer enums. Add missing parts for BitField support to the GDextension API. 2022-07-15 08:49:50 +03:00
reduz
5ac42cf576 Implement a BitField hint
Allows to specify the binder that an enum must be treated as a bitfield.
2022-07-05 22:13:37 +02:00
Rémi Verschelde
a2459c7d35
Merge pull request #61610 from TokageItLab/importer-retarget-registered-gdhumanoid 2022-07-02 00:17:21 +02:00
Rémi Verschelde
88192269a8
Merge pull request #62477 from lyuma/packedbytearray
Prevent out-of-bounds write in array conversion; avoid logspam on empty arrays.
2022-07-01 09:03:20 +02:00
Lyuma
33fd7c63e1 Prevent out-of-bounds write in array conversion; avoid logspam on empty arrays. 2022-06-30 18:04:33 -07:00
Silc Renew
dc43cfc830 implement bone renamer in importer 2022-07-01 03:55:28 +09:00
Voylin
c6291bcd8a Adding print_rich for printing with BBCode 2022-06-29 00:41:29 +09:00
Rémi Verschelde
622b656c40
Merge pull request #53135 from briansemrau/fix-ref-leak 2022-06-28 17:26:44 +02:00
Rémi Verschelde
b863c40356
Merge pull request #62468 from V-Sekai/core-const-expressions
Add a const call mode to Object, Variant and Script.
2022-06-28 01:08:24 +02:00
Rémi Verschelde
8fd0b4d1f8
Merge pull request #62449 from Chaosus/wrap_func
Add generalized version of `wrap` function
2022-06-27 23:28:37 +02:00
Rémi Verschelde
c4a426d6ec
Merge pull request #62462 from vnen/gdscript-setter-chaining
GDScript: Fix setter being called in chains for shared types
2022-06-27 23:25:53 +02:00
K. S. Ernest (iFire) Lee
9ddebc0c22 Add a const call mode to Object, Variant and Script.
For this to work safely (user not call queue_free or something in the expression), a const call mode was added to Object and Variant (and optionally Script).

This mode ensures only const functions can be called, making it safe to use from the editor.

Co-Authored-By: reduz <reduzio@gmail.com>
2022-06-27 13:33:06 -07:00
Hendrik Brucker
99ce0df3b1 Refactor bezier interpolation functions 2022-06-27 19:42:43 +02:00
George Marques
511a4b761c
GDScript: Fix setter being called in chains for shared types
When a type is shared (i.e. passed by reference) it doesn't need to be
called in a setter chain (e.g. `a.b.c = 0`) since it will be updated in
place.

This commit adds an instruction that jumps when the value is shared so
it can be used to skip those cases and avoid redundant calls of setters.
It also solves issues when assigning to sub-properties of read-only
properties.
2022-06-27 12:09:51 -03:00
Yuri Rubinsky
2476c50a66 Add generalized version of wrap function 2022-06-27 16:11:21 +03:00
Pierre-Thomas Meisels
c28936ba6d Add core types enums description to extension api json 2022-06-23 19:19:22 +02:00
reduz
141c375581 Clean up Hash Functions
Clean up and do fixes to hash functions and newly introduced murmur3 hashes in #61934
* Clean up usage of murmur3
* Fixed usages of binary murmur3 on floats (this is invalid)
* Changed DJB2 to use xor (which seems to be better)
2022-06-20 12:54:19 +02:00
bruvzg
860e24683f
Make enum/constant binds 64-bit. 2022-06-17 16:36:26 +03:00
Pedro J. Estébanez
fb86430770 Validate every source element separately Array::append_array() 2022-06-15 20:36:20 +02:00
Rémi Verschelde
632b933a03
Merge pull request #61934 from Geometror/hashfuncs
Hash function improvements
2022-06-15 07:34:43 +02:00
Hendrik Brucker
8c61470fa9 Hash function improvements 2022-06-15 00:32:10 +02:00
Haoyu Qiu
6f38c21253 Fix parameter name for String.left and String.right 2022-06-12 16:34:44 +08:00
Rémi Verschelde
d52a79ad22
Merge pull request #59786 from V-Sekai/ok_color
Allow picking similar colours using OKHSL.
2022-06-07 20:52:32 +02:00
Rémi Verschelde
3f8d86b076
Merge pull request #50349 from Calinou/array-add-some-every
Add `any()` and `all()` methods to Array
2022-06-07 15:15:22 +02:00
K. S. Ernest (iFire) Lee
1b776a6e7a Allow picking similar colours using OKHSL. 2022-06-07 05:53:27 -07:00
Rémi Verschelde
83421cd06f
Merge pull request #59883 from KoBeWi/merge_this 2022-06-06 23:38:29 +02:00
bruvzg
b3bbf3db47
[GDExtension] Expose Variant, NodePath and StringName hash functions. 2022-06-06 12:19:56 +03:00
George Marques
887e292210
Add StringName explicitly to Variant::hash_compare
This makes equality comparisons to StringName more performant
2022-06-03 11:51:46 +02:00
kobewi
a0915e6dee Add Dictionary.merge() 2022-05-31 21:05:56 +02:00
Hugo Locurcio
a98e31aa3a
Add any() and all() methods to Array
These can be used as faster, more convenient shorthands to
using `filter()` + `size()`.
2022-05-25 16:09:10 +02:00
George Marques
023b1d7f5a
Implement read-only arrays
Arrays can be set as read-only and thus cannot be modified. Assigning
the array will create an editable copy.

Similar to is already done to read-only dictionaries.
2022-05-17 14:14:42 -03:00
reduz
e6c443a353 Implement read-only dictionaries.
* Add ability to set them read only.
* If read-only, it can't be modified.

This is added in order to optionally make const dictionaries (and eventually arrays) properly read-only in GDScript.
2022-05-16 23:31:46 +02:00
reduz
746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
reduz
8b7c7f5a75 Add a new HashMap implementation
Adds a new, cleaned up, HashMap implementation.

* Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing).
* Keeps elements in a double linked list for simpler, ordered, iteration.
* Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much
  for performance vs keeping the key, but helps replace old code).
* Uses a more modern C++ iterator API, deprecates the old one.
* Supports custom allocator (in case there is a wish to use a paged one).

This class aims to unify all the associative template usage and replace it by this one:
* Map<> (whereas key order does not matter, which is 99% of cases)
* HashMap<>
* OrderedHashMap<>
* OAHashMap<>
2022-05-12 11:21:29 +02:00
Rémi Verschelde
d68c355145
Merge pull request #58873 from Chaosus/power_op
Implement exponential operator (**) to GDScript/Expressions
2022-05-11 16:58:33 +02:00
Rémi Verschelde
b5689309f6
Merge pull request #56167 from cdemirer/constructor-toarray-fix 2022-05-11 15:47:06 +02:00
Yuri Roubinsky
dbd7a31507 Implement exponential operator (**) to GDScript/Expressions 2022-05-11 16:30:37 +03:00
Haoyu Qiu
380a53f02f Add search methods for packed arrays
* count()
* find()
* rfind()
2022-05-07 20:16:11 +08:00
Rémi Verschelde
f4ece7e736
Merge pull request #60609 from nathanfranke/string-quotes 2022-05-06 08:59:08 +02:00
Rémi Verschelde
e7a58a7eb6 Core: Rename math 'phi' arguments to 'angle' 2022-05-05 14:17:39 +02:00
Rémi Verschelde
192499c743
Merge pull request #48989 from MarioLiebisch/variant-comment-line-breaks
Properly increase line counter when parsing comments
2022-05-05 13:41:08 +02:00
Nathan Franke
58fcad20ef
quote strings inside arrays and dictionaries 2022-05-03 13:37:13 -05:00
Aaron Franke
fa7a7795f0
Rename Basis get_axis to get_column, remove redundant methods 2022-05-03 09:37:47 -05:00
Rémi Verschelde
931838b330
Merge pull request #60627 from aaronfranke/rename-elements
Rename Transform2D and Basis `elements` to `columns` and `rows` respectively
2022-05-03 14:40:01 +02:00