Godot Engine – Multi-platform 2D and 3D game engine
`PhysicsDirectSpaceState2D`/`3D`: Add non-allocating query methods
Rizo Hashimidda27ee15ba6
diff --git a/doc/classes/PhysicsCastMotionResult2D.xml b/doc/classes/PhysicsCastMotionResult2D.xmlnew file mode 100644index 00000000000..5665522075c--- /dev/null+++ b/doc/classes/PhysicsCastMotionResult2D.xml@@ -0,0 +1,19 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsCastMotionResult2D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the result of a shape motion cast query.+ </brief_description>+ <description>+ This class contains the safe and unsafe fractions computed by [method PhysicsDirectSpaceState2D.cast_motion_into].+ </description>+ <tutorials>+ </tutorials>+ <members>+ <member name="safe_fraction" type="float" setter="" getter="get_safe_fraction" default="1.0">+ The maximum fraction of the motion that can be made without a collision.+ </member>+ <member name="unsafe_fraction" type="float" setter="" getter="get_unsafe_fraction" default="1.0">+ The minimum fraction of the distance that must be moved for a collision.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsCastMotionResult3D.xml b/doc/classes/PhysicsCastMotionResult3D.xmlnew file mode 100644index 00000000000..68b3a660248--- /dev/null+++ b/doc/classes/PhysicsCastMotionResult3D.xml@@ -0,0 +1,19 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsCastMotionResult3D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the result of a shape motion cast query.+ </brief_description>+ <description>+ This class contains the safe and unsafe fractions computed by [method PhysicsDirectSpaceState3D.cast_motion_into].+ </description>+ <tutorials>+ </tutorials>+ <members>+ <member name="safe_fraction" type="float" setter="" getter="get_safe_fraction" default="1.0">+ The maximum fraction of the motion that can be made without a collision.+ </member>+ <member name="unsafe_fraction" type="float" setter="" getter="get_unsafe_fraction" default="1.0">+ The minimum fraction of the distance that must be moved for a collision.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsCollideShapeResult2D.xml b/doc/classes/PhysicsCollideShapeResult2D.xmlnew file mode 100644index 00000000000..9ac9b8db49f--- /dev/null+++ b/doc/classes/PhysicsCollideShapeResult2D.xml@@ -0,0 +1,39 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsCollideShapeResult2D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the collision points of a shape collision query.+ </brief_description>+ <description>+ This class contains the contact points computed by [method PhysicsDirectSpaceState2D.collide_shape_into].+ Each collision is represented as a pair of points: one on the query shape and one on the colliding shape.+ </description>+ <tutorials>+ </tutorials>+ <methods>+ <method name="get_collision_count" qualifiers="const">+ <return type="int" />+ <description>+ Returns the number of point pairs detected by the query.+ </description>+ </method>+ <method name="get_point_on_colliding_shape" qualifiers="const">+ <return type="Vector2" />+ <param index="0" name="collision_index" type="int" />+ <description>+ Returns the collision point on the colliding shape for the collision at the given index.+ </description>+ </method>+ <method name="get_point_on_queried_shape" qualifiers="const">+ <return type="Vector2" />+ <param index="0" name="collision_index" type="int" />+ <description>+ Returns the collision point on the query shape for the collision at the given index.+ </description>+ </method>+ </methods>+ <members>+ <member name="max_collisions" type="int" setter="set_max_collisions" getter="get_max_collisions" default="32">+ The maximum number of collisions this object can store.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsCollideShapeResult3D.xml b/doc/classes/PhysicsCollideShapeResult3D.xmlnew file mode 100644index 00000000000..0fce4d2724e--- /dev/null+++ b/doc/classes/PhysicsCollideShapeResult3D.xml@@ -0,0 +1,39 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsCollideShapeResult3D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the collision points of a shape collision query.+ </brief_description>+ <description>+ This class contains the contact points computed by [method PhysicsDirectSpaceState3D.collide_shape_into].+ Each collision is represented as a pair of points: one on the query shape and one on the colliding shape.+ </description>+ <tutorials>+ </tutorials>+ <methods>+ <method name="get_collision_count" qualifiers="const">+ <return type="int" />+ <description>+ Returns the number of point pairs detected by the query.+ </description>+ </method>+ <method name="get_point_on_colliding_shape" qualifiers="const">+ <return type="Vector3" />+ <param index="0" name="collision_index" type="int" />+ <description>+ Returns the collision point on the colliding shape for the collision at the given index.+ </description>+ </method>+ <method name="get_point_on_queried_shape" qualifiers="const">+ <return type="Vector3" />+ <param index="0" name="collision_index" type="int" />+ <description>+ Returns the collision point on the query shape for the collision at the given index.+ </description>+ </method>+ </methods>+ <members>+ <member name="max_collisions" type="int" setter="set_max_collisions" getter="get_max_collisions" default="32">+ The maximum number of collisions this object can store.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsDirectSpaceState2D.xml b/doc/classes/PhysicsDirectSpaceState2D.xmlindex d6f08cebcab..df92a43410a 100644--- a/doc/classes/PhysicsDirectSpaceState2D.xml+++ b/doc/classes/PhysicsDirectSpaceState2D.xml@@ -21,6 +21,16 @@[b]Note:[/b] Any [Shape2D]s that the shape is already colliding with e.g. inside of, will be ignored. Use [method collide_shape] to determine the [Shape2D]s that the shape is already colliding with.</description></method>+ <method name="cast_motion_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />+ <param index="1" name="result" type="PhysicsCastMotionResult2D" />+ <description>+ Checks how far a [Shape2D] can move without colliding. All the parameters for the query, including the shape and the motion, are supplied through a [PhysicsShapeQueryParameters2D] object.+ If the query is successful, this method returns [code]true[/code] and writes the motion results into the [PhysicsCastMotionResult2D] object passed in [param result]. If no collision occurs, it returns [code]false[/code].+ [b]Note:[/b] Any [Shape2D]s that the shape is already colliding with e.g. inside of, will be ignored. Use [method collide_shape_into] to determine the [Shape2D]s that the shape is already colliding with.+ </description>+ </method><method name="collide_shape"><return type="Vector2[]" /><param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />@@ -30,6 +40,16 @@Returned points are a list of pairs of contact points. For each pair the first one is in the shape passed in [PhysicsShapeQueryParameters2D] object, second one is in the collided shape from the physics space.</description></method>+ <method name="collide_shape_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />+ <param index="1" name="result" type="PhysicsCollideShapeResult2D" />+ <description>+ Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters2D] object, against the space.+ If intersections are found, this method returns [code]true[/code] and writes the collision points into the [PhysicsCollideShapeResult2D] object passed in [param result]. If no intersections are found, it returns [code]false[/code].+ The number of returned results can be limited using [member PhysicsCollideShapeResult2D.max_collisions], to reduce the processing time.+ </description>+ </method><method name="get_rest_info"><return type="Dictionary" /><param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />@@ -44,6 +64,15 @@If the shape did not intersect anything, then an empty dictionary is returned instead.</description></method>+ <method name="get_rest_info_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />+ <param index="1" name="result" type="PhysicsGetRestInfoResult2D" />+ <description>+ Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters2D] object, against the space.+ If the shape collides with one or more shapes, this method returns [code]true[/code] and writes the nearest collision information into the [PhysicsGetRestInfoResult2D] object passed in [param result]. If no collisions occur, it returns [code]false[/code].+ </description>+ </method><method name="intersect_point"><return type="Dictionary[]" /><param index="0" name="parameters" type="PhysicsPointQueryParameters2D" />@@ -58,6 +87,17 @@[b]Note:[/b] [ConcavePolygonShape2D]s and [CollisionPolygon2D]s in [code]Segments[/code] build mode are not solid shapes. Therefore, they will not be detected.</description></method>+ <method name="intersect_point_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsPointQueryParameters2D" />+ <param index="1" name="result" type="PhysicsIntersectPointResult2D" />+ <description>+ Checks whether a point is inside any solid shape. Position and other parameters are defined through [PhysicsPointQueryParameters2D].+ If one or more shapes overlap the point, this method returns [code]true[/code] and writes the intersection data into the [PhysicsIntersectPointResult2D] object passed in [param result]. If no intersections are found, it returns [code]false[/code].+ The number of intersections can be limited using [member PhysicsIntersectPointResult2D.max_intersections], to reduce the processing time.+ [b]Note:[/b] [ConcavePolygonShape2D]s and [CollisionPolygon2D]s in [code]Segments[/code] build mode are not solid shapes. Therefore, they will not be detected.+ </description>+ </method><method name="intersect_ray"><return type="Dictionary" /><param index="0" name="parameters" type="PhysicsRayQueryParameters2D" />@@ -72,6 +112,15 @@If the ray did not intersect anything, then an empty dictionary is returned instead.</description></method>+ <method name="intersect_ray_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsRayQueryParameters2D" />+ <param index="1" name="result" type="PhysicsIntersectRayResult2D" />+ <description>+ Intersects a ray in a given space. Ray position and other parameters are defined through [PhysicsRayQueryParameters2D].+ If the ray hits a shape, this method returns [code]true[/code] and writes the intersection information into the [PhysicsIntersectRayResult2D] object passed in [param result]. If nothing is hit, it returns [code]false[/code].+ </description>+ </method><method name="intersect_shape"><return type="Dictionary[]" /><param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />@@ -85,5 +134,15 @@The number of intersections can be limited with the [param max_results] parameter, to reduce the processing time.</description></method>+ <method name="intersect_shape_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsShapeQueryParameters2D" />+ <param index="1" name="result" type="PhysicsIntersectShapeResult2D" />+ <description>+ Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters2D] object, against the space.+ If one or more shapes are found to intersect, this method returns [code]true[/code] and writes the intersection data into the [PhysicsIntersectShapeResult2D] object passed in [param result]. If no shapes are found to intersect, it returns [code]false[/code].+ The number of intersections can be limited using [member PhysicsIntersectShapeResult2D.max_intersections], to reduce the processing time.+ </description>+ </method></methods></class>diff --git a/doc/classes/PhysicsDirectSpaceState3D.xml b/doc/classes/PhysicsDirectSpaceState3D.xmlindex b13abb04da0..3ab8acabf95 100644--- a/doc/classes/PhysicsDirectSpaceState3D.xml+++ b/doc/classes/PhysicsDirectSpaceState3D.xml@@ -21,6 +21,16 @@[b]Note:[/b] Any [Shape3D]s that the shape is already colliding with e.g. inside of, will be ignored. Use [method collide_shape] to determine the [Shape3D]s that the shape is already colliding with.</description></method>+ <method name="cast_motion_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />+ <param index="1" name="result" type="PhysicsCastMotionResult3D" />+ <description>+ Checks how far a [Shape3D] can move without colliding. All the parameters for the query, including the shape and the motion, are supplied through a [PhysicsShapeQueryParameters3D] object.+ If the query is successful, this method returns [code]true[/code] and writes the motion results into the [PhysicsCastMotionResult3D] object passed in [param result]. If no collision occurs, it returns [code]false[/code].+ [b]Note:[/b] Any [Shape3D]s that the shape is already colliding with e.g. inside of, will be ignored. Use [method collide_shape_into] to determine the [Shape3D]s that the shape is already colliding with.+ </description>+ </method><method name="collide_shape"><return type="Vector3[]" /><param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />@@ -31,6 +41,17 @@[b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object.</description></method>+ <method name="collide_shape_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />+ <param index="1" name="result" type="PhysicsCollideShapeResult3D" />+ <description>+ Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters3D] object, against the space.+ If intersections are found, this method returns [code]true[/code] and writes the collision points into the [PhysicsCollideShapeResult3D] object passed in [param result]. If no intersections are found, it returns [code]false[/code].+ The number of returned results can be limited using [member PhysicsCollideShapeResult3D.max_collisions], to reduce the processing time.+ [b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object.+ </description>+ </method><method name="get_rest_info"><return type="Dictionary" /><param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />@@ -46,6 +67,16 @@[b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object.</description></method>+ <method name="get_rest_info_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />+ <param index="1" name="result" type="PhysicsGetRestInfoResult3D" />+ <description>+ Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters3D] object, against the space.+ If the shape collides with one or more shapes, this method returns [code]true[/code] and writes the nearest collision information into the [PhysicsGetRestInfoResult3D] object passed in [param result]. If no collisions occur, it returns [code]false[/code].+ [b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object.+ </description>+ </method><method name="intersect_point"><return type="Dictionary[]" /><param index="0" name="parameters" type="PhysicsPointQueryParameters3D" />@@ -59,6 +90,16 @@The number of intersections can be limited with the [param max_results] parameter, to reduce the processing time.</description></method>+ <method name="intersect_point_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsPointQueryParameters3D" />+ <param index="1" name="result" type="PhysicsIntersectPointResult3D" />+ <description>+ Checks whether a point is inside any solid shape. Position and other parameters are defined through [PhysicsPointQueryParameters3D].+ If one or more shapes overlap the point, this method returns [code]true[/code] and writes the intersection data into the [PhysicsIntersectPointResult3D] object passed in [param result]. If no intersections are found, it returns [code]false[/code].+ The number of intersections can be limited using [member PhysicsIntersectPointResult3D.max_intersections], to reduce the processing time.+ </description>+ </method><method name="intersect_ray"><return type="Dictionary" /><param index="0" name="parameters" type="PhysicsRayQueryParameters3D" />@@ -75,6 +116,15 @@If the ray did not intersect anything, then an empty dictionary is returned instead.</description></method>+ <method name="intersect_ray_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsRayQueryParameters3D" />+ <param index="1" name="result" type="PhysicsIntersectRayResult3D" />+ <description>+ Intersects a ray in a given space. Ray position and other parameters are defined through [PhysicsRayQueryParameters3D].+ If the ray hits a shape, this method returns [code]true[/code] and writes the intersection information into the [PhysicsIntersectRayResult3D] object passed in [param result]. If nothing is hit, it returns [code]false[/code].+ </description>+ </method><method name="intersect_shape"><return type="Dictionary[]" /><param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />@@ -89,5 +139,16 @@[b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object.</description></method>+ <method name="intersect_shape_into">+ <return type="bool" />+ <param index="0" name="parameters" type="PhysicsShapeQueryParameters3D" />+ <param index="1" name="result" type="PhysicsIntersectShapeResult3D" />+ <description>+ Checks the intersections of a shape, given through a [PhysicsShapeQueryParameters3D] object, against the space.+ If one or more shapes are found to intersect, this method returns [code]true[/code] and writes the intersection data into the [PhysicsIntersectShapeResult3D] object passed in [param result]. If no shapes are found to intersect, it returns [code]false[/code].+ The number of intersections can be limited using [member PhysicsIntersectShapeResult3D.max_intersections], to reduce the processing time.+ [b]Note:[/b] This method does not take into account the [code]motion[/code] property of the object.+ </description>+ </method></methods></class>diff --git a/doc/classes/PhysicsGetRestInfoResult2D.xml b/doc/classes/PhysicsGetRestInfoResult2D.xmlnew file mode 100644index 00000000000..323fc0fa5b8--- /dev/null+++ b/doc/classes/PhysicsGetRestInfoResult2D.xml@@ -0,0 +1,32 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsGetRestInfoResult2D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the nearest collision information of a shape query.+ </brief_description>+ <description>+ This class contains the collision data computed by [method PhysicsDirectSpaceState2D.get_rest_info_into].+ If the shape collides with multiple objects, only the nearest collision is stored.+ </description>+ <tutorials>+ </tutorials>+ <members>+ <member name="collider_id" type="int" setter="" getter="get_collider_id" default="0">+ The colliding object's ID.+ </member>+ <member name="collider_rid" type="RID" setter="" getter="get_collider_rid" default="RID()">+ The intersecting object's [RID].+ </member>+ <member name="collider_shape" type="int" setter="" getter="get_collider_shape" default="0">+ The shape index of the colliding shape.+ </member>+ <member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2(0, 0)">+ The colliding object's velocity [Vector2]. If the object is an [Area2D], the result is [code](0, 0)[/code].+ </member>+ <member name="normal" type="Vector2" setter="" getter="get_normal" default="Vector2(0, 0)">+ The collision normal of the query shape at the intersection point, pointing away from the intersecting object.+ </member>+ <member name="point" type="Vector2" setter="" getter="get_point" default="Vector2(0, 0)">+ The intersection point.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsGetRestInfoResult3D.xml b/doc/classes/PhysicsGetRestInfoResult3D.xmlnew file mode 100644index 00000000000..0da2c88d487--- /dev/null+++ b/doc/classes/PhysicsGetRestInfoResult3D.xml@@ -0,0 +1,32 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsGetRestInfoResult3D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the nearest collision information of a shape query.+ </brief_description>+ <description>+ This class contains the collision data computed by [method PhysicsDirectSpaceState3D.get_rest_info_into].+ If the shape collides with multiple objects, only the nearest collision is stored.+ </description>+ <tutorials>+ </tutorials>+ <members>+ <member name="collider_id" type="int" setter="" getter="get_collider_id" default="0">+ The colliding object's ID.+ </member>+ <member name="collider_rid" type="RID" setter="" getter="get_collider_rid" default="RID()">+ The intersecting object's [RID].+ </member>+ <member name="collider_shape" type="int" setter="" getter="get_collider_shape" default="0">+ The shape index of the colliding shape.+ </member>+ <member name="collider_velocity" type="Vector3" setter="" getter="get_collider_velocity" default="Vector3(0, 0, 0)">+ The colliding object's velocity [Vector3]. If the object is an [Area3D], the result is [code](0, 0, 0)[/code].+ </member>+ <member name="normal" type="Vector3" setter="" getter="get_normal" default="Vector3(0, 0, 0)">+ The collision normal of the query shape at the intersection point, pointing away from the intersecting object.+ </member>+ <member name="point" type="Vector3" setter="" getter="get_point" default="Vector3(0, 0, 0)">+ The intersection point.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsIntersectPointResult2D.xml b/doc/classes/PhysicsIntersectPointResult2D.xmlnew file mode 100644index 00000000000..1738d395669--- /dev/null+++ b/doc/classes/PhysicsIntersectPointResult2D.xml@@ -0,0 +1,53 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsIntersectPointResult2D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the results of a point intersection query.+ </brief_description>+ <description>+ This class contains the intersection information produced by [method PhysicsDirectSpaceState2D.intersect_point_into].+ It stores up to a user-defined number of overlapping shapes.+ </description>+ <tutorials>+ </tutorials>+ <methods>+ <method name="get_collider" qualifiers="const">+ <return type="Object" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The colliding object.+ </description>+ </method>+ <method name="get_collider_id" qualifiers="const">+ <return type="int" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The colliding object's ID.+ </description>+ </method>+ <method name="get_collider_rid" qualifiers="const">+ <return type="RID" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The intersecting object's [RID].+ </description>+ </method>+ <method name="get_collider_shape" qualifiers="const">+ <return type="int" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The shape index of the colliding shape.+ </description>+ </method>+ <method name="get_intersection_count" qualifiers="const">+ <return type="int" />+ <description>+ Returns the number of shapes that intersect the queried point.+ </description>+ </method>+ </methods>+ <members>+ <member name="max_intersections" type="int" setter="set_max_intersections" getter="get_max_intersections" default="32">+ The maximum number of intersections this result object can store.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsIntersectPointResult3D.xml b/doc/classes/PhysicsIntersectPointResult3D.xmlnew file mode 100644index 00000000000..5caa0d60387--- /dev/null+++ b/doc/classes/PhysicsIntersectPointResult3D.xml@@ -0,0 +1,53 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsIntersectPointResult3D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the results of a point intersection query.+ </brief_description>+ <description>+ This class contains the intersection information produced by [method PhysicsDirectSpaceState3D.intersect_point_into].+ It stores up to a user-defined number of overlapping shapes.+ </description>+ <tutorials>+ </tutorials>+ <methods>+ <method name="get_collider" qualifiers="const">+ <return type="Object" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The colliding object.+ </description>+ </method>+ <method name="get_collider_id" qualifiers="const">+ <return type="int" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The colliding object's ID.+ </description>+ </method>+ <method name="get_collider_rid" qualifiers="const">+ <return type="RID" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The intersecting object's [RID].+ </description>+ </method>+ <method name="get_collider_shape" qualifiers="const">+ <return type="int" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The shape index of the colliding shape.+ </description>+ </method>+ <method name="get_intersection_count" qualifiers="const">+ <return type="int" />+ <description>+ Returns the number of shapes that intersect the queried point.+ </description>+ </method>+ </methods>+ <members>+ <member name="max_intersections" type="int" setter="set_max_intersections" getter="get_max_intersections" default="32">+ The maximum number of intersections this result object can store.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsIntersectRayResult2D.xml b/doc/classes/PhysicsIntersectRayResult2D.xmlnew file mode 100644index 00000000000..443ed2654a7--- /dev/null+++ b/doc/classes/PhysicsIntersectRayResult2D.xml@@ -0,0 +1,32 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsIntersectRayResult2D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the result of a ray intersection query.+ </brief_description>+ <description>+ This object contains the intersection information produced by [method PhysicsDirectSpaceState2D.intersect_ray_into].+ After calling [method PhysicsDirectSpaceState2D.intersect_ray_into], the fields of this object will be populated with the hit information if the ray intersects a shape. If no intersection occurred, the values remain unchanged from the previous state.+ </description>+ <tutorials>+ </tutorials>+ <members>+ <member name="collider" type="Object" setter="" getter="get_collider">+ The colliding object.+ </member>+ <member name="collider_id" type="int" setter="" getter="get_collider_id" default="0">+ The colliding object's ID.+ </member>+ <member name="collider_rid" type="RID" setter="" getter="get_collider_rid" default="RID()">+ The intersecting object's [RID].+ </member>+ <member name="collider_shape" type="int" setter="" getter="get_collider_shape" default="0">+ The shape index of the colliding shape.+ </member>+ <member name="normal" type="Vector2" setter="" getter="get_normal" default="Vector2(0, 0)">+ The object's surface normal at the intersection point, or [code]Vector2(0, 0)[/code] if the ray starts inside the shape and [member PhysicsRayQueryParameters2D.hit_from_inside] is [code]true[/code].+ </member>+ <member name="position" type="Vector2" setter="" getter="get_position" default="Vector2(0, 0)">+ The intersection point.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsIntersectRayResult3D.xml b/doc/classes/PhysicsIntersectRayResult3D.xmlnew file mode 100644index 00000000000..7d8193f537e--- /dev/null+++ b/doc/classes/PhysicsIntersectRayResult3D.xml@@ -0,0 +1,36 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsIntersectRayResult3D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the result of a ray intersection query.+ </brief_description>+ <description>+ This object contains the intersection information produced by [method PhysicsDirectSpaceState3D.intersect_ray_into].+ After calling [method PhysicsDirectSpaceState3D.intersect_ray_into], the fields of this object will be populated with the hit information if the ray intersects a shape. If no intersection occurred, the values remain unchanged from the previous state.+ </description>+ <tutorials>+ </tutorials>+ <members>+ <member name="collider" type="Object" setter="" getter="get_collider">+ The colliding object.+ </member>+ <member name="collider_face_index" type="int" setter="" getter="get_collider_face_index" default="-1">+ The face index at the intersection point.+ [b]Note:[/b] Returns a valid number only if the intersected shape is a [ConcavePolygonShape3D]. Otherwise, [code]-1[/code] is returned.+ </member>+ <member name="collider_id" type="int" setter="" getter="get_collider_id" default="0">+ The colliding object's ID.+ </member>+ <member name="collider_rid" type="RID" setter="" getter="get_collider_rid" default="RID()">+ The intersecting object's [RID].+ </member>+ <member name="collider_shape" type="int" setter="" getter="get_collider_shape" default="0">+ The shape index of the colliding shape.+ </member>+ <member name="normal" type="Vector3" setter="" getter="get_normal" default="Vector3(0, 0, 0)">+ The object's surface normal at the intersection point, or [code]Vector3(0, 0, 0)[/code] if the ray starts inside the shape and [member PhysicsRayQueryParameters3D.hit_from_inside] is [code]true[/code].+ </member>+ <member name="position" type="Vector3" setter="" getter="get_position" default="Vector3(0, 0, 0)">+ The intersection point.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsIntersectShapeResult2D.xml b/doc/classes/PhysicsIntersectShapeResult2D.xmlnew file mode 100644index 00000000000..bda5fd22db1--- /dev/null+++ b/doc/classes/PhysicsIntersectShapeResult2D.xml@@ -0,0 +1,53 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsIntersectShapeResult2D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the results of a shape intersection query.+ </brief_description>+ <description>+ This class contains the intersection information produced by [method PhysicsDirectSpaceState2D.intersect_shape_into].+ It can store multiple intersections, up to a user-defined maximum.+ </description>+ <tutorials>+ </tutorials>+ <methods>+ <method name="get_collider" qualifiers="const">+ <return type="Object" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The colliding object.+ </description>+ </method>+ <method name="get_collider_id" qualifiers="const">+ <return type="int" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The colliding object's ID.+ </description>+ </method>+ <method name="get_collider_rid" qualifiers="const">+ <return type="RID" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The intersecting object's [RID].+ </description>+ </method>+ <method name="get_collider_shape" qualifiers="const">+ <return type="int" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The shape index of the colliding shape.+ </description>+ </method>+ <method name="get_intersection_count" qualifiers="const">+ <return type="int" />+ <description>+ Returns the number of shapes that intersect with the query shape.+ </description>+ </method>+ </methods>+ <members>+ <member name="max_intersections" type="int" setter="set_max_intersections" getter="get_max_intersections" default="32">+ The maximum number of intersections this result object can store.+ </member>+ </members>+</class>diff --git a/doc/classes/PhysicsIntersectShapeResult3D.xml b/doc/classes/PhysicsIntersectShapeResult3D.xmlnew file mode 100644index 00000000000..a571d02e68a--- /dev/null+++ b/doc/classes/PhysicsIntersectShapeResult3D.xml@@ -0,0 +1,53 @@+<?xml version="1.0" encoding="UTF-8" ?>+<class name="PhysicsIntersectShapeResult3D" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">+ <brief_description>+ Stores the results of a shape intersection query.+ </brief_description>+ <description>+ This class contains the intersection information produced by [method PhysicsDirectSpaceState3D.intersect_shape_into].+ It can store multiple intersections, up to a user-defined maximum.+ </description>+ <tutorials>+ </tutorials>+ <methods>+ <method name="get_collider" qualifiers="const">+ <return type="Object" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The colliding object.+ </description>+ </method>+ <method name="get_collider_id" qualifiers="const">+ <return type="int" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The colliding object's ID.+ </description>+ </method>+ <method name="get_collider_rid" qualifiers="const">+ <return type="RID" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The intersecting object's [RID].+ </description>+ </method>+ <method name="get_collider_shape" qualifiers="const">+ <return type="int" />+ <param index="0" name="intersection_index" type="int" />+ <description>+ The shape index of the colliding shape.+ </description>+ </method>+ <method name="get_intersection_count" qualifiers="const">+ <return type="int" />+ <description>+ Returns the number of shapes that intersect with the query shape.+ </description>+ </method>+ </methods>+ <members>+ <member name="max_intersections" type="int" setter="set_max_intersections" getter="get_max_intersections" default="32">+ The maximum number of intersections this result object can store.+ </member>+ </members>+</class>diff --git a/servers/physics_2d/direct_states/physics_direct_space_state_2d.cpp b/servers/physics_2d/direct_states/physics_direct_space_state_2d.cppindex 647e9da6195..d51b0e8e4e0 100644--- a/servers/physics_2d/direct_states/physics_direct_space_state_2d.cpp+++ b/servers/physics_2d/direct_states/physics_direct_space_state_2d.cpp@@ -154,14 +154,70 @@ Dictionary PhysicsDirectSpaceState2D::_get_rest_info(RequiredParam<PhysicsShapeQreturn r;}+bool PhysicsDirectSpaceState2D::_intersect_ray_into(RequiredParam<PhysicsRayQueryParameters2D> p_ray_query, RequiredParam<PhysicsIntersectRayResult2D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(ray_query, p_ray_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ return intersect_ray(ray_query->get_parameters(), result->result);+}++bool PhysicsDirectSpaceState2D::_intersect_point_into(RequiredParam<PhysicsPointQueryParameters2D> p_point_query, RequiredParam<PhysicsIntersectPointResult2D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(point_query, p_point_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ result->intersection_count = intersect_point(point_query->get_parameters(), result->result.ptr(), result->get_max_intersections());++ return result->intersection_count > 0;+}++bool PhysicsDirectSpaceState2D::_intersect_shape_into(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, RequiredParam<PhysicsIntersectShapeResult2D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(shape_query, p_shape_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ result->intersection_count = intersect_shape(shape_query->get_parameters(), result->result.ptr(), result->get_max_intersections());++ return result->intersection_count > 0;+}++bool PhysicsDirectSpaceState2D::_cast_motion_into(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, RequiredParam<PhysicsCastMotionResult2D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(shape_query, p_shape_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ result->safe_fraction = 1.0;+ result->unsafe_fraction = 1.0;++ return cast_motion(shape_query->get_parameters(), result->safe_fraction, result->unsafe_fraction) && result->safe_fraction < 1.0;+}++bool PhysicsDirectSpaceState2D::_collide_shape_into(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, RequiredParam<PhysicsCollideShapeResult2D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(shape_query, p_shape_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ return collide_shape(shape_query->get_parameters(), result->result.ptr(), result->get_max_collisions(), result->collision_count);+}++bool PhysicsDirectSpaceState2D::_get_rest_info_into(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, RequiredParam<PhysicsGetRestInfoResult2D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(shape_query, p_shape_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ return rest_info(shape_query->get_parameters(), &result->result);+}+PhysicsDirectSpaceState2D::PhysicsDirectSpaceState2D() {}void PhysicsDirectSpaceState2D::_bind_methods() {- ClassDB::bind_method(D_METHOD("intersect_point", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_intersect_point, DEFVAL(32));ClassDB::bind_method(D_METHOD("intersect_ray", "parameters"), &PhysicsDirectSpaceState2D::_intersect_ray);+ ClassDB::bind_method(D_METHOD("intersect_point", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_intersect_point, DEFVAL(32));ClassDB::bind_method(D_METHOD("intersect_shape", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_intersect_shape, DEFVAL(32));ClassDB::bind_method(D_METHOD("cast_motion", "parameters"), &PhysicsDirectSpaceState2D::_cast_motion);ClassDB::bind_method(D_METHOD("collide_shape", "parameters", "max_results"), &PhysicsDirectSpaceState2D::_collide_shape, DEFVAL(32));ClassDB::bind_method(D_METHOD("get_rest_info", "parameters"), &PhysicsDirectSpaceState2D::_get_rest_info);++ ClassDB::bind_method(D_METHOD("intersect_ray_into", "parameters", "result"), &PhysicsDirectSpaceState2D::_intersect_ray_into);+ ClassDB::bind_method(D_METHOD("intersect_point_into", "parameters", "result"), &PhysicsDirectSpaceState2D::_intersect_point_into);+ ClassDB::bind_method(D_METHOD("intersect_shape_into", "parameters", "result"), &PhysicsDirectSpaceState2D::_intersect_shape_into);+ ClassDB::bind_method(D_METHOD("cast_motion_into", "parameters", "result"), &PhysicsDirectSpaceState2D::_cast_motion_into);+ ClassDB::bind_method(D_METHOD("collide_shape_into", "parameters", "result"), &PhysicsDirectSpaceState2D::_collide_shape_into);+ ClassDB::bind_method(D_METHOD("get_rest_info_into", "parameters", "result"), &PhysicsDirectSpaceState2D::_get_rest_info_into);}diff --git a/servers/physics_2d/direct_states/physics_direct_space_state_2d.h b/servers/physics_2d/direct_states/physics_direct_space_state_2d.hindex 48a6db58068..fb33da898b6 100644--- a/servers/physics_2d/direct_states/physics_direct_space_state_2d.h+++ b/servers/physics_2d/direct_states/physics_direct_space_state_2d.h@@ -32,6 +32,12 @@#include "core/variant/type_info.h"#include "servers/physics_2d/physics_server_2d_types.h"+#include "servers/physics_2d/queries/physics_cast_motion_result_2d.h"+#include "servers/physics_2d/queries/physics_collide_shape_result_2d.h"+#include "servers/physics_2d/queries/physics_get_rest_info_result_2d.h"+#include "servers/physics_2d/queries/physics_intersect_point_result_2d.h"+#include "servers/physics_2d/queries/physics_intersect_ray_result_2d.h"+#include "servers/physics_2d/queries/physics_intersect_shape_result_2d.h"#include "servers/physics_2d/queries/physics_point_query_parameters_2d.h"#include "servers/physics_2d/queries/physics_ray_query_parameters_2d.h"#include "servers/physics_2d/queries/physics_shape_query_parameters_2d.h"@@ -46,14 +52,19 @@ class PhysicsDirectSpaceState2D : public Object {TypedArray<Vector2> _collide_shape(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, int p_max_results = 32);Dictionary _get_rest_info(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query);+ bool _intersect_ray_into(RequiredParam<PhysicsRayQueryParameters2D> p_ray_query, RequiredParam<PhysicsIntersectRayResult2D> p_result);+ bool _intersect_point_into(RequiredParam<PhysicsPointQueryParameters2D> p_point_query, RequiredParam<PhysicsIntersectPointResult2D> p_result);+ bool _intersect_shape_into(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, RequiredParam<PhysicsIntersectShapeResult2D> p_result);+ bool _cast_motion_into(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, RequiredParam<PhysicsCastMotionResult2D> p_result);+ bool _collide_shape_into(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, RequiredParam<PhysicsCollideShapeResult2D> p_result);+ bool _get_rest_info_into(RequiredParam<PhysicsShapeQueryParameters2D> p_shape_query, RequiredParam<PhysicsGetRestInfoResult2D> p_result);+protected:static void _bind_methods();public:virtual bool intersect_ray(const PS2DT::RayParameters &p_parameters, PS2DT::RayResult &r_result) = 0;-virtual int intersect_point(const PS2DT::PointParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) = 0;-virtual int intersect_shape(const PS2DT::ShapeParameters &p_parameters, PS2DT::ShapeResult *r_results, int p_result_max) = 0;virtual bool cast_motion(const PS2DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe) = 0;virtual bool collide_shape(const PS2DT::ShapeParameters &p_parameters, Vector2 *r_results, int p_result_max, int &r_result_count) = 0;diff --git a/servers/physics_2d/queries/physics_cast_motion_result_2d.cpp b/servers/physics_2d/queries/physics_cast_motion_result_2d.cppnew file mode 100644index 00000000000..25640552cce--- /dev/null+++ b/servers/physics_2d/queries/physics_cast_motion_result_2d.cpp@@ -0,0 +1,49 @@+/**************************************************************************/+/* physics_cast_motion_result_2d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_cast_motion_result_2d.h"++#include "core/object/class_db.h"++real_t PhysicsCastMotionResult2D::get_safe_fraction() const {+ return safe_fraction;+}++real_t PhysicsCastMotionResult2D::get_unsafe_fraction() const {+ return unsafe_fraction;+}++void PhysicsCastMotionResult2D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_safe_fraction"), &PhysicsCastMotionResult2D::get_safe_fraction);+ ClassDB::bind_method(D_METHOD("get_unsafe_fraction"), &PhysicsCastMotionResult2D::get_unsafe_fraction);++ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "safe_fraction"), "", "get_safe_fraction");+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "unsafe_fraction"), "", "get_unsafe_fraction");+}diff --git a/servers/physics_2d/queries/physics_cast_motion_result_2d.h b/servers/physics_2d/queries/physics_cast_motion_result_2d.hnew file mode 100644index 00000000000..5ab63b65817--- /dev/null+++ b/servers/physics_2d/queries/physics_cast_motion_result_2d.h@@ -0,0 +1,49 @@+/**************************************************************************/+/* physics_cast_motion_result_2d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"++class PhysicsCastMotionResult2D : public RefCounted {+ GDCLASS(PhysicsCastMotionResult2D, RefCounted);++ friend class PhysicsDirectSpaceState2D;++ real_t safe_fraction = 1.0;+ real_t unsafe_fraction = 1.0;++protected:+ static void _bind_methods();++public:+ real_t get_safe_fraction() const;+ real_t get_unsafe_fraction() const;+};diff --git a/servers/physics_2d/queries/physics_collide_shape_result_2d.cpp b/servers/physics_2d/queries/physics_collide_shape_result_2d.cppnew file mode 100644index 00000000000..1c953bd9e20--- /dev/null+++ b/servers/physics_2d/queries/physics_collide_shape_result_2d.cpp@@ -0,0 +1,72 @@+/**************************************************************************/+/* physics_collide_shape_result_2d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_collide_shape_result_2d.h"++#include "core/object/class_db.h"++PhysicsCollideShapeResult2D::PhysicsCollideShapeResult2D(int p_max_collisions) {+ ERR_FAIL_COND(p_max_collisions < 0);+ result.resize(2 * p_max_collisions);+}++int PhysicsCollideShapeResult2D::get_max_collisions() const {+ return result.size() / 2;+}++void PhysicsCollideShapeResult2D::set_max_collisions(int p_max_collisions) {+ ERR_FAIL_COND(p_max_collisions < 0);+ result.resize(2 * p_max_collisions);+ collision_count = MIN(collision_count, static_cast<int>(result.size() / 2));+}++int PhysicsCollideShapeResult2D::get_collision_count() const {+ return collision_count;+}++Vector2 PhysicsCollideShapeResult2D::get_point_on_queried_shape(int p_collision_index) const {+ ERR_FAIL_INDEX_V(p_collision_index, collision_count, Vector2());+ return result[2 * p_collision_index];+}++Vector2 PhysicsCollideShapeResult2D::get_point_on_colliding_shape(int p_collision_index) const {+ ERR_FAIL_INDEX_V(p_collision_index, collision_count, Vector2());+ return result[2 * p_collision_index + 1];+}++void PhysicsCollideShapeResult2D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_max_collisions"), &PhysicsCollideShapeResult2D::get_max_collisions);+ ClassDB::bind_method(D_METHOD("set_max_collisions", "max_collisions"), &PhysicsCollideShapeResult2D::set_max_collisions);+ ClassDB::bind_method(D_METHOD("get_collision_count"), &PhysicsCollideShapeResult2D::get_collision_count);+ ClassDB::bind_method(D_METHOD("get_point_on_queried_shape", "collision_index"), &PhysicsCollideShapeResult2D::get_point_on_queried_shape);+ ClassDB::bind_method(D_METHOD("get_point_on_colliding_shape", "collision_index"), &PhysicsCollideShapeResult2D::get_point_on_colliding_shape);++ ADD_PROPERTY(PropertyInfo(Variant::INT, "max_collisions"), "set_max_collisions", "get_max_collisions");+}diff --git a/servers/physics_2d/queries/physics_collide_shape_result_2d.h b/servers/physics_2d/queries/physics_collide_shape_result_2d.hnew file mode 100644index 00000000000..91f5b08a611--- /dev/null+++ b/servers/physics_2d/queries/physics_collide_shape_result_2d.h@@ -0,0 +1,56 @@+/**************************************************************************/+/* physics_collide_shape_result_2d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"++class PhysicsCollideShapeResult2D : public RefCounted {+ GDCLASS(PhysicsCollideShapeResult2D, RefCounted);++ friend class PhysicsDirectSpaceState2D;++ LocalVector<Vector2> result;+ int collision_count = 0;++protected:+ static void _bind_methods();++public:+ PhysicsCollideShapeResult2D(int p_max_collisions = 32);++ int get_max_collisions() const;+ void set_max_collisions(int p_max_collisions);++ int get_collision_count() const;++ Vector2 get_point_on_queried_shape(int p_collision_index) const;+ Vector2 get_point_on_colliding_shape(int p_collision_index) const;+};diff --git a/servers/physics_2d/queries/physics_get_rest_info_result_2d.cpp b/servers/physics_2d/queries/physics_get_rest_info_result_2d.cppnew file mode 100644index 00000000000..eb15a2f1e3f--- /dev/null+++ b/servers/physics_2d/queries/physics_get_rest_info_result_2d.cpp@@ -0,0 +1,73 @@+/**************************************************************************/+/* physics_get_rest_info_result_2d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_get_rest_info_result_2d.h"++#include "core/object/class_db.h"++Vector2 PhysicsGetRestInfoResult2D::get_point() const {+ return result.point;+}++Vector2 PhysicsGetRestInfoResult2D::get_normal() const {+ return result.normal;+}++RID PhysicsGetRestInfoResult2D::get_collider_rid() const {+ return result.rid;+}++ObjectID PhysicsGetRestInfoResult2D::get_collider_id() const {+ return result.collider_id;+}++int PhysicsGetRestInfoResult2D::get_collider_shape() const {+ return result.shape;+}++Vector2 PhysicsGetRestInfoResult2D::get_collider_velocity() const {+ return result.linear_velocity;+}++void PhysicsGetRestInfoResult2D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_point"), &PhysicsGetRestInfoResult2D::get_point);+ ClassDB::bind_method(D_METHOD("get_normal"), &PhysicsGetRestInfoResult2D::get_normal);+ ClassDB::bind_method(D_METHOD("get_collider_rid"), &PhysicsGetRestInfoResult2D::get_collider_rid);+ ClassDB::bind_method(D_METHOD("get_collider_id"), &PhysicsGetRestInfoResult2D::get_collider_id);+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &PhysicsGetRestInfoResult2D::get_collider_shape);+ ClassDB::bind_method(D_METHOD("get_collider_velocity"), &PhysicsGetRestInfoResult2D::get_collider_velocity);++ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "point"), "", "get_point");+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), "", "get_normal");+ ADD_PROPERTY(PropertyInfo(Variant::RID, "collider_rid"), "", "get_collider_rid");+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape"), "", "get_collider_shape");+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "collider_velocity"), "", "get_collider_velocity");+}diff --git a/servers/physics_2d/queries/physics_get_rest_info_result_2d.h b/servers/physics_2d/queries/physics_get_rest_info_result_2d.hnew file mode 100644index 00000000000..db99f862179--- /dev/null+++ b/servers/physics_2d/queries/physics_get_rest_info_result_2d.h@@ -0,0 +1,53 @@+/**************************************************************************/+/* physics_get_rest_info_result_2d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"+#include "servers/physics_2d/physics_server_2d_types.h"++class PhysicsGetRestInfoResult2D : public RefCounted {+ GDCLASS(PhysicsGetRestInfoResult2D, RefCounted);++ friend class PhysicsDirectSpaceState2D;++ PS2DT::ShapeRestInfo result;++protected:+ static void _bind_methods();++public:+ Vector2 get_point() const;+ Vector2 get_normal() const;+ RID get_collider_rid() const;+ ObjectID get_collider_id() const;+ int get_collider_shape() const;+ Vector2 get_collider_velocity() const;+};diff --git a/servers/physics_2d/queries/physics_intersect_point_result_2d.cpp b/servers/physics_2d/queries/physics_intersect_point_result_2d.cppnew file mode 100644index 00000000000..db401b9abf5--- /dev/null+++ b/servers/physics_2d/queries/physics_intersect_point_result_2d.cpp@@ -0,0 +1,84 @@+/**************************************************************************/+/* physics_intersect_point_result_2d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_intersect_point_result_2d.h"++#include "core/object/class_db.h"++PhysicsIntersectPointResult2D::PhysicsIntersectPointResult2D(int p_max_intersections) {+ ERR_FAIL_COND(p_max_intersections < 0);+ result.resize(p_max_intersections);+}++int PhysicsIntersectPointResult2D::get_max_intersections() const {+ return result.size();+}++void PhysicsIntersectPointResult2D::set_max_intersections(int p_max_intersections) {+ ERR_FAIL_COND(p_max_intersections < 0);+ result.resize(p_max_intersections);+ intersection_count = MIN(intersection_count, static_cast<int>(result.size()));+}++int PhysicsIntersectPointResult2D::get_intersection_count() const {+ return intersection_count;+}++RID PhysicsIntersectPointResult2D::get_collider_rid(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, RID());+ return result[p_intersection_index].rid;+}++ObjectID PhysicsIntersectPointResult2D::get_collider_id(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, ObjectID());+ return result[p_intersection_index].collider_id;+}++Object *PhysicsIntersectPointResult2D::get_collider(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, nullptr);+ return result[p_intersection_index].get_collider();+}++int PhysicsIntersectPointResult2D::get_collider_shape(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, 0);+ return result[p_intersection_index].shape;+}++void PhysicsIntersectPointResult2D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_max_intersections"), &PhysicsIntersectPointResult2D::get_max_intersections);+ ClassDB::bind_method(D_METHOD("set_max_intersections", "max_intersections"), &PhysicsIntersectPointResult2D::set_max_intersections);+ ClassDB::bind_method(D_METHOD("get_intersection_count"), &PhysicsIntersectPointResult2D::get_intersection_count);+ ClassDB::bind_method(D_METHOD("get_collider_id", "intersection_index"), &PhysicsIntersectPointResult2D::get_collider_id);+ ClassDB::bind_method(D_METHOD("get_collider_rid", "intersection_index"), &PhysicsIntersectPointResult2D::get_collider_rid);+ ClassDB::bind_method(D_METHOD("get_collider", "intersection_index"), &PhysicsIntersectPointResult2D::get_collider);+ ClassDB::bind_method(D_METHOD("get_collider_shape", "intersection_index"), &PhysicsIntersectPointResult2D::get_collider_shape);++ ADD_PROPERTY(PropertyInfo(Variant::INT, "max_intersections"), "set_max_intersections", "get_max_intersections");+}diff --git a/servers/physics_2d/queries/physics_intersect_point_result_2d.h b/servers/physics_2d/queries/physics_intersect_point_result_2d.hnew file mode 100644index 00000000000..07ac5f9d539--- /dev/null+++ b/servers/physics_2d/queries/physics_intersect_point_result_2d.h@@ -0,0 +1,59 @@+/**************************************************************************/+/* physics_intersect_point_result_2d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"+#include "servers/physics_2d/physics_server_2d_types.h"++class PhysicsIntersectPointResult2D : public RefCounted {+ GDCLASS(PhysicsIntersectPointResult2D, RefCounted);++ friend class PhysicsDirectSpaceState2D;++ LocalVector<PS2DT::ShapeResult> result;+ int intersection_count = 0;++protected:+ static void _bind_methods();++public:+ PhysicsIntersectPointResult2D(int p_max_intersections = 32);++ int get_max_intersections() const;+ void set_max_intersections(int p_max_intersections);++ int get_intersection_count() const;++ RID get_collider_rid(int p_intersection_index) const;+ ObjectID get_collider_id(int p_intersection_index) const;+ Object *get_collider(int p_intersection_index) const;+ int get_collider_shape(int p_intersection_index) const;+};diff --git a/servers/physics_2d/queries/physics_intersect_ray_result_2d.cpp b/servers/physics_2d/queries/physics_intersect_ray_result_2d.cppnew file mode 100644index 00000000000..3985dabc633--- /dev/null+++ b/servers/physics_2d/queries/physics_intersect_ray_result_2d.cpp@@ -0,0 +1,73 @@+/**************************************************************************/+/* physics_intersect_ray_result_2d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_intersect_ray_result_2d.h"++#include "core/object/class_db.h"++Vector2 PhysicsIntersectRayResult2D::get_position() const {+ return result.position;+}++Vector2 PhysicsIntersectRayResult2D::get_normal() const {+ return result.normal;+}++RID PhysicsIntersectRayResult2D::get_collider_rid() const {+ return result.rid;+}++ObjectID PhysicsIntersectRayResult2D::get_collider_id() const {+ return result.collider_id;+}++Object *PhysicsIntersectRayResult2D::get_collider() const {+ return result.get_collider();+}++int PhysicsIntersectRayResult2D::get_collider_shape() const {+ return result.shape;+}++void PhysicsIntersectRayResult2D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_position"), &PhysicsIntersectRayResult2D::get_position);+ ClassDB::bind_method(D_METHOD("get_normal"), &PhysicsIntersectRayResult2D::get_normal);+ ClassDB::bind_method(D_METHOD("get_collider_rid"), &PhysicsIntersectRayResult2D::get_collider_rid);+ ClassDB::bind_method(D_METHOD("get_collider_id"), &PhysicsIntersectRayResult2D::get_collider_id);+ ClassDB::bind_method(D_METHOD("get_collider"), &PhysicsIntersectRayResult2D::get_collider);+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &PhysicsIntersectRayResult2D::get_collider_shape);++ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "", "get_position");+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "normal"), "", "get_normal");+ ADD_PROPERTY(PropertyInfo(Variant::RID, "collider_rid"), "", "get_collider_rid");+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider");+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape"), "", "get_collider_shape");+}diff --git a/servers/physics_2d/queries/physics_intersect_ray_result_2d.h b/servers/physics_2d/queries/physics_intersect_ray_result_2d.hnew file mode 100644index 00000000000..4702aa31a2c--- /dev/null+++ b/servers/physics_2d/queries/physics_intersect_ray_result_2d.h@@ -0,0 +1,53 @@+/**************************************************************************/+/* physics_intersect_ray_result_2d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"+#include "servers/physics_2d/physics_server_2d_types.h"++class PhysicsIntersectRayResult2D : public RefCounted {+ GDCLASS(PhysicsIntersectRayResult2D, RefCounted);++ friend class PhysicsDirectSpaceState2D;++ PS2DT::RayResult result;++protected:+ static void _bind_methods();++public:+ Vector2 get_position() const;+ Vector2 get_normal() const;+ RID get_collider_rid() const;+ ObjectID get_collider_id() const;+ Object *get_collider() const;+ int get_collider_shape() const;+};diff --git a/servers/physics_2d/queries/physics_intersect_shape_result_2d.cpp b/servers/physics_2d/queries/physics_intersect_shape_result_2d.cppnew file mode 100644index 00000000000..d4e1a0c0879--- /dev/null+++ b/servers/physics_2d/queries/physics_intersect_shape_result_2d.cpp@@ -0,0 +1,84 @@+/**************************************************************************/+/* physics_intersect_shape_result_2d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_intersect_shape_result_2d.h"++#include "core/object/class_db.h"++PhysicsIntersectShapeResult2D::PhysicsIntersectShapeResult2D(int p_max_intersections) {+ ERR_FAIL_COND(p_max_intersections < 0);+ result.resize(p_max_intersections);+}++int PhysicsIntersectShapeResult2D::get_max_intersections() const {+ return result.size();+}++void PhysicsIntersectShapeResult2D::set_max_intersections(int p_max_intersections) {+ ERR_FAIL_COND(p_max_intersections < 0);+ result.resize(p_max_intersections);+ intersection_count = MIN(intersection_count, static_cast<int>(result.size()));+}++int PhysicsIntersectShapeResult2D::get_intersection_count() const {+ return intersection_count;+}++RID PhysicsIntersectShapeResult2D::get_collider_rid(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, RID());+ return result[p_intersection_index].rid;+}++ObjectID PhysicsIntersectShapeResult2D::get_collider_id(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, ObjectID());+ return result[p_intersection_index].collider_id;+}++Object *PhysicsIntersectShapeResult2D::get_collider(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, nullptr);+ return result[p_intersection_index].get_collider();+}++int PhysicsIntersectShapeResult2D::get_collider_shape(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, 0);+ return result[p_intersection_index].shape;+}++void PhysicsIntersectShapeResult2D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_max_intersections"), &PhysicsIntersectShapeResult2D::get_max_intersections);+ ClassDB::bind_method(D_METHOD("set_max_intersections", "max_intersections"), &PhysicsIntersectShapeResult2D::set_max_intersections);+ ClassDB::bind_method(D_METHOD("get_intersection_count"), &PhysicsIntersectShapeResult2D::get_intersection_count);+ ClassDB::bind_method(D_METHOD("get_collider_id", "intersection_index"), &PhysicsIntersectShapeResult2D::get_collider_id);+ ClassDB::bind_method(D_METHOD("get_collider_rid", "intersection_index"), &PhysicsIntersectShapeResult2D::get_collider_rid);+ ClassDB::bind_method(D_METHOD("get_collider", "intersection_index"), &PhysicsIntersectShapeResult2D::get_collider);+ ClassDB::bind_method(D_METHOD("get_collider_shape", "intersection_index"), &PhysicsIntersectShapeResult2D::get_collider_shape);++ ADD_PROPERTY(PropertyInfo(Variant::INT, "max_intersections"), "set_max_intersections", "get_max_intersections");+}diff --git a/servers/physics_2d/queries/physics_intersect_shape_result_2d.h b/servers/physics_2d/queries/physics_intersect_shape_result_2d.hnew file mode 100644index 00000000000..bb872e1e89a--- /dev/null+++ b/servers/physics_2d/queries/physics_intersect_shape_result_2d.h@@ -0,0 +1,59 @@+/**************************************************************************/+/* physics_intersect_shape_result_2d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"+#include "servers/physics_2d/physics_server_2d_types.h"++class PhysicsIntersectShapeResult2D : public RefCounted {+ GDCLASS(PhysicsIntersectShapeResult2D, RefCounted);++ friend class PhysicsDirectSpaceState2D;++ LocalVector<PS2DT::ShapeResult> result;+ int intersection_count = 0;++protected:+ static void _bind_methods();++public:+ PhysicsIntersectShapeResult2D(int p_max_intersections = 32);++ int get_max_intersections() const;+ void set_max_intersections(int p_max_intersections);++ int get_intersection_count() const;++ RID get_collider_rid(int p_intersection_index) const;+ ObjectID get_collider_id(int p_intersection_index) const;+ Object *get_collider(int p_intersection_index) const;+ int get_collider_shape(int p_intersection_index) const;+};diff --git a/servers/physics_3d/direct_states/physics_direct_space_state_3d.cpp b/servers/physics_3d/direct_states/physics_direct_space_state_3d.cppindex 236324fb267..a1824749cd8 100644--- a/servers/physics_3d/direct_states/physics_direct_space_state_3d.cpp+++ b/servers/physics_3d/direct_states/physics_direct_space_state_3d.cpp@@ -154,14 +154,70 @@ Dictionary PhysicsDirectSpaceState3D::_get_rest_info(RequiredParam<PhysicsShapeQreturn r;}+bool PhysicsDirectSpaceState3D::_intersect_ray_into(RequiredParam<PhysicsRayQueryParameters3D> p_ray_query, RequiredParam<PhysicsIntersectRayResult3D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(ray_query, p_ray_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ return intersect_ray(ray_query->get_parameters(), result->result);+}++bool PhysicsDirectSpaceState3D::_intersect_point_into(RequiredParam<PhysicsPointQueryParameters3D> p_point_query, RequiredParam<PhysicsIntersectPointResult3D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(point_query, p_point_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ result->intersection_count = intersect_point(point_query->get_parameters(), result->result.ptr(), result->get_max_intersections());++ return result->intersection_count > 0;+}++bool PhysicsDirectSpaceState3D::_intersect_shape_into(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, RequiredParam<PhysicsIntersectShapeResult3D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(shape_query, p_shape_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ result->intersection_count = intersect_shape(shape_query->get_parameters(), result->result.ptr(), result->get_max_intersections());++ return result->intersection_count > 0;+}++bool PhysicsDirectSpaceState3D::_cast_motion_into(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, RequiredParam<PhysicsCastMotionResult3D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(shape_query, p_shape_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ result->safe_fraction = 1.0;+ result->unsafe_fraction = 1.0;++ return cast_motion(shape_query->get_parameters(), result->safe_fraction, result->unsafe_fraction) && result->safe_fraction < 1.0;+}++bool PhysicsDirectSpaceState3D::_collide_shape_into(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, RequiredParam<PhysicsCollideShapeResult3D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(shape_query, p_shape_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ return collide_shape(shape_query->get_parameters(), result->result.ptr(), result->get_max_collisions(), result->collision_count);+}++bool PhysicsDirectSpaceState3D::_get_rest_info_into(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, RequiredParam<PhysicsGetRestInfoResult3D> p_result) {+ EXTRACT_PARAM_OR_FAIL_V(shape_query, p_shape_query, false);+ EXTRACT_PARAM_OR_FAIL_V(result, p_result, false);++ return rest_info(shape_query->get_parameters(), &result->result);+}+PhysicsDirectSpaceState3D::PhysicsDirectSpaceState3D() {}void PhysicsDirectSpaceState3D::_bind_methods() {- ClassDB::bind_method(D_METHOD("intersect_point", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_intersect_point, DEFVAL(32));ClassDB::bind_method(D_METHOD("intersect_ray", "parameters"), &PhysicsDirectSpaceState3D::_intersect_ray);+ ClassDB::bind_method(D_METHOD("intersect_point", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_intersect_point, DEFVAL(32));ClassDB::bind_method(D_METHOD("intersect_shape", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_intersect_shape, DEFVAL(32));ClassDB::bind_method(D_METHOD("cast_motion", "parameters"), &PhysicsDirectSpaceState3D::_cast_motion);ClassDB::bind_method(D_METHOD("collide_shape", "parameters", "max_results"), &PhysicsDirectSpaceState3D::_collide_shape, DEFVAL(32));ClassDB::bind_method(D_METHOD("get_rest_info", "parameters"), &PhysicsDirectSpaceState3D::_get_rest_info);++ ClassDB::bind_method(D_METHOD("intersect_ray_into", "parameters", "result"), &PhysicsDirectSpaceState3D::_intersect_ray_into);+ ClassDB::bind_method(D_METHOD("intersect_point_into", "parameters", "result"), &PhysicsDirectSpaceState3D::_intersect_point_into);+ ClassDB::bind_method(D_METHOD("intersect_shape_into", "parameters", "result"), &PhysicsDirectSpaceState3D::_intersect_shape_into);+ ClassDB::bind_method(D_METHOD("cast_motion_into", "parameters", "result"), &PhysicsDirectSpaceState3D::_cast_motion_into);+ ClassDB::bind_method(D_METHOD("collide_shape_into", "parameters", "result"), &PhysicsDirectSpaceState3D::_collide_shape_into);+ ClassDB::bind_method(D_METHOD("get_rest_info_into", "parameters", "result"), &PhysicsDirectSpaceState3D::_get_rest_info_into);}diff --git a/servers/physics_3d/direct_states/physics_direct_space_state_3d.h b/servers/physics_3d/direct_states/physics_direct_space_state_3d.hindex 735ac9ad94f..5d7c058a985 100644--- a/servers/physics_3d/direct_states/physics_direct_space_state_3d.h+++ b/servers/physics_3d/direct_states/physics_direct_space_state_3d.h@@ -32,6 +32,12 @@#include "core/variant/type_info.h"#include "servers/physics_3d/physics_server_3d_types.h"+#include "servers/physics_3d/queries/physics_cast_motion_result_3d.h"+#include "servers/physics_3d/queries/physics_collide_shape_result_3d.h"+#include "servers/physics_3d/queries/physics_get_rest_info_result_3d.h"+#include "servers/physics_3d/queries/physics_intersect_point_result_3d.h"+#include "servers/physics_3d/queries/physics_intersect_ray_result_3d.h"+#include "servers/physics_3d/queries/physics_intersect_shape_result_3d.h"#include "servers/physics_3d/queries/physics_point_query_parameters_3d.h"#include "servers/physics_3d/queries/physics_ray_query_parameters_3d.h"#include "servers/physics_3d/queries/physics_shape_query_parameters_3d.h"@@ -47,14 +53,19 @@ private:TypedArray<Vector3> _collide_shape(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, int p_max_results = 32);Dictionary _get_rest_info(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query);+ bool _intersect_ray_into(RequiredParam<PhysicsRayQueryParameters3D> p_ray_query, RequiredParam<PhysicsIntersectRayResult3D> p_result);+ bool _intersect_point_into(RequiredParam<PhysicsPointQueryParameters3D> p_point_query, RequiredParam<PhysicsIntersectPointResult3D> p_result);+ bool _intersect_shape_into(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, RequiredParam<PhysicsIntersectShapeResult3D> p_result);+ bool _cast_motion_into(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, RequiredParam<PhysicsCastMotionResult3D> p_result);+ bool _collide_shape_into(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, RequiredParam<PhysicsCollideShapeResult3D> p_result);+ bool _get_rest_info_into(RequiredParam<PhysicsShapeQueryParameters3D> p_shape_query, RequiredParam<PhysicsGetRestInfoResult3D> p_result);+protected:static void _bind_methods();public:virtual bool intersect_ray(const PS3DT::RayParameters &p_parameters, PS3DT::RayResult &r_result) = 0;-virtual int intersect_point(const PS3DT::PointParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) = 0;-virtual int intersect_shape(const PS3DT::ShapeParameters &p_parameters, PS3DT::ShapeResult *r_results, int p_result_max) = 0;virtual bool cast_motion(const PS3DT::ShapeParameters &p_parameters, real_t &p_closest_safe, real_t &p_closest_unsafe, PS3DT::ShapeRestInfo *r_info = nullptr) = 0;virtual bool collide_shape(const PS3DT::ShapeParameters &p_parameters, Vector3 *r_results, int p_result_max, int &r_result_count) = 0;diff --git a/servers/physics_3d/queries/physics_cast_motion_result_3d.cpp b/servers/physics_3d/queries/physics_cast_motion_result_3d.cppnew file mode 100644index 00000000000..533d1622818--- /dev/null+++ b/servers/physics_3d/queries/physics_cast_motion_result_3d.cpp@@ -0,0 +1,49 @@+/**************************************************************************/+/* physics_cast_motion_result_3d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_cast_motion_result_3d.h"++#include "core/object/class_db.h"++real_t PhysicsCastMotionResult3D::get_safe_fraction() const {+ return safe_fraction;+}++real_t PhysicsCastMotionResult3D::get_unsafe_fraction() const {+ return unsafe_fraction;+}++void PhysicsCastMotionResult3D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_safe_fraction"), &PhysicsCastMotionResult3D::get_safe_fraction);+ ClassDB::bind_method(D_METHOD("get_unsafe_fraction"), &PhysicsCastMotionResult3D::get_unsafe_fraction);++ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "safe_fraction"), "", "get_safe_fraction");+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "unsafe_fraction"), "", "get_unsafe_fraction");+}diff --git a/servers/physics_3d/queries/physics_cast_motion_result_3d.h b/servers/physics_3d/queries/physics_cast_motion_result_3d.hnew file mode 100644index 00000000000..9826c78a8d5--- /dev/null+++ b/servers/physics_3d/queries/physics_cast_motion_result_3d.h@@ -0,0 +1,49 @@+/**************************************************************************/+/* physics_cast_motion_result_3d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"++class PhysicsCastMotionResult3D : public RefCounted {+ GDCLASS(PhysicsCastMotionResult3D, RefCounted);++ friend class PhysicsDirectSpaceState3D;++ real_t safe_fraction = 1.0;+ real_t unsafe_fraction = 1.0;++protected:+ static void _bind_methods();++public:+ real_t get_safe_fraction() const;+ real_t get_unsafe_fraction() const;+};diff --git a/servers/physics_3d/queries/physics_collide_shape_result_3d.cpp b/servers/physics_3d/queries/physics_collide_shape_result_3d.cppnew file mode 100644index 00000000000..4601e0ab227--- /dev/null+++ b/servers/physics_3d/queries/physics_collide_shape_result_3d.cpp@@ -0,0 +1,72 @@+/**************************************************************************/+/* physics_collide_shape_result_3d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_collide_shape_result_3d.h"++#include "core/object/class_db.h"++PhysicsCollideShapeResult3D::PhysicsCollideShapeResult3D(int p_max_collisions) {+ ERR_FAIL_COND(p_max_collisions < 0);+ result.resize(2 * p_max_collisions);+}++int PhysicsCollideShapeResult3D::get_max_collisions() const {+ return result.size() / 2;+}++void PhysicsCollideShapeResult3D::set_max_collisions(int p_max_collisions) {+ ERR_FAIL_COND(p_max_collisions < 0);+ result.resize(2 * p_max_collisions);+ collision_count = MIN(collision_count, static_cast<int>(result.size() / 2));+}++int PhysicsCollideShapeResult3D::get_collision_count() const {+ return collision_count;+}++Vector3 PhysicsCollideShapeResult3D::get_point_on_queried_shape(int p_collision_index) const {+ ERR_FAIL_INDEX_V(p_collision_index, collision_count, Vector3());+ return result[2 * p_collision_index];+}++Vector3 PhysicsCollideShapeResult3D::get_point_on_colliding_shape(int p_collision_index) const {+ ERR_FAIL_INDEX_V(p_collision_index, collision_count, Vector3());+ return result[2 * p_collision_index + 1];+}++void PhysicsCollideShapeResult3D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_max_collisions"), &PhysicsCollideShapeResult3D::get_max_collisions);+ ClassDB::bind_method(D_METHOD("set_max_collisions", "max_collisions"), &PhysicsCollideShapeResult3D::set_max_collisions);+ ClassDB::bind_method(D_METHOD("get_collision_count"), &PhysicsCollideShapeResult3D::get_collision_count);+ ClassDB::bind_method(D_METHOD("get_point_on_queried_shape", "collision_index"), &PhysicsCollideShapeResult3D::get_point_on_queried_shape);+ ClassDB::bind_method(D_METHOD("get_point_on_colliding_shape", "collision_index"), &PhysicsCollideShapeResult3D::get_point_on_colliding_shape);++ ADD_PROPERTY(PropertyInfo(Variant::INT, "max_collisions"), "set_max_collisions", "get_max_collisions");+}diff --git a/servers/physics_3d/queries/physics_collide_shape_result_3d.h b/servers/physics_3d/queries/physics_collide_shape_result_3d.hnew file mode 100644index 00000000000..e74badec87e--- /dev/null+++ b/servers/physics_3d/queries/physics_collide_shape_result_3d.h@@ -0,0 +1,56 @@+/**************************************************************************/+/* physics_collide_shape_result_3d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"++class PhysicsCollideShapeResult3D : public RefCounted {+ GDCLASS(PhysicsCollideShapeResult3D, RefCounted);++ friend class PhysicsDirectSpaceState3D;++ LocalVector<Vector3> result;+ int collision_count = 0;++protected:+ static void _bind_methods();++public:+ PhysicsCollideShapeResult3D(int p_max_collisions = 32);++ int get_max_collisions() const;+ void set_max_collisions(int p_max_collisions);++ int get_collision_count() const;++ Vector3 get_point_on_queried_shape(int p_collision_index) const;+ Vector3 get_point_on_colliding_shape(int p_collision_index) const;+};diff --git a/servers/physics_3d/queries/physics_get_rest_info_result_3d.cpp b/servers/physics_3d/queries/physics_get_rest_info_result_3d.cppnew file mode 100644index 00000000000..924ab966dc2--- /dev/null+++ b/servers/physics_3d/queries/physics_get_rest_info_result_3d.cpp@@ -0,0 +1,73 @@+/**************************************************************************/+/* physics_get_rest_info_result_3d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_get_rest_info_result_3d.h"++#include "core/object/class_db.h"++Vector3 PhysicsGetRestInfoResult3D::get_point() const {+ return result.point;+}++Vector3 PhysicsGetRestInfoResult3D::get_normal() const {+ return result.normal;+}++RID PhysicsGetRestInfoResult3D::get_collider_rid() const {+ return result.rid;+}++ObjectID PhysicsGetRestInfoResult3D::get_collider_id() const {+ return result.collider_id;+}++int PhysicsGetRestInfoResult3D::get_collider_shape() const {+ return result.shape;+}++Vector3 PhysicsGetRestInfoResult3D::get_collider_velocity() const {+ return result.linear_velocity;+}++void PhysicsGetRestInfoResult3D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_point"), &PhysicsGetRestInfoResult3D::get_point);+ ClassDB::bind_method(D_METHOD("get_normal"), &PhysicsGetRestInfoResult3D::get_normal);+ ClassDB::bind_method(D_METHOD("get_collider_rid"), &PhysicsGetRestInfoResult3D::get_collider_rid);+ ClassDB::bind_method(D_METHOD("get_collider_id"), &PhysicsGetRestInfoResult3D::get_collider_id);+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &PhysicsGetRestInfoResult3D::get_collider_shape);+ ClassDB::bind_method(D_METHOD("get_collider_velocity"), &PhysicsGetRestInfoResult3D::get_collider_velocity);++ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "point"), "", "get_point");+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "normal"), "", "get_normal");+ ADD_PROPERTY(PropertyInfo(Variant::RID, "collider_rid"), "", "get_collider_rid");+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape"), "", "get_collider_shape");+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "collider_velocity"), "", "get_collider_velocity");+}diff --git a/servers/physics_3d/queries/physics_get_rest_info_result_3d.h b/servers/physics_3d/queries/physics_get_rest_info_result_3d.hnew file mode 100644index 00000000000..03737827ae7--- /dev/null+++ b/servers/physics_3d/queries/physics_get_rest_info_result_3d.h@@ -0,0 +1,53 @@+/**************************************************************************/+/* physics_get_rest_info_result_3d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"+#include "servers/physics_3d/physics_server_3d_types.h"++class PhysicsGetRestInfoResult3D : public RefCounted {+ GDCLASS(PhysicsGetRestInfoResult3D, RefCounted);++ friend class PhysicsDirectSpaceState3D;++ PS3DT::ShapeRestInfo result;++protected:+ static void _bind_methods();++public:+ Vector3 get_point() const;+ Vector3 get_normal() const;+ RID get_collider_rid() const;+ ObjectID get_collider_id() const;+ int get_collider_shape() const;+ Vector3 get_collider_velocity() const;+};diff --git a/servers/physics_3d/queries/physics_intersect_point_result_3d.cpp b/servers/physics_3d/queries/physics_intersect_point_result_3d.cppnew file mode 100644index 00000000000..8fcb5825771--- /dev/null+++ b/servers/physics_3d/queries/physics_intersect_point_result_3d.cpp@@ -0,0 +1,84 @@+/**************************************************************************/+/* physics_intersect_point_result_3d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_intersect_point_result_3d.h"++#include "core/object/class_db.h"++PhysicsIntersectPointResult3D::PhysicsIntersectPointResult3D(int p_max_intersections) {+ ERR_FAIL_COND(p_max_intersections < 0);+ result.resize(p_max_intersections);+}++int PhysicsIntersectPointResult3D::get_max_intersections() const {+ return result.size();+}++void PhysicsIntersectPointResult3D::set_max_intersections(int p_max_intersections) {+ ERR_FAIL_COND(p_max_intersections < 0);+ result.resize(p_max_intersections);+ intersection_count = MIN(intersection_count, static_cast<int>(result.size()));+}++int PhysicsIntersectPointResult3D::get_intersection_count() const {+ return intersection_count;+}++RID PhysicsIntersectPointResult3D::get_collider_rid(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, RID());+ return result[p_intersection_index].rid;+}++ObjectID PhysicsIntersectPointResult3D::get_collider_id(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, ObjectID());+ return result[p_intersection_index].collider_id;+}++Object *PhysicsIntersectPointResult3D::get_collider(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, nullptr);+ return result[p_intersection_index].get_collider();+}++int PhysicsIntersectPointResult3D::get_collider_shape(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, 0);+ return result[p_intersection_index].shape;+}++void PhysicsIntersectPointResult3D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_max_intersections"), &PhysicsIntersectPointResult3D::get_max_intersections);+ ClassDB::bind_method(D_METHOD("set_max_intersections", "max_intersections"), &PhysicsIntersectPointResult3D::set_max_intersections);+ ClassDB::bind_method(D_METHOD("get_intersection_count"), &PhysicsIntersectPointResult3D::get_intersection_count);+ ClassDB::bind_method(D_METHOD("get_collider_id", "intersection_index"), &PhysicsIntersectPointResult3D::get_collider_id);+ ClassDB::bind_method(D_METHOD("get_collider_rid", "intersection_index"), &PhysicsIntersectPointResult3D::get_collider_rid);+ ClassDB::bind_method(D_METHOD("get_collider", "intersection_index"), &PhysicsIntersectPointResult3D::get_collider);+ ClassDB::bind_method(D_METHOD("get_collider_shape", "intersection_index"), &PhysicsIntersectPointResult3D::get_collider_shape);++ ADD_PROPERTY(PropertyInfo(Variant::INT, "max_intersections"), "set_max_intersections", "get_max_intersections");+}diff --git a/servers/physics_3d/queries/physics_intersect_point_result_3d.h b/servers/physics_3d/queries/physics_intersect_point_result_3d.hnew file mode 100644index 00000000000..b8bf2df1600--- /dev/null+++ b/servers/physics_3d/queries/physics_intersect_point_result_3d.h@@ -0,0 +1,59 @@+/**************************************************************************/+/* physics_intersect_point_result_3d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"+#include "servers/physics_3d/physics_server_3d_types.h"++class PhysicsIntersectPointResult3D : public RefCounted {+ GDCLASS(PhysicsIntersectPointResult3D, RefCounted);++ friend class PhysicsDirectSpaceState3D;++ LocalVector<PS3DT::ShapeResult> result;+ int intersection_count = 0;++protected:+ static void _bind_methods();++public:+ PhysicsIntersectPointResult3D(int p_max_intersections = 32);++ int get_max_intersections() const;+ void set_max_intersections(int p_max_intersections);++ int get_intersection_count() const;++ RID get_collider_rid(int p_intersection_index) const;+ ObjectID get_collider_id(int p_intersection_index) const;+ Object *get_collider(int p_intersection_index) const;+ int get_collider_shape(int p_intersection_index) const;+};diff --git a/servers/physics_3d/queries/physics_intersect_ray_result_3d.cpp b/servers/physics_3d/queries/physics_intersect_ray_result_3d.cppnew file mode 100644index 00000000000..70cff918aff--- /dev/null+++ b/servers/physics_3d/queries/physics_intersect_ray_result_3d.cpp@@ -0,0 +1,79 @@+/**************************************************************************/+/* physics_intersect_ray_result_3d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_intersect_ray_result_3d.h"++#include "core/object/class_db.h"++Vector3 PhysicsIntersectRayResult3D::get_position() const {+ return result.position;+}++Vector3 PhysicsIntersectRayResult3D::get_normal() const {+ return result.normal;+}++RID PhysicsIntersectRayResult3D::get_collider_rid() const {+ return result.rid;+}++ObjectID PhysicsIntersectRayResult3D::get_collider_id() const {+ return result.collider_id;+}++Object *PhysicsIntersectRayResult3D::get_collider() const {+ return result.get_collider();+}++int PhysicsIntersectRayResult3D::get_collider_shape() const {+ return result.shape;+}++int PhysicsIntersectRayResult3D::get_collider_face_index() const {+ return result.face_index;+}++void PhysicsIntersectRayResult3D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_position"), &PhysicsIntersectRayResult3D::get_position);+ ClassDB::bind_method(D_METHOD("get_normal"), &PhysicsIntersectRayResult3D::get_normal);+ ClassDB::bind_method(D_METHOD("get_collider_rid"), &PhysicsIntersectRayResult3D::get_collider_rid);+ ClassDB::bind_method(D_METHOD("get_collider_id"), &PhysicsIntersectRayResult3D::get_collider_id);+ ClassDB::bind_method(D_METHOD("get_collider"), &PhysicsIntersectRayResult3D::get_collider);+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &PhysicsIntersectRayResult3D::get_collider_shape);+ ClassDB::bind_method(D_METHOD("get_collider_face_index"), &PhysicsIntersectRayResult3D::get_collider_face_index);++ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "", "get_position");+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "normal"), "", "get_normal");+ ADD_PROPERTY(PropertyInfo(Variant::RID, "collider_rid"), "", "get_collider_rid");+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider");+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape"), "", "get_collider_shape");+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_face_index"), "", "get_collider_face_index");+}diff --git a/servers/physics_3d/queries/physics_intersect_ray_result_3d.h b/servers/physics_3d/queries/physics_intersect_ray_result_3d.hnew file mode 100644index 00000000000..1d2935fd4f1--- /dev/null+++ b/servers/physics_3d/queries/physics_intersect_ray_result_3d.h@@ -0,0 +1,54 @@+/**************************************************************************/+/* physics_intersect_ray_result_3d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"+#include "servers/physics_3d/physics_server_3d_types.h"++class PhysicsIntersectRayResult3D : public RefCounted {+ GDCLASS(PhysicsIntersectRayResult3D, RefCounted);++ friend class PhysicsDirectSpaceState3D;++ PS3DT::RayResult result;++protected:+ static void _bind_methods();++public:+ Vector3 get_position() const;+ Vector3 get_normal() const;+ RID get_collider_rid() const;+ ObjectID get_collider_id() const;+ Object *get_collider() const;+ int get_collider_shape() const;+ int get_collider_face_index() const;+};diff --git a/servers/physics_3d/queries/physics_intersect_shape_result_3d.cpp b/servers/physics_3d/queries/physics_intersect_shape_result_3d.cppnew file mode 100644index 00000000000..2fe62d23c72--- /dev/null+++ b/servers/physics_3d/queries/physics_intersect_shape_result_3d.cpp@@ -0,0 +1,84 @@+/**************************************************************************/+/* physics_intersect_shape_result_3d.cpp */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#include "physics_intersect_shape_result_3d.h"++#include "core/object/class_db.h"++PhysicsIntersectShapeResult3D::PhysicsIntersectShapeResult3D(int p_max_intersections) {+ ERR_FAIL_COND(p_max_intersections < 0);+ result.resize(p_max_intersections);+}++int PhysicsIntersectShapeResult3D::get_max_intersections() const {+ return result.size();+}++void PhysicsIntersectShapeResult3D::set_max_intersections(int p_max_intersections) {+ ERR_FAIL_COND(p_max_intersections < 0);+ result.resize(p_max_intersections);+ intersection_count = MIN(intersection_count, static_cast<int>(result.size()));+}++int PhysicsIntersectShapeResult3D::get_intersection_count() const {+ return intersection_count;+}++RID PhysicsIntersectShapeResult3D::get_collider_rid(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, RID());+ return result[p_intersection_index].rid;+}++ObjectID PhysicsIntersectShapeResult3D::get_collider_id(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, ObjectID());+ return result[p_intersection_index].collider_id;+}++Object *PhysicsIntersectShapeResult3D::get_collider(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, nullptr);+ return result[p_intersection_index].get_collider();+}++int PhysicsIntersectShapeResult3D::get_collider_shape(int p_intersection_index) const {+ ERR_FAIL_INDEX_V(p_intersection_index, intersection_count, 0);+ return result[p_intersection_index].shape;+}++void PhysicsIntersectShapeResult3D::_bind_methods() {+ ClassDB::bind_method(D_METHOD("get_max_intersections"), &PhysicsIntersectShapeResult3D::get_max_intersections);+ ClassDB::bind_method(D_METHOD("set_max_intersections", "max_intersections"), &PhysicsIntersectShapeResult3D::set_max_intersections);+ ClassDB::bind_method(D_METHOD("get_intersection_count"), &PhysicsIntersectShapeResult3D::get_intersection_count);+ ClassDB::bind_method(D_METHOD("get_collider_id", "intersection_index"), &PhysicsIntersectShapeResult3D::get_collider_id);+ ClassDB::bind_method(D_METHOD("get_collider_rid", "intersection_index"), &PhysicsIntersectShapeResult3D::get_collider_rid);+ ClassDB::bind_method(D_METHOD("get_collider", "intersection_index"), &PhysicsIntersectShapeResult3D::get_collider);+ ClassDB::bind_method(D_METHOD("get_collider_shape", "intersection_index"), &PhysicsIntersectShapeResult3D::get_collider_shape);++ ADD_PROPERTY(PropertyInfo(Variant::INT, "max_intersections"), "set_max_intersections", "get_max_intersections");+}diff --git a/servers/physics_3d/queries/physics_intersect_shape_result_3d.h b/servers/physics_3d/queries/physics_intersect_shape_result_3d.hnew file mode 100644index 00000000000..06ef4aafd04--- /dev/null+++ b/servers/physics_3d/queries/physics_intersect_shape_result_3d.h@@ -0,0 +1,59 @@+/**************************************************************************/+/* physics_intersect_shape_result_3d.h */+/**************************************************************************/+/* This file is part of: */+/* GODOT ENGINE */+/* https://godotengine.org */+/**************************************************************************/+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */+/* */+/* Permission is hereby granted, free of charge, to any person obtaining */+/* a copy of this software and associated documentation files (the */+/* "Software"), to deal in the Software without restriction, including */+/* without limitation the rights to use, copy, modify, merge, publish, */+/* distribute, sublicense, and/or sell copies of the Software, and to */+/* permit persons to whom the Software is furnished to do so, subject to */+/* the following conditions: */+/* */+/* The above copyright notice and this permission notice shall be */+/* included in all copies or substantial portions of the Software. */+/* */+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */+/**************************************************************************/++#pragma once++#include "core/object/ref_counted.h"+#include "servers/physics_3d/physics_server_3d_types.h"++class PhysicsIntersectShapeResult3D : public RefCounted {+ GDCLASS(PhysicsIntersectShapeResult3D, RefCounted);++ friend class PhysicsDirectSpaceState3D;++ LocalVector<PS3DT::ShapeResult> result;+ int intersection_count = 0;++protected:+ static void _bind_methods();++public:+ PhysicsIntersectShapeResult3D(int p_max_intersections = 32);++ int get_max_intersections() const;+ void set_max_intersections(int p_max_intersections);++ int get_intersection_count() const;++ RID get_collider_rid(int p_intersection_index) const;+ ObjectID get_collider_id(int p_intersection_index) const;+ Object *get_collider(int p_intersection_index) const;+ int get_collider_shape(int p_intersection_index) const;+};diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cppindex e3ff56c1f48..49ecf7222df 100644--- a/servers/register_server_types.cpp+++ b/servers/register_server_types.cpp@@ -308,8 +308,14 @@ void register_server_types() {GDREGISTER_NATIVE_STRUCT(PhysicsServer2DExtensionMotionResult, "Vector2 travel;Vector2 remainder;Vector2 collision_point;Vector2 collision_normal;Vector2 collider_velocity;real_t collision_depth;real_t collision_safe_fraction;real_t collision_unsafe_fraction;int collision_local_shape;ObjectID collider_id;RID collider;int collider_shape");GDREGISTER_CLASS(PhysicsRayQueryParameters2D);+ GDREGISTER_CLASS(PhysicsIntersectRayResult2D);GDREGISTER_CLASS(PhysicsPointQueryParameters2D);+ GDREGISTER_CLASS(PhysicsIntersectPointResult2D);GDREGISTER_CLASS(PhysicsShapeQueryParameters2D);+ GDREGISTER_CLASS(PhysicsIntersectShapeResult2D);+ GDREGISTER_CLASS(PhysicsCastMotionResult2D);+ GDREGISTER_CLASS(PhysicsCollideShapeResult2D);+ GDREGISTER_CLASS(PhysicsGetRestInfoResult2D);GDREGISTER_CLASS(PhysicsTestMotionParameters2D);GDREGISTER_CLASS(PhysicsTestMotionResult2D);@@ -351,8 +357,14 @@ void register_server_types() {GDREGISTER_NATIVE_STRUCT(PhysicsServer3DExtensionMotionResult, "Vector3 travel;Vector3 remainder;real_t collision_depth;real_t collision_safe_fraction;real_t collision_unsafe_fraction;PhysicsServer3DExtensionMotionCollision collisions[32];int collision_count");GDREGISTER_CLASS(PhysicsRayQueryParameters3D);+ GDREGISTER_CLASS(PhysicsIntersectRayResult3D);GDREGISTER_CLASS(PhysicsPointQueryParameters3D);+ GDREGISTER_CLASS(PhysicsIntersectPointResult3D);GDREGISTER_CLASS(PhysicsShapeQueryParameters3D);+ GDREGISTER_CLASS(PhysicsIntersectShapeResult3D);+ GDREGISTER_CLASS(PhysicsCastMotionResult3D);+ GDREGISTER_CLASS(PhysicsCollideShapeResult3D);+ GDREGISTER_CLASS(PhysicsGetRestInfoResult3D);GDREGISTER_CLASS(PhysicsTestMotionParameters3D);GDREGISTER_CLASS(PhysicsTestMotionResult3D);