reckfellENGINE

CsgShape3D

The CSG base class.

On this page
class CsgShape3DReckfellSharpInherits GeometryInstance3D

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
# Autosmooth
C#
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
# CalculateTangents
C#
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
# CollisionLayer
C#
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
# CollisionMask
C#
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
# CollisionPriority
C#
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
# Operation
C#
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
# SmoothingAngle
C#
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
# Snap
C#
public float Snap { get; set; }

This property does nothing.

UseCollisionProperty
# UseCollision
C#
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
# BakeCollisionShape
C#
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.

Returns ConcavePolygonShape3D

ConcavePolygonShape3D for the root, or null for a child operand. Separate from ArrayMesh; save and assign them independently.

BakeStaticMeshArrayMesh
# BakeStaticMesh
C#
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.

Returns ArrayMesh

Root 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
# GetCollisionLayer
C#
public uint GetCollisionLayer();
Returns uint
GetCollisionLayerValuebool
# GetCollisionLayerValue
C#
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.

Parameters
NameTypeDefault
layerNumberint—
Returns bool
GetCollisionMaskuint
# GetCollisionMask
C#
public uint GetCollisionMask();
Returns uint
GetCollisionMaskValuebool
# GetCollisionMaskValue
C#
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.

Parameters
NameTypeDefault
layerNumberint—
Returns bool
GetCollisionPriorityfloat
# GetCollisionPriority
C#
public float GetCollisionPriority();
Returns float
GetMeshesReckfell.Collections.Array
# GetMeshes
C#
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.

Returns Reckfell.Collections.Array
GetOperationCsgShape3D.OperationEnum
# GetOperation
C#
public CsgShape3D.OperationEnum GetOperation();
Returns CsgShape3D.OperationEnum
GetSmoothingAnglefloat
# GetSmoothingAngle
C#
public float GetSmoothingAngle();
Returns float
GetSnapfloat
# GetSnap
C#
public float GetSnap();
Returns float
IsAutosmoothbool
# IsAutosmooth
C#
public bool IsAutosmooth();
Returns bool
IsCalculatingTangentsbool
# IsCalculatingTangents
C#
public bool IsCalculatingTangents();
Returns bool
IsRootShapebool
# IsRootShape
C#
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.

Returns bool

true for the composition root; false for a CSG operand within another CSG object.

IsUsingCollisionbool
# IsUsingCollision
C#
public bool IsUsingCollision();
Returns bool
SetAutosmoothvoid
# SetAutosmooth
C#
public void SetAutosmooth(bool autosmooth);
Parameters
NameTypeDefault
autosmoothbool—
SetCalculateTangentsvoid
# SetCalculateTangents
C#
public void SetCalculateTangents(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetCollisionLayervoid
# SetCollisionLayer
C#
public void SetCollisionLayer(uint layer);
Parameters
NameTypeDefault
layeruint—
SetCollisionLayerValuevoid
# SetCollisionLayerValue
C#
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.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
SetCollisionMaskvoid
# SetCollisionMask
C#
public void SetCollisionMask(uint mask);
Parameters
NameTypeDefault
maskuint—
SetCollisionMaskValuevoid
# SetCollisionMaskValue
C#
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.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
SetCollisionPriorityvoid
# SetCollisionPriority
C#
public void SetCollisionPriority(float priority);
Parameters
NameTypeDefault
priorityfloat—
SetOperationvoid
# SetOperation
C#
public void SetOperation(CsgShape3D.OperationEnum operation);
Parameters
NameTypeDefault
operationCsgShape3D.OperationEnum—
SetSmoothingAnglevoid
# SetSmoothingAngle
C#
public void SetSmoothingAngle(float smoothingAngle);
Parameters
NameTypeDefault
smoothingAnglefloat—
SetSnapvoid
# SetSnap
C#
public void SetSnap(float snap);
Parameters
NameTypeDefault
snapfloat—
SetUseCollisionvoid
# SetUseCollision
C#
public void SetUseCollision(bool operation);
Parameters
NameTypeDefault
operationbool—

CsgShape3D.OperationEnum

ValueDescription
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.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.