Browse Source

Merge pull request #9497 from 29jm/gravity-fix

Use the gravity constant to calculate weights
Rémi Verschelde 8 years ago
parent
commit
58320b7f6c
3 changed files with 5 additions and 5 deletions
  1. 3 2
      scene/2d/physics_body_2d.cpp
  2. 2 2
      scene/3d/physics_body.cpp
  3. 0 1
      scene/resources/world_2d.cpp

+ 3 - 2
scene/2d/physics_body_2d.cpp

@@ -554,11 +554,12 @@ real_t RigidBody2D::get_inertia() const {
 
 void RigidBody2D::set_weight(real_t p_weight) {
 
-	set_mass(p_weight / 9.8);
+	set_mass(p_weight / real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10);
 }
+
 real_t RigidBody2D::get_weight() const {
 
-	return mass * 9.8;
+	return mass * real_t(GLOBAL_DEF("physics/2d/default_gravity", 98)) / 10;
 }
 
 void RigidBody2D::set_friction(real_t p_friction) {

+ 2 - 2
scene/3d/physics_body.cpp

@@ -520,11 +520,11 @@ real_t RigidBody::get_mass() const {
 
 void RigidBody::set_weight(real_t p_weight) {
 
-	set_mass(p_weight / 9.8);
+	set_mass(p_weight / real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8)));
 }
 real_t RigidBody::get_weight() const {
 
-	return mass * 9.8;
+	return mass * real_t(GLOBAL_DEF("physics/3d/default_gravity", 9.8));
 }
 
 void RigidBody::set_friction(real_t p_friction) {

+ 0 - 1
scene/resources/world_2d.cpp

@@ -32,7 +32,6 @@
 #include "servers/visual_server.h"
 //#include "servers/spatial_sound_2d_server.h"
 #include "global_config.h"
-#include "global_config.h"
 #include "scene/2d/camera_2d.h"
 #include "scene/2d/visibility_notifier_2d.h"
 #include "scene/main/viewport.h"