Closed aismann closed 1 year ago
I revert design size: https://github.com/axmolengine/axmol/commit/56d4140628d2166c3ba93904539f8f4dc3c6cfcf
Should we not fix this bug?
Can take a look does some tests of cpp-tests design for specific design-size
@aismann This issue caused by clipper2, when I revert to clipper1, works well, can you take a look?
Yes.
@halx99 Please add pinned.
Some hint log:
/*
* clipper1
##################### outPoints count: 5772, cost 250.085 (ms)
##################### outPoints count: 5772, cost 252.699 (ms)
##################### outPoints count: 5772, cost 251.789 (ms)
##################### outPoints count: 5772, cost 250.371 (ms)
##################### outPoints count: 5772, cost 250.287 (ms)
* clipper2:
* ##################### outPoints count: 5827, cost 43.250 (ms)
*/
@aismann Caused by duplicate outPoints, remove duplicated points will solve this issue(notes: the outPoints generate by clipper1 no duplicates):
struct point64_less
{
bool operator()(const Clipper2Lib::Point64* lhs, const Clipper2Lib::Point64* rhs) const
{
return lhs->x < rhs->x || (lhs->x == rhs->x && lhs->y < rhs->y);
}
};
std::set<const Clipper2Lib::Point64*, point64_less> pointSets;
for (auto&& p2 : out)
{
if (!p2->IsHole())
{
outPoints.reserve(outPoints.size() + p2->Polygon().size());
for (auto&& so : p2->Polygon())
{
if(pointSets.emplace(&so).second)
outPoints.emplace_back(so.x / PRECISION, so.y / PRECISION);
}
}
else
{
AXLOG("Clipper2 detect a hole!");
}
}
@halx99 Thanks. I have seen it too. But no time at the Moment
Edit:
Clipper has: cl.StrictlySimple(true);
Clipper2 not.
For me its looks more as a "bug/Missing function" of Clipper2 or a wrong implementation on AutoPolygon::expand.
I dont want add a "workaround" without ask the Clipper2 developer too.
=> I have to write an 'example' for the clipper2 issue stuff
About duplicates outPoints, refer to
@halx99 Thanks. I have seen it too. But no time at the Moment
Edit: Clipper has:
cl.StrictlySimple(true);
Clipper2 not. For me its looks more as a "bug/Missing function" of Clipper2 or a wrong implementation on AutoPolygon::expand. I dont want add a "workaround" without ask the Clipper2 developer too. => I have to write an 'example' for the clipper2 issue stuff
You can ask the clipper2 developer.
Maybe this "function" helps: (not tested)
Clipper2Lib::SimplifyPath(out.Polygon(), epsilon, false);
If yes -> performance will be interesting
I have tested it and it looks very fast!
Changing also the tester: (0.5 => 1.0)
auto pinfo = AutoPolygon::generatePolygon("Images/sprite_polygon_crash.png", Rect::ZERO, 1.0);
Can you send me the code snippet for this performance line too?
* ##################### outPoints count: 5827, cost 43.250 (ms)
with
Clipper2Lib::SimplifyPath(out.Polygon(), epsilon, false);
auto pinfo = AutoPolygon::generatePolygon("Images/sprite_polygon_crash.png", Rect::ZERO, 2.0);
it looks also "fine" and its very very fast (of course!) only 13419 vertices
with epsilon 1.0:
##################### outPoints count: 5827, cost 43.250 (ms)
it's the original clipper2 perf
with
Clipper2Lib::SimplifyPath(out.Polygon(), epsilon, false); auto pinfo = AutoPolygon::generatePolygon("Images/sprite_polygon_crash.png", Rect::ZERO, 2.0);
it looks also "fine" and its very very fast (of course!) only 13419 vertices
will test on my machine with your solution
Notes: upstream: https://github.com/axmolengine/axmol/commit/0bb8c89ef350fa233b04850f9008337e68e4d5bc
#################### #outPoints count : 5813, cost 41.439(ms)
#################### #outPoints count : 5813, cost 42.136(ms)
#################### #outPoints count : 5813, cost 41.424(ms)
#################### #outPoints count : 5813, cost 41.933(ms)
#################### #outPoints count : 5813, cost 41.414(ms)
#################### #outPoints count : 5813, cost 41.721(ms)
Clipper2Lib::SimplifyPath(out.Polygon(), epsilon, false);
Still crash with the code snippet:
std::vector<Vec2> outPoints;
for (auto&& p2 : out)
{
if (!p2->IsHole())
{
Clipper2Lib::SimplifyPath(p2->Polygon(), epsilon, false);
outPoints.reserve(outPoints.size() + p2->Polygon().size());
for (auto&& so : p2->Polygon())
{
outPoints.emplace_back(so.x / PRECISION, so.y / PRECISION);
}
}
else
{
AXLOG("Clipper2 detect a hole!");
}
}
latest
48 node::SpritePloygon -> after 7