Documentation
¶
Overview ¶
This is the CSG base class that provides CSG operation support to the various CSG nodes in Godot.
Performance: CSG nodes are only intended for prototyping as they have a significant CPU performance cost. Consider baking final CSG operation results into static geometry that replaces the CSG nodes.
Individual CSG root node results can be baked to nodes with static resources with the editor menu that appears when a CSG root node is selected.
Individual CSG root nodes can also be baked to static resources with scripts by calling Instance.BakeStaticMesh for the visual mesh or Instance.BakeCollisionShape for the physics collision.
Entire scenes of CSG nodes can be baked to static geometry and exported with the editor glTF scene exporter: Scene > Export As... > glTF 2.0 Scene...
Index ¶
- type Advanced
- type Any
- type Extension
- func (self *Extension[T]) AsCSGShape3D() Instance
- func (self *Extension[T]) AsGeometryInstance3D() GeometryInstance3D.Instance
- func (self *Extension[T]) AsNode() Node.Instance
- func (self *Extension[T]) AsNode3D() Node3D.Instance
- func (self *Extension[T]) AsObject() [1]gd.Object
- func (self *Extension[T]) AsVisualInstance3D() VisualInstance3D.Instance
- type ID
- type Instance
- func (self Instance) AsCSGShape3D() Instance
- func (self Instance) AsGeometryInstance3D() GeometryInstance3D.Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsNode3D() Node3D.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsVisualInstance3D() VisualInstance3D.Instance
- func (self Instance) BakeCollisionShape() ConcavePolygonShape3D.Instance
- func (self Instance) BakeStaticMesh() ArrayMesh.Instance
- func (self Instance) CalculateTangents() bool
- func (self Instance) CollisionLayer() int
- func (self Instance) CollisionMask() int
- func (self Instance) CollisionPriority() Float.X
- func (self Instance) GetCollisionLayerValue(layer_number int) bool
- func (self Instance) GetCollisionMaskValue(layer_number int) bool
- func (self Instance) GetMeshes() (Transform3D.BasisOrigin, Mesh.Instance)
- func (self Instance) ID() ID
- func (self Instance) IsRootShape() bool
- func (self Instance) Operation() Operation
- func (self Instance) SetCalculateTangents(value bool)
- func (self Instance) SetCollisionLayer(value int)
- func (self Instance) SetCollisionLayerValue(layer_number int, value bool)
- func (self Instance) SetCollisionMask(value int)
- func (self Instance) SetCollisionMaskValue(layer_number int, value bool)
- func (self Instance) SetCollisionPriority(value Float.X)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOperation(value Operation)
- func (self Instance) SetSnap(value Float.X)
- func (self Instance) SetUseCollision(value bool)
- func (self Instance) Snap() Float.X
- func (self Instance) UseCollision() bool
- func (self Instance) Virtual(name string) reflect.Value
- type Operation
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 Extension ¶
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]) AsCSGShape3D ¶
func (*Extension[T]) AsGeometryInstance3D ¶
func (self *Extension[T]) AsGeometryInstance3D() GeometryInstance3D.Instance
func (*Extension[T]) AsVisualInstance3D ¶
func (self *Extension[T]) AsVisualInstance3D() VisualInstance3D.Instance
type 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.
type Instance ¶
type Instance [1]gdclass.CSGShape3D
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 (Instance) AsCSGShape3D ¶
func (Instance) AsGeometryInstance3D ¶
func (self Instance) AsGeometryInstance3D() GeometryInstance3D.Instance
func (Instance) AsVisualInstance3D ¶
func (self Instance) AsVisualInstance3D() VisualInstance3D.Instance
func (Instance) BakeCollisionShape ¶
func (self Instance) BakeCollisionShape() ConcavePolygonShape3D.Instance
Returns a baked physics graphics.gd/classdb/ConcavePolygonShape3D of this node's CSG operation result. Returns an empty shape if the node is not a CSG root node or has no valid geometry.
Performance: If the CSG operation results in a very detailed geometry with many faces physics performance will be very slow. Concave shapes should in general only be used for static level geometry and not with dynamic objects that are moving.
Note: CSG mesh data updates are deferred, which means they are updated with a delay of one rendered frame. To avoid getting an empty shape or outdated mesh data, make sure to call await get_tree().process_frame before using Instance.BakeCollisionShape in graphics.gd/classdb/Node.Instance.Ready or after changing properties on the graphics.gd/classdb/CSGShape3D.
func (Instance) BakeStaticMesh ¶
Returns a baked static graphics.gd/classdb/ArrayMesh of this node's CSG operation result. Materials from involved CSG nodes are added as extra mesh surfaces. Returns an empty mesh if the node is not a CSG root node or has no valid geometry.
Note: CSG mesh data updates are deferred, which means they are updated with a delay of one rendered frame. To avoid getting an empty mesh or outdated mesh data, make sure to call await get_tree().process_frame before using Instance.BakeStaticMesh in graphics.gd/classdb/Node.Instance.Ready or after changing properties on the graphics.gd/classdb/CSGShape3D.
func (Instance) CalculateTangents ¶
func (Instance) CollisionLayer ¶
func (Instance) CollisionMask ¶
func (Instance) CollisionPriority ¶
func (Instance) GetCollisionLayerValue ¶
Returns whether or not the specified layer of the Instance.CollisionLayer is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetCollisionMaskValue ¶
Returns whether or not the specified layer of the Instance.CollisionMask is enabled, given a 'layer_number' between 1 and 32.
func (Instance) GetMeshes ¶
func (self Instance) GetMeshes() (Transform3D.BasisOrigin, Mesh.Instance)
Returns an slice with two elements, the first is the [Transform3D.BasisOrigin] of this node and the second is the root graphics.gd/classdb/Mesh of this node. Only works when this node is the root shape.
Note: CSG mesh data updates are deferred, which means they are updated with a delay of one rendered frame. To avoid getting an empty shape or outdated mesh data, make sure to call await get_tree().process_frame before using Instance.GetMeshes in graphics.gd/classdb/Node.Instance.Ready or after changing properties on the graphics.gd/classdb/CSGShape3D.
func (Instance) IsRootShape ¶
Returns true if this is a root shape and is thus the object that is rendered.
func (Instance) SetCalculateTangents ¶
func (Instance) SetCollisionLayer ¶
func (Instance) SetCollisionLayerValue ¶
Based on 'value', enables or disables the specified layer in the Instance.CollisionLayer, given a 'layer_number' between 1 and 32.
func (Instance) SetCollisionMask ¶
func (Instance) SetCollisionMaskValue ¶
Based on 'value', enables or disables the specified layer in the Instance.CollisionMask, given a 'layer_number' between 1 and 32.
func (Instance) SetCollisionPriority ¶
func (Instance) SetOperation ¶
func (Instance) SetUseCollision ¶
func (Instance) UseCollision ¶
type Operation ¶
type Operation int //gd:CSGShape3D.Operation
const ( // Geometry of both primitives is merged, intersecting geometry is removed. OperationUnion Operation = 0 // Only intersecting geometry remains, the rest is removed. OperationIntersection Operation = 1 // The second shape is subtracted from the first, leaving a dent with its shape. OperationSubtraction Operation = 2 )