@@ -104,6 +104,20 @@ glm::vec2 PhysicsBody::GetLinearVelocity() const
104104 return { b2velocity.x , b2velocity.y };
105105}
106106
107+ glm::vec2 PhysicsBody::GetLinearVelocityFromWorldPoint (const glm::vec2& worldPosition) const
108+ {
109+ box2d::vec2 b2point = worldPosition;
110+ box2d::vec2 b2vec = mPhysicsBody ->GetLinearVelocityFromWorldPoint (b2point);
111+ return b2vec;
112+ }
113+
114+ glm::vec2 PhysicsBody::GetLinearVelocityFromLocalPoint (const glm::vec2& localPosition) const
115+ {
116+ box2d::vec2 b2point = localPosition;
117+ box2d::vec2 b2vec = mPhysicsBody ->GetLinearVelocityFromLocalPoint (b2point);
118+ return b2vec;
119+ }
120+
107121cxx::angle_t PhysicsBody::GetAngularVelocity () const
108122{
109123 cxx::angle_t angularVelocity = cxx::angle_t::from_radians (mPhysicsBody ->GetAngularVelocity ());
@@ -352,6 +366,7 @@ CarPhysicsBody::CarPhysicsBody(b2World* physicsWorld, Vehicle* object)
352366 fixtureDef.shape = &shapeDef;
353367 fixtureDef.density = 1 .0f ;
354368 fixtureDef.friction = 0 .0f ;
369+ fixtureDef.restitution = 0 .4f ;
355370 fixtureDef.filter .categoryBits = PHYSICS_OBJCAT_CAR;
356371
357372 mChassisFixture = mPhysicsBody ->CreateFixture (&fixtureDef);
@@ -417,6 +432,17 @@ void CarPhysicsBody::GetChassisCorners(glm::vec2 corners[4]) const
417432 }
418433}
419434
435+ void CarPhysicsBody::GetLocalChassisCorners (glm::vec2 corners[4 ]) const
436+ {
437+ const b2PolygonShape* shape = (const b2PolygonShape*) mChassisFixture ->GetShape ();
438+ debug_assert (shape->m_count == 4 );
439+ for (int icorner = 0 ; icorner < 4 ; ++icorner)
440+ {
441+ box2d::vec2 point = shape->m_vertices [icorner];
442+ corners[icorner] = point;
443+ }
444+ }
445+
420446void CarPhysicsBody::GetWheelCorners (eCarWheel wheelID, glm::vec2 corners[4 ]) const
421447{
422448 debug_assert (wheelID < eCarWheel_COUNT);
0 commit comments