Skip to content
Browse files

Moved some asserts to a better place

  • Loading branch information...
1 parent f128d61 commit d2c84af9f84f705392fd4d99d15057036c5ef64e @josephg committed Feb 2, 2013
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/cpPolyShape.js
View
12 lib/cpPolyShape.js
@@ -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);
@@ -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;

0 comments on commit d2c84af

Please sign in to comment.
Something went wrong with that request. Please try again.