TriangleMesh

package
v0.0.0-...-e10d1cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsTriangleMesh() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsTriangleMesh

func (self *Extension[T]) AsTriangleMesh() Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.TriangleMesh

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsTriangleMesh

func (self Instance) AsTriangleMesh() Instance

func (Instance) CreateFromFaces

func (self Instance) CreateFromFaces(faces []Vector3.XYZ) bool

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.

func (Instance) GetFaces

func (self Instance) GetFaces() []Vector3.XYZ

Returns a copy of the geometry faces. Each 3 vertices of the array represent one triangle (face).

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IntersectRay

func (self Instance) IntersectRay(begin Vector3.XYZ, dir Vector3.XYZ) Intersection

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 data structure 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 data structure if no intersection happens.

See also IntersectSegment, which is similar but uses a finite-length segment.

func (Instance) IntersectSegment

func (self Instance) IntersectSegment(begin Vector3.XYZ, end Vector3.XYZ) Intersection

Tests for intersection with a segment going from 'begin' to 'end'.

If an intersection with a triangle happens returns a data structure 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 data structure if no intersection happens.

See also IntersectRay, which is similar but uses an infinite-length ray.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type Intersection

type Intersection struct {
	Position struct {
		X float32
		Y float32
		Z float32
	} `gd:"position"`
	Normal struct {
		X float32
		Y float32
		Z float32
	} `gd:"normal"`
	FaceIndex int `gd:"face_index"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL