Commit cc9fc8e4 authored by David Flynn's avatar David Flynn
Browse files

trisoup: convert internal positions to int32_t

For consistency with the upcoming change to the pointcloud position
data type, this commit changes the trisoup coding to internally
use int32_t rather than uint32_t.
parent f47efe4c
......@@ -64,8 +64,8 @@ void decodeTrisoupCommon(
//============================================================================
struct TrisoupSegment {
Vec3<uint32_t> startpos; // start point of edge segment
Vec3<uint32_t> endpos; // end point of edge segment
Vec3<int32_t> startpos; // start point of edge segment
Vec3<int32_t> endpos; // end point of edge segment
int index; // index of segment, to reorder after sorting
int uniqueIndex; // index of uniqueSegment
......@@ -74,8 +74,8 @@ struct TrisoupSegment {
struct TrisoupSegmentEnc : public TrisoupSegment {
TrisoupSegmentEnc(
const Vec3<uint32_t>& startpos,
const Vec3<uint32_t>& endpos,
const Vec3<int32_t>& startpos,
const Vec3<int32_t>& endpos,
int index,
int uniqueIndex,
int vertex,
......
......@@ -287,18 +287,18 @@ decodeTrisoupCommon(
auto leaf = leaves[i];
// Width of block.
const uint32_t blockWidth =
defaultBlockWidth; // in future, may override with leaf blockWidth
// in future, may override with leaf blockWidth
const int32_t blockWidth = defaultBlockWidth;
// Eight corners of block.
const Vec3<uint32_t> pos000({0, 0, 0});
const Vec3<uint32_t> posW00({blockWidth, 0, 0});
const Vec3<uint32_t> pos0W0({0, blockWidth, 0});
const Vec3<uint32_t> posWW0({blockWidth, blockWidth, 0});
const Vec3<uint32_t> pos00W({0, 0, blockWidth});
const Vec3<uint32_t> posW0W({blockWidth, 0, blockWidth});
const Vec3<uint32_t> pos0WW({0, blockWidth, blockWidth});
const Vec3<uint32_t> posWWW({blockWidth, blockWidth, blockWidth});
const Vec3<int32_t> pos000({0, 0, 0});
const Vec3<int32_t> posW00({blockWidth, 0, 0});
const Vec3<int32_t> pos0W0({0, blockWidth, 0});
const Vec3<int32_t> posWW0({blockWidth, blockWidth, 0});
const Vec3<int32_t> pos00W({0, 0, blockWidth});
const Vec3<int32_t> posW0W({blockWidth, 0, blockWidth});
const Vec3<int32_t> pos0WW({0, blockWidth, blockWidth});
const Vec3<int32_t> posWWW({blockWidth, blockWidth, blockWidth});
// x: left to right; y: bottom to top; z: far to near
segments.push_back( // far bottom edge
......@@ -395,7 +395,7 @@ decodeTrisoupCommon(
// of surface intersection./ Put decoded vertex at center of voxel,
// unless voxel is first or last along the edge, in which case put the
// decoded vertex at the start or endpoint of the segment.
Vec3<uint32_t> direction = segment.endpos - segment.startpos;
Vec3<int32_t> direction = segment.endpos - segment.startpos;
blockWidth =
std::max(direction[0], std::max(direction[1], direction[2]));
int32_t distance;
......@@ -455,10 +455,10 @@ decodeTrisoupCommon(
// Sort projected vertices by decreasing angle in [-pi,+pi] around center
// of block (i.e., clockwise from 9:00) breaking ties in angle by
// increasing distance along the dominant axis.
Vec3<uint32_t> bc = leaves[i].pos + (blockWidth / 2);
Vec3<int32_t> blockCenter = {(int32_t)(bc[0] << kTrisoupFpBits),
(int32_t)(bc[1] << kTrisoupFpBits),
(int32_t)(bc[2] << kTrisoupFpBits)};
Vec3<int32_t> bc = leaves[i].pos + (blockWidth / 2);
Vec3<int32_t> blockCenter = {bc[0] << kTrisoupFpBits,
bc[1] << kTrisoupFpBits,
bc[2] << kTrisoupFpBits};
for (int j = 0; j < leafVertices.size(); j++) {
Vec3<int32_t> S = leafVertices[j].pos - blockCenter;
switch (dominantAxis) {
......
......@@ -124,17 +124,17 @@ determineTrisoupVertices(
// Width of block.
// in future, may override with leaf blockWidth
const uint32_t blockWidth = defaultBlockWidth;
const int32_t blockWidth = defaultBlockWidth;
// Eight corners of block.
const Vec3<uint32_t> pos000({0, 0, 0});
const Vec3<uint32_t> posW00({blockWidth, 0, 0});
const Vec3<uint32_t> pos0W0({0, blockWidth, 0});
const Vec3<uint32_t> posWW0({blockWidth, blockWidth, 0});
const Vec3<uint32_t> pos00W({0, 0, blockWidth});
const Vec3<uint32_t> posW0W({blockWidth, 0, blockWidth});
const Vec3<uint32_t> pos0WW({0, blockWidth, blockWidth});
const Vec3<uint32_t> posWWW({blockWidth, blockWidth, blockWidth});
const Vec3<int32_t> pos000({0, 0, 0});
const Vec3<int32_t> posW00({blockWidth, 0, 0});
const Vec3<int32_t> pos0W0({0, blockWidth, 0});
const Vec3<int32_t> posWW0({blockWidth, blockWidth, 0});
const Vec3<int32_t> pos00W({0, 0, blockWidth});
const Vec3<int32_t> posW0W({blockWidth, 0, blockWidth});
const Vec3<int32_t> pos0WW({0, blockWidth, blockWidth});
const Vec3<int32_t> posWWW({blockWidth, blockWidth, blockWidth});
// x: left to right; y: bottom to top; z: far to near
TrisoupSegmentEnc seg000W00 = // far bottom edge
......
Markdown is supported
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