diff options
Diffstat (limited to 'scene/3d/vehicle_body.h')
-rw-r--r-- | scene/3d/vehicle_body.h | 98 |
1 files changed, 44 insertions, 54 deletions
diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h index 273e63d741..55b521cfa6 100644 --- a/scene/3d/vehicle_body.h +++ b/scene/3d/vehicle_body.h @@ -35,20 +35,18 @@ class VehicleBody; class VehicleWheel : public Spatial { - GDCLASS(VehicleWheel,Spatial); - -friend class VehicleBody; + GDCLASS(VehicleWheel, Spatial); + friend class VehicleBody; Transform m_worldTransform; Transform local_xform; bool engine_traction; bool steers; - - Vector3 m_chassisConnectionPointCS; //const - Vector3 m_wheelDirectionCS;//const - Vector3 m_wheelAxleCS; // const or modified by steering + Vector3 m_chassisConnectionPointCS; //const + Vector3 m_wheelDirectionCS; //const + Vector3 m_wheelAxleCS; // const or modified by steering real_t m_suspensionRestLength; real_t m_maxSuspensionTravelCm; @@ -65,30 +63,29 @@ friend class VehicleBody; //btVector3 m_wheelAxleCS; // const or modified by steering ? - real_t m_steering; - real_t m_rotation; - real_t m_deltaRotation; - real_t m_rollInfluence; + real_t m_steering; + real_t m_rotation; + real_t m_deltaRotation; + real_t m_rollInfluence; //real_t m_engineForce; - real_t m_brake; + real_t m_brake; - real_t m_clippedInvContactDotSuspension; - real_t m_suspensionRelativeVelocity; + real_t m_clippedInvContactDotSuspension; + real_t m_suspensionRelativeVelocity; //calculated by suspension - real_t m_wheelsSuspensionForce; - real_t m_skidInfo; - + real_t m_wheelsSuspensionForce; + real_t m_skidInfo; struct RaycastInfo { //set by raycaster - Vector3 m_contactNormalWS;//contactnormal - Vector3 m_contactPointWS;//raycast hitpoint - real_t m_suspensionLength; - Vector3 m_hardPointWS;//raycast starting point - Vector3 m_wheelDirectionWS; //direction in worldspace - Vector3 m_wheelAxleWS; // axle in worldspace + Vector3 m_contactNormalWS; //contactnormal + Vector3 m_contactPointWS; //raycast hitpoint + real_t m_suspensionLength; + Vector3 m_hardPointWS; //raycast starting point + Vector3 m_wheelDirectionWS; //direction in worldspace + Vector3 m_wheelAxleWS; // axle in worldspace bool m_isInContact; - PhysicsBody* m_groundObject; //could be general void* ptr + PhysicsBody *m_groundObject; //could be general void* ptr } m_raycastInfo; void _update(PhysicsDirectBodyState *s); @@ -98,7 +95,6 @@ protected: static void _bind_methods(); public: - void set_radius(float p_radius); float get_radius() const; @@ -130,13 +126,11 @@ public: bool is_used_as_steering() const; VehicleWheel(); - }; - class VehicleBody : public PhysicsBody { - GDCLASS(VehicleBody,PhysicsBody); + GDCLASS(VehicleBody, PhysicsBody); real_t mass; real_t friction; @@ -145,52 +139,48 @@ class VehicleBody : public PhysicsBody { float brake; Vector3 linear_velocity; - Vector3 angular_velocity; + Vector3 angular_velocity; bool ccd; - real_t m_pitchControl; - real_t m_steeringValue; - real_t m_currentVehicleSpeedKmHour; + real_t m_pitchControl; + real_t m_steeringValue; + real_t m_currentVehicleSpeedKmHour; Set<RID> exclude; - Vector<Vector3> m_forwardWS; - Vector<Vector3> m_axle; - Vector<real_t> m_forwardImpulse; - Vector<real_t> m_sideImpulse; + Vector<Vector3> m_forwardWS; + Vector<Vector3> m_axle; + Vector<real_t> m_forwardImpulse; + Vector<real_t> m_sideImpulse; struct btVehicleWheelContactPoint { PhysicsDirectBodyState *m_s; - PhysicsBody* m_body1; - Vector3 m_frictionPositionWorld; - Vector3 m_frictionDirectionWorld; - real_t m_jacDiagABInv; - real_t m_maxImpulse; + PhysicsBody *m_body1; + Vector3 m_frictionPositionWorld; + Vector3 m_frictionDirectionWorld; + real_t m_jacDiagABInv; + real_t m_maxImpulse; - - btVehicleWheelContactPoint(PhysicsDirectBodyState *s,PhysicsBody* body1,const Vector3& frictionPosWorld,const Vector3& frictionDirectionWorld, real_t maxImpulse); + btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse); }; - void _resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3& pos1, PhysicsBody* body2, const Vector3& pos2, const Vector3& normal, real_t& impulse); - real_t _calc_rolling_friction(btVehicleWheelContactPoint& contactPoint); + void _resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3 &pos1, PhysicsBody *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse); + real_t _calc_rolling_friction(btVehicleWheelContactPoint &contactPoint); void _update_friction(PhysicsDirectBodyState *s); void _update_suspension(PhysicsDirectBodyState *s); - real_t _ray_cast(int p_idx,PhysicsDirectBodyState *s); - void _update_wheel_transform(VehicleWheel& wheel ,PhysicsDirectBodyState *s); - void _update_wheel(int p_idx,PhysicsDirectBodyState *s); - - + real_t _ray_cast(int p_idx, PhysicsDirectBodyState *s); + void _update_wheel_transform(VehicleWheel &wheel, PhysicsDirectBodyState *s); + void _update_wheel(int p_idx, PhysicsDirectBodyState *s); -friend class VehicleWheel; - Vector<VehicleWheel*> wheels; + friend class VehicleWheel; + Vector<VehicleWheel *> wheels; static void _bind_methods(); void _direct_state_changed(Object *p_state); -public: - +public: void set_mass(real_t p_mass); real_t get_mass() const; |