From e7aa37fe757151e9e241728c628dde6ccb3e0c07 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 3 May 2015 22:37:10 -0300 Subject: [PATCH] improved kinematic motion, improved demos for kinematic motion --- demos/2d/kinematic_char/circle.png | Bin 0 -> 6107 bytes demos/2d/kinematic_char/colworld.scn | Bin 6596 -> 7459 bytes demos/2d/kinematic_char/long_obstacle.png | Bin 0 -> 534 bytes demos/2d/kinematic_char/player.gd | 33 ++++++++--- scene/2d/physics_body_2d.cpp | 16 ++++++ scene/2d/physics_body_2d.h | 5 ++ scene/resources/theme.cpp | 18 ++++-- servers/physics_2d/space_2d_sw.cpp | 67 ++++++++++++---------- servers/physics_2d/space_2d_sw.h | 2 + 9 files changed, 97 insertions(+), 44 deletions(-) create mode 100644 demos/2d/kinematic_char/circle.png create mode 100644 demos/2d/kinematic_char/long_obstacle.png diff --git a/demos/2d/kinematic_char/circle.png b/demos/2d/kinematic_char/circle.png new file mode 100644 index 0000000000000000000000000000000000000000..ddb3ac4b9c2a73644222036e3848e9e23c705eed GIT binary patch literal 6107 zcmV<17bNJ3P)6U0Jw5TazP7OU799Z|uGc8vHy zrbCLf6ciOf(Ex^oKzJm%$$j5@&fa_d`p5d#+WUlzh@j2P%}wsPd++sq>wEluzi(~9 z)Ac9&7g_ICqSL!uUUKH?+3mOAP2xkH>!#Zpuh_V zvhpZ>>8DBTfbjeM1;2C8WAoSDeb0Rl?0)QS{`qrWl0C9{S8;9rAQl%t!UVp^r(@aj zl<%OMWTih6FF0|Tu0Cl3{dzTkiPU3!k%IAH8>X^~JlEa>>F{?8iF(e>gy(AHw1O zNWAb_N9pe3PTaQ(*?Zq}>SbBx&TX|7^uF+r45X03(zH?nW;Xzu697U$64LyfBq${m zc~y9nrT_T#U;p_9>ZZz3t>l}JwEWQAmoSg-^7rC^Asi#~ovZNI-LK0rfA_}hx-V{X zZ$JB_&$Wl#8&pw{$iYG5NWyzS1%L?R=L7);qvM~dGVA34r+ISxUZ%0SVr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qE9l|s@ z3lZAT3sD-kgFy?1Y2NQraD^bos{Cc#m1?3{bhLhaYOd0Ys&s7Lw?pyak@p0jbY2;v zPVu6{jX=f=CM~}touZ)hE-V4bk<#q>`He^94eyB;rHfF{MkFUK3DN;cl)CW<{sKjO z1JB`E>UT)K`RXHN8&GEHu3md@_bi^0pUpdYkS@brtej2Ht+F- diff --git a/demos/2d/kinematic_char/long_obstacle.png b/demos/2d/kinematic_char/long_obstacle.png new file mode 100644 index 0000000000000000000000000000000000000000..88cb22daee6f3948cf4c8ab078d586161063c8a3 GIT binary patch literal 534 zcmV+x0_pvUP)3`LI}x9{;K zmcft-Q`U-D0b*SU35glJCcb}=rtQ;b!Z49CsM6y|H}Q>a-@g1%YeEUFiMokQ$R=77 zl29`qk3$nhjn$9wNsKXvm?N^2`@&r&a?`% z^D%N}xfyQ8{l)QOlw!}%DvnWWQi{zYdX6Hl0 z4fos`SLv#tB+R`lwg~XUeP`z*n*lvHVlhg97sD@Zs^y?t+oa>`y=&CVZ%(5Q{iuIahUlHS7T3_L6U Y3e=LPD&^K1`~Uy|07*qoM6N<$f=8V8EdT%j literal 0 HcmV?d00001 diff --git a/demos/2d/kinematic_char/player.gd b/demos/2d/kinematic_char/player.gd index e8b3cc8d008..3549ba3830d 100644 --- a/demos/2d/kinematic_char/player.gd +++ b/demos/2d/kinematic_char/player.gd @@ -21,6 +21,8 @@ const STOP_FORCE = 1300 const JUMP_SPEED = 200 const JUMP_MAX_AIRBORNE_TIME=0.2 +const SLIDE_STOP_VELOCITY=1.0 #one pixel per second +const SLIDE_STOP_MIN_TRAVEL=1.0 #one pixel var velocity = Vector2() var on_air_time=100 var jumping=false @@ -86,16 +88,29 @@ func _fixed_process(delta): #char is on floor on_air_time=0 floor_velocity=get_collider_velocity() - #velocity.y=0 - #But we were moving and our motion was interrupted, - #so try to complete the motion by "sliding" - #by the normal - motion = n.slide(motion) - velocity = n.slide(velocity) - - #then move again - move(motion) + + if (on_air_time==0 and force.x==0 and get_travel().length() < SLIDE_STOP_MIN_TRAVEL and abs(velocity.x) < SLIDE_STOP_VELOCITY and get_collider_velocity()==Vector2()): + #Since this formula will always slide the character around, + #a special case must be considered to to stop it from moving + #if standing on an inclined floor. Conditions are: + # 1) Standin on floor (on_air_time==0) + # 2) Did not move more than one pixel (get_travel().length() < SLIDE_STOP_MIN_TRAVEL) + # 3) Not moving horizontally (abs(velocity.x) < SLIDE_STOP_VELOCITY) + # 4) Collider is not moving + + revert_motion() + velocity.y=0.0 + + else: + #For every other case of motion,our motion was interrupted. + #Try to complete the motion by "sliding" + #by the normal + + motion = n.slide(motion) + velocity = n.slide(velocity) + #then move again + move(motion) if (floor_velocity!=Vector2()): #if floor moves, move with floor diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 6fb798714fc..9fd4a25e7ff 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -925,6 +925,19 @@ Variant KinematicBody2D::_get_collider() const { return obj; } +void KinematicBody2D::revert_motion() { + + Matrix32 gt = get_global_transform(); + gt.elements[2]-=travel; + travel=Vector2(); + set_global_transform(gt); + +} + +Vector2 KinematicBody2D::get_travel() const { + + return travel; +} Vector2 KinematicBody2D::move(const Vector2& p_motion) { @@ -942,6 +955,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { Matrix32 gt = get_global_transform(); gt.elements[2]+=result.motion; set_global_transform(gt); + travel=result.motion; return result.remainder; #else @@ -1173,6 +1187,8 @@ void KinematicBody2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("move_to","position"),&KinematicBody2D::move_to); ObjectTypeDB::bind_method(_MD("test_move","rel_vec"),&KinematicBody2D::test_move); + ObjectTypeDB::bind_method(_MD("get_travel"),&KinematicBody2D::get_travel); + ObjectTypeDB::bind_method(_MD("revert_motion"),&KinematicBody2D::revert_motion); ObjectTypeDB::bind_method(_MD("is_colliding"),&KinematicBody2D::is_colliding); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 3cb94b95da0..b6be07500ff 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -280,6 +280,7 @@ class KinematicBody2D : public PhysicsBody2D { ObjectID collider; int collider_shape; Variant collider_metadata; + Vector2 travel; Variant _get_collider() const; @@ -294,6 +295,10 @@ public: bool test_move(const Vector2& p_motion); bool is_colliding() const; + + Vector2 get_travel() const; + void revert_motion(); + Vector2 get_collision_pos() const; Vector2 get_collision_normal() const; Vector2 get_collider_velocity() const; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 8350bf8cc85..21bdb6c0ab9 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -105,6 +105,9 @@ bool Theme::_get(const StringName& p_name,Variant &r_ret) const { void Theme::_get_property_list( List *p_list) const { + + List list; + const StringName *key=NULL; while((key=icon_map.next(key))) { @@ -113,7 +116,7 @@ void Theme::_get_property_list( List *p_list) const { while((key2=icon_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/icons/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture" ) ); + list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/icons/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture" ) ); } } @@ -125,7 +128,7 @@ void Theme::_get_property_list( List *p_list) const { while((key2=style_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/styles/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox" ) ); + list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/styles/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "StyleBox" ) ); } } @@ -138,7 +141,7 @@ void Theme::_get_property_list( List *p_list) const { while((key2=font_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/fonts/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Font" ) ); + list.push_back( PropertyInfo( Variant::OBJECT, String()+*key+"/fonts/"+*key2, PROPERTY_HINT_RESOURCE_TYPE, "Font" ) ); } } @@ -150,7 +153,7 @@ void Theme::_get_property_list( List *p_list) const { while((key2=color_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::COLOR, String()+*key+"/colors/"+*key2 ) ); + list.push_back( PropertyInfo( Variant::COLOR, String()+*key+"/colors/"+*key2 ) ); } } @@ -162,9 +165,14 @@ void Theme::_get_property_list( List *p_list) const { while((key2=constant_map[*key].next(key2))) { - p_list->push_back( PropertyInfo( Variant::INT, String()+*key+"/constants/"+*key2 ) ); + list.push_back( PropertyInfo( Variant::INT, String()+*key+"/constants/"+*key2 ) ); } } + + list.sort(); + for(List::Element *E=list.front();E;E=E->next()) { + p_list->push_back(E->get()); + } } diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 40e7b19f6f8..b38cf0c2df4 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -555,38 +555,10 @@ Physics2DDirectSpaceStateSW::Physics2DDirectSpaceStateSW() { - -bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p_margin,Physics2DServer::MotionResult *r_result) { - - //give me back regular physics engine logic - //this is madness - //and most people using this function will think - //what it does is simpler than using physics - //this took about a week to get right.. - //but is it right? who knows at this point.. - - Rect2 body_aabb; - - for(int i=0;iget_shape_count();i++) { - - if (i==0) - body_aabb=p_body->get_shape_aabb(i); - else - body_aabb=body_aabb.merge(p_body->get_shape_aabb(i)); - } - - body_aabb=body_aabb.grow(p_margin); - - { - //add motion - - Rect2 motion_aabb=body_aabb; - motion_aabb.pos+=p_motion; - body_aabb=body_aabb.merge(motion_aabb); - } +int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body,const Rect2& p_aabb) { - int amount = broadphase->cull_aabb(body_aabb,intersection_query_results,INTERSECTION_QUERY_MAX,intersection_query_subindex_results); + int amount = broadphase->cull_aabb(p_aabb,intersection_query_results,INTERSECTION_QUERY_MAX,intersection_query_subindex_results); for(int i=0;iget_shape_count();i++) { + + if (i==0) + body_aabb=p_body->get_shape_aabb(i); + else + body_aabb=body_aabb.merge(p_body->get_shape_aabb(i)); + } + + body_aabb=body_aabb.grow(p_margin); + + Matrix32 body_transform = p_body->get_transform(); { @@ -642,6 +639,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p bool collided=false; + int amount = _cull_aabb_for_body(p_body,body_aabb); for(int j=0;jget_shape_count();j++) { if (p_body->is_shape_set_as_trigger(j)) @@ -694,6 +692,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p } body_transform.elements[2]+=recover_motion; + body_aabb.pos+=recover_motion; recover_attempts--; @@ -709,7 +708,11 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p { // STEP 2 ATTEMPT MOTION + Rect2 motion_aabb=body_aabb; + motion_aabb.pos+=p_motion; + motion_aabb=motion_aabb.merge(body_aabb); + int amount = _cull_aabb_for_body(p_body,motion_aabb); for(int j=0;jget_shape_count();j++) { @@ -847,6 +850,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p Matrix32 body_shape_xform = ugt * p_body->get_shape_transform(best_shape); Shape2DSW *body_shape = p_body->get_shape(best_shape); + body_aabb.pos+=p_motion*unsafe; + + int amount = _cull_aabb_for_body(p_body,body_aabb); + for(int i=0;i