Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty Voxel position not set #11

Open
PassivePicasso opened this issue Dec 3, 2020 · 0 comments
Open

Empty Voxel position not set #11

PassivePicasso opened this issue Dec 3, 2020 · 0 comments

Comments

@PassivePicasso
Copy link

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant