public Test(){ Vec2 gravity = new Vec2(); gravity.Set(0.0f, -10.0f); m_world = new World(gravity); m_bomb = null; m_textLine = 30; m_mouseJoint = null; m_pointCount = 0; m_debugDraw = new DebugDraw(); m_destructionListener = new TestDestructionListener(); m_destructionListener.test = this; m_world.SetDestructionListener(m_destructionListener); m_world.SetContactListener(this); m_world.SetDebugDraw(m_debugDraw); m_bombSpawning = false; m_stepCount = 0; BodyDef bodyDef = new BodyDef(); m_groundBody = m_world.CreateBody(bodyDef); m_maxProfile = new Profile(); m_totalProfile = new Profile(); }
internal Body(BodyDef bd, World world){ Utilities.Assert(bd.Position.IsValid()); Utilities.Assert(bd.linearVelocity.IsValid()); Utilities.Assert(Utilities.IsValid(bd.angle)); Utilities.Assert(Utilities.IsValid(bd.angularVelocity)); Utilities.Assert(Utilities.IsValid(bd.angularDamping) && bd.angularDamping >= 0.0f); Utilities.Assert(Utilities.IsValid(bd.linearDamping) && bd.linearDamping >= 0.0f); m_flags = 0; if (bd.bullet) { m_flags |= BodyFlags.e_bulletFlag; } if (bd.fixedRotation) { m_flags |= BodyFlags.e_fixedRotationFlag; } if (bd.allowSleep) { m_flags |= BodyFlags.e_autoSleepFlag; } if (bd.awake) { m_flags |= BodyFlags.e_awakeFlag; } if (bd.active) { m_flags |= BodyFlags.e_activeFlag; } m_world = world; m_xf.p = bd.Position; m_xf.q.Set(bd.angle); m_sweep.localCenter.SetZero(); m_sweep.c0 = m_xf.p; m_sweep.c = m_xf.p; m_sweep.a0 = bd.angle; m_sweep.a = bd.angle; m_sweep.alpha0 = 0.0f; m_jointList = new List<JointEdge>(); m_contactList = new List<ContactEdge>(); m_prev = null; m_next = null; m_linearVelocity = bd.linearVelocity; m_angularVelocity = bd.angularVelocity; m_linearDamping = bd.linearDamping; m_angularDamping = bd.angularDamping; m_gravityScale = bd.gravityScale; m_force.SetZero(); m_torque = 0.0f; m_sleepTime = 0.0f; m_type = bd.type; if (m_type == BodyType._dynamicBody) { m_mass = 1.0f; m_invMass = 1.0f; } else { m_mass = 0.0f; m_invMass = 0.0f; } m_I = 0.0f; m_invI = 0.0f; m_userData = bd.UserData; m_fixtureList = new List<Fixture>(); }