Apply symmetry at the doPointshapePoint() level

This fixes the pixel-perfect mode (when symmetry is enabled) as it
expects only one joinPoints() call.
This commit is contained in:
David Capello 2015-10-29 17:01:43 -03:00
parent e9bfa5168c
commit f4373ffbc5
2 changed files with 22 additions and 10 deletions

View File

@ -12,6 +12,8 @@
#include "app/tools/intertwine.h"
#include "app/tools/point_shape.h"
#include "app/tools/stroke.h"
#include "app/tools/symmetry.h"
#include "app/tools/tool_loop.h"
#include "doc/algo.h"
@ -23,7 +25,20 @@ using namespace doc;
void Intertwine::doPointshapePoint(int x, int y, ToolLoop* loop)
{
loop->getPointShape()->transformPoint(loop, x, y);
Symmetry* symmetry = loop->getSymmetry();
if (symmetry) {
Stroke main_stroke;
main_stroke.addPoint(gfx::Point(x, y));
Strokes strokes;
symmetry->generateStrokes(main_stroke, strokes);
for (const auto& stroke : strokes)
loop->getPointShape()->transformPoint(
loop, stroke[0].x, stroke[0].y);
}
else {
loop->getPointShape()->transformPoint(loop, x, y);
}
}
void Intertwine::doPointshapeHline(int x1, int y, int x2, ToolLoop* loop)

View File

@ -173,7 +173,7 @@ void ToolLoopManager::doLoopStep(bool last_step)
main_stroke.offset(m_toolLoop->getOffset());
// Apply symmetry
// Calculate the area to be updated in all document observers.
Symmetry* symmetry = m_toolLoop->getSymmetry();
Strokes strokes;
if (symmetry)
@ -181,7 +181,6 @@ void ToolLoopManager::doLoopStep(bool last_step)
else
strokes.push_back(main_stroke);
// Calculate the area to be updated in all document observers.
calculateDirtyArea(strokes);
// Validate source image area.
@ -210,13 +209,11 @@ void ToolLoopManager::doLoopStep(bool last_step)
m_toolLoop->validateDstImage(m_dirtyArea);
// Get the modified area in the sprite with this intertwined set of points
for (Stroke& stroke : strokes) {
if (!m_toolLoop->getFilled() || (!last_step && !m_toolLoop->getPreviewFilled()))
m_toolLoop->getIntertwine()->joinStroke(m_toolLoop, stroke);
else
m_toolLoop->getIntertwine()->fillStroke(m_toolLoop, stroke);
}
// Join or fill user points
if (!m_toolLoop->getFilled() || (!last_step && !m_toolLoop->getPreviewFilled()))
m_toolLoop->getIntertwine()->joinStroke(m_toolLoop, main_stroke);
else
m_toolLoop->getIntertwine()->fillStroke(m_toolLoop, main_stroke);
if (m_toolLoop->getTracePolicy() == TracePolicy::Overlap) {
// Copy destination to source (yes, destination to source). In