Giter Site home page Giter Site logo

Comments (10)

dev7355608 avatar dev7355608 commented on August 19, 2024

Please share some code with me that allows me to reproduce this error.

from graphics-smooth.

ivanpopelyshev avatar ivanpopelyshev commented on August 19, 2024

OMG how! please demo

from graphics-smooth.

dev7355608 avatar dev7355608 commented on August 19, 2024

@ivanpopelyshev Today a non-polygon hole in a polygon shape was giving me the same error. I tracked that down to the fact that the holes use the line command of the shape instead of the one matching its type. Fixed that. But then I noticed why it failed so terribly: because data.closeStroke was false. Then I tried to draw non-closed polygons: those are not rendering at all. Something goes wrong in PolyBuilder#line if closeStroke is false.

let p = new PIXI.Polygon([0, 0, 100, 0, 100, 100, 0, 100]);

p.closeStroke = false;

let g = app.stage.addChild(new PIXI.smooth.SmoothGraphics()
        .lineStyle(1)
        .beginFill(0xffffff)
        .drawPolygon(p)
        .endFill());

from graphics-smooth.

ivanpopelyshev avatar ivanpopelyshev commented on August 19, 2024

Oh, interesting

from graphics-smooth.

dev7355608 avatar dev7355608 commented on August 19, 2024

@ivanpopelyshev I figured out why this error happens and fixed it with a19cda7: joint should be endJoint. The code produced a FILL joint, because it increased a NONE joint by one if closeStroke was false; therefore hasTriangle became true in the segment packer, which corrupted index buffer.

But after changing joint to endJoint there is still something wrong with the MITER joint:
image
I'm not quite sure what exactly is happening here in this part of the code. If I comment it out, the line is rendered correctly.

if (endJoint === JOINT_TYPE.JOINT_MITER)
{
let jointAdd = 0;
if (dx3 * dx + dy3 * dy > -eps)
{
jointAdd++;
}
if (endJoint === JOINT_TYPE.JOINT_MITER && dx2 * dx + dy2 * dy > -eps)
{
jointAdd += 2;
}
endJoint += jointAdd;
}

from graphics-smooth.

dev7355608 avatar dev7355608 commented on August 19, 2024

@ivanpopelyshev I'm considering to remove this code entirely:

if (joint >= JOINT_TYPE.JOINT_BEVEL && joint <= JOINT_TYPE.JOINT_MITER)
{
const dx2 = nextX - x2;
const dy2 = nextY - y2;
if (endJoint >= JOINT_TYPE.JOINT_BEVEL
&& endJoint <= JOINT_TYPE.JOINT_MITER + 3)
{
const D = dx2 * dy - dy2 * dx;
if (Math.abs(D) < eps)
{
switch (joint & ~3)
{
case JOINT_TYPE.JOINT_ROUND:
endJoint = JOINT_TYPE.JOINT_CAP_ROUND;
break;
default:
endJoint = JOINT_TYPE.JOINT_CAP_BUTT;
break;
}
}
}
if (joint === JOINT_TYPE.JOINT_MITER)
{
let jointAdd = 0;
if (dx3 * dx + dy3 * dy > -eps)
{
jointAdd++;
}
if (endJoint === JOINT_TYPE.JOINT_MITER && dx2 * dx + dy2 * dy > -eps)
{
jointAdd += 2;
}
endJoint += jointAdd;
}
}
if (prevCap === 0)
{
if (Math.abs(dx3 * dy - dy3 * dx) < eps)
{
prevCap = JOINT_TYPE.CAP_BUTT2;
}
}

It seems to work fine without it, and it is flawed, but I'm not so sure exactly what it is supposed to do. Do you think it's safe to delete this code?

from graphics-smooth.

ivanpopelyshev avatar ivanpopelyshev commented on August 19, 2024

Oh, hi! Thanks for checking up on me.

Yes, its one of things i coded in beginning that i didnt fix yet. You can remove it if you test degenerate cases like "line goes there and back"

UPD: i think it was idea like "if bevel is good enough, use good miter instead, without a joint". It shouldnt affect things because we already are using instancing, right? or did i forget to enable it here?

from graphics-smooth.

dev7355608 avatar dev7355608 commented on August 19, 2024

The degenerate test in the examples looks good if I remove this part of the code. I tried all join and cap combinations. Then I can proceed to remove it?

I'm not very familiar with this joint stuff yet. MITER + 3 is higher quality? But this looked odd to me:

verts[JOINT_TYPE.JOINT_MITER] = 4 + 5;
verts[JOINT_TYPE.JOINT_MITER + 1] = 4 + 5;
verts[JOINT_TYPE.JOINT_MITER + 2] = 4;
verts[JOINT_TYPE.JOINT_MITER + 3] = 4;

+2 and +3 have less vertices. This the only joint type that has different vertex counts.

from graphics-smooth.

ivanpopelyshev avatar ivanpopelyshev commented on August 19, 2024

Yes, it was there to save vertices. I agree to remove it because , whether instancing is implemented or not - it will make this "optimization" worseless soon

from graphics-smooth.

dev7355608 avatar dev7355608 commented on August 19, 2024

Fixed in 0.0.26.

from graphics-smooth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.