Skip to content

Commit 2545b3f

Browse files
committed
Fix AMR block sampling at the exact upper bound, closes #26
1 parent b283d30 commit 2545b3f

5 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Version History
44
### Open VKL 2.0.2
55

66
- Fix used element size in copyDeviceBufferToHost
7+
- Fix corner case when sampling AMR blocks at exactly the upper bound
78
- Minimum CMake version is now v3.10
89
- Minimum ISPC version is now v1.30.0
910
- Superbuild updates to latest versions of dependencies

openvkl/devices/cpu/volume/amr/AMRData.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ namespace openvkl {
2525
this->cellWidth = info.cellWidth;
2626
this->value = *ispc(data);
2727
this->dims = this->box.size() + vec3i(1);
28-
this->f_dims = vec3f(this->dims);
28+
// make it an ULP smaller such that floor(relBrickPos*f_dims) yields
29+
// correct index even for relBrickPos=1.0f
30+
this->f_dims = nextafter(this->dims, -1);
2931

3032
this->worldBounds =
3133
box3f(vec3f(this->box.lower) * this->cellWidth,
3234
vec3f(this->box.upper + vec3i(1)) * this->cellWidth);
3335
this->gridToWorldScale = 1.f / this->cellWidth;
34-
this->worldToGridScale = rcp(this->worldBounds.size());
36+
this->worldToGridScale = 1.f / this->worldBounds.size();
3537
}
3638

3739
/*! this structure defines only the format of the INPUT of amr

openvkl/devices/cpu/volume/amr/AMRVolume.ih

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ inline void AMRVolume_transformObjectToLocal(
1111
varying vec3f &localCoordinates)
1212
{
1313
localCoordinates =
14-
rcp(volume->gridSpacing) * (objectCoordinates - volume->gridOrigin);
14+
(1.0f/volume->gridSpacing) * (objectCoordinates - volume->gridOrigin);
1515
}

testing/apps/tests/amr_volume_sampling.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ void amr_sampling_at_shell_boundaries(vec3i dimensions, vec3i step = vec3i(1))
3838
offsets.emplace_back(114.0f);
3939
offsets.emplace_back(128.0f);
4040

41+
// sample at the exact brick bound, resulting in relBrickPos=1.0
42+
offsets.emplace_back(256.0f);
43+
4144
for (const vec3f &offset : offsets) {
4245
const auto offsetWithStep = offset * step;
4346

testing/apps/tests/vdb_volume_dense.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ TEST_CASE("VDB volume dense consistency", "[volume_sampling]")
356356
.value_or(std::string(""));
357357

358358
if (vdbFilename.empty()) {
359-
WARN("OPENVDB_TEST_VDB_FILENAME not set; not running .vdb tests");
359+
WARN("OPENVKL_TEST_VDB_FILENAME not set; not running .vdb tests");
360360
return;
361361
}
362362

0 commit comments

Comments
 (0)