-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.
This commit is contained in:
@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user