diff options
Diffstat (limited to 'servers/physics_2d_server.cpp')
-rw-r--r-- | servers/physics_2d_server.cpp | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 098f890222..088c092e75 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -285,7 +285,7 @@ Array Physics2DDirectSpaceState::_cast_motion(const Ref<Physics2DShapeQueryParam Array ret(true); ret.resize(2); ret[0]=closest_safe; - ret[0]=closest_unsafe; + ret[1]=closest_unsafe; return ret; } @@ -421,13 +421,86 @@ void Physics2DShapeQueryResult::_bind_methods() { } +/////////////////////////////// +/*bool Physics2DTestMotionResult::is_colliding() const { + return colliding; +}*/ +Vector2 Physics2DTestMotionResult::get_motion() const{ + return result.motion; +} +Vector2 Physics2DTestMotionResult::get_motion_remainder() const{ + + return result.remainder; +} + +Vector2 Physics2DTestMotionResult::get_collision_point() const{ + + return result.collision_point; +} +Vector2 Physics2DTestMotionResult::get_collision_normal() const{ + + return result.collision_normal; +} +Vector2 Physics2DTestMotionResult::get_collider_velocity() const{ + + return result.collider_velocity; +} +ObjectID Physics2DTestMotionResult::get_collider_id() const{ + + return result.collider_id; +} +RID Physics2DTestMotionResult::get_collider_rid() const{ + + return result.collider; +} + +Object* Physics2DTestMotionResult::get_collider() const { + return ObjectDB::get_instance(result.collider_id); +} + +int Physics2DTestMotionResult::get_collider_shape() const{ + + return result.collider_shape; +} + +void Physics2DTestMotionResult::_bind_methods() { + + //ObjectTypeDB::bind_method(_MD("is_colliding"),&Physics2DTestMotionResult::is_colliding); + ObjectTypeDB::bind_method(_MD("get_motion"),&Physics2DTestMotionResult::get_motion); + ObjectTypeDB::bind_method(_MD("get_motion_remainder"),&Physics2DTestMotionResult::get_motion_remainder); + ObjectTypeDB::bind_method(_MD("get_collision_point"),&Physics2DTestMotionResult::get_collision_point); + ObjectTypeDB::bind_method(_MD("get_collision_normal"),&Physics2DTestMotionResult::get_collision_normal); + ObjectTypeDB::bind_method(_MD("get_collider_velocity"),&Physics2DTestMotionResult::get_collider_velocity); + ObjectTypeDB::bind_method(_MD("get_collider_id"),&Physics2DTestMotionResult::get_collider_id); + ObjectTypeDB::bind_method(_MD("get_collider_rid"),&Physics2DTestMotionResult::get_collider_rid); + ObjectTypeDB::bind_method(_MD("get_collider"),&Physics2DTestMotionResult::get_collider); + ObjectTypeDB::bind_method(_MD("get_collider_shape"),&Physics2DTestMotionResult::get_collider_shape); + +} + +Physics2DTestMotionResult::Physics2DTestMotionResult(){ + + colliding=false; + result.collider_id=0; + result.collider_shape=0; +} /////////////////////////////////////// + + +bool Physics2DServer::_body_test_motion(RID p_body,const Vector2& p_motion,float p_margin,const Ref<Physics2DTestMotionResult>& p_result) { + + MotionResult *r=NULL; + if (p_result.is_valid()) + r=p_result->get_result_ptr(); + return body_test_motion(p_body,p_motion,p_margin,r); +} + void Physics2DServer::_bind_methods() { @@ -543,6 +616,8 @@ void Physics2DServer::_bind_methods() { ObjectTypeDB::bind_method(_MD("body_set_force_integration_callback","body","receiver","method"),&Physics2DServer::body_set_force_integration_callback); + ObjectTypeDB::bind_method(_MD("body_test_motion","body","motion","margin","result:Physics2DTestMotionResult"),&Physics2DServer::_body_test_motion,DEFVAL(0.08),DEFVAL(Variant())); + /* JOINT API */ ObjectTypeDB::bind_method(_MD("joint_set_param","joint","param","value"),&Physics2DServer::joint_set_param); |