Dynamic BVH doesn't update the tree anymore when calling set_pairable
with no parameter change.
Also modified Godot Physics broadphase to create objects directly with
pairable (static) set correctly to make use of this optimization for the
BVH broadphase.
Note: Octree broadphase doesn't use this optimization because it forces
an update on move, so passing the proper AABB and static parameters on
creation would cause the tree to update twice.
List of changes:
- Modified bvh class to handle 2D and 3D as a template
- Changes in Rect2, Vector2, Vector3 interface to uniformize template
calls
- New option in Project Settings to enable BVH for 2D Physics (enabled
by default like in 3D)
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.
Backport of #48239.
I had missed a special case check for userdata of two colliding objects being equal. In this case, collisions should not be reported. This is used in the physics to prevent self intersection in composite objects.
When making items visible from the visual server, the collision check is deferred to prevent two identical collision checks when set_pairable is called shortly after.
It turns out that for some items (especially meshes), set_pairable is never called. This PR detects this occurrence and forces a collision check at the end of the routine.
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.
(cherry picked from commit 7f9bfee0ac)
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).
(cherry picked from commit a2b3a73e2d)
A major feature lacking in the octree was proper support for setting visibility / activation. This meant that invisible objects were still causing lots of processing in the tree unnecessarily.
This PR adds proper support for activation, items are temporarily removed from the tree and collision detection when inactive.
Fix bug whereby AABBs were reused from previous items due to use of a pool, resulting in missed collisions.
Also use full mask collision checks for all cases except generic update.
In the octree collisions are flushed as objects are moved, whereas in the BVH they are usually flushed once per frame.
This was causing problems in the render tree in some rare situations where objects were being created (perhaps deleted and recreated using the same handle in the same frame). This PR flushes the collisions before creating objects, and set_pairable.
set_pairable may not be necessary but it is done for safety until proven not necessary.
Also a small potential for a bug is closed in remove_unordered use.
Change render BVH update scheme from once per update_dirty_instances to a new update_scenarios function called once per draw.
Fix lights not being properly unpaired.
Fixed bug in add_changed_item where AABBs were not being updated due to more than one update per tick.
Calling set_pairable now will update collisions (rather than waiting for the next item_move).
Mask behaviour used for pairing now (hopefully) matches octree.
Completely re-write the lightmap generation code:
- Follow the general lightmapper code structure from 4.0.
- Use proper path tracing to compute the global illumination.
- Use atlassing to merge all lightmaps into a single texture (done by @RandomShaper)
- Use OpenImageDenoiser to improve the generated lightmaps.
- Take into account alpha transparency in material textures.
- Allow baking environment lighting.
- Add bicubic lightmap filtering.
There is some minor compatibility breakage in some properties and methods
in BakedLightmap, but lightmaps generated in previous engine versions
should work fine out of the box.
The scene importer has been changed to generate `.unwrap_cache` files
next to the imported scene files. These files *SHOULD* be added to any
version control system as they guarantee there won't be differences when
re-importing the scene from other OSes or engine versions.
This work started as a Google Summer of Code project; Was later funded by IMVU for a good amount of progress;
Was then finished and polished by me on my free time.
Co-authored-by: Pedro J. Estébanez <pedrojrulez@gmail.com>
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 🎆
(cherry picked from commit b5334d14f7)
Complete rewrite of spatial partitioning using a bounding volume hierarchy rather than octree.
Switchable in project settings between using octree or BVH for rendering and physics.
3.2 version of b5107715f1.
`get_seed()` still returns the previous state and not the initial seed,
because users may rely on this behavior for resetting the state in 3.2.
Documented this is going to be fixed in 4.0.
Co-authored-by: MidZik <matt.idzik1@gmail.com>
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.
(cherry picked from commit 35e6070a35)
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.
(cherry picked from commit 5f4d64f4f3)