mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 20:06:49 +01:00
b574b0371d
Expand on the format of the output array for collide_and_get_contacts and collide_with_motion_and_get_contacts, and describe how the contact point pairs can be used to calculate collision normals and depths. (cherry picked from commit bdf086c781f2f5d1bf5f4f11f0b29a94a629a0ec)
78 lines
4.9 KiB
XML
78 lines
4.9 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="Shape2D" inherits="Resource" version="3.5">
|
|
<brief_description>
|
|
Base class for all 2D shapes.
|
|
</brief_description>
|
|
<description>
|
|
Base class for all 2D shapes. All 2D shape types inherit from this.
|
|
</description>
|
|
<tutorials>
|
|
<link>$DOCS_URL/tutorials/physics/physics_introduction.html</link>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="collide">
|
|
<return type="bool" />
|
|
<argument index="0" name="local_xform" type="Transform2D" />
|
|
<argument index="1" name="with_shape" type="Shape2D" />
|
|
<argument index="2" name="shape_xform" type="Transform2D" />
|
|
<description>
|
|
Returns [code]true[/code] if this shape is colliding with another.
|
|
This method needs the transformation matrix for this shape ([code]local_xform[/code]), the shape to check collisions with ([code]with_shape[/code]), and the transformation matrix of that shape ([code]shape_xform[/code]).
|
|
</description>
|
|
</method>
|
|
<method name="collide_and_get_contacts">
|
|
<return type="Array" />
|
|
<argument index="0" name="local_xform" type="Transform2D" />
|
|
<argument index="1" name="with_shape" type="Shape2D" />
|
|
<argument index="2" name="shape_xform" type="Transform2D" />
|
|
<description>
|
|
Returns a list of contact point pairs where this shape touches another.
|
|
If there are no collisions, the returned list is empty. Otherwise, the returned list contains contact points arranged in pairs, with entries alternating between points on the boundary of this shape and points on the boundary of [code]with_shape[/code].
|
|
A collision pair A, B can be used to calculate the collision normal with [code](B - A).normalized()[/code], and the collision depth with [code](B - A).length()[/code]. This information is typically used to separate shapes, particularly in collision solvers.
|
|
This method needs the transformation matrix for this shape ([code]local_xform[/code]), the shape to check collisions with ([code]with_shape[/code]), and the transformation matrix of that shape ([code]shape_xform[/code]).
|
|
</description>
|
|
</method>
|
|
<method name="collide_with_motion">
|
|
<return type="bool" />
|
|
<argument index="0" name="local_xform" type="Transform2D" />
|
|
<argument index="1" name="local_motion" type="Vector2" />
|
|
<argument index="2" name="with_shape" type="Shape2D" />
|
|
<argument index="3" name="shape_xform" type="Transform2D" />
|
|
<argument index="4" name="shape_motion" type="Vector2" />
|
|
<description>
|
|
Returns whether this shape would collide with another, if a given movement was applied.
|
|
This method needs the transformation matrix for this shape ([code]local_xform[/code]), the movement to test on this shape ([code]local_motion[/code]), the shape to check collisions with ([code]with_shape[/code]), the transformation matrix of that shape ([code]shape_xform[/code]), and the movement to test onto the other object ([code]shape_motion[/code]).
|
|
</description>
|
|
</method>
|
|
<method name="collide_with_motion_and_get_contacts">
|
|
<return type="Array" />
|
|
<argument index="0" name="local_xform" type="Transform2D" />
|
|
<argument index="1" name="local_motion" type="Vector2" />
|
|
<argument index="2" name="with_shape" type="Shape2D" />
|
|
<argument index="3" name="shape_xform" type="Transform2D" />
|
|
<argument index="4" name="shape_motion" type="Vector2" />
|
|
<description>
|
|
Returns a list of contact point pairs where this shape would touch another, if a given movement was applied.
|
|
If there would be no collisions, the returned list is empty. Otherwise, the returned list contains contact points arranged in pairs, with entries alternating between points on the boundary of this shape and points on the boundary of [code]with_shape[/code].
|
|
A collision pair A, B can be used to calculate the collision normal with [code](B - A).normalized()[/code], and the collision depth with [code](B - A).length()[/code]. This information is typically used to separate shapes, particularly in collision solvers.
|
|
This method needs the transformation matrix for this shape ([code]local_xform[/code]), the movement to test on this shape ([code]local_motion[/code]), the shape to check collisions with ([code]with_shape[/code]), the transformation matrix of that shape ([code]shape_xform[/code]), and the movement to test onto the other object ([code]shape_motion[/code]).
|
|
</description>
|
|
</method>
|
|
<method name="draw">
|
|
<return type="void" />
|
|
<argument index="0" name="canvas_item" type="RID" />
|
|
<argument index="1" name="color" type="Color" />
|
|
<description>
|
|
Draws a solid shape onto a [CanvasItem] with the [VisualServer] API filled with the specified [code]color[/code]. The exact drawing method is specific for each shape and cannot be configured.
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<members>
|
|
<member name="custom_solver_bias" type="float" setter="set_custom_solver_bias" getter="get_custom_solver_bias" default="0.0">
|
|
The shape's custom solver bias.
|
|
</member>
|
|
</members>
|
|
<constants>
|
|
</constants>
|
|
</class>
|