summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-09-02 15:05:40 +0200
committerRémi Verschelde <rverschelde@gmail.com>2018-09-02 15:08:43 +0200
commit60570a5e60b6c453e4dfd20e6c47e01e57d5eecb (patch)
treedb2848ace51a261d3d91c7ad580f97da32a38797 /scene/3d
parent457108924f499b22df2438f12621a1aadbd240f1 (diff)
PhysicsBody: Don't create PhysicsMaterial override for default friction/bounce
And don't save physics_material_override if null.
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/physics_body.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 1cb156ac73..f7af6a57dd 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -171,6 +171,10 @@ PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode) :
#ifndef DISABLE_DEPRECATED
void StaticBody::set_friction(real_t p_friction) {
+ if (p_friction == 1.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_friction has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
@@ -197,6 +201,10 @@ real_t StaticBody::get_friction() const {
void StaticBody::set_bounce(real_t p_bounce) {
+ if (p_bounce == 0.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
@@ -288,7 +296,7 @@ void StaticBody::_bind_methods() {
ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_linear_velocity"), "set_constant_linear_velocity", "get_constant_linear_velocity");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity");
}
@@ -606,8 +614,13 @@ real_t RigidBody::get_weight() const {
#ifndef DISABLE_DEPRECATED
void RigidBody::set_friction(real_t p_friction) {
+ if (p_friction == 1.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_friction has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
+
ERR_FAIL_COND(p_friction < 0 || p_friction > 1);
if (physics_material_override.is_null()) {
@@ -620,6 +633,7 @@ real_t RigidBody::get_friction() const {
ERR_EXPLAIN("The method get_friction has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
+
if (physics_material_override.is_null()) {
return 1;
}
@@ -628,8 +642,14 @@ real_t RigidBody::get_friction() const {
}
void RigidBody::set_bounce(real_t p_bounce) {
+
+ if (p_bounce == 0.0) { // default value, don't create an override for that
+ return;
+ }
+
ERR_EXPLAIN("The method set_bounce has been deprecated and will be removed in the future, use physics material instead.")
WARN_DEPRECATED
+
ERR_FAIL_COND(p_bounce < 0 || p_bounce > 1);
if (physics_material_override.is_null()) {
@@ -989,7 +1009,7 @@ void RigidBody::_bind_methods() {
ADD_PROPERTYNO(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_friction", "get_friction");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_bounce", "get_bounce");
#endif // DISABLE_DEPRECATED
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), "set_gravity_scale", "get_gravity_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), "set_use_custom_integrator", "is_using_custom_integrator");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "continuous_cd"), "set_use_continuous_collision_detection", "is_using_continuous_collision_detection");