Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9537c82
NanoVDB Math: refactor onto MatBase/VecBase, fix bugs, add tests
swahtz May 20, 2026
d4c1198
NanoVDB Math: make Vec*::size constexpr to fix linker ODR-use
swahtz May 20, 2026
1b8c667
NanoVDB Math: use lowercase `size` in cross-type Vec* static_asserts
swahtz May 20, 2026
1bef1d7
nanovdb math: address Copilot review — long double rounding
swahtz May 22, 2026
d154d5c
nanovdb math: NANOVDB_ASSERT bounds checks on every operator[] in Math.h
swahtz May 28, 2026
2f95f15
nanovdb math: constexpr sweep across Math.h
swahtz May 28, 2026
b4924f9
nanovdb math: drop constexpr from Rgba8::operator< / == / packed()
swahtz May 28, 2026
9b9a6da
comment cleanup
swahtz May 28, 2026
8597823
nanovdb math: constexpr matMult / Map::applyMap / BBox::transform
swahtz May 28, 2026
ba68440
nanovdb math: add VecBase::x() / y() / z() / w() named accessors
swahtz May 28, 2026
b2cf24c
nanovdb math: alignas on power-of-2 Vec / Mat classes
swahtz May 29, 2026
5890f0d
nanovdb math: [[nodiscard]] on every value-returning query in Math.h
swahtz May 29, 2026
001dbe3
nanovdb math: noexcept sweep + explicit ctors + final on derived classes
swahtz May 29, 2026
993d4bd
NanoVDB Math: convert scalar*Vec/Mat operators to hidden friends
swahtz May 29, 2026
a1072df
NanoVDB Math: delegate Vec/Mat ctors via VecBase/MatBase init list
swahtz May 29, 2026
5183bf0
NanoVDB Math: small audit cleanups (const-correctness, dedupe, symmetry)
swahtz May 29, 2026
c129f34
seperate floorAs/ceilAs doxygen comments
swahtz May 29, 2026
556232d
NanoVDB Math: keep explicit cross-template Vec ctor, fix call sites
swahtz May 29, 2026
894dbc9
NanoVDB Math: doxygen sweep — accurate per-method docs
swahtz May 29, 2026
c10a237
NanoVDB Math: fix PySampleFromVoxels.cu cross-precision Vec assign
swahtz May 29, 2026
80ae020
comment cleanup
swahtz May 29, 2026
1db126b
NanoVDB Math: add const normalized() to VecBase and Vec2/Vec3/Vec4
swahtz Jun 3, 2026
f4beed6
add pendingchanges
swahtz Aug 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions nanovdb/nanovdb/NanoVDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ struct Map
double mTaperD; // 8B, placeholder for taper value

/// @brief Default constructor for the identity map
__hostdev__ Map()
__hostdev__ constexpr Map()
: mMatF{ 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}
, mInvMatF{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}
, mVecF{0.0f, 0.0f, 0.0f}
Expand All @@ -1417,7 +1417,7 @@ struct Map
, mTaperD{1.0}
{
}
__hostdev__ Map(double s, const Vec3d& t = Vec3d(0.0, 0.0, 0.0))
__hostdev__ constexpr Map(double s, const Vec3d& t = Vec3d(0.0, 0.0, 0.0))
: mMatF{float(s), 0.0f, 0.0f, 0.0f, float(s), 0.0f, 0.0f, 0.0f, float(s)}
, mInvMatF{1.0f / float(s), 0.0f, 0.0f, 0.0f, 1.0f / float(s), 0.0f, 0.0f, 0.0f, 1.0f / float(s)}
, mVecF{float(t[0]), float(t[1]), float(t[2])}
Expand Down Expand Up @@ -1449,15 +1449,15 @@ struct Map
/// @param ijk 3D vector to be mapped - typically floating point index coordinates
/// @return Forward mapping for affine transformation, i.e. (mat x ijk) + translation
template<typename Vec3T>
__hostdev__ Vec3T applyMap(const Vec3T& ijk) const { return math::matMult(mMatD, mVecD, ijk); }
__hostdev__ constexpr Vec3T applyMap(const Vec3T& ijk) const { return math::matMult(mMatD, mVecD, ijk); }

/// @brief Apply the forward affine transformation to a vector using 32bit floating point arithmetics.
/// @note Typically this operation is used for the scale, rotation and translation of index -> world mapping
/// @tparam Vec3T Template type of the 3D vector to be mapped
/// @param ijk 3D vector to be mapped - typically floating point index coordinates
/// @return Forward mapping for affine transformation, i.e. (mat x ijk) + translation
template<typename Vec3T>
__hostdev__ Vec3T applyMapF(const Vec3T& ijk) const { return math::matMult(mMatF, mVecF, ijk); }
__hostdev__ constexpr Vec3T applyMapF(const Vec3T& ijk) const { return math::matMult(mMatF, mVecF, ijk); }

/// @brief Apply the linear forward 3x3 transformation to an input 3d vector using 64bit floating point arithmetics,
/// e.g. scale and rotation WITHOUT translation.
Expand All @@ -1466,7 +1466,7 @@ struct Map
/// @param ijk 3D vector to be mapped - typically floating point index coordinates
/// @return linear forward 3x3 mapping of the input vector
template<typename Vec3T>
__hostdev__ Vec3T applyJacobian(const Vec3T& ijk) const { return math::matMult(mMatD, ijk); }
__hostdev__ constexpr Vec3T applyJacobian(const Vec3T& ijk) const { return math::matMult(mMatD, ijk); }

/// @brief Apply the linear forward 3x3 transformation to an input 3d vector using 32bit floating point arithmetics,
/// e.g. scale and rotation WITHOUT translation.
Expand All @@ -1475,15 +1475,15 @@ struct Map
/// @param ijk 3D vector to be mapped - typically floating point index coordinates
/// @return linear forward 3x3 mapping of the input vector
template<typename Vec3T>
__hostdev__ Vec3T applyJacobianF(const Vec3T& ijk) const { return math::matMult(mMatF, ijk); }
__hostdev__ constexpr Vec3T applyJacobianF(const Vec3T& ijk) const { return math::matMult(mMatF, ijk); }

/// @brief Apply the inverse affine mapping to a vector using 64bit floating point arithmetics.
/// @note Typically this operation is used for the world -> index mapping
/// @tparam Vec3T Template type of the 3D vector to be mapped
/// @param xyz 3D vector to be mapped - typically floating point world coordinates
/// @return Inverse affine mapping of the input @c xyz i.e. (xyz - translation) x mat^-1
template<typename Vec3T>
__hostdev__ Vec3T applyInverseMap(const Vec3T& xyz) const
__hostdev__ constexpr Vec3T applyInverseMap(const Vec3T& xyz) const
{
return math::matMult(mInvMatD, Vec3T(xyz[0] - mVecD[0], xyz[1] - mVecD[1], xyz[2] - mVecD[2]));
}
Expand All @@ -1494,7 +1494,7 @@ struct Map
/// @param xyz 3D vector to be mapped - typically floating point world coordinates
/// @return Inverse affine mapping of the input @c xyz i.e. (xyz - translation) x mat^-1
template<typename Vec3T>
__hostdev__ Vec3T applyInverseMapF(const Vec3T& xyz) const
__hostdev__ constexpr Vec3T applyInverseMapF(const Vec3T& xyz) const
{
return math::matMult(mInvMatF, Vec3T(xyz[0] - mVecF[0], xyz[1] - mVecF[1], xyz[2] - mVecF[2]));
}
Expand All @@ -1506,7 +1506,7 @@ struct Map
/// @param ijk 3D vector to be mapped - typically floating point index coordinates
/// @return linear inverse 3x3 mapping of the input vector i.e. xyz x mat^-1
template<typename Vec3T>
__hostdev__ Vec3T applyInverseJacobian(const Vec3T& xyz) const { return math::matMult(mInvMatD, xyz); }
__hostdev__ constexpr Vec3T applyInverseJacobian(const Vec3T& xyz) const { return math::matMult(mInvMatD, xyz); }

/// @brief Apply the linear inverse 3x3 transformation to an input 3d vector using 32bit floating point arithmetics,
/// e.g. inverse scale and inverse rotation WITHOUT translation.
Expand All @@ -1515,7 +1515,7 @@ struct Map
/// @param ijk 3D vector to be mapped - typically floating point index coordinates
/// @return linear inverse 3x3 mapping of the input vector i.e. xyz x mat^-1
template<typename Vec3T>
__hostdev__ Vec3T applyInverseJacobianF(const Vec3T& xyz) const { return math::matMult(mInvMatF, xyz); }
__hostdev__ constexpr Vec3T applyInverseJacobianF(const Vec3T& xyz) const { return math::matMult(mInvMatF, xyz); }

/// @brief Apply the transposed inverse 3x3 transformation to an input 3d vector using 64bit floating point arithmetics,
/// e.g. inverse scale and inverse rotation WITHOUT translation.
Expand All @@ -1524,12 +1524,12 @@ struct Map
/// @param ijk 3D vector to be mapped - typically floating point index coordinates
/// @return linear inverse 3x3 mapping of the input vector i.e. xyz x mat^-1
template<typename Vec3T>
__hostdev__ Vec3T applyIJT(const Vec3T& xyz) const { return math::matMultT(mInvMatD, xyz); }
__hostdev__ constexpr Vec3T applyIJT(const Vec3T& xyz) const { return math::matMultT(mInvMatD, xyz); }
template<typename Vec3T>
__hostdev__ Vec3T applyIJTF(const Vec3T& xyz) const { return math::matMultT(mInvMatF, xyz); }
__hostdev__ constexpr Vec3T applyIJTF(const Vec3T& xyz) const { return math::matMultT(mInvMatF, xyz); }

/// @brief Return a voxels size in each coordinate direction, measured at the origin
__hostdev__ Vec3d getVoxelSize() const { return this->applyMap(Vec3d(1)) - this->applyMap(Vec3d(0)); }
__hostdev__ constexpr Vec3d getVoxelSize() const { return this->applyMap(Vec3d(1)) - this->applyMap(Vec3d(0)); }
}; // Map

template<typename MatT, typename Vec3T>
Expand Down
Loading
Loading