Commit 6a598edf authored by David Flynn's avatar David Flynn
Browse files

refactor/m46245: remove interleave3b0 mortonCode generation method

This is part of a series that implements a single method of Cartesian to
Morton code conversion.
parent d044ff82
......@@ -365,17 +365,6 @@ PCCApproximatelyEqual(
}
//---------------------------------------------------------------------------
// Convert a vector position (divided by 2^depth) to morton order address.
template<typename T>
uint64_t
mortonAddr(const PCCVector3<T>& vec, int depth)
{
uint64_t addr = interleave3b0(uint64_t(vec.z()) >> depth);
addr |= interleave3b0(uint64_t(vec.y()) >> depth) << 1;
addr |= interleave3b0(uint64_t(vec.x()) >> depth) << 2;
return addr;
}
inline uint64_t
mortonAddr(const int32_t x, const int32_t y, const int32_t z)
......@@ -385,10 +374,24 @@ mortonAddr(const int32_t x, const int32_t y, const int32_t z)
| kMortonCode256Y[(y >> 16) & 0xFF] | kMortonCode256Z[(x >> 16) & 0xFF];
answer = answer << 48 | kMortonCode256X[(z >> 8) & 0xFF]
| kMortonCode256Y[(y >> 8) & 0xFF] | kMortonCode256Z[(x >> 8) & 0xFF];
answer = answer << 24 | kMortonCode256X[(z)&0xFF] | kMortonCode256Y[(y)&0xFF]
| kMortonCode256Z[(x)&0xFF];
answer = answer << 24 | kMortonCode256X[z & 0xFF] | kMortonCode256Y[y & 0xFF]
| kMortonCode256Z[x & 0xFF];
return answer;
}
//---------------------------------------------------------------------------
// Convert a vector position (divided by 2^depth) to morton order address.
template<typename T>
uint64_t
mortonAddr(const PCCVector3<T>& vec, int depth)
{
int x = int(vec.x()) >> depth;
int y = int(vec.y()) >> depth;
int z = int(vec.z()) >> depth;
return mortonAddr(x, y, z);
}
//---------------------------------------------------------------------------
} /* namespace pcc */
......
......@@ -163,21 +163,6 @@ ceillog2(uint32_t x)
return ilog2(x - 1) + 1;
}
//-------------------------------------------------------------------------
// Shuffle bits of x so as to interleave 0b00 between each pair.
// NB: x must be in the range [0, 2**21 - 1].
//
inline int64_t
interleave3b0(uint64_t x)
{
x = ((x << 32) | x) & 0x00ff00000000ffffllu;
x = ((x << 16) | x) & 0x00ff0000ff0000ffllu;
x = ((x << 8) | x) & 0xf00f00f00f00f00fllu;
x = ((x << 4) | x) & 0x30c30c30c30c30c3llu;
x = ((x << 2) | x) & 0x9249249249249249llu;
return x;
}
//---------------------------------------------------------------------------
// Decrement the @axis-th dimension of 3D morton code @x.
//
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment