Commit graph

337 commits

Author SHA1 Message Date
Rémi Verschelde c845e20add Revert "Allow Area2D and 3D mouse events without a collision layer"
This reverts commit 7eebb06b55.
2020-07-27 22:45:01 +02:00
Rémi Verschelde 3e87022ecc
Merge pull request #40252 from AndreaCatania/flush
Improved Bullet Physics flush algorithm, Lazy collision filter reload, Shape reload regression fix.
2020-07-27 13:57:47 +02:00
Andrea Catania 8d0d6d6921 - Enhanced the flush mechanism by flushing only needed thing.
- Flushing Areas before anything else.
- Make sure to correctly fetch gravity when the integrate_forces function is used
- Lazy reload body when layer and mask changes
- Shapes are reloaded just before the physics step starts.
- Improved some other parts of the code.
- Added override keyword
- Using LocalVector
2020-07-27 08:25:47 +02:00
Marcel Admiraal 236857c92a Ensure Bullet HeightMapShape3D data width and depth are at least 2. 2020-07-24 13:40:26 +01:00
Marcel Admiraal ec92a26d08 Use difference in position to check whether motion in Bullet is too close
to zero.
2020-07-18 13:15:10 +01:00
volzhs 4e987f5ab9 Fix overlappingObjects vector crash
use clear_overlaps() instead of clearing overlappingObjects directly
2020-07-14 02:34:18 +09:00
Marcel Admiraal 2ea644fda4 Set isScratchedSpaceOverrideModificator to false when removing a
RigidBodyBullet from a space.
2020-07-12 07:46:14 +01:00
Rémi Verschelde d0cea291d2
Merge pull request #40193 from KoBeWi/dem_pikks
Allow Area2D and 3D mouse events without collision layer
2020-07-11 00:26:56 +02:00
Marcel Admiraal 26fcf2b04c Add override keywords. 2020-07-10 13:56:54 +01:00
Tomasz Chabora 7eebb06b55 Allow Area2D and 3D mouse events without a collision layer
Co-authored-by: madmiraal <madmiraal@users.noreply.github.com>
2020-07-10 13:23:20 +02:00
Marcel Admiraal f31b2a1bba Move Bullet physics query flush from Bullet space pre-tick callback to
Bullet physics flush_queries() as is done in Godot physics, and remove
the pre-tick callback.
2020-07-08 11:39:41 +01:00
Rémi Verschelde bd3a468fc2
Merge pull request #39726 from AndreaCatania/add_body_impr_physics
Optimized physics object spawn time
2020-07-07 12:15:09 +02:00
Rémi Verschelde 480cb25961
Merge pull request #39735 from AndreaCatania/bullet_phy_add_api
Added BulletPhysics APIs to return internal objects.
2020-07-07 12:13:51 +02:00
Marcel Admiraal a615d359e8 Clear a Bullet Area's overlappingObjects vector when removing an area
from a space.
2020-07-06 12:04:15 +01:00
Rémi Verschelde 67e4082b1e
Merge pull request #37350 from aaronfranke/force-impulse
Refactor physics force and impulse code to use (force, position) order
2020-07-02 18:39:16 +02:00
Andrea Catania a2b5e7971a Added BulletPhysics APIs to return internal objects and fixed a typo. 2020-06-24 09:09:50 +02:00
Andrea Catania 7709a83493 Optimized physics object spawn time and optimized shape usage when the shape is not scaled 2020-06-24 08:54:11 +02:00
Rémi Verschelde 10d2fa4210
Merge pull request #39747 from nekomatata/fix-crash-space-query
Fix crashes with invalid shapes in BulletPhysicsDirectSpaceState queries
2020-06-22 10:46:39 +02:00
PouleyKetchoupp 8b0232bf29 Fix crashes with invalid shapes in BulletPhysicsDirectSpaceState queries 2020-06-22 10:22:11 +02:00
Rémi Verschelde c59be89273
Merge pull request #34236 from madmiraal/enable-bullet-debug
Enable Bullet DEBUG on debug builds.
2020-06-21 18:41:42 +02:00
Marcel Admiraal 8ffe905c45 Check for motion in cast_motion() before doing Bullet convexSweepTest().
Also ensure that default closest_safe and closest_unsafe values are
defined in cast_motion() and before cast_motion() is called.
2020-06-21 16:20:26 +01:00
Aaron Franke ba27deef06
Refactor physics force and impulse code 2020-06-02 23:18:59 -04:00
Rémi Verschelde e67339eeca
Merge pull request #39085 from madmiraal/fix-39059
Correct Bullet's default Area angular damp value.
2020-05-29 12:10:47 +02:00
Andrii Doroshenko (Xrayez) 69d5de632e Split Geometry singleton into Geometry2D and Geometry3D
Extra `_2d` suffixes are removed from 2D methods accoringly.
2020-05-27 14:28:34 +03:00
Marcel Admiraal ddcc2a0360 Correct Bullet's default Area angular damp value. 2020-05-27 11:57:48 +01:00
Rémi Verschelde ca3192d18a Style: Fix unnecessary semicolons that confused clang-format 2020-05-19 11:24:58 +02:00
Rémi Verschelde 0ee0fa42e6 Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14 21:57:34 +02:00
Rémi Verschelde 07bc4e2f96 Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route:
```
find -name "thirdparty" -prune \
  -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \
  -o -name "*.glsl" > files
perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files)
misc/scripts/fix_style.sh -c
```

This adds a newline after all `}` on the first column, unless they
are followed by `#` (typically `#endif`). This leads to having lots
of places with two lines between function/class definitions, but
clang-format then fixes it as we enforce max one line of separation.

This doesn't fix potential occurrences of function definitions which
are indented (e.g. for a helper class defined in a .cpp), but it's
better than nothing. Also can't be made to run easily on CI/hooks so
we'll have to be careful with new code.

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde 0be6d925dc Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde dcd1151d77 Enforce use of bool literals instead of integers
Using clang-tidy's `modernize-use-bool-literals`.
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-bool-literals.html
2020-05-14 13:45:01 +02:00
Rémi Verschelde 1f6f364a56 Port member initialization from constructor to declaration (C++11)
Using `clang-tidy`'s `modernize-use-default-member-init` check and
manual review of the changes, and some extra manual changes that
`clang-tidy` failed to do.

Also went manually through all of `core` to find occurrences that
`clang-tidy` couldn't handle, especially all initializations done
in a constructor without using initializer lists.
2020-05-14 10:01:56 +02:00
Rémi Verschelde 94721f5ab8 Revert "Renamed plane's d to distance"
This reverts commit ec7b481170.

This was wrong, `d` is not a distance but the `d` constant in the
parametric equation `ax + by + cz = d` describing the plane.
2020-05-10 16:47:11 +02:00
Rémi Verschelde 69de7ce38c Style: clang-format: Disable AllowShortCaseLabelsOnASingleLine
Part of #33027.
2020-05-10 13:13:54 +02:00
Rémi Verschelde e956e80c1f Style: clang-format: Disable AllowShortIfStatementsOnASingleLine
Part of #33027, also discussed in #29848.

Enforcing the use of brackets even on single line statements would be
preferred, but `clang-format` doesn't have this functionality yet.
2020-05-10 13:12:16 +02:00
Marcus Elg ec7b481170 Renamed plane's d to distance 2020-05-10 12:12:51 +02:00
PouleyKetchoupp 9353a2bbd1 Better damping implementation for Bullet rigid bodies
Apply old method for linear & angular damping in Bullet, in order to
make it easier to tweak and consistent with Godot Physics.
2020-04-27 18:24:33 +02:00
PouleyKetchoupp 3e7db60d56 Update to bullet master (2.90) 2020-04-27 11:37:47 +02:00
Rémi Verschelde 0ef8bcac4d DocData: Skip unexposed classes
Properly expose classes that we actually want accessible.
2020-04-20 12:51:10 +02:00
PouleyKetchoupp 30b184cb06 Fix set_sleep_state in Bullet body direct state
It was inverted, it should set the body to be active when sleep is disabled.
2020-04-14 11:39:34 +02:00
lupoDharkael 95a1400a2a Replace NULL with nullptr 2020-04-02 13:38:00 +02:00
Rémi Verschelde 5f11e15571
Merge pull request #37504 from qarmin/out_of_bound_cursor
Fix array out of bounds access caused by uninitialised variables
2020-04-02 13:07:55 +02:00
Marcel Admiraal ff90327146 Enable Bullet DEBUG on debug builds. 2020-04-01 18:37:52 +01:00
Rafał Mikrut 359bebd8c0 Fix out of bound array access caused by unassigned variable 2020-04-01 19:29:35 +02:00
Rémi Verschelde f3c74afd28
Merge pull request #37436 from akien-mga/doc-node-renames
doc: Update classref with node renames
2020-03-30 20:32:11 +02:00
Rémi Verschelde eaaee63b62 doc: Update classref with node renames
A few extra renames for classes which were missed in last week's PRs.
2020-03-30 18:23:02 +02:00
Rémi Verschelde cd4e46ee65 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.
2020-03-30 09:05:53 +02:00
Juan Linietsky a6f3bc7c69 Renaming of servers for coherency.
VisualServer -> RenderingServer
PhysicsServer -> PhysicsServer3D
Physics2DServer -> PhysicsServer2D
NavigationServer -> NavigationServer3D
Navigation2DServer -> NavigationServer2D

Also renamed corresponding files.
2020-03-27 15:21:27 -03:00
Juan Linietsky eaae4b6408 Renamed 2D and 3D nodes to make their types explicit
Fixes #30736.
2020-03-27 14:54:04 +01:00
Rémi Verschelde cb282c6ef0 Style: Set clang-format Standard to Cpp11
For us, it practically only changes the fact that `A<A<int>>` is now
used instead of the C++03 compatible `A<A<int> >`.

Note: clang-format 10+ changed the `Standard` arguments to fully
specified `c++11`, `c++14`, etc. versions, but we can't use `c++17`
now if we want to preserve compatibility with clang-format 8 and 9.
`Cpp11` is still supported as deprecated alias for `Latest`.
2020-03-17 07:36:24 +01:00
Pierre Caye f30f3f3deb change an exclamation mark to a dot 2020-03-09 14:44:12 +01:00
Rémi Verschelde fde1211771
Merge pull request #33690 from Phischermen/area-enhancement
Bullet: Fix detection of concave shape in Area
2020-02-26 21:51:37 +01:00
Juan Linietsky 33b5c57199 Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.

Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.

For Variant, the float datatype is always 64 bits, and exposed as `float`.

We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.

Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-25 12:55:53 +01:00
Phischermen 2c01cf54f8 Enabled concave collision detection with Areas in Bullet. 2020-02-24 07:37:15 -08:00
Yuri Roubinsky 3b0638fe1c Changed default capsule axis to vertical
Co-authored-by: Hugo Locurcio <https://hugo.pro>
2020-02-23 23:18:01 +03:00
Juan Linietsky 69c95f4b4c Reworked signal connection system, added support for Callable and Signal objects and made them default. 2020-02-20 08:24:50 +01:00
Juan Linietsky 3205a92ad8 PoolVector is gone, replaced by Vector
Typed `PoolTypeArray` types are now renamed `PackedTypeArray` and are
sugar for `Vector<Type>`.
2020-02-18 10:10:36 +01:00
Rémi Verschelde 54ac8eaba6 Remove more deprecated methods and code 2020-02-13 12:37:45 +01:00
Juan Linietsky cf8c679a23 ObjectID converted to a structure, fixes many bugs where used incorrectly as 32 bits. 2020-02-12 14:24:54 -03:00
Rémi Verschelde fff4240bb4 Fix code formatting issues and VS compilation
Also temporarily disable multicheck build so that we get a full build
even when there are style issues on Vulkan.

Fixes #33356.
2020-02-11 12:05:19 +01:00
Juan Linietsky dd3682e5fe Modernized default 3D material, fixes material bugs. 2020-02-11 12:01:24 +01:00
Juan Linietsky 4f163972bb Refactored RID/RID_Owner to always use O(1) allocation.
* Implements a growing chunked allocator
* Removed redudant methods get and getptr, only getornull is supported now.
2020-02-11 11:53:26 +01:00
Andrea Catania ca7ee56759 Make softbody completelly stiff to attachment point 2020-02-09 10:18:11 +01:00
Marcel Admiraal 6d69cd40bd Add do..while(0) wrappers to macros without one.
- Add do..while(0) wrapper to ERR_FAIL_NULL macros.
- Add do..while(0) wrapper to ERR_FAIL_COND macros.
- Add do..while(0) wrapper to ERR_CONTINUE macros.
- Add do..while(0) wrapper to ERR_BREAK macros.
- Add do..while(0) wrapper to CRASH_COND macros.
- Add do..while(0) wrapper to ERR_FAIL macros.
- Add do..while(0) wrapper to ERR_PRINT macros.
- Add do..while(0) wrapper to WARN_PRINT macros.
- Add do..while(0) wrapper to WARN_DEPRECATED macros.
- Add do..while(0) wrapper to CRASH_NOW macros.
2020-02-05 11:19:12 +01:00
Marcel Admiraal f0db13502a Remove duplicate WARN_PRINT macro. 2020-02-05 11:13:24 +01:00
Marcel Admiraal 5af3b4ca27 Remove duplicate ERR_PRINT macro. 2020-02-05 11:13:24 +01:00
clayjohn 57e27683ba Update docs to version 4.0 2020-01-31 17:15:41 -08:00
Rémi Verschelde 2d20fc39aa doc: Drop unused 'category' property from header
We already removed it from the online docs with #35132.

Currently it can only be "Built-In Types" (Variant types) or "Core"
(everything else), which is of limited use.

We might also want to consider dropping it from `ClassDB` altogether
in Godot 4.0.
2020-01-26 16:02:39 +01:00
Rémi Verschelde 41b21dee01 Bullet: Prevent potential division by zero
Fixes #33715.
2020-01-21 00:20:57 +01:00
Rémi Verschelde 0b185278f3
Merge pull request #34225 from madmiraal/fix-34210
Add check for zero length motion at beginning of each sweep test loop in SpaceBullet::test_body_motion
2020-01-11 11:57:41 +01:00
Rémi Verschelde 29e07dfa4e bullet: Sync with upstream 2.89
This allows distro unbundling again for distros that ship Bullet 2.89+.
2020-01-08 18:05:43 +01:00
Rémi Verschelde a7f49ac9a1 Update copyright statements to 2020
Happy new year to the wonderful Godot community!

We're starting a new decade with a well-established, non-profit, free
and open source game engine, and tons of further improvements in the
pipeline from hundreds of contributors.

Godot will keep getting better, and we're looking forward to all the
games that the community will keep developing and releasing with it.
2020-01-01 11:16:22 +01:00
Marcel Admiraal e0d252311e Add check for zero length motion at beginning of each sweep test loop
in SpaceBullet::test_body_motion.
2019-12-10 08:16:32 +01:00
Marcel Admiraal 78055cbdaf Check that motion is not zero before doing a sweep test.
Fixes #25476.
2019-12-09 09:21:38 +01:00
Rafał Mikrut e53e1c566a Fix some crashes and using null pointers 2019-10-28 08:07:29 +01:00
Marcel Admiraal 0539023fd4 Call activate function when setting RigidBodyBullet activation state. 2019-10-14 10:04:44 +02:00
PouleyKetchoupp 655694b394 Fixed RigidBody stuttering when changing collision layer/mask
- Changing collision layer/mask now only updates the broadphase proxy to avoid the velocity to be reset each time (also avoids unnecessary computations)
- No rigid body update at all when the collision layer/mask stays the same
- Same changes for Area for optimization purpose

Fixes #32577
2019-10-08 14:40:24 +02:00
Robin Hübner 8aeade74db Replace 'ERR_EXPLAIN' with 'ERR_FAIL_*_MSG' in rest of 'modules/' 2019-08-12 10:15:54 +02:00
PouleyKetchoupp 189e4e59ad Fixed KinematicCollision.get_local_shape() - the local shape id was never set during move_and_collide()
Fixes #31144
2019-08-07 12:32:32 +02:00
Michael Alexsander Silva Dias 12ae7a4c02 Update some dead links in the codebase 2019-07-23 21:06:12 -03:00
qarmin aab8da25ad Fix some code found by Coverity Scan and PVS Studio 2019-07-23 09:14:31 +02:00
qarmin 9a77d748c0 Fixes minor issues found by static analyzer 2019-07-07 23:08:51 +02:00
Rémi Verschelde b0d41847ed SCons: Use CPPDEFINES instead of CPPFLAGS for pre-processor defines
It's the recommended way to set those, and is more portable
(automatically prepends -D for GCC/Clang and /D for MSVC).

We still use CPPFLAGS for some pre-processor flags which are not
defines.
2019-07-03 09:59:04 +02:00
Rémi Verschelde 6b30f284a0
Merge pull request #29980 from Dentrax/directed-by-qarmin
Fix some editor crashes
2019-07-01 14:59:29 +02:00
Furkan Türkal 7d8d337b2c fix some crashes 2019-07-01 14:28:29 +03:00
Rémi Verschelde 603e87e2bb
Merge pull request #29938 from jonri/fix-collisionshape-scale
Fix updating of collision shape when the transform is set
2019-06-24 22:58:28 +02:00
Jon Ring 9d3089181c Fix updating of collision shape when the transform is set 2019-06-20 16:12:58 -04:00
JohnJLight 38d3bfe971 Made use of semicolons more consitent, fixed formatting 2019-06-19 15:24:31 +02:00
Rémi Verschelde 6d16f2f053 Fix error macro calls not ending with semicolon
It's not necessary, but the vast majority of calls of error macros
do have an ending semicolon, so it's best to be consistent.
Most WARN_DEPRECATED calls did *not* have a semicolon, but there's
no reason for them to be treated differently.
2019-06-11 14:49:34 +02:00
Rémi Verschelde 99acec63f1 bullet: Sync with current upstream master branch
This updates our local copy to commit 5ec8339b6fc491e3f09a34a4516e82787f053fcc.
We need a recent master commit for some new features that we use in Godot
(see #25543 and #28909).

To avoid warnings generated by Bullet headers included in our own module,
we include those headers with -isystem on GCC and Clang.

Fixes #29503.
2019-06-11 13:19:42 +02:00
Rémi Verschelde e0574e1d98 Fix typos with codespell
Using codespell 1.15.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
curvelinear
doubleclick
leapyear
lod
merchantibility
nd
numer
ois
ony
que
seeked
synching
te
uint
unselect
webp
EOF

$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2019-05-19 13:10:35 +02:00
Max Hilbrunner c67bb5f145
Merge pull request #28595 from godotengine/AndreaCatania-patch-1
Improved CCD calculation algorithm
2019-05-16 23:11:12 +02:00
Andrea Catania c1c8555565 Improved CCD calculation algorithm 2019-05-16 18:56:37 +02:00
Rémi Verschelde c38d9180df
Revert "Revert "Implemented terrain raycast acceleration"" 2019-05-16 10:18:48 +02:00
Rémi Verschelde 647021e864
Merge pull request #28326 from BastiaanOlij/center_heightmap
Center shape according to logic Bullet applies
2019-05-13 12:58:00 +02:00
Aaron Franke 702b539405
Change "ID" to lowercase "id"
Reasoning: ID is not an acronym, it is simply short for identification, so it logically should not be capitalized. But even if it was an acronym, other acronyms in Godot are not capitalized, like p_rid, p_ip, and p_json.
2019-05-09 06:25:32 -04:00
Bastiaan Olij e4dea0595a Add transform support to deal with Bullets centering of shapes 2019-05-07 22:43:10 +10:00
Rémi Verschelde 262924296b
Merge pull request #27415 from aqnuep/kinematicbody_fixes
KinematicBody performance and quality improvements
2019-05-02 18:03:58 +02:00
Rémi Verschelde d52b70fb5e SCons: Always use env.Prepend for CPPPATH
Include paths are processed from left to right, so we use Prepend to
ensure that paths to bundled thirdparty files will have precedence over
system paths (e.g. `/usr/include` should have lowest priority).
2019-04-30 13:12:06 +02:00
Rémi Verschelde f40c62fa29
Merge pull request #27371 from ShyRed/fixdisabled2dcollisions
Allow adding disabled shapes
2019-04-30 11:43:11 +02:00
Rémi Verschelde c2a669a9f0 SCons: Review uses of CCFLAGS, CXXFLAGS and CPPFLAGS
Many contributors (me included) did not fully understand what CCFLAGS,
CXXFLAGS and CPPFLAGS refer to exactly, and were thus not using them
in the way they are intended to be.

As per the SCons manual: https://www.scons.org/doc/HTML/scons-user/apa.html

- CCFLAGS: General options that are passed to the C and C++ compilers.
- CFLAGS: General options that are passed to the C compiler (C only;
  not C++).
- CXXFLAGS: General options that are passed to the C++ compiler. By
  default, this includes the value of $CCFLAGS, so that setting
  $CCFLAGS affects both C and C++ compilation.
- CPPFLAGS: User-specified C preprocessor options. These will be
  included in any command that uses the C preprocessor, including not
  just compilation of C and C++ source files [...], but also [...]
  Fortran [...] and [...] assembly language source file[s].

TL;DR: Compiler options go to CCFLAGS, unless they must be restricted
to either C (CFLAGS) or C++ (CXXFLAGS). Preprocessor defines go to
CPPFLAGS.
2019-04-24 16:57:58 +02:00