Search code examples
cchipmunk

use of undeclared identifier 'cpPolyShapeGetNumVerts'


I am trying to use cpPolyShapeGetNumVerts on Chipmunk2D 7.X and it seems it was removed.

How can I replace it?


Solution

  • The answer is

      const auto position = cpBodyGetPosition(_props.body.get());
      const int count = cpPolyShapeGetCount(_props.shape.get());
    
      std::vector<cpVect> vertices(count);
      for (int i = 0; i < count; ++i) {
        vertices[i] = cpPolyShapeGetVert(_props.shape.get(), i);
      }