Shape#

struct nvShape#

Collision shape.

Public Members

nvShapeType type#

Type of the shape

nv_float radius#

Circle radius.

nvArray *vertices#

Polygon local vertices.

nvArray *trans_vertices#

Polygon transformed vertices.

nvArray *normals#

Polygon edge normals.

Enums#

enum nvShapeType#

Shape type enumerator.

Values:

enumerator nvShapeType_CIRCLE#

Circle shape. It’s the simplest collision shape.

enumerator nvShapeType_POLYGON#

Convex polygon shape. It’s more complex than circle shape and the calculations gets more expensive as the vertex count goes higher.

Methods#

nvShape *nvCircleShape_new(nv_float radius)#

Create a new circle shape.

Parameters:

radius – Radius of the circle

Returns:

nvShape *

nvShape *nvPolygonShape_new(nvArray *vertices)#

Create a new convex polygon shape.

Parameters:

vertices – Array of vertices

Returns:

nvShape *

nvShape *nvRectShape_new(nv_float width, nv_float height)#

Create a new polygon shape that is a rectangle.

Parameters:
  • width – Width

  • height – Height

Returns:

nvShape *

nvBoxShape_new(width, height)#

Create a new polygon shape that is a rectangle. Alias for nvRectShape_new.

Parameters:
  • width – Width

  • height – Height

Returns:

nvShape *

nvShape *nvNGonShape_new(size_t n, nv_float radius)#

Create a new polygon shape that is a regular n-gon.

Parameters:
  • n – Number of vertices or edges

  • radius – Length of a vertex from the centroid

Returns:

nvShape *

nvShape *nvConvexHullShape_new(nvArray *points)#

Create a new polygon shape from a convex hull of an array of points.

Parameters:

points – Points to generate a convex hull from

Returns:

nvShape *

void nvShape_free(nvShape *shape)#

Free shape.

Parameters:

shape – Shape