示例#1
0
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();
}
示例#2
0
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();
}
示例#3
0
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);
}
示例#4
0
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();
}
示例#5
0
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);
}
示例#6
0
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);
    }
  }
}
示例#7
0
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);
    }
  }
}
示例#8
0
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();
  }
}
示例#9
0
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();
}
示例#10
0
void physics_fixture_set_static(int id)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->body->SetType(b2_staticBody);
  sb2dfixture->body->ResetMassData();
}
示例#11
0
void b2d_fixture_set_restitution(int id, double restitution)
{
  get_fixture(b2dfixture, id);
  b2dfixture->fixture->SetRestitution(restitution);
}
示例#12
0
void physics_fixture_set_sleep(int id, bool allowsleep)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->body->SetSleepingAllowed(allowsleep);
}
示例#13
0
void physics_fixture_set_awake(int id, bool state)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->body->SetAwake(state);
}
示例#14
0
void physics_fixture_set_sensor(int id, bool state)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->fixture->SetSensor(state);
}
示例#15
0
void physics_fixture_set_restitution(int id, double restitution)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->fixture->SetRestitution(restitution);
}
示例#16
0
void physics_fixture_bind(int id)
{
  // binds a fixture to nothing, just closes and fills the definition
  get_fixture(sb2dfixture, id);
}
示例#17
0
void physics_fixture_set_friction(int id, double friction)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->fixture->SetFriction(friction);
  sb2dfixture->body->ResetMassData();
}
示例#18
0
void b2d_fixture_set_friction(int id, double friction)
{
  get_fixture(b2dfixture, id);
  b2dfixture->fixture->SetFriction(friction);
}
示例#19
0
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);
}
示例#20
0
void b2d_fixture_set_sensor(int id, bool state)
{
  get_fixture(b2dfixture, id);
  b2dfixture->fixture->SetSensor(state);
}
示例#21
0
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));
}
示例#22
0
void physics_fixture_add_point(int id, double x, double y)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->vertices.push_back(b2Vec2(x, y));
}
示例#23
0
void physics_fixture_set_dynamic(int id)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->body->SetType(b2_dynamicBody);
}
示例#24
0
void physics_fixture_set_angular_damping(int id, double damping)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->body->SetAngularDamping(damping);
}
示例#25
0
void physics_fixture_set_position(int id, double x, double y)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->body->SetTransform(b2Vec2(x, y), sb2dfixture->body->GetAngle());
}
示例#26
0
void physics_fixture_delete(int id)
{
  get_fixture(sb2dfixture, id);
  delete sb2dfixture;
}
示例#27
0
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);
}
示例#28
0
void physics_fixture_set_angle(int id, double angle)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->body->SetTransform(sb2dfixture->body->GetPosition(), cs_angle_to_radians(angle));
}
示例#29
0
void physics_apply_local_torque(int id, double torque, bool wake)
{
  get_fixture(sb2dfixture, id);
  sb2dfixture->body->ApplyTorque(torque, wake);
}
示例#30
0
void b2d_fixture_set_density(int id, double density)
{
  get_fixture(b2dfixture, id);
  b2dfixture->fixture->SetDensity(density);
}