[sfml] Fix clipping

This commit is contained in:
Mario Zechner 2025-06-02 18:38:16 +02:00
parent d33c10f856
commit b01bac8332
3 changed files with 11 additions and 5 deletions

View File

@ -79,7 +79,7 @@ Vector<int> &Triangulator::triangulate(Vector<float> &vertices) {
if (!isConcaveArray[ii]) continue; if (!isConcaveArray[ii]) continue;
int v = indices[ii] << 1; int v = indices[ii] << 1;
float &vx = vertices[v], vy = vertices[v + 1]; float vx = vertices[v], vy = vertices[v + 1];
if (positiveArea(p3x, p3y, p1x, p1y, vx, vy)) { if (positiveArea(p3x, p3y, p1x, p1y, vx, vy)) {
if (positiveArea(p1x, p1y, p2x, p2y, vx, vy)) { if (positiveArea(p1x, p1y, p2x, p2y, vx, vy)) {
if (positiveArea(p2x, p2y, p3x, p3y, vx, vy)) { if (positiveArea(p2x, p2y, p3x, p3y, vx, vy)) {

View File

@ -125,10 +125,13 @@ void SkeletonDrawable::draw (RenderTarget& target, RenderStates states) const {
for (int i = 0; i < skeleton->slotsCount; ++i) { for (int i = 0; i < skeleton->slotsCount; ++i) {
Slot* slot = skeleton->drawOrder[i]; Slot* slot = skeleton->drawOrder[i];
Attachment* attachment = slot->attachment; Attachment* attachment = slot->attachment;
if (!attachment) continue; if (!attachment) {
spSkeletonClipping_clipEnd(clipper, slot);
continue;
}
// Early out if slot is invisible // Early out if slot is invisible
if (slot->color.a == 0 || !slot->bone->active) { if ((slot->color.a == 0 || !slot->bone->active) && attachment->type != SP_ATTACHMENT_CLIPPING) {
spSkeletonClipping_clipEnd(clipper, slot); spSkeletonClipping_clipEnd(clipper, slot);
continue; continue;
} }

View File

@ -100,10 +100,13 @@ void SkeletonDrawable::draw(RenderTarget &target, RenderStates states) const {
for (unsigned i = 0; i < skeleton->getSlots().size(); ++i) { for (unsigned i = 0; i < skeleton->getSlots().size(); ++i) {
Slot &slot = *skeleton->getDrawOrder()[i]; Slot &slot = *skeleton->getDrawOrder()[i];
Attachment *attachment = slot.getAttachment(); Attachment *attachment = slot.getAttachment();
if (!attachment) continue; if (!attachment) {
clipper.clipEnd(slot);
continue;
}
// Early out if the slot color is 0 or the bone is not active // Early out if the slot color is 0 or the bone is not active
if (slot.getColor().a == 0 || !slot.getBone().isActive()) { if ((slot.getColor().a == 0 || !slot.getBone().isActive()) && !attachment->getRTTI().isExactly(ClippingAttachment::rtti)) {
clipper.clipEnd(slot); clipper.clipEnd(slot);
continue; continue;
} }