Commit graph

167 commits

Author SHA1 Message Date
Hein-Pieter van Braam
0e29f7974b Reduce unnecessary COW on Vector by make writing explicit
This commit makes operator[] on Vector const and adds a write proxy to it.  From
now on writes to Vectors need to happen through the .write proxy. So for
instance:

Vector<int> vec;
vec.push_back(10);
std::cout << vec[0] << std::endl;
vec.write[0] = 20;

Failing to use the .write proxy will cause a compilation error.

In addition COWable datatypes can now embed a CowData pointer to their data.
This means that String, CharString, and VMap no longer use or derive from
Vector.

_ALWAYS_INLINE_ and _FORCE_INLINE_ are now equivalent for debug and non-debug
builds. This is a lot faster for Vector in the editor and while running tests.
The reason why this difference used to exist is because force-inlined methods
used to give a bad debugging experience. After extensive testing with modern
compilers this is no longer the case.
2018-07-26 00:54:16 +02:00
Tiger Caldwell
40c7716586 Modified RigidBody, PhysicsDirectBodyState, PhysicsServer, and their respective 2D counterparts to be more consistent and to include more useful methods.
RigidBody:
- Added add_central_force
- Added add_force
- Added add_torque
- Added apply_central_impulse

RigidBody2D:
- Added add_central_force
- Added add_torque
- Added apply_central_impulse
- Added apply_torque_impulse

PhysicsDirectBodyState:
- Added apply_central_impulse

Physics2DDirectBodyState:
- Added add_central_force
- Added add_force
- Added add_torque
- Added apply_central_impulse
- Added apply_impulse
- Added apply_torque_impulse

PhysicsServer:
- Added body_add_force
- Added body_add_torque
- Added body_add_central_force
- Added body_apply_central_impulse

Physics2DServer:
- Added body_add_torque
- Added body_add_central_force
- Added body_apply_central_impulse
- Added body_apply_torque_impulse

Also fixed some small bugs along the way
2018-07-24 05:00:56 -04:00
Juan Linietsky
1ad20dc2f1
Merge pull request #12403 from AndreaCatania/phymat
Physics material
2018-07-23 07:37:03 -03:00
Juan Linietsky
13a801430b Further fixes to KinematicBody2D API, support for sync motion in moving objects 2018-07-17 08:58:04 -03:00
Juan Linietsky
063a22851a -Added support for raycast in KinematicBody2D
-Added support for snapping in KinematicBody2D
2018-07-16 20:04:07 -03:00
Max Hilbrunner
e790d4aafa
Merge pull request #18349 from Gorgexpress/master
Fixed 2D intersect_shape limiting broadphase results
2018-05-26 18:29:49 +02:00
AndreaCatania
5f66734d2d Implemented physics material
Hidden a function

Fixed travis static check
2018-05-11 03:23:09 +02:00
Juan Linietsky
4897373015
Merge pull request #18144 from Crazy-P/Resolves-crash-on-shape2D-culling-for-empty-Concave-shapes
Resolves crash on shape2D culling for empty Concave shapes
2018-05-07 15:35:33 -03:00
Michael
1ba106a71e Fixed 2D intersect_shape limiting broadphase results
Physics2DDirectSpaceStateSW was applying the result limit to broadphase
collision detection instead of narrow. This is inconsistent with its 3D
variant, as well as the rest of the 2D direct space state functions.

Broadphase is now limited by INTERSECTION_QUERY_MAX like everything else,
and narrow phase is exited early when the result limit has been reached.
2018-04-22 06:01:29 -04:00
Rémi Verschelde
bf7ca623a6 Fix Coverity reports of uninitialized scalar variable
Fixes most current reports on Coverity Scan of uninitialized scalar
variable (CWE-457): https://cwe.mitre.org/data/definitions/457.html

These happen most of the time (in our code) when instanciating structs
without a constructor (or with an incomplete one), and later returning
the instance. This is sometimes intended though, as some parameters are
only used in some situations and should not be double-initialized for
performance reasons (e.g. `constant` in ShaderLanguage::Token).
2018-04-19 15:20:45 +02:00
Crazy-P
158c7c72c7 Resolves crash on shape2D culling for empty Concave shapes
Fixes https://github.com/godotengine/godot/issues/17789
2018-04-12 18:15:34 +08:00
Juan Linietsky
20e68fef85
Merge pull request #17151 from ShyRed/disabled_shapes_2d
Remove disabled shapes from physics 2D calculations
2018-04-08 11:16:55 -03:00
Bernhard Liebl
9d7856620c Bring back Vector2.cross() 2018-03-07 21:10:31 +01:00
ShyRed
4d6bb43931 Remove disabled shapes from physics
Disabling a shape removes it from physics calculations. Enabling a shape adds it back to the physics calculations.
2018-03-07 18:03:44 +01:00
Rémi Verschelde
497a4e9e25
Merge pull request #16757 from AndreaCatania/kinpush
Improved kinematic body, Now can move rigid body
2018-02-20 15:41:10 +01:00
Andrea Catania
6ed392f47a Improved kinematic body 2D and 3D, Now can move rigid body 2018-02-20 12:43:47 +01:00
Rémi Verschelde
b2aeb02e7d
Merge pull request #16530 from AndreaCatania/rays
Improved ray shape (2D and 3D) by addiing the possibility to act as r…
2018-02-19 22:15:49 +01:00
Andrea Catania
ffc3ef8677 Improved ray shape (2D and 3D) by addiing the possibility to act as regular shape 2018-02-19 20:59:57 +01:00
Konrad Nowakowski
3659df6624 Fix 2d collision body update on shape remove 2018-02-18 20:46:37 +00:00
Artem Varaksa
d35e486228 Clean up some bad words from code comments 2018-02-17 16:00:39 +03:00
Andrea Catania
a42765dada Added physics API in order to enable/disable collisions between rigidbody attached to a joint with bullet physics bullet
Fixes #16424
2018-02-05 18:54:07 +01:00
Rémi Verschelde
e4213e66b2 Add missing copyright headers and fix formatting
Using `misc/scripts/fix_headers.py` on all Godot files.
Some missing header guards were added, and the header inclusion order
was fixed in the Bullet module.
2018-01-05 01:22:23 +01:00
Rémi Verschelde
b50a9114b1 Update copyright statements to 2018
Happy new year to the wonderful Godot community!
2018-01-01 14:40:47 +01:00
Rémi Verschelde
13c2ff9320 Style: Apply new clang-format 5.0 style to all files 2017-12-07 08:02:00 +01:00
AndreaCatania
d6e413bb9c Removed type_mask and fixed some variable name 2017-11-21 22:56:40 +01:00
Juan Linietsky
4deac219b0 Remove node from list before calling queries, fixes #10886 2017-11-10 08:32:02 -03:00
Juan Linietsky
192a4d7de5 Reworked how servers preallocate RIDs, should fix #10970 2017-11-09 23:35:34 -03:00
MateusMP
b37e277303 Fixing bad index used in Space2DSW
Fix wrong col_obj access using wrong index variable.
Related with issue #11695
2017-11-08 20:38:49 -02:00
Rémi Verschelde
24b3733f3b
Merge pull request #10770 from RandomShaper/fix-joints
Fix joints collision exceptions, plus a bit more
2017-10-31 23:02:37 +01:00
Pedro J. Estébanez
7b12ae39f2 Rename RayCasts collision_layer to collision_mask
The point is that `RayCast`s are checked against objects' `collision_layer`(s), but they themselves are considered no to _belong_ to any layer. Therefore, the correct name for their property is `collision_mask`, rather than `collision_layer`.

Only renaming is needed since the behavior was already the right one, only that it wasn't matching what users would expect from the name and description of the property.

Fixes #7589, where it's also discussed.
2017-10-21 22:17:47 +02:00
Marcelo Fernandez
79922be693 Prevent a possible crash at collision_object_2d_sw.h 2017-10-12 14:25:40 -03:00
Rémi Verschelde
8e9b99fe59 Merge pull request #11702 from AndreaCatania/bodyDS
Added new API to get body direct state
2017-10-09 11:01:36 +02:00
AndreaCatania
4537977d6d Renamed fixed_process to physics_process 2017-09-30 16:19:07 +02:00
AndreaCatania
c56c67db39 Added new API to get body direct state 2017-09-29 17:33:30 +02:00
Indah Sylvia
1ed5e75dd7 Removed print_line in Physics2DServerWrapMT::init() 2017-09-25 15:05:32 +07:00
letheed
5ad9be4c24 Rename pos to position in user facing methods and variables
Rename user facing methods and variables as well as the corresponding
C++ methods according to the folloming changes:

* pos -> position
* rot -> rotation
* loc -> location

C++ variables are left as is.
2017-09-20 13:11:10 +02:00
Juan Linietsky
d22ceeef1b correction to one way collision code 2017-09-17 10:18:09 -03:00
Juan Linietsky
5886f810c2 fixes to one way collision, closes #10971 2017-09-17 09:39:03 -03:00
Pedro J. Estébanez
fbeb27b01d Remove joint freeing logic from physics servers
Since joint resources are created by joint nodes and also they take care of freeing them, the physics server doesn't need to free bodies' joints explicitly.

The logic for clearing the constraints map/set is still relevant as there may be collision pairs and in their case its the server itself the one creating them and therefore releasing them.
2017-09-09 21:45:22 +02:00
Hein-Pieter van Braam
f9467ec1ea Fix signed and unsigned comparisons
The first in my quest to make Godot 3.x compile with -Werror on GCC7
2017-09-01 08:13:12 +02:00
Juan Linietsky
77ec304966 Fix special case where KinematicBody fails one way collisions by adding exclusion lists, closes #9729 2017-08-31 22:55:01 -03:00
Rémi Verschelde
7ad14e7a3e Dead code tells no tales 2017-08-27 22:13:45 +02:00
Rémi Verschelde
bd282ff43f Use HTTPS URL for Godot's website in the headers 2017-08-27 14:16:55 +02:00
Wilson E. Alvarez
738d2ab969 Removed unnecessary assignments 2017-08-21 15:15:55 -04:00
TwistedTwigleg
00f6c85928 Synchronize parameter names in definition and declaration
Fixes #10244.
2017-08-16 17:22:23 +02:00
Pedro J. Estébanez
e1bdf81008 Remove needless check in motion test
Since now one-way collision is at shapes, the removed if was unneeded.
2017-08-16 12:36:26 +02:00
Bojidar Marinov
fe1c3349e5
Fix freeze on close of game using 2D physics introduced by #9832
Additionally, port the fix to 3D physics, just in case
2017-08-08 23:17:11 +03:00
Indah Sylvia
5ae78fdf6a Makes all Godot API's methods Lower Case 2017-08-07 18:24:35 +07:00
Rémi Verschelde
7c860a7d4f Merge pull request #9832 from RandomShaper/port-physics-fixes
Port physics fixes
2017-08-01 22:23:59 +02:00
Pedro J. Estébanez
7264716e86 Improve cleanup of physics constraints
Don't abort the loop when one is already released
Remove warning on already-released constraint
Clean up area's contraints as well
Clear the constraint data as well
Do the cleanup as soon as the space changes
2017-08-01 01:39:40 +02:00