:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/TriangleMesh.xml. .. _class_TriangleMesh: TriangleMesh ============ **Inherits:** :ref:`RefCounted` **<** :ref:`Object` Triangle geometry for efficient, physicsless intersection queries. .. rst-class:: classref-introduction-group Description ----------- Creates a bounding volume hierarchy (BVH) tree structure around triangle geometry. The triangle BVH tree can be used for efficient intersection queries without involving a physics engine. For example, this can be used in editor tools to select objects with complex shapes based on the mouse cursor position. \ **Performance:** Creating the BVH tree for complex geometry is a slow process and best done in a background thread. .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`create_from_faces`\ (\ faces\: :ref:`PackedVector3Array`\ ) | +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedVector3Array` | :ref:`get_faces`\ (\ ) |const| | +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Dictionary` | :ref:`intersect_ray`\ (\ begin\: :ref:`Vector3`, dir\: :ref:`Vector3`\ ) |const| | +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Dictionary` | :ref:`intersect_segment`\ (\ begin\: :ref:`Vector3`, end\: :ref:`Vector3`\ ) |const| | +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_TriangleMesh_method_create_from_faces: .. rst-class:: classref-method :ref:`bool` **create_from_faces**\ (\ faces\: :ref:`PackedVector3Array`\ ) :ref:`🔗` Creates the BVH tree from an array of faces. Each 3 vertices of the input ``faces`` array represent one triangle (face). Returns ``true`` if the tree is successfully built, ``false`` otherwise. .. rst-class:: classref-item-separator ---- .. _class_TriangleMesh_method_get_faces: .. rst-class:: classref-method :ref:`PackedVector3Array` **get_faces**\ (\ ) |const| :ref:`🔗` Returns a copy of the geometry faces. Each 3 vertices of the array represent one triangle (face). .. rst-class:: classref-item-separator ---- .. _class_TriangleMesh_method_intersect_ray: .. rst-class:: classref-method :ref:`Dictionary` **intersect_ray**\ (\ begin\: :ref:`Vector3`, dir\: :ref:`Vector3`\ ) |const| :ref:`🔗` Tests for intersection with a ray starting at ``begin`` and facing ``dir`` and extending toward infinity. If an intersection with a triangle happens, returns a :ref:`Dictionary` with the following fields: \ ``position``: The position on the intersected triangle. \ ``normal``: The normal of the intersected triangle. \ ``face_index``: The index of the intersected triangle. Returns an empty :ref:`Dictionary` if no intersection happens. See also :ref:`intersect_segment()`, which is similar but uses a finite-length segment. .. rst-class:: classref-item-separator ---- .. _class_TriangleMesh_method_intersect_segment: .. rst-class:: classref-method :ref:`Dictionary` **intersect_segment**\ (\ begin\: :ref:`Vector3`, end\: :ref:`Vector3`\ ) |const| :ref:`🔗` Tests for intersection with a segment going from ``begin`` to ``end``. If an intersection with a triangle happens returns a :ref:`Dictionary` with the following fields: \ ``position``: The position on the intersected triangle. \ ``normal``: The normal of the intersected triangle. \ ``face_index``: The index of the intersected triangle. Returns an empty :ref:`Dictionary` if no intersection happens. See also :ref:`intersect_ray()`, which is similar but uses an infinite-length ray. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`