aboutsummaryrefslogtreecommitdiff
path: root/servers/physics_2d_server.h
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.h
parent1de1a04b78b65254aa41d7930947df82a121160c (diff)
downloadgodot-28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6.tar.gz
godot-28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6.tar.zst
godot-28c4afeb5733f9ca9725ab2a5f4066af8e02b2a6.zip
-Rewritten KinematicBody2D::move to MUCH more efficient code.
-KinematicBody2D::move now properly recognizes collision exceptions and masks, fixes #1649 -Removed object type masking for KinematicBody2D -Added a test_motion() function to RigidBody2D, allowing simlar behavior to KinematicBody2D::move there.
Diffstat (limited to 'servers/physics_2d_server.h')
-rw-r--r--servers/physics_2d_server.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h
index a3e65ec28..306144c2b 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_2d_server.h
@@ -230,6 +230,7 @@ public:
Physics2DShapeQueryResult();
};
+class Physics2DTestMotionResult;
class Physics2DServer : public Object {
@@ -237,6 +238,8 @@ class Physics2DServer : public Object {
static Physics2DServer * singleton;
+ virtual bool _body_test_motion(RID p_body,const Vector2& p_motion,float p_margin=0.08,const Ref<Physics2DTestMotionResult>& p_result=Ref<Physics2DTestMotionResult>());
+
protected:
static void _bind_methods();
@@ -468,6 +471,22 @@ public:
virtual void body_set_pickable(RID p_body,bool p_pickable)=0;
+ struct MotionResult {
+
+ Vector2 motion;
+ Vector2 remainder;
+
+ Vector2 collision_point;
+ Vector2 collision_normal;
+ Vector2 collider_velocity;
+ ObjectID collider_id;
+ RID collider;
+ int collider_shape;
+ Variant collider_metadata;
+ };
+
+ virtual bool body_test_motion(RID p_body,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL)=0;
+
/* JOINT API */
enum JointType {
@@ -532,6 +551,37 @@ public:
~Physics2DServer();
};
+
+class Physics2DTestMotionResult : public Reference {
+
+ OBJ_TYPE( Physics2DTestMotionResult, Reference );
+
+ Physics2DServer::MotionResult result;
+ bool colliding;
+friend class Physics2DServer;
+
+protected:
+ static void _bind_methods();
+public:
+
+ Physics2DServer::MotionResult* get_result_ptr() const { return const_cast<Physics2DServer::MotionResult*>(&result); }
+
+ //bool is_colliding() const;
+ Vector2 get_motion() const;
+ Vector2 get_motion_remainder() const;
+
+ Vector2 get_collision_point() const;
+ Vector2 get_collision_normal() const;
+ Vector2 get_collider_velocity() const;
+ ObjectID get_collider_id() const;
+ RID get_collider_rid() const;
+ Object* get_collider() const;
+ int get_collider_shape() const;
+
+ Physics2DTestMotionResult();
+};
+
+
VARIANT_ENUM_CAST( Physics2DServer::ShapeType );
VARIANT_ENUM_CAST( Physics2DServer::SpaceParameter );
VARIANT_ENUM_CAST( Physics2DServer::AreaParameter );