This is a consistent and reproducible bug with the decomposedPoly method - for some shapes, the convex decomposition creates shapes that fail the area < b2_epsilon assert and report this error:
Assertion failed: (area > b2_epsilon), function ComputeCentroid, file ../Box2D/Collision/Shapes/b2PolygonShape.cpp, line 115.
[object AlchemyExit]
at Function/<anonymous>()
at Function/<anonymous>()
at Box2DAS.Collision.Shapes::b2PolygonShape$/Decompose()
at wck::BodyShape/decomposedPoly()
at MyShape/create()
at misc::Entity/ensureCreated()
at Function/<anonymous>()
This can be reproduced by adding an instance of MyShape to a world with the following code for MyShape:
Sorry for the weird shape, it was sent to me by a friend. Any ideas about why this shape (and some other strange shapes) break the decomposed poly function?
EDIT: Even though the shape seems small, that is not the problem - it is actually a decent size since my world scale is set to 1, but you can confirm it's not the scale of the object by just scaling it up. Adding this line before the decomposedPoly call changes the scale:
Assertion failed: (area > b2_epsilon), function ComputeCentroid, file ../Box2D/Collision/Shapes/b2PolygonShape.cpp, line 115.
[object AlchemyExit]
at Function/<anonymous>()
at Function/<anonymous>()
at Box2DAS.Collision.Shapes::b2PolygonShape$/Decompose()
at wck::BodyShape/decomposedPoly()
at MyShape/create()
at misc::Entity/ensureCreated()
at Function/<anonymous>()
This can be reproduced by adding an instance of MyShape to a world with the following code for MyShape:
Code:
package {
import wck.BodyShape ;
public class MyShape extends BodyShape {
public override function create():void {
super.create();
var coords:Vector.<Number> = new Vector.<Number>();
coords.push(0,0,
-0.05166666582226753,0,
-0.11166666448116302,0.02666666731238365,
-0.14166666567325592,0.05249999836087227,
-0.1941666603088379,0.1158333346247673,
-0.2241666615009308,0.18000000715255737,
-0.23916666209697723,0.2316666692495346,
-0.25,0.42250001430511475,
-0.21250000596046448,0.4333333373069763,
-0.13249999284744263,0.49000000953674316,
-0.07999999821186066,0.5049999952316284,
-0.03750000149011612,0.512499988079071,
0.007499999832361937,0.5083333253860474,
0.03583333268761635,0.4749999940395355,
0.05833333358168602,0.4449999928474426,
0.07333333045244217,0.4333333373069763,
0.10000000149011612,0.36666667461395264,
0.10750000178813934,0.33666667342185974,
0.11166666448116302,0.15333333611488342,
0.09666666388511658,0.07083333283662796,
0.05999999865889549,0.02666666731238365,
0.034166667610406876,0.011666666716337204,
0.028333334252238274,0,
-0.012500000186264515,0);
decomposedPoly(coords);
}
}
}
import wck.BodyShape ;
public class MyShape extends BodyShape {
public override function create():void {
super.create();
var coords:Vector.<Number> = new Vector.<Number>();
coords.push(0,0,
-0.05166666582226753,0,
-0.11166666448116302,0.02666666731238365,
-0.14166666567325592,0.05249999836087227,
-0.1941666603088379,0.1158333346247673,
-0.2241666615009308,0.18000000715255737,
-0.23916666209697723,0.2316666692495346,
-0.25,0.42250001430511475,
-0.21250000596046448,0.4333333373069763,
-0.13249999284744263,0.49000000953674316,
-0.07999999821186066,0.5049999952316284,
-0.03750000149011612,0.512499988079071,
0.007499999832361937,0.5083333253860474,
0.03583333268761635,0.4749999940395355,
0.05833333358168602,0.4449999928474426,
0.07333333045244217,0.4333333373069763,
0.10000000149011612,0.36666667461395264,
0.10750000178813934,0.33666667342185974,
0.11166666448116302,0.15333333611488342,
0.09666666388511658,0.07083333283662796,
0.05999999865889549,0.02666666731238365,
0.034166667610406876,0.011666666716337204,
0.028333334252238274,0,
-0.012500000186264515,0);
decomposedPoly(coords);
}
}
}
Sorry for the weird shape, it was sent to me by a friend. Any ideas about why this shape (and some other strange shapes) break the decomposed poly function?
EDIT: Even though the shape seems small, that is not the problem - it is actually a decent size since my world scale is set to 1, but you can confirm it's not the scale of the object by just scaling it up. Adding this line before the decomposedPoly call changes the scale:
Code:
for(var i:uint=0; i<coords.length; i++) coords[i] *= 1000.0;