class_concavepolygonshape3d.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/ConcavePolygonShape3D.xml.
  6. .. _class_ConcavePolygonShape3D:
  7. ConcavePolygonShape3D
  8. =====================
  9. **Inherits:** :ref:`Shape3D<class_Shape3D>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Concave polygon shape resource (also called "trimesh") for 3D physics.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 3D concave polygon shape resource (also called "trimesh") to be added as a *direct* child of a :ref:`PhysicsBody3D<class_PhysicsBody3D>` or :ref:`Area3D<class_Area3D>` using a :ref:`CollisionShape3D<class_CollisionShape3D>` node.
  15. The shape consists of a collection of triangle faces, and as such it does not include any "inside" that the faces might be enclosing. If the faces enclose anything, then the shape is *hollow*, as opposed to a :ref:`ConvexPolygonShape3D<class_ConvexPolygonShape3D>` which is solid. See also :ref:`CollisionPolygon3D<class_CollisionPolygon3D>`.
  16. Being made out of triangle faces, this shape is the most freely configurable single 3D shape. Despite its name, it can be used to form (hollow) polyhedra of any nature, convex or concave.
  17. \ **Note:** When used for collision, **ConcavePolygonShape3D** is intended to work with static :ref:`PhysicsBody3D<class_PhysicsBody3D>` nodes like :ref:`StaticBody3D<class_StaticBody3D>` and will not work with :ref:`CharacterBody3D<class_CharacterBody3D>` or :ref:`RigidBody3D<class_RigidBody3D>` in a mode other than Static.
  18. \ **Warning:** The nature of this shape makes it extra prone to being tunneled through by (small) fast physics bodies. For example, consider a (small) rigid body *Ball* traveling toward a static body *Box* at high speed. If the box uses a **ConcavePolygonShape3D** consisting of twelve triangle faces (two triangle faces for each of the six sides of the box), then the ball might end up inside the box or tunnel all the way through the box, if it goes fast enough. This is (partly) because the ball can only collide against the individual faces of the hollow box. In interactions with rigid bodies tunneling can be avoided by enabling continuous collision detection on the rigid body.
  19. \ **Warning:** Using this shape for an :ref:`Area3D<class_Area3D>` (via a :ref:`CollisionShape3D<class_CollisionShape3D>` node, created e.g. by using the *Create Trimesh Collision Sibling* option in the *Mesh* menu that appears when selecting a :ref:`MeshInstance3D<class_MeshInstance3D>` node) may give unexpected results: the area will only detect collisions with the triangle faces in the **ConcavePolygonShape3D** (and not with any "inside" of the shape, for example); moreover it will only detect all such collisions if :ref:`backface_collision<class_ConcavePolygonShape3D_property_backface_collision>` is ``true``.
  20. \ **Performance:** Due to its complexity, **ConcavePolygonShape3D** is the slowest collision shape to check collisions against. Its use should generally be limited to level geometry. For convex geometry, using :ref:`ConvexPolygonShape3D<class_ConvexPolygonShape3D>` will perform better. For dynamic physics bodies that need concave collision, several :ref:`ConvexPolygonShape3D<class_ConvexPolygonShape3D>`\ s can be used to represent its collision by using convex decomposition; see :ref:`ConvexPolygonShape3D<class_ConvexPolygonShape3D>`'s documentation for instructions. However, consider using primitive collision shapes such as :ref:`SphereShape3D<class_SphereShape3D>` or :ref:`BoxShape3D<class_BoxShape3D>` first.
  21. .. rst-class:: classref-introduction-group
  22. Tutorials
  23. ---------
  24. - `3D Physics Tests Demo <https://godotengine.org/asset-library/asset/675>`__
  25. .. rst-class:: classref-reftable-group
  26. Properties
  27. ----------
  28. .. table::
  29. :widths: auto
  30. +-------------------------+------------------------------------------------------------------------------------+-----------+
  31. | :ref:`bool<class_bool>` | :ref:`backface_collision<class_ConcavePolygonShape3D_property_backface_collision>` | ``false`` |
  32. +-------------------------+------------------------------------------------------------------------------------+-----------+
  33. .. rst-class:: classref-reftable-group
  34. Methods
  35. -------
  36. .. table::
  37. :widths: auto
  38. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`PackedVector3Array<class_PackedVector3Array>` | :ref:`get_faces<class_ConcavePolygonShape3D_method_get_faces>` **(** **)** |const| |
  40. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_faces<class_ConcavePolygonShape3D_method_set_faces>` **(** :ref:`PackedVector3Array<class_PackedVector3Array>` faces **)** |
  42. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  43. .. rst-class:: classref-section-separator
  44. ----
  45. .. rst-class:: classref-descriptions-group
  46. Property Descriptions
  47. ---------------------
  48. .. _class_ConcavePolygonShape3D_property_backface_collision:
  49. .. rst-class:: classref-property
  50. :ref:`bool<class_bool>` **backface_collision** = ``false``
  51. .. rst-class:: classref-property-setget
  52. - void **set_backface_collision_enabled** **(** :ref:`bool<class_bool>` value **)**
  53. - :ref:`bool<class_bool>` **is_backface_collision_enabled** **(** **)**
  54. If set to ``true``, collisions occur on both sides of the concave shape faces. Otherwise they occur only along the face normals.
  55. .. rst-class:: classref-section-separator
  56. ----
  57. .. rst-class:: classref-descriptions-group
  58. Method Descriptions
  59. -------------------
  60. .. _class_ConcavePolygonShape3D_method_get_faces:
  61. .. rst-class:: classref-method
  62. :ref:`PackedVector3Array<class_PackedVector3Array>` **get_faces** **(** **)** |const|
  63. Returns the faces of the trimesh shape as an array of vertices. The array (of length divisible by three) is naturally divided into triples; each triple of vertices defines a triangle.
  64. .. rst-class:: classref-item-separator
  65. ----
  66. .. _class_ConcavePolygonShape3D_method_set_faces:
  67. .. rst-class:: classref-method
  68. void **set_faces** **(** :ref:`PackedVector3Array<class_PackedVector3Array>` faces **)**
  69. Sets the faces of the trimesh shape from an array of vertices. The ``faces`` array should be composed of triples such that each triple of vertices defines a triangle.
  70. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  71. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  72. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  73. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  74. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  75. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`