VoxelToolLodTerrain
Implementation of VoxelTool specialized for uses on VoxelLodTerrain.
Implementation of VoxelTool specialized for uses on VoxelLodTerrain.
Functions in this class are specific to VoxelLodTerrain. For generic functions, you may also check VoxelTool.
It's not a class to instantiate alone, you may get it from VoxelLodTerrain using the get_voxel_tool() method.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Methods9
DoGraphvoid
public void DoGraph(VoxelGeneratorGraph graph, Transform3D transform, Vector3 areaSize);Uses a VoxelGeneratorGraph as a brush, which allows to program SDF operations performed by the brush.
The graph must have an SDF input and an SDF output, and preferably work assuming a shape of unit size. For example, an additive sphere brush may use an SdfSphere node with radius 1 with a Min to combine it with terrain SDF.
See also online documentation.
| Name | Type | Default |
|---|---|---|
graph | VoxelGeneratorGraph | — |
transform | Transform3D | — |
areaSize | Vector3 | — |
DoHemispherevoid
public void DoHemisphere(Vector3 center, float radius, Vector3 flatDirection, float smoothness = 0f);Operates on a hemisphere, where flat_direction is pointing away from the flat surface (like a normal). smoothness determines how the flat part blends with the rounded part, with higher values producing softer more rounded edge.
| Name | Type | Default |
|---|---|---|
center | Vector3 | — |
radius | float | — |
flatDirection | Vector3 | — |
smoothness | float | 0f |
DoSphereAsyncvoid
public void DoSphereAsync(Vector3 center, float radius);| Name | Type | Default |
|---|---|---|
center | Vector3 | — |
radius | float | — |
GetRaycastBinarySearchIterationsint
public int GetRaycastBinarySearchIterations();intGetVoxelFInterpolatedfloat
public float GetVoxelFInterpolated(Vector3 position);| Name | Type | Default |
|---|---|---|
position | Vector3 | — |
floatRunBlockyRandomTickvoid
public void RunBlockyRandomTick(Aabb area, int voxelCount, Callable callback, int batchCount = 16, uint tagsMask = 4294967295);Picks random voxels within the specified area. If voxel models have VoxelBlockyModel.RandomTickable set to true and VoxelBlockyModel.TagsMask matches any bit in tags_mask, executes a function on them. This only works for terrains using VoxelMesherBlocky.
The given callback takes two arguments: voxel position (Vector3i), voxel value (int).
The purpose of batch_count is to optimize the picking process through the internal data structure. The algorithm goes as follows: voxel_count is divided in batches of length batch_count. For each batch, a random block intersecting area is chosen, and batch_count voxels are picked at random inside of it. If voxel_count is not divisible by batch_count, an extra block will be picked to do the remainder.
batch can bias randomness by concentrating picks in specific blocks, but if this function is used every frame over time, that bias should average out. If you want no bias at all, set batch_count to 1.
| Name | Type | Default |
|---|---|---|
area | Aabb | — |
voxelCount | int | — |
callback | Callable | — |
batchCount | int | 16 |
tagsMask | uint | 4294967295 |
SeparateFloatingChunksReckfell.Collections.Array
public Reckfell.Collections.Array SeparateFloatingChunks(Aabb box, Entity parentNode);Turns floating voxels into RigidBodies. Chunks of floating voxels are detected within a box. The box is relative to the voxel volume this VoxelTool is attached to. Chunks have to be contained entirely within that box to be considered floating. Chunks are removed from the source volume and transformed into RigidBodies with convex collision shapes. They will be added as child of the provided node. They will start "kinematic", and turn "rigid" after a short time, to allow the terrain to update its colliders after the removal (otherwise they will overlap). The function returns an array of these rigid bodies, which you can use to attach further behavior to them (such as disappearing after some time or distance for example). This algorithm can become expensive quickly, so the box should not be too big. A size of around 30 voxels should be ok.
| Name | Type | Default |
|---|---|---|
box | Aabb | — |
parentNode | Entity | — |
Reckfell.Collections.ArraySetRaycastBinarySearchIterationsvoid
public void SetRaycastBinarySearchIterations(int iterations);Picks random voxels within the specified area and executes a function on them. This only works for terrains using VoxelMesherBlocky. Only voxels where Voxel.random_tickable is true will be picked.
The given callback takes two arguments: voxel position (Vector3i), voxel value (int).
Only voxels at LOD 0 will be considered.
| Name | Type | Default |
|---|---|---|
iterations | int | — |
StampSdfvoid · Deprecated
public void StampSdf(VoxelMeshSdf meshSdf, Transform3D transform, float isolevel, float sdfScale);| Name | Type | Default |
|---|---|---|
meshSdf | VoxelMeshSdf | — |
transform | Transform3D | — |
isolevel | float | — |
sdfScale | float | — |