Created
August 29, 2014 20:08
-
-
Save AllanHasegawa/7543a22b0e5b57d9ab9f to your computer and use it in GitHub Desktop.
Overloading Grid::FloatGrid with Z-Curve Order for elements of the LeafNode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef OPENVDB_USE_ZORDER | |
namespace openvdb { | |
namespace v3_0_0 { | |
namespace tree { | |
inline uint32_t splitBy3(uint32_t x) | |
{ | |
return (x & 0x1) | ((x & 0x2) << 2) | ((x & 0x4) << 4); | |
} | |
template<> | |
inline openvdb::Index | |
LeafNode<float, 3>::coordToOffset(const openvdb::Coord& xyz) | |
{ | |
assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM); | |
return splitBy3(xyz[0]) | (splitBy3(xyz[1]) << 1) | (splitBy3(xyz[2]) << 2); | |
} | |
template<> | |
inline openvdb::Coord | |
LeafNode<float, 3>::offsetToLocalCoord(openvdb::Index n) | |
{ | |
return Coord( | |
/*x=*/(n & 0x001) | (n & 0x008) | (n & 0x080), | |
/*y=*/(n & 0x002) | (n & 0x010) | (n & 0x100), | |
/*z=*/(n & 0x004) | (n & 0x020) | (n & 0x200) | |
); | |
} | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment