Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script interface improvements for test body motion #53280

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 67 additions & 36 deletions doc/classes/KinematicCollision2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,74 @@
<return type="float" />
<argument index="0" name="up_direction" type="Vector2" default="Vector2(0, -1)" />
<description>
The collision angle according to [code]up_direction[/code], which is [code]Vector2.UP[/code] by default. This value is always positive.
Returns the collision angle according to [code]up_direction[/code], which is [code]Vector2.UP[/code] by default. This value is always positive.
</description>
</method>
<method name="get_collider" qualifiers="const">
<return type="Object" />
<description>
Returns the colliding body's attached [Object].
</description>
</method>
<method name="get_collider_id" qualifiers="const">
<return type="int" />
<description>
Returns the unique instance ID of the colliding body's attached [Object]. See [method Object.get_instance_id].
</description>
</method>
<method name="get_collider_rid" qualifiers="const">
<return type="RID" />
<description>
Returns the colliding body's [RID] used by the [PhysicsServer2D].
</description>
</method>
<method name="get_collider_shape" qualifiers="const">
<return type="Object" />
<description>
Returns the colliding body's shape.
</description>
</method>
<method name="get_collider_shape_index" qualifiers="const">
<return type="int" />
<description>
Returns the colliding body's shape index. See [CollisionObject2D].
</description>
</method>
<method name="get_collider_velocity" qualifiers="const">
<return type="Vector2" />
<description>
Returns the colliding body's velocity.
</description>
</method>
<method name="get_local_shape" qualifiers="const">
<return type="Object" />
<description>
Returns the moving object's colliding shape.
</description>
</method>
<method name="get_normal" qualifiers="const">
<return type="Vector2" />
<description>
Returns the colliding body's shape's normal at the point of collision.
</description>
</method>
<method name="get_position" qualifiers="const">
<return type="Vector2" />
<description>
Returns the point of collision in global coordinates.
</description>
</method>
<method name="get_remainder" qualifiers="const">
<return type="Vector2" />
<description>
Returns the moving object's remaining movement vector.
</description>
</method>
<method name="get_travel" qualifiers="const">
<return type="Vector2" />
<description>
Returns the moving object's travel before collision.
</description>
</method>
</methods>
<members>
<member name="collider" type="Object" setter="" getter="get_collider">
The colliding body.
</member>
<member name="collider_id" type="int" setter="" getter="get_collider_id" default="0">
The colliding body's unique instance ID. See [method Object.get_instance_id].
</member>
<member name="collider_rid" type="RID" setter="" getter="get_collider_rid">
The colliding body's [RID] used by the [PhysicsServer2D].
</member>
<member name="collider_shape" type="Object" setter="" getter="get_collider_shape">
The colliding body's shape.
</member>
<member name="collider_shape_index" type="int" setter="" getter="get_collider_shape_index" default="0">
The colliding shape's index. See [CollisionObject2D].
</member>
<member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2(0, 0)">
The colliding object's velocity.
</member>
<member name="local_shape" type="Object" setter="" getter="get_local_shape">
The moving object's colliding shape.
</member>
<member name="normal" type="Vector2" setter="" getter="get_normal" default="Vector2(0, 0)">
The colliding body's shape's normal at the point of collision.
</member>
<member name="position" type="Vector2" setter="" getter="get_position" default="Vector2(0, 0)">
The point of collision, in global coordinates.
</member>
<member name="remainder" type="Vector2" setter="" getter="get_remainder" default="Vector2(0, 0)">
The moving object's remaining movement vector.
</member>
<member name="travel" type="Vector2" setter="" getter="get_travel" default="Vector2(0, 0)">
The distance the moving object traveled before collision.
</member>
</members>
</class>
75 changes: 28 additions & 47 deletions doc/classes/KinematicCollision3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,108 +15,89 @@
<argument index="0" name="collision_index" type="int" default="0" />
<argument index="1" name="up_direction" type="Vector3" default="Vector3(0, 1, 0)" />
<description>
The collision angle according to [code]up_direction[/code], which is [code]Vector3.UP[/code] by default. This value is always positive.
Returns the collision angle according to [code]up_direction[/code], which is [code]Vector3.UP[/code] by default. This value is always positive.
</description>
</method>
<method name="get_collider" qualifiers="const">
<return type="Object" />
<argument index="0" name="collision_index" type="int" default="0" />
<description>
Returns the collider by index (the latest by default).
Returns the colliding body's attached [Object] given a collision index (the deepest collision by default).
</description>
</method>
<method name="get_collider_id" qualifiers="const">
<return type="int" />
<argument index="0" name="collision_index" type="int" default="0" />
<description>
Returns the collider ID by index (the latest by default).
Returns the unique instance ID of the colliding body's attached [Object] given a collision index (the deepest collision by default). See [method Object.get_instance_id].
</description>
</method>
<method name="get_collider_rid" qualifiers="const">
<return type="RID" />
<argument index="0" name="collision_index" type="int" default="0" />
<description>
Returns the collider RID by index (the latest by default).
Returns the colliding body's [RID] used by the [PhysicsServer3D] given a collision index (the deepest collision by default).
</description>
</method>
<method name="get_collider_shape" qualifiers="const">
<return type="Object" />
<argument index="0" name="collision_index" type="int" default="0" />
<description>
Returns the collider shape by index (the latest by default).
Returns the colliding body's shape given a collision index (the deepest collision by default).
</description>
</method>
<method name="get_collider_shape_index" qualifiers="const">
<return type="int" />
<argument index="0" name="collision_index" type="int" default="0" />
<description>
Returns the collider shape index by index (the latest by default).
Returns the colliding body's shape index given a collision index (the deepest collision by default). See [CollisionObject3D].
</description>
</method>
<method name="get_collider_velocity" qualifiers="const">
<return type="Vector3" />
<argument index="0" name="collision_index" type="int" default="0" />
<description>
Returns the collider velocity by index (the latest by default).
Returns the colliding body's velocity given a collision index (the deepest collision by default).
</description>
</method>
<method name="get_collision_count" qualifiers="const">
<return type="int" />
<description>
Returns the number of detected collisions.
</description>
</method>
<method name="get_local_shape" qualifiers="const">
<return type="Object" />
<argument index="0" name="collision_index" type="int" default="0" />
<description>
Returns the collider velocity by index (the latest by default).
Returns the moving object's colliding shape given a collision index (the deepest collision by default).
</description>
</method>
<method name="get_normal" qualifiers="const">
<return type="Vector3" />
<argument index="0" name="collision_index" type="int" default="0" />
<description>
Returns the collider normal by index (the latest by default).
Returns the colliding body's shape's normal at the point of collision given a collision index (the deepest collision by default).
</description>
</method>
<method name="get_position" qualifiers="const">
<return type="Vector3" />
<argument index="0" name="collision_index" type="int" default="0" />
<description>
Returns the collider collision point by index (the latest by default).
Returns the point of collision in global coordinates given a collision index (the deepest collision by default).
</description>
</method>
<method name="get_remainder" qualifiers="const">
<return type="Vector3" />
<description>
Returns the moving object's remaining movement vector.
</description>
</method>
<method name="get_travel" qualifiers="const">
<return type="Vector3" />
<description>
Returns the moving object's travel before collision.
</description>
</method>
</methods>
<members>
<member name="collider" type="Object" setter="" getter="get_best_collider">
The colliding body.
</member>
<member name="collider_id" type="int" setter="" getter="get_best_collider_id" default="0">
The colliding body's unique instance ID. See [method Object.get_instance_id].
</member>
<member name="collider_rid" type="RID" setter="" getter="get_best_collider_rid">
The colliding body's [RID] used by the [PhysicsServer3D].
</member>
<member name="collider_shape" type="Object" setter="" getter="get_best_collider_shape">
The colliding body's shape.
</member>
<member name="collider_shape_index" type="int" setter="" getter="get_best_collider_shape_index" default="0">
The colliding shape's index. See [CollisionObject3D].
</member>
<member name="collider_velocity" type="Vector3" setter="" getter="get_best_collider_velocity" default="Vector3(0, 0, 0)">
The colliding object's velocity.
</member>
<member name="collision_count" type="int" setter="" getter="get_collision_count" default="0">
</member>
<member name="local_shape" type="Object" setter="" getter="get_best_local_shape">
The moving object's colliding shape.
</member>
<member name="normal" type="Vector3" setter="" getter="get_best_normal" default="Vector3(0, 0, 0)">
The colliding body's shape's normal at the point of collision.
</member>
<member name="position" type="Vector3" setter="" getter="get_best_position" default="Vector3(0, 0, 0)">
The point of collision, in global coordinates.
</member>
<member name="remainder" type="Vector3" setter="" getter="get_remainder" default="Vector3(0, 0, 0)">
The moving object's remaining movement vector.
</member>
<member name="travel" type="Vector3" setter="" getter="get_travel" default="Vector3(0, 0, 0)">
The distance the moving object traveled before collision.
</member>
</members>
</class>
12 changes: 4 additions & 8 deletions doc/classes/PhysicsServer2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,10 @@
<method name="body_test_motion">
<return type="bool" />
<argument index="0" name="body" type="RID" />
<argument index="1" name="from" type="Transform2D" />
<argument index="2" name="motion" type="Vector2" />
<argument index="3" name="margin" type="float" default="0.08" />
<argument index="4" name="result" type="PhysicsTestMotionResult2D" default="null" />
<argument index="5" name="collide_separation_ray" type="bool" default="false" />
<argument index="6" name="exclude" type="Array" default="[]" />
<description>
Returns [code]true[/code] if a collision would result from moving in the given direction from a given point in space. Margin increases the size of the shapes involved in the collision detection. [PhysicsTestMotionResult2D] can be passed to return additional information in.
<argument index="1" name="parameters" type="PhysicsTestMotionParameters2D" />
<argument index="2" name="result" type="PhysicsTestMotionResult2D" default="null" />
<description>
Returns [code]true[/code] if a collision would result from moving along a motion vector from a given point in space. [PhysicsTestMotionParameters2D] is passed to set motion parameters. [PhysicsTestMotionResult2D] can be passed to return additional information.
</description>
</method>
<method name="capsule_shape_create">
Expand Down
13 changes: 4 additions & 9 deletions doc/classes/PhysicsServer3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,10 @@
<method name="body_test_motion">
<return type="bool" />
<argument index="0" name="body" type="RID" />
<argument index="1" name="from" type="Transform3D" />
<argument index="2" name="motion" type="Vector3" />
<argument index="3" name="margin" type="float" default="0.001" />
<argument index="4" name="result" type="PhysicsTestMotionResult3D" default="null" />
<argument index="5" name="collide_separation_ray" type="bool" default="false" />
<argument index="6" name="exclude" type="Array" default="[]" />
<argument index="7" name="max_collisions" type="int" default="1" />
<description>
Returns [code]true[/code] if a collision would result from moving in the given direction from a given point in space. Margin increases the size of the shapes involved in the collision detection. [PhysicsTestMotionResult3D] can be passed to return additional information in.
<argument index="1" name="parameters" type="PhysicsTestMotionParameters3D" />
<argument index="2" name="result" type="PhysicsTestMotionResult3D" default="null" />
<description>
Returns [code]true[/code] if a collision would result from moving along a motion vector from a given point in space. [PhysicsTestMotionParameters3D] is passed to set motion parameters. [PhysicsTestMotionResult3D] can be passed to return additional information.
</description>
</method>
<method name="box_shape_create">
Expand Down
29 changes: 29 additions & 0 deletions doc/classes/PhysicsTestMotionParameters2D.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicsTestMotionParameters2D" inherits="RefCounted" version="4.0">
<brief_description>
Parameters to be sent to a 2D body motion test.
</brief_description>
<description>
This class contains parameters used in [method PhysicsServer2D.body_test_motion].
</description>
<tutorials>
</tutorials>
<members>
<member name="collide_separation_ray" type="bool" setter="set_collide_separation_ray_enabled" getter="is_collide_separation_ray_enabled" default="false">
If set to [code]true[/code], shapes of type [constant PhysicsServer2D.SHAPE_SEPARATION_RAY] are used to detect collisions and can stop the motion. Can be useful when snapping to the ground.
If set to [code]false[/code], shapes of type [constant PhysicsServer2D.SHAPE_SEPARATION_RAY] are only used for separation when overlapping with other bodies. That's the main use for separation ray shapes.
</member>
<member name="exclude_bodies" type="Array" setter="set_exclude_bodies" getter="get_exclude_bodies" default="[]">
Optional array of body [RID] to exclude from collision.
</member>
<member name="from" type="Transform2D" setter="set_from" getter="get_from" default="Transform2D(1, 0, 0, 1, 0, 0)">
Transform in global space where the motion should start. Usually set to [member Node2D.global_transform] for the current body's transform.
</member>
<member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.08">
Increases the size of the shapes involved in the collision detection.
</member>
<member name="motion" type="Vector2" setter="set_motion" getter="get_motion" default="Vector2(0, 0)">
Motion vector to define the length and direction of the motion to test.
</member>
</members>
</class>
32 changes: 32 additions & 0 deletions doc/classes/PhysicsTestMotionParameters3D.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicsTestMotionParameters3D" inherits="RefCounted" version="4.0">
<brief_description>
Parameters to be sent to a 3D body motion test.
</brief_description>
<description>
This class contains parameters used in [method PhysicsServer3D.body_test_motion].
</description>
<tutorials>
</tutorials>
<members>
<member name="collide_separation_ray" type="bool" setter="set_collide_separation_ray_enabled" getter="is_collide_separation_ray_enabled" default="false">
If set to [code]true[/code], shapes of type [constant PhysicsServer3D.SHAPE_SEPARATION_RAY] are used to detect collisions and can stop the motion. Can be useful when snapping to the ground.
If set to [code]false[/code], shapes of type [constant PhysicsServer3D.SHAPE_SEPARATION_RAY] are only used for separation when overlapping with other bodies. That's the main use for separation ray shapes.
</member>
<member name="exclude_bodies" type="Array" setter="set_exclude_bodies" getter="get_exclude_bodies" default="[]">
Optional array of body [RID] to exclude from collision.
</member>
<member name="from" type="Transform3D" setter="set_from" getter="get_from" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)">
Transform in global space where the motion should start. Usually set to [member Node3D.global_transform] for the current body's transform.
</member>
<member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.001">
Increases the size of the shapes involved in the collision detection.
</member>
<member name="max_collisions" type="int" setter="set_max_collisions" getter="get_max_collisions" default="1">
Maximum number of returned collisions, between [code]1[/code] and [code]32[/code]. Always returns the deepest detected collisions.
</member>
<member name="motion" type="Vector3" setter="set_motion" getter="get_motion" default="Vector3(0, 0, 0)">
Motion vector to define the length and direction of the motion to test.
</member>
</members>
</class>
Loading