void physics_fixture_set_box_shape(int id, double halfwidth, double halfheight) { get_fixture(sb2dfixture, id); b2PolygonShape shape; shape.SetAsBox(halfwidth, halfheight); sb2dfixture->shape = &shape; sb2dfixture->FinishShape(); }
void physics_fixture_set_circle_shape(int id, double radius) { get_fixture(sb2dfixture, id); b2CircleShape shape; shape.m_radius = radius; sb2dfixture->shape = &shape; sb2dfixture->FinishShape(); }
void physics_fixture_set_collision_group(int id, int group) { get_fixture(sb2dfixture, id); // sets the collision group used to make parts of things not collide, like a ragdoll for // instance should not collide with itself b2Filter newfilter; newfilter.groupIndex = group; fixtures[id]->fixture->SetFilterData(newfilter); }
void physics_fixture_set_polygon_shape(int id) { get_fixture(sb2dfixture, id); b2PolygonShape shape; shape.Set(&sb2dfixture->vertices[0], sb2dfixture->vertices.size()); sb2dfixture->shape = &shape; sb2dfixture->FinishShape(); }
void physics_fixture_mass_properties(int id, double mass, double local_center_x, double local_center_y, double inertia) { get_fixture(sb2dfixture, id); b2MassData lMassData; sb2dfixture->body->GetMassData(&lMassData); lMassData.mass = mass; lMassData.center.Set(local_center_x, local_center_y); lMassData.I = inertia; sb2dfixture->body->SetMassData(&lMassData); }
void physics_apply_impulse(int world, double xpos, double ypos, double ximpulse, double yimpulse, bool wake) { get_fixture(sb2dworld, world); for (int i = 0; i < fixtures.size(); i++) { if (fixtures[i]->world == world) { fixtures[i]->body->ApplyLinearImpulse(b2Vec2(ximpulse, yimpulse), b2Vec2(xpos, ypos), wake); } } }
void physics_apply_force(int world, double xpos, double ypos, double xforce, double yforce, bool wake) { get_fixture(sb2dworld, world); for (int i = 0; i < fixtures.size(); i++) { if (fixtures[i]->world == world) { fixtures[i]->body->ApplyForce(b2Vec2(xforce, yforce), b2Vec2(xpos, ypos), wake); } } }
void physics_fixture_set_density(int id, double density) { get_fixture(sb2dfixture, id); // stupido makes it so 0 density, means infinite density and just makes it // a static object, thats actually stupid though because box2d lets you use it as a flag // for floating object, oh well use the ENIGMA version instead :/ if (density == 0) { sb2dfixture->body->SetType(b2_staticBody); } else { sb2dfixture->fixture->SetDensity(density); sb2dfixture->body->ResetMassData(); } }
void physics_fixture_set_edge_shape(int id, bool adjstart, bool adjend) { get_fixture(sb2dfixture, id); b2EdgeShape shape; int vid = 0; if (adjstart) { shape.m_hasVertex0 = true; shape.m_vertex0 = sb2dfixture->vertices[vid]; vid += 1; } shape.Set(sb2dfixture->vertices[vid], sb2dfixture->vertices[vid + 1]); vid += 2; if (adjend) { shape.m_hasVertex3 = true; shape.m_vertex3 = sb2dfixture->vertices[vid]; } sb2dfixture->shape = &shape; sb2dfixture->FinishShape(); }
void physics_fixture_set_static(int id) { get_fixture(sb2dfixture, id); sb2dfixture->body->SetType(b2_staticBody); sb2dfixture->body->ResetMassData(); }
void b2d_fixture_set_restitution(int id, double restitution) { get_fixture(b2dfixture, id); b2dfixture->fixture->SetRestitution(restitution); }
void physics_fixture_set_sleep(int id, bool allowsleep) { get_fixture(sb2dfixture, id); sb2dfixture->body->SetSleepingAllowed(allowsleep); }
void physics_fixture_set_awake(int id, bool state) { get_fixture(sb2dfixture, id); sb2dfixture->body->SetAwake(state); }
void physics_fixture_set_sensor(int id, bool state) { get_fixture(sb2dfixture, id); sb2dfixture->fixture->SetSensor(state); }
void physics_fixture_set_restitution(int id, double restitution) { get_fixture(sb2dfixture, id); sb2dfixture->fixture->SetRestitution(restitution); }
void physics_fixture_bind(int id) { // binds a fixture to nothing, just closes and fills the definition get_fixture(sb2dfixture, id); }
void physics_fixture_set_friction(int id, double friction) { get_fixture(sb2dfixture, id); sb2dfixture->fixture->SetFriction(friction); sb2dfixture->body->ResetMassData(); }
void b2d_fixture_set_friction(int id, double friction) { get_fixture(b2dfixture, id); b2dfixture->fixture->SetFriction(friction); }
void physics_apply_local_impulse(int id, double xlocal, double ylocal, double ximpulse, double yimpulse, bool wake) { get_fixture(sb2dfixture, id); sb2dfixture->body->ApplyLinearImpulse(b2Vec2(ximpulse, yimpulse), b2Vec2(xlocal, ylocal), wake); }
void b2d_fixture_set_sensor(int id, bool state) { get_fixture(b2dfixture, id); b2dfixture->fixture->SetSensor(state); }
void physics_fixture_set_transform(int id, double x, double y, double angle) { get_fixture(sb2dfixture, id); sb2dfixture->body->SetTransform(b2Vec2(x, y), cs_angle_to_radians(angle)); }
void physics_fixture_add_point(int id, double x, double y) { get_fixture(sb2dfixture, id); sb2dfixture->vertices.push_back(b2Vec2(x, y)); }
void physics_fixture_set_dynamic(int id) { get_fixture(sb2dfixture, id); sb2dfixture->body->SetType(b2_dynamicBody); }
void physics_fixture_set_angular_damping(int id, double damping) { get_fixture(sb2dfixture, id); sb2dfixture->body->SetAngularDamping(damping); }
void physics_fixture_set_position(int id, double x, double y) { get_fixture(sb2dfixture, id); sb2dfixture->body->SetTransform(b2Vec2(x, y), sb2dfixture->body->GetAngle()); }
void physics_fixture_delete(int id) { get_fixture(sb2dfixture, id); delete sb2dfixture; }
void physics_apply_local_force(int id, double xlocal, double ylocal, double xforce, double yforce, bool wake) { get_fixture(sb2dfixture, id); sb2dfixture->body->ApplyForce(b2Vec2(xforce, yforce), b2Vec2(xlocal, ylocal), wake); }
void physics_fixture_set_angle(int id, double angle) { get_fixture(sb2dfixture, id); sb2dfixture->body->SetTransform(sb2dfixture->body->GetPosition(), cs_angle_to_radians(angle)); }
void physics_apply_local_torque(int id, double torque, bool wake) { get_fixture(sb2dfixture, id); sb2dfixture->body->ApplyTorque(torque, wake); }
void b2d_fixture_set_density(int id, double density) { get_fixture(b2dfixture, id); b2dfixture->fixture->SetDensity(density); }