Skip to content
0.2.0-dev Download ZIP
58 lines ·3.0 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="TriangleMesh" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Triangle geometry for efficient, physicsless intersection queries.
5 </brief_description>
6 <description>
7 Creates a bounding volume hierarchy (BVH) tree structure around triangle geometry.
8 The triangle BVH tree can be used for efficient intersection queries without involving a physics engine.
9 For example, this can be used in editor tools to select objects with complex shapes based on the mouse cursor position.
10 [b]Performance:[/b] Creating the BVH tree for complex geometry is a slow process and best done in a background thread.
11 </description>
12 <tutorials>
13 </tutorials>
14 <methods>
15 <method name="create_from_faces">
16 <return type="bool" />
17 <param index="0" name="faces" type="PackedVector3Array" />
18 <description>
19 Creates the BVH tree from an array of faces. Each 3 vertices of the input [param faces] array represent one triangle (face).
20 Returns [code]true[/code] if the tree is successfully built, [code]false[/code] otherwise.
21 </description>
22 </method>
23 <method name="get_faces" qualifiers="const">
24 <return type="PackedVector3Array" />
25 <description>
26 Returns a copy of the geometry faces. Each 3 vertices of the array represent one triangle (face).
27 </description>
28 </method>
29 <method name="intersect_ray" qualifiers="const">
30 <return type="Dictionary" />
31 <param index="0" name="begin" type="Vector3" />
32 <param index="1" name="dir" type="Vector3" />
33 <description>
34 Tests for intersection with a ray starting at [param begin] and facing [param dir] and extending toward infinity.
35 If an intersection with a triangle happens, returns a [Dictionary] with the following fields:
36 [code]position[/code]: The position on the intersected triangle.
37 [code]normal[/code]: The normal of the intersected triangle.
38 [code]face_index[/code]: The index of the intersected triangle.
39 Returns an empty [Dictionary] if no intersection happens.
40 See also [method intersect_segment], which is similar but uses a finite-length segment.
41 </description>
42 </method>
43 <method name="intersect_segment" qualifiers="const">
44 <return type="Dictionary" />
45 <param index="0" name="begin" type="Vector3" />
46 <param index="1" name="end" type="Vector3" />
47 <description>
48 Tests for intersection with a segment going from [param begin] to [param end].
49 If an intersection with a triangle happens returns a [Dictionary] with the following fields:
50 [code]position[/code]: The position on the intersected triangle.
51 [code]normal[/code]: The normal of the intersected triangle.
52 [code]face_index[/code]: The index of the intersected triangle.
53 Returns an empty [Dictionary] if no intersection happens.
54 See also [method intersect_ray], which is similar but uses an infinite-length ray.
55 </description>
56 </method>
57 </methods>
58</class>