Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
Update box2d_wrapper.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ughuuu committed Mar 1, 2024
1 parent 65ae790 commit 9f10c29
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/box2d-wrapper/box2d_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,9 @@ ShapeHandle box2d::shape_create_circle(real_t radius, b2Vec2 pos) {
ShapeHandle box2d::shape_create_concave_polyline(const b2Vec2 *points, size_t point_count) {
b2Hull hull;
ERR_FAIL_COND_V(point_count > b2_maxPolygonVertices, invalid_shape_handle());
std::copy(&hull.points[0], &hull.points[point_count], points);
for (int i = 0; i < point_count; i++) {
hull.points[i] = points[i];
}
hull.count = point_count;
b2Polygon polygon_shape = b2MakePolygon(&hull, 0.0);
return ShapeHandle{
Expand All @@ -1051,7 +1053,9 @@ ShapeHandle box2d::shape_create_concave_polyline(const b2Vec2 *points, size_t po
ShapeHandle box2d::shape_create_convex_polyline(const b2Vec2 *points, size_t point_count) {
b2Hull hull;
ERR_FAIL_COND_V(point_count > b2_maxPolygonVertices, invalid_shape_handle());
std::copy(&hull.points[0], &hull.points[point_count], points);
for (int i = 0; i < point_count; i++) {
hull.points[i] = points[i];
}
hull.count = point_count;
b2Polygon polygon_shape = b2MakePolygon(&hull, 0.0);
return ShapeHandle{
Expand All @@ -1076,7 +1080,9 @@ ShapeHandle box2d::shape_create_halfspace(const b2Vec2 normal, real_t distance)

b2Hull hull;
ERR_FAIL_COND_V(4 > b2_maxPolygonVertices, invalid_shape_handle());
std::copy(&hull.points[0], &hull.points[4], points);
for (int i = 0; i < 4; i++) {
hull.points[i] = points[i];
}
hull.count = 4;
b2Polygon polygon_shape = b2MakePolygon(&hull, 0.0);
return ShapeHandle{
Expand Down

0 comments on commit 9f10c29

Please sign in to comment.