Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5767: Start unifying the algorithms by moving the texture tool node …
…processor to selection::algorithm namespace, into Texturing.h/.cpp
- Loading branch information
1 parent
834dab9
commit d3aa245
Showing
6 changed files
with
76 additions
and
21 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "Texturing.h" | ||
|
||
namespace selection | ||
{ | ||
|
||
namespace algorithm | ||
{ | ||
|
||
TextureFlipper::TextureFlipper(const Vector2& flipCenter, int axis) | ||
{ | ||
auto flipMatrix = Matrix3::getIdentity(); | ||
|
||
if (axis == 0) | ||
{ | ||
flipMatrix.xx() = -1; | ||
} | ||
else // axis == 1 | ||
{ | ||
flipMatrix.yy() = -1; | ||
} | ||
|
||
_transform = Matrix3::getTranslation(-flipCenter); | ||
_transform.premultiplyBy(flipMatrix); | ||
_transform.premultiplyBy(Matrix3::getTranslation(+flipCenter)); | ||
} | ||
|
||
bool TextureFlipper::operator()(const textool::INode::Ptr& node) | ||
{ | ||
node->beginTransformation(); | ||
node->transform(_transform); | ||
node->commitTransformation(); | ||
return true; | ||
} | ||
|
||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "itexturetoolmodel.h" | ||
#include "math/Matrix3.h" | ||
|
||
namespace selection | ||
{ | ||
|
||
namespace algorithm | ||
{ | ||
|
||
// Flips all the visited node about the given axis and the given flip center point (in UV space) | ||
class TextureFlipper | ||
{ | ||
private: | ||
Matrix3 _transform; | ||
|
||
public: | ||
TextureFlipper(const Vector2& flipCenter, int axis); | ||
|
||
// Function operator, makes this class suitable to pass to e.g. ITextureToolSelectionSystem.foreachSelected() | ||
bool operator()(const textool::INode::Ptr& node); | ||
}; | ||
|
||
} | ||
|
||
} |
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
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
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