Skip to content

Commit

Permalink
#5767: Replace the old Patch::flipTexture algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 1, 2021
1 parent 2134f74 commit 3e0b6a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 2 additions & 8 deletions radiantcore/patch/Patch.cpp
Expand Up @@ -15,6 +15,7 @@
#include "brush/Winding.h"
#include "command/ExecutionFailure.h"
#include "selection/algorithm/Shader.h"
#include "selection/algorithm/Texturing.h"

#include "PatchSavedState.h"
#include "PatchNode.h"
Expand Down Expand Up @@ -858,14 +859,7 @@ Patch* Patch::MakeCap(Patch* patch, patch::CapType eType, EMatrixMajor mt, bool

void Patch::flipTexture(int nAxis)
{
undoSave();

for(PatchControlIter i = _ctrl.begin(); i != _ctrl.end(); ++i)
{
i->texcoord[nAxis] = -i->texcoord[nAxis];
}

controlPointsChanged();
selection::algorithm::TextureFlipper::FlipPatch(*this, nAxis);
}

/** greebo: Helper function that shifts all control points in
Expand Down
12 changes: 12 additions & 0 deletions radiantcore/selection/algorithm/Texturing.cpp
@@ -1,5 +1,7 @@
#include "Texturing.h"

#include "selection/textool/PatchNode.h"

namespace selection
{

Expand Down Expand Up @@ -46,6 +48,16 @@ bool TextureFlipper::processNode(const textool::INode::Ptr& node)
return true;
}

void TextureFlipper::FlipPatch(IPatch& patch, int flipAxis)
{
auto node = std::make_shared<textool::PatchNode>(patch);

const auto& bounds = node->localAABB();
TextureFlipper flipper({ bounds.origin.x(), bounds.origin.y() }, flipAxis);

flipper.processNode(node);
}

}

}
3 changes: 3 additions & 0 deletions radiantcore/selection/algorithm/Texturing.h
Expand Up @@ -51,6 +51,9 @@ class TextureFlipper :
TextureFlipper(const Vector2& flipCenter, int axis);

bool processNode(const textool::INode::Ptr& node) override;

// Directly flip the texture of the given patch
static void FlipPatch(IPatch& patch, int flipAxis);
};

}
Expand Down

0 comments on commit 3e0b6a0

Please sign in to comment.