summaryrefslogtreecommitdiff
path: root/servers/physics_2d_server.h
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics_2d_server.h')
-rw-r--r--servers/physics_2d_server.h59
1 files changed, 56 insertions, 3 deletions
diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h
index 01670ace7e..5411228c0f 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_2d_server.h
@@ -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 */
@@ -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();
@@ -344,6 +347,9 @@ public:
virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const=0;
virtual Matrix32 area_get_transform(RID p_area) const=0;
+ virtual void area_set_collision_mask(RID p_area,uint32_t p_mask)=0;
+ virtual void area_set_layer_mask(RID p_area,uint32_t p_mask)=0;
+
virtual void area_set_monitorable(RID p_area,bool p_monitorable)=0;
virtual void area_set_pickable(RID p_area,bool p_pickable)=0;
@@ -401,8 +407,8 @@ public:
virtual void body_set_layer_mask(RID p_body, uint32_t p_mask)=0;
virtual uint32_t body_get_layer_mask(RID p_body, uint32_t p_mask) const=0;
- virtual void body_set_user_mask(RID p_body, uint32_t p_mask)=0;
- virtual uint32_t body_get_user_mask(RID p_body, uint32_t p_mask) const=0;
+ virtual void body_set_collision_mask(RID p_body, uint32_t p_mask)=0;
+ virtual uint32_t body_get_collision_mask(RID p_body, uint32_t p_mask) const=0;
// common body variables
enum BodyParameter {
@@ -468,6 +474,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 +554,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 );