Class CsgShape3D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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 BakeStaticMesh() for the visual mesh or BakeCollisionShape() for the physics collision.
Entire scenes of CSG nodes can be baked to static geometry and exported with the editor gltf scene exporter.
[GodotClassName("CSGShape3D")]
public class CsgShape3D : GeometryInstance3D, IDisposable
- Inheritance
-
CsgShape3D
- Implements
- Derived
- Inherited Members
Properties
CalculateTangents
Calculate tangents for the CSG shape which allows the use of normal maps. This is only applied on the root shape, this setting is ignored on any child.
public bool CalculateTangents { get; set; }
Property Value
CollisionLayer
The physics layers this area is in.
Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. See Collision layers and masks in the documentation for more information.
public uint CollisionLayer { get; set; }
Property Value
CollisionMask
The physics layers this CSG shape scans for collisions. Only effective if UseCollision is true. See Collision layers and masks in the documentation for more information.
public uint CollisionMask { get; set; }
Property Value
CollisionPriority
The priority used to solve colliding when occurring penetration. Only effective if UseCollision is true. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.
public float CollisionPriority { get; set; }
Property Value
Operation
The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent.
public CsgShape3D.OperationEnum Operation { get; set; }
Property Value
Snap
This property does nothing.
[Obsolete("The CSG library no longer uses snapping.")]
public float Snap { get; set; }
Property Value
UseCollision
Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden. See also CollisionMask and CollisionPriority.
public bool UseCollision { get; set; }
Property Value
Methods
BakeCollisionShape()
Returns a baked physics 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.
public ConcavePolygonShape3D BakeCollisionShape()
Returns
BakeStaticMesh()
Returns a baked static 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.
public ArrayMesh BakeStaticMesh()
Returns
GetCollisionLayerValue(int)
Returns whether or not the specified layer of the CollisionLayer is enabled, given a layerNumber
between 1 and 32.
public bool GetCollisionLayerValue(int layerNumber)
Parameters
layerNumber
int
Returns
GetCollisionMaskValue(int)
Returns whether or not the specified layer of the CollisionMask is enabled, given a layerNumber
between 1 and 32.
public bool GetCollisionMaskValue(int layerNumber)
Parameters
layerNumber
int
Returns
GetMeshes()
Returns an Array with two elements, the first is the Transform3D of this node and the second is the root Mesh of this node. Only works when this node is the root shape.
public Array GetMeshes()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsRootShape()
Returns true if this is a root shape and is thus the object that is rendered.
public bool IsRootShape()
Returns
SetCollisionLayerValue(int, bool)
Based on value
, enables or disables the specified layer in the CollisionLayer, given a layerNumber
between 1 and 32.
public void SetCollisionLayerValue(int layerNumber, bool value)
Parameters
SetCollisionMaskValue(int, bool)
Based on value
, enables or disables the specified layer in the CollisionMask, given a layerNumber
between 1 and 32.
public void SetCollisionMaskValue(int layerNumber, bool value)