diff options
Diffstat (limited to 'servers/physics_2d_server.cpp')
-rw-r--r-- | servers/physics_2d_server.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index a51b938541..3ca6e29f0b 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -29,9 +29,10 @@ /*************************************************************************/ #include "physics_2d_server.h" + #include "core/method_bind_ext.gen.inc" +#include "core/print_string.h" #include "core/project_settings.h" -#include "print_string.h" Physics2DServer *Physics2DServer::singleton = NULL; @@ -291,6 +292,8 @@ Dictionary Physics2DDirectSpaceState::_intersect_ray(const Vector2 &p_from, cons Array Physics2DDirectSpaceState::_intersect_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); + Vector<ShapeResult> sr; sr.resize(p_max_results); int rc = intersect_shape(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, sr.ptrw(), sr.size(), p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); @@ -312,6 +315,8 @@ Array Physics2DDirectSpaceState::_intersect_shape(const Ref<Physics2DShapeQueryP Array Physics2DDirectSpaceState::_cast_motion(const Ref<Physics2DShapeQueryParameters> &p_shape_query) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); + float closest_safe, closest_unsafe; bool res = cast_motion(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, closest_safe, closest_unsafe, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); if (!res) @@ -353,6 +358,8 @@ Array Physics2DDirectSpaceState::_intersect_point(const Vector2 &p_point, int p_ Array Physics2DDirectSpaceState::_collide_shape(const Ref<Physics2DShapeQueryParameters> &p_shape_query, int p_max_results) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Array()); + Vector<Vector2> ret; ret.resize(p_max_results * 2); int rc = 0; @@ -367,6 +374,8 @@ Array Physics2DDirectSpaceState::_collide_shape(const Ref<Physics2DShapeQueryPar } Dictionary Physics2DDirectSpaceState::_get_rest_info(const Ref<Physics2DShapeQueryParameters> &p_shape_query) { + ERR_FAIL_COND_V(!p_shape_query.is_valid(), Dictionary()); + ShapeRestInfo sri; bool res = rest_info(p_shape_query->shape, p_shape_query->transform, p_shape_query->motion, p_shape_query->margin, &sri, p_shape_query->exclude, p_shape_query->collision_mask, p_shape_query->collide_with_bodies, p_shape_query->collide_with_areas); @@ -396,7 +405,6 @@ void Physics2DDirectSpaceState::_bind_methods() { ClassDB::bind_method(D_METHOD("cast_motion", "shape"), &Physics2DDirectSpaceState::_cast_motion); ClassDB::bind_method(D_METHOD("collide_shape", "shape", "max_results"), &Physics2DDirectSpaceState::_collide_shape, DEFVAL(32)); ClassDB::bind_method(D_METHOD("get_rest_info", "shape"), &Physics2DDirectSpaceState::_get_rest_info); - //ClassDB::bind_method(D_METHOD("cast_motion","shape","xform","motion","exclude","umask"),&Physics2DDirectSpaceState::_intersect_shape,DEFVAL(Array()),DEFVAL(0)); } int Physics2DShapeQueryResult::get_result_count() const { @@ -434,10 +442,6 @@ void Physics2DShapeQueryResult::_bind_methods() { /////////////////////////////// -/*bool Physics2DTestMotionResult::is_colliding() const { - - return colliding; -}*/ Vector2 Physics2DTestMotionResult::get_motion() const { return result.motion; @@ -479,7 +483,6 @@ int Physics2DTestMotionResult::get_collider_shape() const { void Physics2DTestMotionResult::_bind_methods() { - //ClassDB::bind_method(D_METHOD("is_colliding"),&Physics2DTestMotionResult::is_colliding); ClassDB::bind_method(D_METHOD("get_motion"), &Physics2DTestMotionResult::get_motion); ClassDB::bind_method(D_METHOD("get_motion_remainder"), &Physics2DTestMotionResult::get_motion_remainder); ClassDB::bind_method(D_METHOD("get_collision_point"), &Physics2DTestMotionResult::get_collision_point); @@ -628,7 +631,6 @@ void Physics2DServer::_bind_methods() { ClassDB::bind_method(D_METHOD("body_add_collision_exception", "body", "excepted_body"), &Physics2DServer::body_add_collision_exception); ClassDB::bind_method(D_METHOD("body_remove_collision_exception", "body", "excepted_body"), &Physics2DServer::body_remove_collision_exception); - //virtual void body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions)=0; ClassDB::bind_method(D_METHOD("body_set_max_contacts_reported", "body", "amount"), &Physics2DServer::body_set_max_contacts_reported); ClassDB::bind_method(D_METHOD("body_get_max_contacts_reported", "body"), &Physics2DServer::body_get_max_contacts_reported); @@ -662,11 +664,6 @@ void Physics2DServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &Physics2DServer::get_process_info); - //ClassDB::bind_method(D_METHOD("init"),&Physics2DServer::init); - //ClassDB::bind_method(D_METHOD("step"),&Physics2DServer::step); - //ClassDB::bind_method(D_METHOD("sync"),&Physics2DServer::sync); - //ClassDB::bind_method(D_METHOD("flush_queries"),&Physics2DServer::flush_queries); - BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_RECYCLE_RADIUS); BIND_ENUM_CONSTANT(SPACE_PARAM_CONTACT_MAX_SEPARATION); BIND_ENUM_CONSTANT(SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION); @@ -736,9 +733,6 @@ void Physics2DServer::_bind_methods() { BIND_ENUM_CONSTANT(CCD_MODE_CAST_RAY); BIND_ENUM_CONSTANT(CCD_MODE_CAST_SHAPE); - //BIND_ENUM_CONSTANT( TYPE_BODY ); - //BIND_ENUM_CONSTANT( TYPE_AREA ); - BIND_ENUM_CONSTANT(AREA_BODY_ADDED); BIND_ENUM_CONSTANT(AREA_BODY_REMOVED); @@ -749,7 +743,6 @@ void Physics2DServer::_bind_methods() { Physics2DServer::Physics2DServer() { - //ERR_FAIL_COND( singleton!=NULL ); singleton = this; } |