It was due to main_shape_changed being called two times for each
added body. The first time it disables ccd, which sets the internal ccd
threshold to be 10000. The second time, it enables ccd again because
the internal threshold is > 0.
Bodies are now consistently set with a ccd threshold of 0 when ccd is
disabled.
This was causing crashing asserts in Bullet when adding bodies in some
scenarios, in btVector3::normalize():
btAssert(!fuzzyZero());
These crashes will still happen with ccd enabled.
(cherry picked from commit faca8b77aa)
This ensures the project setting never disappears from the editor,
even if the current physics engine is GodotPhysics.
This also adds documentation for the Smooth Trimesh Collision
project setting.
A common source of errors is to call functions (such as round()) expecting them to work in place, but them actually being designed only to return the processed value. Not using the return value in this case in indicative of a bug, and can be flagged as a warning by using the [[nodiscard]] attribute.
Two main changes:
- Better handling of concave shapes to make sure the queries don't
return a triangle index instead of shape index.
Note: A concave shape within a compound shape will always return a shape
index of 0 because of Bullet limitations.
- Extra check for compound shapes in some queries to avoid undefined
behavior, because the shape index can have an uninitialized value with
convex shapes in some cases.
(cherry picked from commit 02d40de30d)
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.
Stop include Bullet headers using `-isystem` for GCC/Clang as it misleads
SCons into not properly rebuilding all files when headers change.
This means we also need to make sure Bullet builds without warning, and
current version fares fairly well, there were just a couple to fix (patch
included).
Increase minimum version for distro packages to 2.90 (this was never released
as the "next" version after 2.89 was 3.05... but that covers it too).
Prevents a crash when calling test_body_motion. Call reload_kinematic_shapes
from init_kinematic_utilities as they are always called together.
(cherry picked from commits 112985c5bc
and 3540e716f9)
Same thing that was already done in 2D, applies moving platform motion
by using a call to move_and_collide that excludes the platform itself,
instead of making it part of the body motion.
Helps with handling walls and slopes correctly when the character walks
on the moving platform.
Also made some minor adjustments to the 2D version and documentation.
Co-authored-by: fabriceci <fabricecipolla@gmail.com>
When synchronizing KinematicBody motion with moving the platform using
direct body state, only the linear velocity was taken into account.
This change exposes velocity at local point in direct body state and
uses it in move_and_slide to get the proper velocity that includes
rotations.
Since we clone the environments to build thirdparty code, we don't get an
explicit dependency on the build objects produced by that environment.
So when we update thirdparty code, Godot code using it is not necessarily
rebuilt (I think it is for changed headers, but not for changed .c/.cpp files),
which can lead to an invalid compilation output (linking old Godot .o files
with a newer, potentially ABI breaking version of thirdparty code).
This was only seen as really problematic with bullet updates (leading to
crashes when rebuilding Godot after a bullet update without cleaning .o files),
but it's safer to fix it everywhere, even if it's a LOT of hacky boilerplate.
(cherry picked from commit c7b53c03ae)