Merge branch 'main' into dev-LayerStyle
commit
6494758781
|
@ -998,9 +998,9 @@ bool shouldFillBeginCap(vec2 localUV, bool onVeryBegin, int endType, vec2 p0, ve
|
||||||
vec2 normal;
|
vec2 normal;
|
||||||
if (onVeryBegin)
|
if (onVeryBegin)
|
||||||
{
|
{
|
||||||
if (endType == 0)
|
if (endType%2 == 0)
|
||||||
return true;
|
return true;
|
||||||
else if (endType == 1)
|
else if (endType%2 == 1)
|
||||||
normal = normalize(mat2(0, 1, -1, 0) * (-tangentBegin));
|
normal = normalize(mat2(0, 1, -1, 0) * (-tangentBegin));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1017,9 +1017,9 @@ bool shouldFillEndCap(vec2 localUV, bool onVeryEnd, int endType, vec2 p3, vec2 t
|
||||||
vec2 normal;
|
vec2 normal;
|
||||||
if (onVeryEnd)
|
if (onVeryEnd)
|
||||||
{
|
{
|
||||||
if (endType == 0)
|
if ((endType/2)%2 == 0)
|
||||||
return true;
|
return true;
|
||||||
else if (endType == 1)
|
else if ((endType/2)%2 == 1)
|
||||||
normal = normalize(mat2(0, 1, -1, 0) * tangentEnd);
|
normal = normalize(mat2(0, 1, -1, 0) * tangentEnd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1103,10 +1103,7 @@ void main()
|
||||||
if (isinf(pTemp.x))
|
if (isinf(pTemp.x))
|
||||||
{
|
{
|
||||||
// TODO: ¼ì²âÊÇ·ñ·â±Õ²¢´¦Àí
|
// TODO: ¼ì²âÊÇ·ñ·â±Õ²¢´¦Àí
|
||||||
if (hitElement && distance(localUV, p3Last) <= strokeWidth)
|
|
||||||
{
|
|
||||||
// hitElement = shouldFillEndCap(localUV, true, endType, p3Last, tangentEndLast);
|
|
||||||
}
|
|
||||||
|
|
||||||
pBegin = path[++pathIndex];
|
pBegin = path[++pathIndex];
|
||||||
p3Last = pBegin;
|
p3Last = pBegin;
|
||||||
|
@ -1134,6 +1131,8 @@ void main()
|
||||||
tangentBeginNext = normalize(pNext[0] - pNext[2]);
|
tangentBeginNext = normalize(pNext[0] - pNext[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
onVeryEnd = true;
|
||||||
|
|
||||||
float d = cubic_bezier_dis(localUV, p[0], p[1], p[2], p[3], true);
|
float d = cubic_bezier_dis(localUV, p[0], p[1], p[2], p[3], true);
|
||||||
if (d <= strokeWidth)
|
if (d <= strokeWidth)
|
||||||
|
@ -1184,18 +1183,6 @@ void main()
|
||||||
vec2 metallicRoughness;
|
vec2 metallicRoughness;
|
||||||
drawLine(minDistance / strokeWidth, styleIndex, elementColor, metallicRoughness);
|
drawLine(minDistance / strokeWidth, styleIndex, elementColor, metallicRoughness);
|
||||||
}
|
}
|
||||||
// else if (lastHitIndex == pathIndex - 3)
|
|
||||||
// {
|
|
||||||
// hitElement = lastHitElement;
|
|
||||||
// lastHitElement = false;
|
|
||||||
// // if(lastHitElement ==false)
|
|
||||||
// //{
|
|
||||||
// // hitElement = true;
|
|
||||||
// // elementColor = vec4(1, 1, 0, 1);
|
|
||||||
// //}
|
|
||||||
|
|
||||||
// minDistance = 1e38;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
tangentEndLast = tangentEnd;
|
tangentEndLast = tangentEnd;
|
||||||
}
|
}
|
||||||
|
@ -1203,10 +1190,6 @@ void main()
|
||||||
p2Last = p[2];
|
p2Last = p[2];
|
||||||
onVeryBegin = false;
|
onVeryBegin = false;
|
||||||
}
|
}
|
||||||
if (hitElement && distance(localUV, p3Last) <= strokeWidth)
|
|
||||||
{
|
|
||||||
// hitElement = shouldFillEndCap(localUV, true, endType, p3Last, tangentEndLast);
|
|
||||||
}
|
|
||||||
nextStyleIndex(styleIndex);
|
nextStyleIndex(styleIndex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace Renderer
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class StrokeType { kBothSides = 2, kLeftSide = 1, kRightSide = 0 };
|
enum class StrokeType { kBothSides = 2, kLeftSide = 1, kRightSide = 0 };
|
||||||
enum class StrokeEndType { kRound = 0, kFlat = 1 };
|
enum class StrokeEndType { kRound = 0b00, kFlat = 0b11, kRoundFlat = 0b10, kFlatRound = 0b01 };
|
||||||
|
|
||||||
class MaterialStyleStroke : public MaterialStyle
|
class MaterialStyleStroke : public MaterialStyle
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace UnitTest
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
TEST_METHOD(TestRightSideFlat)
|
TEST_METHOD(TestRightSideFlatRound)
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
class StyleStrokeRadialGradient : public Renderer::ElementStyle
|
class StyleStrokeRadialGradient : public Renderer::ElementStyle
|
||||||
|
@ -124,7 +124,7 @@ namespace UnitTest
|
||||||
{1.00, Material{QColor(58,64,151)}}
|
{1.00, Material{QColor(58,64,151)}}
|
||||||
};
|
};
|
||||||
return { BaseStyle(std::make_shared<TransformStyle>(),
|
return { BaseStyle(std::make_shared<TransformStyle>(),
|
||||||
std::make_shared<MaterialStyleStroke>(200, StrokeType::kRightSide, StrokeEndType::kFlat,
|
std::make_shared<MaterialStyleStroke>(160, StrokeType::kRightSide, StrokeEndType::kFlatRound,
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
|
|
Loading…
Reference in New Issue