summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-07-05 16:25:56 +0200
committerGitHub <noreply@github.com>2017-07-05 16:25:56 +0200
commit58320b7f6cfe17ad3793a9ce6981b8ce0e50ad6a (patch)
treeb389c4fe6e25f296f03b6a723fbb59216291f2ac
parent6f63a01302355077af2459c96a17e299c32b2960 (diff)
parent00afca31c65812ecc5dfe6c4c92627c476ea8ea5 (diff)
Merge pull request #9497 from 29jm/gravity-fix
Use the gravity constant to calculate weights
-rw-r--r--scene/2d/physics_body_2d.cpp5
-rw-r--r--scene/3d/physics_body.cpp4
-rw-r--r--scene/resources/world_2d.cpp1
3 files changed, 5 insertions, 5 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index fd261117e1..8b2653f639 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/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) {
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 2a7a804470..718daab75a 100644
--- a/scene/3d/physics_body.cpp
+++ b/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) {
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 36d2a38b3d..9ec89e4003 100644
--- a/scene/resources/world_2d.cpp
+++ b/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"