Commit graph

154 commits

Author SHA1 Message Date
Rémi Verschelde
060988408b Physics: Properly obsolete friction and bounce properties
Without this change any new PhysicsBody would show deprecation warnings
due to default values for friction and bounce being defined.

It also enforced a physics material override even when using default
values.
2018-08-29 18:44:42 +02:00
Rémi Verschelde
3b01bf94ad Fix operator precedence in PhysicsBody2D::set_weight
Fixes #16038.
2018-08-29 08:37:08 +02:00
Rémi Verschelde
52466d57e9 Make some debug prints verbose-only, remove others 2018-08-24 14:59:01 +02:00
Rémi Verschelde
ab3716bd46 Revert "Take CanvasLayer transform into account for 2D physics"
This reverts commit 4839e5f6d9.

Fixes #21289.
2018-08-23 21:49:24 +02:00
Pedro J. Estébanez
4839e5f6d9 Take CanvasLayer transform into account for 2D physics
Fixes #18073.
2018-08-21 20:10:15 +02:00
Andrea Catania
0010d9c82a Added ray shape and move_and_slide with snapping on 3D.
Added stop_on_slope on 2d part
2018-08-19 13:45:23 +02:00
Juan Linietsky
c02fb271fd apply a threshold for floor angle, fixes #16037, fixes #15632 2018-08-10 13:07:52 -03:00
Juan Linietsky
14fd797c53
Merge pull request #20381 from AndreaCatania/phymat_2
Improved Physics material
2018-08-07 15:31:26 -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
Rémi Verschelde
12254594ac Fix PhysicsBody build with deprecated=no
Fixes #20483.
2018-07-27 15:34:58 +02:00
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
e1f2feec2e Changes to how snap works (I think this makes more sense now) 2018-07-16 21:30:44 -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
AndreaCatania
5f66734d2d Implemented physics material
Hidden a function

Fixed travis static check
2018-05-11 03:23:09 +02:00
Andrea Catania
39fb83630d
Added forgotten infinite_inertia to bindings
Related to this comment: https://github.com/godotengine/godot/pull/16757#discussion_r169470394
2018-02-21 08:42:36 +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
Artem Varaksa
d35e486228 Clean up some bad words from code comments 2018-02-17 16:00:39 +03:00
Bernhard Liebl
e9237d83c7 Fix crash on deleted rigidbodies without contact monitor (issue 15904) 2018-01-21 12:46:13 +01:00
Rémi Verschelde
9f479f096c Fix typos in code and docs with codespell
Using v1.11.0 from https://github.com/lucasdemarchi/codespell
2018-01-18 22:01:42 +01:00
Juan Linietsky
a26e6c8215 Renamed tree_exited to tree_exiting. tree_exited is now used for actual out of tree notification.
Updated doc accordingly.
2018-01-12 08:29:24 -03:00
Bojidar Marinov
9b8e8b2220
Bind many more properties to scripts
Notable potentially breaking changes:
- PROPERTY_USAGE_NOEDITOR is now PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_NETWORK, without PROPERTY_USAGE_INTERNAL
- Some properties were renamed, and sometimes even shadowed by new ones
- New getter methods (some virtual) were added
2018-01-12 00:58:14 +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
Eric Wiltfang
7dd9e5c57c Fix the prevention for sliding on slopes in the 2d version of move_and_slide
Done by using the same method the 3d counterpart uses.

Fixes #13063.
2017-11-20 01:42:44 +01:00
Juan Linietsky
192a4d7de5 Reworked how servers preallocate RIDs, should fix #10970 2017-11-09 23:35:34 -03:00
Poommetee Ketson
9cadb9e5f3 Bind unbound enums, rearrange some by value 2017-10-22 01:58:02 +07:00
AndreaCatania
4537977d6d Renamed fixed_process to physics_process 2017-09-30 16:19:07 +02:00
Aron de Castro
6e0892f223 Added to kinematicbody2d the copy and paste of the API friendler of KinematicBody 2017-09-10 13:07:47 -03:00
Ignacio Etcheverry
c16d00591b DocData and type hints fixes
- Makes vararg methods automatically use PROPERTY_USAGE_NIL_IS_VARIANT on return types
- Completely removes the ":type" suffix for method names. Virtual methods must use the MethodInfo constructors that takes Variant::Type or PropertyHint as the first parameter for the return type (with CLASS_INFO as a helper to get the PropertyInfo). Parameters must use PROPERTY_HINT_RESOURCE_TYPE and hint string.
- PROPERTY_USAGE_NIL_IS_VARIANT is no longer needed for parameters, because parameters cannot be void.
- Adds missing PROPERTY_USAGE_NIL_IS_VARIANT to virtual and built-in methods that return Variant.
2017-08-29 19:40:21 +02: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
Hein-Pieter van Braam
cacced7e50 Convert Object::cast_to() to the static version
Currently we rely on some undefined behavior when Object->cast_to() gets
called with a Null pointer. This used to work fine with GCC < 6 but
newer versions of GCC remove all codepaths in which the this pointer is
Null. However, the non-static cast_to() was supposed to be null safe.

This patch makes cast_to() Null safe and removes the now redundant Null
checks where they existed.

It is explained in this article: https://www.viva64.com/en/b/0226/
2017-08-24 23:08:24 +02:00
Juan Linietsky
2cc8309249 Merge pull request #10351 from neikeq/enums-are-for-the-weak
ClassDB: Provide the enum name of integer constants
2017-08-21 19:56:08 -03:00
Ignacio Etcheverry
32dd9a9f66 ClassDB: Provide the enum name of integer constants 2017-08-20 22:07:43 +02:00
Juan Linietsky
541fdffc0a Merge pull request #10319 from neikeq/pr-engine-editor-hint
Adds Engine::is_editor_hint() method
2017-08-20 12:55:46 -03:00
Ignacio Etcheverry
90b8a5b71e Removes editor_hint from SceneTree 2017-08-19 01:29:45 +02:00
Nathan Hold
fb40846dca Fix missing and incorrect values in return value of _move method 2017-08-12 19:59:39 +10:00
Ignacio Etcheverry
78619a5866 Fixes method definitions with extra number of arguments 2017-08-10 07:17:51 +02:00
Ignacio Etcheverry
2f290038d6 Removes type information from method binds 2017-08-10 07:17:50 +02:00
Juan Linietsky
de9fb90dbf Warn about resizing a rigidbody (2D or 3D), covers the most common cases, closes #7615 2017-08-05 16:06:15 -03:00
Johan Manuel
00afca31c6 Use the gravity constant to calculate weights 2017-07-05 15:14:12 +02:00
Juan Linietsky
bc509ac7bd Simplified 2D Kinematicbody.. 3D will wait a bit. 2017-06-24 12:34:29 -03: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
Poommetee Ketson
6c44fff508 Refactor layer_mask to collision_layer 2017-06-14 10:58:34 +07:00
gamemanj
0a4dde93d4 Apply is_ceiling/is_wall swap fix to 2D move_and_slide (minus explaination)
As it turns out, is_ceiling would be true when hitting a wall,
 and is_wall would be true momentarily when hitting a ceiling.

This makes a tiny one-line change to fix that.
Without trying to explain the code for anyone else having to
 mess around with it.
2017-04-15 10:24:36 +01:00
Rémi Verschelde
df61dc4b2b Add "Godot Engine contributors" copyright line 2017-04-08 00:11:42 +02:00
Rémi Verschelde
02f9851d0d Merge pull request #8259 from bojidar-bg/move-slide-wall-fix
Fix is_move_and_slide_on_wall, make move_and_slide floor angle configurable
2017-04-05 01:24:19 +02:00
Bojidar Marinov
289abd3710
Fix is_move_and_slide_on_wall, make move_and_slide floor angle configurable
Fixes #7313
2017-04-04 18:32:27 +03:00
Ferenc Arn
1a620bd5fa Made slide and reflect active verbs acting on itself in Vector2 and Vector3.
This is in alignment with other functions in vector classes.
Also added checks for normalization, fixed the sign of reflect (which now corresponds to reflection along a plane mathematically), added bounce method and updated docs.

Fixes #8201.
2017-04-03 10:02:12 -05: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
Hein-Pieter van Braam
411ee71b4d Rename the _MD macro to D_METHOD
This new name also makes its purpose a little clearer

This is a step towards fixing #56
2017-02-13 12:50:02 +01:00
Hein-Pieter van Braam
0f687f0ccb Remove use of _SCS from ADD_METHOD
This saves typing and is a step towards fixing #56
2017-02-13 10:37:47 +01:00
Ferenc Arn
6f4f9aa6de Overloaded basic math funcs (double and float variants). Use real_t rather than float or double in generic functions (core/math) whenever possible.
Also inlined some more math functions.
2017-01-16 13:36:33 -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
0ad9939603 Rename collision layer as suggested in #5696 2017-01-13 11:01:19 -03:00
Juan Linietsky
83cb84753f Renamed most signals so they refer to:
-An action being requested to the user in present tense: (ie, draw, gui_input, etc)
-A notification that an action happened, in past tense (ie, area_entered, modal_closed, etc).
2017-01-12 00:51:08 -03: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
Juan Linietsky
4338c90163 It is now possible to name layers of different kinds! 2017-01-10 22:20:57 -03:00
Juan Linietsky
b085c40edf -Conversion of most properties to a simpler syntax, easier to use by script
-Modified help to display properties

GDScript can still not make use of them, though.
2017-01-04 01:16:14 -03:00
Juan Linietsky
118eed485e ObjectTypeDB was renamed to ClassDB. Types are meant to be more generic to Variant.
All usages of "type" to refer to classes were renamed to "class"
ClassDB has been exposed to GDScript.
OBJ_TYPE() macro is now GDCLASS()
2017-01-02 23:03:46 -03: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
Ignacio Etcheverry
d579d0a814 KinematicBody: Fix wrong method bind return type 2016-12-10 16:23:47 +01:00
Juan Linietsky
5fc084c28e -Fixed issue in Kinematicbody2D 2016-09-01 12:03:55 -03:00
Juan Linietsky
fc70824f7c More improvements to visual script..
fixed a bug of not saving when sub-nodes changed.
2016-08-31 17:58:51 -03:00
Juan Linietsky
748836e0b3 Several all around fixes to visual scripting (in the process of creating demos) 2016-08-28 20:59:01 -03:00
Juan Linietsky
95dc15b750 Send body inout notifications after state is applied, fixes #4683 2016-06-17 16:45:10 -03:00
Josh Grams
a7b4127481 RigidBody2D (add_force, set_inertia): new methods. 2016-04-26 08:15:15 -04:00
Josh Grams
ffaced87a6 RigidBody2D: rename apply_impulse(pos) to offset. 2016-04-24 04:36:51 -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
Josh Grams
dbabe4c07c RigidBody2D: add and bind get/set_applied_torque. 2016-04-20 19:49:35 -04:00
Bojidar Marinov
6dcd1354c2 Add a sleeping_state_changed signal to RigidBody and RigidBody2D classes
Closes #3911
2016-04-06 17:14:38 +03:00
Juan Linietsky
a625f7d073 -Properly lock and and warn about switching off contact monitoring, fixes #3041 2016-01-12 06:14:15 -03:00
Juan Linietsky
a501ee355b properly specify metadata in KB function 2016-01-03 20:25:27 -03:00
George Marques
5be9ff7b67 Update copyright to 2016 in headers 2016-01-01 11:50:53 -02:00
Juan Linietsky
9acab32daa new file dialog!
-ItemList control for easier lists/thumbnails
-New file dialog, with support for thumbnails, favorites, recent places,
etc
-Moved .fscache out of the project, no more bugs due to committed/pulled
.fscache!
-Dir dialog now sorts directories
2015-06-06 09:44:38 -03:00
Juan Linietsky
421b4fec3e -compatibility option for physicsbody layers, fixes #1842 2015-05-10 15:58:08 -03:00
Juan Linietsky
e7aa37fe75 improved kinematic motion, improved demos for kinematic motion 2015-05-03 22:37:10 -03:00
Juan Linietsky
af06843982 -new collision layer & mask system for 2D, for more flexible collision masking 2015-05-03 16:47:21 -03:00
Juan Linietsky
79d5b7f258 -fixed bodyenter/bodyexit callback of physics bodies, fixes #1739 2015-04-26 17:46:20 -03:00
Juan Linietsky
28c4afeb57 -Rewritten KinematicBody2D::move to MUCH more efficient code.
-KinematicBody2D::move now properly recognizes collision exceptions and masks, fixes #1649
-Removed object type masking for KinematicBody2D
-Added a test_motion() function to RigidBody2D, allowing simlar behavior to KinematicBody2D::move there.
2015-04-19 20:50:55 -03:00
Juan Linietsky
fdaa2920eb Updated copyright year in all headers 2015-04-18 14:38:54 -03:00
Juan Linietsky
1572238adb merging okam changes 2015-04-02 07:22:17 -03:00
Juan Linietsky
c6c72a3c37 input events on Area2D is now supported
also added a demo showing how this works
2015-03-22 01:46:18 -03:00
Juan Linietsky
9012cd408e -Add support for one-way collision in 2D (only works for kinematic body so far)
-Solve drawing order bug introduced in previous commit: solves #1214
2015-01-13 21:19:11 -03:00
Juan Linietsky
2ef5a342e3 -begin work on unidirectional collision detection
-fixed performance issue in new 2D engine
-texscreen() working in shader 2D
2015-01-13 10:49:26 -03:00
Juan Linietsky
b51f645711 Changes to 2D physics engine
-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-Removed "density" property
-Added instead more flexible "angular damp" and "linear damp"
-Added ability to override angular and linear damp in rigidbody
-Added gravity scale option rigidbody

Test well and iron out bugs, when it works the same will be moved to 3D
2015-01-05 18:37:12 -03:00
Juan Linietsky
a36a774897 Fixes
-=-=-=

-Added missing quaternion constructor
-code completion fixes
-winrt fixes
2014-12-20 15:30:06 -03:00
Juan Linietsky
abbea4d945 UDP Fixes
-=-=-=-=-

Curse the day I decided to port UDP code, as it ended up
being two nights of work.  At least It's done now (I hope).

-Fixed UDP Support, API seems stable
-Added UDP Chat demo (chat that can lose your packets, heh)
-Added helpers to areas and bodies to get list of collided bodies and contained bodies.
-Sped up screen/viewport capture code.
-Added code to save an image as PNG
-Small fix so scripts register their singletons after modules did.
2014-11-13 00:53:12 -03:00
Juan Linietsky
0dbedd18fc SceneMainLoop -> SceneTree
-=-=-=-=-=-=-=-=-=-=-=-=-=-

*YOUR SOURCE MIGHT NOT WORK*
For mor information on fix:
https://github.com/okamstudio/godot/wiki/devel_scene_tree

Other stuff:
-Shower of bullets demo
-Fixes all around
2014-11-05 21:20:42 -03:00
Juan Linietsky
371eac9bef -added custom metadata to physics shapes (2D only for now)
-gizmos are not displayed in camera preview
2014-10-16 00:06:34 -03:00
Juan Linietsky
a84ba9c853 Collada
-=-=-=-

-Fixed some DAE import & export bugs
-Changed Collada exporter to use the mesh loops API
-Added tangent export to Collada exporter
-Added triangulation option to Collada exporter
-Changed a little how normalmaps are handled in shader. Not sure if it's working properly, be careful.
-Fixed some strange bug with kinematic bodies #776
-Fix release compilaiton issues #782
2014-10-14 01:01:25 -03:00
Juan Linietsky
af4a97bef9 missing fils from yesterday comit.
must have made some mistake with git,
not sure why they were not sent..
2014-10-03 08:58:41 -03:00
Juan Linietsky
048fdc8aea -variables with export in script are now IMMEDIATELY AND ALWAYS visible in properties (#718)
-WorldEnvironment cleanup issues fixed (#563)
-Text Editor improvement to shift-mouse selection (#648)
-(Hopefully) fixed rare (but horrible) indexing bug in GDScript compiler (#652)
-Some changes to PhysicsBody API, renamed property "active" to "sleeping", which makes more sense
-Added add_collision_exception() API in PhysicsBody (more accessible)
-ability to select and copy in the output messages panel
2014-09-22 00:50:48 -03:00
Juan Linietsky
1a2cb755e2 3D Physics and Other Stuff
-=-=-=-=-=-=-=-=-=-=-=-=-=

-New Vehicle (Based on Bullet's RaycastVehicle) - Vehiclebody/VehicleWheel. Demo will come soon, old vehicle (CarBody) will go away soon too.
-A lot of fixes to the 3D physics engine
-Added KinematicBody with demo
-Fixed the space query API for 2D (demo will come soon). 3D is WIP.
-Fixed long-standing bug with body_enter/body_exit for Area and Area2D
-Performance variables now includes physics (active bodies, collision pairs and islands)
-Ability to see what's inside of instanced scenes!
-Fixed Blend Shapes (no bs+skeleton yet)
-Added an Android JavaClassWrapper singleton for using Android native classes directly from GDScript. This is very Alpha!
2014-09-02 23:13:40 -03:00
Juan Linietsky
b324ff7ea5 A bit of everything:
-IMA-ADPCM support for samples, this means that sound effects can be compressed and use 4 timess less RAM.
-New 3D import workflow based on Wavefront OBJ. Import single objects as mesh resources instead of full scenes. Many people prefers to work this way. Just like the rest of the imported resources, these are updated in realtime if modified externally.
-Mesh resources now support naming surfaces. This helps reimporting to identify which user-created materials must be kept.
-Several fixes and improvements to SurfaceTool.
-Anti Aliasing added to WorldEnvironment effects (using FXAA)
-2D Physics bodies (RigidBody, KinematicBody, etc), Raycasts, Tilemap, etc support collision layers. This makes easy to group which objects collide against which.
-2D Trigger shapes can now also trigger collision reporting in other 2D bodies (it used to be in Area2D before)
-Viewport render target textures can now be filtered.
-Few fixes in GDscript make it easier to work with static functions and class members.
-Several and many bugfixes.
2014-05-14 01:22:15 -03:00