Commit graph

666 commits

Author SHA1 Message Date
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
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
jfons 4d9d99bb82 Implement occlusion culling
Added an occlusion culling system with support for static occluder meshes.
It can be enabled via `Project Settings > Rendering > Occlusion Culling > Use Occlusion Culling`.

Occluders are defined via the new `Occluder3D` resource and instanced using the new
`OccluderInstance3D` node. The occluders can also be automatically baked from a
scene using the built-in editor plugin.
2021-04-23 21:45:23 +02:00
kobewi 22efa850bd Make randomize() use unix time too 2021-04-22 21:08:33 +02:00
Danil Alexeev e63976d4b2
Fix Color::get_{r,g,b,a}8
Closes #47022.
2021-04-09 16:11:02 +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 9bbe51dc27
Style: Apply clang-tidy's modernize-use-nullptr 2021-04-05 14:05:07 +02:00
rafallus 9196722935 Fix Quat multiplication
x, y, z values were updated too early
2021-03-29 13:57:34 -06:00
Anshul7sp1 91181c2086 Fixes small typos and grammar correction 2021-03-12 19:05:16 +05:30
kleonc b59a06da25 Make Color::from_hsv use Color::set_hsv 2021-02-25 19:50:43 +01:00
kleonc 988f4cdc90 Geometry2D::make_atlas Fail is passed invalid rect size 2021-02-24 23:38:30 +01:00
Delf Neumärker f054f760e6 Fix unchecked array access in build_*_planes 2021-02-22 16:32:51 +01: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
JestemStefan 2c71ff1119
Added signed_angle_to for Vector3 2021-02-16 05:07:33 -05:00
PouleyKetchoupp 333f184734 Cylinder support in Godot Physics 3D
Cylinder collision detection uses a mix of SAT and GJKEPA.
GJKEPA is used to find the best separation axis in cases where finding
it analytically is too complex.

Changes in SAT solver:
Added support for generating separation axes for cylinder shape.
Added support for generating contact points with circle feature.

Changes in GJKEPA solver:
Updated from latest Bullet version which includes EPA fixes in some
scenarios.
Setting a lower EPA_ACCURACY to fix accuracy problems with cylinder vs.
cylinder in some cases.
2021-02-10 10:00:53 -07:00
Rémi Verschelde 3a3af0279b
Merge pull request #45658 from RandomShaper/fix_frozen_peak
Make audio bus channels' peak volume consistent
2021-02-03 10:05:34 +01:00
Pedro J. Estébanez a2b3a73e2d Make audio bus channels' peak volume consistent
Channels that are inactive -or when playback has not started yet- will report -200 dB as their peak value (which is also the lowest value possible during playback).
2021-02-02 11:30:32 +01:00
Aaron Franke f55445079a
Replace ColorN and from HTML with a string constructor 2021-02-01 17:27:19 -05:00
Rémi Verschelde d2e1216504
Merge pull request #37547 from aaronfranke/tau
Use Math_TAU and deg2rad/etc in more places and optimize code
2021-02-01 20:55:25 +01:00
Aaron Franke 1be0d6b30e
Type consistencies in core 2021-01-26 13:04:22 -05:00
George Marques fa498f6105
Merge pull request #45373 from aaronfranke/gdnative-sizeof
Define GDNative sizes using sizeof(godot_real) and sizeof(int32_t)
2021-01-26 14:00:32 -03:00
Danil Alexeev a97f1a3dc6 Rename color constants (alternative)
Named color constants renamed to UPPERCASE. Unlike #41019, this PR
is complete and implements these changes in the simplest way possible.

Co-authored-by: Shivam Mukherjee <mshivam98@gmail.com>
2021-01-26 19:07:00 +03:00
Marcel Admiraal 8b983bddfb Remove Quat set methods in favour of constructors 2021-01-26 06:52:04 +00:00
Aaron Franke 6c197cf259
Define GDNative sizes using sizeof(godot_real_t) and sizeof(int32_t) 2021-01-25 16:42:14 -05:00
Rémi Verschelde 8a6d4dd5ed
Merge pull request #45023 from reduz/optimize-shader-vgpr1
Shader optimizations to reduce VGPR usage and increase occupancy
2021-01-20 00:10:21 +01:00
reduz 099dee35f4 Added GPU based cluster builder
Clustering is now GPU based, uses an implementation based on the Activision algorithm.
2021-01-19 23:31:06 +01:00
PouleyKetchoupp 356d0fccc2
Remove useless "else" statements from vector3.h 2021-01-19 16:36:29 -05:00
Rémi Verschelde 0b409d89d0
Merge pull request #45136 from akien-mga/clang-format-11
CI: Update to clang-format 11 and apply ternary operator changes
2021-01-13 16:10:44 +01:00
Aaron Franke ddd6fb37e8
Update PolyPartition / Triangulator library 2021-01-12 13:46:16 -05:00
Rémi Verschelde af878716f2
CI: Update to clang-format 11 and apply ternary operator changes 2021-01-12 19:32:53 +01:00
Aaron Franke 1d5042c9e2
Use Math_TAU and deg2rad/rad2deg in more places and optimize code 2021-01-09 03:47:14 -05:00
Rémi Verschelde 9349a5507f
Merge pull request #35505 from dalexeev/rtl_colors
Unified named colors in RichTextLabel
2021-01-08 09:03:55 +01:00
Mai Lavelle 4cb070e590 Fix xform_inv of Plane, intermediate results were ignored 2021-01-03 23:49:39 -05:00
Rémi Verschelde b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
Marcus Brummer e455ca2f2f Added Geometry2D unit tests 2020-12-30 21:11:09 +01:00
Rémi Verschelde 6cebb8c117
Merge pull request #44586 from madmiraal/rename-stepify
Rename Math::stepify to snapped
2020-12-28 21:46:43 +01:00
Rémi Verschelde 058f3fe069
Merge pull request #44149 from madmiraal/rename-tangent-orthogonal
Rename Vector2.tangent() to Vector2.orthogonal()
2020-12-28 16:00:12 +01:00
Marcel Admiraal b743a2ef3c Rename Math::stepify to snapped 2020-12-28 13:01:30 +00:00
Marcel Admiraal b628912af0 Rename Rect2 and Rect2i grow_margin() to grow_side() 2020-12-28 12:47:33 +00:00
Marcel Admiraal 5b937d493f Rename empty() to is_empty() 2020-12-28 10:39:56 +00:00
reduz 2e66e5d599 Use page allocator for BVH 2020-12-24 14:08:03 -03:00
reduz 1bebb2ba05 Cull fixes and optimizations 2020-12-24 12:18:28 -03:00
lawnjelly 6d687de9b8 Fix BVH to world_aabb, and call update
The calls to the BVH need to use the world space AABB, rather than local space for it to work. Also, update was not being called which is required to update the AABB as objects move.
2020-12-24 11:19:50 +00:00
reduz 83058597cf Replace Octree by DynamicBVH in cull code
-Much greater pairing/unpairing performance
-For now, using it for culling too, but this will change in a couple of days.
-Added a paged allocator, to efficiently alloc/free some types of objects.
2020-12-23 19:31:30 -03:00
Marcel Admiraal 4b8b803931 Rename Control margin to offset 2020-12-23 06:25:56 +00:00
Marco Cognetta 900e55eb70 simplify randi_range 2020-12-21 20:25:58 -05:00
reduz 5ff89931c7 Add a Dynamic BVH implementation.
-Based on Bullet Dbvh, has style and functional changes.
-Provides efficient pairing
-Needed to optimize rendering
-Needed to optimize physics

This PR is up for others to review the implementation.
2020-12-19 20:23:37 -03:00
Marcel Admiraal 2df9a8ccad Rename Rect2 and Rect2i clip() to intersection() 2020-12-19 12:59:08 +00:00
reduz d2302f53d6 Implement automatic LOD (Level of Detail)
-Happens on import by default for all models
-Just works (tm)
-Biasing can be later adjusted per node or per viewport (as well as globally)
-Disabled AABB.get_support test because its broken
2020-12-18 15:48:03 +01:00
Rémi Verschelde 114f97ff11
Merge pull request #44128 from KoBeWi/🧹
Cleanup unused engine code
2020-12-09 13:01:50 +01:00
Tomasz Chabora 2c048ea164 Cleanup unused engine code 2020-12-09 12:12:36 +01:00
Rémi Verschelde 0c5d3b838c
Merge pull request #44199 from bruvzg/pvs_fixes_1
PVS-Studio static analyzer fixes
2020-12-09 10:23:21 +01:00
bruvzg 644f739660
Static analyzer fixes:
Removes unused code in OS.
Fixes return types.
Fixes few typos.
2020-12-09 10:17:53 +02:00
Rémi Verschelde 2034a1cca0
Merge pull request #44089 from Xrayez/rng-state
Add ability to restore `RandomNumberGenerator` state
2020-12-08 21:40:38 +01:00
Andrii Doroshenko (Xrayez) b5107715f1 Add ability to restore RandomNumberGenerator state
- added `state` as a property to restore internal state of RNG;
- `get_seed()` returns last seed used to initialize the state rather than the current state.

Co-authored-by: MidZik <matt.idzik1@gmail.com>
2020-12-07 13:50:46 +02:00
Aaron Franke 5465e604bb
Improve argument names for core types 2020-12-07 05:01:33 -05:00
Marcel Admiraal a24c38d1a8 Rename Vector2.tangent() to Vector2.orthogonal() 2020-12-06 18:16:06 +00:00
bruvzg 99666de00f
[Complex Text Layouts] Refactor Font class, default themes and controls to use Text Server interface.
Implement interface mirroring.
Add TextLine and TextParagraph classes.
Handle UTF-16 input on macOS and Windows.
2020-11-26 14:25:48 +02:00
Rafał Mikrut 7bd03b7188 Initialize class/struct variables with default values in core/ and drivers/ 2020-11-23 17:38:46 +01:00
Aaron Franke 02161aad5a
Remove empty lines around braces with the formatting script 2020-11-16 23:38:11 -05:00
Danil Alexeev 01d0addf56 Unified named colors in RichTextLabel
Now the BB tag `[color]` uses the color names from the `Color` class.
Also, the use of the `#` symbol in an HTML color code has become optional.
2020-11-17 02:55:36 +03:00
reduz 635d33dc6c Refactor variant built-in methods yet again.
* Using C-style function pointers now, InternalMethod is gone.
* This ensures much better performance in typed code.
* Renamed builtin_funcs to utility_funcs, to avoid naming confusion
2020-11-11 16:36:36 -03:00
Rémi Verschelde fb2151089c
Merge pull request #43372 from aaronfranke/clamp-fixes
Minor clamp and float fixes
2020-11-11 13:20:19 +01:00
reduz 5288ff538d Create Variant built-in functions.
-Moved Expression to use this, removed its own.
-Eventually GDScript/VisualScript/GDNative need to be moved to this.
-Given the JSON functions were hacked-in, removed them and created a new JSONParser class
-Made sure these functions appear properly in documentation, since they will be removed from GDScript
2020-11-10 19:31:10 -03:00
Aaron Franke ee79fc627c
Minor clamp and float fixes 2020-11-10 14:30:07 -05:00
Rémi Verschelde 0f249f5c0a
Variant: Sync docs with new constructors, fixups after #43403
Change DocData comparators for MethodDoc and ArgumentDoc to get a better
ordering of constructors.
2020-11-09 23:39:53 +01:00
Rémi Verschelde 8a318fe1dd
Merge pull request #43404 from akien-mga/color-fix-clamp-uint32_t-warning
Color: Fix -Wtype-limits GCC warning after refactoring
2020-11-09 14:59:11 +01:00
Rémi Verschelde 771b3c583d
Color: Fix -Wtype-limits GCC warning after refactoring
Warning from GCC 10.2.0 with `warnings=extra`:
```
./core/math/color.h: In member function 'int32_t Color::get_r8() const':
./core/typedefs.h:107:42: error: comparison of unsigned expression in '< 0' is always false [-Werror=type-limits]
  107 | #define CLAMP(m_a, m_min, m_max) (((m_a) < (m_min)) ? (m_min) : (((m_a) > (m_max)) ? m_max : m_a))
      |                                    ~~~~~~^~~~~~~~~
./core/math/color.h:201:49: note: in expansion of macro 'CLAMP'
  201 |  _FORCE_INLINE_ int32_t get_r8() const { return CLAMP(uint32_t(r * 255.0), 0, 255); }
      |                                                 ^~~~~
```

Also some code consistency changes while at it.
2020-11-09 14:11:21 +01:00
reduz 221a2a1742 Refactored variant constructor logic 2020-11-09 08:54:43 -03:00
reduz 127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00
reduz 05de7ce6ca Refactored variant setters/getters
-Discern between named, indexed and keyed
-Get direct access to functions for typed GDScript and GDNative bindings
-Small changes to some classes in order to work with the new setget binder
2020-11-07 15:16:15 -03:00
reduz f2397809a8 Refactored Variant Operators.
-Using classes to call and a table
-For typed code (GDS or GDNative), can obtain functions to call prevalidated or ptr.
2020-11-06 12:45:50 -03:00
Yuri Roubinsky 38fb26794b Exposed randi_range to global funcs + renamed rand_range to randf_range 2020-11-06 17:06:26 +03:00
Andrii Doroshenko (Xrayez) 34ca426851 Remove unused PHI define in math funcs 2020-11-05 18:05:58 +02:00
Rémi Verschelde 35e6070a35
doc: Override default value for RandomNumberGenerator.seed
It's non-deterministic so it's better to show a fixed value like 0 instead of
having it potentially change whenever `randomize()` is called.

Fixes #43317.
2020-11-05 00:41:24 +01:00
Rémi Verschelde 424cd00f8b
doc: Sync classref with current source + fixup some bindings
Includes various changes triggered by the refactoring of method bindings.
2020-11-04 15:38:26 +01:00
reduz f123981a96 Implement DirectionalLight2D
Also separated Light2D in PointLight2D and DirectionalLight2D.
Used PointLight2D because its more of a point, and it does not work
the same as OmniLight (as shape depends on texture).
Added a few utility methods to Rect2D I needed.
2020-11-04 10:03:01 -03:00
Yuri Roubinsky 31faa1f226 Fix biased output of randi_range 2020-10-29 15:41:00 +03:00
Andrii Doroshenko (Xrayez) 1923f0d302 Make randbase member protected in RandomNumberGenerator
Allows to extend `RandomNumberGenerator` via C++ modules.
2020-10-27 01:52:15 +02:00
reduz b8c64184c6 Refactored binding system for core types
Moved to a system using variadic templates, shared with CallableBind.

New code is cleaner, faster and allows for much better optimization of core
type functions from GDScript and GDNative.

Added Variant::InternalMethod function for direct call access.
2020-10-14 15:24:30 +02:00
Rémi Verschelde 7c4d1e9c65
Merge pull request #42660 from Chaosus/remove_get_uv84_normal_bit
Removed unused method Geometry3D.get_uv84_normal_bit
2020-10-09 19:31:24 +02:00
reduz 26f5bd245c Implement GPU Particle Collisions
-Sphere Attractor
-Box Attractor
-Vector Field
-Sphere Collider
-Box Collider
-Baked SDF Collider
-Heightmap Collider
2020-10-09 13:25:47 -03:00
Yuri Roubinsky 66c2aaf749 Removed unused method Geometry.get_uv84_normal_bit 2020-10-09 10:22:26 +03:00
Rémi Verschelde b07f020c99
Merge pull request #42133 from vnen/variant-op-consistency
Allow commutative multiplication in Variant
2020-09-28 15:56:29 +02:00
Aaron Franke 9394c057b8
Remove redundant is_equal_approx_ratio method
is_equal_approx is able to handle values of any size, and is_equal_approx_ratio is no longer used in any exposed APIs, so we don't need is_equal_approx_ratio anymore. Also, add #ifdef MATH_CHECKS for a method that is only used when MATH_CHECKS is defined.
2020-09-23 00:28:49 -04:00
Aaron Franke 23dabcd2d0
Change Basis is_equal_approx to use instance method 2020-09-23 00:28:49 -04:00
Rémi Verschelde 5f4d64f4f3
Linux/BSD: Fix support for NetBSD
Add __NetBSD__ to `platform_config.h` so that it can find `alloca`
and use the proper `pthread_setname_np` format.

Rename RANDOM_MAX to avoid conflict with NetBSD stdlib.

Fixes #42145.
2020-09-18 10:27:55 +02:00
George Marques e4942e4a96
Allow commutative multiplication in Variant
Also allow quaternions to be multiplied by integers.
2020-09-17 09:02:53 -03:00
Aaron Franke d0a1399a1b
Change inequality comparison operators to use exact equality 2020-09-08 18:10:58 -04:00
Marcel Admiraal 9149fb760c Initialise Basis elements with a default Basis in the declaration.
Ensures a valid Basis is created with all constructors.
2020-09-08 12:15:08 +01:00
Marcel Admiraal ce263c4ff6 Ensure assignment operators return by reference to avoid unnecessary copies. 2020-09-04 09:18:19 +01:00
bruvzg 80b8eff6aa
[Complex Test Layouts] Change String to use UTF-32 encoding on all platforms. 2020-09-03 19:56:24 +03:00
Rémi Verschelde a276e6fc36
Merge pull request #40955 from Calinou/test-add-expression
Add a test suite for Expression
2020-08-31 11:12:34 +02:00
Hugo Locurcio d5ffa42cd2
Add a test suite for Expression
This also makes the first parameter of `Expression::execute()` optional
from C++. Previously, it was only optional in the scripting API.
2020-08-27 15:16:09 +02:00
Juan Linietsky 079ca220e1 Added volumetric fog effect. 2020-08-13 11:28:45 -03:00
Aaron Franke 56e2c6c704
Make all String float conversion methods be 64-bit 2020-07-27 18:38:53 -04:00
Meriipu 7f9bfee0ac GDScript: Clarified/fixed inaccuracies in the built-in function docs.
The input to smoothstep is not actually a weight, and the decscription
of smoothstep was pretty hard to understand and easy to misinterpret.

Clarified what it means to be approximately equal.

nearest_po2 does not do what the descriptions says it does. For one,
it returns the same power if the input is a power of 2. Second, it
returns 0 if the input is negative or 0, while the smallest possible
integral power of 2 actually is 1 (2^0 = 1). Due to the implementation
and how it is used in a lot of places, it does not seem wise to change
such a core function however, and I decided it is better to alter the
description of the built-in.

Added a few examples/clarifications/edge-cases.
2020-07-25 20:26:02 +02:00
Aaron Franke 83e324d670
Update core documentation to match recent C# changes
Also a few minor API changes like adding AABB.abs()

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2020-07-21 14:44:53 -04:00
Rémi Verschelde a8a2769bb6
Merge pull request #38713 from aaronfranke/string-64bit
Make all String integer conversion methods be 64-bit
2020-07-01 16:01:05 +02:00
Juan Linietsky 201d606b3d Addition of SDFGI for open world global illumination
Move GI to a deferred pass
2020-06-26 11:06:48 -03:00