Skip to content

Commit

Permalink
#5382: Remove unused parts and fix a few warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 12, 2020
1 parent 2584394 commit 0f9b1cc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 35 deletions.
12 changes: 6 additions & 6 deletions libs/patch/PatchIterators.h
Expand Up @@ -125,7 +125,7 @@ class SinglePatchRowIteratorBase :
{
public:
SinglePatchRowIteratorBase(IPatch& patch, std::size_t row, std::size_t startCol, int delta) :
PatchControlIterator(patch, static_cast<int>(row), startCol,
PatchControlIterator(patch, static_cast<int>(row), static_cast<int>(startCol),
std::bind(SinglePatchRowIteratorBase::moveToNextCol, std::placeholders::_1, delta))
{}

Expand Down Expand Up @@ -162,7 +162,7 @@ class SinglePatchColumnIteratorBase :
{
public:
SinglePatchColumnIteratorBase(IPatch& patch, std::size_t col, std::size_t startRow, int delta) :
PatchControlIterator(patch, startRow, static_cast<int>(col),
PatchControlIterator(patch, static_cast<int>(startRow), static_cast<int>(col),
std::bind(SinglePatchColumnIteratorBase::moveToNextRow, std::placeholders::_1, delta))
{}

Expand Down Expand Up @@ -205,7 +205,7 @@ class ColumnWisePatchIteratorBase :
{}

ColumnWisePatchIteratorBase(IPatch& patch, std::size_t startColumn, std::size_t endColumn, int rowDelta) :
PatchControlIterator(patch, rowDelta > 0 ? 0 : patch.getHeight() - 1, startColumn,
PatchControlIterator(patch, rowDelta > 0 ? 0 : static_cast<int>(patch.getHeight()) - 1, static_cast<int>(startColumn),
std::bind(ColumnWisePatchIteratorBase::moveNext, std::placeholders::_1, std::ref(patch),
endColumn, startColumn <= endColumn ? +1 : -1, rowDelta))
{}
Expand All @@ -226,7 +226,7 @@ class ColumnWisePatchIteratorBase :
if (columnDelta > 0 && nextColumn <= endColumn ||
columnDelta < 0 && nextColumn >= endColumn)
{
nextRow = rowDelta > 0 ? 0 : patch.getHeight() - 1;
nextRow = rowDelta > 0 ? 0 : static_cast<int>(patch.getHeight()) - 1;
}
}

Expand Down Expand Up @@ -276,7 +276,7 @@ class RowWisePatchIteratorBase :
{}

RowWisePatchIteratorBase(IPatch& patch, std::size_t startRow, std::size_t endRow, int columnDelta) :
PatchControlIterator(patch, startRow, columnDelta > 0 ? 0 : patch.getWidth() - 1,
PatchControlIterator(patch, static_cast<int>(startRow), columnDelta > 0 ? 0 : static_cast<int>(patch.getWidth()) - 1,
std::bind(RowWisePatchIteratorBase::moveNext, std::placeholders::_1, std::ref(patch),
endRow, startRow <= endRow ? +1 : -1, columnDelta))
{}
Expand All @@ -297,7 +297,7 @@ class RowWisePatchIteratorBase :
if (rowDelta > 0 && nextRow <= endRow ||
rowDelta < 0 && nextRow >= endRow)
{
nextColumn = columnDelta > 0 ? 0 : patch.getWidth() - 1;
nextColumn = columnDelta > 0 ? 0 : static_cast<int>(patch.getWidth()) - 1;
}
}

Expand Down
52 changes: 23 additions & 29 deletions radiantcore/patch/algorithm/General.cpp
Expand Up @@ -216,12 +216,6 @@ scene::INodePtr createdMergedPatch(const PatchNodePtr& patchNode1, const PatchNo
auto& patch1 = patchNode1->getPatch();
auto& patch2 = patchNode2->getPatch();

enum EdgeLocation
{
Begin,
End,
};

enum EdgeType
{
Row,
Expand All @@ -230,28 +224,28 @@ scene::INodePtr createdMergedPatch(const PatchNodePtr& patchNode1, const PatchNo

// Construct edge iterators for the first patch
// Iterator, Starting Point for copying data to new patch, Edge Length
auto patch1FirstRow = std::make_tuple(SinglePatchRowIterator(patch1, 0), RowWisePatchIterator(patch1, patch1.getHeight() - 1, 1), Row, patch1.getWidth(), "patch1FirstRow");
auto patch1FirstCol = std::make_tuple(SinglePatchColumnIterator(patch1, 0), ColumnWisePatchIterator(patch1, patch1.getWidth() - 1, 1), Column, patch1.getHeight(), "patch1FirstCol");
auto patch1LastRow = std::make_tuple(SinglePatchRowIterator(patch1, patch1.getHeight() - 1), RowWisePatchIterator(patch1, 0, patch1.getHeight() - 2), Row, patch1.getWidth(), "patch1LastRow");
auto patch1LastCol = std::make_tuple(SinglePatchColumnIterator(patch1, patch1.getWidth() - 1), ColumnWisePatchIterator(patch1, 0, patch1.getWidth() - 2), Column, patch1.getHeight(), "patch1LastCol");
auto patch1FirstRow = std::make_tuple(SinglePatchRowIterator(patch1, 0), RowWisePatchIterator(patch1, patch1.getHeight() - 1, 1), Row, patch1.getWidth());
auto patch1FirstCol = std::make_tuple(SinglePatchColumnIterator(patch1, 0), ColumnWisePatchIterator(patch1, patch1.getWidth() - 1, 1), Column, patch1.getHeight());
auto patch1LastRow = std::make_tuple(SinglePatchRowIterator(patch1, patch1.getHeight() - 1), RowWisePatchIterator(patch1, 0, patch1.getHeight() - 2), Row, patch1.getWidth());
auto patch1LastCol = std::make_tuple(SinglePatchColumnIterator(patch1, patch1.getWidth() - 1), ColumnWisePatchIterator(patch1, 0, patch1.getWidth() - 2), Column, patch1.getHeight());

// We'll be comparing each of the above edges to all other four edges of the second patch
// and we're doing it in forward and backward iteration, so we're trying to orient patch 2
// such that the edge vertices are matching up with patch 1
auto patch2FirstRow = std::make_tuple(RowWisePatchIterator(patch2), Begin, patch2.getWidth(), "patch2FirstRow");
auto patch2FirstCol = std::make_tuple(ColumnWisePatchIterator(patch2), Begin, patch2.getHeight(), "patch2FirstCol");
auto patch2LastRow = std::make_tuple(RowWisePatchIterator(patch2, patch2.getHeight() - 1, 0), End, patch2.getWidth(), "patch2LastRow");
auto patch2LastCol = std::make_tuple(ColumnWisePatchIterator(patch2, patch2.getWidth() - 1, 0), End, patch2.getHeight(), "patch2LastCol");

auto patch2FirstRowReverse = std::make_tuple(RowWisePatchReverseIterator(patch2), Begin, patch2.getWidth(), "patch2FirstRowReverse");
auto patch2FirstColReverse = std::make_tuple(ColumnWisePatchReverseIterator(patch2), Begin, patch2.getHeight(), "patch2FirstColReverse");
auto patch2LastRowReverse = std::make_tuple(RowWisePatchReverseIterator(patch2, patch2.getHeight() - 1, 0), End, patch2.getWidth(), "patch2LastRowReverse");
auto patch2LastColReverse = std::make_tuple(ColumnWisePatchReverseIterator(patch2, patch2.getWidth() - 1, 0), End, patch2.getHeight(), "patch2LastColReverse");
auto patch2FirstRow = std::make_pair(RowWisePatchIterator(patch2), patch2.getWidth());
auto patch2FirstCol = std::make_pair(ColumnWisePatchIterator(patch2), patch2.getHeight());
auto patch2LastRow = std::make_pair(RowWisePatchIterator(patch2, patch2.getHeight() - 1, 0), patch2.getWidth());
auto patch2LastCol = std::make_pair(ColumnWisePatchIterator(patch2, patch2.getWidth() - 1, 0), patch2.getHeight());

auto patch2FirstRowReverse = std::make_pair(RowWisePatchReverseIterator(patch2), patch2.getWidth());
auto patch2FirstColReverse = std::make_pair(ColumnWisePatchReverseIterator(patch2), patch2.getHeight());
auto patch2LastRowReverse = std::make_pair(RowWisePatchReverseIterator(patch2, patch2.getHeight() - 1, 0), patch2.getWidth());
auto patch2LastColReverse = std::make_pair(ColumnWisePatchReverseIterator(patch2, patch2.getWidth() - 1, 0), patch2.getHeight());

std::vector<std::tuple<PatchControlIterator, PatchControlIterator, EdgeType, std::size_t, const char*>> patch1Edges =
std::vector<std::tuple<PatchControlIterator, PatchControlIterator, EdgeType, std::size_t>> patch1Edges =
{ patch1FirstRow, patch1FirstCol, patch1LastRow, patch1LastCol };

std::vector<std::tuple<PatchControlIterator, EdgeLocation, std::size_t, const char*>> patch2Edges =
std::vector<std::pair<PatchControlIterator, std::size_t>> patch2Edges =
{
patch2FirstRow, patch2FirstCol, patch2LastRow, patch2LastCol,
patch2FirstRowReverse, patch2FirstColReverse, patch2LastRowReverse, patch2LastColReverse
Expand All @@ -261,22 +255,20 @@ scene::INodePtr createdMergedPatch(const PatchNodePtr& patchNode1, const PatchNo
{
for (const auto& patch2Edge : patch2Edges)
{
if (std::get<3>(patch1Edge) != std::get<2>(patch2Edge))
if (std::get<3>(patch1Edge) != patch2Edge.second)
{
continue; // length don't match
continue; // length doesn't match
}

//rMessage() << "Comparing " << std::get<4>(patch1Edge) << " to " << std::get<3>(patch2Edge) << std::endl;

if (!firstNItemsAreEqual(std::get<0>(patch1Edge), std::get<0>(patch2Edge), std::get<3>(patch1Edge), WELD_EPSILON))
if (!firstNItemsAreEqual(std::get<0>(patch1Edge), patch2Edge.first, std::get<3>(patch1Edge), WELD_EPSILON))
{
continue;
}

// Expand the patch dimensions
std::size_t numNewRows = patch1.getHeight();
std::size_t numNewColumns = patch1.getWidth();
std::size_t numNewElements = patch2.getWidth() * patch2.getHeight() / std::get<2>(patch2Edge) - 1;
std::size_t numNewElements = patch2.getWidth() * patch2.getHeight() / patch2Edge.second - 1;

auto& dimensionToExpand = std::get<2>(patch1Edge) == Row ? numNewRows : numNewColumns;
dimensionToExpand += numNewElements;
Expand All @@ -287,17 +279,19 @@ scene::INodePtr createdMergedPatch(const PatchNodePtr& patchNode1, const PatchNo

if (std::get<2>(patch1Edge) == Row)
{
// Load the control points row-wise into the new patch
RowWisePatchIterator target(newPatch);

assignPatchControls(std::get<1>(patch1Edge), target);
assignPatchControls(std::get<0>(patch2Edge), target);
assignPatchControls(patch2Edge.first, target);
}
else
{
// Load the control points column-wise into the new patch
ColumnWisePatchIterator target(newPatch);

assignPatchControls(std::get<1>(patch1Edge), target);
assignPatchControls(std::get<0>(patch2Edge), target);
assignPatchControls(patch2Edge.first, target);
}

newPatch.controlPointsChanged();
Expand Down

0 comments on commit 0f9b1cc

Please sign in to comment.