Commit graph

62 commits

Author SHA1 Message Date
Keegan Owsley e148338d42 Wrap angles to (-pi, pi) in momentum calculation.
Fixes a bug that causes KinematicBody2Ds to produce too much angular
momentum when rotating beyond 180 degrees.
2020-08-26 08:25:28 -07: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
lupoDharkael 95a1400a2a Replace NULL with nullptr 2020-04-02 13:38:00 +02:00
Rémi Verschelde 0c320a6bf3 More server renames for consistency after #37361 2020-03-28 13:20:48 +01: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 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 cf8c679a23 ObjectID converted to a structure, fixes many bugs where used incorrectly as 32 bits. 2020-02-12 14:24:54 -03: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
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 13798746e7 Activate Body(2D)SW when switching to rigid or character mode. 2019-10-15 07:41:13 +02:00
Marcel Admiraal 42a9ae7a82 Fix mismatch between RigidBody(2D) and Body(2D)SW can_sleep defaults.
- Set Body2DSW can_sleep default to true.

- Set Body2D can_sleep default to true.
2019-10-12 12:11:11 +02:00
Andrii Doroshenko (Xrayez) 718f09ad20 Fix uninitialized inertia value in Body2DSW 2019-08-23 20:13:57 +03:00
RaphaelHunter 74713fe970 Fix custom inertia in physics2d, closes#30838 2019-08-22 20:30:03 +08:00
qarmin e0b5b21863 Add some code changes/fixes proposed by Coverity and Clang Tidy 2019-08-07 12:54:30 +02:00
qarmin aab8da25ad Fix some code found by Coverity Scan and PVS Studio 2019-07-23 09:14:31 +02:00
Rémi Verschelde c8994b56f9 Style: Apply new changes from clang-format 8.0
It seems to stay compatible with formatting done by clang-format 6.0 and 7.0,
so contributors can keep using those versions for now (they will not undo those
changes).
2019-04-09 17:09:48 +02:00
Rémi Verschelde b16c309f82 Update copyright statements to 2019
Happy new year to the wonderful Godot community!
2019-01-01 12:58:10 +01:00
Stanislav 9edf98e841 Disabled CollisionShape and CollisionShape2D are not processed now
Fixes #24183
2018-12-12 17:48:35 +03:00
Juan Linietsky d403b4086c 2D Rigid Body CCD should work again, fixes #6664 2018-11-08 15:22:28 -03:00
Andrea Catania 5e65e28eed Removed physics material combination mode. Added rough and absorbent parameter to material. Fixed 'change' signal connection 2018-08-07 19:38:04 +02:00
AndreaCatania 5f66734d2d Implemented physics material
Hidden a function

Fixed travis static check
2018-05-11 03:23:09 +02: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
Rémi Verschelde bd282ff43f Use HTTPS URL for Godot's website in the headers 2017-08-27 14:16:55 +02:00
Poommetee Ketson 2fd204c35e Refactor 'treshold' to 'threshold' 2017-07-08 22:24:56 +07:00
Juan Linietsky 6ba1e4677b -Trigger shapes removed in 2D, they became obsolete long ago when areas could detect their own overlap
-Added ability to disable individual collisionshape/polygon
-Moved One Way Collision to shape, allowing more flexibility
-Changed internals of CollisionObject, shapes are generated from child nodes on the fly, not stored inside any longer.
-Modifying a CollisionPolygon2D on the fly now works, it can even be animated.

Will port this to 3D once well tested. Have fun!
2017-06-23 23:39:52 -03:00
Rémi Verschelde df61dc4b2b Add "Godot Engine contributors" copyright line 2017-04-08 00:11:42 +02:00
Rémi Verschelde debeee56f7 Fix typos in source code using codespell
From https://github.com/lucasdemarchi/codespell
2017-03-24 21:45:31 +01:00
Rémi Verschelde 5dbf1809c6 A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?

I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon

A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format

A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
2017-03-05 16:44:50 +01:00
Ferenc Arn eae94ba1c8 Use real_t as floating point type in physics code.
This is a continuation of an on-going work for 64-bit floating point builds, started in PR #7528. Covers physics, physics/joints and physics_2d code.

Also removed matrixToEulerXYZ function in favor of Basis::get_euler.
2017-02-13 17:42:02 -06:00
Rémi Verschelde 93ab45b6b5 Style: Fix whole-line commented code
They do not play well with clang-format which aligns the `//` part
with the rest of the code block, thus producing badly indented commented code.
2017-01-14 14:52:23 +01:00
Juan Linietsky bc26f90581 Type renames:
Matrix32 -> Transform2D
	Matrix3 -> Basis
	AABB -> Rect3
	RawArray -> PoolByteArray
	IntArray -> PoolIntArray
	FloatArray -> PoolFloatArray
	Vector2Array -> PoolVector2Array
	Vector3Array -> PoolVector3Array
	ColorArray -> PoolColorArray
2017-01-11 00:52:51 -03:00
Ferenc Arn f271591ac2 Various corrections in 2D math.
This is the follow up for the 2D changes mentioned in PR #6865. It fixes various mistakes regarding the order of matrix indices, order of transformation operations, usage of atan2 function and ensures that the sense of rotation is compatible with a left-handed coordinate system with Y-axis pointing down (which flips the sense of rotations along the z-axis). Also replaced float with real_t, and tried to make use of Matrix32 methods rather than accessing its elements directly.

Affected code in the Godot code base is also fixed in this commit.

The user code using functions involving angles such as atan2, angle_to, get_rotation, set_rotation will need to be updated to conform with the new behavior. Furthermore, the sign of the rotation angles in existing 2D scene files need to be flipped as well.
2017-01-10 10:14:20 -06:00
Rémi Verschelde c7bc44d5ad Welcome in 2017, dear changelog reader!
That year should bring the long-awaited OpenGL ES 3.0 compatible renderer
with state-of-the-art rendering techniques tuned to work as low as middle
end handheld devices - without compromising with the possibilities given
for higher end desktop games of course. Great times ahead for the Godot
community and the gamers that will play our games!
2017-01-01 22:03:33 +01:00
Josh Grams a7b4127481 RigidBody2D (add_force, set_inertia): new methods. 2016-04-26 08:15:15 -04:00
Josh Grams f7d31cec38 RigidBody2D: add and bind get_inertia() method.
You can't set this value very well, since it's automatically computed
from the mass and the collision shapes. But since the values are higher
than many people might suspect, so being able to read it helps estimate
the amount of torque you might need to apply.
2016-04-20 20:49:37 -04:00
Hubert Jarosz 4a4f247914
remove trailing whitespace 2016-03-09 00:00:52 +01:00
Juan Linietsky 606729fa2d physics state properly returns contact metadata, closes #1979 2016-01-03 20:23:44 -03:00
Juan Linietsky 27c47e09a1 skip the first integration in physics bodies, fixes #2213 2016-01-02 13:28:18 -03:00
George Marques 5be9ff7b67 Update copyright to 2016 in headers 2016-01-01 11:50:53 -02:00
Juan Linietsky 1e65c3c701 remove error print in area collision, should be a valid situation, closes #2463 2015-12-31 11:15:49 -03:00
Ovnuniarchos 89efebbf56 New and corrected are override modes. 2015-12-14 02:56:49 +01:00
Ovnuniarchos 43b2c9c7a4 Areas now calculate their dampenings the same way as their gravity. 2015-12-08 18:45:14 +01:00
Juan Linietsky d3eb9e8c54 -remove Vector2.atan2() replaced by Vector2.angle(), fixes #2260 2015-11-19 10:41:20 -03:00
Fabio Alessandrelli 590afbcac4 Calculate gravity based on distance from body to gravity point (2D) 2015-05-18 01:32:26 +00:00
Juan Linietsky bbe9a37f1d sleeping property now should work properly, fixes #1892 2015-05-16 17:54:36 -03:00
Juan Linietsky 767f71a35e -Made one way collision work with 2D physics (rigidbody) 2015-05-03 18:18:21 -03:00