Merge pull request #64894 from fabriceci/remove-dynamic-bodies-name

This commit is contained in:
Rémi Verschelde 2022-08-26 16:16:32 +02:00 committed by GitHub
commit 1c97dde78f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
61 changed files with 616 additions and 618 deletions

View File

@ -131,7 +131,7 @@
<method name="move_and_slide"> <method name="move_and_slide">
<return type="bool" /> <return type="bool" />
<description> <description>
Moves the body based on [member velocity]. If the body collides with another, it will slide along the other body (by default only on floor) rather than stop immediately. If the other body is a [CharacterBody2D] or [RigidDynamicBody2D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes. Moves the body based on [member velocity]. If the body collides with another, it will slide along the other body (by default only on floor) rather than stop immediately. If the other body is a [CharacterBody2D] or [RigidBody2D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes.
Modifies [member velocity] if a slide collision occurred. To get the latest collision call [method get_last_slide_collision], for detailed information about collisions that occurred, use [method get_slide_collision]. Modifies [member velocity] if a slide collision occurred. To get the latest collision call [method get_last_slide_collision], for detailed information about collisions that occurred, use [method get_slide_collision].
When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions. When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions.
The general behavior and available properties change according to the [member motion_mode]. The general behavior and available properties change according to the [member motion_mode].

View File

@ -117,7 +117,7 @@
<method name="move_and_slide"> <method name="move_and_slide">
<return type="bool" /> <return type="bool" />
<description> <description>
Moves the body based on [member velocity]. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [CharacterBody3D] or [RigidDynamicBody3D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes. Moves the body based on [member velocity]. If the body collides with another, it will slide along the other body rather than stop immediately. If the other body is a [CharacterBody3D] or [RigidBody3D], it will also be affected by the motion of the other body. You can use this to make moving and rotating platforms, or to make nodes push other nodes.
Modifies [member velocity] if a slide collision occurred. To get the latest collision call [method get_last_slide_collision], for more detailed information about collisions that occurred, use [method get_slide_collision]. Modifies [member velocity] if a slide collision occurred. To get the latest collision call [method get_last_slide_collision], for more detailed information about collisions that occurred, use [method get_slide_collision].
When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions. When the body touches a moving platform, the platform's velocity is automatically added to the body motion. If a collision occurs due to the platform's motion, it will always be first in the slide collisions.
Returns [code]true[/code] if the body collided, otherwise, returns [code]false[/code]. Returns [code]true[/code] if the body collided, otherwise, returns [code]false[/code].

View File

@ -4,7 +4,7 @@
Concave polygon shape resource for 2D physics. Concave polygon shape resource for 2D physics.
</brief_description> </brief_description>
<description> <description>
2D concave polygon shape to be added as a [i]direct[/i] child of a [PhysicsBody2D] or [Area2D] using a [CollisionShape2D] node. It is made out of segments and is optimal for complex polygonal concave collisions. However, it is not advised to use for [RigidDynamicBody2D] nodes. A CollisionPolygon2D in convex decomposition mode (solids) or several convex objects are advised for that instead. Otherwise, a concave polygon 2D shape is better for static collisions. 2D concave polygon shape to be added as a [i]direct[/i] child of a [PhysicsBody2D] or [Area2D] using a [CollisionShape2D] node. It is made out of segments and is optimal for complex polygonal concave collisions. However, it is not advised to use for [RigidBody2D] nodes. A CollisionPolygon2D in convex decomposition mode (solids) or several convex objects are advised for that instead. Otherwise, a concave polygon 2D shape is better for static collisions.
The main difference between a [ConvexPolygonShape2D] and a [ConcavePolygonShape2D] is that a concave polygon assumes it is concave and uses a more complex method of collision detection, and a convex one forces itself to be convex to speed up collision detection. The main difference between a [ConvexPolygonShape2D] and a [ConcavePolygonShape2D] is that a concave polygon assumes it is concave and uses a more complex method of collision detection, and a convex one forces itself to be convex to speed up collision detection.
[b]Performance:[/b] Due to its complexity, [ConcavePolygonShape2D] is the slowest collision shape to check collisions against. Its use should generally be limited to level geometry. For convex geometry, using [ConvexPolygonShape2D] will perform better. For dynamic physics bodies that need concave collision, several [ConvexPolygonShape2D]s can be used to represent its collision by using convex decomposition; see [ConvexPolygonShape2D]'s documentation for instructions. However, consider using primitive collision shapes such as [CircleShape2D] or [RectangleShape2D] first. [b]Performance:[/b] Due to its complexity, [ConcavePolygonShape2D] is the slowest collision shape to check collisions against. Its use should generally be limited to level geometry. For convex geometry, using [ConvexPolygonShape2D] will perform better. For dynamic physics bodies that need concave collision, several [ConvexPolygonShape2D]s can be used to represent its collision by using convex decomposition; see [ConvexPolygonShape2D]'s documentation for instructions. However, consider using primitive collision shapes such as [CircleShape2D] or [RectangleShape2D] first.
[b]Warning:[/b] Using this shape for an [Area2D] (via a [CollisionShape2D] node) may give unexpected results: the area will only detect collisions with the segments in the [ConcavePolygonShape2D] (and not with any "inside" of the shape, for example). [b]Warning:[/b] Using this shape for an [Area2D] (via a [CollisionShape2D] node) may give unexpected results: the area will only detect collisions with the segments in the [ConcavePolygonShape2D] (and not with any "inside" of the shape, for example).

View File

@ -5,7 +5,7 @@
</brief_description> </brief_description>
<description> <description>
3D concave polygon shape resource (also called "trimesh") to be added as a [i]direct[/i] child of a [PhysicsBody3D] or [Area3D] using a [CollisionShape3D] node. This shape is created by feeding a list of triangles. Despite its name, [ConcavePolygonShape3D] can also store convex polygon shapes. However, unlike [ConvexPolygonShape3D], [ConcavePolygonShape3D] is [i]not[/i] limited to storing convex shapes exclusively. 3D concave polygon shape resource (also called "trimesh") to be added as a [i]direct[/i] child of a [PhysicsBody3D] or [Area3D] using a [CollisionShape3D] node. This shape is created by feeding a list of triangles. Despite its name, [ConcavePolygonShape3D] can also store convex polygon shapes. However, unlike [ConvexPolygonShape3D], [ConcavePolygonShape3D] is [i]not[/i] limited to storing convex shapes exclusively.
[b]Note:[/b] When used for collision, [ConcavePolygonShape3D] is intended to work with static [PhysicsBody3D] nodes like [StaticBody3D] and will not work with [CharacterBody3D] or [RigidDynamicBody3D] with a mode other than Static. [b]Note:[/b] When used for collision, [ConcavePolygonShape3D] is intended to work with static [PhysicsBody3D] nodes like [StaticBody3D] and will not work with [CharacterBody3D] or [RigidBody3D] with a mode other than Static.
[b]Performance:[/b] Due to its complexity, [ConcavePolygonShape3D] is the slowest collision shape to check collisions against. Its use should generally be limited to level geometry. For convex geometry, using [ConvexPolygonShape3D] will perform better. For dynamic physics bodies that need concave collision, several [ConvexPolygonShape3D]s can be used to represent its collision by using convex decomposition; see [ConvexPolygonShape3D]'s documentation for instructions. However, consider using primitive collision shapes such as [SphereShape3D] or [BoxShape3D] first. [b]Performance:[/b] Due to its complexity, [ConcavePolygonShape3D] is the slowest collision shape to check collisions against. Its use should generally be limited to level geometry. For convex geometry, using [ConvexPolygonShape3D] will perform better. For dynamic physics bodies that need concave collision, several [ConvexPolygonShape3D]s can be used to represent its collision by using convex decomposition; see [ConvexPolygonShape3D]'s documentation for instructions. However, consider using primitive collision shapes such as [SphereShape3D] or [BoxShape3D] first.
[b]Warning:[/b] Using this shape for an [Area3D] (via a [CollisionShape3D] node, created e.g. by using the [i]Create Trimesh Collision Sibling[/i] option in the [i]Mesh[/i] menu that appears when selecting a [MeshInstance3D] node) may give unexpected results: the area will only detect collisions with the triangle faces in the [ConcavePolygonShape3D] (and not with any "inside" of the shape, for example); moreover it will only detect all such collisions if [member backface_collision] is [code]true[/code]. [b]Warning:[/b] Using this shape for an [Area3D] (via a [CollisionShape3D] node, created e.g. by using the [i]Create Trimesh Collision Sibling[/i] option in the [i]Mesh[/i] menu that appears when selecting a [MeshInstance3D] node) may give unexpected results: the area will only detect collisions with the triangle faces in the [ConcavePolygonShape3D] (and not with any "inside" of the shape, for example); moreover it will only detect all such collisions if [member backface_collision] is [code]true[/code].
</description> </description>

View File

@ -22,12 +22,12 @@
AddChild(scene); AddChild(scene);
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
[b]Example of saving a node with different owners:[/b] The following example creates 3 objects: [Node2D] ([code]node[/code]), [RigidDynamicBody2D] ([code]body[/code]) and [CollisionObject2D] ([code]collision[/code]). [code]collision[/code] is a child of [code]body[/code] which is a child of [code]node[/code]. Only [code]body[/code] is owned by [code]node[/code] and [code]pack[/code] will therefore only save those two nodes, but not [code]collision[/code]. [b]Example of saving a node with different owners:[/b] The following example creates 3 objects: [Node2D] ([code]node[/code]), [RigidBody2D] ([code]body[/code]) and [CollisionObject2D] ([code]collision[/code]). [code]collision[/code] is a child of [code]body[/code] which is a child of [code]node[/code]. Only [code]body[/code] is owned by [code]node[/code] and [code]pack[/code] will therefore only save those two nodes, but not [code]collision[/code].
[codeblocks] [codeblocks]
[gdscript] [gdscript]
# Create the objects. # Create the objects.
var node = Node2D.new() var node = Node2D.new()
var body = RigidDynamicBody2D.new() var body = RigidBody2D.new()
var collision = CollisionShape2D.new() var collision = CollisionShape2D.new()
# Create the object hierarchy. # Create the object hierarchy.
@ -48,7 +48,7 @@
[csharp] [csharp]
// Create the objects. // Create the objects.
var node = new Node2D(); var node = new Node2D();
var body = new RigidDynamicBody2D(); var body = new RigidBody2D();
var collision = new CollisionShape2D(); var collision = new CollisionShape2D();
// Create the object hierarchy. // Create the object hierarchy.

View File

@ -409,7 +409,7 @@
No collision for particles. Particles will go through [GPUParticlesCollision3D] nodes. No collision for particles. Particles will go through [GPUParticlesCollision3D] nodes.
</constant> </constant>
<constant name="COLLISION_RIGID" value="1" enum="CollisionMode"> <constant name="COLLISION_RIGID" value="1" enum="CollisionMode">
[RigidDynamicBody3D]-style collision for particles using [GPUParticlesCollision3D] nodes. [RigidBody3D]-style collision for particles using [GPUParticlesCollision3D] nodes.
</constant> </constant>
<constant name="COLLISION_HIDE_ON_CONTACT" value="2" enum="CollisionMode"> <constant name="COLLISION_HIDE_ON_CONTACT" value="2" enum="CollisionMode">
Hide particles instantly when colliding with a [GPUParticlesCollision3D] node. This can be combined with a subemitter that uses the [constant COLLISION_RIGID] collision mode to "replace" the parent particle with the subemitter on impact. Hide particles instantly when colliding with a [GPUParticlesCollision3D] node. This can be combined with a subemitter that uses the [constant COLLISION_RIGID] collision mode to "replace" the parent particle with the subemitter on impact.

View File

@ -171,7 +171,7 @@
The amount of render buffer memory used (in bytes). [i]Lower is better.[/i] The amount of render buffer memory used (in bytes). [i]Lower is better.[/i]
</constant> </constant>
<constant name="PHYSICS_2D_ACTIVE_OBJECTS" value="16" enum="Monitor"> <constant name="PHYSICS_2D_ACTIVE_OBJECTS" value="16" enum="Monitor">
Number of active [RigidDynamicBody2D] nodes in the game. [i]Lower is better.[/i] Number of active [RigidBody2D] nodes in the game. [i]Lower is better.[/i]
</constant> </constant>
<constant name="PHYSICS_2D_COLLISION_PAIRS" value="17" enum="Monitor"> <constant name="PHYSICS_2D_COLLISION_PAIRS" value="17" enum="Monitor">
Number of collision pairs in the 2D physics engine. [i]Lower is better.[/i] Number of collision pairs in the 2D physics engine. [i]Lower is better.[/i]
@ -180,7 +180,7 @@
Number of islands in the 2D physics engine. [i]Lower is better.[/i] Number of islands in the 2D physics engine. [i]Lower is better.[/i]
</constant> </constant>
<constant name="PHYSICS_3D_ACTIVE_OBJECTS" value="19" enum="Monitor"> <constant name="PHYSICS_3D_ACTIVE_OBJECTS" value="19" enum="Monitor">
Number of active [RigidDynamicBody3D] and [VehicleBody3D] nodes in the game. [i]Lower is better.[/i] Number of active [RigidBody3D] and [VehicleBody3D] nodes in the game. [i]Lower is better.[/i]
</constant> </constant>
<constant name="PHYSICS_3D_COLLISION_PAIRS" value="20" enum="Monitor"> <constant name="PHYSICS_3D_COLLISION_PAIRS" value="20" enum="Monitor">
Number of collision pairs in the 3D physics engine. [i]Lower is better.[/i] Number of collision pairs in the 3D physics engine. [i]Lower is better.[/i]

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicalBone2D" inherits="RigidDynamicBody2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <class name="PhysicalBone2D" inherits="RigidBody2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description> <brief_description>
A 2D node that can be used for physically aware bones in 2D. A 2D node that can be used for physically aware bones in 2D.
</brief_description> </brief_description>
<description> <description>
The [code]PhysicalBone2D[/code] node is a [RigidDynamicBody2D]-based node that can be used to make [Bone2D] nodes in a [Skeleton2D] react to physics. This node is very similar to the [PhysicalBone3D] node, just for 2D instead of 3D. The [code]PhysicalBone2D[/code] node is a [RigidBody2D]-based node that can be used to make [Bone2D] nodes in a [Skeleton2D] react to physics. This node is very similar to the [PhysicalBone3D] node, just for 2D instead of 3D.
[b]Note:[/b] To have the Bone2D nodes visually follow the [code]PhysicalBone2D[/code] node, use a [SkeletonModification2DPhysicalBones] modification on the [Skeleton2D] node with the [Bone2D] nodes. [b]Note:[/b] To have the Bone2D nodes visually follow the [code]PhysicalBone2D[/code] node, use a [SkeletonModification2DPhysicalBones] modification on the [Skeleton2D] node with the [Bone2D] nodes.
[b]Note:[/b] The PhysicalBone2D node does not automatically create a [Joint2D] node to keep [code]PhysicalBone2D[/code] nodes together. You will need to create these manually. For most cases, you want to use a [PinJoint2D] node. The [code]PhysicalBone2D[/code] node can automatically configure the [Joint2D] node once it's been created as a child node. [b]Note:[/b] The PhysicalBone2D node does not automatically create a [Joint2D] node to keep [code]PhysicalBone2D[/code] nodes together. You will need to create these manually. For most cases, you want to use a [PinJoint2D] node. The [code]PhysicalBone2D[/code] node can automatically configure the [Joint2D] node once it's been created as a child node.
</description> </description>

View File

@ -4,7 +4,7 @@
Direct access object to a physics body in the [PhysicsServer2D]. Direct access object to a physics body in the [PhysicsServer2D].
</brief_description> </brief_description>
<description> <description>
Provides direct access to a physics body in the [PhysicsServer2D], allowing safe changes to physics properties. This object is passed via the direct state callback of dynamic bodies, and is intended for changing the direct state of that body. See [method RigidDynamicBody2D._integrate_forces]. Provides direct access to a physics body in the [PhysicsServer2D], allowing safe changes to physics properties. This object is passed via the direct state callback of rigid bodies, and is intended for changing the direct state of that body. See [method RigidBody2D._integrate_forces].
</description> </description>
<tutorials> <tutorials>
<link title="Physics introduction">$DOCS_URL/tutorials/physics/physics_introduction.html</link> <link title="Physics introduction">$DOCS_URL/tutorials/physics/physics_introduction.html</link>
@ -146,7 +146,7 @@
<return type="int" /> <return type="int" />
<description> <description>
Returns the number of contacts this body has with other bodies. Returns the number of contacts this body has with other bodies.
[b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidDynamicBody2D.contact_monitor]. [b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidBody2D.contact_monitor].
</description> </description>
</method> </method>
<method name="get_contact_local_normal" qualifiers="const"> <method name="get_contact_local_normal" qualifiers="const">

View File

@ -4,7 +4,7 @@
Direct access object to a physics body in the [PhysicsServer3D]. Direct access object to a physics body in the [PhysicsServer3D].
</brief_description> </brief_description>
<description> <description>
Provides direct access to a physics body in the [PhysicsServer3D], allowing safe changes to physics properties. This object is passed via the direct state callback of dynamic bodies, and is intended for changing the direct state of that body. See [method RigidDynamicBody3D._integrate_forces]. Provides direct access to a physics body in the [PhysicsServer3D], allowing safe changes to physics properties. This object is passed via the direct state callback of rigid bodies, and is intended for changing the direct state of that body. See [method RigidBody3D._integrate_forces].
</description> </description>
<tutorials> <tutorials>
<link title="Physics introduction">$DOCS_URL/tutorials/physics/physics_introduction.html</link> <link title="Physics introduction">$DOCS_URL/tutorials/physics/physics_introduction.html</link>
@ -146,7 +146,7 @@
<return type="int" /> <return type="int" />
<description> <description>
Returns the number of contacts this body has with other bodies. Returns the number of contacts this body has with other bodies.
[b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidDynamicBody3D.contact_monitor]. [b]Note:[/b] By default, this returns 0 unless bodies are configured to monitor contacts. See [member RigidBody3D.contact_monitor].
</description> </description>
</method> </method>
<method name="get_contact_impulse" qualifiers="const"> <method name="get_contact_impulse" qualifiers="const">

View File

@ -980,11 +980,11 @@
<constant name="BODY_MODE_KINEMATIC" value="1" enum="BodyMode"> <constant name="BODY_MODE_KINEMATIC" value="1" enum="BodyMode">
Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path. Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path.
</constant> </constant>
<constant name="BODY_MODE_DYNAMIC" value="2" enum="BodyMode"> <constant name="BODY_MODE_RIGID" value="2" enum="BodyMode">
Constant for dynamic bodies. In this mode, a body can be pushed by other bodies and has forces applied. Constant for rigid bodies. In this mode, a body can be pushed by other bodies and has forces applied.
</constant> </constant>
<constant name="BODY_MODE_DYNAMIC_LINEAR" value="3" enum="BodyMode"> <constant name="BODY_MODE_RIGID_LINEAR" value="3" enum="BodyMode">
Constant for linear dynamic bodies. In this mode, a body is dynamic but can not rotate, and only its linear velocity is affected by external forces. Constant for linear rigid bodies. In this mode, a body can not rotate, and only its linear velocity is affected by external forces.
</constant> </constant>
<constant name="BODY_PARAM_BOUNCE" value="0" enum="BodyParameter"> <constant name="BODY_PARAM_BOUNCE" value="0" enum="BodyParameter">
Constant to set/get a body's bounce factor. Constant to set/get a body's bounce factor.

View File

@ -1340,11 +1340,11 @@
<constant name="BODY_MODE_KINEMATIC" value="1" enum="BodyMode"> <constant name="BODY_MODE_KINEMATIC" value="1" enum="BodyMode">
Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path. Constant for kinematic bodies. In this mode, a body can be only moved by user code and collides with other bodies along its path.
</constant> </constant>
<constant name="BODY_MODE_DYNAMIC" value="2" enum="BodyMode"> <constant name="BODY_MODE_RIGID" value="2" enum="BodyMode">
Constant for dynamic bodies. In this mode, a body can be pushed by other bodies and has forces applied. Constant for rigid bodies. In this mode, a body can be pushed by other bodies and has forces applied.
</constant> </constant>
<constant name="BODY_MODE_DYNAMIC_LINEAR" value="3" enum="BodyMode"> <constant name="BODY_MODE_RIGID_LINEAR" value="3" enum="BodyMode">
Constant for linear dynamic bodies. In this mode, a body is dynamic but can not rotate, and only its linear velocity is affected by external forces. Constant for linear rigid bodies. In this mode, a body can not rotate, and only its linear velocity is affected by external forces.
</constant> </constant>
<constant name="BODY_PARAM_BOUNCE" value="0" enum="BodyParameter"> <constant name="BODY_PARAM_BOUNCE" value="0" enum="BodyParameter">
Constant to set/get a body's bounce factor. Constant to set/get a body's bounce factor.

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="RigidDynamicBody2D" inherits="PhysicsBody2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <class name="RigidBody2D" inherits="PhysicsBody2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description> <brief_description>
Physics Body which is moved by 2D physics simulation. Useful for objects that have gravity and can be pushed by other objects. Physics Body which is moved by 2D physics simulation. Useful for objects that have gravity and can be pushed by other objects.
</brief_description> </brief_description>
<description> <description>
This node implements simulated 2D physics. You do not control a RigidDynamicBody2D directly. Instead, you apply forces to it (gravity, impulses, etc.) and the physics simulation calculates the resulting movement based on its mass, friction, and other physical properties. This node implements simulated 2D physics. You do not control a RigidBody2D directly. Instead, you apply forces to it (gravity, impulses, etc.) and the physics simulation calculates the resulting movement based on its mass, friction, and other physical properties.
You can switch the body's behavior using [member lock_rotation], [member freeze], and [member freeze_mode]. You can switch the body's behavior using [member lock_rotation], [member freeze], and [member freeze_mode].
[b]Note:[/b] You should not change a RigidDynamicBody2D's [code]position[/code] or [code]linear_velocity[/code] every frame or even very often. If you need to directly affect the body's state, use [method _integrate_forces], which allows you to directly access the physics state. [b]Note:[/b] You should not change a RigidBody2D's [code]position[/code] or [code]linear_velocity[/code] every frame or even very often. If you need to directly affect the body's state, use [method _integrate_forces], which allows you to directly access the physics state.
Please also keep in mind that physics bodies manage their own transform which overwrites the ones you set. So any direct or indirect transformation (including scaling of the node or its parent) will be visible in the editor only, and immediately reset at runtime. Please also keep in mind that physics bodies manage their own transform which overwrites the ones you set. So any direct or indirect transformation (including scaling of the node or its parent) will be visible in the editor only, and immediately reset at runtime.
If you need to override the default physics behavior or add a transformation at runtime, you can write a custom force integration. See [member custom_integrator]. If you need to override the default physics behavior or add a transformation at runtime, you can write a custom force integration. See [member custom_integrator].
</description> </description>
@ -124,7 +124,7 @@
Damps the body's rotation. By default, the body will use the [b]Default Angular Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b] or any value override set by an [Area2D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value. Damps the body's rotation. By default, the body will use the [b]Default Angular Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b] or any value override set by an [Area2D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value.
See [member ProjectSettings.physics/2d/default_angular_damp] for more details about damping. See [member ProjectSettings.physics/2d/default_angular_damp] for more details about damping.
</member> </member>
<member name="angular_damp_mode" type="int" setter="set_angular_damp_mode" getter="get_angular_damp_mode" enum="RigidDynamicBody2D.DampMode" default="0"> <member name="angular_damp_mode" type="int" setter="set_angular_damp_mode" getter="get_angular_damp_mode" enum="RigidBody2D.DampMode" default="0">
Defines how [member angular_damp] is applied. See [enum DampMode] for possible values. Defines how [member angular_damp] is applied. See [enum DampMode] for possible values.
</member> </member>
<member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity" default="0.0"> <member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity" default="0.0">
@ -137,7 +137,7 @@
The body's custom center of mass, relative to the body's origin position, when [member center_of_mass_mode] is set to [constant CENTER_OF_MASS_MODE_CUSTOM]. This is the balanced point of the body, where applied forces only cause linear acceleration. Applying forces outside of the center of mass causes angular acceleration. The body's custom center of mass, relative to the body's origin position, when [member center_of_mass_mode] is set to [constant CENTER_OF_MASS_MODE_CUSTOM]. This is the balanced point of the body, where applied forces only cause linear acceleration. Applying forces outside of the center of mass causes angular acceleration.
When [member center_of_mass_mode] is set to [constant CENTER_OF_MASS_MODE_AUTO] (default value), the center of mass is automatically computed. When [member center_of_mass_mode] is set to [constant CENTER_OF_MASS_MODE_AUTO] (default value), the center of mass is automatically computed.
</member> </member>
<member name="center_of_mass_mode" type="int" setter="set_center_of_mass_mode" getter="get_center_of_mass_mode" enum="RigidDynamicBody2D.CenterOfMassMode" default="0"> <member name="center_of_mass_mode" type="int" setter="set_center_of_mass_mode" getter="get_center_of_mass_mode" enum="RigidBody2D.CenterOfMassMode" default="0">
Defines the way the body's center of mass is set. See [enum CenterOfMassMode] for possible values. Defines the way the body's center of mass is set. See [enum CenterOfMassMode] for possible values.
</member> </member>
<member name="constant_force" type="Vector2" setter="set_constant_force" getter="get_constant_force" default="Vector2(0, 0)"> <member name="constant_force" type="Vector2" setter="set_constant_force" getter="get_constant_force" default="Vector2(0, 0)">
@ -149,10 +149,10 @@
See [method add_constant_torque]. See [method add_constant_torque].
</member> </member>
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" default="false"> <member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" default="false">
If [code]true[/code], the RigidDynamicBody2D will emit signals when it collides with another RigidDynamicBody2D. If [code]true[/code], the RigidBody2D will emit signals when it collides with another RigidBody2D.
[b]Note:[/b] By default the maximum contacts reported is set to 0, meaning nothing will be recorded, see [member max_contacts_reported]. [b]Note:[/b] By default the maximum contacts reported is set to 0, meaning nothing will be recorded, see [member max_contacts_reported].
</member> </member>
<member name="continuous_cd" type="int" setter="set_continuous_collision_detection_mode" getter="get_continuous_collision_detection_mode" enum="RigidDynamicBody2D.CCDMode" default="0"> <member name="continuous_cd" type="int" setter="set_continuous_collision_detection_mode" getter="get_continuous_collision_detection_mode" enum="RigidBody2D.CCDMode" default="0">
Continuous collision detection mode. Continuous collision detection mode.
Continuous collision detection tries to predict where a moving body will collide instead of moving it and correcting its movement after collision. Continuous collision detection is slower, but more precise and misses fewer collisions with small, fast-moving objects. Raycasting and shapecasting methods are available. See [enum CCDMode] for details. Continuous collision detection tries to predict where a moving body will collide instead of moving it and correcting its movement after collision. Continuous collision detection is slower, but more precise and misses fewer collisions with small, fast-moving objects. Raycasting and shapecasting methods are available. See [enum CCDMode] for details.
</member> </member>
@ -164,7 +164,7 @@
See [member freeze_mode] to set the body's behavior when frozen. See [member freeze_mode] to set the body's behavior when frozen.
For a body that is always frozen, use [StaticBody2D] or [AnimatableBody2D] instead. For a body that is always frozen, use [StaticBody2D] or [AnimatableBody2D] instead.
</member> </member>
<member name="freeze_mode" type="int" setter="set_freeze_mode" getter="get_freeze_mode" enum="RigidDynamicBody2D.FreezeMode" default="0"> <member name="freeze_mode" type="int" setter="set_freeze_mode" getter="get_freeze_mode" enum="RigidBody2D.FreezeMode" default="0">
The body's freeze mode. Can be used to set the body's behavior when [member freeze] is enabled. See [enum FreezeMode] for possible values. The body's freeze mode. Can be used to set the body's behavior when [member freeze] is enabled. See [enum FreezeMode] for possible values.
For a body that is always frozen, use [StaticBody2D] or [AnimatableBody2D] instead. For a body that is always frozen, use [StaticBody2D] or [AnimatableBody2D] instead.
</member> </member>
@ -179,7 +179,7 @@
Damps the body's movement. By default, the body will use the [b]Default Linear Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b] or any value override set by an [Area2D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value. Damps the body's movement. By default, the body will use the [b]Default Linear Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 2d[/b] or any value override set by an [Area2D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value.
See [member ProjectSettings.physics/2d/default_linear_damp] for more details about damping. See [member ProjectSettings.physics/2d/default_linear_damp] for more details about damping.
</member> </member>
<member name="linear_damp_mode" type="int" setter="set_linear_damp_mode" getter="get_linear_damp_mode" enum="RigidDynamicBody2D.DampMode" default="0"> <member name="linear_damp_mode" type="int" setter="set_linear_damp_mode" getter="get_linear_damp_mode" enum="RigidBody2D.DampMode" default="0">
Defines how [member linear_damp] is applied. See [enum DampMode] for possible values. Defines how [member linear_damp] is applied. See [enum DampMode] for possible values.
</member> </member>
<member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2(0, 0)"> <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2(0, 0)">
@ -224,11 +224,11 @@
<param index="2" name="body_shape_index" type="int" /> <param index="2" name="body_shape_index" type="int" />
<param index="3" name="local_shape_index" type="int" /> <param index="3" name="local_shape_index" type="int" />
<description> <description>
Emitted when one of this RigidDynamicBody2D's [Shape2D]s collides with another [PhysicsBody2D] or [TileMap]'s [Shape2D]s. Requires [member contact_monitor] to be set to [code]true[/code] and [member max_contacts_reported] to be set high enough to detect all the collisions. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. Emitted when one of this RigidBody2D's [Shape2D]s collides with another [PhysicsBody2D] or [TileMap]'s [Shape2D]s. Requires [member contact_monitor] to be set to [code]true[/code] and [member max_contacts_reported] to be set high enough to detect all the collisions. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s.
[param body_rid] the [RID] of the other [PhysicsBody2D] or [TileSet]'s [CollisionObject2D] used by the [PhysicsServer2D]. [param body_rid] the [RID] of the other [PhysicsBody2D] or [TileSet]'s [CollisionObject2D] used by the [PhysicsServer2D].
[param body] the [Node], if it exists in the tree, of the other [PhysicsBody2D] or [TileMap]. [param body] the [Node], if it exists in the tree, of the other [PhysicsBody2D] or [TileMap].
[param body_shape_index] the index of the [Shape2D] of the other [PhysicsBody2D] or [TileMap] used by the [PhysicsServer2D]. Get the [CollisionShape2D] node with [code]body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))[/code]. [param body_shape_index] the index of the [Shape2D] of the other [PhysicsBody2D] or [TileMap] used by the [PhysicsServer2D]. Get the [CollisionShape2D] node with [code]body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))[/code].
[param local_shape_index] the index of the [Shape2D] of this RigidDynamicBody2D used by the [PhysicsServer2D]. Get the [CollisionShape2D] node with [code]self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))[/code]. [param local_shape_index] the index of the [Shape2D] of this RigidBody2D used by the [PhysicsServer2D]. Get the [CollisionShape2D] node with [code]self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))[/code].
</description> </description>
</signal> </signal>
<signal name="body_shape_exited"> <signal name="body_shape_exited">
@ -237,11 +237,11 @@
<param index="2" name="body_shape_index" type="int" /> <param index="2" name="body_shape_index" type="int" />
<param index="3" name="local_shape_index" type="int" /> <param index="3" name="local_shape_index" type="int" />
<description> <description>
Emitted when the collision between one of this RigidDynamicBody2D's [Shape2D]s and another [PhysicsBody2D] or [TileMap]'s [Shape2D]s ends. Requires [member contact_monitor] to be set to [code]true[/code] and [member max_contacts_reported] to be set high enough to detect all the collisions. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s. Emitted when the collision between one of this RigidBody2D's [Shape2D]s and another [PhysicsBody2D] or [TileMap]'s [Shape2D]s ends. Requires [member contact_monitor] to be set to [code]true[/code] and [member max_contacts_reported] to be set high enough to detect all the collisions. [TileMap]s are detected if the [TileSet] has Collision [Shape2D]s.
[param body_rid] the [RID] of the other [PhysicsBody2D] or [TileSet]'s [CollisionObject2D] used by the [PhysicsServer2D]. [param body_rid] the [RID] of the other [PhysicsBody2D] or [TileSet]'s [CollisionObject2D] used by the [PhysicsServer2D].
[param body] the [Node], if it exists in the tree, of the other [PhysicsBody2D] or [TileMap]. [param body] the [Node], if it exists in the tree, of the other [PhysicsBody2D] or [TileMap].
[param body_shape_index] the index of the [Shape2D] of the other [PhysicsBody2D] or [TileMap] used by the [PhysicsServer2D]. Get the [CollisionShape2D] node with [code]body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))[/code]. [param body_shape_index] the index of the [Shape2D] of the other [PhysicsBody2D] or [TileMap] used by the [PhysicsServer2D]. Get the [CollisionShape2D] node with [code]body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))[/code].
[param local_shape_index] the index of the [Shape2D] of this RigidDynamicBody2D used by the [PhysicsServer2D]. Get the [CollisionShape2D] node with [code]self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))[/code]. [param local_shape_index] the index of the [Shape2D] of this RigidBody2D used by the [PhysicsServer2D]. Get the [CollisionShape2D] node with [code]self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))[/code].
</description> </description>
</signal> </signal>
<signal name="sleeping_state_changed"> <signal name="sleeping_state_changed">

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="RigidDynamicBody3D" inherits="PhysicsBody3D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <class name="RigidBody3D" inherits="PhysicsBody3D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description> <brief_description>
Physics Body which is moved by 3D physics simulation. Useful for objects that have gravity and can be pushed by other objects. Physics Body which is moved by 3D physics simulation. Useful for objects that have gravity and can be pushed by other objects.
</brief_description> </brief_description>
<description> <description>
This is the node that implements full 3D physics. This means that you do not control a RigidDynamicBody3D directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc. This is the node that implements full 3D physics. This means that you do not control a RigidBody3D directly. Instead, you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
You can switch the body's behavior using [member lock_rotation], [member freeze], and [member freeze_mode]. You can switch the body's behavior using [member lock_rotation], [member freeze], and [member freeze_mode].
[b]Note:[/b] Don't change a RigidDynamicBody3D's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed Hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop may result in strange behavior. If you need to directly affect the body's state, use [method _integrate_forces], which allows you to directly access the physics state. [b]Note:[/b] Don't change a RigidBody3D's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed Hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop may result in strange behavior. If you need to directly affect the body's state, use [method _integrate_forces], which allows you to directly access the physics state.
If you need to override the default physics behavior, you can write a custom force integration function. See [member custom_integrator]. If you need to override the default physics behavior, you can write a custom force integration function. See [member custom_integrator].
</description> </description>
<tutorials> <tutorials>
@ -114,7 +114,7 @@
<method name="get_inverse_inertia_tensor" qualifiers="const"> <method name="get_inverse_inertia_tensor" qualifiers="const">
<return type="Basis" /> <return type="Basis" />
<description> <description>
Returns the inverse inertia tensor basis. This is used to calculate the angular acceleration resulting from a torque applied to the [RigidDynamicBody3D]. Returns the inverse inertia tensor basis. This is used to calculate the angular acceleration resulting from a torque applied to the [RigidBody3D].
</description> </description>
</method> </method>
<method name="set_axis_velocity"> <method name="set_axis_velocity">
@ -130,11 +130,11 @@
Damps the body's rotation. By default, the body will use the [b]Default Angular Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] or any value override set by an [Area3D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value. Damps the body's rotation. By default, the body will use the [b]Default Angular Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] or any value override set by an [Area3D] the body is in. Depending on [member angular_damp_mode], you can set [member angular_damp] to be added to or to replace the body's damping value.
See [member ProjectSettings.physics/3d/default_angular_damp] for more details about damping. See [member ProjectSettings.physics/3d/default_angular_damp] for more details about damping.
</member> </member>
<member name="angular_damp_mode" type="int" setter="set_angular_damp_mode" getter="get_angular_damp_mode" enum="RigidDynamicBody3D.DampMode" default="0"> <member name="angular_damp_mode" type="int" setter="set_angular_damp_mode" getter="get_angular_damp_mode" enum="RigidBody3D.DampMode" default="0">
Defines how [member angular_damp] is applied. See [enum DampMode] for possible values. Defines how [member angular_damp] is applied. See [enum DampMode] for possible values.
</member> </member>
<member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" default="Vector3(0, 0, 0)"> <member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" default="Vector3(0, 0, 0)">
The RigidDynamicBody3D's rotational velocity in [i]radians[/i] per second. The RigidBody3D's rotational velocity in [i]radians[/i] per second.
</member> </member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true"> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true">
If [code]true[/code], the body can enter sleep mode when there is no movement. See [member sleeping]. If [code]true[/code], the body can enter sleep mode when there is no movement. See [member sleeping].
@ -143,7 +143,7 @@
The body's custom center of mass, relative to the body's origin position, when [member center_of_mass_mode] is set to [constant CENTER_OF_MASS_MODE_CUSTOM]. This is the balanced point of the body, where applied forces only cause linear acceleration. Applying forces outside of the center of mass causes angular acceleration. The body's custom center of mass, relative to the body's origin position, when [member center_of_mass_mode] is set to [constant CENTER_OF_MASS_MODE_CUSTOM]. This is the balanced point of the body, where applied forces only cause linear acceleration. Applying forces outside of the center of mass causes angular acceleration.
When [member center_of_mass_mode] is set to [constant CENTER_OF_MASS_MODE_AUTO] (default value), the center of mass is automatically computed. When [member center_of_mass_mode] is set to [constant CENTER_OF_MASS_MODE_AUTO] (default value), the center of mass is automatically computed.
</member> </member>
<member name="center_of_mass_mode" type="int" setter="set_center_of_mass_mode" getter="get_center_of_mass_mode" enum="RigidDynamicBody3D.CenterOfMassMode" default="0"> <member name="center_of_mass_mode" type="int" setter="set_center_of_mass_mode" getter="get_center_of_mass_mode" enum="RigidBody3D.CenterOfMassMode" default="0">
Defines the way the body's center of mass is set. See [enum CenterOfMassMode] for possible values. Defines the way the body's center of mass is set. See [enum CenterOfMassMode] for possible values.
</member> </member>
<member name="constant_force" type="Vector3" setter="set_constant_force" getter="get_constant_force" default="Vector3(0, 0, 0)"> <member name="constant_force" type="Vector3" setter="set_constant_force" getter="get_constant_force" default="Vector3(0, 0, 0)">
@ -155,7 +155,7 @@
See [method add_constant_torque]. See [method add_constant_torque].
</member> </member>
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" default="false"> <member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" default="false">
If [code]true[/code], the RigidDynamicBody3D will emit signals when it collides with another RigidDynamicBody3D. If [code]true[/code], the RigidBody3D will emit signals when it collides with another RigidBody3D.
[b]Note:[/b] By default the maximum contacts reported is set to 0, meaning nothing will be recorded, see [member max_contacts_reported]. [b]Note:[/b] By default the maximum contacts reported is set to 0, meaning nothing will be recorded, see [member max_contacts_reported].
</member> </member>
<member name="continuous_cd" type="bool" setter="set_use_continuous_collision_detection" getter="is_using_continuous_collision_detection" default="false"> <member name="continuous_cd" type="bool" setter="set_use_continuous_collision_detection" getter="is_using_continuous_collision_detection" default="false">
@ -170,12 +170,12 @@
See [member freeze_mode] to set the body's behavior when frozen. See [member freeze_mode] to set the body's behavior when frozen.
For a body that is always frozen, use [StaticBody3D] or [AnimatableBody3D] instead. For a body that is always frozen, use [StaticBody3D] or [AnimatableBody3D] instead.
</member> </member>
<member name="freeze_mode" type="int" setter="set_freeze_mode" getter="get_freeze_mode" enum="RigidDynamicBody3D.FreezeMode" default="0"> <member name="freeze_mode" type="int" setter="set_freeze_mode" getter="get_freeze_mode" enum="RigidBody3D.FreezeMode" default="0">
The body's freeze mode. Can be used to set the body's behavior when [member freeze] is enabled. See [enum FreezeMode] for possible values. The body's freeze mode. Can be used to set the body's behavior when [member freeze] is enabled. See [enum FreezeMode] for possible values.
For a body that is always frozen, use [StaticBody3D] or [AnimatableBody3D] instead. For a body that is always frozen, use [StaticBody3D] or [AnimatableBody3D] instead.
</member> </member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0"> <member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0">
This is multiplied by the global 3D gravity setting found in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] to produce RigidDynamicBody3D's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object. This is multiplied by the global 3D gravity setting found in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] to produce RigidBody3D's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
</member> </member>
<member name="inertia" type="Vector3" setter="set_inertia" getter="get_inertia" default="Vector3(0, 0, 0)"> <member name="inertia" type="Vector3" setter="set_inertia" getter="get_inertia" default="Vector3(0, 0, 0)">
The body's moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body on each axis. The moment of inertia is usually computed automatically from the mass and the shapes, but this property allows you to set a custom value. The body's moment of inertia. This is like mass, but for rotation: it determines how much torque it takes to rotate the body on each axis. The moment of inertia is usually computed automatically from the mass and the shapes, but this property allows you to set a custom value.
@ -185,7 +185,7 @@
Damps the body's movement. By default, the body will use the [b]Default Linear Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] or any value override set by an [Area3D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value. Damps the body's movement. By default, the body will use the [b]Default Linear Damp[/b] in [b]Project &gt; Project Settings &gt; Physics &gt; 3d[/b] or any value override set by an [Area3D] the body is in. Depending on [member linear_damp_mode], you can set [member linear_damp] to be added to or to replace the body's damping value.
See [member ProjectSettings.physics/3d/default_linear_damp] for more details about damping. See [member ProjectSettings.physics/3d/default_linear_damp] for more details about damping.
</member> </member>
<member name="linear_damp_mode" type="int" setter="set_linear_damp_mode" getter="get_linear_damp_mode" enum="RigidDynamicBody3D.DampMode" default="0"> <member name="linear_damp_mode" type="int" setter="set_linear_damp_mode" getter="get_linear_damp_mode" enum="RigidBody3D.DampMode" default="0">
Defines how [member linear_damp] is applied. See [enum DampMode] for possible values. Defines how [member linear_damp] is applied. See [enum DampMode] for possible values.
</member> </member>
<member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)"> <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)">
@ -230,11 +230,11 @@
<param index="2" name="body_shape_index" type="int" /> <param index="2" name="body_shape_index" type="int" />
<param index="3" name="local_shape_index" type="int" /> <param index="3" name="local_shape_index" type="int" />
<description> <description>
Emitted when one of this RigidDynamicBody3D's [Shape3D]s collides with another [PhysicsBody3D] or [GridMap]'s [Shape3D]s. Requires [member contact_monitor] to be set to [code]true[/code] and [member max_contacts_reported] to be set high enough to detect all the collisions. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. Emitted when one of this RigidBody3D's [Shape3D]s collides with another [PhysicsBody3D] or [GridMap]'s [Shape3D]s. Requires [member contact_monitor] to be set to [code]true[/code] and [member max_contacts_reported] to be set high enough to detect all the collisions. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s.
[param body_rid] the [RID] of the other [PhysicsBody3D] or [MeshLibrary]'s [CollisionObject3D] used by the [PhysicsServer3D]. [param body_rid] the [RID] of the other [PhysicsBody3D] or [MeshLibrary]'s [CollisionObject3D] used by the [PhysicsServer3D].
[param body] the [Node], if it exists in the tree, of the other [PhysicsBody3D] or [GridMap]. [param body] the [Node], if it exists in the tree, of the other [PhysicsBody3D] or [GridMap].
[param body_shape_index] the index of the [Shape3D] of the other [PhysicsBody3D] or [GridMap] used by the [PhysicsServer3D]. Get the [CollisionShape3D] node with [code]body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))[/code]. [param body_shape_index] the index of the [Shape3D] of the other [PhysicsBody3D] or [GridMap] used by the [PhysicsServer3D]. Get the [CollisionShape3D] node with [code]body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))[/code].
[param local_shape_index] the index of the [Shape3D] of this RigidDynamicBody3D used by the [PhysicsServer3D]. Get the [CollisionShape3D] node with [code]self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))[/code]. [param local_shape_index] the index of the [Shape3D] of this RigidBody3D used by the [PhysicsServer3D]. Get the [CollisionShape3D] node with [code]self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))[/code].
</description> </description>
</signal> </signal>
<signal name="body_shape_exited"> <signal name="body_shape_exited">
@ -243,11 +243,11 @@
<param index="2" name="body_shape_index" type="int" /> <param index="2" name="body_shape_index" type="int" />
<param index="3" name="local_shape_index" type="int" /> <param index="3" name="local_shape_index" type="int" />
<description> <description>
Emitted when the collision between one of this RigidDynamicBody3D's [Shape3D]s and another [PhysicsBody3D] or [GridMap]'s [Shape3D]s ends. Requires [member contact_monitor] to be set to [code]true[/code] and [member max_contacts_reported] to be set high enough to detect all the collisions. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s. Emitted when the collision between one of this RigidBody3D's [Shape3D]s and another [PhysicsBody3D] or [GridMap]'s [Shape3D]s ends. Requires [member contact_monitor] to be set to [code]true[/code] and [member max_contacts_reported] to be set high enough to detect all the collisions. [GridMap]s are detected if the [MeshLibrary] has Collision [Shape3D]s.
[param body_rid] the [RID] of the other [PhysicsBody3D] or [MeshLibrary]'s [CollisionObject3D] used by the [PhysicsServer3D]. [GridMap]s are detected if the Meshes have [Shape3D]s. [param body_rid] the [RID] of the other [PhysicsBody3D] or [MeshLibrary]'s [CollisionObject3D] used by the [PhysicsServer3D]. [GridMap]s are detected if the Meshes have [Shape3D]s.
[param body] the [Node], if it exists in the tree, of the other [PhysicsBody3D] or [GridMap]. [param body] the [Node], if it exists in the tree, of the other [PhysicsBody3D] or [GridMap].
[param body_shape_index] the index of the [Shape3D] of the other [PhysicsBody3D] or [GridMap] used by the [PhysicsServer3D]. Get the [CollisionShape3D] node with [code]body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))[/code]. [param body_shape_index] the index of the [Shape3D] of the other [PhysicsBody3D] or [GridMap] used by the [PhysicsServer3D]. Get the [CollisionShape3D] node with [code]body.shape_owner_get_owner(body.shape_find_owner(body_shape_index))[/code].
[param local_shape_index] the index of the [Shape3D] of this RigidDynamicBody3D used by the [PhysicsServer3D]. Get the [CollisionShape3D] node with [code]self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))[/code]. [param local_shape_index] the index of the [Shape3D] of this RigidBody3D used by the [PhysicsServer3D]. Get the [CollisionShape3D] node with [code]self.shape_owner_get_owner(self.shape_find_owner(local_shape_index))[/code].
</description> </description>
</signal> </signal>
<signal name="sleeping_state_changed"> <signal name="sleeping_state_changed">

View File

@ -231,7 +231,7 @@
<param index="0" name="exception" type="RID" /> <param index="0" name="exception" type="RID" />
<description> <description>
Adds a collision exception to the physical bone. Adds a collision exception to the physical bone.
Works just like the [RigidDynamicBody3D] node. Works just like the [RigidBody3D] node.
</description> </description>
</method> </method>
<method name="physical_bones_remove_collision_exception"> <method name="physical_bones_remove_collision_exception">
@ -239,7 +239,7 @@
<param index="0" name="exception" type="RID" /> <param index="0" name="exception" type="RID" />
<description> <description>
Removes a collision exception to the physical bone. Removes a collision exception to the physical bone.
Works just like the [RigidDynamicBody3D] node. Works just like the [RigidBody3D] node.
</description> </description>
</method> </method>
<method name="physical_bones_start_simulation"> <method name="physical_bones_start_simulation">

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="SoftDynamicBody3D" inherits="MeshInstance3D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <class name="SoftBody3D" inherits="MeshInstance3D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description> <brief_description>
A soft mesh physics body. A soft mesh physics body.
</brief_description> </brief_description>
<description> <description>
A deformable physics body. Used to create elastic or deformable objects such as cloth, rubber, or other flexible materials. A deformable physics body. Used to create elastic or deformable objects such as cloth, rubber, or other flexible materials.
[b]Note:[/b] There are many known bugs in [SoftDynamicBody3D]. Therefore, it's not recommended to use them for things that can affect gameplay (such as a player character made entirely out of soft bodies). [b]Note:[/b] There are many known bugs in [SoftBody3D]. Therefore, it's not recommended to use them for things that can affect gameplay (such as a player character made entirely out of soft bodies).
</description> </description>
<tutorials> <tutorials>
<link title="SoftBody">$DOCS_URL/tutorials/physics/soft_body.html</link> <link title="SoftBody">$DOCS_URL/tutorials/physics/soft_body.html</link>
@ -92,16 +92,16 @@
</methods> </methods>
<members> <members>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1"> <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
The physics layers this SoftDynamicBody3D [b]is in[/b]. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask]. The physics layers this SoftBody3D [b]is in[/b]. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask].
[b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. [b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member> </member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The physics layers this SoftDynamicBody3D [b]scans[/b]. Collision objects can scan one or more of 32 different layers. See also [member collision_layer]. The physics layers this SoftBody3D [b]scans[/b]. Collision objects can scan one or more of 32 different layers. See also [member collision_layer].
[b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. [b]Note:[/b] Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
</member> </member>
<member name="damping_coefficient" type="float" setter="set_damping_coefficient" getter="get_damping_coefficient" default="0.01"> <member name="damping_coefficient" type="float" setter="set_damping_coefficient" getter="get_damping_coefficient" default="0.01">
</member> </member>
<member name="disable_mode" type="int" setter="set_disable_mode" getter="get_disable_mode" enum="SoftDynamicBody3D.DisableMode" default="0"> <member name="disable_mode" type="int" setter="set_disable_mode" getter="get_disable_mode" enum="SoftBody3D.DisableMode" default="0">
Defines the behavior in physics when [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED]. See [enum DisableMode] for more details about the different modes. Defines the behavior in physics when [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED]. See [enum DisableMode] for more details about the different modes.
</member> </member>
<member name="drag_coefficient" type="float" setter="set_drag_coefficient" getter="get_drag_coefficient" default="0.0"> <member name="drag_coefficient" type="float" setter="set_drag_coefficient" getter="get_drag_coefficient" default="0.0">
@ -109,23 +109,23 @@
<member name="linear_stiffness" type="float" setter="set_linear_stiffness" getter="get_linear_stiffness" default="0.5"> <member name="linear_stiffness" type="float" setter="set_linear_stiffness" getter="get_linear_stiffness" default="0.5">
</member> </member>
<member name="parent_collision_ignore" type="NodePath" setter="set_parent_collision_ignore" getter="get_parent_collision_ignore" default="NodePath(&quot;&quot;)"> <member name="parent_collision_ignore" type="NodePath" setter="set_parent_collision_ignore" getter="get_parent_collision_ignore" default="NodePath(&quot;&quot;)">
[NodePath] to a [CollisionObject3D] this SoftDynamicBody3D should avoid clipping. [NodePath] to a [CollisionObject3D] this SoftBody3D should avoid clipping.
</member> </member>
<member name="pressure_coefficient" type="float" setter="set_pressure_coefficient" getter="get_pressure_coefficient" default="0.0"> <member name="pressure_coefficient" type="float" setter="set_pressure_coefficient" getter="get_pressure_coefficient" default="0.0">
</member> </member>
<member name="ray_pickable" type="bool" setter="set_ray_pickable" getter="is_ray_pickable" default="true"> <member name="ray_pickable" type="bool" setter="set_ray_pickable" getter="is_ray_pickable" default="true">
If [code]true[/code], the [SoftDynamicBody3D] will respond to [RayCast3D]s. If [code]true[/code], the [SoftBody3D] will respond to [RayCast3D]s.
</member> </member>
<member name="simulation_precision" type="int" setter="set_simulation_precision" getter="get_simulation_precision" default="5"> <member name="simulation_precision" type="int" setter="set_simulation_precision" getter="get_simulation_precision" default="5">
Increasing this value will improve the resulting simulation, but can affect performance. Use with care. Increasing this value will improve the resulting simulation, but can affect performance. Use with care.
</member> </member>
<member name="total_mass" type="float" setter="set_total_mass" getter="get_total_mass" default="1.0"> <member name="total_mass" type="float" setter="set_total_mass" getter="get_total_mass" default="1.0">
The SoftDynamicBody3D's mass. The SoftBody3D's mass.
</member> </member>
</members> </members>
<constants> <constants>
<constant name="DISABLE_MODE_REMOVE" value="0" enum="DisableMode"> <constant name="DISABLE_MODE_REMOVE" value="0" enum="DisableMode">
When [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED], remove from the physics simulation to stop all physics interactions with this [SoftDynamicBody3D]. When [member Node.process_mode] is set to [constant Node.PROCESS_MODE_DISABLED], remove from the physics simulation to stop all physics interactions with this [SoftBody3D].
Automatically re-added to the physics simulation when the [Node] is processed again. Automatically re-added to the physics simulation when the [Node] is processed again.
</constant> </constant>
<constant name="DISABLE_MODE_KEEP_ACTIVE" value="1" enum="DisableMode"> <constant name="DISABLE_MODE_KEEP_ACTIVE" value="1" enum="DisableMode">

View File

@ -5,7 +5,7 @@
</brief_description> </brief_description>
<description> <description>
Static body for 2D physics. Static body for 2D physics.
A static body is a simple body that can't be moved by external forces or contacts. It is ideal for implementing objects in the environment, such as walls or platforms. In contrast to [RigidDynamicBody2D], it doesn't consume any CPU resources as long as they don't move. A static body is a simple body that can't be moved by external forces or contacts. It is ideal for implementing objects in the environment, such as walls or platforms. In contrast to [RigidBody2D], it doesn't consume any CPU resources as long as they don't move.
They have extra functionalities to move and affect other bodies: They have extra functionalities to move and affect other bodies:
[b]Static transform change:[/b] Static bodies can be moved by animation or script. In this case, they are just teleported and don't affect other bodies on their path. [b]Static transform change:[/b] Static bodies can be moved by animation or script. In this case, they are just teleported and don't affect other bodies on their path.
[b]Constant velocity:[/b] When [member constant_linear_velocity] or [member constant_angular_velocity] is set, static bodies don't move themselves but affect touching bodies as if they were moving. This is useful for simulating conveyor belts or conveyor wheels. [b]Constant velocity:[/b] When [member constant_linear_velocity] or [member constant_angular_velocity] is set, static bodies don't move themselves but affect touching bodies as if they were moving. This is useful for simulating conveyor belts or conveyor wheels.

View File

@ -5,7 +5,7 @@
</brief_description> </brief_description>
<description> <description>
Static body for 3D physics. Static body for 3D physics.
A static body is a simple body that can't be moved by external forces or contacts. It is ideal for implementing objects in the environment, such as walls or platforms. In contrast to [RigidDynamicBody3D], it doesn't consume any CPU resources as long as they don't move. A static body is a simple body that can't be moved by external forces or contacts. It is ideal for implementing objects in the environment, such as walls or platforms. In contrast to [RigidBody3D], it doesn't consume any CPU resources as long as they don't move.
They have extra functionalities to move and affect other bodies: They have extra functionalities to move and affect other bodies:
[b]Static transform change:[/b] Static bodies can be moved by animation or script. In this case, they are just teleported and don't affect other bodies on their path. [b]Static transform change:[/b] Static bodies can be moved by animation or script. In this case, they are just teleported and don't affect other bodies on their path.
[b]Constant velocity:[/b] When [member constant_linear_velocity] or [member constant_angular_velocity] is set, static bodies don't move themselves but affect touching bodies as if they were moving. This is useful for simulating conveyor belts or conveyor wheels. [b]Constant velocity:[/b] When [member constant_linear_velocity] or [member constant_angular_velocity] is set, static bodies don't move themselves but affect touching bodies as if they were moving. This is useful for simulating conveyor belts or conveyor wheels.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="VehicleBody3D" inherits="RigidDynamicBody3D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <class name="VehicleBody3D" inherits="RigidBody3D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description> <brief_description>
Physics body that simulates the behavior of a car. Physics body that simulates the behavior of a car.
</brief_description> </brief_description>
@ -13,14 +13,14 @@
</tutorials> </tutorials>
<members> <members>
<member name="brake" type="float" setter="set_brake" getter="get_brake" default="0.0"> <member name="brake" type="float" setter="set_brake" getter="get_brake" default="0.0">
Slows down the vehicle by applying a braking force. The vehicle is only slowed down if the wheels are in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the [member RigidDynamicBody3D.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking. Slows down the vehicle by applying a braking force. The vehicle is only slowed down if the wheels are in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the [member RigidBody3D.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking.
</member> </member>
<member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0"> <member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0">
Accelerates the vehicle by applying an engine force. The vehicle is only sped up if the wheels that have [member VehicleWheel3D.use_as_traction] set to [code]true[/code] and are in contact with a surface. The [member RigidDynamicBody3D.mass] of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration. Accelerates the vehicle by applying an engine force. The vehicle is only sped up if the wheels that have [member VehicleWheel3D.use_as_traction] set to [code]true[/code] and are in contact with a surface. The [member RigidBody3D.mass] of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration.
[b]Note:[/b] The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears. [b]Note:[/b] The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears.
A negative value will result in the vehicle reversing. A negative value will result in the vehicle reversing.
</member> </member>
<member name="mass" type="float" setter="set_mass" getter="get_mass" overrides="RigidDynamicBody3D" default="40.0" /> <member name="mass" type="float" setter="set_mass" getter="get_mass" overrides="RigidBody3D" default="40.0" />
<member name="steering" type="float" setter="set_steering" getter="get_steering" default="0.0"> <member name="steering" type="float" setter="set_steering" getter="get_steering" default="0.0">
The steering angle for the vehicle, in radians. Setting this to a non-zero value will result in the vehicle turning when it's moving. Wheels that have [member VehicleWheel3D.use_as_steering] set to [code]true[/code] will automatically be rotated. The steering angle for the vehicle, in radians. Setting this to a non-zero value will result in the vehicle turning when it's moving. Wheels that have [member VehicleWheel3D.use_as_steering] set to [code]true[/code] will automatically be rotated.
</member> </member>

View File

@ -39,7 +39,7 @@
</methods> </methods>
<members> <members>
<member name="brake" type="float" setter="set_brake" getter="get_brake" default="0.0"> <member name="brake" type="float" setter="set_brake" getter="get_brake" default="0.0">
Slows down the wheel by applying a braking force. The wheel is only slowed down if it is in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the [member RigidDynamicBody3D.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking. Slows down the wheel by applying a braking force. The wheel is only slowed down if it is in contact with a surface. The force you need to apply to adequately slow down your vehicle depends on the [member RigidBody3D.mass] of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 30 range for hard braking.
</member> </member>
<member name="damping_compression" type="float" setter="set_damping_compression" getter="get_damping_compression" default="0.83"> <member name="damping_compression" type="float" setter="set_damping_compression" getter="get_damping_compression" default="0.83">
The damping applied to the spring when the spring is being compressed. This value should be between 0.0 (no damping) and 1.0. A value of 0.0 means the car will keep bouncing as the spring keeps its energy. A good value for this is around 0.3 for a normal car, 0.5 for a race car. The damping applied to the spring when the spring is being compressed. This value should be between 0.0 (no damping) and 1.0. A value of 0.0 means the car will keep bouncing as the spring keeps its energy. A good value for this is around 0.3 for a normal car, 0.5 for a race car.
@ -48,7 +48,7 @@
The damping applied to the spring when relaxing. This value should be between 0.0 (no damping) and 1.0. This value should always be slightly higher than the [member damping_compression] property. For a [member damping_compression] value of 0.3, try a relaxation value of 0.5. The damping applied to the spring when relaxing. This value should be between 0.0 (no damping) and 1.0. This value should always be slightly higher than the [member damping_compression] property. For a [member damping_compression] value of 0.3, try a relaxation value of 0.5.
</member> </member>
<member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0"> <member name="engine_force" type="float" setter="set_engine_force" getter="get_engine_force" default="0.0">
Accelerates the wheel by applying an engine force. The wheel is only sped up if it is in contact with a surface. The [member RigidDynamicBody3D.mass] of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration. Accelerates the wheel by applying an engine force. The wheel is only sped up if it is in contact with a surface. The [member RigidBody3D.mass] of the vehicle has an effect on the acceleration of the vehicle. For a vehicle with a mass set to 1000, try a value in the 25 - 50 range for acceleration.
[b]Note:[/b] The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears. [b]Note:[/b] The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears.
A negative value will result in the wheel reversing. A negative value will result in the wheel reversing.
</member> </member>
@ -56,7 +56,7 @@
The steering angle for the wheel, in radians. Setting this to a non-zero value will result in the vehicle turning when it's moving. The steering angle for the wheel, in radians. Setting this to a non-zero value will result in the vehicle turning when it's moving.
</member> </member>
<member name="suspension_max_force" type="float" setter="set_suspension_max_force" getter="get_suspension_max_force" default="6000.0"> <member name="suspension_max_force" type="float" setter="set_suspension_max_force" getter="get_suspension_max_force" default="6000.0">
The maximum force the spring can resist. This value should be higher than a quarter of the [member RigidDynamicBody3D.mass] of the [VehicleBody3D] or the spring will not carry the weight of the vehicle. Good results are often obtained by a value that is about 3× to 4× this number. The maximum force the spring can resist. This value should be higher than a quarter of the [member RigidBody3D.mass] of the [VehicleBody3D] or the spring will not carry the weight of the vehicle. Good results are often obtained by a value that is about 3× to 4× this number.
</member> </member>
<member name="suspension_stiffness" type="float" setter="set_suspension_stiffness" getter="get_suspension_stiffness" default="5.88"> <member name="suspension_stiffness" type="float" setter="set_suspension_stiffness" getter="get_suspension_stiffness" default="5.88">
This value defines the stiffness of the suspension. Use a value lower than 50 for an off-road car, a value between 50 and 100 for a race car and try something around 200 for something like a Formula 1 car. This value defines the stiffness of the suspension. Use a value lower than 50 for an off-road car, a value between 50 and 100 for a race car and try something around 200 for something like a Formula 1 car.

View File

@ -4,7 +4,7 @@
Enables certain nodes only when approximately visible. Enables certain nodes only when approximately visible.
</brief_description> </brief_description>
<description> <description>
The VisibleOnScreenEnabler3D will disable [RigidDynamicBody3D] and [AnimationPlayer] nodes when they are not visible. It will only affect other nodes within the same scene as the VisibleOnScreenEnabler3D itself. The VisibleOnScreenEnabler3D will disable [RigidBody3D] and [AnimationPlayer] nodes when they are not visible. It will only affect other nodes within the same scene as the VisibleOnScreenEnabler3D itself.
If you just want to receive notifications, use [VisibleOnScreenNotifier3D] instead. If you just want to receive notifications, use [VisibleOnScreenNotifier3D] instead.
[b]Note:[/b] VisibleOnScreenEnabler3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node and/or [method Vector3.dot]. [b]Note:[/b] VisibleOnScreenEnabler3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node and/or [method Vector3.dot].
[b]Note:[/b] VisibleOnScreenEnabler3D will not affect nodes added after scene initialization. [b]Note:[/b] VisibleOnScreenEnabler3D will not affect nodes added after scene initialization.

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 224 B

After

Width:  |  Height:  |  Size: 224 B

View File

@ -565,7 +565,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, HashMap<R
_pre_gen_shape_list(mesh, shapes, true); _pre_gen_shape_list(mesh, shapes, true);
} }
RigidDynamicBody3D *rigid_body = memnew(RigidDynamicBody3D); RigidBody3D *rigid_body = memnew(RigidBody3D);
rigid_body->set_name(_fixstr(name, "rigid_body")); rigid_body->set_name(_fixstr(name, "rigid_body"));
p_node->replace_by(rigid_body); p_node->replace_by(rigid_body);
rigid_body->set_transform(mi->get_transform()); rigid_body->set_transform(mi->get_transform());
@ -1060,7 +1060,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, HashMap<
base = col; base = col;
} break; } break;
case MESH_PHYSICS_RIGID_BODY_AND_MESH: { case MESH_PHYSICS_RIGID_BODY_AND_MESH: {
RigidDynamicBody3D *rigid_body = memnew(RigidDynamicBody3D); RigidBody3D *rigid_body = memnew(RigidBody3D);
rigid_body->set_name(p_node->get_name()); rigid_body->set_name(p_node->get_name());
p_node->replace_by(rigid_body); p_node->replace_by(rigid_body);
rigid_body->set_transform(mi->get_transform() * get_collision_shapes_transform(node_settings)); rigid_body->set_transform(mi->get_transform() * get_collision_shapes_transform(node_settings));

View File

@ -59,7 +59,7 @@
#include "scene/3d/ray_cast_3d.h" #include "scene/3d/ray_cast_3d.h"
#include "scene/3d/reflection_probe.h" #include "scene/3d/reflection_probe.h"
#include "scene/3d/shape_cast_3d.h" #include "scene/3d/shape_cast_3d.h"
#include "scene/3d/soft_dynamic_body_3d.h" #include "scene/3d/soft_body_3d.h"
#include "scene/3d/spring_arm_3d.h" #include "scene/3d/spring_arm_3d.h"
#include "scene/3d/sprite_3d.h" #include "scene/3d/sprite_3d.h"
#include "scene/3d/vehicle_body_3d.h" #include "scene/3d/vehicle_body_3d.h"
@ -1944,7 +1944,7 @@ MeshInstance3DGizmoPlugin::MeshInstance3DGizmoPlugin() {
} }
bool MeshInstance3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { bool MeshInstance3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<MeshInstance3D>(p_spatial) != nullptr && Object::cast_to<SoftDynamicBody3D>(p_spatial) == nullptr; return Object::cast_to<MeshInstance3D>(p_spatial) != nullptr && Object::cast_to<SoftBody3D>(p_spatial) == nullptr;
} }
String MeshInstance3DGizmoPlugin::get_gizmo_name() const { String MeshInstance3DGizmoPlugin::get_gizmo_name() const {
@ -2687,30 +2687,30 @@ void VehicleWheel3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
/////////// ///////////
SoftDynamicBody3DGizmoPlugin::SoftDynamicBody3DGizmoPlugin() { SoftBody3DGizmoPlugin::SoftBody3DGizmoPlugin() {
Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape");
create_material("shape_material", gizmo_color); create_material("shape_material", gizmo_color);
create_handle_material("handles"); create_handle_material("handles");
} }
bool SoftDynamicBody3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { bool SoftBody3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<SoftDynamicBody3D>(p_spatial) != nullptr; return Object::cast_to<SoftBody3D>(p_spatial) != nullptr;
} }
String SoftDynamicBody3DGizmoPlugin::get_gizmo_name() const { String SoftBody3DGizmoPlugin::get_gizmo_name() const {
return "SoftDynamicBody3D"; return "SoftBody3D";
} }
int SoftDynamicBody3DGizmoPlugin::get_priority() const { int SoftBody3DGizmoPlugin::get_priority() const {
return -1; return -1;
} }
bool SoftDynamicBody3DGizmoPlugin::is_selectable_when_hidden() const { bool SoftBody3DGizmoPlugin::is_selectable_when_hidden() const {
return true; return true;
} }
void SoftDynamicBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { void SoftBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
SoftDynamicBody3D *soft_body = Object::cast_to<SoftDynamicBody3D>(p_gizmo->get_spatial_node()); SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
p_gizmo->clear(); p_gizmo->clear();
@ -2746,22 +2746,22 @@ void SoftDynamicBody3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->add_collision_triangles(tm); p_gizmo->add_collision_triangles(tm);
} }
String SoftDynamicBody3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const { String SoftBody3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
return "SoftDynamicBody3D pin point"; return "SoftBody3D pin point";
} }
Variant SoftDynamicBody3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const { Variant SoftBody3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
SoftDynamicBody3D *soft_body = Object::cast_to<SoftDynamicBody3D>(p_gizmo->get_spatial_node()); SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
return Variant(soft_body->is_point_pinned(p_id)); return Variant(soft_body->is_point_pinned(p_id));
} }
void SoftDynamicBody3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) { void SoftBody3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
SoftDynamicBody3D *soft_body = Object::cast_to<SoftDynamicBody3D>(p_gizmo->get_spatial_node()); SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
soft_body->pin_point_toggle(p_id); soft_body->pin_point_toggle(p_id);
} }
bool SoftDynamicBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const { bool SoftBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
SoftDynamicBody3D *soft_body = Object::cast_to<SoftDynamicBody3D>(p_gizmo->get_spatial_node()); SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_spatial_node());
return soft_body->is_point_pinned(p_id); return soft_body->is_point_pinned(p_id);
} }

View File

@ -409,8 +409,8 @@ public:
VehicleWheel3DGizmoPlugin(); VehicleWheel3DGizmoPlugin();
}; };
class SoftDynamicBody3DGizmoPlugin : public EditorNode3DGizmoPlugin { class SoftBody3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(SoftDynamicBody3DGizmoPlugin, EditorNode3DGizmoPlugin); GDCLASS(SoftBody3DGizmoPlugin, EditorNode3DGizmoPlugin);
public: public:
bool has_gizmo(Node3D *p_spatial) override; bool has_gizmo(Node3D *p_spatial) override;
@ -424,7 +424,7 @@ public:
void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override; void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override;
bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const override; bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const override;
SoftDynamicBody3DGizmoPlugin(); SoftBody3DGizmoPlugin();
}; };
class VisibleOnScreenNotifier3DGizmoPlugin : public EditorNode3DGizmoPlugin { class VisibleOnScreenNotifier3DGizmoPlugin : public EditorNode3DGizmoPlugin {

View File

@ -7500,7 +7500,7 @@ void Node3DEditor::_register_all_gizmos() {
add_gizmo_plugin(Ref<AudioListener3DGizmoPlugin>(memnew(AudioListener3DGizmoPlugin))); add_gizmo_plugin(Ref<AudioListener3DGizmoPlugin>(memnew(AudioListener3DGizmoPlugin)));
add_gizmo_plugin(Ref<MeshInstance3DGizmoPlugin>(memnew(MeshInstance3DGizmoPlugin))); add_gizmo_plugin(Ref<MeshInstance3DGizmoPlugin>(memnew(MeshInstance3DGizmoPlugin)));
add_gizmo_plugin(Ref<OccluderInstance3DGizmoPlugin>(memnew(OccluderInstance3DGizmoPlugin))); add_gizmo_plugin(Ref<OccluderInstance3DGizmoPlugin>(memnew(OccluderInstance3DGizmoPlugin)));
add_gizmo_plugin(Ref<SoftDynamicBody3DGizmoPlugin>(memnew(SoftDynamicBody3DGizmoPlugin))); add_gizmo_plugin(Ref<SoftBody3DGizmoPlugin>(memnew(SoftBody3DGizmoPlugin)));
add_gizmo_plugin(Ref<Sprite3DGizmoPlugin>(memnew(Sprite3DGizmoPlugin))); add_gizmo_plugin(Ref<Sprite3DGizmoPlugin>(memnew(Sprite3DGizmoPlugin)));
add_gizmo_plugin(Ref<Label3DGizmoPlugin>(memnew(Label3DGizmoPlugin))); add_gizmo_plugin(Ref<Label3DGizmoPlugin>(memnew(Label3DGizmoPlugin)));
add_gizmo_plugin(Ref<Marker3DGizmoPlugin>(memnew(Marker3DGizmoPlugin))); add_gizmo_plugin(Ref<Marker3DGizmoPlugin>(memnew(Marker3DGizmoPlugin)));

View File

@ -76,8 +76,7 @@ static const char *enum_renames[][2] = {
{ "ARVR_STEREO", "XR_STEREO" }, // XRInterface { "ARVR_STEREO", "XR_STEREO" }, // XRInterface
{ "ARVR_UNKNOWN_TRACKING", "XR_UNKNOWN_TRACKING" }, // XRInterface { "ARVR_UNKNOWN_TRACKING", "XR_UNKNOWN_TRACKING" }, // XRInterface
{ "BAKE_ERROR_INVALID_MESH", "BAKE_ERROR_MESHES_INVALID" }, // LightmapGI { "BAKE_ERROR_INVALID_MESH", "BAKE_ERROR_MESHES_INVALID" }, // LightmapGI
{ "BODY_MODE_CHARACTER", "BODY_MODE_DYNAMIC" }, // PhysicsServer2D { "BODY_MODE_CHARACTER", "BODY_MODE_RIGID_LINEAR" }, // PhysicsServer
{ "BODY_MODE_DYNAMIC_LOCKED", "BODY_MODE_DYNAMIC_LINEAR" }, // PhysicsServer3D
{ "BUTTON_LEFT", "MOUSE_BUTTON_LEFT" }, // Globals { "BUTTON_LEFT", "MOUSE_BUTTON_LEFT" }, // Globals
{ "BUTTON_MASK_LEFT", "MOUSE_BUTTON_MASK_LEFT" }, // Globals { "BUTTON_MASK_LEFT", "MOUSE_BUTTON_MASK_LEFT" }, // Globals
{ "BUTTON_MASK_MIDDLE", "MOUSE_BUTTON_MASK_MIDDLE" }, // Globals { "BUTTON_MASK_MIDDLE", "MOUSE_BUTTON_MASK_MIDDLE" }, // Globals
@ -125,15 +124,13 @@ static const char *enum_renames[][2] = {
{ "MATH_RAND", "MATH_RANDF_RANGE" }, // VisualScriptBuiltinFunc { "MATH_RAND", "MATH_RANDF_RANGE" }, // VisualScriptBuiltinFunc
{ "MATH_RANDOM", "MATH_RANDI_RANGE" }, // VisualScriptBuiltinFunc { "MATH_RANDOM", "MATH_RANDI_RANGE" }, // VisualScriptBuiltinFunc
{ "MATH_STEPIFY", "MATH_STEP_DECIMALS" }, // VisualScriptBuiltinFunc { "MATH_STEPIFY", "MATH_STEP_DECIMALS" }, // VisualScriptBuiltinFunc
{ "MODE_CHARACTER", "MODE_DYNAMIC_LOCKED" }, // RigidBody2D, RigidBody3D { "MODE_KINEMATIC", "FREEZE_MODE_KINEMATIC" }, // RigidBody
{ "MODE_KINEMATIC", "FREEZE_MODE_KINEMATIC" }, // RigidDynamicBody
{ "MODE_OPEN_ANY", "FILE_MODE_OPEN_ANY" }, // FileDialog { "MODE_OPEN_ANY", "FILE_MODE_OPEN_ANY" }, // FileDialog
{ "MODE_OPEN_DIR", "FILE_MODE_OPEN_DIR" }, // FileDialog { "MODE_OPEN_DIR", "FILE_MODE_OPEN_DIR" }, // FileDialog
{ "MODE_OPEN_FILE", "FILE_MODE_OPEN_FILE" }, // FileDialog { "MODE_OPEN_FILE", "FILE_MODE_OPEN_FILE" }, // FileDialog
{ "MODE_OPEN_FILES", "FILE_MODE_OPEN_FILES" }, // FileDialog { "MODE_OPEN_FILES", "FILE_MODE_OPEN_FILES" }, // FileDialog
{ "MODE_RIGID", "MODE_DYNAMIC" }, // RigidBody2D, RigidBody3D
{ "MODE_SAVE_FILE", "FILE_MODE_SAVE_FILE" }, // FileDialog { "MODE_SAVE_FILE", "FILE_MODE_SAVE_FILE" }, // FileDialog
{ "MODE_STATIC", "FREEZE_MODE_STATIC" }, // RigidDynamicBody { "MODE_STATIC", "FREEZE_MODE_STATIC" }, // RigidBody
{ "NOTIFICATION_APP_PAUSED", "NOTIFICATION_APPLICATION_PAUSED" }, // MainLoop { "NOTIFICATION_APP_PAUSED", "NOTIFICATION_APPLICATION_PAUSED" }, // MainLoop
{ "NOTIFICATION_APP_RESUMED", "NOTIFICATION_APPLICATION_RESUMED" }, // MainLoop { "NOTIFICATION_APP_RESUMED", "NOTIFICATION_APPLICATION_RESUMED" }, // MainLoop
{ "NOTIFICATION_PATH_CHANGED", "NOTIFICATION_PATH_RENAMED" }, //Node { "NOTIFICATION_PATH_CHANGED", "NOTIFICATION_PATH_RENAMED" }, //Node
@ -221,16 +218,16 @@ static const char *gdscript_function_renames[][2] = {
{ "_update_wrap_at", "_update_wrap_at_column" }, // TextEdit { "_update_wrap_at", "_update_wrap_at_column" }, // TextEdit
{ "add_animation", "add_animation_library" }, // AnimationPlayer { "add_animation", "add_animation_library" }, // AnimationPlayer
{ "add_cancel", "add_cancel_button" }, // AcceptDialog { "add_cancel", "add_cancel_button" }, // AcceptDialog
{ "add_central_force", "apply_central_force" }, //RigidDynamicBody2D { "add_central_force", "apply_central_force" }, //RigidBody2D
{ "add_child_below_node", "add_sibling" }, // Node { "add_child_below_node", "add_sibling" }, // Node
{ "add_color_override", "add_theme_color_override" }, // Control { "add_color_override", "add_theme_color_override" }, // Control
{ "add_constant_override", "add_theme_constant_override" }, // Control { "add_constant_override", "add_theme_constant_override" }, // Control
{ "add_font_override", "add_theme_font_override" }, // Control { "add_font_override", "add_theme_font_override" }, // Control
{ "add_force", "apply_force" }, //RigidDynamicBody2D { "add_force", "apply_force" }, //RigidBody2D
{ "add_icon_override", "add_theme_icon_override" }, // Control { "add_icon_override", "add_theme_icon_override" }, // Control
{ "add_scene_import_plugin", "add_scene_format_importer_plugin" }, //EditorPlugin { "add_scene_import_plugin", "add_scene_format_importer_plugin" }, //EditorPlugin
{ "add_stylebox_override", "add_theme_stylebox_override" }, // Control { "add_stylebox_override", "add_theme_stylebox_override" }, // Control
{ "add_torque", "apply_torque" }, //RigidDynamicBody2D { "add_torque", "apply_torque" }, //RigidBody2D
{ "apply_changes", "_apply_changes" }, // EditorPlugin { "apply_changes", "_apply_changes" }, // EditorPlugin
{ "bind_child_node_to_bone", "set_bone_children" }, // Skeleton3D { "bind_child_node_to_bone", "set_bone_children" }, // Skeleton3D
{ "body_add_force", "body_apply_force" }, // PhysicsServer2D { "body_add_force", "body_apply_force" }, // PhysicsServer2D
@ -276,8 +273,8 @@ static const char *gdscript_function_renames[][2] = {
{ "get_action_list", "action_get_events" }, // InputMap { "get_action_list", "action_get_events" }, // InputMap
{ "get_alt", "is_alt_pressed" }, // InputEventWithModifiers { "get_alt", "is_alt_pressed" }, // InputEventWithModifiers
{ "get_animation_process_mode", "get_process_callback" }, // AnimationPlayer { "get_animation_process_mode", "get_process_callback" }, // AnimationPlayer
{ "get_applied_force", "get_constant_force" }, //RigidDynamicBody2D { "get_applied_force", "get_constant_force" }, //RigidBody2D
{ "get_applied_torque", "get_constant_torque" }, //RigidDynamicBody2D { "get_applied_torque", "get_constant_torque" }, //RigidBody2D
{ "get_audio_bus", "get_audio_bus_name" }, // Area3D { "get_audio_bus", "get_audio_bus_name" }, // Area3D
{ "get_bound_child_nodes_to_bone", "get_bone_children" }, // Skeleton3D { "get_bound_child_nodes_to_bone", "get_bone_children" }, // Skeleton3D
{ "get_camera", "get_camera_3d" }, // Viewport -> this is also convertable to get_camera_2d, broke GLTFNode { "get_camera", "get_camera_3d" }, // Viewport -> this is also convertable to get_camera_2d, broke GLTFNode
@ -631,16 +628,16 @@ static const char *csharp_function_renames[][2] = {
{ "_UpdateWrapAt", "_UpdateWrapAtColumn" }, // TextEdit { "_UpdateWrapAt", "_UpdateWrapAtColumn" }, // TextEdit
{ "AddAnimation", "AddAnimationLibrary" }, // AnimationPlayer { "AddAnimation", "AddAnimationLibrary" }, // AnimationPlayer
{ "AddCancel", "AddCancelButton" }, // AcceptDialog { "AddCancel", "AddCancelButton" }, // AcceptDialog
{ "AddCentralForce", "AddConstantCentralForce" }, //RigidDynamicBody2D { "AddCentralForce", "AddConstantCentralForce" }, //RigidBody2D
{ "AddChildBelowNode", "AddSibling" }, // Node { "AddChildBelowNode", "AddSibling" }, // Node
{ "AddColorOverride", "AddThemeColorOverride" }, // Control { "AddColorOverride", "AddThemeColorOverride" }, // Control
{ "AddConstantOverride", "AddThemeConstantOverride" }, // Control { "AddConstantOverride", "AddThemeConstantOverride" }, // Control
{ "AddFontOverride", "AddThemeFontOverride" }, // Control { "AddFontOverride", "AddThemeFontOverride" }, // Control
{ "AddForce", "AddConstantForce" }, //RigidDynamicBody2D { "AddForce", "AddConstantForce" }, //RigidBody2D
{ "AddIconOverride", "AddThemeIconOverride" }, // Control { "AddIconOverride", "AddThemeIconOverride" }, // Control
{ "AddSceneImportPlugin", "AddSceneFormatImporterPlugin" }, //EditorPlugin { "AddSceneImportPlugin", "AddSceneFormatImporterPlugin" }, //EditorPlugin
{ "AddStyleboxOverride", "AddThemeStyleboxOverride" }, // Control { "AddStyleboxOverride", "AddThemeStyleboxOverride" }, // Control
{ "AddTorque", "AddConstantTorque" }, //RigidDynamicBody2D { "AddTorque", "AddConstantTorque" }, //RigidBody2D
{ "BindChildNodeToBone", "SetBoneChildren" }, // Skeleton3D { "BindChildNodeToBone", "SetBoneChildren" }, // Skeleton3D
{ "BumpmapToNormalmap", "BumpMapToNormalMap" }, // Image { "BumpmapToNormalmap", "BumpMapToNormalMap" }, // Image
{ "CanBeHidden", "_CanBeHidden" }, // EditorNode3DGizmoPlugin { "CanBeHidden", "_CanBeHidden" }, // EditorNode3DGizmoPlugin
@ -679,8 +676,8 @@ static const char *csharp_function_renames[][2] = {
{ "GetActionList", "ActionGetEvents" }, // InputMap { "GetActionList", "ActionGetEvents" }, // InputMap
{ "GetAlt", "IsAltPressed" }, // InputEventWithModifiers { "GetAlt", "IsAltPressed" }, // InputEventWithModifiers
{ "GetAnimationProcessMode", "GetProcessCallback" }, // AnimationPlayer { "GetAnimationProcessMode", "GetProcessCallback" }, // AnimationPlayer
{ "GetAppliedForce", "GetConstantForce" }, //RigidDynamicBody2D { "GetAppliedForce", "GetConstantForce" }, //RigidBody2D
{ "GetAppliedTorque", "GetConstantTorque" }, //RigidDynamicBody2D { "GetAppliedTorque", "GetConstantTorque" }, //RigidBody2D
{ "GetAudioBus", "GetAudioBusName" }, // Area3D { "GetAudioBus", "GetAudioBusName" }, // Area3D
{ "GetBoundChildNodesToBone", "GetBoneChildren" }, // Skeleton3D { "GetBoundChildNodesToBone", "GetBoneChildren" }, // Skeleton3D
{ "GetCamera", "GetCamera3d" }, // Viewport -> this is also convertable to getCamera2d, broke GLTFNode { "GetCamera", "GetCamera3d" }, // Viewport -> this is also convertable to getCamera2d, broke GLTFNode
@ -997,7 +994,7 @@ static const char *gdscript_properties_renames[][2] = {
{ "close_h_ofs", "close_h_offset" }, // Theme { "close_h_ofs", "close_h_offset" }, // Theme
{ "close_v_ofs", "close_v_offset" }, // Theme { "close_v_ofs", "close_v_offset" }, // Theme
{ "commentfocus", "comment_focus" }, // Theme { "commentfocus", "comment_focus" }, // Theme
{ "contacts_reported", "max_contacts_reported" }, // RigidDynamicBody { "contacts_reported", "max_contacts_reported" }, // RigidBody
{ "drag_margin_bottom", "drag_bottom_margin" }, // Camera2D { "drag_margin_bottom", "drag_bottom_margin" }, // Camera2D
{ "drag_margin_h_enabled", "drag_horizontal_enabled" }, // Camera2D { "drag_margin_h_enabled", "drag_horizontal_enabled" }, // Camera2D
{ "drag_margin_left", "drag_left_margin" }, // Camera2D { "drag_margin_left", "drag_left_margin" }, // Camera2D
@ -1385,15 +1382,14 @@ static const char *class_renames[][2] = {
{ "Reference", "RefCounted" }, // Be careful, this will be used everywhere { "Reference", "RefCounted" }, // Be careful, this will be used everywhere
{ "RemoteTransform", "RemoteTransform3D" }, { "RemoteTransform", "RemoteTransform3D" },
{ "ResourceInteractiveLoader", "ResourceLoader" }, { "ResourceInteractiveLoader", "ResourceLoader" },
{ "RigidBody", "RigidDynamicBody3D" }, { "RigidBody", "RigidBody3D" },
{ "RigidBody2D", "RigidDynamicBody2D" },
{ "SceneTreeTween", "Tween" }, { "SceneTreeTween", "Tween" },
{ "Shape", "Shape3D" }, // Be careful, this will be used everywhere { "Shape", "Shape3D" }, // Be careful, this will be used everywhere
{ "ShortCut", "Shortcut" }, { "ShortCut", "Shortcut" },
{ "Skeleton", "Skeleton3D" }, { "Skeleton", "Skeleton3D" },
{ "SkeletonIK", "SkeletonIK3D" }, { "SkeletonIK", "SkeletonIK3D" },
{ "SliderJoint", "SliderJoint3D" }, { "SliderJoint", "SliderJoint3D" },
{ "SoftBody", "SoftDynamicBody3D" }, { "SoftBody", "SoftBody3D" },
{ "Spatial", "Node3D" }, { "Spatial", "Node3D" },
{ "SpatialGizmo", "Node3DGizmo" }, { "SpatialGizmo", "Node3DGizmo" },
{ "SpatialMaterial", "StandardMaterial3D" }, { "SpatialMaterial", "StandardMaterial3D" },

View File

@ -6,7 +6,7 @@ extends _BASE_
const SPEED = 300.0 const SPEED = 300.0
const JUMP_VELOCITY = -400.0 const JUMP_VELOCITY = -400.0
# Get the gravity from the project settings to be synced with RigidDynamicBody nodes. # Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity") var gravity: int = ProjectSettings.get_setting("physics/2d/default_gravity")

View File

@ -6,7 +6,7 @@ extends _BASE_
const SPEED = 5.0 const SPEED = 5.0
const JUMP_VELOCITY = 4.5 const JUMP_VELOCITY = 4.5
# Get the gravity from the project settings to be synced with RigidDynamicBody nodes. # Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity") var gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity")

View File

@ -8,7 +8,7 @@ public partial class _CLASS_ : _BASE_
public const float Speed = 300.0f; public const float Speed = 300.0f;
public const float JumpVelocity = -400.0f; public const float JumpVelocity = -400.0f;
// Get the gravity from the project settings to be synced with RigidDynamicBody nodes. // Get the gravity from the project settings to be synced with RigidBody nodes.
public float gravity = ProjectSettings.GetSetting("physics/2d/default_gravity").AsSingle(); public float gravity = ProjectSettings.GetSetting("physics/2d/default_gravity").AsSingle();
public override void _PhysicsProcess(float delta) public override void _PhysicsProcess(float delta)

View File

@ -8,7 +8,7 @@ public partial class _CLASS_ : _BASE_
public const float Speed = 5.0f; public const float Speed = 5.0f;
public const float JumpVelocity = 4.5f; public const float JumpVelocity = 4.5f;
// Get the gravity from the project settings to be synced with RigidDynamicBody nodes. // Get the gravity from the project settings to be synced with RigidBody nodes.
public float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle(); public float gravity = ProjectSettings.GetSetting("physics/3d/default_gravity").AsSingle();
public override void _PhysicsProcess(float delta) public override void _PhysicsProcess(float delta)

View File

@ -239,7 +239,7 @@ TypedArray<String> CollisionPolygon2D::get_configuration_warnings() const {
TypedArray<String> warnings = Node::get_configuration_warnings(); TypedArray<String> warnings = Node::get_configuration_warnings();
if (!Object::cast_to<CollisionObject2D>(get_parent())) { if (!Object::cast_to<CollisionObject2D>(get_parent())) {
warnings.push_back(RTR("CollisionPolygon2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidDynamicBody2D, CharacterBody2D, etc. to give them a shape.")); warnings.push_back(RTR("CollisionPolygon2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, CharacterBody2D, etc. to give them a shape."));
} }
int polygon_count = polygon.size(); int polygon_count = polygon.size();

View File

@ -172,7 +172,7 @@ TypedArray<String> CollisionShape2D::get_configuration_warnings() const {
TypedArray<String> warnings = Node::get_configuration_warnings(); TypedArray<String> warnings = Node::get_configuration_warnings();
if (!Object::cast_to<CollisionObject2D>(get_parent())) { if (!Object::cast_to<CollisionObject2D>(get_parent())) {
warnings.push_back(RTR("CollisionShape2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidDynamicBody2D, CharacterBody2D, etc. to give them a shape.")); warnings.push_back(RTR("CollisionShape2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, CharacterBody2D, etc. to give them a shape."));
} }
if (!shape.is_valid()) { if (!shape.is_valid()) {
warnings.push_back(RTR("A shape must be provided for CollisionShape2D to function. Please create a shape resource for it!")); warnings.push_back(RTR("A shape must be provided for CollisionShape2D to function. Please create a shape resource for it!"));

View File

@ -127,7 +127,7 @@ TypedArray<String> NavigationObstacle2D::get_configuration_warnings() const {
} }
if (Object::cast_to<StaticBody2D>(get_parent())) { if (Object::cast_to<StaticBody2D>(get_parent())) {
warnings.push_back(RTR("The NavigationObstacle2D is intended for constantly moving bodies like CharacterBody2D or RigidDynamicBody2D as it creates only an RVO avoidance radius and does not follow scene geometry exactly." warnings.push_back(RTR("The NavigationObstacle2D is intended for constantly moving bodies like CharacterBody2D or RigidBody2D as it creates only an RVO avoidance radius and does not follow scene geometry exactly."
"\nNot constantly moving or complete static objects should be captured with a refreshed NavigationPolygon so agents can not only avoid them but also move along those objects outline at high detail")); "\nNot constantly moving or complete static objects should be captured with a refreshed NavigationPolygon so agents can not only avoid them but also move along those objects outline at high detail"));
} }

View File

@ -35,7 +35,7 @@
void PhysicalBone2D::_notification(int p_what) { void PhysicalBone2D::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
// Position the RigidDynamicBody in the correct position. // Position the RigidBody in the correct position.
if (follow_bone_when_simulating) { if (follow_bone_when_simulating) {
_position_at_bone2d(); _position_at_bone2d();
} }
@ -287,7 +287,7 @@ void PhysicalBone2D::_bind_methods() {
} }
PhysicalBone2D::PhysicalBone2D() { PhysicalBone2D::PhysicalBone2D() {
// Stop the RigidDynamicBody from executing its force integration. // Stop the RigidBody from executing its force integration.
PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), 0); PhysicsServer2D::get_singleton()->body_set_collision_layer(get_rid(), 0);
PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), 0); PhysicsServer2D::get_singleton()->body_set_collision_mask(get_rid(), 0);
PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BodyMode::BODY_MODE_STATIC); PhysicsServer2D::get_singleton()->body_set_mode(get_rid(), PhysicsServer2D::BodyMode::BODY_MODE_STATIC);

View File

@ -36,8 +36,8 @@
class Joint2D; class Joint2D;
class PhysicalBone2D : public RigidDynamicBody2D { class PhysicalBone2D : public RigidBody2D {
GDCLASS(PhysicalBone2D, RigidDynamicBody2D); GDCLASS(PhysicalBone2D, RigidBody2D);
protected: protected:
void _notification(int p_what); void _notification(int p_what);

View File

@ -325,7 +325,7 @@ AnimatableBody2D::AnimatableBody2D() :
StaticBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) { StaticBody2D(PhysicsServer2D::BODY_MODE_KINEMATIC) {
} }
void RigidDynamicBody2D::_body_enter_tree(ObjectID p_id) { void RigidBody2D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id); Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj); Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node); ERR_FAIL_COND(!node);
@ -347,7 +347,7 @@ void RigidDynamicBody2D::_body_enter_tree(ObjectID p_id) {
contact_monitor->locked = false; contact_monitor->locked = false;
} }
void RigidDynamicBody2D::_body_exit_tree(ObjectID p_id) { void RigidBody2D::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id); Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj); Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node); ERR_FAIL_COND(!node);
@ -368,7 +368,7 @@ void RigidDynamicBody2D::_body_exit_tree(ObjectID p_id) {
contact_monitor->locked = false; contact_monitor->locked = false;
} }
void RigidDynamicBody2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_local_shape) { void RigidBody2D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_local_shape) {
bool body_in = p_status == 1; bool body_in = p_status == 1;
ObjectID objid = p_instance; ObjectID objid = p_instance;
@ -387,8 +387,8 @@ void RigidDynamicBody2D::_body_inout(int p_status, const RID &p_body, ObjectID p
//E->value.rc=0; //E->value.rc=0;
E->value.in_scene = node && node->is_inside_tree(); E->value.in_scene = node && node->is_inside_tree();
if (node) { if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidDynamicBody2D::_body_enter_tree).bind(objid)); node->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody2D::_body_enter_tree).bind(objid));
node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidDynamicBody2D::_body_exit_tree).bind(objid)); node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody2D::_body_exit_tree).bind(objid));
if (E->value.in_scene) { if (E->value.in_scene) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node); emit_signal(SceneStringNames::get_singleton()->body_entered, node);
} }
@ -416,8 +416,8 @@ void RigidDynamicBody2D::_body_inout(int p_status, const RID &p_body, ObjectID p
if (E->value.shapes.is_empty()) { if (E->value.shapes.is_empty()) {
if (node) { if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidDynamicBody2D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody2D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidDynamicBody2D::_body_exit_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody2D::_body_exit_tree));
if (in_scene) { if (in_scene) {
emit_signal(SceneStringNames::get_singleton()->body_exited, node); emit_signal(SceneStringNames::get_singleton()->body_exited, node);
} }
@ -431,19 +431,19 @@ void RigidDynamicBody2D::_body_inout(int p_status, const RID &p_body, ObjectID p
} }
} }
struct _RigidDynamicBody2DInOut { struct _RigidBody2DInOut {
RID rid; RID rid;
ObjectID id; ObjectID id;
int shape = 0; int shape = 0;
int local_shape = 0; int local_shape = 0;
}; };
void RigidDynamicBody2D::_body_state_changed_callback(void *p_instance, PhysicsDirectBodyState2D *p_state) { void RigidBody2D::_body_state_changed_callback(void *p_instance, PhysicsDirectBodyState2D *p_state) {
RigidDynamicBody2D *body = static_cast<RigidDynamicBody2D *>(p_instance); RigidBody2D *body = static_cast<RigidBody2D *>(p_instance);
body->_body_state_changed(p_state); body->_body_state_changed(p_state);
} }
void RigidDynamicBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state) { void RigidBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state) {
set_block_transform_notify(true); // don't want notify (would feedback loop) set_block_transform_notify(true); // don't want notify (would feedback loop)
if (!freeze || freeze_mode != FREEZE_MODE_KINEMATIC) { if (!freeze || freeze_mode != FREEZE_MODE_KINEMATIC) {
set_global_transform(p_state->get_transform()); set_global_transform(p_state->get_transform());
@ -473,9 +473,9 @@ void RigidDynamicBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state)
} }
} }
_RigidDynamicBody2DInOut *toadd = (_RigidDynamicBody2DInOut *)alloca(p_state->get_contact_count() * sizeof(_RigidDynamicBody2DInOut)); _RigidBody2DInOut *toadd = (_RigidBody2DInOut *)alloca(p_state->get_contact_count() * sizeof(_RigidBody2DInOut));
int toadd_count = 0; //state->get_contact_count(); int toadd_count = 0; //state->get_contact_count();
RigidDynamicBody2D_RemoveAction *toremove = (RigidDynamicBody2D_RemoveAction *)alloca(rc * sizeof(RigidDynamicBody2D_RemoveAction)); RigidBody2D_RemoveAction *toremove = (RigidBody2D_RemoveAction *)alloca(rc * sizeof(RigidBody2D_RemoveAction));
int toremove_count = 0; int toremove_count = 0;
//put the ones to add //put the ones to add
@ -539,7 +539,7 @@ void RigidDynamicBody2D::_body_state_changed(PhysicsDirectBodyState2D *p_state)
} }
} }
void RigidDynamicBody2D::_apply_body_mode() { void RigidBody2D::_apply_body_mode() {
if (freeze) { if (freeze) {
switch (freeze_mode) { switch (freeze_mode) {
case FREEZE_MODE_STATIC: { case FREEZE_MODE_STATIC: {
@ -550,13 +550,13 @@ void RigidDynamicBody2D::_apply_body_mode() {
} break; } break;
} }
} else if (lock_rotation) { } else if (lock_rotation) {
set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC_LINEAR); set_body_mode(PhysicsServer2D::BODY_MODE_RIGID_LINEAR);
} else { } else {
set_body_mode(PhysicsServer2D::BODY_MODE_DYNAMIC); set_body_mode(PhysicsServer2D::BODY_MODE_RIGID);
} }
} }
void RigidDynamicBody2D::set_lock_rotation_enabled(bool p_lock_rotation) { void RigidBody2D::set_lock_rotation_enabled(bool p_lock_rotation) {
if (p_lock_rotation == lock_rotation) { if (p_lock_rotation == lock_rotation) {
return; return;
} }
@ -565,11 +565,11 @@ void RigidDynamicBody2D::set_lock_rotation_enabled(bool p_lock_rotation) {
_apply_body_mode(); _apply_body_mode();
} }
bool RigidDynamicBody2D::is_lock_rotation_enabled() const { bool RigidBody2D::is_lock_rotation_enabled() const {
return lock_rotation; return lock_rotation;
} }
void RigidDynamicBody2D::set_freeze_enabled(bool p_freeze) { void RigidBody2D::set_freeze_enabled(bool p_freeze) {
if (p_freeze == freeze) { if (p_freeze == freeze) {
return; return;
} }
@ -578,11 +578,11 @@ void RigidDynamicBody2D::set_freeze_enabled(bool p_freeze) {
_apply_body_mode(); _apply_body_mode();
} }
bool RigidDynamicBody2D::is_freeze_enabled() const { bool RigidBody2D::is_freeze_enabled() const {
return freeze; return freeze;
} }
void RigidDynamicBody2D::set_freeze_mode(FreezeMode p_freeze_mode) { void RigidBody2D::set_freeze_mode(FreezeMode p_freeze_mode) {
if (p_freeze_mode == freeze_mode) { if (p_freeze_mode == freeze_mode) {
return; return;
} }
@ -591,31 +591,31 @@ void RigidDynamicBody2D::set_freeze_mode(FreezeMode p_freeze_mode) {
_apply_body_mode(); _apply_body_mode();
} }
RigidDynamicBody2D::FreezeMode RigidDynamicBody2D::get_freeze_mode() const { RigidBody2D::FreezeMode RigidBody2D::get_freeze_mode() const {
return freeze_mode; return freeze_mode;
} }
void RigidDynamicBody2D::set_mass(real_t p_mass) { void RigidBody2D::set_mass(real_t p_mass) {
ERR_FAIL_COND(p_mass <= 0); ERR_FAIL_COND(p_mass <= 0);
mass = p_mass; mass = p_mass;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_MASS, mass); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_MASS, mass);
} }
real_t RigidDynamicBody2D::get_mass() const { real_t RigidBody2D::get_mass() const {
return mass; return mass;
} }
void RigidDynamicBody2D::set_inertia(real_t p_inertia) { void RigidBody2D::set_inertia(real_t p_inertia) {
ERR_FAIL_COND(p_inertia < 0); ERR_FAIL_COND(p_inertia < 0);
inertia = p_inertia; inertia = p_inertia;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA, inertia); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_INERTIA, inertia);
} }
real_t RigidDynamicBody2D::get_inertia() const { real_t RigidBody2D::get_inertia() const {
return inertia; return inertia;
} }
void RigidDynamicBody2D::set_center_of_mass_mode(CenterOfMassMode p_mode) { void RigidBody2D::set_center_of_mass_mode(CenterOfMassMode p_mode) {
if (center_of_mass_mode == p_mode) { if (center_of_mass_mode == p_mode) {
return; return;
} }
@ -637,11 +637,11 @@ void RigidDynamicBody2D::set_center_of_mass_mode(CenterOfMassMode p_mode) {
} }
} }
RigidDynamicBody2D::CenterOfMassMode RigidDynamicBody2D::get_center_of_mass_mode() const { RigidBody2D::CenterOfMassMode RigidBody2D::get_center_of_mass_mode() const {
return center_of_mass_mode; return center_of_mass_mode;
} }
void RigidDynamicBody2D::set_center_of_mass(const Vector2 &p_center_of_mass) { void RigidBody2D::set_center_of_mass(const Vector2 &p_center_of_mass) {
if (center_of_mass == p_center_of_mass) { if (center_of_mass == p_center_of_mass) {
return; return;
} }
@ -652,102 +652,102 @@ void RigidDynamicBody2D::set_center_of_mass(const Vector2 &p_center_of_mass) {
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS, center_of_mass); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
} }
const Vector2 &RigidDynamicBody2D::get_center_of_mass() const { const Vector2 &RigidBody2D::get_center_of_mass() const {
return center_of_mass; return center_of_mass;
} }
void RigidDynamicBody2D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) { void RigidBody2D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) { if (physics_material_override.is_valid()) {
if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidDynamicBody2D::_reload_physics_characteristics))) { if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody2D::_reload_physics_characteristics))) {
physics_material_override->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidDynamicBody2D::_reload_physics_characteristics)); physics_material_override->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody2D::_reload_physics_characteristics));
} }
} }
physics_material_override = p_physics_material_override; physics_material_override = p_physics_material_override;
if (physics_material_override.is_valid()) { if (physics_material_override.is_valid()) {
physics_material_override->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidDynamicBody2D::_reload_physics_characteristics)); physics_material_override->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody2D::_reload_physics_characteristics));
} }
_reload_physics_characteristics(); _reload_physics_characteristics();
} }
Ref<PhysicsMaterial> RigidDynamicBody2D::get_physics_material_override() const { Ref<PhysicsMaterial> RigidBody2D::get_physics_material_override() const {
return physics_material_override; return physics_material_override;
} }
void RigidDynamicBody2D::set_gravity_scale(real_t p_gravity_scale) { void RigidBody2D::set_gravity_scale(real_t p_gravity_scale) {
gravity_scale = p_gravity_scale; gravity_scale = p_gravity_scale;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE, gravity_scale); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
} }
real_t RigidDynamicBody2D::get_gravity_scale() const { real_t RigidBody2D::get_gravity_scale() const {
return gravity_scale; return gravity_scale;
} }
void RigidDynamicBody2D::set_linear_damp_mode(DampMode p_mode) { void RigidBody2D::set_linear_damp_mode(DampMode p_mode) {
linear_damp_mode = p_mode; linear_damp_mode = p_mode;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode);
} }
RigidDynamicBody2D::DampMode RigidDynamicBody2D::get_linear_damp_mode() const { RigidBody2D::DampMode RigidBody2D::get_linear_damp_mode() const {
return linear_damp_mode; return linear_damp_mode;
} }
void RigidDynamicBody2D::set_angular_damp_mode(DampMode p_mode) { void RigidBody2D::set_angular_damp_mode(DampMode p_mode) {
angular_damp_mode = p_mode; angular_damp_mode = p_mode;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode);
} }
RigidDynamicBody2D::DampMode RigidDynamicBody2D::get_angular_damp_mode() const { RigidBody2D::DampMode RigidBody2D::get_angular_damp_mode() const {
return angular_damp_mode; return angular_damp_mode;
} }
void RigidDynamicBody2D::set_linear_damp(real_t p_linear_damp) { void RigidBody2D::set_linear_damp(real_t p_linear_damp) {
ERR_FAIL_COND(p_linear_damp < -1); ERR_FAIL_COND(p_linear_damp < -1);
linear_damp = p_linear_damp; linear_damp = p_linear_damp;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP, linear_damp); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_LINEAR_DAMP, linear_damp);
} }
real_t RigidDynamicBody2D::get_linear_damp() const { real_t RigidBody2D::get_linear_damp() const {
return linear_damp; return linear_damp;
} }
void RigidDynamicBody2D::set_angular_damp(real_t p_angular_damp) { void RigidBody2D::set_angular_damp(real_t p_angular_damp) {
ERR_FAIL_COND(p_angular_damp < -1); ERR_FAIL_COND(p_angular_damp < -1);
angular_damp = p_angular_damp; angular_damp = p_angular_damp;
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP, angular_damp); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_ANGULAR_DAMP, angular_damp);
} }
real_t RigidDynamicBody2D::get_angular_damp() const { real_t RigidBody2D::get_angular_damp() const {
return angular_damp; return angular_damp;
} }
void RigidDynamicBody2D::set_axis_velocity(const Vector2 &p_axis) { void RigidBody2D::set_axis_velocity(const Vector2 &p_axis) {
Vector2 axis = p_axis.normalized(); Vector2 axis = p_axis.normalized();
linear_velocity -= axis * axis.dot(linear_velocity); linear_velocity -= axis * axis.dot(linear_velocity);
linear_velocity += p_axis; linear_velocity += p_axis;
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity); PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
} }
void RigidDynamicBody2D::set_linear_velocity(const Vector2 &p_velocity) { void RigidBody2D::set_linear_velocity(const Vector2 &p_velocity) {
linear_velocity = p_velocity; linear_velocity = p_velocity;
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity); PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
} }
Vector2 RigidDynamicBody2D::get_linear_velocity() const { Vector2 RigidBody2D::get_linear_velocity() const {
return linear_velocity; return linear_velocity;
} }
void RigidDynamicBody2D::set_angular_velocity(real_t p_velocity) { void RigidBody2D::set_angular_velocity(real_t p_velocity) {
angular_velocity = p_velocity; angular_velocity = p_velocity;
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity); PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
} }
real_t RigidDynamicBody2D::get_angular_velocity() const { real_t RigidBody2D::get_angular_velocity() const {
return angular_velocity; return angular_velocity;
} }
void RigidDynamicBody2D::set_use_custom_integrator(bool p_enable) { void RigidBody2D::set_use_custom_integrator(bool p_enable) {
if (custom_integrator == p_enable) { if (custom_integrator == p_enable) {
return; return;
} }
@ -756,105 +756,105 @@ void RigidDynamicBody2D::set_use_custom_integrator(bool p_enable) {
PhysicsServer2D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable); PhysicsServer2D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
} }
bool RigidDynamicBody2D::is_using_custom_integrator() { bool RigidBody2D::is_using_custom_integrator() {
return custom_integrator; return custom_integrator;
} }
void RigidDynamicBody2D::set_sleeping(bool p_sleeping) { void RigidBody2D::set_sleeping(bool p_sleeping) {
sleeping = p_sleeping; sleeping = p_sleeping;
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_SLEEPING, sleeping); PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_SLEEPING, sleeping);
} }
void RigidDynamicBody2D::set_can_sleep(bool p_active) { void RigidBody2D::set_can_sleep(bool p_active) {
can_sleep = p_active; can_sleep = p_active;
PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_CAN_SLEEP, p_active); PhysicsServer2D::get_singleton()->body_set_state(get_rid(), PhysicsServer2D::BODY_STATE_CAN_SLEEP, p_active);
} }
bool RigidDynamicBody2D::is_able_to_sleep() const { bool RigidBody2D::is_able_to_sleep() const {
return can_sleep; return can_sleep;
} }
bool RigidDynamicBody2D::is_sleeping() const { bool RigidBody2D::is_sleeping() const {
return sleeping; return sleeping;
} }
void RigidDynamicBody2D::set_max_contacts_reported(int p_amount) { void RigidBody2D::set_max_contacts_reported(int p_amount) {
max_contacts_reported = p_amount; max_contacts_reported = p_amount;
PhysicsServer2D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount); PhysicsServer2D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
} }
int RigidDynamicBody2D::get_max_contacts_reported() const { int RigidBody2D::get_max_contacts_reported() const {
return max_contacts_reported; return max_contacts_reported;
} }
int RigidDynamicBody2D::get_contact_count() const { int RigidBody2D::get_contact_count() const {
PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(get_rid()); PhysicsDirectBodyState2D *bs = PhysicsServer2D::get_singleton()->body_get_direct_state(get_rid());
ERR_FAIL_NULL_V(bs, 0); ERR_FAIL_NULL_V(bs, 0);
return bs->get_contact_count(); return bs->get_contact_count();
} }
void RigidDynamicBody2D::apply_central_impulse(const Vector2 &p_impulse) { void RigidBody2D::apply_central_impulse(const Vector2 &p_impulse) {
PhysicsServer2D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); PhysicsServer2D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
} }
void RigidDynamicBody2D::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position) { void RigidBody2D::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position) {
PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_impulse, p_position); PhysicsServer2D::get_singleton()->body_apply_impulse(get_rid(), p_impulse, p_position);
} }
void RigidDynamicBody2D::apply_torque_impulse(real_t p_torque) { void RigidBody2D::apply_torque_impulse(real_t p_torque) {
PhysicsServer2D::get_singleton()->body_apply_torque_impulse(get_rid(), p_torque); PhysicsServer2D::get_singleton()->body_apply_torque_impulse(get_rid(), p_torque);
} }
void RigidDynamicBody2D::apply_central_force(const Vector2 &p_force) { void RigidBody2D::apply_central_force(const Vector2 &p_force) {
PhysicsServer2D::get_singleton()->body_apply_central_force(get_rid(), p_force); PhysicsServer2D::get_singleton()->body_apply_central_force(get_rid(), p_force);
} }
void RigidDynamicBody2D::apply_force(const Vector2 &p_force, const Vector2 &p_position) { void RigidBody2D::apply_force(const Vector2 &p_force, const Vector2 &p_position) {
PhysicsServer2D::get_singleton()->body_apply_force(get_rid(), p_force, p_position); PhysicsServer2D::get_singleton()->body_apply_force(get_rid(), p_force, p_position);
} }
void RigidDynamicBody2D::apply_torque(real_t p_torque) { void RigidBody2D::apply_torque(real_t p_torque) {
PhysicsServer2D::get_singleton()->body_apply_torque(get_rid(), p_torque); PhysicsServer2D::get_singleton()->body_apply_torque(get_rid(), p_torque);
} }
void RigidDynamicBody2D::add_constant_central_force(const Vector2 &p_force) { void RigidBody2D::add_constant_central_force(const Vector2 &p_force) {
PhysicsServer2D::get_singleton()->body_add_constant_central_force(get_rid(), p_force); PhysicsServer2D::get_singleton()->body_add_constant_central_force(get_rid(), p_force);
} }
void RigidDynamicBody2D::add_constant_force(const Vector2 &p_force, const Vector2 &p_position) { void RigidBody2D::add_constant_force(const Vector2 &p_force, const Vector2 &p_position) {
PhysicsServer2D::get_singleton()->body_add_constant_force(get_rid(), p_force, p_position); PhysicsServer2D::get_singleton()->body_add_constant_force(get_rid(), p_force, p_position);
} }
void RigidDynamicBody2D::add_constant_torque(const real_t p_torque) { void RigidBody2D::add_constant_torque(const real_t p_torque) {
PhysicsServer2D::get_singleton()->body_add_constant_torque(get_rid(), p_torque); PhysicsServer2D::get_singleton()->body_add_constant_torque(get_rid(), p_torque);
} }
void RigidDynamicBody2D::set_constant_force(const Vector2 &p_force) { void RigidBody2D::set_constant_force(const Vector2 &p_force) {
PhysicsServer2D::get_singleton()->body_set_constant_force(get_rid(), p_force); PhysicsServer2D::get_singleton()->body_set_constant_force(get_rid(), p_force);
} }
Vector2 RigidDynamicBody2D::get_constant_force() const { Vector2 RigidBody2D::get_constant_force() const {
return PhysicsServer2D::get_singleton()->body_get_constant_force(get_rid()); return PhysicsServer2D::get_singleton()->body_get_constant_force(get_rid());
} }
void RigidDynamicBody2D::set_constant_torque(real_t p_torque) { void RigidBody2D::set_constant_torque(real_t p_torque) {
PhysicsServer2D::get_singleton()->body_set_constant_torque(get_rid(), p_torque); PhysicsServer2D::get_singleton()->body_set_constant_torque(get_rid(), p_torque);
} }
real_t RigidDynamicBody2D::get_constant_torque() const { real_t RigidBody2D::get_constant_torque() const {
return PhysicsServer2D::get_singleton()->body_get_constant_torque(get_rid()); return PhysicsServer2D::get_singleton()->body_get_constant_torque(get_rid());
} }
void RigidDynamicBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) { void RigidBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) {
ccd_mode = p_mode; ccd_mode = p_mode;
PhysicsServer2D::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), PhysicsServer2D::CCDMode(p_mode)); PhysicsServer2D::get_singleton()->body_set_continuous_collision_detection_mode(get_rid(), PhysicsServer2D::CCDMode(p_mode));
} }
RigidDynamicBody2D::CCDMode RigidDynamicBody2D::get_continuous_collision_detection_mode() const { RigidBody2D::CCDMode RigidBody2D::get_continuous_collision_detection_mode() const {
return ccd_mode; return ccd_mode;
} }
TypedArray<Node2D> RigidDynamicBody2D::get_colliding_bodies() const { TypedArray<Node2D> RigidBody2D::get_colliding_bodies() const {
ERR_FAIL_COND_V(!contact_monitor, TypedArray<Node2D>()); ERR_FAIL_COND_V(!contact_monitor, TypedArray<Node2D>());
TypedArray<Node2D> ret; TypedArray<Node2D> ret;
@ -872,7 +872,7 @@ TypedArray<Node2D> RigidDynamicBody2D::get_colliding_bodies() const {
return ret; return ret;
} }
void RigidDynamicBody2D::set_contact_monitor(bool p_enabled) { void RigidBody2D::set_contact_monitor(bool p_enabled) {
if (p_enabled == is_contact_monitor_enabled()) { if (p_enabled == is_contact_monitor_enabled()) {
return; return;
} }
@ -886,8 +886,8 @@ void RigidDynamicBody2D::set_contact_monitor(bool p_enabled) {
Node *node = Object::cast_to<Node>(obj); Node *node = Object::cast_to<Node>(obj);
if (node) { if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidDynamicBody2D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody2D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidDynamicBody2D::_body_exit_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody2D::_body_exit_tree));
} }
} }
@ -899,11 +899,11 @@ void RigidDynamicBody2D::set_contact_monitor(bool p_enabled) {
} }
} }
bool RigidDynamicBody2D::is_contact_monitor_enabled() const { bool RigidBody2D::is_contact_monitor_enabled() const {
return contact_monitor != nullptr; return contact_monitor != nullptr;
} }
void RigidDynamicBody2D::_notification(int p_what) { void RigidBody2D::_notification(int p_what) {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
@ -921,103 +921,103 @@ void RigidDynamicBody2D::_notification(int p_what) {
#endif #endif
} }
TypedArray<String> RigidDynamicBody2D::get_configuration_warnings() const { TypedArray<String> RigidBody2D::get_configuration_warnings() const {
Transform2D t = get_transform(); Transform2D t = get_transform();
TypedArray<String> warnings = CollisionObject2D::get_configuration_warnings(); TypedArray<String> warnings = CollisionObject2D::get_configuration_warnings();
if (ABS(t.columns[0].length() - 1.0) > 0.05 || ABS(t.columns[1].length() - 1.0) > 0.05) { if (ABS(t.columns[0].length() - 1.0) > 0.05 || ABS(t.columns[1].length() - 1.0) > 0.05) {
warnings.push_back(RTR("Size changes to RigidDynamicBody2D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.")); warnings.push_back(RTR("Size changes to RigidBody2D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."));
} }
return warnings; return warnings;
} }
void RigidDynamicBody2D::_bind_methods() { void RigidBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mass", "mass"), &RigidDynamicBody2D::set_mass); ClassDB::bind_method(D_METHOD("set_mass", "mass"), &RigidBody2D::set_mass);
ClassDB::bind_method(D_METHOD("get_mass"), &RigidDynamicBody2D::get_mass); ClassDB::bind_method(D_METHOD("get_mass"), &RigidBody2D::get_mass);
ClassDB::bind_method(D_METHOD("get_inertia"), &RigidDynamicBody2D::get_inertia); ClassDB::bind_method(D_METHOD("get_inertia"), &RigidBody2D::get_inertia);
ClassDB::bind_method(D_METHOD("set_inertia", "inertia"), &RigidDynamicBody2D::set_inertia); ClassDB::bind_method(D_METHOD("set_inertia", "inertia"), &RigidBody2D::set_inertia);
ClassDB::bind_method(D_METHOD("set_center_of_mass_mode", "mode"), &RigidDynamicBody2D::set_center_of_mass_mode); ClassDB::bind_method(D_METHOD("set_center_of_mass_mode", "mode"), &RigidBody2D::set_center_of_mass_mode);
ClassDB::bind_method(D_METHOD("get_center_of_mass_mode"), &RigidDynamicBody2D::get_center_of_mass_mode); ClassDB::bind_method(D_METHOD("get_center_of_mass_mode"), &RigidBody2D::get_center_of_mass_mode);
ClassDB::bind_method(D_METHOD("set_center_of_mass", "center_of_mass"), &RigidDynamicBody2D::set_center_of_mass); ClassDB::bind_method(D_METHOD("set_center_of_mass", "center_of_mass"), &RigidBody2D::set_center_of_mass);
ClassDB::bind_method(D_METHOD("get_center_of_mass"), &RigidDynamicBody2D::get_center_of_mass); ClassDB::bind_method(D_METHOD("get_center_of_mass"), &RigidBody2D::get_center_of_mass);
ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidDynamicBody2D::set_physics_material_override); ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidBody2D::set_physics_material_override);
ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidDynamicBody2D::get_physics_material_override); ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidBody2D::get_physics_material_override);
ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &RigidDynamicBody2D::set_gravity_scale); ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &RigidBody2D::set_gravity_scale);
ClassDB::bind_method(D_METHOD("get_gravity_scale"), &RigidDynamicBody2D::get_gravity_scale); ClassDB::bind_method(D_METHOD("get_gravity_scale"), &RigidBody2D::get_gravity_scale);
ClassDB::bind_method(D_METHOD("set_linear_damp_mode", "linear_damp_mode"), &RigidDynamicBody2D::set_linear_damp_mode); ClassDB::bind_method(D_METHOD("set_linear_damp_mode", "linear_damp_mode"), &RigidBody2D::set_linear_damp_mode);
ClassDB::bind_method(D_METHOD("get_linear_damp_mode"), &RigidDynamicBody2D::get_linear_damp_mode); ClassDB::bind_method(D_METHOD("get_linear_damp_mode"), &RigidBody2D::get_linear_damp_mode);
ClassDB::bind_method(D_METHOD("set_angular_damp_mode", "angular_damp_mode"), &RigidDynamicBody2D::set_angular_damp_mode); ClassDB::bind_method(D_METHOD("set_angular_damp_mode", "angular_damp_mode"), &RigidBody2D::set_angular_damp_mode);
ClassDB::bind_method(D_METHOD("get_angular_damp_mode"), &RigidDynamicBody2D::get_angular_damp_mode); ClassDB::bind_method(D_METHOD("get_angular_damp_mode"), &RigidBody2D::get_angular_damp_mode);
ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &RigidDynamicBody2D::set_linear_damp); ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &RigidBody2D::set_linear_damp);
ClassDB::bind_method(D_METHOD("get_linear_damp"), &RigidDynamicBody2D::get_linear_damp); ClassDB::bind_method(D_METHOD("get_linear_damp"), &RigidBody2D::get_linear_damp);
ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &RigidDynamicBody2D::set_angular_damp); ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &RigidBody2D::set_angular_damp);
ClassDB::bind_method(D_METHOD("get_angular_damp"), &RigidDynamicBody2D::get_angular_damp); ClassDB::bind_method(D_METHOD("get_angular_damp"), &RigidBody2D::get_angular_damp);
ClassDB::bind_method(D_METHOD("set_linear_velocity", "linear_velocity"), &RigidDynamicBody2D::set_linear_velocity); ClassDB::bind_method(D_METHOD("set_linear_velocity", "linear_velocity"), &RigidBody2D::set_linear_velocity);
ClassDB::bind_method(D_METHOD("get_linear_velocity"), &RigidDynamicBody2D::get_linear_velocity); ClassDB::bind_method(D_METHOD("get_linear_velocity"), &RigidBody2D::get_linear_velocity);
ClassDB::bind_method(D_METHOD("set_angular_velocity", "angular_velocity"), &RigidDynamicBody2D::set_angular_velocity); ClassDB::bind_method(D_METHOD("set_angular_velocity", "angular_velocity"), &RigidBody2D::set_angular_velocity);
ClassDB::bind_method(D_METHOD("get_angular_velocity"), &RigidDynamicBody2D::get_angular_velocity); ClassDB::bind_method(D_METHOD("get_angular_velocity"), &RigidBody2D::get_angular_velocity);
ClassDB::bind_method(D_METHOD("set_max_contacts_reported", "amount"), &RigidDynamicBody2D::set_max_contacts_reported); ClassDB::bind_method(D_METHOD("set_max_contacts_reported", "amount"), &RigidBody2D::set_max_contacts_reported);
ClassDB::bind_method(D_METHOD("get_max_contacts_reported"), &RigidDynamicBody2D::get_max_contacts_reported); ClassDB::bind_method(D_METHOD("get_max_contacts_reported"), &RigidBody2D::get_max_contacts_reported);
ClassDB::bind_method(D_METHOD("get_contact_count"), &RigidDynamicBody2D::get_contact_count); ClassDB::bind_method(D_METHOD("get_contact_count"), &RigidBody2D::get_contact_count);
ClassDB::bind_method(D_METHOD("set_use_custom_integrator", "enable"), &RigidDynamicBody2D::set_use_custom_integrator); ClassDB::bind_method(D_METHOD("set_use_custom_integrator", "enable"), &RigidBody2D::set_use_custom_integrator);
ClassDB::bind_method(D_METHOD("is_using_custom_integrator"), &RigidDynamicBody2D::is_using_custom_integrator); ClassDB::bind_method(D_METHOD("is_using_custom_integrator"), &RigidBody2D::is_using_custom_integrator);
ClassDB::bind_method(D_METHOD("set_contact_monitor", "enabled"), &RigidDynamicBody2D::set_contact_monitor); ClassDB::bind_method(D_METHOD("set_contact_monitor", "enabled"), &RigidBody2D::set_contact_monitor);
ClassDB::bind_method(D_METHOD("is_contact_monitor_enabled"), &RigidDynamicBody2D::is_contact_monitor_enabled); ClassDB::bind_method(D_METHOD("is_contact_monitor_enabled"), &RigidBody2D::is_contact_monitor_enabled);
ClassDB::bind_method(D_METHOD("set_continuous_collision_detection_mode", "mode"), &RigidDynamicBody2D::set_continuous_collision_detection_mode); ClassDB::bind_method(D_METHOD("set_continuous_collision_detection_mode", "mode"), &RigidBody2D::set_continuous_collision_detection_mode);
ClassDB::bind_method(D_METHOD("get_continuous_collision_detection_mode"), &RigidDynamicBody2D::get_continuous_collision_detection_mode); ClassDB::bind_method(D_METHOD("get_continuous_collision_detection_mode"), &RigidBody2D::get_continuous_collision_detection_mode);
ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidDynamicBody2D::set_axis_velocity); ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidBody2D::set_axis_velocity);
ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidDynamicBody2D::apply_central_impulse, Vector2()); ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidBody2D::apply_central_impulse, Vector2());
ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &RigidDynamicBody2D::apply_impulse, Vector2()); ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &RigidBody2D::apply_impulse, Vector2());
ClassDB::bind_method(D_METHOD("apply_torque_impulse", "torque"), &RigidDynamicBody2D::apply_torque_impulse); ClassDB::bind_method(D_METHOD("apply_torque_impulse", "torque"), &RigidBody2D::apply_torque_impulse);
ClassDB::bind_method(D_METHOD("apply_central_force", "force"), &RigidDynamicBody2D::apply_central_force); ClassDB::bind_method(D_METHOD("apply_central_force", "force"), &RigidBody2D::apply_central_force);
ClassDB::bind_method(D_METHOD("apply_force", "force", "position"), &RigidDynamicBody2D::apply_force, Vector2()); ClassDB::bind_method(D_METHOD("apply_force", "force", "position"), &RigidBody2D::apply_force, Vector2());
ClassDB::bind_method(D_METHOD("apply_torque", "torque"), &RigidDynamicBody2D::apply_torque); ClassDB::bind_method(D_METHOD("apply_torque", "torque"), &RigidBody2D::apply_torque);
ClassDB::bind_method(D_METHOD("add_constant_central_force", "force"), &RigidDynamicBody2D::add_constant_central_force); ClassDB::bind_method(D_METHOD("add_constant_central_force", "force"), &RigidBody2D::add_constant_central_force);
ClassDB::bind_method(D_METHOD("add_constant_force", "force", "position"), &RigidDynamicBody2D::add_constant_force, Vector2()); ClassDB::bind_method(D_METHOD("add_constant_force", "force", "position"), &RigidBody2D::add_constant_force, Vector2());
ClassDB::bind_method(D_METHOD("add_constant_torque", "torque"), &RigidDynamicBody2D::add_constant_torque); ClassDB::bind_method(D_METHOD("add_constant_torque", "torque"), &RigidBody2D::add_constant_torque);
ClassDB::bind_method(D_METHOD("set_constant_force", "force"), &RigidDynamicBody2D::set_constant_force); ClassDB::bind_method(D_METHOD("set_constant_force", "force"), &RigidBody2D::set_constant_force);
ClassDB::bind_method(D_METHOD("get_constant_force"), &RigidDynamicBody2D::get_constant_force); ClassDB::bind_method(D_METHOD("get_constant_force"), &RigidBody2D::get_constant_force);
ClassDB::bind_method(D_METHOD("set_constant_torque", "torque"), &RigidDynamicBody2D::set_constant_torque); ClassDB::bind_method(D_METHOD("set_constant_torque", "torque"), &RigidBody2D::set_constant_torque);
ClassDB::bind_method(D_METHOD("get_constant_torque"), &RigidDynamicBody2D::get_constant_torque); ClassDB::bind_method(D_METHOD("get_constant_torque"), &RigidBody2D::get_constant_torque);
ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidDynamicBody2D::set_sleeping); ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidBody2D::set_sleeping);
ClassDB::bind_method(D_METHOD("is_sleeping"), &RigidDynamicBody2D::is_sleeping); ClassDB::bind_method(D_METHOD("is_sleeping"), &RigidBody2D::is_sleeping);
ClassDB::bind_method(D_METHOD("set_can_sleep", "able_to_sleep"), &RigidDynamicBody2D::set_can_sleep); ClassDB::bind_method(D_METHOD("set_can_sleep", "able_to_sleep"), &RigidBody2D::set_can_sleep);
ClassDB::bind_method(D_METHOD("is_able_to_sleep"), &RigidDynamicBody2D::is_able_to_sleep); ClassDB::bind_method(D_METHOD("is_able_to_sleep"), &RigidBody2D::is_able_to_sleep);
ClassDB::bind_method(D_METHOD("set_lock_rotation_enabled", "lock_rotation"), &RigidDynamicBody2D::set_lock_rotation_enabled); ClassDB::bind_method(D_METHOD("set_lock_rotation_enabled", "lock_rotation"), &RigidBody2D::set_lock_rotation_enabled);
ClassDB::bind_method(D_METHOD("is_lock_rotation_enabled"), &RigidDynamicBody2D::is_lock_rotation_enabled); ClassDB::bind_method(D_METHOD("is_lock_rotation_enabled"), &RigidBody2D::is_lock_rotation_enabled);
ClassDB::bind_method(D_METHOD("set_freeze_enabled", "freeze_mode"), &RigidDynamicBody2D::set_freeze_enabled); ClassDB::bind_method(D_METHOD("set_freeze_enabled", "freeze_mode"), &RigidBody2D::set_freeze_enabled);
ClassDB::bind_method(D_METHOD("is_freeze_enabled"), &RigidDynamicBody2D::is_freeze_enabled); ClassDB::bind_method(D_METHOD("is_freeze_enabled"), &RigidBody2D::is_freeze_enabled);
ClassDB::bind_method(D_METHOD("set_freeze_mode", "freeze_mode"), &RigidDynamicBody2D::set_freeze_mode); ClassDB::bind_method(D_METHOD("set_freeze_mode", "freeze_mode"), &RigidBody2D::set_freeze_mode);
ClassDB::bind_method(D_METHOD("get_freeze_mode"), &RigidDynamicBody2D::get_freeze_mode); ClassDB::bind_method(D_METHOD("get_freeze_mode"), &RigidBody2D::get_freeze_mode);
ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidDynamicBody2D::get_colliding_bodies); ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody2D::get_colliding_bodies);
GDVIRTUAL_BIND(_integrate_forces, "state"); GDVIRTUAL_BIND(_integrate_forces, "state");
@ -1069,7 +1069,7 @@ void RigidDynamicBody2D::_bind_methods() {
BIND_ENUM_CONSTANT(CCD_MODE_CAST_SHAPE); BIND_ENUM_CONSTANT(CCD_MODE_CAST_SHAPE);
} }
void RigidDynamicBody2D::_validate_property(PropertyInfo &p_property) const { void RigidBody2D::_validate_property(PropertyInfo &p_property) const {
if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM) { if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM) {
if (p_property.name == "center_of_mass") { if (p_property.name == "center_of_mass") {
p_property.usage = PROPERTY_USAGE_NO_EDITOR; p_property.usage = PROPERTY_USAGE_NO_EDITOR;
@ -1077,18 +1077,18 @@ void RigidDynamicBody2D::_validate_property(PropertyInfo &p_property) const {
} }
} }
RigidDynamicBody2D::RigidDynamicBody2D() : RigidBody2D::RigidBody2D() :
PhysicsBody2D(PhysicsServer2D::BODY_MODE_DYNAMIC) { PhysicsBody2D(PhysicsServer2D::BODY_MODE_RIGID) {
PhysicsServer2D::get_singleton()->body_set_state_sync_callback(get_rid(), this, _body_state_changed_callback); PhysicsServer2D::get_singleton()->body_set_state_sync_callback(get_rid(), this, _body_state_changed_callback);
} }
RigidDynamicBody2D::~RigidDynamicBody2D() { RigidBody2D::~RigidBody2D() {
if (contact_monitor) { if (contact_monitor) {
memdelete(contact_monitor); memdelete(contact_monitor);
} }
} }
void RigidDynamicBody2D::_reload_physics_characteristics() { void RigidBody2D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) { if (physics_material_override.is_null()) {
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, 0); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_BOUNCE, 0);
PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, 1); PhysicsServer2D::get_singleton()->body_set_param(get_rid(), PhysicsServer2D::BODY_PARAM_FRICTION, 1);

View File

@ -113,8 +113,8 @@ private:
bool is_sync_to_physics_enabled() const; bool is_sync_to_physics_enabled() const;
}; };
class RigidDynamicBody2D : public PhysicsBody2D { class RigidBody2D : public PhysicsBody2D {
GDCLASS(RigidDynamicBody2D, PhysicsBody2D); GDCLASS(RigidBody2D, PhysicsBody2D);
public: public:
enum FreezeMode { enum FreezeMode {
@ -186,7 +186,7 @@ private:
local_shape = p_ls; local_shape = p_ls;
} }
}; };
struct RigidDynamicBody2D_RemoveAction { struct RigidBody2D_RemoveAction {
RID rid; RID rid;
ObjectID body_id; ObjectID body_id;
ShapePair pair; ShapePair pair;
@ -311,17 +311,17 @@ public:
virtual TypedArray<String> get_configuration_warnings() const override; virtual TypedArray<String> get_configuration_warnings() const override;
RigidDynamicBody2D(); RigidBody2D();
~RigidDynamicBody2D(); ~RigidBody2D();
private: private:
void _reload_physics_characteristics(); void _reload_physics_characteristics();
}; };
VARIANT_ENUM_CAST(RigidDynamicBody2D::FreezeMode); VARIANT_ENUM_CAST(RigidBody2D::FreezeMode);
VARIANT_ENUM_CAST(RigidDynamicBody2D::CenterOfMassMode); VARIANT_ENUM_CAST(RigidBody2D::CenterOfMassMode);
VARIANT_ENUM_CAST(RigidDynamicBody2D::DampMode); VARIANT_ENUM_CAST(RigidBody2D::DampMode);
VARIANT_ENUM_CAST(RigidDynamicBody2D::CCDMode); VARIANT_ENUM_CAST(RigidBody2D::CCDMode);
class CharacterBody2D : public PhysicsBody2D { class CharacterBody2D : public PhysicsBody2D {
GDCLASS(CharacterBody2D, PhysicsBody2D); GDCLASS(CharacterBody2D, PhysicsBody2D);

View File

@ -171,7 +171,7 @@ TypedArray<String> CollisionPolygon3D::get_configuration_warnings() const {
TypedArray<String> warnings = Node::get_configuration_warnings(); TypedArray<String> warnings = Node::get_configuration_warnings();
if (!Object::cast_to<CollisionObject3D>(get_parent())) { if (!Object::cast_to<CollisionObject3D>(get_parent())) {
warnings.push_back(RTR("CollisionPolygon3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidDynamicBody3D, CharacterBody3D, etc. to give them a shape.")); warnings.push_back(RTR("CollisionPolygon3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, CharacterBody3D, etc. to give them a shape."));
} }
if (polygon.is_empty()) { if (polygon.is_empty()) {

View File

@ -118,7 +118,7 @@ TypedArray<String> CollisionShape3D::get_configuration_warnings() const {
TypedArray<String> warnings = Node::get_configuration_warnings(); TypedArray<String> warnings = Node::get_configuration_warnings();
if (!Object::cast_to<CollisionObject3D>(get_parent())) { if (!Object::cast_to<CollisionObject3D>(get_parent())) {
warnings.push_back(RTR("CollisionShape3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidDynamicBody3D, CharacterBody3D, etc. to give them a shape.")); warnings.push_back(RTR("CollisionShape3D only serves to provide a collision shape to a CollisionObject3D derived node. Please only use it as a child of Area3D, StaticBody3D, RigidBody3D, CharacterBody3D, etc. to give them a shape."));
} }
if (!shape.is_valid()) { if (!shape.is_valid()) {
@ -126,9 +126,9 @@ TypedArray<String> CollisionShape3D::get_configuration_warnings() const {
} }
if (shape.is_valid() && if (shape.is_valid() &&
Object::cast_to<RigidDynamicBody3D>(get_parent()) && Object::cast_to<RigidBody3D>(get_parent()) &&
Object::cast_to<ConcavePolygonShape3D>(*shape)) { Object::cast_to<ConcavePolygonShape3D>(*shape)) {
warnings.push_back(RTR("ConcavePolygonShape3D doesn't support RigidDynamicBody3D in another mode than static.")); warnings.push_back(RTR("ConcavePolygonShape3D doesn't support RigidBody3D in another mode than static."));
} }
return warnings; return warnings;

View File

@ -133,7 +133,7 @@ TypedArray<String> NavigationObstacle3D::get_configuration_warnings() const {
} }
if (Object::cast_to<StaticBody3D>(get_parent())) { if (Object::cast_to<StaticBody3D>(get_parent())) {
warnings.push_back(RTR("The NavigationObstacle3D is intended for constantly moving bodies like CharacterBody3D or RigidDynamicBody3D as it creates only an RVO avoidance radius and does not follow scene geometry exactly." warnings.push_back(RTR("The NavigationObstacle3D is intended for constantly moving bodies like CharacterBody3D or RigidBody3D as it creates only an RVO avoidance radius and does not follow scene geometry exactly."
"\nNot constantly moving or complete static objects should be (re)baked to a NavigationMesh so agents can not only avoid them but also move along those objects outline at high detail")); "\nNot constantly moving or complete static objects should be (re)baked to a NavigationMesh so agents can not only avoid them but also move along those objects outline at high detail"));
} }

View File

@ -376,7 +376,7 @@ AnimatableBody3D::AnimatableBody3D() :
PhysicsServer3D::get_singleton()->body_set_state_sync_callback(get_rid(), this, _body_state_changed_callback); PhysicsServer3D::get_singleton()->body_set_state_sync_callback(get_rid(), this, _body_state_changed_callback);
} }
void RigidDynamicBody3D::_body_enter_tree(ObjectID p_id) { void RigidBody3D::_body_enter_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id); Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj); Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node); ERR_FAIL_COND(!node);
@ -399,7 +399,7 @@ void RigidDynamicBody3D::_body_enter_tree(ObjectID p_id) {
contact_monitor->locked = false; contact_monitor->locked = false;
} }
void RigidDynamicBody3D::_body_exit_tree(ObjectID p_id) { void RigidBody3D::_body_exit_tree(ObjectID p_id) {
Object *obj = ObjectDB::get_instance(p_id); Object *obj = ObjectDB::get_instance(p_id);
Node *node = Object::cast_to<Node>(obj); Node *node = Object::cast_to<Node>(obj);
ERR_FAIL_COND(!node); ERR_FAIL_COND(!node);
@ -420,7 +420,7 @@ void RigidDynamicBody3D::_body_exit_tree(ObjectID p_id) {
contact_monitor->locked = false; contact_monitor->locked = false;
} }
void RigidDynamicBody3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_local_shape) { void RigidBody3D::_body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_local_shape) {
bool body_in = p_status == 1; bool body_in = p_status == 1;
ObjectID objid = p_instance; ObjectID objid = p_instance;
@ -439,8 +439,8 @@ void RigidDynamicBody3D::_body_inout(int p_status, const RID &p_body, ObjectID p
//E->value.rc=0; //E->value.rc=0;
E->value.in_tree = node && node->is_inside_tree(); E->value.in_tree = node && node->is_inside_tree();
if (node) { if (node) {
node->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidDynamicBody3D::_body_enter_tree).bind(objid)); node->connect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree).bind(objid));
node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidDynamicBody3D::_body_exit_tree).bind(objid)); node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree).bind(objid));
if (E->value.in_tree) { if (E->value.in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_entered, node); emit_signal(SceneStringNames::get_singleton()->body_entered, node);
} }
@ -466,8 +466,8 @@ void RigidDynamicBody3D::_body_inout(int p_status, const RID &p_body, ObjectID p
if (E->value.shapes.is_empty()) { if (E->value.shapes.is_empty()) {
if (node) { if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidDynamicBody3D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidDynamicBody3D::_body_exit_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree));
if (in_tree) { if (in_tree) {
emit_signal(SceneStringNames::get_singleton()->body_exited, node); emit_signal(SceneStringNames::get_singleton()->body_exited, node);
} }
@ -481,19 +481,19 @@ void RigidDynamicBody3D::_body_inout(int p_status, const RID &p_body, ObjectID p
} }
} }
struct _RigidDynamicBodyInOut { struct _RigidBodyInOut {
RID rid; RID rid;
ObjectID id; ObjectID id;
int shape = 0; int shape = 0;
int local_shape = 0; int local_shape = 0;
}; };
void RigidDynamicBody3D::_body_state_changed_callback(void *p_instance, PhysicsDirectBodyState3D *p_state) { void RigidBody3D::_body_state_changed_callback(void *p_instance, PhysicsDirectBodyState3D *p_state) {
RigidDynamicBody3D *body = (RigidDynamicBody3D *)p_instance; RigidBody3D *body = (RigidBody3D *)p_instance;
body->_body_state_changed(p_state); body->_body_state_changed(p_state);
} }
void RigidDynamicBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) { void RigidBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
set_ignore_transform_notification(true); set_ignore_transform_notification(true);
set_global_transform(p_state->get_transform()); set_global_transform(p_state->get_transform());
@ -524,9 +524,9 @@ void RigidDynamicBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state)
} }
} }
_RigidDynamicBodyInOut *toadd = (_RigidDynamicBodyInOut *)alloca(p_state->get_contact_count() * sizeof(_RigidDynamicBodyInOut)); _RigidBodyInOut *toadd = (_RigidBodyInOut *)alloca(p_state->get_contact_count() * sizeof(_RigidBodyInOut));
int toadd_count = 0; int toadd_count = 0;
RigidDynamicBody3D_RemoveAction *toremove = (RigidDynamicBody3D_RemoveAction *)alloca(rc * sizeof(RigidDynamicBody3D_RemoveAction)); RigidBody3D_RemoveAction *toremove = (RigidBody3D_RemoveAction *)alloca(rc * sizeof(RigidBody3D_RemoveAction));
int toremove_count = 0; int toremove_count = 0;
//put the ones to add //put the ones to add
@ -590,7 +590,7 @@ void RigidDynamicBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state)
} }
} }
void RigidDynamicBody3D::_notification(int p_what) { void RigidBody3D::_notification(int p_what) {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_TREE: { case NOTIFICATION_ENTER_TREE: {
@ -608,7 +608,7 @@ void RigidDynamicBody3D::_notification(int p_what) {
#endif #endif
} }
void RigidDynamicBody3D::_apply_body_mode() { void RigidBody3D::_apply_body_mode() {
if (freeze) { if (freeze) {
switch (freeze_mode) { switch (freeze_mode) {
case FREEZE_MODE_STATIC: { case FREEZE_MODE_STATIC: {
@ -619,13 +619,13 @@ void RigidDynamicBody3D::_apply_body_mode() {
} break; } break;
} }
} else if (lock_rotation) { } else if (lock_rotation) {
set_body_mode(PhysicsServer3D::BODY_MODE_DYNAMIC_LINEAR); set_body_mode(PhysicsServer3D::BODY_MODE_RIGID_LINEAR);
} else { } else {
set_body_mode(PhysicsServer3D::BODY_MODE_DYNAMIC); set_body_mode(PhysicsServer3D::BODY_MODE_RIGID);
} }
} }
void RigidDynamicBody3D::set_lock_rotation_enabled(bool p_lock_rotation) { void RigidBody3D::set_lock_rotation_enabled(bool p_lock_rotation) {
if (p_lock_rotation == lock_rotation) { if (p_lock_rotation == lock_rotation) {
return; return;
} }
@ -634,11 +634,11 @@ void RigidDynamicBody3D::set_lock_rotation_enabled(bool p_lock_rotation) {
_apply_body_mode(); _apply_body_mode();
} }
bool RigidDynamicBody3D::is_lock_rotation_enabled() const { bool RigidBody3D::is_lock_rotation_enabled() const {
return lock_rotation; return lock_rotation;
} }
void RigidDynamicBody3D::set_freeze_enabled(bool p_freeze) { void RigidBody3D::set_freeze_enabled(bool p_freeze) {
if (p_freeze == freeze) { if (p_freeze == freeze) {
return; return;
} }
@ -647,11 +647,11 @@ void RigidDynamicBody3D::set_freeze_enabled(bool p_freeze) {
_apply_body_mode(); _apply_body_mode();
} }
bool RigidDynamicBody3D::is_freeze_enabled() const { bool RigidBody3D::is_freeze_enabled() const {
return freeze; return freeze;
} }
void RigidDynamicBody3D::set_freeze_mode(FreezeMode p_freeze_mode) { void RigidBody3D::set_freeze_mode(FreezeMode p_freeze_mode) {
if (p_freeze_mode == freeze_mode) { if (p_freeze_mode == freeze_mode) {
return; return;
} }
@ -660,21 +660,21 @@ void RigidDynamicBody3D::set_freeze_mode(FreezeMode p_freeze_mode) {
_apply_body_mode(); _apply_body_mode();
} }
RigidDynamicBody3D::FreezeMode RigidDynamicBody3D::get_freeze_mode() const { RigidBody3D::FreezeMode RigidBody3D::get_freeze_mode() const {
return freeze_mode; return freeze_mode;
} }
void RigidDynamicBody3D::set_mass(real_t p_mass) { void RigidBody3D::set_mass(real_t p_mass) {
ERR_FAIL_COND(p_mass <= 0); ERR_FAIL_COND(p_mass <= 0);
mass = p_mass; mass = p_mass;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_MASS, mass);
} }
real_t RigidDynamicBody3D::get_mass() const { real_t RigidBody3D::get_mass() const {
return mass; return mass;
} }
void RigidDynamicBody3D::set_inertia(const Vector3 &p_inertia) { void RigidBody3D::set_inertia(const Vector3 &p_inertia) {
ERR_FAIL_COND(p_inertia.x < 0); ERR_FAIL_COND(p_inertia.x < 0);
ERR_FAIL_COND(p_inertia.y < 0); ERR_FAIL_COND(p_inertia.y < 0);
ERR_FAIL_COND(p_inertia.z < 0); ERR_FAIL_COND(p_inertia.z < 0);
@ -683,11 +683,11 @@ void RigidDynamicBody3D::set_inertia(const Vector3 &p_inertia) {
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_INERTIA, inertia); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_INERTIA, inertia);
} }
const Vector3 &RigidDynamicBody3D::get_inertia() const { const Vector3 &RigidBody3D::get_inertia() const {
return inertia; return inertia;
} }
void RigidDynamicBody3D::set_center_of_mass_mode(CenterOfMassMode p_mode) { void RigidBody3D::set_center_of_mass_mode(CenterOfMassMode p_mode) {
if (center_of_mass_mode == p_mode) { if (center_of_mass_mode == p_mode) {
return; return;
} }
@ -709,11 +709,11 @@ void RigidDynamicBody3D::set_center_of_mass_mode(CenterOfMassMode p_mode) {
} }
} }
RigidDynamicBody3D::CenterOfMassMode RigidDynamicBody3D::get_center_of_mass_mode() const { RigidBody3D::CenterOfMassMode RigidBody3D::get_center_of_mass_mode() const {
return center_of_mass_mode; return center_of_mass_mode;
} }
void RigidDynamicBody3D::set_center_of_mass(const Vector3 &p_center_of_mass) { void RigidBody3D::set_center_of_mass(const Vector3 &p_center_of_mass) {
if (center_of_mass == p_center_of_mass) { if (center_of_mass == p_center_of_mass) {
return; return;
} }
@ -724,106 +724,106 @@ void RigidDynamicBody3D::set_center_of_mass(const Vector3 &p_center_of_mass) {
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS, center_of_mass); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS, center_of_mass);
} }
const Vector3 &RigidDynamicBody3D::get_center_of_mass() const { const Vector3 &RigidBody3D::get_center_of_mass() const {
return center_of_mass; return center_of_mass;
} }
void RigidDynamicBody3D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) { void RigidBody3D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) { if (physics_material_override.is_valid()) {
if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidDynamicBody3D::_reload_physics_characteristics))) { if (physics_material_override->is_connected(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody3D::_reload_physics_characteristics))) {
physics_material_override->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidDynamicBody3D::_reload_physics_characteristics)); physics_material_override->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody3D::_reload_physics_characteristics));
} }
} }
physics_material_override = p_physics_material_override; physics_material_override = p_physics_material_override;
if (physics_material_override.is_valid()) { if (physics_material_override.is_valid()) {
physics_material_override->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidDynamicBody3D::_reload_physics_characteristics)); physics_material_override->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &RigidBody3D::_reload_physics_characteristics));
} }
_reload_physics_characteristics(); _reload_physics_characteristics();
} }
Ref<PhysicsMaterial> RigidDynamicBody3D::get_physics_material_override() const { Ref<PhysicsMaterial> RigidBody3D::get_physics_material_override() const {
return physics_material_override; return physics_material_override;
} }
void RigidDynamicBody3D::set_gravity_scale(real_t p_gravity_scale) { void RigidBody3D::set_gravity_scale(real_t p_gravity_scale) {
gravity_scale = p_gravity_scale; gravity_scale = p_gravity_scale;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE, gravity_scale);
} }
real_t RigidDynamicBody3D::get_gravity_scale() const { real_t RigidBody3D::get_gravity_scale() const {
return gravity_scale; return gravity_scale;
} }
void RigidDynamicBody3D::set_linear_damp_mode(DampMode p_mode) { void RigidBody3D::set_linear_damp_mode(DampMode p_mode) {
linear_damp_mode = p_mode; linear_damp_mode = p_mode;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP_MODE, linear_damp_mode);
} }
RigidDynamicBody3D::DampMode RigidDynamicBody3D::get_linear_damp_mode() const { RigidBody3D::DampMode RigidBody3D::get_linear_damp_mode() const {
return linear_damp_mode; return linear_damp_mode;
} }
void RigidDynamicBody3D::set_angular_damp_mode(DampMode p_mode) { void RigidBody3D::set_angular_damp_mode(DampMode p_mode) {
angular_damp_mode = p_mode; angular_damp_mode = p_mode;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP_MODE, angular_damp_mode);
} }
RigidDynamicBody3D::DampMode RigidDynamicBody3D::get_angular_damp_mode() const { RigidBody3D::DampMode RigidBody3D::get_angular_damp_mode() const {
return angular_damp_mode; return angular_damp_mode;
} }
void RigidDynamicBody3D::set_linear_damp(real_t p_linear_damp) { void RigidBody3D::set_linear_damp(real_t p_linear_damp) {
ERR_FAIL_COND(p_linear_damp < 0.0); ERR_FAIL_COND(p_linear_damp < 0.0);
linear_damp = p_linear_damp; linear_damp = p_linear_damp;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP, linear_damp); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_LINEAR_DAMP, linear_damp);
} }
real_t RigidDynamicBody3D::get_linear_damp() const { real_t RigidBody3D::get_linear_damp() const {
return linear_damp; return linear_damp;
} }
void RigidDynamicBody3D::set_angular_damp(real_t p_angular_damp) { void RigidBody3D::set_angular_damp(real_t p_angular_damp) {
ERR_FAIL_COND(p_angular_damp < 0.0); ERR_FAIL_COND(p_angular_damp < 0.0);
angular_damp = p_angular_damp; angular_damp = p_angular_damp;
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP, angular_damp); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP, angular_damp);
} }
real_t RigidDynamicBody3D::get_angular_damp() const { real_t RigidBody3D::get_angular_damp() const {
return angular_damp; return angular_damp;
} }
void RigidDynamicBody3D::set_axis_velocity(const Vector3 &p_axis) { void RigidBody3D::set_axis_velocity(const Vector3 &p_axis) {
Vector3 axis = p_axis.normalized(); Vector3 axis = p_axis.normalized();
linear_velocity -= axis * axis.dot(linear_velocity); linear_velocity -= axis * axis.dot(linear_velocity);
linear_velocity += p_axis; linear_velocity += p_axis;
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity); PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
} }
void RigidDynamicBody3D::set_linear_velocity(const Vector3 &p_velocity) { void RigidBody3D::set_linear_velocity(const Vector3 &p_velocity) {
linear_velocity = p_velocity; linear_velocity = p_velocity;
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity); PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY, linear_velocity);
} }
Vector3 RigidDynamicBody3D::get_linear_velocity() const { Vector3 RigidBody3D::get_linear_velocity() const {
return linear_velocity; return linear_velocity;
} }
void RigidDynamicBody3D::set_angular_velocity(const Vector3 &p_velocity) { void RigidBody3D::set_angular_velocity(const Vector3 &p_velocity) {
angular_velocity = p_velocity; angular_velocity = p_velocity;
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity); PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY, angular_velocity);
} }
Vector3 RigidDynamicBody3D::get_angular_velocity() const { Vector3 RigidBody3D::get_angular_velocity() const {
return angular_velocity; return angular_velocity;
} }
Basis RigidDynamicBody3D::get_inverse_inertia_tensor() const { Basis RigidBody3D::get_inverse_inertia_tensor() const {
return inverse_inertia_tensor; return inverse_inertia_tensor;
} }
void RigidDynamicBody3D::set_use_custom_integrator(bool p_enable) { void RigidBody3D::set_use_custom_integrator(bool p_enable) {
if (custom_integrator == p_enable) { if (custom_integrator == p_enable) {
return; return;
} }
@ -832,108 +832,108 @@ void RigidDynamicBody3D::set_use_custom_integrator(bool p_enable) {
PhysicsServer3D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable); PhysicsServer3D::get_singleton()->body_set_omit_force_integration(get_rid(), p_enable);
} }
bool RigidDynamicBody3D::is_using_custom_integrator() { bool RigidBody3D::is_using_custom_integrator() {
return custom_integrator; return custom_integrator;
} }
void RigidDynamicBody3D::set_sleeping(bool p_sleeping) { void RigidBody3D::set_sleeping(bool p_sleeping) {
sleeping = p_sleeping; sleeping = p_sleeping;
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_SLEEPING, sleeping); PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_SLEEPING, sleeping);
} }
void RigidDynamicBody3D::set_can_sleep(bool p_active) { void RigidBody3D::set_can_sleep(bool p_active) {
can_sleep = p_active; can_sleep = p_active;
PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_CAN_SLEEP, p_active); PhysicsServer3D::get_singleton()->body_set_state(get_rid(), PhysicsServer3D::BODY_STATE_CAN_SLEEP, p_active);
} }
bool RigidDynamicBody3D::is_able_to_sleep() const { bool RigidBody3D::is_able_to_sleep() const {
return can_sleep; return can_sleep;
} }
bool RigidDynamicBody3D::is_sleeping() const { bool RigidBody3D::is_sleeping() const {
return sleeping; return sleeping;
} }
void RigidDynamicBody3D::set_max_contacts_reported(int p_amount) { void RigidBody3D::set_max_contacts_reported(int p_amount) {
max_contacts_reported = p_amount; max_contacts_reported = p_amount;
PhysicsServer3D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount); PhysicsServer3D::get_singleton()->body_set_max_contacts_reported(get_rid(), p_amount);
} }
int RigidDynamicBody3D::get_max_contacts_reported() const { int RigidBody3D::get_max_contacts_reported() const {
return max_contacts_reported; return max_contacts_reported;
} }
int RigidDynamicBody3D::get_contact_count() const { int RigidBody3D::get_contact_count() const {
PhysicsDirectBodyState3D *bs = PhysicsServer3D::get_singleton()->body_get_direct_state(get_rid()); PhysicsDirectBodyState3D *bs = PhysicsServer3D::get_singleton()->body_get_direct_state(get_rid());
ERR_FAIL_NULL_V(bs, 0); ERR_FAIL_NULL_V(bs, 0);
return bs->get_contact_count(); return bs->get_contact_count();
} }
void RigidDynamicBody3D::apply_central_impulse(const Vector3 &p_impulse) { void RigidBody3D::apply_central_impulse(const Vector3 &p_impulse) {
PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
} }
void RigidDynamicBody3D::apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position) { void RigidBody3D::apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position) {
PhysicsServer3D *singleton = PhysicsServer3D::get_singleton(); PhysicsServer3D *singleton = PhysicsServer3D::get_singleton();
singleton->body_apply_impulse(get_rid(), p_impulse, p_position); singleton->body_apply_impulse(get_rid(), p_impulse, p_position);
} }
void RigidDynamicBody3D::apply_torque_impulse(const Vector3 &p_impulse) { void RigidBody3D::apply_torque_impulse(const Vector3 &p_impulse) {
PhysicsServer3D::get_singleton()->body_apply_torque_impulse(get_rid(), p_impulse); PhysicsServer3D::get_singleton()->body_apply_torque_impulse(get_rid(), p_impulse);
} }
void RigidDynamicBody3D::apply_central_force(const Vector3 &p_force) { void RigidBody3D::apply_central_force(const Vector3 &p_force) {
PhysicsServer3D::get_singleton()->body_apply_central_force(get_rid(), p_force); PhysicsServer3D::get_singleton()->body_apply_central_force(get_rid(), p_force);
} }
void RigidDynamicBody3D::apply_force(const Vector3 &p_force, const Vector3 &p_position) { void RigidBody3D::apply_force(const Vector3 &p_force, const Vector3 &p_position) {
PhysicsServer3D *singleton = PhysicsServer3D::get_singleton(); PhysicsServer3D *singleton = PhysicsServer3D::get_singleton();
singleton->body_apply_force(get_rid(), p_force, p_position); singleton->body_apply_force(get_rid(), p_force, p_position);
} }
void RigidDynamicBody3D::apply_torque(const Vector3 &p_torque) { void RigidBody3D::apply_torque(const Vector3 &p_torque) {
PhysicsServer3D::get_singleton()->body_apply_torque(get_rid(), p_torque); PhysicsServer3D::get_singleton()->body_apply_torque(get_rid(), p_torque);
} }
void RigidDynamicBody3D::add_constant_central_force(const Vector3 &p_force) { void RigidBody3D::add_constant_central_force(const Vector3 &p_force) {
PhysicsServer3D::get_singleton()->body_add_constant_central_force(get_rid(), p_force); PhysicsServer3D::get_singleton()->body_add_constant_central_force(get_rid(), p_force);
} }
void RigidDynamicBody3D::add_constant_force(const Vector3 &p_force, const Vector3 &p_position) { void RigidBody3D::add_constant_force(const Vector3 &p_force, const Vector3 &p_position) {
PhysicsServer3D *singleton = PhysicsServer3D::get_singleton(); PhysicsServer3D *singleton = PhysicsServer3D::get_singleton();
singleton->body_add_constant_force(get_rid(), p_force, p_position); singleton->body_add_constant_force(get_rid(), p_force, p_position);
} }
void RigidDynamicBody3D::add_constant_torque(const Vector3 &p_torque) { void RigidBody3D::add_constant_torque(const Vector3 &p_torque) {
PhysicsServer3D::get_singleton()->body_add_constant_torque(get_rid(), p_torque); PhysicsServer3D::get_singleton()->body_add_constant_torque(get_rid(), p_torque);
} }
void RigidDynamicBody3D::set_constant_force(const Vector3 &p_force) { void RigidBody3D::set_constant_force(const Vector3 &p_force) {
PhysicsServer3D::get_singleton()->body_set_constant_force(get_rid(), p_force); PhysicsServer3D::get_singleton()->body_set_constant_force(get_rid(), p_force);
} }
Vector3 RigidDynamicBody3D::get_constant_force() const { Vector3 RigidBody3D::get_constant_force() const {
return PhysicsServer3D::get_singleton()->body_get_constant_force(get_rid()); return PhysicsServer3D::get_singleton()->body_get_constant_force(get_rid());
} }
void RigidDynamicBody3D::set_constant_torque(const Vector3 &p_torque) { void RigidBody3D::set_constant_torque(const Vector3 &p_torque) {
PhysicsServer3D::get_singleton()->body_set_constant_torque(get_rid(), p_torque); PhysicsServer3D::get_singleton()->body_set_constant_torque(get_rid(), p_torque);
} }
Vector3 RigidDynamicBody3D::get_constant_torque() const { Vector3 RigidBody3D::get_constant_torque() const {
return PhysicsServer3D::get_singleton()->body_get_constant_torque(get_rid()); return PhysicsServer3D::get_singleton()->body_get_constant_torque(get_rid());
} }
void RigidDynamicBody3D::set_use_continuous_collision_detection(bool p_enable) { void RigidBody3D::set_use_continuous_collision_detection(bool p_enable) {
ccd = p_enable; ccd = p_enable;
PhysicsServer3D::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(), p_enable); PhysicsServer3D::get_singleton()->body_set_enable_continuous_collision_detection(get_rid(), p_enable);
} }
bool RigidDynamicBody3D::is_using_continuous_collision_detection() const { bool RigidBody3D::is_using_continuous_collision_detection() const {
return ccd; return ccd;
} }
void RigidDynamicBody3D::set_contact_monitor(bool p_enabled) { void RigidBody3D::set_contact_monitor(bool p_enabled) {
if (p_enabled == is_contact_monitor_enabled()) { if (p_enabled == is_contact_monitor_enabled()) {
return; return;
} }
@ -947,8 +947,8 @@ void RigidDynamicBody3D::set_contact_monitor(bool p_enabled) {
Node *node = Object::cast_to<Node>(obj); Node *node = Object::cast_to<Node>(obj);
if (node) { if (node) {
node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidDynamicBody3D::_body_enter_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_entered, callable_mp(this, &RigidBody3D::_body_enter_tree));
node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidDynamicBody3D::_body_exit_tree)); node->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &RigidBody3D::_body_exit_tree));
} }
} }
@ -960,11 +960,11 @@ void RigidDynamicBody3D::set_contact_monitor(bool p_enabled) {
} }
} }
bool RigidDynamicBody3D::is_contact_monitor_enabled() const { bool RigidBody3D::is_contact_monitor_enabled() const {
return contact_monitor != nullptr; return contact_monitor != nullptr;
} }
TypedArray<Node3D> RigidDynamicBody3D::get_colliding_bodies() const { TypedArray<Node3D> RigidBody3D::get_colliding_bodies() const {
ERR_FAIL_COND_V(!contact_monitor, TypedArray<Node3D>()); ERR_FAIL_COND_V(!contact_monitor, TypedArray<Node3D>());
TypedArray<Node3D> ret; TypedArray<Node3D> ret;
@ -982,106 +982,106 @@ TypedArray<Node3D> RigidDynamicBody3D::get_colliding_bodies() const {
return ret; return ret;
} }
TypedArray<String> RigidDynamicBody3D::get_configuration_warnings() const { TypedArray<String> RigidBody3D::get_configuration_warnings() const {
Transform3D t = get_transform(); Transform3D t = get_transform();
TypedArray<String> warnings = Node::get_configuration_warnings(); TypedArray<String> warnings = Node::get_configuration_warnings();
if (ABS(t.basis.get_column(0).length() - 1.0) > 0.05 || ABS(t.basis.get_column(1).length() - 1.0) > 0.05 || ABS(t.basis.get_column(2).length() - 1.0) > 0.05) { if (ABS(t.basis.get_column(0).length() - 1.0) > 0.05 || ABS(t.basis.get_column(1).length() - 1.0) > 0.05 || ABS(t.basis.get_column(2).length() - 1.0) > 0.05) {
warnings.push_back(RTR("Size changes to RigidDynamicBody will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.")); warnings.push_back(RTR("Size changes to RigidBody will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."));
} }
return warnings; return warnings;
} }
void RigidDynamicBody3D::_bind_methods() { void RigidBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mass", "mass"), &RigidDynamicBody3D::set_mass); ClassDB::bind_method(D_METHOD("set_mass", "mass"), &RigidBody3D::set_mass);
ClassDB::bind_method(D_METHOD("get_mass"), &RigidDynamicBody3D::get_mass); ClassDB::bind_method(D_METHOD("get_mass"), &RigidBody3D::get_mass);
ClassDB::bind_method(D_METHOD("set_inertia", "inertia"), &RigidDynamicBody3D::set_inertia); ClassDB::bind_method(D_METHOD("set_inertia", "inertia"), &RigidBody3D::set_inertia);
ClassDB::bind_method(D_METHOD("get_inertia"), &RigidDynamicBody3D::get_inertia); ClassDB::bind_method(D_METHOD("get_inertia"), &RigidBody3D::get_inertia);
ClassDB::bind_method(D_METHOD("set_center_of_mass_mode", "mode"), &RigidDynamicBody3D::set_center_of_mass_mode); ClassDB::bind_method(D_METHOD("set_center_of_mass_mode", "mode"), &RigidBody3D::set_center_of_mass_mode);
ClassDB::bind_method(D_METHOD("get_center_of_mass_mode"), &RigidDynamicBody3D::get_center_of_mass_mode); ClassDB::bind_method(D_METHOD("get_center_of_mass_mode"), &RigidBody3D::get_center_of_mass_mode);
ClassDB::bind_method(D_METHOD("set_center_of_mass", "center_of_mass"), &RigidDynamicBody3D::set_center_of_mass); ClassDB::bind_method(D_METHOD("set_center_of_mass", "center_of_mass"), &RigidBody3D::set_center_of_mass);
ClassDB::bind_method(D_METHOD("get_center_of_mass"), &RigidDynamicBody3D::get_center_of_mass); ClassDB::bind_method(D_METHOD("get_center_of_mass"), &RigidBody3D::get_center_of_mass);
ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidDynamicBody3D::set_physics_material_override); ClassDB::bind_method(D_METHOD("set_physics_material_override", "physics_material_override"), &RigidBody3D::set_physics_material_override);
ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidDynamicBody3D::get_physics_material_override); ClassDB::bind_method(D_METHOD("get_physics_material_override"), &RigidBody3D::get_physics_material_override);
ClassDB::bind_method(D_METHOD("set_linear_velocity", "linear_velocity"), &RigidDynamicBody3D::set_linear_velocity); ClassDB::bind_method(D_METHOD("set_linear_velocity", "linear_velocity"), &RigidBody3D::set_linear_velocity);
ClassDB::bind_method(D_METHOD("get_linear_velocity"), &RigidDynamicBody3D::get_linear_velocity); ClassDB::bind_method(D_METHOD("get_linear_velocity"), &RigidBody3D::get_linear_velocity);
ClassDB::bind_method(D_METHOD("set_angular_velocity", "angular_velocity"), &RigidDynamicBody3D::set_angular_velocity); ClassDB::bind_method(D_METHOD("set_angular_velocity", "angular_velocity"), &RigidBody3D::set_angular_velocity);
ClassDB::bind_method(D_METHOD("get_angular_velocity"), &RigidDynamicBody3D::get_angular_velocity); ClassDB::bind_method(D_METHOD("get_angular_velocity"), &RigidBody3D::get_angular_velocity);
ClassDB::bind_method(D_METHOD("get_inverse_inertia_tensor"), &RigidDynamicBody3D::get_inverse_inertia_tensor); ClassDB::bind_method(D_METHOD("get_inverse_inertia_tensor"), &RigidBody3D::get_inverse_inertia_tensor);
ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &RigidDynamicBody3D::set_gravity_scale); ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &RigidBody3D::set_gravity_scale);
ClassDB::bind_method(D_METHOD("get_gravity_scale"), &RigidDynamicBody3D::get_gravity_scale); ClassDB::bind_method(D_METHOD("get_gravity_scale"), &RigidBody3D::get_gravity_scale);
ClassDB::bind_method(D_METHOD("set_linear_damp_mode", "linear_damp_mode"), &RigidDynamicBody3D::set_linear_damp_mode); ClassDB::bind_method(D_METHOD("set_linear_damp_mode", "linear_damp_mode"), &RigidBody3D::set_linear_damp_mode);
ClassDB::bind_method(D_METHOD("get_linear_damp_mode"), &RigidDynamicBody3D::get_linear_damp_mode); ClassDB::bind_method(D_METHOD("get_linear_damp_mode"), &RigidBody3D::get_linear_damp_mode);
ClassDB::bind_method(D_METHOD("set_angular_damp_mode", "angular_damp_mode"), &RigidDynamicBody3D::set_angular_damp_mode); ClassDB::bind_method(D_METHOD("set_angular_damp_mode", "angular_damp_mode"), &RigidBody3D::set_angular_damp_mode);
ClassDB::bind_method(D_METHOD("get_angular_damp_mode"), &RigidDynamicBody3D::get_angular_damp_mode); ClassDB::bind_method(D_METHOD("get_angular_damp_mode"), &RigidBody3D::get_angular_damp_mode);
ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &RigidDynamicBody3D::set_linear_damp); ClassDB::bind_method(D_METHOD("set_linear_damp", "linear_damp"), &RigidBody3D::set_linear_damp);
ClassDB::bind_method(D_METHOD("get_linear_damp"), &RigidDynamicBody3D::get_linear_damp); ClassDB::bind_method(D_METHOD("get_linear_damp"), &RigidBody3D::get_linear_damp);
ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &RigidDynamicBody3D::set_angular_damp); ClassDB::bind_method(D_METHOD("set_angular_damp", "angular_damp"), &RigidBody3D::set_angular_damp);
ClassDB::bind_method(D_METHOD("get_angular_damp"), &RigidDynamicBody3D::get_angular_damp); ClassDB::bind_method(D_METHOD("get_angular_damp"), &RigidBody3D::get_angular_damp);
ClassDB::bind_method(D_METHOD("set_max_contacts_reported", "amount"), &RigidDynamicBody3D::set_max_contacts_reported); ClassDB::bind_method(D_METHOD("set_max_contacts_reported", "amount"), &RigidBody3D::set_max_contacts_reported);
ClassDB::bind_method(D_METHOD("get_max_contacts_reported"), &RigidDynamicBody3D::get_max_contacts_reported); ClassDB::bind_method(D_METHOD("get_max_contacts_reported"), &RigidBody3D::get_max_contacts_reported);
ClassDB::bind_method(D_METHOD("get_contact_count"), &RigidDynamicBody3D::get_contact_count); ClassDB::bind_method(D_METHOD("get_contact_count"), &RigidBody3D::get_contact_count);
ClassDB::bind_method(D_METHOD("set_use_custom_integrator", "enable"), &RigidDynamicBody3D::set_use_custom_integrator); ClassDB::bind_method(D_METHOD("set_use_custom_integrator", "enable"), &RigidBody3D::set_use_custom_integrator);
ClassDB::bind_method(D_METHOD("is_using_custom_integrator"), &RigidDynamicBody3D::is_using_custom_integrator); ClassDB::bind_method(D_METHOD("is_using_custom_integrator"), &RigidBody3D::is_using_custom_integrator);
ClassDB::bind_method(D_METHOD("set_contact_monitor", "enabled"), &RigidDynamicBody3D::set_contact_monitor); ClassDB::bind_method(D_METHOD("set_contact_monitor", "enabled"), &RigidBody3D::set_contact_monitor);
ClassDB::bind_method(D_METHOD("is_contact_monitor_enabled"), &RigidDynamicBody3D::is_contact_monitor_enabled); ClassDB::bind_method(D_METHOD("is_contact_monitor_enabled"), &RigidBody3D::is_contact_monitor_enabled);
ClassDB::bind_method(D_METHOD("set_use_continuous_collision_detection", "enable"), &RigidDynamicBody3D::set_use_continuous_collision_detection); ClassDB::bind_method(D_METHOD("set_use_continuous_collision_detection", "enable"), &RigidBody3D::set_use_continuous_collision_detection);
ClassDB::bind_method(D_METHOD("is_using_continuous_collision_detection"), &RigidDynamicBody3D::is_using_continuous_collision_detection); ClassDB::bind_method(D_METHOD("is_using_continuous_collision_detection"), &RigidBody3D::is_using_continuous_collision_detection);
ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidDynamicBody3D::set_axis_velocity); ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidBody3D::set_axis_velocity);
ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidDynamicBody3D::apply_central_impulse); ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidBody3D::apply_central_impulse);
ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &RigidDynamicBody3D::apply_impulse, Vector3()); ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &RigidBody3D::apply_impulse, Vector3());
ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &RigidDynamicBody3D::apply_torque_impulse); ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &RigidBody3D::apply_torque_impulse);
ClassDB::bind_method(D_METHOD("apply_central_force", "force"), &RigidDynamicBody3D::apply_central_force); ClassDB::bind_method(D_METHOD("apply_central_force", "force"), &RigidBody3D::apply_central_force);
ClassDB::bind_method(D_METHOD("apply_force", "force", "position"), &RigidDynamicBody3D::apply_force, Vector3()); ClassDB::bind_method(D_METHOD("apply_force", "force", "position"), &RigidBody3D::apply_force, Vector3());
ClassDB::bind_method(D_METHOD("apply_torque", "torque"), &RigidDynamicBody3D::apply_torque); ClassDB::bind_method(D_METHOD("apply_torque", "torque"), &RigidBody3D::apply_torque);
ClassDB::bind_method(D_METHOD("add_constant_central_force", "force"), &RigidDynamicBody3D::add_constant_central_force); ClassDB::bind_method(D_METHOD("add_constant_central_force", "force"), &RigidBody3D::add_constant_central_force);
ClassDB::bind_method(D_METHOD("add_constant_force", "force", "position"), &RigidDynamicBody3D::add_constant_force, Vector3()); ClassDB::bind_method(D_METHOD("add_constant_force", "force", "position"), &RigidBody3D::add_constant_force, Vector3());
ClassDB::bind_method(D_METHOD("add_constant_torque", "torque"), &RigidDynamicBody3D::add_constant_torque); ClassDB::bind_method(D_METHOD("add_constant_torque", "torque"), &RigidBody3D::add_constant_torque);
ClassDB::bind_method(D_METHOD("set_constant_force", "force"), &RigidDynamicBody3D::set_constant_force); ClassDB::bind_method(D_METHOD("set_constant_force", "force"), &RigidBody3D::set_constant_force);
ClassDB::bind_method(D_METHOD("get_constant_force"), &RigidDynamicBody3D::get_constant_force); ClassDB::bind_method(D_METHOD("get_constant_force"), &RigidBody3D::get_constant_force);
ClassDB::bind_method(D_METHOD("set_constant_torque", "torque"), &RigidDynamicBody3D::set_constant_torque); ClassDB::bind_method(D_METHOD("set_constant_torque", "torque"), &RigidBody3D::set_constant_torque);
ClassDB::bind_method(D_METHOD("get_constant_torque"), &RigidDynamicBody3D::get_constant_torque); ClassDB::bind_method(D_METHOD("get_constant_torque"), &RigidBody3D::get_constant_torque);
ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidDynamicBody3D::set_sleeping); ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidBody3D::set_sleeping);
ClassDB::bind_method(D_METHOD("is_sleeping"), &RigidDynamicBody3D::is_sleeping); ClassDB::bind_method(D_METHOD("is_sleeping"), &RigidBody3D::is_sleeping);
ClassDB::bind_method(D_METHOD("set_can_sleep", "able_to_sleep"), &RigidDynamicBody3D::set_can_sleep); ClassDB::bind_method(D_METHOD("set_can_sleep", "able_to_sleep"), &RigidBody3D::set_can_sleep);
ClassDB::bind_method(D_METHOD("is_able_to_sleep"), &RigidDynamicBody3D::is_able_to_sleep); ClassDB::bind_method(D_METHOD("is_able_to_sleep"), &RigidBody3D::is_able_to_sleep);
ClassDB::bind_method(D_METHOD("set_lock_rotation_enabled", "lock_rotation"), &RigidDynamicBody3D::set_lock_rotation_enabled); ClassDB::bind_method(D_METHOD("set_lock_rotation_enabled", "lock_rotation"), &RigidBody3D::set_lock_rotation_enabled);
ClassDB::bind_method(D_METHOD("is_lock_rotation_enabled"), &RigidDynamicBody3D::is_lock_rotation_enabled); ClassDB::bind_method(D_METHOD("is_lock_rotation_enabled"), &RigidBody3D::is_lock_rotation_enabled);
ClassDB::bind_method(D_METHOD("set_freeze_enabled", "freeze_mode"), &RigidDynamicBody3D::set_freeze_enabled); ClassDB::bind_method(D_METHOD("set_freeze_enabled", "freeze_mode"), &RigidBody3D::set_freeze_enabled);
ClassDB::bind_method(D_METHOD("is_freeze_enabled"), &RigidDynamicBody3D::is_freeze_enabled); ClassDB::bind_method(D_METHOD("is_freeze_enabled"), &RigidBody3D::is_freeze_enabled);
ClassDB::bind_method(D_METHOD("set_freeze_mode", "freeze_mode"), &RigidDynamicBody3D::set_freeze_mode); ClassDB::bind_method(D_METHOD("set_freeze_mode", "freeze_mode"), &RigidBody3D::set_freeze_mode);
ClassDB::bind_method(D_METHOD("get_freeze_mode"), &RigidDynamicBody3D::get_freeze_mode); ClassDB::bind_method(D_METHOD("get_freeze_mode"), &RigidBody3D::get_freeze_mode);
ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidDynamicBody3D::get_colliding_bodies); ClassDB::bind_method(D_METHOD("get_colliding_bodies"), &RigidBody3D::get_colliding_bodies);
GDVIRTUAL_BIND(_integrate_forces, "state"); GDVIRTUAL_BIND(_integrate_forces, "state");
@ -1129,7 +1129,7 @@ void RigidDynamicBody3D::_bind_methods() {
BIND_ENUM_CONSTANT(DAMP_MODE_REPLACE); BIND_ENUM_CONSTANT(DAMP_MODE_REPLACE);
} }
void RigidDynamicBody3D::_validate_property(PropertyInfo &p_property) const { void RigidBody3D::_validate_property(PropertyInfo &p_property) const {
if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM) { if (center_of_mass_mode != CENTER_OF_MASS_MODE_CUSTOM) {
if (p_property.name == "center_of_mass") { if (p_property.name == "center_of_mass") {
p_property.usage = PROPERTY_USAGE_NO_EDITOR; p_property.usage = PROPERTY_USAGE_NO_EDITOR;
@ -1137,18 +1137,18 @@ void RigidDynamicBody3D::_validate_property(PropertyInfo &p_property) const {
} }
} }
RigidDynamicBody3D::RigidDynamicBody3D() : RigidBody3D::RigidBody3D() :
PhysicsBody3D(PhysicsServer3D::BODY_MODE_DYNAMIC) { PhysicsBody3D(PhysicsServer3D::BODY_MODE_RIGID) {
PhysicsServer3D::get_singleton()->body_set_state_sync_callback(get_rid(), this, _body_state_changed_callback); PhysicsServer3D::get_singleton()->body_set_state_sync_callback(get_rid(), this, _body_state_changed_callback);
} }
RigidDynamicBody3D::~RigidDynamicBody3D() { RigidBody3D::~RigidBody3D() {
if (contact_monitor) { if (contact_monitor) {
memdelete(contact_monitor); memdelete(contact_monitor);
} }
} }
void RigidDynamicBody3D::_reload_physics_characteristics() { void RigidBody3D::_reload_physics_characteristics() {
if (physics_material_override.is_null()) { if (physics_material_override.is_null()) {
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, 0); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_BOUNCE, 0);
PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, 1); PhysicsServer3D::get_singleton()->body_set_param(get_rid(), PhysicsServer3D::BODY_PARAM_FRICTION, 1);
@ -3421,7 +3421,7 @@ void PhysicalBone3D::_start_physics_simulation() {
return; return;
} }
reset_to_rest_position(); reset_to_rest_position();
set_body_mode(PhysicsServer3D::BODY_MODE_DYNAMIC); set_body_mode(PhysicsServer3D::BODY_MODE_RIGID);
PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer()); PhysicsServer3D::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer());
PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask()); PhysicsServer3D::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask());
PhysicsServer3D::get_singleton()->body_set_collision_priority(get_rid(), get_collision_priority()); PhysicsServer3D::get_singleton()->body_set_collision_priority(get_rid(), get_collision_priority());

View File

@ -129,8 +129,8 @@ private:
bool is_sync_to_physics_enabled() const; bool is_sync_to_physics_enabled() const;
}; };
class RigidDynamicBody3D : public PhysicsBody3D { class RigidBody3D : public PhysicsBody3D {
GDCLASS(RigidDynamicBody3D, PhysicsBody3D); GDCLASS(RigidBody3D, PhysicsBody3D);
public: public:
enum FreezeMode { enum FreezeMode {
@ -198,7 +198,7 @@ private:
tagged = false; tagged = false;
} }
}; };
struct RigidDynamicBody3D_RemoveAction { struct RigidBody3D_RemoveAction {
RID rid; RID rid;
ObjectID body_id; ObjectID body_id;
ShapePair pair; ShapePair pair;
@ -327,16 +327,16 @@ public:
virtual TypedArray<String> get_configuration_warnings() const override; virtual TypedArray<String> get_configuration_warnings() const override;
RigidDynamicBody3D(); RigidBody3D();
~RigidDynamicBody3D(); ~RigidBody3D();
private: private:
void _reload_physics_characteristics(); void _reload_physics_characteristics();
}; };
VARIANT_ENUM_CAST(RigidDynamicBody3D::FreezeMode); VARIANT_ENUM_CAST(RigidBody3D::FreezeMode);
VARIANT_ENUM_CAST(RigidDynamicBody3D::CenterOfMassMode); VARIANT_ENUM_CAST(RigidBody3D::CenterOfMassMode);
VARIANT_ENUM_CAST(RigidDynamicBody3D::DampMode); VARIANT_ENUM_CAST(RigidBody3D::DampMode);
class KinematicCollision3D; class KinematicCollision3D;

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* soft_dynamic_body_3d.cpp */ /* soft_body_3d.cpp */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#include "soft_dynamic_body_3d.h" #include "soft_body_3d.h"
#include "scene/3d/physics_body_3d.h" #include "scene/3d/physics_body_3d.h"
SoftDynamicBodyRenderingServerHandler::SoftDynamicBodyRenderingServerHandler() {} SoftBodyRenderingServerHandler::SoftBodyRenderingServerHandler() {}
void SoftDynamicBodyRenderingServerHandler::prepare(RID p_mesh, int p_surface) { void SoftBodyRenderingServerHandler::prepare(RID p_mesh, int p_surface) {
clear(); clear();
ERR_FAIL_COND(!p_mesh.is_valid()); ERR_FAIL_COND(!p_mesh.is_valid());
@ -56,7 +56,7 @@ void SoftDynamicBodyRenderingServerHandler::prepare(RID p_mesh, int p_surface) {
offset_normal = surface_offsets[RS::ARRAY_NORMAL]; offset_normal = surface_offsets[RS::ARRAY_NORMAL];
} }
void SoftDynamicBodyRenderingServerHandler::clear() { void SoftBodyRenderingServerHandler::clear() {
buffer.resize(0); buffer.resize(0);
stride = 0; stride = 0;
offset_vertices = 0; offset_vertices = 0;
@ -66,23 +66,23 @@ void SoftDynamicBodyRenderingServerHandler::clear() {
mesh = RID(); mesh = RID();
} }
void SoftDynamicBodyRenderingServerHandler::open() { void SoftBodyRenderingServerHandler::open() {
write_buffer = buffer.ptrw(); write_buffer = buffer.ptrw();
} }
void SoftDynamicBodyRenderingServerHandler::close() { void SoftBodyRenderingServerHandler::close() {
write_buffer = nullptr; write_buffer = nullptr;
} }
void SoftDynamicBodyRenderingServerHandler::commit_changes() { void SoftBodyRenderingServerHandler::commit_changes() {
RS::get_singleton()->mesh_surface_update_vertex_region(mesh, surface, 0, buffer); RS::get_singleton()->mesh_surface_update_vertex_region(mesh, surface, 0, buffer);
} }
void SoftDynamicBodyRenderingServerHandler::set_vertex(int p_vertex_id, const void *p_vector3) { void SoftBodyRenderingServerHandler::set_vertex(int p_vertex_id, const void *p_vector3) {
memcpy(&write_buffer[p_vertex_id * stride + offset_vertices], p_vector3, sizeof(float) * 3); memcpy(&write_buffer[p_vertex_id * stride + offset_vertices], p_vector3, sizeof(float) * 3);
} }
void SoftDynamicBodyRenderingServerHandler::set_normal(int p_vertex_id, const void *p_vector3) { void SoftBodyRenderingServerHandler::set_normal(int p_vertex_id, const void *p_vector3) {
// Store normal vector in A2B10G10R10 format. // Store normal vector in A2B10G10R10 format.
Vector3 n; Vector3 n;
memcpy(&n, p_vector3, sizeof(Vector3)); memcpy(&n, p_vector3, sizeof(Vector3));
@ -95,28 +95,28 @@ void SoftDynamicBodyRenderingServerHandler::set_normal(int p_vertex_id, const vo
memcpy(&write_buffer[p_vertex_id * stride + offset_normal], &value, sizeof(uint32_t)); memcpy(&write_buffer[p_vertex_id * stride + offset_normal], &value, sizeof(uint32_t));
} }
void SoftDynamicBodyRenderingServerHandler::set_aabb(const AABB &p_aabb) { void SoftBodyRenderingServerHandler::set_aabb(const AABB &p_aabb) {
RS::get_singleton()->mesh_set_custom_aabb(mesh, p_aabb); RS::get_singleton()->mesh_set_custom_aabb(mesh, p_aabb);
} }
SoftDynamicBody3D::PinnedPoint::PinnedPoint() { SoftBody3D::PinnedPoint::PinnedPoint() {
} }
SoftDynamicBody3D::PinnedPoint::PinnedPoint(const PinnedPoint &obj_tocopy) { SoftBody3D::PinnedPoint::PinnedPoint(const PinnedPoint &obj_tocopy) {
point_index = obj_tocopy.point_index; point_index = obj_tocopy.point_index;
spatial_attachment_path = obj_tocopy.spatial_attachment_path; spatial_attachment_path = obj_tocopy.spatial_attachment_path;
spatial_attachment = obj_tocopy.spatial_attachment; spatial_attachment = obj_tocopy.spatial_attachment;
offset = obj_tocopy.offset; offset = obj_tocopy.offset;
} }
void SoftDynamicBody3D::PinnedPoint::operator=(const PinnedPoint &obj) { void SoftBody3D::PinnedPoint::operator=(const PinnedPoint &obj) {
point_index = obj.point_index; point_index = obj.point_index;
spatial_attachment_path = obj.spatial_attachment_path; spatial_attachment_path = obj.spatial_attachment_path;
spatial_attachment = obj.spatial_attachment; spatial_attachment = obj.spatial_attachment;
offset = obj.offset; offset = obj.offset;
} }
void SoftDynamicBody3D::_update_pickable() { void SoftBody3D::_update_pickable() {
if (!is_inside_tree()) { if (!is_inside_tree()) {
return; return;
} }
@ -124,7 +124,7 @@ void SoftDynamicBody3D::_update_pickable() {
PhysicsServer3D::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable); PhysicsServer3D::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable);
} }
bool SoftDynamicBody3D::_set(const StringName &p_name, const Variant &p_value) { bool SoftBody3D::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name; String name = p_name;
String which = name.get_slicec('/', 0); String which = name.get_slicec('/', 0);
@ -141,7 +141,7 @@ bool SoftDynamicBody3D::_set(const StringName &p_name, const Variant &p_value) {
return false; return false;
} }
bool SoftDynamicBody3D::_get(const StringName &p_name, Variant &r_ret) const { bool SoftBody3D::_get(const StringName &p_name, Variant &r_ret) const {
String name = p_name; String name = p_name;
String which = name.get_slicec('/', 0); String which = name.get_slicec('/', 0);
@ -168,7 +168,7 @@ bool SoftDynamicBody3D::_get(const StringName &p_name, Variant &r_ret) const {
return false; return false;
} }
void SoftDynamicBody3D::_get_property_list(List<PropertyInfo> *p_list) const { void SoftBody3D::_get_property_list(List<PropertyInfo> *p_list) const {
const int pinned_points_indices_size = pinned_points.size(); const int pinned_points_indices_size = pinned_points.size();
p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, PNAME("pinned_points"))); p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, PNAME("pinned_points")));
@ -181,7 +181,7 @@ void SoftDynamicBody3D::_get_property_list(List<PropertyInfo> *p_list) const {
} }
} }
bool SoftDynamicBody3D::_set_property_pinned_points_indices(const Array &p_indices) { bool SoftBody3D::_set_property_pinned_points_indices(const Array &p_indices) {
const int p_indices_size = p_indices.size(); const int p_indices_size = p_indices.size();
{ // Remove the pined points on physics server that will be removed by resize { // Remove the pined points on physics server that will be removed by resize
@ -210,7 +210,7 @@ bool SoftDynamicBody3D::_set_property_pinned_points_indices(const Array &p_indic
return true; return true;
} }
bool SoftDynamicBody3D::_set_property_pinned_points_attachment(int p_item, const String &p_what, const Variant &p_value) { bool SoftBody3D::_set_property_pinned_points_attachment(int p_item, const String &p_what, const Variant &p_value) {
if (pinned_points.size() <= p_item) { if (pinned_points.size() <= p_item) {
return false; return false;
} }
@ -229,7 +229,7 @@ bool SoftDynamicBody3D::_set_property_pinned_points_attachment(int p_item, const
return true; return true;
} }
bool SoftDynamicBody3D::_get_property_pinned_points(int p_item, const String &p_what, Variant &r_ret) const { bool SoftBody3D::_get_property_pinned_points(int p_item, const String &p_what, Variant &r_ret) const {
if (pinned_points.size() <= p_item) { if (pinned_points.size() <= p_item) {
return false; return false;
} }
@ -248,7 +248,7 @@ bool SoftDynamicBody3D::_get_property_pinned_points(int p_item, const String &p_
return true; return true;
} }
void SoftDynamicBody3D::_notification(int p_what) { void SoftBody3D::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_ENTER_WORLD: { case NOTIFICATION_ENTER_WORLD: {
if (Engine::get_singleton()->is_editor_hint()) { if (Engine::get_singleton()->is_editor_hint()) {
@ -313,56 +313,56 @@ void SoftDynamicBody3D::_notification(int p_what) {
} }
} }
void SoftDynamicBody3D::_bind_methods() { void SoftBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_physics_rid"), &SoftDynamicBody3D::get_physics_rid); ClassDB::bind_method(D_METHOD("get_physics_rid"), &SoftBody3D::get_physics_rid);
ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &SoftDynamicBody3D::set_collision_mask); ClassDB::bind_method(D_METHOD("set_collision_mask", "collision_mask"), &SoftBody3D::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &SoftDynamicBody3D::get_collision_mask); ClassDB::bind_method(D_METHOD("get_collision_mask"), &SoftBody3D::get_collision_mask);
ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &SoftDynamicBody3D::set_collision_layer); ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &SoftBody3D::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &SoftDynamicBody3D::get_collision_layer); ClassDB::bind_method(D_METHOD("get_collision_layer"), &SoftBody3D::get_collision_layer);
ClassDB::bind_method(D_METHOD("set_collision_mask_value", "layer_number", "value"), &SoftDynamicBody3D::set_collision_mask_value); ClassDB::bind_method(D_METHOD("set_collision_mask_value", "layer_number", "value"), &SoftBody3D::set_collision_mask_value);
ClassDB::bind_method(D_METHOD("get_collision_mask_value", "layer_number"), &SoftDynamicBody3D::get_collision_mask_value); ClassDB::bind_method(D_METHOD("get_collision_mask_value", "layer_number"), &SoftBody3D::get_collision_mask_value);
ClassDB::bind_method(D_METHOD("set_collision_layer_value", "layer_number", "value"), &SoftDynamicBody3D::set_collision_layer_value); ClassDB::bind_method(D_METHOD("set_collision_layer_value", "layer_number", "value"), &SoftBody3D::set_collision_layer_value);
ClassDB::bind_method(D_METHOD("get_collision_layer_value", "layer_number"), &SoftDynamicBody3D::get_collision_layer_value); ClassDB::bind_method(D_METHOD("get_collision_layer_value", "layer_number"), &SoftBody3D::get_collision_layer_value);
ClassDB::bind_method(D_METHOD("set_parent_collision_ignore", "parent_collision_ignore"), &SoftDynamicBody3D::set_parent_collision_ignore); ClassDB::bind_method(D_METHOD("set_parent_collision_ignore", "parent_collision_ignore"), &SoftBody3D::set_parent_collision_ignore);
ClassDB::bind_method(D_METHOD("get_parent_collision_ignore"), &SoftDynamicBody3D::get_parent_collision_ignore); ClassDB::bind_method(D_METHOD("get_parent_collision_ignore"), &SoftBody3D::get_parent_collision_ignore);
ClassDB::bind_method(D_METHOD("set_disable_mode", "mode"), &SoftDynamicBody3D::set_disable_mode); ClassDB::bind_method(D_METHOD("set_disable_mode", "mode"), &SoftBody3D::set_disable_mode);
ClassDB::bind_method(D_METHOD("get_disable_mode"), &SoftDynamicBody3D::get_disable_mode); ClassDB::bind_method(D_METHOD("get_disable_mode"), &SoftBody3D::get_disable_mode);
ClassDB::bind_method(D_METHOD("get_collision_exceptions"), &SoftDynamicBody3D::get_collision_exceptions); ClassDB::bind_method(D_METHOD("get_collision_exceptions"), &SoftBody3D::get_collision_exceptions);
ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &SoftDynamicBody3D::add_collision_exception_with); ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &SoftBody3D::add_collision_exception_with);
ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &SoftDynamicBody3D::remove_collision_exception_with); ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &SoftBody3D::remove_collision_exception_with);
ClassDB::bind_method(D_METHOD("set_simulation_precision", "simulation_precision"), &SoftDynamicBody3D::set_simulation_precision); ClassDB::bind_method(D_METHOD("set_simulation_precision", "simulation_precision"), &SoftBody3D::set_simulation_precision);
ClassDB::bind_method(D_METHOD("get_simulation_precision"), &SoftDynamicBody3D::get_simulation_precision); ClassDB::bind_method(D_METHOD("get_simulation_precision"), &SoftBody3D::get_simulation_precision);
ClassDB::bind_method(D_METHOD("set_total_mass", "mass"), &SoftDynamicBody3D::set_total_mass); ClassDB::bind_method(D_METHOD("set_total_mass", "mass"), &SoftBody3D::set_total_mass);
ClassDB::bind_method(D_METHOD("get_total_mass"), &SoftDynamicBody3D::get_total_mass); ClassDB::bind_method(D_METHOD("get_total_mass"), &SoftBody3D::get_total_mass);
ClassDB::bind_method(D_METHOD("set_linear_stiffness", "linear_stiffness"), &SoftDynamicBody3D::set_linear_stiffness); ClassDB::bind_method(D_METHOD("set_linear_stiffness", "linear_stiffness"), &SoftBody3D::set_linear_stiffness);
ClassDB::bind_method(D_METHOD("get_linear_stiffness"), &SoftDynamicBody3D::get_linear_stiffness); ClassDB::bind_method(D_METHOD("get_linear_stiffness"), &SoftBody3D::get_linear_stiffness);
ClassDB::bind_method(D_METHOD("set_pressure_coefficient", "pressure_coefficient"), &SoftDynamicBody3D::set_pressure_coefficient); ClassDB::bind_method(D_METHOD("set_pressure_coefficient", "pressure_coefficient"), &SoftBody3D::set_pressure_coefficient);
ClassDB::bind_method(D_METHOD("get_pressure_coefficient"), &SoftDynamicBody3D::get_pressure_coefficient); ClassDB::bind_method(D_METHOD("get_pressure_coefficient"), &SoftBody3D::get_pressure_coefficient);
ClassDB::bind_method(D_METHOD("set_damping_coefficient", "damping_coefficient"), &SoftDynamicBody3D::set_damping_coefficient); ClassDB::bind_method(D_METHOD("set_damping_coefficient", "damping_coefficient"), &SoftBody3D::set_damping_coefficient);
ClassDB::bind_method(D_METHOD("get_damping_coefficient"), &SoftDynamicBody3D::get_damping_coefficient); ClassDB::bind_method(D_METHOD("get_damping_coefficient"), &SoftBody3D::get_damping_coefficient);
ClassDB::bind_method(D_METHOD("set_drag_coefficient", "drag_coefficient"), &SoftDynamicBody3D::set_drag_coefficient); ClassDB::bind_method(D_METHOD("set_drag_coefficient", "drag_coefficient"), &SoftBody3D::set_drag_coefficient);
ClassDB::bind_method(D_METHOD("get_drag_coefficient"), &SoftDynamicBody3D::get_drag_coefficient); ClassDB::bind_method(D_METHOD("get_drag_coefficient"), &SoftBody3D::get_drag_coefficient);
ClassDB::bind_method(D_METHOD("get_point_transform", "point_index"), &SoftDynamicBody3D::get_point_transform); ClassDB::bind_method(D_METHOD("get_point_transform", "point_index"), &SoftBody3D::get_point_transform);
ClassDB::bind_method(D_METHOD("set_point_pinned", "point_index", "pinned", "attachment_path"), &SoftDynamicBody3D::pin_point, DEFVAL(NodePath())); ClassDB::bind_method(D_METHOD("set_point_pinned", "point_index", "pinned", "attachment_path"), &SoftBody3D::pin_point, DEFVAL(NodePath()));
ClassDB::bind_method(D_METHOD("is_point_pinned", "point_index"), &SoftDynamicBody3D::is_point_pinned); ClassDB::bind_method(D_METHOD("is_point_pinned", "point_index"), &SoftBody3D::is_point_pinned);
ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &SoftDynamicBody3D::set_ray_pickable); ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &SoftBody3D::set_ray_pickable);
ClassDB::bind_method(D_METHOD("is_ray_pickable"), &SoftDynamicBody3D::is_ray_pickable); ClassDB::bind_method(D_METHOD("is_ray_pickable"), &SoftBody3D::is_ray_pickable);
ADD_GROUP("Collision", "collision_"); ADD_GROUP("Collision", "collision_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer");
@ -384,7 +384,7 @@ void SoftDynamicBody3D::_bind_methods() {
BIND_ENUM_CONSTANT(DISABLE_MODE_KEEP_ACTIVE); BIND_ENUM_CONSTANT(DISABLE_MODE_KEEP_ACTIVE);
} }
TypedArray<String> SoftDynamicBody3D::get_configuration_warnings() const { TypedArray<String> SoftBody3D::get_configuration_warnings() const {
TypedArray<String> warnings = Node::get_configuration_warnings(); TypedArray<String> warnings = Node::get_configuration_warnings();
if (mesh.is_null()) { if (mesh.is_null()) {
@ -393,13 +393,13 @@ TypedArray<String> SoftDynamicBody3D::get_configuration_warnings() const {
Transform3D t = get_transform(); Transform3D t = get_transform();
if ((ABS(t.basis.get_column(0).length() - 1.0) > 0.05 || ABS(t.basis.get_column(1).length() - 1.0) > 0.05 || ABS(t.basis.get_column(2).length() - 1.0) > 0.05)) { if ((ABS(t.basis.get_column(0).length() - 1.0) > 0.05 || ABS(t.basis.get_column(1).length() - 1.0) > 0.05 || ABS(t.basis.get_column(2).length() - 1.0) > 0.05)) {
warnings.push_back(RTR("Size changes to SoftDynamicBody3D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead.")); warnings.push_back(RTR("Size changes to SoftBody3D will be overridden by the physics engine when running.\nChange the size in children collision shapes instead."));
} }
return warnings; return warnings;
} }
void SoftDynamicBody3D::_update_physics_server() { void SoftBody3D::_update_physics_server() {
if (!simulation_started) { if (!simulation_started) {
return; return;
} }
@ -415,7 +415,7 @@ void SoftDynamicBody3D::_update_physics_server() {
} }
} }
void SoftDynamicBody3D::_draw_soft_mesh() { void SoftBody3D::_draw_soft_mesh() {
if (mesh.is_null()) { if (mesh.is_null()) {
return; return;
} }
@ -445,7 +445,7 @@ void SoftDynamicBody3D::_draw_soft_mesh() {
rendering_server_handler->commit_changes(); rendering_server_handler->commit_changes();
} }
void SoftDynamicBody3D::_prepare_physics_server() { void SoftBody3D::_prepare_physics_server() {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) { if (Engine::get_singleton()->is_editor_hint()) {
if (mesh.is_valid()) { if (mesh.is_valid()) {
@ -465,22 +465,22 @@ void SoftDynamicBody3D::_prepare_physics_server() {
mesh_rid = mesh->get_rid(); mesh_rid = mesh->get_rid();
} }
PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, mesh_rid); PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, mesh_rid);
RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &SoftDynamicBody3D::_draw_soft_mesh)); RS::get_singleton()->connect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh));
} else { } else {
PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, RID()); PhysicsServer3D::get_singleton()->soft_body_set_mesh(physics_rid, RID());
if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &SoftDynamicBody3D::_draw_soft_mesh))) { if (RS::get_singleton()->is_connected("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh))) {
RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &SoftDynamicBody3D::_draw_soft_mesh)); RS::get_singleton()->disconnect("frame_pre_draw", callable_mp(this, &SoftBody3D::_draw_soft_mesh));
} }
} }
} }
void SoftDynamicBody3D::_become_mesh_owner() { void SoftBody3D::_become_mesh_owner() {
Vector<Ref<Material>> copy_materials; Vector<Ref<Material>> copy_materials;
copy_materials.append_array(surface_override_materials); copy_materials.append_array(surface_override_materials);
ERR_FAIL_COND(!mesh->get_surface_count()); ERR_FAIL_COND(!mesh->get_surface_count());
// Get current mesh array and create new mesh array with necessary flag for SoftDynamicBody // Get current mesh array and create new mesh array with necessary flag for SoftBody
Array surface_arrays = mesh->surface_get_arrays(0); Array surface_arrays = mesh->surface_get_arrays(0);
Array surface_blend_arrays = mesh->surface_get_blend_shape_arrays(0); Array surface_blend_arrays = mesh->surface_get_blend_shape_arrays(0);
Dictionary surface_lods = mesh->surface_get_lods(0); Dictionary surface_lods = mesh->surface_get_lods(0);
@ -502,25 +502,25 @@ void SoftDynamicBody3D::_become_mesh_owner() {
owned_mesh = soft_mesh->get_rid(); owned_mesh = soft_mesh->get_rid();
} }
void SoftDynamicBody3D::set_collision_mask(uint32_t p_mask) { void SoftBody3D::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask; collision_mask = p_mask;
PhysicsServer3D::get_singleton()->soft_body_set_collision_mask(physics_rid, p_mask); PhysicsServer3D::get_singleton()->soft_body_set_collision_mask(physics_rid, p_mask);
} }
uint32_t SoftDynamicBody3D::get_collision_mask() const { uint32_t SoftBody3D::get_collision_mask() const {
return collision_mask; return collision_mask;
} }
void SoftDynamicBody3D::set_collision_layer(uint32_t p_layer) { void SoftBody3D::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer; collision_layer = p_layer;
PhysicsServer3D::get_singleton()->soft_body_set_collision_layer(physics_rid, p_layer); PhysicsServer3D::get_singleton()->soft_body_set_collision_layer(physics_rid, p_layer);
} }
uint32_t SoftDynamicBody3D::get_collision_layer() const { uint32_t SoftBody3D::get_collision_layer() const {
return collision_layer; return collision_layer;
} }
void SoftDynamicBody3D::set_collision_layer_value(int p_layer_number, bool p_value) { void SoftBody3D::set_collision_layer_value(int p_layer_number, bool p_value) {
ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive.");
ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive.");
uint32_t collision_layer = get_collision_layer(); uint32_t collision_layer = get_collision_layer();
@ -532,13 +532,13 @@ void SoftDynamicBody3D::set_collision_layer_value(int p_layer_number, bool p_val
set_collision_layer(collision_layer); set_collision_layer(collision_layer);
} }
bool SoftDynamicBody3D::get_collision_layer_value(int p_layer_number) const { bool SoftBody3D::get_collision_layer_value(int p_layer_number) const {
ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Collision layer number must be between 1 and 32 inclusive.");
ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Collision layer number must be between 1 and 32 inclusive.");
return get_collision_layer() & (1 << (p_layer_number - 1)); return get_collision_layer() & (1 << (p_layer_number - 1));
} }
void SoftDynamicBody3D::set_collision_mask_value(int p_layer_number, bool p_value) { void SoftBody3D::set_collision_mask_value(int p_layer_number, bool p_value) {
ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_MSG(p_layer_number < 1, "Collision layer number must be between 1 and 32 inclusive.");
ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_MSG(p_layer_number > 32, "Collision layer number must be between 1 and 32 inclusive.");
uint32_t mask = get_collision_mask(); uint32_t mask = get_collision_mask();
@ -550,13 +550,13 @@ void SoftDynamicBody3D::set_collision_mask_value(int p_layer_number, bool p_valu
set_collision_mask(mask); set_collision_mask(mask);
} }
bool SoftDynamicBody3D::get_collision_mask_value(int p_layer_number) const { bool SoftBody3D::get_collision_mask_value(int p_layer_number) const {
ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_V_MSG(p_layer_number < 1, false, "Collision layer number must be between 1 and 32 inclusive.");
ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Collision layer number must be between 1 and 32 inclusive."); ERR_FAIL_COND_V_MSG(p_layer_number > 32, false, "Collision layer number must be between 1 and 32 inclusive.");
return get_collision_mask() & (1 << (p_layer_number - 1)); return get_collision_mask() & (1 << (p_layer_number - 1));
} }
void SoftDynamicBody3D::set_disable_mode(DisableMode p_mode) { void SoftBody3D::set_disable_mode(DisableMode p_mode) {
if (disable_mode == p_mode) { if (disable_mode == p_mode) {
return; return;
} }
@ -568,30 +568,30 @@ void SoftDynamicBody3D::set_disable_mode(DisableMode p_mode) {
} }
} }
SoftDynamicBody3D::DisableMode SoftDynamicBody3D::get_disable_mode() const { SoftBody3D::DisableMode SoftBody3D::get_disable_mode() const {
return disable_mode; return disable_mode;
} }
void SoftDynamicBody3D::set_parent_collision_ignore(const NodePath &p_parent_collision_ignore) { void SoftBody3D::set_parent_collision_ignore(const NodePath &p_parent_collision_ignore) {
parent_collision_ignore = p_parent_collision_ignore; parent_collision_ignore = p_parent_collision_ignore;
} }
const NodePath &SoftDynamicBody3D::get_parent_collision_ignore() const { const NodePath &SoftBody3D::get_parent_collision_ignore() const {
return parent_collision_ignore; return parent_collision_ignore;
} }
void SoftDynamicBody3D::set_pinned_points_indices(Vector<SoftDynamicBody3D::PinnedPoint> p_pinned_points_indices) { void SoftBody3D::set_pinned_points_indices(Vector<SoftBody3D::PinnedPoint> p_pinned_points_indices) {
pinned_points = p_pinned_points_indices; pinned_points = p_pinned_points_indices;
for (int i = pinned_points.size() - 1; 0 <= i; --i) { for (int i = pinned_points.size() - 1; 0 <= i; --i) {
pin_point(p_pinned_points_indices[i].point_index, true); pin_point(p_pinned_points_indices[i].point_index, true);
} }
} }
Vector<SoftDynamicBody3D::PinnedPoint> SoftDynamicBody3D::get_pinned_points_indices() { Vector<SoftBody3D::PinnedPoint> SoftBody3D::get_pinned_points_indices() {
return pinned_points; return pinned_points;
} }
TypedArray<PhysicsBody3D> SoftDynamicBody3D::get_collision_exceptions() { TypedArray<PhysicsBody3D> SoftBody3D::get_collision_exceptions() {
List<RID> exceptions; List<RID> exceptions;
PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions); PhysicsServer3D::get_singleton()->soft_body_get_collision_exceptions(physics_rid, &exceptions);
TypedArray<PhysicsBody3D> ret; TypedArray<PhysicsBody3D> ret;
@ -604,77 +604,77 @@ TypedArray<PhysicsBody3D> SoftDynamicBody3D::get_collision_exceptions() {
return ret; return ret;
} }
void SoftDynamicBody3D::add_collision_exception_with(Node *p_node) { void SoftBody3D::add_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node); ERR_FAIL_NULL(p_node);
CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node); CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds."); ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds.");
PhysicsServer3D::get_singleton()->soft_body_add_collision_exception(physics_rid, collision_object->get_rid()); PhysicsServer3D::get_singleton()->soft_body_add_collision_exception(physics_rid, collision_object->get_rid());
} }
void SoftDynamicBody3D::remove_collision_exception_with(Node *p_node) { void SoftBody3D::remove_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node); ERR_FAIL_NULL(p_node);
CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node); CollisionObject3D *collision_object = Object::cast_to<CollisionObject3D>(p_node);
ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds."); ERR_FAIL_COND_MSG(!collision_object, "Collision exception only works between two CollisionObject3Ds.");
PhysicsServer3D::get_singleton()->soft_body_remove_collision_exception(physics_rid, collision_object->get_rid()); PhysicsServer3D::get_singleton()->soft_body_remove_collision_exception(physics_rid, collision_object->get_rid());
} }
int SoftDynamicBody3D::get_simulation_precision() { int SoftBody3D::get_simulation_precision() {
return PhysicsServer3D::get_singleton()->soft_body_get_simulation_precision(physics_rid); return PhysicsServer3D::get_singleton()->soft_body_get_simulation_precision(physics_rid);
} }
void SoftDynamicBody3D::set_simulation_precision(int p_simulation_precision) { void SoftBody3D::set_simulation_precision(int p_simulation_precision) {
PhysicsServer3D::get_singleton()->soft_body_set_simulation_precision(physics_rid, p_simulation_precision); PhysicsServer3D::get_singleton()->soft_body_set_simulation_precision(physics_rid, p_simulation_precision);
} }
real_t SoftDynamicBody3D::get_total_mass() { real_t SoftBody3D::get_total_mass() {
return PhysicsServer3D::get_singleton()->soft_body_get_total_mass(physics_rid); return PhysicsServer3D::get_singleton()->soft_body_get_total_mass(physics_rid);
} }
void SoftDynamicBody3D::set_total_mass(real_t p_total_mass) { void SoftBody3D::set_total_mass(real_t p_total_mass) {
PhysicsServer3D::get_singleton()->soft_body_set_total_mass(physics_rid, p_total_mass); PhysicsServer3D::get_singleton()->soft_body_set_total_mass(physics_rid, p_total_mass);
} }
void SoftDynamicBody3D::set_linear_stiffness(real_t p_linear_stiffness) { void SoftBody3D::set_linear_stiffness(real_t p_linear_stiffness) {
PhysicsServer3D::get_singleton()->soft_body_set_linear_stiffness(physics_rid, p_linear_stiffness); PhysicsServer3D::get_singleton()->soft_body_set_linear_stiffness(physics_rid, p_linear_stiffness);
} }
real_t SoftDynamicBody3D::get_linear_stiffness() { real_t SoftBody3D::get_linear_stiffness() {
return PhysicsServer3D::get_singleton()->soft_body_get_linear_stiffness(physics_rid); return PhysicsServer3D::get_singleton()->soft_body_get_linear_stiffness(physics_rid);
} }
real_t SoftDynamicBody3D::get_pressure_coefficient() { real_t SoftBody3D::get_pressure_coefficient() {
return PhysicsServer3D::get_singleton()->soft_body_get_pressure_coefficient(physics_rid); return PhysicsServer3D::get_singleton()->soft_body_get_pressure_coefficient(physics_rid);
} }
void SoftDynamicBody3D::set_pressure_coefficient(real_t p_pressure_coefficient) { void SoftBody3D::set_pressure_coefficient(real_t p_pressure_coefficient) {
PhysicsServer3D::get_singleton()->soft_body_set_pressure_coefficient(physics_rid, p_pressure_coefficient); PhysicsServer3D::get_singleton()->soft_body_set_pressure_coefficient(physics_rid, p_pressure_coefficient);
} }
real_t SoftDynamicBody3D::get_damping_coefficient() { real_t SoftBody3D::get_damping_coefficient() {
return PhysicsServer3D::get_singleton()->soft_body_get_damping_coefficient(physics_rid); return PhysicsServer3D::get_singleton()->soft_body_get_damping_coefficient(physics_rid);
} }
void SoftDynamicBody3D::set_damping_coefficient(real_t p_damping_coefficient) { void SoftBody3D::set_damping_coefficient(real_t p_damping_coefficient) {
PhysicsServer3D::get_singleton()->soft_body_set_damping_coefficient(physics_rid, p_damping_coefficient); PhysicsServer3D::get_singleton()->soft_body_set_damping_coefficient(physics_rid, p_damping_coefficient);
} }
real_t SoftDynamicBody3D::get_drag_coefficient() { real_t SoftBody3D::get_drag_coefficient() {
return PhysicsServer3D::get_singleton()->soft_body_get_drag_coefficient(physics_rid); return PhysicsServer3D::get_singleton()->soft_body_get_drag_coefficient(physics_rid);
} }
void SoftDynamicBody3D::set_drag_coefficient(real_t p_drag_coefficient) { void SoftBody3D::set_drag_coefficient(real_t p_drag_coefficient) {
PhysicsServer3D::get_singleton()->soft_body_set_drag_coefficient(physics_rid, p_drag_coefficient); PhysicsServer3D::get_singleton()->soft_body_set_drag_coefficient(physics_rid, p_drag_coefficient);
} }
Vector3 SoftDynamicBody3D::get_point_transform(int p_point_index) { Vector3 SoftBody3D::get_point_transform(int p_point_index) {
return PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, p_point_index); return PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, p_point_index);
} }
void SoftDynamicBody3D::pin_point_toggle(int p_point_index) { void SoftBody3D::pin_point_toggle(int p_point_index) {
pin_point(p_point_index, !(-1 != _has_pinned_point(p_point_index))); pin_point(p_point_index, !(-1 != _has_pinned_point(p_point_index)));
} }
void SoftDynamicBody3D::pin_point(int p_point_index, bool pin, const NodePath &p_spatial_attachment_path) { void SoftBody3D::pin_point(int p_point_index, bool pin, const NodePath &p_spatial_attachment_path) {
_pin_point_on_physics_server(p_point_index, pin); _pin_point_on_physics_server(p_point_index, pin);
if (pin) { if (pin) {
_add_pinned_point(p_point_index, p_spatial_attachment_path); _add_pinned_point(p_point_index, p_spatial_attachment_path);
@ -683,35 +683,35 @@ void SoftDynamicBody3D::pin_point(int p_point_index, bool pin, const NodePath &p
} }
} }
bool SoftDynamicBody3D::is_point_pinned(int p_point_index) const { bool SoftBody3D::is_point_pinned(int p_point_index) const {
return -1 != _has_pinned_point(p_point_index); return -1 != _has_pinned_point(p_point_index);
} }
void SoftDynamicBody3D::set_ray_pickable(bool p_ray_pickable) { void SoftBody3D::set_ray_pickable(bool p_ray_pickable) {
ray_pickable = p_ray_pickable; ray_pickable = p_ray_pickable;
_update_pickable(); _update_pickable();
} }
bool SoftDynamicBody3D::is_ray_pickable() const { bool SoftBody3D::is_ray_pickable() const {
return ray_pickable; return ray_pickable;
} }
SoftDynamicBody3D::SoftDynamicBody3D() : SoftBody3D::SoftBody3D() :
physics_rid(PhysicsServer3D::get_singleton()->soft_body_create()) { physics_rid(PhysicsServer3D::get_singleton()->soft_body_create()) {
rendering_server_handler = memnew(SoftDynamicBodyRenderingServerHandler); rendering_server_handler = memnew(SoftBodyRenderingServerHandler);
PhysicsServer3D::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id()); PhysicsServer3D::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id());
} }
SoftDynamicBody3D::~SoftDynamicBody3D() { SoftBody3D::~SoftBody3D() {
memdelete(rendering_server_handler); memdelete(rendering_server_handler);
PhysicsServer3D::get_singleton()->free(physics_rid); PhysicsServer3D::get_singleton()->free(physics_rid);
} }
void SoftDynamicBody3D::_make_cache_dirty() { void SoftBody3D::_make_cache_dirty() {
pinned_points_cache_dirty = true; pinned_points_cache_dirty = true;
} }
void SoftDynamicBody3D::_update_cache_pin_points_datas() { void SoftBody3D::_update_cache_pin_points_datas() {
if (!pinned_points_cache_dirty) { if (!pinned_points_cache_dirty) {
return; return;
} }
@ -724,17 +724,17 @@ void SoftDynamicBody3D::_update_cache_pin_points_datas() {
w[i].spatial_attachment = Object::cast_to<Node3D>(get_node(w[i].spatial_attachment_path)); w[i].spatial_attachment = Object::cast_to<Node3D>(get_node(w[i].spatial_attachment_path));
} }
if (!w[i].spatial_attachment) { if (!w[i].spatial_attachment) {
ERR_PRINT("Node3D node not defined in the pinned point, this is undefined behavior for SoftDynamicBody3D!"); ERR_PRINT("Node3D node not defined in the pinned point, this is undefined behavior for SoftBody3D!");
} }
} }
} }
void SoftDynamicBody3D::_pin_point_on_physics_server(int p_point_index, bool pin) { void SoftBody3D::_pin_point_on_physics_server(int p_point_index, bool pin) {
PhysicsServer3D::get_singleton()->soft_body_pin_point(physics_rid, p_point_index, pin); PhysicsServer3D::get_singleton()->soft_body_pin_point(physics_rid, p_point_index, pin);
} }
void SoftDynamicBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path) { void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path) {
SoftDynamicBody3D::PinnedPoint *pinned_point; SoftBody3D::PinnedPoint *pinned_point;
if (-1 == _get_pinned_point(p_point_index, pinned_point)) { if (-1 == _get_pinned_point(p_point_index, pinned_point)) {
// Create new // Create new
PinnedPoint pp; PinnedPoint pp;
@ -759,7 +759,7 @@ void SoftDynamicBody3D::_add_pinned_point(int p_point_index, const NodePath &p_s
} }
} }
void SoftDynamicBody3D::_reset_points_offsets() { void SoftBody3D::_reset_points_offsets() {
if (!Engine::get_singleton()->is_editor_hint()) { if (!Engine::get_singleton()->is_editor_hint()) {
return; return;
} }
@ -781,25 +781,25 @@ void SoftDynamicBody3D::_reset_points_offsets() {
} }
} }
void SoftDynamicBody3D::_remove_pinned_point(int p_point_index) { void SoftBody3D::_remove_pinned_point(int p_point_index) {
const int id(_has_pinned_point(p_point_index)); const int id(_has_pinned_point(p_point_index));
if (-1 != id) { if (-1 != id) {
pinned_points.remove_at(id); pinned_points.remove_at(id);
} }
} }
int SoftDynamicBody3D::_get_pinned_point(int p_point_index, SoftDynamicBody3D::PinnedPoint *&r_point) const { int SoftBody3D::_get_pinned_point(int p_point_index, SoftBody3D::PinnedPoint *&r_point) const {
const int id = _has_pinned_point(p_point_index); const int id = _has_pinned_point(p_point_index);
if (-1 == id) { if (-1 == id) {
r_point = nullptr; r_point = nullptr;
return -1; return -1;
} else { } else {
r_point = const_cast<SoftDynamicBody3D::PinnedPoint *>(&pinned_points.ptr()[id]); r_point = const_cast<SoftBody3D::PinnedPoint *>(&pinned_points.ptr()[id]);
return id; return id;
} }
} }
int SoftDynamicBody3D::_has_pinned_point(int p_point_index) const { int SoftBody3D::_has_pinned_point(int p_point_index) const {
const PinnedPoint *r = pinned_points.ptr(); const PinnedPoint *r = pinned_points.ptr();
for (int i = pinned_points.size() - 1; 0 <= i; --i) { for (int i = pinned_points.size() - 1; 0 <= i; --i) {
if (p_point_index == r[i].point_index) { if (p_point_index == r[i].point_index) {

View File

@ -1,5 +1,5 @@
/*************************************************************************/ /*************************************************************************/
/* soft_dynamic_body_3d.h */ /* soft_body_3d.h */
/*************************************************************************/ /*************************************************************************/
/* This file is part of: */ /* This file is part of: */
/* GODOT ENGINE */ /* GODOT ENGINE */
@ -28,17 +28,17 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/ /*************************************************************************/
#ifndef SOFT_DYNAMIC_BODY_3D_H #ifndef SOFT_BODY_3D_H
#define SOFT_DYNAMIC_BODY_3D_H #define SOFT_BODY_3D_H
#include "scene/3d/mesh_instance_3d.h" #include "scene/3d/mesh_instance_3d.h"
#include "servers/physics_server_3d.h" #include "servers/physics_server_3d.h"
class PhysicsBody3D; class PhysicsBody3D;
class SoftDynamicBody3D; class SoftBody3D;
class SoftDynamicBodyRenderingServerHandler : public PhysicsServer3DRenderingServerHandler { class SoftBodyRenderingServerHandler : public PhysicsServer3DRenderingServerHandler {
friend class SoftDynamicBody3D; friend class SoftBody3D;
RID mesh; RID mesh;
int surface = 0; int surface = 0;
@ -50,7 +50,7 @@ class SoftDynamicBodyRenderingServerHandler : public PhysicsServer3DRenderingSer
uint8_t *write_buffer = nullptr; uint8_t *write_buffer = nullptr;
private: private:
SoftDynamicBodyRenderingServerHandler(); SoftBodyRenderingServerHandler();
bool is_ready(RID p_mesh_rid) const { return mesh.is_valid() && mesh == p_mesh_rid; } bool is_ready(RID p_mesh_rid) const { return mesh.is_valid() && mesh == p_mesh_rid; }
void prepare(RID p_mesh_rid, int p_surface); void prepare(RID p_mesh_rid, int p_surface);
void clear(); void clear();
@ -64,8 +64,8 @@ public:
void set_aabb(const AABB &p_aabb) override; void set_aabb(const AABB &p_aabb) override;
}; };
class SoftDynamicBody3D : public MeshInstance3D { class SoftBody3D : public MeshInstance3D {
GDCLASS(SoftDynamicBody3D, MeshInstance3D); GDCLASS(SoftBody3D, MeshInstance3D);
public: public:
enum DisableMode { enum DisableMode {
@ -85,7 +85,7 @@ public:
}; };
private: private:
SoftDynamicBodyRenderingServerHandler *rendering_server_handler = nullptr; SoftBodyRenderingServerHandler *rendering_server_handler = nullptr;
RID physics_rid; RID physics_rid;
@ -182,8 +182,8 @@ public:
void set_ray_pickable(bool p_ray_pickable); void set_ray_pickable(bool p_ray_pickable);
bool is_ray_pickable() const; bool is_ray_pickable() const;
SoftDynamicBody3D(); SoftBody3D();
~SoftDynamicBody3D(); ~SoftBody3D();
private: private:
void _make_cache_dirty(); void _make_cache_dirty();
@ -198,6 +198,6 @@ private:
int _has_pinned_point(int p_point_index) const; int _has_pinned_point(int p_point_index) const;
}; };
VARIANT_ENUM_CAST(SoftDynamicBody3D::DisableMode); VARIANT_ENUM_CAST(SoftBody3D::DisableMode);
#endif // SOFT_DYNAMIC_BODY_3D_H #endif // SOFT_BODY_3D_H

View File

@ -807,7 +807,7 @@ void VehicleBody3D::_update_friction(PhysicsDirectBodyState3D *s) {
} }
void VehicleBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) { void VehicleBody3D::_body_state_changed(PhysicsDirectBodyState3D *p_state) {
RigidDynamicBody3D::_body_state_changed(p_state); RigidBody3D::_body_state_changed(p_state);
real_t step = p_state->get_step(); real_t step = p_state->get_step();

View File

@ -152,8 +152,8 @@ public:
VehicleWheel3D(); VehicleWheel3D();
}; };
class VehicleBody3D : public RigidDynamicBody3D { class VehicleBody3D : public RigidBody3D {
GDCLASS(VehicleBody3D, RigidDynamicBody3D); GDCLASS(VehicleBody3D, RigidBody3D);
real_t engine_force = 0.0; real_t engine_force = 0.0;
real_t brake = 0.0; real_t brake = 0.0;

View File

@ -248,7 +248,7 @@
#include "scene/3d/shape_cast_3d.h" #include "scene/3d/shape_cast_3d.h"
#include "scene/3d/skeleton_3d.h" #include "scene/3d/skeleton_3d.h"
#include "scene/3d/skeleton_ik_3d.h" #include "scene/3d/skeleton_ik_3d.h"
#include "scene/3d/soft_dynamic_body_3d.h" #include "scene/3d/soft_body_3d.h"
#include "scene/3d/spring_arm_3d.h" #include "scene/3d/spring_arm_3d.h"
#include "scene/3d/sprite_3d.h" #include "scene/3d/sprite_3d.h"
#include "scene/3d/vehicle_body_3d.h" #include "scene/3d/vehicle_body_3d.h"
@ -533,13 +533,13 @@ void register_scene_types() {
GDREGISTER_ABSTRACT_CLASS(PhysicsBody3D); GDREGISTER_ABSTRACT_CLASS(PhysicsBody3D);
GDREGISTER_CLASS(StaticBody3D); GDREGISTER_CLASS(StaticBody3D);
GDREGISTER_CLASS(AnimatableBody3D); GDREGISTER_CLASS(AnimatableBody3D);
GDREGISTER_CLASS(RigidDynamicBody3D); GDREGISTER_CLASS(RigidBody3D);
GDREGISTER_CLASS(KinematicCollision3D); GDREGISTER_CLASS(KinematicCollision3D);
GDREGISTER_CLASS(CharacterBody3D); GDREGISTER_CLASS(CharacterBody3D);
GDREGISTER_CLASS(SpringArm3D); GDREGISTER_CLASS(SpringArm3D);
GDREGISTER_CLASS(PhysicalBone3D); GDREGISTER_CLASS(PhysicalBone3D);
GDREGISTER_CLASS(SoftDynamicBody3D); GDREGISTER_CLASS(SoftBody3D);
GDREGISTER_CLASS(SkeletonIK3D); GDREGISTER_CLASS(SkeletonIK3D);
GDREGISTER_CLASS(BoneAttachment3D); GDREGISTER_CLASS(BoneAttachment3D);
@ -704,7 +704,7 @@ void register_scene_types() {
GDREGISTER_ABSTRACT_CLASS(PhysicsBody2D); GDREGISTER_ABSTRACT_CLASS(PhysicsBody2D);
GDREGISTER_CLASS(StaticBody2D); GDREGISTER_CLASS(StaticBody2D);
GDREGISTER_CLASS(AnimatableBody2D); GDREGISTER_CLASS(AnimatableBody2D);
GDREGISTER_CLASS(RigidDynamicBody2D); GDREGISTER_CLASS(RigidBody2D);
GDREGISTER_CLASS(CharacterBody2D); GDREGISTER_CLASS(CharacterBody2D);
GDREGISTER_CLASS(KinematicCollision2D); GDREGISTER_CLASS(KinematicCollision2D);
GDREGISTER_CLASS(Area2D); GDREGISTER_CLASS(Area2D);
@ -1042,14 +1042,16 @@ void register_scene_types() {
ClassDB::add_compatibility_class("RayShape", "SeparationRayShape3D"); ClassDB::add_compatibility_class("RayShape", "SeparationRayShape3D");
ClassDB::add_compatibility_class("RayShape2D", "SeparationRayShape2D"); ClassDB::add_compatibility_class("RayShape2D", "SeparationRayShape2D");
ClassDB::add_compatibility_class("RemoteTransform", "RemoteTransform3D"); ClassDB::add_compatibility_class("RemoteTransform", "RemoteTransform3D");
ClassDB::add_compatibility_class("RigidBody", "RigidDynamicBody3D"); ClassDB::add_compatibility_class("RigidBody", "RigidBody3D");
ClassDB::add_compatibility_class("RigidBody2D", "RigidDynamicBody2D"); ClassDB::add_compatibility_class("RigidDynamicBody2D", "RigidBody2D");
ClassDB::add_compatibility_class("RigidDynamicBody3D", "RigidBody3D");
ClassDB::add_compatibility_class("Shape", "Shape3D"); ClassDB::add_compatibility_class("Shape", "Shape3D");
ClassDB::add_compatibility_class("ShortCut", "Shortcut"); ClassDB::add_compatibility_class("ShortCut", "Shortcut");
ClassDB::add_compatibility_class("Skeleton", "Skeleton3D"); ClassDB::add_compatibility_class("Skeleton", "Skeleton3D");
ClassDB::add_compatibility_class("SkeletonIK", "SkeletonIK3D"); ClassDB::add_compatibility_class("SkeletonIK", "SkeletonIK3D");
ClassDB::add_compatibility_class("SliderJoint", "SliderJoint3D"); ClassDB::add_compatibility_class("SliderJoint", "SliderJoint3D");
ClassDB::add_compatibility_class("SoftBody", "SoftDynamicBody3D"); ClassDB::add_compatibility_class("SoftBody", "SoftBody3D");
ClassDB::add_compatibility_class("SoftDynamicBody3D", "SoftBody3D");
ClassDB::add_compatibility_class("Spatial", "Node3D"); ClassDB::add_compatibility_class("Spatial", "Node3D");
ClassDB::add_compatibility_class("SpatialGizmo", "Node3DGizmo"); ClassDB::add_compatibility_class("SpatialGizmo", "Node3DGizmo");
ClassDB::add_compatibility_class("SpatialMaterial", "StandardMaterial3D"); ClassDB::add_compatibility_class("SpatialMaterial", "StandardMaterial3D");

View File

@ -44,7 +44,7 @@ void GodotBody2D::update_mass_properties() {
//update shapes and motions //update shapes and motions
switch (mode) { switch (mode) {
case PhysicsServer2D::BODY_MODE_DYNAMIC: { case PhysicsServer2D::BODY_MODE_RIGID: {
real_t total_area = 0; real_t total_area = 0;
for (int i = 0; i < get_shape_count(); i++) { for (int i = 0; i < get_shape_count(); i++) {
if (is_shape_disabled(i)) { if (is_shape_disabled(i)) {
@ -113,7 +113,7 @@ void GodotBody2D::update_mass_properties() {
_inv_inertia = 0; _inv_inertia = 0;
_inv_mass = 0; _inv_mass = 0;
} break; } break;
case PhysicsServer2D::BODY_MODE_DYNAMIC_LINEAR: { case PhysicsServer2D::BODY_MODE_RIGID_LINEAR: {
_inv_inertia = 0; _inv_inertia = 0;
_inv_mass = 1.0 / mass; _inv_mass = 1.0 / mass;
@ -160,7 +160,7 @@ void GodotBody2D::set_param(PhysicsServer2D::BodyParameter p_param, const Varian
real_t mass_value = p_value; real_t mass_value = p_value;
ERR_FAIL_COND(mass_value <= 0); ERR_FAIL_COND(mass_value <= 0);
mass = mass_value; mass = mass_value;
if (mode >= PhysicsServer2D::BODY_MODE_DYNAMIC) { if (mode >= PhysicsServer2D::BODY_MODE_RIGID) {
_mass_properties_changed(); _mass_properties_changed();
} }
} break; } break;
@ -168,13 +168,13 @@ void GodotBody2D::set_param(PhysicsServer2D::BodyParameter p_param, const Varian
real_t inertia_value = p_value; real_t inertia_value = p_value;
if (inertia_value <= 0.0) { if (inertia_value <= 0.0) {
calculate_inertia = true; calculate_inertia = true;
if (mode == PhysicsServer2D::BODY_MODE_DYNAMIC) { if (mode == PhysicsServer2D::BODY_MODE_RIGID) {
_mass_properties_changed(); _mass_properties_changed();
} }
} else { } else {
calculate_inertia = false; calculate_inertia = false;
inertia = inertia_value; inertia = inertia_value;
if (mode == PhysicsServer2D::BODY_MODE_DYNAMIC) { if (mode == PhysicsServer2D::BODY_MODE_RIGID) {
_inv_inertia = 1.0 / inertia; _inv_inertia = 1.0 / inertia;
} }
} }
@ -267,7 +267,7 @@ void GodotBody2D::set_mode(PhysicsServer2D::BodyMode p_mode) {
first_time_kinematic = true; first_time_kinematic = true;
} }
} break; } break;
case PhysicsServer2D::BODY_MODE_DYNAMIC: { case PhysicsServer2D::BODY_MODE_RIGID: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0; _inv_mass = mass > 0 ? (1.0 / mass) : 0;
if (!calculate_inertia) { if (!calculate_inertia) {
_inv_inertia = 1.0 / inertia; _inv_inertia = 1.0 / inertia;
@ -277,7 +277,7 @@ void GodotBody2D::set_mode(PhysicsServer2D::BodyMode p_mode) {
set_active(true); set_active(true);
} break; } break;
case PhysicsServer2D::BODY_MODE_DYNAMIC_LINEAR: { case PhysicsServer2D::BODY_MODE_RIGID_LINEAR: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0; _inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = 0; _inv_inertia = 0;
angular_velocity = 0; angular_velocity = 0;
@ -358,7 +358,7 @@ void GodotBody2D::set_state(PhysicsServer2D::BodyState p_state, const Variant &p
} break; } break;
case PhysicsServer2D::BODY_STATE_CAN_SLEEP: { case PhysicsServer2D::BODY_STATE_CAN_SLEEP: {
can_sleep = p_variant; can_sleep = p_variant;
if (mode >= PhysicsServer2D::BODY_MODE_DYNAMIC && !active && !can_sleep) { if (mode >= PhysicsServer2D::BODY_MODE_RIGID && !active && !can_sleep) {
set_active(true); set_active(true);
} }
@ -661,7 +661,7 @@ void GodotBody2D::wakeup_neighbours() {
continue; continue;
} }
GodotBody2D *b = n[i]; GodotBody2D *b = n[i];
if (b->mode < PhysicsServer2D::BODY_MODE_DYNAMIC) { if (b->mode < PhysicsServer2D::BODY_MODE_RIGID) {
continue; continue;
} }

View File

@ -42,7 +42,7 @@ class GodotConstraint2D;
class GodotPhysicsDirectBodyState2D; class GodotPhysicsDirectBodyState2D;
class GodotBody2D : public GodotCollisionObject2D { class GodotBody2D : public GodotCollisionObject2D {
PhysicsServer2D::BodyMode mode = PhysicsServer2D::BODY_MODE_DYNAMIC; PhysicsServer2D::BodyMode mode = PhysicsServer2D::BODY_MODE_RIGID;
Vector2 biased_linear_velocity; Vector2 biased_linear_velocity;
real_t biased_angular_velocity = 0.0; real_t biased_angular_velocity = 0.0;

View File

@ -643,7 +643,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::
if (col_obj->get_type() == GodotCollisionObject2D::TYPE_BODY) { if (col_obj->get_type() == GodotCollisionObject2D::TYPE_BODY) {
const GodotBody2D *b = static_cast<const GodotBody2D *>(col_obj); const GodotBody2D *b = static_cast<const GodotBody2D *>(col_obj);
if (b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_DYNAMIC) { if (b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_RIGID) {
//fix for moving platforms (kinematic and dynamic), margin is increased by how much it moved in the given direction //fix for moving platforms (kinematic and dynamic), margin is increased by how much it moved in the given direction
Vector2 lv = b->get_linear_velocity(); Vector2 lv = b->get_linear_velocity();
//compute displacement from linear velocity //compute displacement from linear velocity
@ -948,7 +948,7 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D::
if (col_obj->get_type() == GodotCollisionObject2D::TYPE_BODY) { if (col_obj->get_type() == GodotCollisionObject2D::TYPE_BODY) {
const GodotBody2D *b = static_cast<const GodotBody2D *>(col_obj); const GodotBody2D *b = static_cast<const GodotBody2D *>(col_obj);
if (b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_DYNAMIC) { if (b->get_mode() == PhysicsServer2D::BODY_MODE_KINEMATIC || b->get_mode() == PhysicsServer2D::BODY_MODE_RIGID) {
//fix for moving platforms (kinematic and dynamic), margin is increased by how much it moved in the given direction //fix for moving platforms (kinematic and dynamic), margin is increased by how much it moved in the given direction
Vector2 lv = b->get_linear_velocity(); Vector2 lv = b->get_linear_velocity();
//compute displacement from linear velocity //compute displacement from linear velocity

View File

@ -42,7 +42,7 @@ void GodotStep2D::_populate_island(GodotBody2D *p_body, LocalVector<GodotBody2D
p_body->set_island_step(_step); p_body->set_island_step(_step);
if (p_body->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) { if (p_body->get_mode() > PhysicsServer2D::BODY_MODE_KINEMATIC) {
// Only dynamic bodies are tested for activation. // Only rigid bodies are tested for activation.
p_body_island.push_back(p_body); p_body_island.push_back(p_body);
} }

View File

@ -56,7 +56,7 @@ void GodotBody3D::update_mass_properties() {
// Update shapes and motions. // Update shapes and motions.
switch (mode) { switch (mode) {
case PhysicsServer3D::BODY_MODE_DYNAMIC: { case PhysicsServer3D::BODY_MODE_RIGID: {
real_t total_area = 0; real_t total_area = 0;
for (int i = 0; i < get_shape_count(); i++) { for (int i = 0; i < get_shape_count(); i++) {
if (is_shape_disabled(i)) { if (is_shape_disabled(i)) {
@ -154,7 +154,7 @@ void GodotBody3D::update_mass_properties() {
_inv_inertia = Vector3(); _inv_inertia = Vector3();
_inv_mass = 0; _inv_mass = 0;
} break; } break;
case PhysicsServer3D::BODY_MODE_DYNAMIC_LINEAR: { case PhysicsServer3D::BODY_MODE_RIGID_LINEAR: {
_inv_inertia_tensor.set_zero(); _inv_inertia_tensor.set_zero();
_inv_mass = 1.0 / mass; _inv_mass = 1.0 / mass;
@ -201,7 +201,7 @@ void GodotBody3D::set_param(PhysicsServer3D::BodyParameter p_param, const Varian
real_t mass_value = p_value; real_t mass_value = p_value;
ERR_FAIL_COND(mass_value <= 0); ERR_FAIL_COND(mass_value <= 0);
mass = mass_value; mass = mass_value;
if (mode >= PhysicsServer3D::BODY_MODE_DYNAMIC) { if (mode >= PhysicsServer3D::BODY_MODE_RIGID) {
_mass_properties_changed(); _mass_properties_changed();
} }
} break; } break;
@ -209,12 +209,12 @@ void GodotBody3D::set_param(PhysicsServer3D::BodyParameter p_param, const Varian
inertia = p_value; inertia = p_value;
if ((inertia.x <= 0.0) || (inertia.y <= 0.0) || (inertia.z <= 0.0)) { if ((inertia.x <= 0.0) || (inertia.y <= 0.0) || (inertia.z <= 0.0)) {
calculate_inertia = true; calculate_inertia = true;
if (mode == PhysicsServer3D::BODY_MODE_DYNAMIC) { if (mode == PhysicsServer3D::BODY_MODE_RIGID) {
_mass_properties_changed(); _mass_properties_changed();
} }
} else { } else {
calculate_inertia = false; calculate_inertia = false;
if (mode == PhysicsServer3D::BODY_MODE_DYNAMIC) { if (mode == PhysicsServer3D::BODY_MODE_RIGID) {
principal_inertia_axes_local = Basis(); principal_inertia_axes_local = Basis();
_inv_inertia = inertia.inverse(); _inv_inertia = inertia.inverse();
_update_transform_dependent(); _update_transform_dependent();
@ -263,7 +263,7 @@ Variant GodotBody3D::get_param(PhysicsServer3D::BodyParameter p_param) const {
return mass; return mass;
} break; } break;
case PhysicsServer3D::BODY_PARAM_INERTIA: { case PhysicsServer3D::BODY_PARAM_INERTIA: {
if (mode == PhysicsServer3D::BODY_MODE_DYNAMIC) { if (mode == PhysicsServer3D::BODY_MODE_RIGID) {
return _inv_inertia.inverse(); return _inv_inertia.inverse();
} else { } else {
return Vector3(); return Vector3();
@ -315,7 +315,7 @@ void GodotBody3D::set_mode(PhysicsServer3D::BodyMode p_mode) {
_update_transform_dependent(); _update_transform_dependent();
} break; } break;
case PhysicsServer3D::BODY_MODE_DYNAMIC: { case PhysicsServer3D::BODY_MODE_RIGID: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0; _inv_mass = mass > 0 ? (1.0 / mass) : 0;
if (!calculate_inertia) { if (!calculate_inertia) {
principal_inertia_axes_local = Basis(); principal_inertia_axes_local = Basis();
@ -327,7 +327,7 @@ void GodotBody3D::set_mode(PhysicsServer3D::BodyMode p_mode) {
set_active(true); set_active(true);
} break; } break;
case PhysicsServer3D::BODY_MODE_DYNAMIC_LINEAR: { case PhysicsServer3D::BODY_MODE_RIGID_LINEAR: {
_inv_mass = mass > 0 ? (1.0 / mass) : 0; _inv_mass = mass > 0 ? (1.0 / mass) : 0;
_inv_inertia = Vector3(); _inv_inertia = Vector3();
angular_velocity = Vector3(); angular_velocity = Vector3();
@ -407,7 +407,7 @@ void GodotBody3D::set_state(PhysicsServer3D::BodyState p_state, const Variant &p
} break; } break;
case PhysicsServer3D::BODY_STATE_CAN_SLEEP: { case PhysicsServer3D::BODY_STATE_CAN_SLEEP: {
can_sleep = p_variant; can_sleep = p_variant;
if (mode >= PhysicsServer3D::BODY_MODE_DYNAMIC && !active && !can_sleep) { if (mode >= PhysicsServer3D::BODY_MODE_RIGID && !active && !can_sleep) {
set_active(true); set_active(true);
} }
@ -744,7 +744,7 @@ void GodotBody3D::wakeup_neighbours() {
continue; continue;
} }
GodotBody3D *b = n[i]; GodotBody3D *b = n[i];
if (b->mode < PhysicsServer3D::BODY_MODE_DYNAMIC) { if (b->mode < PhysicsServer3D::BODY_MODE_RIGID) {
continue; continue;
} }

View File

@ -40,7 +40,7 @@ class GodotConstraint3D;
class GodotPhysicsDirectBodyState3D; class GodotPhysicsDirectBodyState3D;
class GodotBody3D : public GodotCollisionObject3D { class GodotBody3D : public GodotCollisionObject3D {
PhysicsServer3D::BodyMode mode = PhysicsServer3D::BODY_MODE_DYNAMIC; PhysicsServer3D::BodyMode mode = PhysicsServer3D::BODY_MODE_RIGID;
Vector3 linear_velocity; Vector3 linear_velocity;
Vector3 angular_velocity; Vector3 angular_velocity;

View File

@ -44,7 +44,7 @@ void GodotStep3D::_populate_island(GodotBody3D *p_body, LocalVector<GodotBody3D
p_body->set_island_step(_step); p_body->set_island_step(_step);
if (p_body->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC) { if (p_body->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC) {
// Only dynamic bodies are tested for activation. // Only rigid bodies are tested for activation.
p_body_island.push_back(p_body); p_body_island.push_back(p_body);
} }

View File

@ -817,8 +817,8 @@ void PhysicsServer2D::_bind_methods() {
BIND_ENUM_CONSTANT(BODY_MODE_STATIC); BIND_ENUM_CONSTANT(BODY_MODE_STATIC);
BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC); BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC);
BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC); BIND_ENUM_CONSTANT(BODY_MODE_RIGID);
BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC_LINEAR); BIND_ENUM_CONSTANT(BODY_MODE_RIGID_LINEAR);
BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE); BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE);
BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION); BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION);

View File

@ -348,8 +348,8 @@ public:
enum BodyMode { enum BodyMode {
BODY_MODE_STATIC, BODY_MODE_STATIC,
BODY_MODE_KINEMATIC, BODY_MODE_KINEMATIC,
BODY_MODE_DYNAMIC, BODY_MODE_RIGID,
BODY_MODE_DYNAMIC_LINEAR, BODY_MODE_RIGID_LINEAR,
}; };
virtual RID body_create() = 0; virtual RID body_create() = 0;

View File

@ -988,8 +988,8 @@ void PhysicsServer3D::_bind_methods() {
BIND_ENUM_CONSTANT(BODY_MODE_STATIC); BIND_ENUM_CONSTANT(BODY_MODE_STATIC);
BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC); BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC);
BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC); BIND_ENUM_CONSTANT(BODY_MODE_RIGID);
BIND_ENUM_CONSTANT(BODY_MODE_DYNAMIC_LINEAR); BIND_ENUM_CONSTANT(BODY_MODE_RIGID_LINEAR);
BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE); BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE);
BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION); BIND_ENUM_CONSTANT(BODY_PARAM_FRICTION);

View File

@ -381,8 +381,8 @@ public:
enum BodyMode { enum BodyMode {
BODY_MODE_STATIC, BODY_MODE_STATIC,
BODY_MODE_KINEMATIC, BODY_MODE_KINEMATIC,
BODY_MODE_DYNAMIC, BODY_MODE_RIGID,
BODY_MODE_DYNAMIC_LINEAR, BODY_MODE_RIGID_LINEAR,
}; };
enum BodyDampMode { enum BodyDampMode {