|
@@ -1,5 +1,5 @@
|
|
|
/*************************************************************************/
|
|
|
-/* vehicle_body.cpp */
|
|
|
+/* vehicle_body_3d.cpp */
|
|
|
/*************************************************************************/
|
|
|
/* This file is part of: */
|
|
|
/* GODOT ENGINE */
|
|
@@ -28,7 +28,7 @@
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
/*************************************************************************/
|
|
|
|
|
|
-#include "vehicle_body.h"
|
|
|
+#include "vehicle_body_3d.h"
|
|
|
|
|
|
#define ROLLING_INFLUENCE_FIX
|
|
|
|
|
@@ -78,11 +78,11 @@ public:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-void VehicleWheel::_notification(int p_what) {
|
|
|
+void VehicleWheel3D::_notification(int p_what) {
|
|
|
|
|
|
if (p_what == NOTIFICATION_ENTER_TREE) {
|
|
|
|
|
|
- VehicleBody *cb = Object::cast_to<VehicleBody>(get_parent());
|
|
|
+ VehicleBody3D *cb = Object::cast_to<VehicleBody3D>(get_parent());
|
|
|
if (!cb)
|
|
|
return;
|
|
|
body = cb;
|
|
@@ -95,7 +95,7 @@ void VehicleWheel::_notification(int p_what) {
|
|
|
}
|
|
|
if (p_what == NOTIFICATION_EXIT_TREE) {
|
|
|
|
|
|
- VehicleBody *cb = Object::cast_to<VehicleBody>(get_parent());
|
|
|
+ VehicleBody3D *cb = Object::cast_to<VehicleBody3D>(get_parent());
|
|
|
if (!cb)
|
|
|
return;
|
|
|
cb->wheels.erase(this);
|
|
@@ -103,15 +103,15 @@ void VehicleWheel::_notification(int p_what) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-String VehicleWheel::get_configuration_warning() const {
|
|
|
- if (!Object::cast_to<VehicleBody>(get_parent())) {
|
|
|
+String VehicleWheel3D::get_configuration_warning() const {
|
|
|
+ if (!Object::cast_to<VehicleBody3D>(get_parent())) {
|
|
|
return TTR("VehicleWheel serves to provide a wheel system to a VehicleBody. Please use it as a child of a VehicleBody.");
|
|
|
}
|
|
|
|
|
|
return String();
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::_update(PhysicsDirectBodyState *s) {
|
|
|
+void VehicleWheel3D::_update(PhysicsDirectBodyState *s) {
|
|
|
|
|
|
if (m_raycastInfo.m_isInContact)
|
|
|
|
|
@@ -144,142 +144,142 @@ void VehicleWheel::_update(PhysicsDirectBodyState *s) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_radius(float p_radius) {
|
|
|
+void VehicleWheel3D::set_radius(float p_radius) {
|
|
|
|
|
|
m_wheelRadius = p_radius;
|
|
|
update_gizmo();
|
|
|
}
|
|
|
|
|
|
-float VehicleWheel::get_radius() const {
|
|
|
+float VehicleWheel3D::get_radius() const {
|
|
|
|
|
|
return m_wheelRadius;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_suspension_rest_length(float p_length) {
|
|
|
+void VehicleWheel3D::set_suspension_rest_length(float p_length) {
|
|
|
|
|
|
m_suspensionRestLength = p_length;
|
|
|
update_gizmo();
|
|
|
}
|
|
|
-float VehicleWheel::get_suspension_rest_length() const {
|
|
|
+float VehicleWheel3D::get_suspension_rest_length() const {
|
|
|
|
|
|
return m_suspensionRestLength;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_suspension_travel(float p_length) {
|
|
|
+void VehicleWheel3D::set_suspension_travel(float p_length) {
|
|
|
|
|
|
m_maxSuspensionTravelCm = p_length / 0.01;
|
|
|
}
|
|
|
-float VehicleWheel::get_suspension_travel() const {
|
|
|
+float VehicleWheel3D::get_suspension_travel() const {
|
|
|
|
|
|
return m_maxSuspensionTravelCm * 0.01;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_suspension_stiffness(float p_value) {
|
|
|
+void VehicleWheel3D::set_suspension_stiffness(float p_value) {
|
|
|
|
|
|
m_suspensionStiffness = p_value;
|
|
|
}
|
|
|
-float VehicleWheel::get_suspension_stiffness() const {
|
|
|
+float VehicleWheel3D::get_suspension_stiffness() const {
|
|
|
|
|
|
return m_suspensionStiffness;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_suspension_max_force(float p_value) {
|
|
|
+void VehicleWheel3D::set_suspension_max_force(float p_value) {
|
|
|
|
|
|
m_maxSuspensionForce = p_value;
|
|
|
}
|
|
|
-float VehicleWheel::get_suspension_max_force() const {
|
|
|
+float VehicleWheel3D::get_suspension_max_force() const {
|
|
|
|
|
|
return m_maxSuspensionForce;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_damping_compression(float p_value) {
|
|
|
+void VehicleWheel3D::set_damping_compression(float p_value) {
|
|
|
|
|
|
m_wheelsDampingCompression = p_value;
|
|
|
}
|
|
|
-float VehicleWheel::get_damping_compression() const {
|
|
|
+float VehicleWheel3D::get_damping_compression() const {
|
|
|
|
|
|
return m_wheelsDampingCompression;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_damping_relaxation(float p_value) {
|
|
|
+void VehicleWheel3D::set_damping_relaxation(float p_value) {
|
|
|
|
|
|
m_wheelsDampingRelaxation = p_value;
|
|
|
}
|
|
|
-float VehicleWheel::get_damping_relaxation() const {
|
|
|
+float VehicleWheel3D::get_damping_relaxation() const {
|
|
|
|
|
|
return m_wheelsDampingRelaxation;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_friction_slip(float p_value) {
|
|
|
+void VehicleWheel3D::set_friction_slip(float p_value) {
|
|
|
|
|
|
m_frictionSlip = p_value;
|
|
|
}
|
|
|
-float VehicleWheel::get_friction_slip() const {
|
|
|
+float VehicleWheel3D::get_friction_slip() const {
|
|
|
|
|
|
return m_frictionSlip;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_roll_influence(float p_value) {
|
|
|
+void VehicleWheel3D::set_roll_influence(float p_value) {
|
|
|
m_rollInfluence = p_value;
|
|
|
}
|
|
|
|
|
|
-float VehicleWheel::get_roll_influence() const {
|
|
|
+float VehicleWheel3D::get_roll_influence() const {
|
|
|
return m_rollInfluence;
|
|
|
}
|
|
|
|
|
|
-bool VehicleWheel::is_in_contact() const {
|
|
|
+bool VehicleWheel3D::is_in_contact() const {
|
|
|
return m_raycastInfo.m_isInContact;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::_bind_methods() {
|
|
|
+void VehicleWheel3D::_bind_methods() {
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_radius", "length"), &VehicleWheel::set_radius);
|
|
|
- ClassDB::bind_method(D_METHOD("get_radius"), &VehicleWheel::get_radius);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_radius", "length"), &VehicleWheel3D::set_radius);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_radius"), &VehicleWheel3D::get_radius);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_suspension_rest_length", "length"), &VehicleWheel::set_suspension_rest_length);
|
|
|
- ClassDB::bind_method(D_METHOD("get_suspension_rest_length"), &VehicleWheel::get_suspension_rest_length);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_suspension_rest_length", "length"), &VehicleWheel3D::set_suspension_rest_length);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_suspension_rest_length"), &VehicleWheel3D::get_suspension_rest_length);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_suspension_travel", "length"), &VehicleWheel::set_suspension_travel);
|
|
|
- ClassDB::bind_method(D_METHOD("get_suspension_travel"), &VehicleWheel::get_suspension_travel);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_suspension_travel", "length"), &VehicleWheel3D::set_suspension_travel);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_suspension_travel"), &VehicleWheel3D::get_suspension_travel);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_suspension_stiffness", "length"), &VehicleWheel::set_suspension_stiffness);
|
|
|
- ClassDB::bind_method(D_METHOD("get_suspension_stiffness"), &VehicleWheel::get_suspension_stiffness);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_suspension_stiffness", "length"), &VehicleWheel3D::set_suspension_stiffness);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_suspension_stiffness"), &VehicleWheel3D::get_suspension_stiffness);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_suspension_max_force", "length"), &VehicleWheel::set_suspension_max_force);
|
|
|
- ClassDB::bind_method(D_METHOD("get_suspension_max_force"), &VehicleWheel::get_suspension_max_force);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_suspension_max_force", "length"), &VehicleWheel3D::set_suspension_max_force);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_suspension_max_force"), &VehicleWheel3D::get_suspension_max_force);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_damping_compression", "length"), &VehicleWheel::set_damping_compression);
|
|
|
- ClassDB::bind_method(D_METHOD("get_damping_compression"), &VehicleWheel::get_damping_compression);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_damping_compression", "length"), &VehicleWheel3D::set_damping_compression);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_damping_compression"), &VehicleWheel3D::get_damping_compression);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_damping_relaxation", "length"), &VehicleWheel::set_damping_relaxation);
|
|
|
- ClassDB::bind_method(D_METHOD("get_damping_relaxation"), &VehicleWheel::get_damping_relaxation);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_damping_relaxation", "length"), &VehicleWheel3D::set_damping_relaxation);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_damping_relaxation"), &VehicleWheel3D::get_damping_relaxation);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_use_as_traction", "enable"), &VehicleWheel::set_use_as_traction);
|
|
|
- ClassDB::bind_method(D_METHOD("is_used_as_traction"), &VehicleWheel::is_used_as_traction);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_use_as_traction", "enable"), &VehicleWheel3D::set_use_as_traction);
|
|
|
+ ClassDB::bind_method(D_METHOD("is_used_as_traction"), &VehicleWheel3D::is_used_as_traction);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_use_as_steering", "enable"), &VehicleWheel::set_use_as_steering);
|
|
|
- ClassDB::bind_method(D_METHOD("is_used_as_steering"), &VehicleWheel::is_used_as_steering);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_use_as_steering", "enable"), &VehicleWheel3D::set_use_as_steering);
|
|
|
+ ClassDB::bind_method(D_METHOD("is_used_as_steering"), &VehicleWheel3D::is_used_as_steering);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_friction_slip", "length"), &VehicleWheel::set_friction_slip);
|
|
|
- ClassDB::bind_method(D_METHOD("get_friction_slip"), &VehicleWheel::get_friction_slip);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_friction_slip", "length"), &VehicleWheel3D::set_friction_slip);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_friction_slip"), &VehicleWheel3D::get_friction_slip);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("is_in_contact"), &VehicleWheel::is_in_contact);
|
|
|
+ ClassDB::bind_method(D_METHOD("is_in_contact"), &VehicleWheel3D::is_in_contact);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_roll_influence", "roll_influence"), &VehicleWheel::set_roll_influence);
|
|
|
- ClassDB::bind_method(D_METHOD("get_roll_influence"), &VehicleWheel::get_roll_influence);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_roll_influence", "roll_influence"), &VehicleWheel3D::set_roll_influence);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_roll_influence"), &VehicleWheel3D::get_roll_influence);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("get_skidinfo"), &VehicleWheel::get_skidinfo);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_skidinfo"), &VehicleWheel3D::get_skidinfo);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("get_rpm"), &VehicleWheel::get_rpm);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_rpm"), &VehicleWheel3D::get_rpm);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleWheel::set_engine_force);
|
|
|
- ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleWheel::get_engine_force);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleWheel3D::set_engine_force);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleWheel3D::get_engine_force);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleWheel::set_brake);
|
|
|
- ClassDB::bind_method(D_METHOD("get_brake"), &VehicleWheel::get_brake);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleWheel3D::set_brake);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_brake"), &VehicleWheel3D::get_brake);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleWheel::set_steering);
|
|
|
- ClassDB::bind_method(D_METHOD("get_steering"), &VehicleWheel::get_steering);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleWheel3D::set_steering);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_steering"), &VehicleWheel3D::get_steering);
|
|
|
|
|
|
ADD_GROUP("Per-Wheel Motion", "");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01,or_greater"), "set_engine_force", "get_engine_force");
|
|
@@ -302,65 +302,65 @@ void VehicleWheel::_bind_methods() {
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "damping_relaxation"), "set_damping_relaxation", "get_damping_relaxation");
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_engine_force(float p_engine_force) {
|
|
|
+void VehicleWheel3D::set_engine_force(float p_engine_force) {
|
|
|
|
|
|
m_engineForce = p_engine_force;
|
|
|
}
|
|
|
|
|
|
-float VehicleWheel::get_engine_force() const {
|
|
|
+float VehicleWheel3D::get_engine_force() const {
|
|
|
|
|
|
return m_engineForce;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_brake(float p_brake) {
|
|
|
+void VehicleWheel3D::set_brake(float p_brake) {
|
|
|
|
|
|
m_brake = p_brake;
|
|
|
}
|
|
|
-float VehicleWheel::get_brake() const {
|
|
|
+float VehicleWheel3D::get_brake() const {
|
|
|
|
|
|
return m_brake;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_steering(float p_steering) {
|
|
|
+void VehicleWheel3D::set_steering(float p_steering) {
|
|
|
|
|
|
m_steering = p_steering;
|
|
|
}
|
|
|
-float VehicleWheel::get_steering() const {
|
|
|
+float VehicleWheel3D::get_steering() const {
|
|
|
|
|
|
return m_steering;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_use_as_traction(bool p_enable) {
|
|
|
+void VehicleWheel3D::set_use_as_traction(bool p_enable) {
|
|
|
|
|
|
engine_traction = p_enable;
|
|
|
}
|
|
|
|
|
|
-bool VehicleWheel::is_used_as_traction() const {
|
|
|
+bool VehicleWheel3D::is_used_as_traction() const {
|
|
|
|
|
|
return engine_traction;
|
|
|
}
|
|
|
|
|
|
-void VehicleWheel::set_use_as_steering(bool p_enabled) {
|
|
|
+void VehicleWheel3D::set_use_as_steering(bool p_enabled) {
|
|
|
|
|
|
steers = p_enabled;
|
|
|
}
|
|
|
|
|
|
-bool VehicleWheel::is_used_as_steering() const {
|
|
|
+bool VehicleWheel3D::is_used_as_steering() const {
|
|
|
|
|
|
return steers;
|
|
|
}
|
|
|
|
|
|
-float VehicleWheel::get_skidinfo() const {
|
|
|
+float VehicleWheel3D::get_skidinfo() const {
|
|
|
|
|
|
return m_skidInfo;
|
|
|
}
|
|
|
|
|
|
-float VehicleWheel::get_rpm() const {
|
|
|
+float VehicleWheel3D::get_rpm() const {
|
|
|
|
|
|
return m_rpm;
|
|
|
}
|
|
|
|
|
|
-VehicleWheel::VehicleWheel() {
|
|
|
+VehicleWheel3D::VehicleWheel3D() {
|
|
|
|
|
|
steers = false;
|
|
|
engine_traction = false;
|
|
@@ -388,7 +388,7 @@ VehicleWheel::VehicleWheel() {
|
|
|
body = NULL;
|
|
|
}
|
|
|
|
|
|
-void VehicleBody::_update_wheel_transform(VehicleWheel &wheel, PhysicsDirectBodyState *s) {
|
|
|
+void VehicleBody3D::_update_wheel_transform(VehicleWheel3D &wheel, PhysicsDirectBodyState *s) {
|
|
|
|
|
|
wheel.m_raycastInfo.m_isInContact = false;
|
|
|
|
|
@@ -405,9 +405,9 @@ void VehicleBody::_update_wheel_transform(VehicleWheel &wheel, PhysicsDirectBody
|
|
|
wheel.m_raycastInfo.m_wheelAxleWS = chassisTrans.get_basis().xform(wheel.m_wheelAxleCS).normalized();
|
|
|
}
|
|
|
|
|
|
-void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) {
|
|
|
+void VehicleBody3D::_update_wheel(int p_idx, PhysicsDirectBodyState *s) {
|
|
|
|
|
|
- VehicleWheel &wheel = *wheels[p_idx];
|
|
|
+ VehicleWheel3D &wheel = *wheels[p_idx];
|
|
|
_update_wheel_transform(wheel, s);
|
|
|
|
|
|
Vector3 up = -wheel.m_raycastInfo.m_wheelDirectionWS;
|
|
@@ -430,9 +430,9 @@ void VehicleBody::_update_wheel(int p_idx, PhysicsDirectBodyState *s) {
|
|
|
wheel.m_raycastInfo.m_hardPointWS + wheel.m_raycastInfo.m_wheelDirectionWS * wheel.m_raycastInfo.m_suspensionLength);
|
|
|
}
|
|
|
|
|
|
-real_t VehicleBody::_ray_cast(int p_idx, PhysicsDirectBodyState *s) {
|
|
|
+real_t VehicleBody3D::_ray_cast(int p_idx, PhysicsDirectBodyState *s) {
|
|
|
|
|
|
- VehicleWheel &wheel = *wheels[p_idx];
|
|
|
+ VehicleWheel3D &wheel = *wheels[p_idx];
|
|
|
|
|
|
_update_wheel_transform(wheel, s);
|
|
|
|
|
@@ -513,12 +513,12 @@ real_t VehicleBody::_ray_cast(int p_idx, PhysicsDirectBodyState *s) {
|
|
|
return depth;
|
|
|
}
|
|
|
|
|
|
-void VehicleBody::_update_suspension(PhysicsDirectBodyState *s) {
|
|
|
+void VehicleBody3D::_update_suspension(PhysicsDirectBodyState *s) {
|
|
|
|
|
|
real_t chassisMass = mass;
|
|
|
|
|
|
for (int w_it = 0; w_it < wheels.size(); w_it++) {
|
|
|
- VehicleWheel &wheel_info = *wheels[w_it];
|
|
|
+ VehicleWheel3D &wheel_info = *wheels[w_it];
|
|
|
|
|
|
if (wheel_info.m_raycastInfo.m_isInContact) {
|
|
|
real_t force;
|
|
@@ -558,7 +558,7 @@ void VehicleBody::_update_suspension(PhysicsDirectBodyState *s) {
|
|
|
}
|
|
|
|
|
|
//bilateral constraint between two dynamic objects
|
|
|
-void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3 &pos1,
|
|
|
+void VehicleBody3D::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vector3 &pos1,
|
|
|
PhysicsBody3D *body2, const Vector3 &pos2, const Vector3 &normal, real_t &impulse, const real_t p_rollInfluence) {
|
|
|
|
|
|
real_t normalLenSqr = normal.length_squared();
|
|
@@ -636,7 +636,7 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-VehicleBody::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody3D *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse) :
|
|
|
+VehicleBody3D::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody3D *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse) :
|
|
|
m_s(s),
|
|
|
m_body1(body1),
|
|
|
m_frictionPositionWorld(frictionPosWorld),
|
|
@@ -667,7 +667,7 @@ VehicleBody::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirec
|
|
|
m_jacDiagABInv = relaxation / (denom0 + denom1);
|
|
|
}
|
|
|
|
|
|
-real_t VehicleBody::_calc_rolling_friction(btVehicleWheelContactPoint &contactPoint) {
|
|
|
+real_t VehicleBody3D::_calc_rolling_friction(btVehicleWheelContactPoint &contactPoint) {
|
|
|
|
|
|
real_t j1 = 0.f;
|
|
|
|
|
@@ -698,7 +698,7 @@ real_t VehicleBody::_calc_rolling_friction(btVehicleWheelContactPoint &contactPo
|
|
|
}
|
|
|
|
|
|
static const real_t sideFrictionStiffness2 = real_t(1.0);
|
|
|
-void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
|
|
|
+void VehicleBody3D::_update_friction(PhysicsDirectBodyState *s) {
|
|
|
|
|
|
//calculate the impulse, so that the wheels don't move sidewards
|
|
|
int numWheel = wheels.size();
|
|
@@ -720,7 +720,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
|
|
|
|
|
|
for (int i = 0; i < wheels.size(); i++) {
|
|
|
|
|
|
- VehicleWheel &wheelInfo = *wheels[i];
|
|
|
+ VehicleWheel3D &wheelInfo = *wheels[i];
|
|
|
|
|
|
if (wheelInfo.m_raycastInfo.m_isInContact) {
|
|
|
|
|
@@ -754,7 +754,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
|
|
|
bool sliding = false;
|
|
|
{
|
|
|
for (int wheel = 0; wheel < wheels.size(); wheel++) {
|
|
|
- VehicleWheel &wheelInfo = *wheels[wheel];
|
|
|
+ VehicleWheel3D &wheelInfo = *wheels[wheel];
|
|
|
|
|
|
//class btRigidBody* groundObject = (class btRigidBody*) wheelInfo.m_raycastInfo.m_groundObject;
|
|
|
|
|
@@ -816,7 +816,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
|
|
|
// apply the impulses
|
|
|
{
|
|
|
for (int wheel = 0; wheel < wheels.size(); wheel++) {
|
|
|
- VehicleWheel &wheelInfo = *wheels[wheel];
|
|
|
+ VehicleWheel3D &wheelInfo = *wheels[wheel];
|
|
|
|
|
|
Vector3 rel_pos = wheelInfo.m_raycastInfo.m_contactPointWS -
|
|
|
s->get_transform().origin;
|
|
@@ -850,7 +850,7 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void VehicleBody::_direct_state_changed(Object *p_state) {
|
|
|
+void VehicleBody3D::_direct_state_changed(Object *p_state) {
|
|
|
|
|
|
RigidBody3D::_direct_state_changed(p_state);
|
|
|
|
|
@@ -874,7 +874,7 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
|
|
|
for (int i = 0; i < wheels.size(); i++) {
|
|
|
|
|
|
//apply suspension force
|
|
|
- VehicleWheel &wheel = *wheels[i];
|
|
|
+ VehicleWheel3D &wheel = *wheels[i];
|
|
|
|
|
|
real_t suspensionForce = wheel.m_wheelsSuspensionForce;
|
|
|
|
|
@@ -891,7 +891,7 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
|
|
|
_update_friction(state);
|
|
|
|
|
|
for (int i = 0; i < wheels.size(); i++) {
|
|
|
- VehicleWheel &wheel = *wheels[i];
|
|
|
+ VehicleWheel3D &wheel = *wheels[i];
|
|
|
Vector3 relpos = wheel.m_raycastInfo.m_hardPointWS - state->get_transform().origin;
|
|
|
Vector3 vel = state->get_linear_velocity() + (state->get_angular_velocity()).cross(relpos); // * mPos);
|
|
|
|
|
@@ -920,58 +920,58 @@ void VehicleBody::_direct_state_changed(Object *p_state) {
|
|
|
state = NULL;
|
|
|
}
|
|
|
|
|
|
-void VehicleBody::set_engine_force(float p_engine_force) {
|
|
|
+void VehicleBody3D::set_engine_force(float p_engine_force) {
|
|
|
|
|
|
engine_force = p_engine_force;
|
|
|
for (int i = 0; i < wheels.size(); i++) {
|
|
|
- VehicleWheel &wheelInfo = *wheels[i];
|
|
|
+ VehicleWheel3D &wheelInfo = *wheels[i];
|
|
|
if (wheelInfo.engine_traction)
|
|
|
wheelInfo.m_engineForce = p_engine_force;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-float VehicleBody::get_engine_force() const {
|
|
|
+float VehicleBody3D::get_engine_force() const {
|
|
|
|
|
|
return engine_force;
|
|
|
}
|
|
|
|
|
|
-void VehicleBody::set_brake(float p_brake) {
|
|
|
+void VehicleBody3D::set_brake(float p_brake) {
|
|
|
|
|
|
brake = p_brake;
|
|
|
for (int i = 0; i < wheels.size(); i++) {
|
|
|
- VehicleWheel &wheelInfo = *wheels[i];
|
|
|
+ VehicleWheel3D &wheelInfo = *wheels[i];
|
|
|
wheelInfo.m_brake = p_brake;
|
|
|
}
|
|
|
}
|
|
|
-float VehicleBody::get_brake() const {
|
|
|
+float VehicleBody3D::get_brake() const {
|
|
|
|
|
|
return brake;
|
|
|
}
|
|
|
|
|
|
-void VehicleBody::set_steering(float p_steering) {
|
|
|
+void VehicleBody3D::set_steering(float p_steering) {
|
|
|
|
|
|
m_steeringValue = p_steering;
|
|
|
for (int i = 0; i < wheels.size(); i++) {
|
|
|
- VehicleWheel &wheelInfo = *wheels[i];
|
|
|
+ VehicleWheel3D &wheelInfo = *wheels[i];
|
|
|
if (wheelInfo.steers)
|
|
|
wheelInfo.m_steering = p_steering;
|
|
|
}
|
|
|
}
|
|
|
-float VehicleBody::get_steering() const {
|
|
|
+float VehicleBody3D::get_steering() const {
|
|
|
|
|
|
return m_steeringValue;
|
|
|
}
|
|
|
|
|
|
-void VehicleBody::_bind_methods() {
|
|
|
+void VehicleBody3D::_bind_methods() {
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleBody::set_engine_force);
|
|
|
- ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleBody::get_engine_force);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_engine_force", "engine_force"), &VehicleBody3D::set_engine_force);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_engine_force"), &VehicleBody3D::get_engine_force);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleBody::set_brake);
|
|
|
- ClassDB::bind_method(D_METHOD("get_brake"), &VehicleBody::get_brake);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_brake", "brake"), &VehicleBody3D::set_brake);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_brake"), &VehicleBody3D::get_brake);
|
|
|
|
|
|
- ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleBody::set_steering);
|
|
|
- ClassDB::bind_method(D_METHOD("get_steering"), &VehicleBody::get_steering);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_steering", "steering"), &VehicleBody3D::set_steering);
|
|
|
+ ClassDB::bind_method(D_METHOD("get_steering"), &VehicleBody3D::get_steering);
|
|
|
|
|
|
ADD_GROUP("Motion", "");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "engine_force", PROPERTY_HINT_RANGE, "0.00,1024.0,0.01,or_greater"), "set_engine_force", "get_engine_force");
|
|
@@ -979,7 +979,7 @@ void VehicleBody::_bind_methods() {
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "steering", PROPERTY_HINT_RANGE, "-180,180.0,0.01"), "set_steering", "get_steering");
|
|
|
}
|
|
|
|
|
|
-VehicleBody::VehicleBody() {
|
|
|
+VehicleBody3D::VehicleBody3D() {
|
|
|
|
|
|
m_pitchControl = 0;
|
|
|
m_currentVehicleSpeedKmHour = real_t(0.);
|