summaryrefslogtreecommitdiff
path: root/servers/physics_2d
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics_2d')
-rw-r--r--servers/physics_2d/body_2d_sw.cpp52
-rw-r--r--servers/physics_2d/broad_phase_2d_hash_grid.cpp12
-rw-r--r--servers/physics_2d/collision_solver_2d_sat.cpp16
-rw-r--r--servers/physics_2d/collision_solver_2d_sw.cpp8
-rw-r--r--servers/physics_2d/joints_2d_sw.cpp4
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp18
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h2
-rw-r--r--servers/physics_2d/shape_2d_sw.cpp18
-rw-r--r--servers/physics_2d/space_2d_sw.cpp27
-rw-r--r--servers/physics_2d/step_2d_sw.cpp2
10 files changed, 99 insertions, 60 deletions
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index a32e024fe9..093f69a169 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -251,8 +251,10 @@ void Body2DSW::set_mode(Physics2DServer::BodyMode p_mode) {
}
_update_inertia();
- //if (get_space())
-// _update_queries();
+ /*
+ if (get_space())
+ _update_queries();
+ */
}
Physics2DServer::BodyMode Body2DSW::get_mode() const {
@@ -301,15 +303,19 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant& p_va
} break;
case Physics2DServer::BODY_STATE_LINEAR_VELOCITY: {
- //if (mode==Physics2DServer::BODY_MODE_STATIC)
- // break;
+ /*
+ if (mode==Physics2DServer::BODY_MODE_STATIC)
+ break;
+ */
linear_velocity=p_variant;
wakeup();
} break;
case Physics2DServer::BODY_STATE_ANGULAR_VELOCITY: {
- //if (mode!=Physics2DServer::BODY_MODE_RIGID)
- // break;
+ /*
+ if (mode!=Physics2DServer::BODY_MODE_RIGID)
+ break;
+ */
angular_velocity=p_variant;
wakeup();
@@ -385,11 +391,13 @@ void Body2DSW::set_space(Space2DSW *p_space){
_update_inertia();
if (active)
get_space()->body_add_to_active_list(&active_list);
-// _update_queries();
- //if (is_active()) {
- // active=false;
- // set_active(true);
- //}
+ /*
+ _update_queries();
+ if (is_active()) {
+ active=false;
+ set_active(true);
+ }
+ */
}
@@ -459,13 +467,17 @@ void Body2DSW::integrate_forces(real_t p_step) {
// If less than 0, override dampenings with that of the Body2D
if (angular_damp>=0)
area_angular_damp = angular_damp;
- //else
- // area_angular_damp=damp_area->get_angular_damp();
+ /*
+ else
+ area_angular_damp=damp_area->get_angular_damp();
+ */
if (linear_damp>=0)
area_linear_damp = linear_damp;
- //else
- // area_linear_damp=damp_area->get_linear_damp();
+ /*
+ else
+ area_linear_damp=damp_area->get_linear_damp();
+ */
Vector2 motion;
bool do_motion=false;
@@ -482,10 +494,12 @@ void Body2DSW::integrate_forces(real_t p_step) {
do_motion=true;
- //for(int i=0;i<get_shape_count();i++) {
- // set_shape_kinematic_advance(i,Vector2());
- // set_shape_kinematic_retreat(i,0);
- //}
+ /*
+ for(int i=0;i<get_shape_count();i++) {
+ set_shape_kinematic_advance(i,Vector2());
+ set_shape_kinematic_retreat(i,0);
+ }
+ */
} else {
if (!omit_force_integration && !first_integration) {
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
index efa12c37cb..d2b37319ad 100644
--- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp
+++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp
@@ -599,8 +599,10 @@ int BroadPhase2DHashGrid::cull_segment(const Vector2& p_from, const Vector2& p_t
E->key()->pass=pass;
-// if (use_aabb && !p_aabb.intersects(E->key()->aabb))
-// continue;
+ /*
+ if (use_aabb && !p_aabb.intersects(E->key()->aabb))
+ continue;
+ */
if (!E->key()->aabb.intersects_segment(p_from,p_to))
continue;
@@ -645,8 +647,10 @@ int BroadPhase2DHashGrid::cull_aabb(const Rect2& p_aabb,CollisionObject2DSW** p_
if (!p_aabb.intersects(E->key()->aabb))
continue;
-// if (!E->key()->aabb.intersects_segment(p_from,p_to))
-// continue;
+ /*
+ if (!E->key()->aabb.intersects_segment(p_from,p_to))
+ continue;
+ */
p_results[cullcount]=E->key()->owner;
p_result_indices[cullcount]=E->key()->subindex;
diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp
index 2e7b0d8835..a09574a94c 100644
--- a/servers/physics_2d/collision_solver_2d_sat.cpp
+++ b/servers/physics_2d/collision_solver_2d_sat.cpp
@@ -40,8 +40,10 @@ struct _CollectorCallback2D {
_FORCE_INLINE_ void call(const Vector2& p_point_A, const Vector2& p_point_B) {
- //if (normal.dot(p_point_A) >= normal.dot(p_point_B))
- // return;
+ /*
+ if (normal.dot(p_point_A) >= normal.dot(p_point_B))
+ return;
+ */
if (swap)
callback(p_point_B,p_point_A,userdata);
else
@@ -462,7 +464,7 @@ public:
}
}
- // print_line("test axis: "+p_axis+" depth: "+rtos(best_depth));
+ //print_line("test axis: "+p_axis+" depth: "+rtos(best_depth));
#ifdef DEBUG_ENABLED
best_axis_count++;
#endif
@@ -610,8 +612,10 @@ static void _collision_segment_segment(const Shape2DSW* p_a,const Transform2D& p
//this collision is kind of pointless
- //if (!separator.test_previous_axis())
- // return;
+ /*
+ if (!separator.test_previous_axis())
+ return;
+ */
if (!separator.test_cast())
return;
@@ -850,7 +854,7 @@ static void _collision_circle_rectangle(const Shape2DSW* p_a,const Transform2D&
const Vector2 &sphere=p_transform_a.elements[2];
const Vector2 *axis=&p_transform_b.elements[0];
-// const Vector2& half_extents = rectangle_B->get_half_extents();
+ //const Vector2& half_extents = rectangle_B->get_half_extents();
if (!separator.test_axis(axis[0].normalized()))
return;
diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp
index e509bb76cd..02d59b69f0 100644
--- a/servers/physics_2d/collision_solver_2d_sw.cpp
+++ b/servers/physics_2d/collision_solver_2d_sw.cpp
@@ -226,7 +226,7 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Transfo
concave_B->cull(local_aabb,concave_callback,&cinfo);
-// print_line("Rect2 TESTS: "+itos(cinfo.aabb_tests));
+ //print_line("Rect2 TESTS: "+itos(cinfo.aabb_tests));
return cinfo.collided;
}
@@ -255,9 +255,11 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A,const Transform2D& p_
if (type_B==Physics2DServer::SHAPE_LINE || type_B==Physics2DServer::SHAPE_RAY) {
return false;
- //if (type_B==Physics2DServer::SHAPE_RAY) {
- // return false;
}
+ /*
+ if (type_B==Physics2DServer::SHAPE_RAY) {
+ return false;
+ */
if (swap) {
return solve_static_line(p_shape_B,p_transform_B,p_shape_A,p_transform_A,p_result_callback,p_userdata,true);
diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp
index 7205e90d27..f0703a0894 100644
--- a/servers/physics_2d/joints_2d_sw.cpp
+++ b/servers/physics_2d/joints_2d_sw.cpp
@@ -407,8 +407,8 @@ bool GrooveJoint2DSW::setup(float p_step) {
jn_max = get_max_force() * p_step;
// calculate bias velocity
-// cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1));
-// joint->bias = cpvclamp(cpvmult(delta, -joint->constraint.biasCoef*dt_inv), joint->constraint.maxBias);
+ //cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1));
+ //joint->bias = cpvclamp(cpvmult(delta, -joint->constraint.biasCoef*dt_inv), joint->constraint.maxBias);
Vector2 delta = (B->get_transform().get_origin() +rB) - (A->get_transform().get_origin() + rA);
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index 3cc69f470e..d134ce7ea8 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -1176,11 +1176,13 @@ void Physics2DServerSW::free(RID p_rid) {
Body2DSW *body = body_owner.get(p_rid);
-// if (body->get_state_query())
-// _clear_query(body->get_state_query());
+ /*
+ if (body->get_state_query())
+ _clear_query(body->get_state_query());
-// if (body->get_direct_state_query())
-// _clear_query(body->get_direct_state_query());
+ if (body->get_direct_state_query())
+ _clear_query(body->get_direct_state_query());
+ */
body->set_space(NULL);
@@ -1203,8 +1205,10 @@ void Physics2DServerSW::free(RID p_rid) {
Area2DSW *area = area_owner.get(p_rid);
-// if (area->get_monitor_query())
-// _clear_query(area->get_monitor_query());
+ /*
+ if (area->get_monitor_query())
+ _clear_query(area->get_monitor_query());
+ */
area->set_space(NULL);
@@ -1380,7 +1384,7 @@ Physics2DServerSW::Physics2DServerSW() {
singletonsw=this;
BroadPhase2DSW::create_func=BroadPhase2DHashGrid::_create;
-// BroadPhase2DSW::create_func=BroadPhase2DBasic::_create;
+ //BroadPhase2DSW::create_func=BroadPhase2DBasic::_create;
active=true;
island_count=0;
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index ba45dd9272..1da7d65dc8 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -70,7 +70,7 @@ friend class Physics2DDirectBodyStateSW;
static Physics2DServerSW *singletonsw;
-// void _clear_query(Query2DSW *p_query);
+ //void _clear_query(Query2DSW *p_query);
public:
struct CollCbkData {
diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp
index 8b19122f17..886ae7730b 100644
--- a/servers/physics_2d/shape_2d_sw.cpp
+++ b/servers/physics_2d/shape_2d_sw.cpp
@@ -639,8 +639,10 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2& p_begin,const Vect
for(int i=0;i<point_count;i++) {
//hmm crap.. no can do..
- //if (d.dot(points[i].normal)>=0)
- // continue;
+ /*
+ if (d.dot(points[i].normal)>=0)
+ continue;
+ */
Vector2 res;
@@ -816,8 +818,10 @@ bool ConcavePolygonShape2DSW::intersect_segment(const Vector2& p_begin,const Vec
real_t d=1e10;
bool inters=false;
- //for(int i=0;i<bvh_depth;i++)
- // stack[i]=0;
+ /*
+ for(int i=0;i<bvh_depth;i++)
+ stack[i]=0;
+ */
int level=0;
@@ -1077,8 +1081,10 @@ void ConcavePolygonShape2DSW::cull(const Rect2& p_local_aabb,Callback p_callback
};
- //for(int i=0;i<bvh_depth;i++)
- // stack[i]=0;
+ /*
+ for(int i=0;i<bvh_depth;i++)
+ stack[i]=0;
+ */
int level=0;
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 2c7b099b36..e95707f135 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -248,8 +248,10 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transfor
aabb=aabb.merge(Rect2(aabb.pos+p_motion,aabb.size)); //motion
aabb=aabb.grow(p_margin);
- //if (p_motion!=Vector2())
- // print_line(p_motion);
+ /*
+ if (p_motion!=Vector2())
+ print_line(p_motion);
+ */
int amount = space->broadphase->cull_aabb(aabb,space->intersection_query_results,Space2DSW::INTERSECTION_QUERY_MAX,space->intersection_query_subindex_results);
@@ -661,8 +663,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
const Body2DSW *body=static_cast<const Body2DSW*>(col_obj);
Vector2 cdir = body->get_one_way_collision_direction();
- //if (cdir!=Vector2() && p_motion.dot(cdir)<0)
- // continue;
+ /*
+ if (cdir!=Vector2() && p_motion.dot(cdir)<0)
+ continue;
+ */
cbk.valid_dir=cdir;
cbk.valid_depth=body->get_one_way_collision_max_depth();
@@ -698,11 +702,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
float traveled = n.dot(recover_motion);
a+=n*traveled;
+ float d = a.distance_to(b);
+ if (d<margin)
+ continue;
#endif
- // float d = a.distance_to(b);
-
- //if (d<margin)
- /// continue;
recover_motion+=(b-a)*0.4;
}
@@ -972,7 +975,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (collide_character)
mask|=Physics2DDirectSpaceState::TYPE_MASK_CHARACTER_BODY;
-// print_line("motion: "+p_motion+" margin: "+rtos(margin));
+ //print_line("motion: "+p_motion+" margin: "+rtos(margin));
//print_line("margin: "+rtos(margin));
do {
@@ -999,8 +1002,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
float d = a.distance_to(b);
- //if (d<margin)
- /// continue;
+ /*
+ if (d<margin)
+ continue;
+ */
recover_motion+=(b-a)*0.4;
}
diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp
index 05c0bf0516..8be4e2b5d5 100644
--- a/servers/physics_2d/step_2d_sw.cpp
+++ b/servers/physics_2d/step_2d_sw.cpp
@@ -216,7 +216,7 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) {
p_space->area_remove_from_moved_list((SelfList<Area2DSW>*)aml.first()); //faster to remove here
}
-// print_line("island count: "+itos(island_count)+" active count: "+itos(active_count));
+ //print_line("island count: "+itos(island_count)+" active count: "+itos(active_count));
{ //profile
profile_endtime=OS::get_singleton()->get_ticks_usec();