summaryrefslogtreecommitdiff
path: root/servers/physics_2d/step_2d_sw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics_2d/step_2d_sw.cpp')
-rw-r--r--servers/physics_2d/step_2d_sw.cpp40
1 files changed, 38 insertions, 2 deletions
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++;