CsgShape3D
The CSG base class.
The CSG base class.
This is the CSG base class that provides CSG operation support to the various CSG nodes in Reckfell.
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 CsgShape3D.BakeStaticMesh for the visual mesh or CsgShape3D.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...
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties9
AutosmoothProperty
public bool Autosmooth { get; set; }Enables automatic smoothing. This overrides any smoothing on the CSG node and instead uses CsgShape3D.SmoothingAngle to calculate normals based on the angle between faces.
Children of a CsgCombiner3D node will be treated as a single mesh.
CalculateTangentsProperty
public bool CalculateTangents { get; set; }Calculate tangents for the CSG shape which allows the use of normal and height maps. This is only applied on the root shape, this setting is ignored on any child. Setting this to false can speed up shape generation slightly.
CollisionLayerProperty
public uint CollisionLayer { get; set; }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.
CollisionMaskProperty
public uint CollisionMask { get; set; }The physics layers this CSG shape scans for collisions. Only effective if CsgShape3D.UseCollision is true. See Collision layers and masks in the documentation for more information.
CollisionPriorityProperty
public float CollisionPriority { get; set; }The priority used to solve colliding when occurring penetration. Only effective if CsgShape3D.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.
OperationProperty
public CsgShape3D.OperationEnum Operation { get; set; }Child operand operation against the accumulated CSG result: Union, Intersection or Subtraction. Child order matters. Separate roots do not subtract from one another; operands must belong to one CSG composition.
SmoothingAngleProperty
public float SmoothingAngle { get; set; }When autosmooth is enabled, faces with an angle between them greater than this will be smoothed, while faces with a smaller angle will remain sharp. Note: An angle lower than 0.1 will cause all smoothing to be disabled, this can be used to increase performance.
SnapProperty · Deprecated
public float Snap { get; set; }This property does nothing.
UseCollisionProperty
public bool UseCollision { get; set; }Enables physics for the root CSG result. Child CSG operands do not become separate bodies. Geometry and collision update later; BakeCollisionShape can create a resource even when false, but a resource alone does not add a body to the world.
Methods26
BakeCollisionShapeConcavePolygonShape3D
public ConcavePolygonShape3D BakeCollisionShape();Creates a concave shape resource from the root CSG result. UseCollision need not be enabled, but data must be ready. Assign it to CollisionShape3D inside a StaticBody3D for actual collision; it is not a universal dynamic-body shape.
ConcavePolygonShape3DConcavePolygonShape3D for the root, or null for a child operand. Separate from ArrayMesh; save and assign them independently.
BakeStaticMeshArrayMesh
public ArrayMesh BakeStaticMesh();Obtains the root CSG composition mesh after its deferred update. Does not remove source entities, create a MeshInstance3D or save a file. Returns the current root mesh resource, not a guaranteed independent deep copy.
ArrayMeshRoot ArrayMesh, or null for a child operand or before the root mesh is ready. Wait for updates after CSG creation/changes and check the result before ResourceSaver.
GetCollisionLayeruint
public uint GetCollisionLayer();uintGetCollisionLayerValuebool
public bool GetCollisionLayerValue(int layerNumber);Returns whether or not the specified layer of the CsgShape3D.CollisionLayer is enabled, given a layer_number between 1 and 32.
| Name | Type | Default |
|---|---|---|
layerNumber | int | — |
boolGetCollisionMaskuint
public uint GetCollisionMask();uintGetCollisionMaskValuebool
public bool GetCollisionMaskValue(int layerNumber);Returns whether or not the specified layer of the CsgShape3D.CollisionMask is enabled, given a layer_number between 1 and 32.
| Name | Type | Default |
|---|---|---|
layerNumber | int | — |
boolGetCollisionPriorityfloat
public float GetCollisionPriority();floatGetMeshesReckfell.Collections.Array
public Reckfell.Collections.Array GetMeshes();Returns an Reckfell.Collections.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.
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 CsgShape3D.GetMeshes in Entity.Ready or after changing properties on the CsgShape3D.
Reckfell.Collections.ArrayGetOperationCsgShape3D.OperationEnum
public CsgShape3D.OperationEnum GetOperation();CsgShape3D.OperationEnumGetSmoothingAnglefloat
public float GetSmoothingAngle();floatGetSnapfloat
public float GetSnap();floatIsAutosmoothbool
public bool IsAutosmooth();boolIsCalculatingTangentsbool
public bool IsCalculatingTangents();boolIsRootShapebool
public bool IsRootShape();Checks whether this entity produces an independent CSG result. CSG hierarchy determines the root, not the object name. Bake methods operate on that root.
booltrue for the composition root; false for a CSG operand within another CSG object.
IsUsingCollisionbool
public bool IsUsingCollision();boolSetAutosmoothvoid
public void SetAutosmooth(bool autosmooth);| Name | Type | Default |
|---|---|---|
autosmooth | bool | — |
SetCalculateTangentsvoid
public void SetCalculateTangents(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetCollisionLayervoid
public void SetCollisionLayer(uint layer);| Name | Type | Default |
|---|---|---|
layer | uint | — |
SetCollisionLayerValuevoid
public void SetCollisionLayerValue(int layerNumber, bool value);Based on value, enables or disables the specified layer in the CsgShape3D.CollisionLayer, given a layer_number between 1 and 32.
| Name | Type | Default |
|---|---|---|
layerNumber | int | — |
value | bool | — |
SetCollisionMaskvoid
public void SetCollisionMask(uint mask);| Name | Type | Default |
|---|---|---|
mask | uint | — |
SetCollisionMaskValuevoid
public void SetCollisionMaskValue(int layerNumber, bool value);Based on value, enables or disables the specified layer in the CsgShape3D.CollisionMask, given a layer_number between 1 and 32.
| Name | Type | Default |
|---|---|---|
layerNumber | int | — |
value | bool | — |
SetCollisionPriorityvoid
public void SetCollisionPriority(float priority);| Name | Type | Default |
|---|---|---|
priority | float | — |
SetOperationvoid
public void SetOperation(CsgShape3D.OperationEnum operation);| Name | Type | Default |
|---|---|---|
operation | CsgShape3D.OperationEnum | — |
SetSmoothingAnglevoid
public void SetSmoothingAngle(float smoothingAngle);| Name | Type | Default |
|---|---|---|
smoothingAngle | float | — |
SetSnapvoid
public void SetSnap(float snap);| Name | Type | Default |
|---|---|---|
snap | float | — |
SetUseCollisionvoid
public void SetUseCollision(bool operation);| Name | Type | Default |
|---|---|---|
operation | bool | — |
CsgShape3D.OperationEnum
| Value | Description |
|---|---|
Intersection = 1 | Only intersecting geometry remains, the rest is removed. |
Subtraction = 2 | The second shape is subtracted from the first, leaving a dent with its shape. |
Union = 0 | Geometry of both primitives is merged, intersecting geometry is removed. |