aboutsummaryrefslogtreecommitdiff
path: root/servers/physics_2d_server.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2015-04-19 20:50:55 -0300
committerJuan Linietsky2015-04-19 20:50:55 -0300
commit28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6 (patch)
treebccdcd878d023b34d1458e37de657138f6c66e72 /servers/physics_2d_server.cpp
parent1de1a04b78b65254aa41d7930947df82a121160c (diff)
downloadgodot-28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6.tar.gz
godot-28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6.tar.zst
godot-28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6.zip
Diffstat (limited to 'servers/physics_2d_server.cpp')
-rw-r--r--servers/physics_2d_server.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp
index ffd240365..16a15617f 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_2d_server.cpp
@@ -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);