diff options
Diffstat (limited to 'servers/physics_2d')
-rw-r--r-- | servers/physics_2d/broad_phase_2d_hash_grid.cpp | 108 | ||||
-rw-r--r-- | servers/physics_2d/broad_phase_2d_hash_grid.h | 35 | ||||
-rw-r--r-- | servers/physics_2d/collision_solver_2d_sat.cpp | 61 | ||||
-rw-r--r-- | servers/physics_2d/constraint_2d_sw.cpp | 30 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_sw.cpp | 45 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_sw.h | 1 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_wrap_mt.cpp | 28 | ||||
-rw-r--r-- | servers/physics_2d/physics_2d_server_wrap_mt.h | 28 | ||||
-rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 3 | ||||
-rw-r--r-- | servers/physics_2d/space_2d_sw.h | 17 | ||||
-rw-r--r-- | servers/physics_2d/step_2d_sw.cpp | 40 |
11 files changed, 324 insertions, 72 deletions
diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp index 6a52d5fe5b..953c87021f 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp +++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp @@ -29,6 +29,8 @@ #include "broad_phase_2d_hash_grid.h" #include "globals.h" +#define LARGE_ELEMENT_FI 1.01239812 + void BroadPhase2DHashGrid::_pair_attempt(Element *p_elem, Element* p_with) { Map<Element*,PairData*>::Element *E=p_elem->paired.find(p_with); @@ -102,6 +104,26 @@ void BroadPhase2DHashGrid::_check_motion(Element *p_elem) { void BroadPhase2DHashGrid::_enter_grid( Element* p_elem, const Rect2& p_rect,bool p_static) { + + Vector2 sz = (p_rect.size/cell_size*LARGE_ELEMENT_FI); //use magic number to avoid floating point issues + if (sz.width*sz.height > large_object_min_surface) { + //large object, do not use grid, must check against all elements + for (Map<ID,Element>::Element *E=element_map.front();E;E=E->next()) { + if (E->key()==p_elem->self) + continue; // do not pair against itself + if (E->get().owner == p_elem->owner) + continue; + if (E->get()._static && p_static) + continue; + + _pair_attempt(p_elem,&E->get()); + } + + + large_elements[p_elem].inc(); + return; + } + Point2i from = (p_rect.pos/cell_size).floor(); Point2i to = ((p_rect.pos+p_rect.size)/cell_size).floor(); @@ -174,12 +196,40 @@ void BroadPhase2DHashGrid::_enter_grid( Element* p_elem, const Rect2& p_rect,boo } + //pair separatedly with large elements + + for (Map<Element*,RC>::Element *E=large_elements.front();E;E=E->next()) { + + if (E->key()==p_elem) + continue; // do not pair against itself + if (E->key()->owner == p_elem->owner) + continue; + if (E->key()->_static && p_static) + continue; + + _pair_attempt(E->key(),p_elem); + } } void BroadPhase2DHashGrid::_exit_grid( Element* p_elem, const Rect2& p_rect,bool p_static) { + Vector2 sz = (p_rect.size/cell_size*LARGE_ELEMENT_FI); + if (sz.width*sz.height > large_object_min_surface) { + + //unpair all elements, instead of checking all, just check what is already paired, so we at least save from checking static vs static + for (Map<Element*,PairData*>::Element *E=p_elem->paired.front();E;E=E->next()) { + + _unpair_attempt(p_elem,E->key()); + } + + if (large_elements[p_elem].dec()==0) { + large_elements.erase(p_elem); + } + return; + } + Point2i from = (p_rect.pos/cell_size).floor(); Point2i to = ((p_rect.pos+p_rect.size)/cell_size).floor(); @@ -274,6 +324,20 @@ void BroadPhase2DHashGrid::_exit_grid( Element* p_elem, const Rect2& p_rect,bool } + + for (Map<Element*,RC>::Element *E=large_elements.front();E;E=E->next()) { + if (E->key()==p_elem) + continue; // do not pair against itself + if (E->key()->owner == p_elem->owner) + continue; + if (E->key()->_static && p_static) + continue; + + //unpair from large elements + _unpair_attempt(p_elem,E->key()); + } + + } @@ -526,6 +590,28 @@ int BroadPhase2DHashGrid::cull_segment(const Vector2& p_from, const Vector2& p_t } + for (Map<Element*,RC>::Element *E=large_elements.front();E;E=E->next()) { + + if (cullcount>=p_max_results) + break; + if (E->key()->pass==pass) + continue; + + E->key()->pass=pass; + +// if (use_aabb && !p_aabb.intersects(E->key()->aabb)) +// 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; + cullcount++; + + + } + return cullcount; } @@ -547,6 +633,27 @@ int BroadPhase2DHashGrid::cull_aabb(const Rect2& p_aabb,CollisionObject2DSW** p_ } + for (Map<Element*,RC>::Element *E=large_elements.front();E;E=E->next()) { + + if (cullcount>=p_max_results) + break; + if (E->key()->pass==pass) + continue; + + E->key()->pass=pass; + + if (!p_aabb.intersects(E->key()->aabb)) + 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; + cullcount++; + + + } return cullcount; } @@ -581,6 +688,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() { hash_table = memnew_arr( PosBin*, hash_table_size); cell_size = GLOBAL_DEF("physics_2d/cell_size",128); + large_object_min_surface = GLOBAL_DEF("physics_2d/large_object_surface_treshold_in_cells",512); for(int i=0;i<hash_table_size;i++) hash_table[i]=NULL; diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.h b/servers/physics_2d/broad_phase_2d_hash_grid.h index bda5ea21cf..561d488484 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.h +++ b/servers/physics_2d/broad_phase_2d_hash_grid.h @@ -55,8 +55,26 @@ class BroadPhase2DHashGrid : public BroadPhase2DSW { }; + struct RC { + + int ref; + + _FORCE_INLINE_ int inc() { + ref++; + return ref; + } + _FORCE_INLINE_ int dec() { + ref--; + return ref; + } + + _FORCE_INLINE_ RC() { + ref=0; + } + }; Map<ID,Element> element_map; + Map<Element*,RC> large_elements; ID current; @@ -86,6 +104,7 @@ class BroadPhase2DHashGrid : public BroadPhase2DSW { Map<PairKey,PairData> pair_map; int cell_size; + int large_object_min_surface; PairCallback pair_callback; void *pair_userdata; @@ -127,23 +146,7 @@ class BroadPhase2DHashGrid : public BroadPhase2DSW { }; - struct RC { - - int ref; - - _FORCE_INLINE_ int inc() { - ref++; - return ref; - } - _FORCE_INLINE_ int dec() { - ref--; - return ref; - } - _FORCE_INLINE_ RC() { - ref=0; - } - }; struct PosBin { diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp index f22b676304..a6d12bdada 100644 --- a/servers/physics_2d/collision_solver_2d_sat.cpp +++ b/servers/physics_2d/collision_solver_2d_sat.cpp @@ -77,6 +77,7 @@ _FORCE_INLINE_ static void _generate_contacts_point_edge(const Vector2 * p_point struct _generate_contacts_Pair { + bool a; int idx; float d; _FORCE_INLINE_ bool operator <(const _generate_contacts_Pair& l) const { return d< l.d; } @@ -89,12 +90,14 @@ _FORCE_INLINE_ static void _generate_contacts_edge_edge(const Vector2 * p_points ERR_FAIL_COND( p_point_count_B != 2 ); // circle is actually a 4x3 matrix #endif - +# if 0 Vector2 rel_A=p_points_A[1]-p_points_A[0]; Vector2 rel_B=p_points_B[1]-p_points_B[0]; Vector2 t = p_collector->normal.tangent(); + print_line("tangent: "+t); + real_t dA[2]={t.dot(p_points_A[0]),t.dot(p_points_A[1])}; Vector2 pA[2]={p_points_A[0],p_points_A[1]}; @@ -201,41 +204,55 @@ _FORCE_INLINE_ static void _generate_contacts_edge_edge(const Vector2 * p_points } } +#endif + +#if 1 -#if 0 - Vector2 axis = rel_A.normalized(); - Vector2 axis_B = rel_B.normalized(); - if (axis.dot(axis_B)<0) - axis_B=-axis_B; - axis=(axis+axis_B)*0.5; - Vector2 normal_A = axis.tangent(); - real_t dA = normal_A.dot(p_points_A[0]); - Vector2 normal_B = rel_B.tangent().normalized(); - real_t dB = normal_A.dot(p_points_B[0]); - Vector2 A[4]={ normal_A.plane_project(dA,p_points_B[0]), normal_A.plane_project(dA,p_points_B[1]), p_points_A[0], p_points_A[1] }; - Vector2 B[4]={ p_points_B[0], p_points_B[1], normal_B.plane_project(dB,p_points_A[0]), normal_B.plane_project(dB,p_points_A[1]) }; + Vector2 n = p_collector->normal; + Vector2 t = n.tangent(); + real_t dA = n.dot(p_points_A[0]); + real_t dB = n.dot(p_points_B[0]); _generate_contacts_Pair dvec[4]; - for(int i=0;i<4;i++) { - dvec[i].d=axis.dot(p_points_A[0]-A[i]); - dvec[i].idx=i; - } + + dvec[0].d=t.dot(p_points_A[0]); + dvec[0].a=true; + dvec[0].idx=0; + dvec[1].d=t.dot(p_points_A[1]); + dvec[1].a=true; + dvec[1].idx=1; + dvec[2].d=t.dot(p_points_B[0]); + dvec[2].a=false; + dvec[2].idx=0; + dvec[3].d=t.dot(p_points_B[1]); + dvec[3].a=false; + dvec[3].idx=1; SortArray<_generate_contacts_Pair> sa; sa.sort(dvec,4); for(int i=1;i<=2;i++) { - Vector2 a = A[i]; - Vector2 b = B[i]; - if (p_collector->normal.dot(a) > p_collector->normal.dot(b)-CMP_EPSILON) - continue; - p_collector->call(a,b); + if (dvec[i].a) { + Vector2 a = p_points_A[dvec[i].idx]; + Vector2 b = n.plane_project(dB,a); + if (n.dot(a) > n.dot(b)-CMP_EPSILON) + continue; + p_collector->call(a,b); + } else { + Vector2 b = p_points_B[dvec[i].idx]; + Vector2 a = n.plane_project(dA,b); + if (n.dot(a) > n.dot(b)-CMP_EPSILON) + continue; + p_collector->call(a,b); + } } + + #elif 0 Vector2 axis = rel_A.normalized(); //make an axis Vector2 axis_B = rel_B.normalized(); diff --git a/servers/physics_2d/constraint_2d_sw.cpp b/servers/physics_2d/constraint_2d_sw.cpp deleted file mode 100644 index 2f681e8590..0000000000 --- a/servers/physics_2d/constraint_2d_sw.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/*************************************************************************/ -/* constraint_2d_sw.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "constraint_2d_sw.h" - diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 3796ddd961..54cd929c2f 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -31,6 +31,9 @@ #include "broad_phase_2d_hash_grid.h" #include "collision_solver_2d_sw.h" #include "globals.h" +#include "script_language.h" +#include "os/os.h" + RID Physics2DServerSW::shape_create(ShapeType p_shape) { Shape2DSW *shape=NULL; @@ -1276,6 +1279,8 @@ void Physics2DServerSW::step(float p_step) { active_objects+=E->get()->get_active_objects(); collision_pairs+=E->get()->get_collision_pairs(); } + + }; void Physics2DServerSW::sync() { @@ -1288,6 +1293,7 @@ void Physics2DServerSW::flush_queries() { if (!active) return; + uint64_t time_beg = OS::get_singleton()->get_ticks_usec(); for( Set<const Space2DSW*>::Element *E=active_spaces.front();E;E=E->next()) { @@ -1295,7 +1301,44 @@ void Physics2DServerSW::flush_queries() { space->call_queries(); } -}; + + if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_profiling()) { + + uint64_t total_time[Space2DSW::ELAPSED_TIME_MAX]; + static const char* time_name[Space2DSW::ELAPSED_TIME_MAX]={ + "integrate_forces", + "generate_islands", + "setup_constraints", + "solve_constraints", + "integrate_velocities" + }; + + for(int i=0;i<Space2DSW::ELAPSED_TIME_MAX;i++) { + total_time[i]=0; + } + + for( Set<const Space2DSW*>::Element *E=active_spaces.front();E;E=E->next()) { + + for(int i=0;i<Space2DSW::ELAPSED_TIME_MAX;i++) { + total_time[i]+=E->get()->get_elapsed_time(Space2DSW::ElapsedTime(i)); + } + + } + + Array values; + values.resize(Space2DSW::ELAPSED_TIME_MAX*2); + for(int i=0;i<Space2DSW::ELAPSED_TIME_MAX;i++) { + values[i*2+0]=time_name[i]; + values[i*2+1]=USEC_TO_SEC(total_time[i]); + } + values.push_back("flush_queries"); + values.push_back(USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()-time_beg)); + + ScriptDebugger::get_singleton()->add_profiling_frame_data("physics_2d",values); + + } + +} void Physics2DServerSW::end_sync() { doing_sync=false; diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h index 6415786803..d557688b91 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_2d_server_sw.h @@ -55,6 +55,7 @@ friend class Physics2DDirectBodyStateSW; bool using_threads; + Step2DSW *stepper; Set<const Space2DSW*> active_spaces; diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index c5f023f162..3e8b284b9b 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* physics_2d_server_wrap_mt.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "physics_2d_server_wrap_mt.h" #include "os/os.h" diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 891c45addf..fd98da2d9c 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* physics_2d_server_wrap_mt.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef PHYSICS2DSERVERWRAPMT_H #define PHYSICS2DSERVERWRAPMT_H diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index d83efeea9c..ddef5fc86b 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -1325,7 +1325,8 @@ Space2DSW::Space2DSW() { direct_access->space=this; - + for(int i=0;i<ELAPSED_TIME_MAX;i++) + elapsed_time[i]=0; } diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index 5f35f224b2..f8e1f32838 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -60,6 +60,20 @@ public: class Space2DSW { +public: + + enum ElapsedTime { + ELAPSED_TIME_INTEGRATE_FORCES, + ELAPSED_TIME_GENERATE_ISLANDS, + ELAPSED_TIME_SETUP_CONSTRAINTS, + ELAPSED_TIME_SOLVE_CONSTRAINTS, + ELAPSED_TIME_INTEGRATE_VELOCITIES, + ELAPSED_TIME_MAX + + }; +private: + + uint64_t elapsed_time[ELAPSED_TIME_MAX]; Physics2DDirectSpaceStateSW *direct_access; RID self; @@ -182,6 +196,9 @@ public: Physics2DDirectSpaceStateSW *get_direct_state(); + void set_elapsed_time(ElapsedTime p_time,uint64_t p_msec) { elapsed_time[p_time]=p_msec; } + uint64_t get_elapsed_time(ElapsedTime p_time) const { return elapsed_time[p_time]; } + Space2DSW(); ~Space2DSW(); }; diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp index 4f9d06ee96..4f86168c1e 100644 --- a/servers/physics_2d/step_2d_sw.cpp +++ b/servers/physics_2d/step_2d_sw.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "step_2d_sw.h" - +#include "os/os.h" void Step2DSW::_populate_island(Body2DSW* p_body,Body2DSW** p_island,Constraint2DSW **p_constraint_island) { @@ -142,6 +142,11 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { const SelfList<Body2DSW>::List * body_list = &p_space->get_active_body_list(); /* INTEGRATE FORCES */ + + uint64_t profile_begtime = OS::get_singleton()->get_ticks_usec(); + uint64_t profile_endtime=0; + + int active_count=0; const SelfList<Body2DSW>*b = body_list->first(); @@ -154,6 +159,13 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { p_space->set_active_objects(active_count); + + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_INTEGRATE_FORCES,profile_endtime-profile_begtime); + profile_begtime=profile_endtime; + } + /* GENERATE CONSTRAINT ISLANDS */ Body2DSW *island_list=NULL; @@ -190,7 +202,6 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { const SelfList<Area2DSW>::List &aml = p_space->get_moved_area_list(); - while(aml.first()) { for(const Set<Constraint2DSW*>::Element *E=aml.first()->self()->get_constraints().front();E;E=E->next()) { @@ -206,6 +217,13 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { } // print_line("island count: "+itos(island_count)+" active count: "+itos(active_count)); + + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_GENERATE_ISLANDS,profile_endtime-profile_begtime); + profile_begtime=profile_endtime; + } + /* SETUP CONSTRAINT ISLANDS */ { @@ -248,6 +266,12 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { } } + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_SETUP_CONSTRAINTS,profile_endtime-profile_begtime); + profile_begtime=profile_endtime; + } + /* SOLVE CONSTRAINT ISLANDS */ { @@ -259,6 +283,12 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { } } + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_SOLVE_CONSTRAINTS,profile_endtime-profile_begtime); + profile_begtime=profile_endtime; + } + /* INTEGRATE VELOCITIES */ b = body_list->first(); @@ -280,6 +310,12 @@ void Step2DSW::step(Space2DSW* p_space,float p_delta,int p_iterations) { } } + { //profile + profile_endtime=OS::get_singleton()->get_ticks_usec(); + p_space->set_elapsed_time(Space2DSW::ELAPSED_TIME_INTEGRATE_VELOCITIES,profile_endtime-profile_begtime); + //profile_begtime=profile_endtime; + } + p_space->update(); p_space->unlock(); _step++; |