Skip to content

Commit

Permalink
Moved some asserts to a better place
Browse files Browse the repository at this point in the history
  • Loading branch information
josephg committed Feb 2, 2013
1 parent f128d61 commit d2c84af
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/cpPolyShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ var polyValidate = function(verts)
/// The vertexes must be convex and have a clockwise winding.
var PolyShape = cp.PolyShape = function(body, verts, offset)
{
assert(verts.length >= 4, "Polygons require some verts");
assert(typeof(verts[0]) === 'number', 'Polygon verticies should be specified in a flattened list');
// Fail if the user attempts to pass a concave poly, or a bad winding.
assert(polyValidate(verts), "Polygon is concave or has a reversed winding.");

this.setVerts(verts, offset);
this.type = 'poly';
Shape.call(this, body);
Expand All @@ -69,6 +64,13 @@ SplittingPlane.prototype.compare = function(v)

PolyShape.prototype.setVerts = function(verts, offset)
{
assert(verts.length >= 4, "Polygons require some verts");
assert(typeof(verts[0]) === 'number',
'Polygon verticies should be specified in a flattened list (eg [x1,y1,x2,y2,x3,y3,...])');

// Fail if the user attempts to pass a concave poly, or a bad winding.
assert(polyValidate(verts), "Polygon is concave or has a reversed winding. Consider using cpConvexHull()");

var len = verts.length;
var numVerts = len >> 1;

Expand Down

0 comments on commit d2c84af

Please sign in to comment.