<commit_before>#include "wrap_body.hpp"

#include "wrap_vertex_array.hpp"

#include <boost/python.hpp>
#include <Box2D/Collision/Shapes/b2CircleShape.h>
#include <Box2D/Collision/Shapes/b2EdgeShape.h>
#include <Box2D/Collision/Shapes/b2LoopShape.h>
#include <Box2D/Collision/Shapes/b2PolygonShape.h>
#include <Box2D/Dynamics/b2Fixture.h>
#include <Box2D/Dynamics/b2Body.h>
#include <Box2D/Dynamics/b2World.h>
#include <Box2D/Dynamics/Contacts/b2Contact.h>
#include <Box2D/Dynamics/Joints/b2Joint.h>

using namespace boost::python;

namespace pysics {
    void wrap_body_type()
    {
        enum_<b2BodyType>("BodyType")
            .value("STATIC_BODY", b2_staticBody)
            .value("KINEMATIC_BODY", b2_kinematicBody)
            .value("DYNAMIC_BODY", b2_dynamicBody)
            .export_values()
        ;
    }

    b2Fixture *create_fixture(b2Body *body,
                              b2Shape *shape,
                              b2UserData user_data,
                              float32 friction,
                              float32 restitution,
                              float32 density,
                              bool sensor,
                              uint16 category_bits,
                              uint16 mask_bits,
                              uint16 group_index)
    {
        b2FixtureDef fixture_def;
        fixture_def.shape = shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;
        return body->CreateFixture(&fixture_def);
    }

    b2Fixture *create_circle_fixture(b2Body *body,
                                     b2Vec2 position,
                                     float32 radius,
                                     b2UserData user_data,
                                     float32 friction,
                                     float32 restitution,
                                     float32 density,
                                     bool sensor,
                                     uint16 category_bits,
                                     uint16 mask_bits,
                                     uint16 group_index)
    {
        b2CircleShape circle_shape;
        circle_shape.m_p = position;
        circle_shape.m_radius = radius;

        b2FixtureDef fixture_def;
        fixture_def.shape = &circle_shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;

        return body->CreateFixture(&fixture_def);
    }

    b2Fixture *create_edge_fixture(b2Body *body,
                                   b2Vec2 vertex_1,
                                   b2Vec2 vertex_2,
                                   b2UserData user_data,
                                   float32 friction,
                                   float32 restitution,
                                   float32 density,
                                   bool sensor,
                                   uint16 category_bits,
                                   uint16 mask_bits,
                                   uint16 group_index)
    {
        b2EdgeShape edge_shape;
        edge_shape.m_vertex1 = vertex_1;
        edge_shape.m_vertex2 = vertex_2;

        b2FixtureDef fixture_def;
        fixture_def.shape = &edge_shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;

        return body->CreateFixture(&fixture_def);
    }

    namespace {
        void set_vertices(b2PolygonShape *polygon_shape, list vertices)
        {
            b2Vec2 arr[b2_maxPolygonVertices];
            long n = len(vertices);
            for (long i = 0; i != n; ++i) {
                arr[i] = extract<b2Vec2>(vertices[i]);
            }
            polygon_shape->Set(arr, n);
        }
    }

    b2Fixture *create_polygon_fixture(b2Body *body,
                                      list vertices,
                                      b2UserData user_data,
                                      float32 friction,
                                      float32 restitution,
                                      float32 density,
                                      bool sensor,
                                      uint16 category_bits,
                                      uint16 mask_bits,
                                      uint16 group_index)
    {
        b2PolygonShape polygon_shape;
        if (len(vertices)) {
            set_vertices(&polygon_shape, vertices);
        } else {
            polygon_shape.SetAsBox(1.0f, 1.0f);
        }

        b2FixtureDef fixture_def;
        fixture_def.shape = &polygon_shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;

        return body->CreateFixture(&fixture_def);
    }

    b2Fixture *create_loop_fixture(b2Body *body,
                                   VertexArray vertices,
                                   b2UserData user_data,
                                   float32 friction,
                                   float32 restitution,
                                   float32 density,
                                   bool sensor,
                                   uint16 category_bits,
                                   uint16 mask_bits,
                                   uint16 group_index)
    {
        b2LoopShape loop_shape;
        loop_shape.m_vertices = vertices.ptr();
        loop_shape.m_count = vertices.size();

        b2FixtureDef fixture_def;
        fixture_def.shape = &loop_shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;

        return body->CreateFixture(&fixture_def);
    }

    void wrap_body()
    {
        b2Fixture *(b2Body::*get_fixture_list)() = &b2Body::GetFixtureList;
        b2JointEdge *(b2Body::*get_joint_list)() = &b2Body::GetJointList;
        b2ContactEdge *(b2Body::*get_contact_list)() = &b2Body::GetContactList;
        b2Body *(b2Body::*get_next)() = &b2Body::GetNext;
        b2World *(b2Body::*get_world)() = &b2Body::GetWorld;

        class_<b2Body, boost::noncopyable>("Body", no_init)
            .def("create_fixture", &create_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("shape"),
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=1.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,
                  arg("mask_bits")=0xffff,
                  arg("group_index")=0))
            .def("create_circle_fixture", &create_circle_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("position")=b2Vec2(0.0f, 0.0f),
                  arg("radius")=1.0f,
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=1.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,
                  arg("mask_bits")=0xffff,
                  arg("group_index")=0))
            .def("create_edge_fixture", &create_edge_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("vertex_1")=b2Vec2(0.0f, 0.0f),
                  arg("vertex_2")=b2Vec2(0.0f, 0.0f),
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=1.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,
                  arg("mask_bits")=0xffff,
                  arg("group_index")=0))
            .def("create_polygon_fixture", &create_polygon_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("vertices")=list(),
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=1.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,
                  arg("mask_bits")=0xffff,
                  arg("group_index")=0))
            .def("create_loop_fixture", &create_loop_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("vertices"),
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=1.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,<commit_msg>reverted default density to zero<commit_after>#include "wrap_body.hpp"

#include "wrap_vertex_array.hpp"

#include <boost/python.hpp>
#include <Box2D/Collision/Shapes/b2CircleShape.h>
#include <Box2D/Collision/Shapes/b2EdgeShape.h>
#include <Box2D/Collision/Shapes/b2LoopShape.h>
#include <Box2D/Collision/Shapes/b2PolygonShape.h>
#include <Box2D/Dynamics/b2Fixture.h>
#include <Box2D/Dynamics/b2Body.h>
#include <Box2D/Dynamics/b2World.h>
#include <Box2D/Dynamics/Contacts/b2Contact.h>
#include <Box2D/Dynamics/Joints/b2Joint.h>

using namespace boost::python;

namespace pysics {
    void wrap_body_type()
    {
        enum_<b2BodyType>("BodyType")
            .value("STATIC_BODY", b2_staticBody)
            .value("KINEMATIC_BODY", b2_kinematicBody)
            .value("DYNAMIC_BODY", b2_dynamicBody)
            .export_values()
        ;
    }

    b2Fixture *create_fixture(b2Body *body,
                              b2Shape *shape,
                              b2UserData user_data,
                              float32 friction,
                              float32 restitution,
                              float32 density,
                              bool sensor,
                              uint16 category_bits,
                              uint16 mask_bits,
                              uint16 group_index)
    {
        b2FixtureDef fixture_def;
        fixture_def.shape = shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;
        return body->CreateFixture(&fixture_def);
    }

    b2Fixture *create_circle_fixture(b2Body *body,
                                     b2Vec2 position,
                                     float32 radius,
                                     b2UserData user_data,
                                     float32 friction,
                                     float32 restitution,
                                     float32 density,
                                     bool sensor,
                                     uint16 category_bits,
                                     uint16 mask_bits,
                                     uint16 group_index)
    {
        b2CircleShape circle_shape;
        circle_shape.m_p = position;
        circle_shape.m_radius = radius;

        b2FixtureDef fixture_def;
        fixture_def.shape = &circle_shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;

        return body->CreateFixture(&fixture_def);
    }

    b2Fixture *create_edge_fixture(b2Body *body,
                                   b2Vec2 vertex_1,
                                   b2Vec2 vertex_2,
                                   b2UserData user_data,
                                   float32 friction,
                                   float32 restitution,
                                   float32 density,
                                   bool sensor,
                                   uint16 category_bits,
                                   uint16 mask_bits,
                                   uint16 group_index)
    {
        b2EdgeShape edge_shape;
        edge_shape.m_vertex1 = vertex_1;
        edge_shape.m_vertex2 = vertex_2;

        b2FixtureDef fixture_def;
        fixture_def.shape = &edge_shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;

        return body->CreateFixture(&fixture_def);
    }

    namespace {
        void set_vertices(b2PolygonShape *polygon_shape, list vertices)
        {
            b2Vec2 arr[b2_maxPolygonVertices];
            long n = len(vertices);
            for (long i = 0; i != n; ++i) {
                arr[i] = extract<b2Vec2>(vertices[i]);
            }
            polygon_shape->Set(arr, n);
        }
    }

    b2Fixture *create_polygon_fixture(b2Body *body,
                                      list vertices,
                                      b2UserData user_data,
                                      float32 friction,
                                      float32 restitution,
                                      float32 density,
                                      bool sensor,
                                      uint16 category_bits,
                                      uint16 mask_bits,
                                      uint16 group_index)
    {
        b2PolygonShape polygon_shape;
        if (len(vertices)) {
            set_vertices(&polygon_shape, vertices);
        } else {
            polygon_shape.SetAsBox(1.0f, 1.0f);
        }

        b2FixtureDef fixture_def;
        fixture_def.shape = &polygon_shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;

        return body->CreateFixture(&fixture_def);
    }

    b2Fixture *create_loop_fixture(b2Body *body,
                                   VertexArray vertices,
                                   b2UserData user_data,
                                   float32 friction,
                                   float32 restitution,
                                   float32 density,
                                   bool sensor,
                                   uint16 category_bits,
                                   uint16 mask_bits,
                                   uint16 group_index)
    {
        b2LoopShape loop_shape;
        loop_shape.m_vertices = vertices.ptr();
        loop_shape.m_count = vertices.size();

        b2FixtureDef fixture_def;
        fixture_def.shape = &loop_shape;
        fixture_def.userData = user_data;
        fixture_def.friction = friction;
        fixture_def.restitution = restitution;
        fixture_def.density = density;
        fixture_def.isSensor = sensor;
        fixture_def.filter.categoryBits = category_bits;
        fixture_def.filter.maskBits = mask_bits;
        fixture_def.filter.groupIndex = group_index;

        return body->CreateFixture(&fixture_def);
    }

    void wrap_body()
    {
        b2Fixture *(b2Body::*get_fixture_list)() = &b2Body::GetFixtureList;
        b2JointEdge *(b2Body::*get_joint_list)() = &b2Body::GetJointList;
        b2ContactEdge *(b2Body::*get_contact_list)() = &b2Body::GetContactList;
        b2Body *(b2Body::*get_next)() = &b2Body::GetNext;
        b2World *(b2Body::*get_world)() = &b2Body::GetWorld;

        class_<b2Body, boost::noncopyable>("Body", no_init)
            .def("create_fixture", &create_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("shape"),
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=0.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,
                  arg("mask_bits")=0xffff,
                  arg("group_index")=0))
            .def("create_circle_fixture", &create_circle_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("position")=b2Vec2(0.0f, 0.0f),
                  arg("radius")=1.0f,
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=0.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,
                  arg("mask_bits")=0xffff,
                  arg("group_index")=0))
            .def("create_edge_fixture", &create_edge_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("vertex_1")=b2Vec2(0.0f, 0.0f),
                  arg("vertex_2")=b2Vec2(0.0f, 0.0f),
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=0.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,
                  arg("mask_bits")=0xffff,
                  arg("group_index")=0))
            .def("create_polygon_fixture", &create_polygon_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("vertices")=list(),
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=0.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,
                  arg("mask_bits")=0xffff,
                  arg("group_index")=0))
            .def("create_loop_fixture", &create_loop_fixture, return_internal_reference<>(),
                 (arg("self"),
                  arg("vertices"),
                  arg("user_data")=object(),
                  arg("friction")=0.2f,
                  arg("restitution")=0.0f,
                  arg("density")=0.0f,
                  arg("sensor")=false,
                  arg("category_bits")=0x0001,
{'fraction_non_alphanumeric': 0.09513816019587268, 'fraction_numerical': 0.023284864837855395, 'mean_word_length': 1.4309486214016762, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 82, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2850325', 'n_tokens_mistral': 5802, 'n_tokens_neox': 5541, 'n_words': 793}