Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/chipmunk/cpPolyShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ CP_EXPORT cpVect cpPolyShapeGetVert(const cpShape *shape, int index);
/// Get the radius of a polygon shape.
CP_EXPORT cpFloat cpPolyShapeGetRadius(const cpShape *shape);

/// Query if shape is a polygon shape.
CP_EXPORT cpBool cpShapeIsPoly(const cpShape *shape);

/// @}
6 changes: 6 additions & 0 deletions include/chipmunk/cpShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ CP_EXPORT cpVect cpCircleShapeGetOffset(const cpShape *shape);
/// Get the radius of a circle shape.
CP_EXPORT cpFloat cpCircleShapeGetRadius(const cpShape *shape);

/// Query if shape is a polygon shape.
CP_EXPORT cpBool cpShapeIsCircle(const cpShape *shape);

/// @}
/// @defgroup cpSegmentShape cpSegmentShape

Expand All @@ -196,4 +199,7 @@ CP_EXPORT cpVect cpSegmentShapeGetNormal(const cpShape *shape);
/// Get the first endpoint of a segment shape.
CP_EXPORT cpFloat cpSegmentShapeGetRadius(const cpShape *shape);

/// Query if shape is a segment shape.
CP_EXPORT cpBool cpShapeIsSegment(const cpShape *shape);

/// @}
6 changes: 6 additions & 0 deletions src/cpPolyShape.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,9 @@ cpPolyShapeSetRadius(cpShape *shape, cpFloat radius)
// shape->massInfo = cpPolyShapeMassInfo(shape->massInfo.m, poly->count, poly->verts, poly->r);
// if(mass > 0.0f) cpBodyAccumulateMassFromShapes(shape->body);
}

cpBool
cpShapeIsPoly(const cpShape *shape)
{
return shape->klass == &polyClass;
}
11 changes: 11 additions & 0 deletions src/cpShape.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ cpCircleShapeGetRadius(const cpShape *shape)
return ((cpCircleShape *)shape)->r;
}

cpBool
cpShapeIsCircle(const cpShape *shape)
{
return shape->klass == &cpCircleShapeClass;
}

cpSegmentShape *
cpSegmentShapeAlloc(void)
Expand Down Expand Up @@ -602,3 +607,9 @@ cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius)
shape->massInfo = cpSegmentShapeMassInfo(shape->massInfo.m, seg->a, seg->b, seg->r);
if(mass > 0.0f) cpBodyAccumulateMassFromShapes(shape->body);
}

cpBool
cpShapeIsSegment(const cpShape *shape)
{
return shape->klass == &cpSegmentShapeClass;
}