diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 5f8909e..61f0588 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -147,15 +147,25 @@ { if(data.points.length >= 6) { - if(data.points.length > 5 * 2) + if(data.points.length < 6 * 2) { - webGLData = PIXI.WebGLGraphics.switchMode(webGL, 1); - PIXI.WebGLGraphics.buildComplexPoly(data, webGLData); + webGLData = PIXI.WebGLGraphics.switchMode(webGL, 0); + + var canDrawUsingSimple = PIXI.WebGLGraphics.buildPoly(data, webGLData); + // console.log(canDrawUsingSimple); + + if(!canDrawUsingSimple) + { + // console.log("<>>>") + webGLData = PIXI.WebGLGraphics.switchMode(webGL, 1); + PIXI.WebGLGraphics.buildComplexPoly(data, webGLData); + } + } else { - webGLData = PIXI.WebGLGraphics.switchMode(webGL, 0); - PIXI.WebGLGraphics.buildPoly(data, webGLData); + webGLData = PIXI.WebGLGraphics.switchMode(webGL, 1); + PIXI.WebGLGraphics.buildComplexPoly(data, webGLData); } } } @@ -803,6 +813,9 @@ var b = color[2] * alpha; var triangles = PIXI.PolyK.Triangulate(points); + + if(!triangles)return false; + var vertPos = verts.length / 6; var i = 0; @@ -822,6 +835,7 @@ r, g, b, alpha); } + return true; }; PIXI.WebGLGraphics.graphicsDataPool = []; diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 5f8909e..61f0588 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -147,15 +147,25 @@ { if(data.points.length >= 6) { - if(data.points.length > 5 * 2) + if(data.points.length < 6 * 2) { - webGLData = PIXI.WebGLGraphics.switchMode(webGL, 1); - PIXI.WebGLGraphics.buildComplexPoly(data, webGLData); + webGLData = PIXI.WebGLGraphics.switchMode(webGL, 0); + + var canDrawUsingSimple = PIXI.WebGLGraphics.buildPoly(data, webGLData); + // console.log(canDrawUsingSimple); + + if(!canDrawUsingSimple) + { + // console.log("<>>>") + webGLData = PIXI.WebGLGraphics.switchMode(webGL, 1); + PIXI.WebGLGraphics.buildComplexPoly(data, webGLData); + } + } else { - webGLData = PIXI.WebGLGraphics.switchMode(webGL, 0); - PIXI.WebGLGraphics.buildPoly(data, webGLData); + webGLData = PIXI.WebGLGraphics.switchMode(webGL, 1); + PIXI.WebGLGraphics.buildComplexPoly(data, webGLData); } } } @@ -803,6 +813,9 @@ var b = color[2] * alpha; var triangles = PIXI.PolyK.Triangulate(points); + + if(!triangles)return false; + var vertPos = verts.length / 6; var i = 0; @@ -822,6 +835,7 @@ r, g, b, alpha); } + return true; }; PIXI.WebGLGraphics.graphicsDataPool = []; diff --git a/src/pixi/utils/Polyk.js b/src/pixi/utils/Polyk.js index 0e150b2..838e6a2 100644 --- a/src/pixi/utils/Polyk.js +++ b/src/pixi/utils/Polyk.js @@ -107,8 +107,8 @@ } else { - window.console.log("PIXI Warning: shape too complex to fill"); - return []; + // window.console.log("PIXI Warning: shape too complex to fill"); + return null; } } }