Skip to content

Some voxels out of bounds #1

@m-schuetz

Description

@m-schuetz
  • When mapping float coordinates to quantized voxel coordinates, the coordinate should be clamped to [0, gridSize - 1]
  • Code below occasionally maps coordinates to exactly gridSize if a sample is roughly equal to the bounding box maximum.
  • Occurs in first-come and random sampling strategies

int ix = float(bitgrid_size) * (point.x - child->min.x) / childSize.x;
int iy = float(bitgrid_size) * (point.y - child->min.y) / childSize.y;
int iz = float(bitgrid_size) * (point.z - child->min.z) / childSize.z;

Should be clamped like this:

int ix = clamp(fGridSize * (point.x - node->min.x) / boxSize.x, 0.0f, fGridSize - 1.0f);
int iy = clamp(fGridSize * (point.y - node->min.y) / boxSize.y, 0.0f, fGridSize - 1.0f);
int iz = clamp(fGridSize * (point.z - node->min.z) / boxSize.z, 0.0f, fGridSize - 1.0f);

Should probably also be done in similar sections in average and weighted strategies? e.g.

float fx = fGridSize * (point.x - node->min.x) / boxSize.x;
float fy = fGridSize * (point.y - node->min.y) / boxSize.y;
float fz = fGridSize * (point.z - node->min.z) / boxSize.z;

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