class_trianglemesh.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/TriangleMesh.xml.
  6. .. _class_TriangleMesh:
  7. TriangleMesh
  8. ============
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Triangle geometry for efficient, physicsless intersection queries.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Creates a bounding volume hierarchy (BVH) tree structure around triangle geometry.
  15. The triangle BVH tree can be used for efficient intersection queries without involving a physics engine.
  16. For example, this can be used in editor tools to select objects with complex shapes based on the mouse cursor position.
  17. \ **Performance:** Creating the BVH tree for complex geometry is a slow process and best done in a background thread.
  18. .. rst-class:: classref-reftable-group
  19. Methods
  20. -------
  21. .. table::
  22. :widths: auto
  23. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`create_from_faces<class_TriangleMesh_method_create_from_faces>`\ (\ faces\: :ref:`PackedVector3Array<class_PackedVector3Array>`\ ) |
  25. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`PackedVector3Array<class_PackedVector3Array>` | :ref:`get_faces<class_TriangleMesh_method_get_faces>`\ (\ ) |const| |
  27. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Dictionary<class_Dictionary>` | :ref:`intersect_ray<class_TriangleMesh_method_intersect_ray>`\ (\ begin\: :ref:`Vector3<class_Vector3>`, dir\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  29. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Dictionary<class_Dictionary>` | :ref:`intersect_segment<class_TriangleMesh_method_intersect_segment>`\ (\ begin\: :ref:`Vector3<class_Vector3>`, end\: :ref:`Vector3<class_Vector3>`\ ) |const| |
  31. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. .. rst-class:: classref-section-separator
  33. ----
  34. .. rst-class:: classref-descriptions-group
  35. Method Descriptions
  36. -------------------
  37. .. _class_TriangleMesh_method_create_from_faces:
  38. .. rst-class:: classref-method
  39. :ref:`bool<class_bool>` **create_from_faces**\ (\ faces\: :ref:`PackedVector3Array<class_PackedVector3Array>`\ ) :ref:`🔗<class_TriangleMesh_method_create_from_faces>`
  40. Creates the BVH tree from an array of faces. Each 3 vertices of the input ``faces`` array represent one triangle (face).
  41. Returns ``true`` if the tree is successfully built, ``false`` otherwise.
  42. .. rst-class:: classref-item-separator
  43. ----
  44. .. _class_TriangleMesh_method_get_faces:
  45. .. rst-class:: classref-method
  46. :ref:`PackedVector3Array<class_PackedVector3Array>` **get_faces**\ (\ ) |const| :ref:`🔗<class_TriangleMesh_method_get_faces>`
  47. Returns a copy of the geometry faces. Each 3 vertices of the array represent one triangle (face).
  48. .. rst-class:: classref-item-separator
  49. ----
  50. .. _class_TriangleMesh_method_intersect_ray:
  51. .. rst-class:: classref-method
  52. :ref:`Dictionary<class_Dictionary>` **intersect_ray**\ (\ begin\: :ref:`Vector3<class_Vector3>`, dir\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_TriangleMesh_method_intersect_ray>`
  53. Tests for intersection with a ray starting at ``begin`` and facing ``dir`` and extending toward infinity.
  54. If an intersection with a triangle happens, returns a :ref:`Dictionary<class_Dictionary>` with the following fields:
  55. \ ``position``: The position on the intersected triangle.
  56. \ ``normal``: The normal of the intersected triangle.
  57. \ ``face_index``: The index of the intersected triangle.
  58. Returns an empty :ref:`Dictionary<class_Dictionary>` if no intersection happens.
  59. See also :ref:`intersect_segment()<class_TriangleMesh_method_intersect_segment>`, which is similar but uses a finite-length segment.
  60. .. rst-class:: classref-item-separator
  61. ----
  62. .. _class_TriangleMesh_method_intersect_segment:
  63. .. rst-class:: classref-method
  64. :ref:`Dictionary<class_Dictionary>` **intersect_segment**\ (\ begin\: :ref:`Vector3<class_Vector3>`, end\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_TriangleMesh_method_intersect_segment>`
  65. Tests for intersection with a segment going from ``begin`` to ``end``.
  66. If an intersection with a triangle happens returns a :ref:`Dictionary<class_Dictionary>` with the following fields:
  67. \ ``position``: The position on the intersected triangle.
  68. \ ``normal``: The normal of the intersected triangle.
  69. \ ``face_index``: The index of the intersected triangle.
  70. Returns an empty :ref:`Dictionary<class_Dictionary>` if no intersection happens.
  71. See also :ref:`intersect_ray()<class_TriangleMesh_method_intersect_ray>`, which is similar but uses an infinite-length ray.
  72. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  73. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  74. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  75. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  76. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  77. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  78. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  79. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  80. .. |void| replace:: :abbr:`void (No return value.)`