Commit Graph

1633 Commits

Author SHA1 Message Date
Aaron Franke 1d8cef8236
[3.x] Backport some APIs in math structs 2021-11-27 01:19:45 -06:00
Yuri Roubinsky 5928cc90f8 [3.x] Prevent return statement from using in block in shader main func 2021-11-23 10:40:47 +03:00
Camille Mohr-Daurat 3970f28f67
Merge pull request #55096 from lawnjelly/bvh_expanded_leaf
BVH - add option for expanded AABBs in leaves
2021-11-22 09:37:16 -07:00
Rémi Verschelde 393c7959ef
Merge pull request #42929 from madmiraal/fix-42877-3.2 2021-11-20 10:23:06 +01:00
Marcel Admiraal 702529d63e Give each RigidBody its own DirectBodyState wrapper. 2021-11-20 08:17:04 +00:00
Marcel Admiraal e900bac80b Add area to moved list when changing monitorable,
and only remove area from query when deleting pair if it was monitorable.
2021-11-20 06:54:36 +00:00
lawnjelly 211dc8cd2d BVH - add option for expanded AABBs in leaves
This PR adds a define BVH_EXPAND_LEAF_AABBS which is set, which stores expanded AABBs in the tree instead of exact AABBs.

This makes the logic less error prone when considering reciprocal collisions in the pairing, as all collision detect is now taking place between expanded AABB against expanded AABB, rather than expanded AABB against exact AABB.

The flip side of this is that the intersection tests will now be less exact when expanded margins are set.

All margins are now user customizable via project settings, and take account of collision pairing density to adjust the margin dynamically.
2021-11-20 06:45:12 +00:00
Hugo Locurcio d7d35e4f73
Add `const` qualifier support for function arguments in shaders
This prevents the function argument from being reassigned within
the function.

Example:

    void test(const int t) {}
2021-11-19 21:20:23 +01:00
Marcel Admiraal 4d3690eba5 Remove unimplemented methods 2021-11-18 12:47:36 +00:00
Rémi Verschelde 45088780be
Merge pull request #54925 from nekomatata/bvh-fix-update-3.x 2021-11-16 21:23:11 +01:00
PouleyKetchoupp e9fdf3e61f Fix physics BVH pairing for teleported or fast moving objects
Updating the broadphase to find new collision pairs was done after
checking for collision islands, so it was working in most cases due to
the pairing margin used in the BVH, but in case of teleported objects
the narrowphase collision could be skipped.

Now it's done before checking for collision islands, so we can ensure
that broadphase pairing has been done at the same time as objects are
marked as moved so their collision can be checked properly.

This issue didn't happen in the Octree/HashGrid because they do nothing
on update and trigger pairs directly when objects move instead.
2021-11-16 12:01:57 -07:00
Rémi Verschelde 4103b0b7d8
Merge pull request #50823 from fbcosentino/3d-material-overlay 2021-11-16 08:21:18 +01:00
Fernando Cosentino cc8846bef6 Added material_overlay property to MeshInstance
Applying overlay materials into multi-surface meshes currently
requires adding a next pass material to all the surfaces, which
might be cumbersome when the material is to be applied to a range
of different geometries. This also makes it not trivial to use
AnimationPlayer to control the material in case of visual effects.
The material_override property is not an option as it works
replacing the active material for the surfaces, not adding a new pass.

This commit adds the material_overlay property to GeometryInstance
(and therefore MeshInstance), having the same reach as
material_override (that is, all surfaces) but adding a new material
pass on top of the active materials, instead of replacing them.

Implemented in rasterizer of both GLES2 and GLES3.
2021-11-15 23:50:34 +00:00
Rémi Verschelde 89792e5c49
Merge pull request #54921 from lawnjelly/portals_roaming_margin 2021-11-15 22:45:46 +01:00
Yuri Roubinsky 824183854c
Removed incorrect autocompletion of matrixes in shader
(cherry picked from commit 04a2053f9b)
2021-11-15 16:30:00 +01:00
Julian Adamse 7e5034958e
Fix the volume calculation for cylinders
(cherry picked from commit 03903fdeec)
2021-11-15 16:09:59 +01:00
lawnjelly 062406b555 [3.x] Add Basis helper functions for transforming normals
Correct transformation of normals that works with a Basis containing non-uniform scale is difficult to get correct for those not familiar with the maths, it is also rather verbose and hard to read in calling code. This PR adds helper functions which both standardize the approach and make it clearer in calling code what is being done and why.
2021-11-15 08:43:46 +00:00
lawnjelly 788f075b44 Portals - Allow user to set roaming expansion margin
Previously a crude metric was used to decide on the roaming expansion margin, but it created unexpected results in some scenarios. Instead this setting is exposed to the user via the RoomManager, allowing them to tailor it to the world size, room sizes, roaming objects sizes and the speeds of movement.
2021-11-12 15:46:04 +00:00
PouleyKetchoupp b93aeec4a2 Fix errors in KinematicBody when floor is destroyed or removed
In all physics servers, body_get_direct_state() now silently returns
nullptr when the body has been already freed or is removed from space,
so the client code can detect this state and invalidate the body rid.

In 2D, there is no change in behavior (just no more errors).

In 3D, the Bullet server returned a valid direct body state when the
body was removed from the physics space, but in this case it didn't
make sense to use the information from the body state.
2021-11-09 15:15:40 -07:00
Rémi Verschelde 1f8497d281
Merge pull request #53411 from RandomShaper/ubershaders_3.x 2021-11-09 13:12:44 +01:00
Pedro J. Estébanez 4c710780d4 Implement async shader compilation plus caching for GL ES 3
Async. compilation via ubershader is currently available in the scene and particles shaders only.

Bonus:
- Use `#if defined()` syntax for not true conditionals, so they don't unnecessarily take a bit in the version flagset.
- Remove unused `ENABLE_CLIP_ALPHA` from scene shader.
- Remove unused `PARTICLES_COPY` from the particles shader.
- Remove unused uniform related code.
- Shader language/compiler: use ordered hash maps for deterministic code generation (needed for caching).
2021-11-09 12:19:12 +01:00
Rémi Verschelde cfff7a9032
Merge pull request #54751 from NHodgesVFX/3.x 2021-11-09 00:15:49 +01:00
Rémi Verschelde 6b7c841e1b
Merge pull request #54111 from nekomatata/fix-rigid-body-update-collision-layer-3.x 2021-11-08 23:58:47 +01:00
Rémi Verschelde ee46679ca3
Merge pull request #54577 from nekomatata/intersect-point-3d-3.x 2021-11-08 13:16:14 +01:00
NHodgesVFX 237f7eeabe Add more OpenGL Attributes
Co-Authored-By: Johann Meyer <25986904+johannmeyer@users.noreply.github.com>
Co-Authored-By: Clay John <claynjohn@gmail.com>
2021-11-08 01:22:40 -05:00
PouleyKetchoupp 160346f794 Add support for motion in 2D intersect_shape function
It was only missing extended rect for broadphase check, the solver was
already taking the motion from parameters into account.
2021-11-04 11:43:30 -07:00
PouleyKetchoupp fc2bd63ca0 Expose intersect_point in 3D physics server
Also cleaned a few things in the documentation for 2D.
2021-11-03 16:46:40 -07:00
Rémi Verschelde 1b65550ec7
clang-format: Various fixes to comments alignment from `clang-format` 13
All reviewed manually and occasionally rewritten to avoid bad auto formatting.
2021-10-28 14:50:32 +02:00
Rémi Verschelde 42d385b312
clang-format: Disable alignment of operands, too unreliable
Sets `AlignOperands` to `DontAlign`.

`clang-format` developers seem to mostly care about space-based indentation and
every other version of clang-format breaks the bad mismatch of tabs and spaces
that it seems to use for operand alignment. So it's better without, so that it
respects our two-tabs `ContinuationIndentWidth`.
2021-10-28 13:23:38 +02:00
Bastiaan Olij 3bd6088663 Only update render target directly if ARVR mode is off 2021-10-26 21:40:25 +11:00
Rémi Verschelde bc0d18d8d5
GLES2: Disable half float on iOS via platform override
This can be changed back by setting
`rendering/gles2/compatibility/disable_half_float.iOS` to false.

Fixes #31907.
2021-10-25 16:25:56 +02:00
PouleyKetchoupp 562d9cef1b Fix RigidBody collision update after changing collision layer/mask
Changing the collision layer of a sleeping body was not triggering area
updates correctly.

Bodies need to be active for collision to be checked against already
overlapping bodies and areas.

Neighbors need to be activated too in order to handle the case where a
static body is modified (it can't be activated directly but paired
bodies need to check their collision again).

In 3D, moved the call to wakeup() from the physics server to
BodySW::_shapes_changed to make it consistent with 2D and also handle
the case where shapes are modified (_shapes_changed is called in both
this case and collision layer changes).
2021-10-21 17:22:47 -07:00
PouleyKetchoupp 48144ed40e Fix physics BVH broadphase update when changing collision layer/mask
The BVH implementation is not checking collision layers on existing
pairs on move like other physics broadphases do.

This is solved by adding a new call to trigger pair callbacks again so
the physics engine can check layers again (specific to the BVH version,
other broadphase implementations just trigger a move like before).
2021-10-21 16:53:41 -07:00
Rémi Verschelde 302ad4e600
Merge pull request #52918 from Calinou/add-new-light-attenuation-3.x 2021-10-08 23:08:49 +02:00
Hugo Locurcio 85e080fcc0
Backport new 3D point light attenuation as an option
This provides more realistic lighting with a very small performance cost.
The option is available in both GLES3 and GLES2, and can be enabled in
the Project Settings. This goes well with the ACES Fitted tonemapping mode
that was recently added.

When enabled, this also makes upgrading Godot 3.x projects to Godot 4.0 easier,
since lighting in 3.x will better match how it'll look in Godot 4.0.
2021-10-08 22:15:22 +02:00
Rémi Verschelde 06fc2378de
Merge pull request #51491 from Calinou/glow-add-high-quality-mode-3.x
Add high quality glow mode (3.x)
2021-10-08 07:47:07 +02:00
PouleyKetchoupp 11aeaaa2cf Make body_test_motion thread safe for multi-threaded physics
Needs proper synchro with the command buffer for thread safety, in case
physics is not running on the main thread.
2021-10-06 16:06:03 -07:00
Rémi Verschelde abb1413e0f
Merge pull request #53453 from nekomatata/fix-rayshape-snap-3.x 2021-10-06 08:37:57 +02:00
PouleyKetchoupp 255febefb2 Fix Rayshape recovery in test_body_ray_separation
These changes improve Rayshape behavior for Godot Physics 2D and 3D
when using move_and_slide with and without snapping.

Kinematic margin is now applied to ray shapes when handling snapping
collision tests and separation raycasts to help getting consistent
results in slopes and flat surfaces.

Recovery is calculated without the margin and a depth of 0 is still
considered a collision to stabilize results when on flat surface.

Recovery depth takes into account the current recovery vector (just like
test_body_motion) to fix jittering issues with multiple ray shapes due
to applying too much recovery.
2021-10-05 18:24:30 -07:00
PouleyKetchoupp 9bc1b4b90e Improved logic for KinematicBody collision recovery depth
Allows more flexible collision detection with different safe margin values.

Kinematic body motion changes in 2D and 3D:
-Recovery only for depth > min contact depth to help with collision
detection consistency (rest info could be lost if recovery was too much)
-Adaptive min contact depth (based on margin) instead of space parameter
2021-10-05 17:00:55 -07:00
lawnjelly 192ec963ae Create 'rendering/misc' project settings section
To prevent the project settings `rendering` section getting out of hand, this PR moves some of the smaller new settings into a `misc` category.
2021-10-05 11:47:03 +01:00
Rémi Verschelde 69437eb746
Merge pull request #53012 from lawnjelly/portals_unload_reason 2021-10-05 12:00:43 +02:00
lawnjelly c835f1f3c5 Add DEV_ASSERT and DEV_CHECK macros
Change the existing DEV_ASSERT function to be switched on and off by the DEV_ENABLED define. DEV_ASSERT breaks into the debugger as soon as hit.
Add error macros DEV_CHECK and DEV_CHECK_ONCE to add an alternative check that ERR_PRINT when a condition fails, again only enabled in DEV_ENABLED builds.
2021-10-04 14:57:54 +01:00
Rémi Verschelde 33a42160a0
Merge pull request #42365 from madmiraal/fix-39887-3.2 2021-10-03 13:41:38 +02:00
Daniel 57b3b5108a Added wakeup() call to velocity, force and impulse functions. 2021-09-28 19:00:10 +13:00
lawnjelly 279e6f65cd Portals - add reason string to unload message
To help users identify conditions that are causing room system invalidation, a reason message is passed to the unload function and logged.
2021-09-24 14:00:24 +01:00
Rémi Verschelde b37776fa2f
Merge pull request #52591 from timothyqiu/error-macros
[3.x] Remove do{ } while(0) wrapper around error macros
2021-09-21 10:38:34 +02:00
Fabio Alessandrelli b800438efb [HTML5] Use browser mix rate by default on the Web.
Browsers doesn't really like forcing the mix rate, e.g. Firefox does not
allow input (microphone) if the mix rate is not the default one, Chrom*
will exhibit worse performances, etc.
2021-09-15 20:36:19 +02:00
lawnjelly d878fe7b90 Sphere occluders - self occlusion and improvements
Sphere occluders are now tested for self occlusion. Spheres that are behind another sphere in the current view are superfluous so can be removed, cutting down on the runtime calculations.

AABBs are now maintained for Occluders as well as individual spheres, meaning a bunch of occluder spheres can be frustum rejected as a block.
2021-09-14 11:31:14 +01:00
Haoyu Qiu 70853fd669 Remove do{ } while(0) wrapper around error macros 2021-09-12 15:04:53 +08:00