Skip to content

Empty Voxel position not set #11

@PassivePicasso

Description

@PassivePicasso

I recently acquired this tool in an attempt to use it to identify empty space as a starting point for generating a navigation graph.
Unfortunately I found that while I can retrieve empty voxels from the GPUVoxelizer, Voxel's which return true from IsEmpty have their position set to Vector3.zero unexpectedly.

I attempted to determine what the problem was in the existing code, but it appeared to me that all voxels should be getting their correct position set and I don't understand the code well enough to understand why they don't in the context.

However, I was able to add in a new kernel which simply iterates over the the buffer and sets the position, which appears to work correctly.

The code for that kernel is as follows;

[numthreads(8, 8, 8)]
void FixVoxelPositions(uint3 id : SV_DispatchThreadID)
{
    int x = (int)id.x;
    int y = (int)id.y;
    int z = (int)id.z;

    if(x >= _Width) return;
    if(y >= _Height) return;
    if(z >= _Depth) return;

    uint vid = get_voxel_index(x, y, z);
    Voxel v = _VoxelBuffer[vid];
    v.position = get_voxel_position(x, y, z);
    _VoxelBuffer[vid] = v;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions