Can anyone explain how to use this function/what should be passed in for each of the parameters? : VoxelFarm::CClipmapView::stampVoxels

Background : I'm trying to "paint" roads along the surface of the terrain. My plan is to follow the surface of the terrain by checking voxels in a particular direction from a starting point and continually searching up until I find material 0 (air) voxels. Then I can change the material of these surface voxels to the road material. I tried calling CBlockData::setBlock directly, but that didn't work reliably and looks like it led to a massive increase in memory, so it seems that's not the proper way to achieve this.
0 0
For this use case, we recommend the "VoxelFarm::cursorPaint()" function found in VoxelSmooth.h.

This is the function's declaration:

void cursorPaint(VoxelFarm::CGenerator* generator,
/// A reference to the block layer
IBlockData* blockData,
/// Specifies the target cell for the operation. Depending on the kernel's size the operation may bleed to neighboring cells
CellId targetCell,
/// Specifies the target location along the X axis, in voxels relative to the origin of the cell
int targetCellX,
/// Specifies the target location along the Y axis, in voxels relative to the origin of the cell
int targetCellY,
/// Specifies the target location along the Z axis, in voxels relative to the origin of the cell
int targetCellZ,
/// Kernel dimensions along the X axis
int kernelSizeX,
/// Kernel dimensions along the Y axis
int kernelSizeY,
/// Kernel dimensions along the Z axis
int kernelSizeZ,
/// If false the paint cursor will be spherical, if true it will be a cube
bool cube,
/// Material to paint with
MaterialId material,
/// It translates a given material depending of the position in the world
IMeshStamMaterialSource* materials,
/// Returns a list of all affected cells during the process
TSet<CellId>* changedCells,
/// returns a list of the volumes of all affected cells during the process
TMap<CellId, CCellData::CInstanceEditionVolume>& volumes

Calling the function will modify the block data, but changes will not have any visual consequences until you ask your ClipmapView instance to actually process the cells that were modified. You can achieve this by calling the clipmapview's "processModifiedCells()" method:

clipmapView.processModifiedCells(changedCells, false, &volumes);

Here "changedCells" and "volumes" are the same as in the "cursorPaint()" function call.

In theory, you could perform many calls to "cursorPaint" and just one call to "processModifiedCells" to make all changes visible. In this case, you must make sure the "changedCells" and "volumes" containers will include the items from all calls to "paintCursor". The "paintCursor" function will accumulate these normally, as long as you do not clear these containers before calling "processModifiedCells" this will have the desired effect.

0 0