summaryrefslogtreecommitdiff
path: root/servers/physics_2d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-07-15 01:23:10 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-07-15 08:32:34 -0300
commit2e73be99d8d86d9dad7bcb99518a4d3cbb5c373c (patch)
treed863db50852afe5d4b0bc15b8452054498004cb1 /servers/physics_2d
parente64b82ebfcc3475c7a7d2a9196bfe20d6c9e3614 (diff)
Lots of work on Audio & Physics engine:
-Added new 3D stream player node -Added ability for Area to capture sound from streams -Added small features in physics to be able to properly guess distance to areas for sound -Fixed 3D CollisionObject so shapes are added the same as in 2D, directly from children -Fixed KinematicBody API to make it the same as 2D.
Diffstat (limited to 'servers/physics_2d')
-rw-r--r--servers/physics_2d/space_2d_sw.cpp156
1 files changed, 0 insertions, 156 deletions
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index bcc58b3aac..c407a17bc6 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -809,162 +809,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
return collided;
-
-#if 0
- //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..
-
-
- colliding=false;
- ERR_FAIL_COND_V(!is_inside_tree(),Vector2());
- Physics2DDirectSpaceState *dss = Physics2DServer::get_singleton()->space_get_direct_state(get_world_2d()->get_space());
- ERR_FAIL_COND_V(!dss,Vector2());
- const int max_shapes=32;
- Vector2 sr[max_shapes*2];
- int res_shapes;
-
- Set<RID> exclude;
- exclude.insert(get_rid());
-
-
- //recover first
- int recover_attempts=4;
-
- bool collided=false;
- uint32_t mask=0;
- if (collide_static)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_STATIC_BODY;
- if (collide_kinematic)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_KINEMATIC_BODY;
- if (collide_rigid)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_RIGID_BODY;
- if (collide_character)
- mask|=Physics2DDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
-
- //print_line("motion: "+p_motion+" margin: "+rtos(margin));
-
- //print_line("margin: "+rtos(margin));
- do {
-
- //motion recover
- for(int i=0;i<get_shape_count();i++) {
-
- if (is_shape_set_as_trigger(i))
- continue;
- if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),Vector2(),margin,sr,max_shapes,res_shapes,exclude,get_layer_mask(),mask))
- collided=true;
-
- }
-
- if (!collided)
- break;
-
- Vector2 recover_motion;
-
- for(int i=0;i<res_shapes;i++) {
-
- Vector2 a = sr[i*2+0];
- Vector2 b = sr[i*2+1];
-
- real_t d = a.distance_to(b);
-
- /*
- if (d<margin)
- continue;
- */
- recover_motion+=(b-a)*0.4;
- }
-
- if (recover_motion==Vector2()) {
- collided=false;
- break;
- }
-
- Matrix32 gt = get_global_transform();
- gt.elements[2]+=recover_motion;
- set_global_transform(gt);
-
- recover_attempts--;
-
- } while (recover_attempts);
-
-
- //move second
- real_t safe = 1.0;
- real_t unsafe = 1.0;
- int best_shape=-1;
-
- for(int i=0;i<get_shape_count();i++) {
-
- if (is_shape_set_as_trigger(i))
- continue;
-
- real_t lsafe,lunsafe;
- bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion, 0,lsafe,lunsafe,exclude,get_layer_mask(),mask);
- //print_line("shape: "+itos(i)+" travel:"+rtos(ltravel));
- if (!valid) {
-
- safe=0;
- unsafe=0;
- best_shape=i; //sadly it's the best
- break;
- }
- if (lsafe==1.0) {
- continue;
- }
- if (lsafe < safe) {
-
- safe=lsafe;
- unsafe=lunsafe;
- best_shape=i;
- }
- }
-
-
- //print_line("best shape: "+itos(best_shape)+" motion "+p_motion);
-
- if (safe>=1) {
- //not collided
- colliding=false;
- } else {
-
- //it collided, let's get the rest info in unsafe advance
- Matrix32 ugt = get_global_transform();
- ugt.elements[2]+=p_motion*unsafe;
- Physics2DDirectSpaceState::ShapeRestInfo rest_info;
- bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), Vector2(), margin,&rest_info,exclude,get_layer_mask(),mask);
- if (!c2) {
- //should not happen, but floating point precision is so weird..
-
- colliding=false;
- } else {
-
-
- //print_line("Travel: "+rtos(travel));
- colliding=true;
- collision=rest_info.point;
- normal=rest_info.normal;
- collider=rest_info.collider_id;
- collider_vel=rest_info.linear_velocity;
- collider_shape=rest_info.shape;
- collider_metadata=rest_info.metadata;
- }
-
- }
-
- Vector2 motion=p_motion*safe;
- Matrix32 gt = get_global_transform();
- gt.elements[2]+=motion;
- set_global_transform(gt);
-
- return p_motion-motion;
-
-#endif
- return false;
}
void *Space2DSW::_broadphase_pair(CollisionObject2DSW *A, int p_subindex_A, CollisionObject2DSW *B, int p_subindex_B, void *p_self) {