-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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user