diff options
Diffstat (limited to 'servers/physics')
-rw-r--r-- | servers/physics/body_sw.cpp | 1 | ||||
-rw-r--r-- | servers/physics/collision_object_sw.h | 6 | ||||
-rw-r--r-- | servers/physics/gjk_epa.h | 5 | ||||
-rw-r--r-- | servers/physics/physics_server_sw.cpp | 26 | ||||
-rw-r--r-- | servers/physics/space_sw.cpp | 6 |
5 files changed, 11 insertions, 33 deletions
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index 172a2a3429..a3bb581cb5 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -266,6 +266,7 @@ void BodySW::set_mode(PhysicsServer::BodyMode p_mode) { _inv_mass = mass > 0 ? (1.0 / mass) : 0; _set_static(false); + angular_velocity = Vector3(); } break; } diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index 895eda8528..b9912f0ba2 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -86,13 +86,9 @@ protected: void _unregister_shapes(); _FORCE_INLINE_ void _set_transform(const Transform &p_transform, bool p_update_shapes = true) { - #ifdef DEBUG_ENABLED - if (p_transform.origin.length_squared() > MAX_OBJECT_DISTANCE_X2) { - ERR_EXPLAIN("Object went too far away (more than " + itos(MAX_OBJECT_DISTANCE) + "mts from origin)."); - ERR_FAIL(); - } + ERR_FAIL_COND_MSG(p_transform.origin.length_squared() > MAX_OBJECT_DISTANCE_X2, "Object went too far away (more than " + itos(MAX_OBJECT_DISTANCE) + " units from origin)."); #endif transform = p_transform; diff --git a/servers/physics/gjk_epa.h b/servers/physics/gjk_epa.h index 0b7885c9a5..d3fa192804 100644 --- a/servers/physics/gjk_epa.h +++ b/servers/physics/gjk_epa.h @@ -31,11 +31,8 @@ #ifndef GJK_EPA_H #define GJK_EPA_H -#include "shape_sw.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ #include "collision_solver_sw.h" +#include "shape_sw.h" bool gjk_epa_calculate_penetration(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CollisionSolverSW::CallbackResult p_result_callback, void *p_userdata, bool p_swap = false); bool gjk_epa_calculate_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_result_A, Vector3 &r_result_B); diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 7b982e7015..09872977b6 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -40,11 +40,8 @@ #include "joints/pin_joint_sw.h" #include "joints/slider_joint_sw.h" -#define FLUSH_QUERY_CHECK(m_object) \ - if (m_object->get_space() && flushing_queries) { \ - ERR_EXPLAIN("Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead"); \ - ERR_FAIL(); \ - } +#define FLUSH_QUERY_CHECK(m_object) \ + ERR_FAIL_COND_MSG(m_object->get_space() && flushing_queries, "Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead."); RID PhysicsServerSW::shape_create(ShapeType p_shape) { @@ -73,8 +70,7 @@ RID PhysicsServerSW::shape_create(ShapeType p_shape) { } break; case SHAPE_CYLINDER: { - ERR_EXPLAIN("CylinderShape is not supported in GodotPhysics. Please switch to Bullet in the Project Settings."); - ERR_FAIL_V(RID()); + ERR_FAIL_V_MSG(RID(), "CylinderShape is not supported in GodotPhysics. Please switch to Bullet in the Project Settings."); } break; case SHAPE_CONVEX_POLYGON: { @@ -200,11 +196,7 @@ PhysicsDirectSpaceState *PhysicsServerSW::space_get_direct_state(RID p_space) { SpaceSW *space = space_owner.get(p_space); ERR_FAIL_COND_V(!space, NULL); - if (!doing_sync || space->is_locked()) { - - ERR_EXPLAIN("Space state is inaccessible right now, wait for iteration or physics process notification."); - ERR_FAIL_V(NULL); - } + ERR_FAIL_COND_V_MSG(!doing_sync || space->is_locked(), NULL, "Space state is inaccessible right now, wait for iteration or physics process notification."); return space->get_direct_state(); } @@ -987,12 +979,7 @@ PhysicsDirectBodyState *PhysicsServerSW::body_get_direct_state(RID p_body) { BodySW *body = body_owner.get(p_body); ERR_FAIL_COND_V(!body, NULL); - - if (!doing_sync || body->get_space()->is_locked()) { - - ERR_EXPLAIN("Body state is inaccessible right now, wait for iteration or physics process notification."); - ERR_FAIL_V(NULL); - } + ERR_FAIL_COND_V_MSG(!doing_sync || body->get_space()->is_locked(), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification."); direct_state->body = body; return direct_state; @@ -1410,8 +1397,7 @@ void PhysicsServerSW::free(RID p_rid) { } else { - ERR_EXPLAIN("Invalid ID"); - ERR_FAIL(); + ERR_FAIL_MSG("Invalid ID."); } }; diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index f3a4cbed24..410b6e59a0 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -348,11 +348,9 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh cbk.max = p_result_max; cbk.amount = 0; cbk.ptr = r_results; - CollisionSolverSW::CallbackResult cbkres = NULL; + CollisionSolverSW::CallbackResult cbkres = PhysicsServerSW::_shape_col_cbk; - PhysicsServerSW::CollCbkData *cbkptr = NULL; - cbkptr = &cbk; - cbkres = PhysicsServerSW::_shape_col_cbk; + PhysicsServerSW::CollCbkData *cbkptr = &cbk; for (int i = 0; i < amount; i++) { |