mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
classref: Sync with current master branch (215acd5)
This commit is contained in:
@@ -12,14 +12,117 @@ TriangleMesh
|
||||
|
||||
**Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
|
||||
|
||||
Internal mesh type.
|
||||
Triangle geometry for efficient, physicsless intersection queries.
|
||||
|
||||
.. rst-class:: classref-introduction-group
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Mesh type used internally for collision calculations.
|
||||
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<class_bool>` | :ref:`create_from_faces<class_TriangleMesh_method_create_from_faces>`\ (\ faces\: :ref:`PackedVector3Array<class_PackedVector3Array>`\ ) |
|
||||
+-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`PackedVector3Array<class_PackedVector3Array>` | :ref:`get_faces<class_TriangleMesh_method_get_faces>`\ (\ ) |const| |
|
||||
+-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`intersect_ray<class_TriangleMesh_method_intersect_ray>`\ (\ begin\: :ref:`Vector3<class_Vector3>`, dir\: :ref:`Vector3<class_Vector3>`\ ) |const| |
|
||||
+-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| :ref:`Dictionary<class_Dictionary>` | :ref:`intersect_segment<class_TriangleMesh_method_intersect_segment>`\ (\ begin\: :ref:`Vector3<class_Vector3>`, end\: :ref:`Vector3<class_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<class_bool>` **create_from_faces**\ (\ faces\: :ref:`PackedVector3Array<class_PackedVector3Array>`\ ) :ref:`🔗<class_TriangleMesh_method_create_from_faces>`
|
||||
|
||||
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<class_PackedVector3Array>` **get_faces**\ (\ ) |const| :ref:`🔗<class_TriangleMesh_method_get_faces>`
|
||||
|
||||
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<class_Dictionary>` **intersect_ray**\ (\ begin\: :ref:`Vector3<class_Vector3>`, dir\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_TriangleMesh_method_intersect_ray>`
|
||||
|
||||
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<class_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<class_Dictionary>` if no intersection happens.
|
||||
|
||||
See also :ref:`intersect_segment()<class_TriangleMesh_method_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<class_Dictionary>` **intersect_segment**\ (\ begin\: :ref:`Vector3<class_Vector3>`, end\: :ref:`Vector3<class_Vector3>`\ ) |const| :ref:`🔗<class_TriangleMesh_method_intersect_segment>`
|
||||
|
||||
Tests for intersection with a segment going from ``begin`` to ``end``.
|
||||
|
||||
If an intersection with a triangle happens returns a :ref:`Dictionary<class_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<class_Dictionary>` if no intersection happens.
|
||||
|
||||
See also :ref:`intersect_ray()<class_TriangleMesh_method_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.)`
|
||||
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
||||
|
||||
Reference in New Issue
Block a user