Revision: 1505
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1505&view=rev
Author: rorthomas
Date: 2010-08-07 01:11:21 +0000 (Sat, 07 Aug 2010)
Log Message:
-----------
improved beam timing debug mode
Modified Paths:
--------------
trunk/CMakeDependenciesConfig.txt
trunk/bin/resources/overlays.zip
trunk/source/main/Beam.cpp
trunk/source/main/Beam.h
trunk/source/main/BeamStats.cpp
trunk/source/main/BeamStats.h
trunk/source/main/CMakeLists.txt
trunk/source/main/Landusemap.cpp
Modified: trunk/CMakeDependenciesConfig.txt
===================================================================
--- trunk/CMakeDependenciesConfig.txt 2010-08-06 17:10:41 UTC (rev 1504)
+++ trunk/CMakeDependenciesConfig.txt 2010-08-07 01:11:21 UTC (rev 1505)
@@ -8,7 +8,9 @@
set(ROR_USE_CAELUM "FALSE" CACHE BOOL "use caelum sky")
set(ROR_USE_ANGELSCRIPT "FALSE" CACHE BOOL "use angel script")
set(ROR_USE_LITESQL "FALSE" CACHE BOOL "use sqlite")
+set(ROR_FEAT_TIMING "FALSE" CACHE BOOL "enable beam statistics. For core
development only")
+
# set some defaults
IF(WIN32)
# options only available under windows
Modified: trunk/bin/resources/overlays.zip
===================================================================
(Binary files differ)
Modified: trunk/source/main/Beam.cpp
===================================================================
--- trunk/source/main/Beam.cpp 2010-08-06 17:10:41 UTC (rev 1504)
+++ trunk/source/main/Beam.cpp 2010-08-07 01:11:21 UTC (rev 1505)
@@ -56,9 +56,7 @@
#include "PositionStorage.h"
#include "network.h"
#include "PointColDetector.h"
-#ifdef FEAT_TIMING
#include "BeamStats.h"
-#endif
#include "Skidmark.h"
#include "CmdKeyInertia.h"
#include "ColoredTextAreaOverlayElement.h"
@@ -346,9 +344,13 @@
dynamicMapMode=0;
meshesVisible=true;
disable_default_sounds=false;
+
#ifdef FEAT_TIMING
- statistics = BES.getClient(tnum);
+ // this enables beam engine timing statistics
+ statistics = BES.getClient(tnum, BES_CORE);
+ statistics_gfx = BES.getClient(tnum, BES_GFX);
#endif
+
//truckScript = new TruckCommandScheduler();
flaresMode = _flaresMode;
int i;
@@ -567,8 +569,12 @@
for(int i=0; i<MAX_WHEELS*2; i++) skidtrails[i] = 0;
collisions=icollisions;
+
+ // you could disable the collision code here:
+ // pointCD = 0;
pointCD = new PointColDetector();
+
dustp = DustManager::getSingleton().getDustPool("dust");
dripp = DustManager::getSingleton().getDustPool("dripp");
sparksp = DustManager::getSingleton().getDustPool("sparks");
@@ -726,6 +732,8 @@
// the material type and they do not depend on length or scale.
void Beam::scaleTruck(float value)
{
+ BES_GFX_START(BES_GFX_ScaleTruck);
+
if(value<0) return;
currentScale *= value;
// scale beams
@@ -794,6 +802,7 @@
//if(vwheels[i].cnode) vwheels[i].cnode->scale(value, value,
value);
//if(vwheels[i].fm && vwheels[i].cnode)
vwheels[i].cnode->scale(value, value, value);
//}
+ BES_GFX_STOP(BES_GFX_ScaleTruck);
}
@@ -820,6 +829,8 @@
void Beam::updateSimpleSkeleton()
{
+ BES_GFX_START(BES_GFX_UpdateSkeleton);
+
if(!simpleSkeletonInitiated)
initSimpleSkeleton();
// just update
@@ -844,6 +855,8 @@
simpleSkeletonManualObject->position(beams[i].p2->smoothpos);
simpleSkeletonManualObject->end();
}
+
+ BES_GFX_STOP(BES_GFX_UpdateSkeleton);
}
void Beam::moveOrigin(Vector3 offset)
@@ -909,6 +922,7 @@
void Beam::checkBeamMaterial()
{
+ BES_GFX_START(BES_GFX_checkBeamMaterial);
if(MaterialManager::getSingleton().resourceExists("mat-beam-0"))
return;
int i = 0;
@@ -928,6 +942,7 @@
mat->setLightingEnabled(false);
mat->setReceiveShadows(false);
}
+ BES_GFX_STOP(BES_GFX_checkBeamMaterial);
}
void Beam::activate()
@@ -988,6 +1003,7 @@
//called by the network thread
void Beam::pushNetwork(char* data, int size)
{
+ BES_GFX_START(BES_GFX_pushNetwork);
if(!oob3) return;
if ((unsigned int)size==(netbuffersize+sizeof(oob_t)))
{
@@ -1023,10 +1039,12 @@
}
netcounter++;
pthread_mutex_unlock(&net_mutex);
+ BES_GFX_STOP(BES_GFX_pushNetwork);
}
void Beam::calcNetwork()
{
+ BES_GFX_START(BES_GFX_calcNetwork);
Vector3 apos=Vector3::ZERO;
if (netcounter<4) return;
//we must update Nodes positions from available network informations
@@ -1167,6 +1185,7 @@
ssm->trigStop(trucknum, SS_TRIG_REVERSE_GEAR);
#endif //OPENAL
+ BES_GFX_STOP(BES_GFX_calcNetwork);
}
void Beam::addPressure(float v)
@@ -1188,6 +1207,7 @@
void Beam::calc_masses2(Real total, bool reCalc)
{
+ BES_GFX_START(BES_GFX_calc_masses2);
bool debugMass=(SETTINGS.getSetting("Debug Truck Mass")=="Yes");
@@ -1302,6 +1322,8 @@
if (beams[i].p2->mass<mass) mass=beams[i].p2->mass;
}
LogManager::getSingleton().logMessage("Beams status:
unstable:"+StringConverter::toString(unst)+"
wheel:"+StringConverter::toString(wunst)+"
normal:"+StringConverter::toString(free_beam-unst-wunst-st)+"
superstable:"+StringConverter::toString(st));
+
+ BES_GFX_STOP(BES_GFX_calc_masses2);
}
// this recalcs the masses, useful when the gravity was changed...
@@ -5257,6 +5279,8 @@
void Beam::calcBox()
{
+ BES_GFX_START(BES_GFX_calcBox);
+
minx=nodes[0].AbsPosition.x;
maxx=nodes[0].AbsPosition.x;
miny=nodes[0].AbsPosition.y;
@@ -5284,10 +5308,13 @@
maxy+=0.3;
minz-=0.3;
maxz+=0.3;
+
+ BES_GFX_STOP(BES_GFX_calcBox);
}
void Beam::calcNodeConnectivityGraph()
{
+ BES_GFX_START(BES_GFX_calcNodeConnectivityGraph);
int i;
nodetonodeconnections.resize(free_node, std::vector< int >());
@@ -5303,6 +5330,7 @@
nodebeamconnections[beams[i].p2->pos].push_back(i);
}
}
+ BES_GFX_STOP(BES_GFX_calcNodeConnectivityGraph);
}
void Beam::updateContacterNodes()
@@ -5560,6 +5588,7 @@
int Beam::calculateDriverPos(Vector3 &pos, Quaternion &rot)
{
+ BES_GFX_START(BES_GFX_calculateDriverPos);
if(!this || !driverSeat) return 1;
Vector3
normal=(nodes[driverSeat->nodey].smoothpos-nodes[driverSeat->noderef].smoothpos).crossProduct(nodes[driverSeat->nodex].smoothpos-nodes[driverSeat->noderef].smoothpos);
normal.normalise();
@@ -5572,6 +5601,7 @@
refx.normalise();
Vector3 refy=refx.crossProduct(normal);
rot = Quaternion(refx, normal, refy) * driverSeat->rot *
Quaternion(Degree(180), Vector3::UNIT_Y); // rotate towards the driving
direction
+ BES_GFX_STOP(BES_GFX_calculateDriverPos);
return 0;
}
@@ -6191,7 +6221,7 @@
parkingbrake=0;
fusedrag=Vector3::ZERO;
origin=Vector3::ZERO; //to fix
- pointCD->reset();
+ if(pointCD) pointCD->reset();
Vector3 cur_position = nodes[0].AbsPosition;
Vector3 cur_dir = nodes[cameranodepos[0]].RelPosition -
nodes[cameranodedir[0]].RelPosition;
@@ -6321,6 +6351,7 @@
//the instance called is the one of the current ACTIVATED truck
bool Beam::frameStep(Real dt, Beam** trucks, int numtrucks)
{
+ BES_GFX_START(BES_GFX_framestep);
/*LogManager::getSingleton().logMessage("BEAM: frame starting
dt="+StringConverter::toString(dt)
+"minx"+StringConverter::toString(minx)
+"maxx"+StringConverter::toString(maxx)
@@ -6389,6 +6420,7 @@
//if(networking)
// sendStreamData();
+ BES_GFX_STOP(BES_GFX_framestep);
fasted=1;
slowed=1;
@@ -6585,8 +6617,8 @@
#ifdef FEAT_TIMING
- if(statistics)
- statistics->frameStep(dt);
+ if(statistics) statistics->frameStep(dt);
+ if(statistics_gfx) statistics_gfx->frameStep(dt);
#endif
//we must take care of this
for (int t=0; t<numtrucks; t++)
@@ -6643,6 +6675,7 @@
void Beam::sendStreamData()
{
+ BES_GFX_START(BES_GFX_sendStreamData);
#ifdef USE_SOCKETW
int t = netTimer.getMilliseconds();
if (t-last_net_time < 100)
@@ -6732,10 +6765,12 @@
//memcpy(send_buffer+sizeof(oob_t), (char*)send_buffer,
send_buffer_len);
this->addPacket(MSG2_STREAM_DATA, packet_len, send_buffer);
#endif //SOCKETW
+ BES_GFX_STOP(BES_GFX_sendStreamData);
}
void Beam::receiveStreamData(unsigned int &type, int &source, unsigned int
&_streamid, char *buffer, unsigned int &len)
{
+ BES_GFX_START(BES_GFX_receiveStreamData);
if(state != NETWORKED) return; // this should not happen
// TODO: FIX
//if(this->source != source || this->streamid != streamid) return; //
data not for us
@@ -6747,10 +6782,12 @@
{
pushNetwork(buffer, len);
}
+ BES_GFX_STOP(BES_GFX_receiveStreamData);
}
void Beam::calcAnimators(int flagstate, float &cstate, int &div, Real timer,
float opt1, float opt2, float opt3)
{
+ BES_GFX_START(BES_GFX_calcAnimators);
int flag_state=flagstate;
Real dt = timer;
float option1 = opt1;
@@ -7149,6 +7186,7 @@
div++;
}
+ BES_GFX_STOP(BES_GFX_calcAnimators);
}
@@ -7306,33 +7344,24 @@
int increased_accuracy=0;
float inverted_dt=1.0f/dt;
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStart(BeamThreadStats::WholeTruckCalc);
-#endif
+ BES_START(BES_CORE_WholeTruckCalc);
+
//engine callback
if (state==ACTIVATED && engine)
{
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStart(BeamThreadStats::TruckEngine);
-#endif
+ BES_START(BES_CORE_TruckEngine);
+
if(engine)
engine->update(dt, doUpdate);
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::TruckEngine);
-#endif
+
+ BES_STOP(BES_CORE_TruckEngine);
}
// if (doUpdate) mWindow->setDebugText(engine->status);
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStart(BeamThreadStats::Beams);
-#endif
+ BES_START(BES_CORE_Beams);
-//springs
+ //springs
Vector3 dis;
Vector3 v;
for (i=0; i<free_beam; i++)
@@ -7550,6 +7579,9 @@
}
}
+ BES_STOP(BES_CORE_Beams);
+ BES_START(BES_CORE_AnimatedProps);
+
//animate props
for (int propi=0; propi<free_prop; propi++)
{
@@ -7837,6 +7869,9 @@
props[propi].rot = Quaternion(Degree(rz), Vector3::UNIT_Z) *
Quaternion(Degree(ry), Vector3::UNIT_Y) * Quaternion(Degree(rx),
Vector3::UNIT_X);
}
+ BES_STOP(BES_CORE_AnimatedProps);
+ BES_START(BES_CORE_SkeletonColouring);
+
//skeleton colouring
if (((skeleton && doUpdate) || replay) )
{
@@ -7867,13 +7902,9 @@
}
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Beams);
+ BES_STOP(BES_CORE_SkeletonColouring);
+ BES_START(BES_CORE_Rigidifiers);
- if(statistics)
- statistics->queryStart(BeamThreadStats::Rigidifiers);
-#endif
//the rigidifiers
for (i=0; i<free_rigidifier; i++)
{
@@ -7909,11 +7940,11 @@
rigidifiers[i].b->Forces += -va - vc;
rigidifiers[i].lastalpha=alphap;
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Rigidifiers);
-#endif
+
+ BES_STOP(BES_CORE_Rigidifiers);
+ BES_START(BES_CORE_Hooks);
+
//aposition=Vector3::ZERO;
if (state==ACTIVATED) //force feedback sensors
{
@@ -7965,10 +7996,9 @@
}
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStart(BeamThreadStats::Ropes);
-#endif
+ BES_STOP(BES_CORE_Hooks);
+ BES_START(BES_CORE_Ropes);
+
if (ropes.size())
{
for(std::vector <rope_t>::iterator it = ropes.begin();
it!=ropes.end(); it++)
@@ -7983,10 +8013,9 @@
}
}
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Ropes);
-#endif
+
+ BES_STOP(BES_CORE_Ropes);
+
//mouse stuff
if (mousenode!=-1)
{
@@ -7997,13 +8026,14 @@
// START Slidenode section
/////////////////////////////////////////////////
// these must be done before the integrator, or else the forces are not
calculated properly
+ BES_START(BES_CORE_SlideNodes);
updateSlideNodeForces(dt);
+ BES_STOP(BES_CORE_SlideNodes);
// END Slidenode section
/////////////////////////////////////////////////
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStart(BeamThreadStats::Nodes);
-#endif
+
+ BES_START(BES_CORE_Nodes);
+
float tminx=nodes[0].AbsPosition.x;
float tmaxx=tminx;
float tminy=nodes[0].AbsPosition.y;
@@ -8227,42 +8257,30 @@
miny=tminy-0.3;maxy=tmaxy+0.3;
minz=tminz-0.3;maxz=tmaxz+0.3;
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Nodes);
+ BES_STOP(BES_CORE_Nodes);
+ BES_START(BES_CORE_Turboprop);
- if(statistics)
- statistics->queryStart(BeamThreadStats::Turboprop);
-#endif
//turboprop forces
for (i=0; i<free_aeroengine; i++)
if(aeroengines[i]) aeroengines[i]->updateForces(dt, doUpdate);
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Turboprop);
- if(statistics)
- statistics->queryStart(BeamThreadStats::Screwprop);
-#endif
+ BES_STOP(BES_CORE_Turboprop);
+ BES_START(BES_CORE_Screwprop);
+
//screwprop forces
for (i=0; i<free_screwprop; i++)
if(screwprops[i]) screwprops[i]->updateForces(doUpdate);
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Screwprop);
- if(statistics)
- statistics->queryStart(BeamThreadStats::Wing);
-#endif
+
+ BES_STOP(BES_CORE_Screwprop);
+ BES_START(BES_CORE_Wing);
+
//wing forces
for (i=0; i<free_wing; i++)
if(wings[i].fa) wings[i].fa->updateForces();
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Wing);
- if(statistics)
- statistics->queryStart(BeamThreadStats::FuseDrag);
-#endif
+ BES_STOP(BES_CORE_Wing);
+ BES_START(BES_CORE_FuseDrag);
+
//compute fuse drag
if (fuseAirfoil)
{
@@ -8291,25 +8309,19 @@
//fuselage as an airfoil + parasitic drag (half fuselage front
surface almost as a flat plane!)
fusedrag=((cx*s+fuseWidth*fuseWidth*0.5)*0.5*airdensity*wspeed/free_node)*wind;
//free_node is never null
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::FuseDrag);
- if(statistics)
- statistics->queryStart(BeamThreadStats::Airbrakes);
-#endif
+ BES_STOP(BES_CORE_FuseDrag);
+ BES_START(BES_CORE_Airbrakes);
+
//airbrakes
for (int i=0; i<free_airbrake; i++)
{
airbrakes[i]->applyForce();
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Airbrakes);
- if(statistics)
- statistics->queryStart(BeamThreadStats::Buoyance);
-#endif
+ BES_STOP(BES_CORE_Airbrakes);
+ BES_START(BES_CORE_Buoyance);
+
//water buoyance
mrtime+=dt;
if (free_buoycab && water)
@@ -8338,15 +8350,10 @@
}
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Buoyance);
-#endif
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStart(BeamThreadStats::Wheels);
-#endif
+ BES_STOP(BES_CORE_Buoyance);
+ BES_START(BES_CORE_Axles);
+
//wheel speed
Real wspeed=0;
//wheel stuff
@@ -8377,6 +8384,8 @@
intertorque[i*2+3]+=torque*0.5f;
}
}
+
+
// new-style Axles
// loop through all axles for interaxle torque, this is the torsion to
keep
// the axles aligned with each other as if they connected by a shaft
@@ -8437,6 +8446,8 @@
intertorque[axles[i].wheel_1] = diff_data.out_torque[0];
intertorque[axles[i].wheel_2] = diff_data.out_torque[1];
}
+ BES_STOP(BES_CORE_Axles);
+ BES_START(BES_CORE_Wheels);
for (i=0; i<free_wheel; i++)
{
@@ -8553,14 +8564,9 @@
}
}
+ BES_STOP(BES_CORE_Wheels);
+ BES_START(BES_CORE_Shocks);
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Wheels);
-
- if(statistics)
- statistics->queryStart(BeamThreadStats::Shocks);
-#endif
//update position
// if(free_node != 0)
// aposition/=(Real)(free_node);
@@ -8601,13 +8607,10 @@
#endif //OPENAL
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Shocks);
- if(statistics)
- statistics->queryStart(BeamThreadStats::Hydros);
-#endif
+ BES_STOP(BES_CORE_Shocks);
+ BES_START(BES_CORE_Hydros);
+
//direction
if (hydrodirstate!=0 || hydrodircommand!=0)
{
@@ -8721,11 +8724,10 @@
}
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Hydros);
-#endif
+ BES_STOP(BES_CORE_Hydros);
+ BES_START(BES_CORE_Commands);
+
// forward things to trailers
if (state==ACTIVATED && forwardcommands)
{
@@ -8758,10 +8760,6 @@
}
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStart(BeamThreadStats::Commands);
-#endif
// commands
if (hascommands)
{
@@ -9124,13 +9122,9 @@
}
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Commands);
- if(statistics)
- statistics->queryStop(BeamThreadStats::WholeTruckCalc);
-#endif
+ BES_STOP(BES_CORE_Commands);
+ BES_START(BES_CORE_Replay);
//we also store a new replay frame
if(replay)
@@ -9157,17 +9151,17 @@
}
}
+ BES_STOP(BES_CORE_Replay);
+ BES_STOP(BES_CORE_WholeTruckCalc);
+
}
//truck-truck collisions
void Beam::truckTruckCollisions(Real dt, Beam** trucks, int numtrucks)
{
+ if(!pointCD) return;
+ BES_START(BES_CORE_Contacters);
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStart(BeamThreadStats::Contacters);
-#endif
-
float trwidth;
int t;
@@ -9177,7 +9171,7 @@
float inverted_dt=1.0f/dt;
- pointCD->update(trucks, numtrucks);
+ if(pointCD) pointCD->update(trucks, numtrucks);
// TODO Unused Varaible
@@ -9366,15 +9360,14 @@
}
}
-#ifdef FEAT_TIMING
- if(statistics)
- statistics->queryStop(BeamThreadStats::Contacters);
-#endif
+ BES_STOP(BES_CORE_Contacters);
}
// call this once per frame in order to update the skidmarks
void Beam::updateSkidmarks()
{
+ BES_START(BES_CORE_Skidmarks);
+
for(int i=0;i<free_wheel;i++)
{
// ignore wheels without data
@@ -9389,6 +9382,8 @@
//LogManager::getSingleton().logMessage("updating skidmark visuals");
for(int i=0;i<free_wheel;i++)
if(skidtrails[i]) skidtrails[i]->update();
+
+ BES_STOP(BES_CORE_Skidmarks);
}
@@ -9610,6 +9605,7 @@
return;
if(flaresMode==2 && !isCurrent)
enableAll=false;
+ BES_GFX_START(BES_GFX_updateFlares);
int i;
//okay, this is just ugly, we have flares in props!
//we have to update them here because they run
@@ -9842,6 +9838,7 @@
}
if(keysleep)
mTimeUntilNextToggle = 0.2;
+ BES_GFX_STOP(BES_GFX_updateFlares);
}
@@ -9884,6 +9881,7 @@
void Beam::updateProps()
{
+ BES_GFX_START(BES_GFX_updateProps);
int i;
//the props
for (i=0; i<free_prop; i++)
@@ -9911,6 +9909,7 @@
}
//we also consider airbrakes as props
for (i=0; i<free_airbrake; i++)
airbrakes[i]->updatePosition((float)airbrakeval/5.0);
+ BES_GFX_STOP(BES_GFX_updateProps);
}
void Beam::toggleCustomParticles()
@@ -9934,6 +9933,7 @@
void Beam::updateSoundSources()
{
+ BES_GFX_START(BES_GFX_updateSoundSources);
#ifdef USE_OPENAL
if(!ssm) return;
for (int i=0; i<free_soundsource; i++)
@@ -9944,10 +9944,12 @@
ssm->modulate(trucknum, SS_MOD_AIRSPEED,
nodes[0].Velocity.length()*1.9438);
ssm->modulate(trucknum, SS_MOD_WHEELSPEED, WheelSpeed*3.6);
#endif //OPENAL
+ BES_GFX_STOP(BES_GFX_updateSoundSources);
}
void Beam::updateVisual(float dt)
{
+ BES_GFX_START(BES_GFX_updateVisual);
int i;
Vector3 ref=Vector3(0.0,1.0,0.0);
autoBlinkReset();
@@ -10109,8 +10111,11 @@
updateSimpleSkeleton();
//updateDebugOverlay();
}
+
//Flex body
+ BES_GFX_START(BES_GFX_updateFlexBodies);
for (i=0; i<free_flexbody; i++) flexbodies[i]->flexit();
+ BES_GFX_STOP(BES_GFX_updateFlexBodies);
if (netLabelNode && netMT && netMT->isVisible())
{
@@ -10132,6 +10137,8 @@
//netMT->setAdditionalHeight((maxy-miny)+h+0.1);
netMT->setVisible(true);
}
+
+ BES_GFX_STOP(BES_GFX_updateVisual);
}
@@ -10983,6 +10990,7 @@
void Beam::updateNetworkInfo()
{
+ BES_GFX_START(BES_GFX_updateNetworkInfo);
#ifdef USE_SOCKETW
if(!net) return;
bool remote = (state == NETWORKED);
@@ -11048,6 +11056,7 @@
deletion_Objects.push_back(netMT);
}
#endif //SOCKETW
+ BES_GFX_STOP(BES_GFX_updateNetworkInfo);
}
void Beam::deleteNetTruck()
Modified: trunk/source/main/Beam.h
===================================================================
--- trunk/source/main/Beam.h 2010-08-06 17:10:41 UTC (rev 1504)
+++ trunk/source/main/Beam.h 2010-08-07 01:11:21 UTC (rev 1505)
@@ -633,7 +633,7 @@
CmdKeyInertia *hydroInertia;
CmdKeyInertia *cmdInertia;
#ifdef FEAT_TIMING
- BeamThreadStats *statistics;
+ BeamThreadStats *statistics, *statistics_gfx;
#endif
Modified: trunk/source/main/BeamStats.cpp
===================================================================
--- trunk/source/main/BeamStats.cpp 2010-08-06 17:10:41 UTC (rev 1504)
+++ trunk/source/main/BeamStats.cpp 2010-08-07 01:11:21 UTC (rev 1505)
@@ -19,7 +19,7 @@
*/
#include "BeamStats.h"
-#ifdef FEAT_BEAMSTATS
+#ifdef FEAT_TIMING
// thomas, 11th of March 2008
@@ -30,10 +30,64 @@
using namespace Ogre;
BeamEngineStats *BeamEngineStats::myInstance = 0;
+Ogre::String BeamEngineStats::typeDescriptions[MAX_TIMINGS];
+Ogre::String BeamEngineStats::typeDescriptions_gfx[MAX_TIMINGS];
BeamEngineStats::BeamEngineStats()
{
enabled=true;
+ updateTimeGUI=0;
+ stats =
OverlayManager::getSingleton().getOverlayElement("tracks/DebugBeamTiming/Text");
+
+ // setup descriptions
+ typeDescriptions[BES_CORE_WholeTruckCalc] = "Sum";
+ typeDescriptions[BES_CORE_Beams] = "Beams";
+ typeDescriptions[BES_CORE_Nodes] = "Nodes";
+ typeDescriptions[BES_CORE_TruckEngine] = "TruckEngine";
+ typeDescriptions[BES_CORE_Rigidifiers] = "Rigidifiers";
+ typeDescriptions[BES_CORE_Ropes] = "Ropes";
+ typeDescriptions[BES_CORE_Turboprop] = "Turboprop";
+ typeDescriptions[BES_CORE_Screwprop] = "Screwprop";
+ typeDescriptions[BES_CORE_Wing] = "Wing";
+ typeDescriptions[BES_CORE_FuseDrag] = "FuseDrag";
+ typeDescriptions[BES_CORE_Airbrakes] = "Airbrakes";
+ typeDescriptions[BES_CORE_Buoyance] = "Buoyance";
+ typeDescriptions[BES_CORE_Contacters] = "Contacters";
+ typeDescriptions[BES_CORE_CollisionCab] = "CollisionCab";
+ typeDescriptions[BES_CORE_Wheels] = "Wheels";
+ typeDescriptions[BES_CORE_Shocks] = "Shocks";
+ typeDescriptions[BES_CORE_Hydros] = "Hydros";
+ typeDescriptions[BES_CORE_Commands] = "Commands";
+ typeDescriptions[BES_CORE_AnimatedProps] = "AnimatedProps";
+ typeDescriptions[BES_CORE_SkeletonColouring] = "SkeletonColouring";
+ typeDescriptions[BES_CORE_Hooks] = "Hooks";
+ typeDescriptions[BES_CORE_SlideNodes] = "SlideNodes";
+ typeDescriptions[BES_CORE_Axles] = "Axles";
+ typeDescriptions[BES_CORE_Replay] = "Replay";
+ typeDescriptions[BES_CORE_Skidmarks] = "Skidmarks";
+
+
+ typeDescriptions_gfx[BES_GFX_UpdateSkeleton] =
"UpdateSkeleton";
+ typeDescriptions_gfx[BES_GFX_ScaleTruck] = "ScaleTruck";
+ typeDescriptions_gfx[BES_GFX_checkBeamMaterial] =
"checkBeamMaterial";
+ typeDescriptions_gfx[BES_GFX_pushNetwork] = "pushNetwork";
+ typeDescriptions_gfx[BES_GFX_calcNetwork] = "calcNetwork";
+ typeDescriptions_gfx[BES_GFX_calc_masses2] =
"calc_masses2";
+ typeDescriptions_gfx[BES_GFX_calcBox] = "calcBox";
+ typeDescriptions_gfx[BES_GFX_calcNodeConnectivityGraph] =
"calcNodeConGraph";
+ typeDescriptions_gfx[BES_GFX_calculateDriverPos] =
"calculateDriverPos";
+ typeDescriptions_gfx[BES_GFX_framestep] = "framestep";
+ typeDescriptions_gfx[BES_GFX_sendStreamData] =
"sendStreamData";
+ typeDescriptions_gfx[BES_GFX_receiveStreamData] =
"receiveStreamData";
+ typeDescriptions_gfx[BES_GFX_calcAnimators] =
"calcAnimators";
+ typeDescriptions_gfx[BES_GFX_updateFlares] =
"updateFlares";
+ typeDescriptions_gfx[BES_GFX_updateProps] = "updateProps";
+ typeDescriptions_gfx[BES_GFX_updateSoundSources] =
"updateSoundSources";
+ typeDescriptions_gfx[BES_GFX_updateVisual] =
"updateVisual";
+ typeDescriptions_gfx[BES_GFX_updateFlexBodies] =
"updateFlexBodies";
+ typeDescriptions_gfx[BES_GFX_updateNetworkInfo] =
"updateNetworkInfo";
+
+ stats->setCaption("calculating ...");
}
BeamEngineStats::~BeamEngineStats()
@@ -48,17 +102,26 @@
return *myInstance;
}
-BeamThreadStats *BeamEngineStats::getClient(int number)
+BeamThreadStats *BeamEngineStats::getClient(int number, int type)
{
- if(enabled)
- {
- BeamThreadStats *bts = new BeamThreadStats();
- if(statClients[number]!=0)
- delete statClients[number];
- statClients[number] = bts;
- return bts;
- } else
+ if(!enabled)
return 0;
+ BeamThreadStats *bts = new BeamThreadStats(type);
+
+ // TODO: check for duplicates
+ //if(statClients[number]!=0)
+ // delete statClients[number];
+
+ stats_entry_t e;
+ e.trucknum = number;
+ e.stat = bts;
+
+ if(type == BES_CORE)
+ statClients.push_back(e);
+ else if(type == BES_GFX)
+ statClientsGFX.push_back(e);
+
+ return bts;
}
void BeamEngineStats::setup(bool enabled)
@@ -68,9 +131,11 @@
bool BeamEngineStats::updateGUI(float dt, int current_truck, Beam **trucks)
{
- static OverlayElement *stats = 0;
- if(!stats)
- stats =
OverlayManager::getSingleton().getOverlayElement("tracks/DebugBeamTiming/Text");
+ updateTimeGUI += dt;
+ if(updateTimeGUI < 5.0f)
+ return true;
+
+ updateTimeGUI = 0;
if(statClients.size() == 0)
return true;
@@ -78,34 +143,80 @@
if(!stats->isVisible())
return true;
- std::map<int, BeamThreadStats*>::iterator it;
String msg = "";
- for(it=statClients.begin(); it!=statClients.end(); it++)
+
+ char tmp[1024]="";
+ char tmp_gfx[1024]="";
+ char line[1024]="";
+
+ for(int c = 0; c < statClients.size(); c++)
{
//if(it->first != current_truck || trucks[it->first]->state ==
SLEEPING)
- if(trucks[it->first]->state == SLEEPING)
+ if(trucks[statClients[c].trucknum]->state == SLEEPING)
continue;
- double sum=0, t=0, perc=0;
+ BeamThreadStats *core = statClients[c].stat;
+ BeamThreadStats *gfx = statClientsGFX[c].stat;
- msg += "\n";
- msg += "Truck "+StringConverter::toString(it->first) + "\n";
- msg += " Graphic Frames: " +
StringConverter::toString(it->second->getFramecount()) + "\n";
- msg += " Physic Frames: " +
StringConverter::toString(it->second->getPhysFrameCount()) + "\n";
+ double sum=0, sum_gfx=0, t=0, perc=0;
+ msg += "Stats Timestep: 5 Seconds\n";
+ msg += "Truck
"+StringConverter::toString(statClients[c].trucknum) + "\n";
+ msg += " Graphic Frames: " +
StringConverter::toString(core->getFramecount()) + "\n";
+ msg += " Physic Frames: " +
StringConverter::toString(core->getPhysFrameCount()) + "\n";
+
+ sprintf(line, "%-46s | %-46s\n", "============== PHYSICS
==============", "================ GFX ================");
+ msg += String(line);
- sum = it->second->getTiming(BeamThreadStats::WholeTruckCalc);
+ sum = core->getTiming(BES_CORE_WholeTruckCalc);
+ sum_gfx = core->getTiming(BES_CORE_WholeTruckCalc);
if(sum==0)
continue;
- msg += " sum: 100%
("+StringConverter::toString((Real)sum)+"s\n";
-
+ sprintf(tmp, " %20s: % 10.4f%% : %1.6fs", "Whole truck",
100.0f, sum);
+ sprintf(tmp_gfx, " %20s: % 10.4f%% : %1.6fs", "FrameTime",
100.0f, sum_gfx);
+ sprintf(line, "%-46s | %-46s\n", tmp, tmp_gfx);
+ msg += String(line);
+
+ float sum_real = 0, sum_real_gfx = 0;
for(int i=1;i<MAX_TIMINGS;i++)
{
- t = it->second->getTiming(i);
- perc=(int)(100.0 * t / sum);
- if(perc>=2)
- msg += " " +
BeamThreadStats::typeDescriptions[i] + ":
"+StringConverter::toString((int)perc)+"%
("+StringConverter::toString((Real)t)+"s)\n";
+ sprintf(tmp, "");
+ sprintf(tmp_gfx, "");
+
+ bool addLine=false;
+ if(!typeDescriptions[i].empty())
+ {
+ t = core->getTiming(i);
+ sum_real += t;
+ perc = (100.0 * t / sum);
+ sprintf(tmp, " %20s: % 10.4f%% : %1.6fs",
typeDescriptions[i].c_str(), perc, t);
+ addLine=true;
+ }
+ if(!typeDescriptions_gfx[i].empty())
+ {
+ t = gfx->getTiming(i);
+ sum_real_gfx += t;
+ perc = (100.0 * t / sum_gfx);
+ sprintf(tmp_gfx, " %20s: % 10.4f%% : %1.6fs",
typeDescriptions_gfx[i].c_str(), perc, t);
+ addLine=true;
+ }
+ if(!addLine) break;
+ sprintf(line, "%-46s | %-46s\n", tmp, tmp_gfx);
+ msg += String(line);
+
}
+ // find out the rest time
+ {
+ float unknown_time = sum - sum_real;
+ perc=(int)(100.0 * unknown_time / sum);
+ sprintf(tmp, " %20s: % 10.4f%% : %1.6fs", "Unknown",
perc, unknown_time);
+
+ float unknown_time_gfx = sum_gfx - sum_real_gfx;
+ perc=(int)(100.0 * unknown_time_gfx / sum_gfx);
+ sprintf(tmp_gfx, " %20s: % 10.4f%% : %1.6fs",
"Unknown", perc, unknown_time_gfx);
+ sprintf(line, "%-46s | %-46s\n", tmp, tmp_gfx);
+ msg += String(line);
+ }
}
stats->setCaption(msg);
return true;
@@ -114,10 +225,7 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-Ogre::String BeamThreadStats::typeDescriptions[MAX_TIMINGS];
-
-BeamThreadStats::BeamThreadStats()
+BeamThreadStats::BeamThreadStats(int _type) : stype(_type)
{
for (int i=0; i<MAX_TIMINGS; i++)
{
@@ -127,26 +235,7 @@
}
framecounter=0;
physcounter=0;
-
- // setup descriptions
- BeamThreadStats::typeDescriptions[WholeTruckCalc] = "Sum";
- BeamThreadStats::typeDescriptions[Beams] = "Beams";
- BeamThreadStats::typeDescriptions[Nodes] = "Nodes";
- BeamThreadStats::typeDescriptions[TruckEngine] = "TruckEngine";
- BeamThreadStats::typeDescriptions[Rigidifiers] = "Rigidifiers";
- BeamThreadStats::typeDescriptions[Ropes] = "Ropes";
- BeamThreadStats::typeDescriptions[Turboprop] = "Turboprop";
- BeamThreadStats::typeDescriptions[Screwprop] = "Screwprop";
- BeamThreadStats::typeDescriptions[Wing] = "Wing";
- BeamThreadStats::typeDescriptions[FuseDrag] = "FuseDrag";
- BeamThreadStats::typeDescriptions[Airbrakes] = "Airbrakes";
- BeamThreadStats::typeDescriptions[Buoyance] = "Buoyance";
- BeamThreadStats::typeDescriptions[Contacters] = "Contacters";
- BeamThreadStats::typeDescriptions[CollisionCab] = "CollisionCab";
- BeamThreadStats::typeDescriptions[Wheels] = "Wheels";
- BeamThreadStats::typeDescriptions[Shocks] = "Shocks";
- BeamThreadStats::typeDescriptions[Hydros] = "Hydros";
- BeamThreadStats::typeDescriptions[Commands] = "Commands";
+ updateTime=0;
}
BeamThreadStats::~BeamThreadStats()
@@ -155,8 +244,13 @@
void BeamThreadStats::frameStep(float ds)
{
- for (int i=0; i<MAX_TIMINGS; i++)
- timings[i]=0;
+ updateTime += ds;
+ if(updateTime > 5.0f)
+ {
+ for (int i=0; i<MAX_TIMINGS; i++)
+ timings[i]=0;
+ updateTime = 0;
+ }
framecounter++;
}
@@ -172,12 +266,17 @@
timings[type] += (timings_start[type]->elapsed());
- if(type == WholeTruckCalc)
+ if(stype == BES_CORE && type == BES_CORE_WholeTruckCalc)
{
// secure timings
physcounter++;
memcpy(savedTimings, timings, sizeof(double) * MAX_TIMINGS);
}
+ else if(stype == BES_GFX)
+ {
+ // secure timings
+ memcpy(savedTimings, timings, sizeof(double) * MAX_TIMINGS);
+ }
}
unsigned int BeamThreadStats::getPhysFrameCount()
@@ -196,5 +295,5 @@
}
-#endif
+#endif //FEAT_TIMING
Modified: trunk/source/main/BeamStats.h
===================================================================
--- trunk/source/main/BeamStats.h 2010-08-06 17:10:41 UTC (rev 1504)
+++ trunk/source/main/BeamStats.h 2010-08-07 01:11:21 UTC (rev 1505)
@@ -29,14 +29,91 @@
class Beam;
class PrecisionTimer;
-#ifdef FEAT_BEAMSTATS
+#ifdef FEAT_TIMING
-#define MAX_TIMINGS 20
+#define BES_START(x) statistics->queryStart(x)
+#define BES_STOP(x) statistics->queryStop (x)
+#define BES_GFX_START(x) statistics_gfx->queryStart(x)
+#define BES_GFX_STOP(x) statistics_gfx->queryStop (x)
+
+
+#else //FEAT_TIMING
+
+#define BES_START(x)
+#define BES_STOP(x)
+#define BES_GFX_START(x)
+#define BES_GFX_STOP(x)
+
+#endif //FEAT_TIMING
+
+#ifdef FEAT_TIMING
+
+// Beam engine stats type
+enum {
+ BES_CORE,
+ BES_GFX
+};
+
+// stats items
+#define MAX_TIMINGS 60 // this number must fit with the amount of enum items
below
+enum {
+ BES_CORE_WholeTruckCalc=0,
+ BES_CORE_Beams,
+ BES_CORE_Nodes,
+ BES_CORE_TruckEngine,
+ BES_CORE_Rigidifiers,
+ BES_CORE_Ropes,
+ BES_CORE_Turboprop,
+ BES_CORE_Screwprop,
+ BES_CORE_Wing,
+ BES_CORE_FuseDrag,
+ BES_CORE_Airbrakes,
+ BES_CORE_Buoyance,
+ BES_CORE_Contacters,
+ BES_CORE_CollisionCab,
+ BES_CORE_Wheels,
+ BES_CORE_Shocks,
+ BES_CORE_Hydros,
+ BES_CORE_Commands,
+ BES_CORE_AnimatedProps,
+ BES_CORE_SkeletonColouring,
+ BES_CORE_Hooks,
+ BES_CORE_SlideNodes,
+ BES_CORE_Axles,
+ BES_CORE_Replay,
+ BES_CORE_Skidmarks
+ // if you change this, change MAX_TIMINGS as well
+};
+
+enum {
+ BES_GFX_framestep=0,
+ BES_GFX_UpdateSkeleton,
+ BES_GFX_ScaleTruck,
+ BES_GFX_checkBeamMaterial,
+ BES_GFX_pushNetwork,
+ BES_GFX_calcNetwork,
+ BES_GFX_calc_masses2,
+ BES_GFX_calcBox,
+ BES_GFX_calcNodeConnectivityGraph,
+ BES_GFX_calculateDriverPos,
+ BES_GFX_sendStreamData,
+ BES_GFX_receiveStreamData,
+ BES_GFX_calcAnimators,
+ BES_GFX_updateFlares,
+ BES_GFX_updateProps,
+ BES_GFX_updateSoundSources,
+ BES_GFX_updateVisual,
+ BES_GFX_updateFlexBodies,
+ BES_GFX_updateNetworkInfo
+ // if you change this, change MAX_TIMINGS as well
+};
+
+
#define BES BeamEngineStats::getInstance()
class BeamThreadStats : public MemoryAllocatedObject
{
public:
- BeamThreadStats();
+ BeamThreadStats(int type);
~BeamThreadStats();
void queryStart(int type);
void queryStop(int type);
@@ -46,9 +123,6 @@
unsigned int getPhysFrameCount();
double getTiming(int type);
-
- static enum types {WholeTruckCalc=0, Beams, Nodes, TruckEngine,
Rigidifiers, Ropes, Turboprop, Screwprop, Wing, FuseDrag, Airbrakes, Buoyance,
Contacters, CollisionCab, Wheels, Shocks, Hydros, Commands};
- static Ogre::String typeDescriptions[MAX_TIMINGS];
private:
PrecisionTimer *timings_start[MAX_TIMINGS];
double timings[MAX_TIMINGS];
@@ -56,6 +130,8 @@
Ogre::String stattext;
unsigned int framecounter;
unsigned int physcounter;
+ float updateTime;
+ int stype;
};
class BeamEngineStats : public MemoryAllocatedObject
@@ -63,22 +139,32 @@
public:
bool updateGUI(float dt, int current_truck, Beam **trucks);
void setup(bool enabled);
- BeamThreadStats *getClient(int number);
+ BeamThreadStats *getClient(int number, int type);
static BeamEngineStats & getInstance();
~BeamEngineStats();
protected:
BeamEngineStats();
BeamEngineStats(const BeamEngineStats&);
BeamEngineStats& operator= (const BeamEngineStats&);
+ static Ogre::String typeDescriptions[MAX_TIMINGS];
+ static Ogre::String typeDescriptions_gfx[MAX_TIMINGS];
private:
+
+ typedef struct stats_entry_t {
+ int trucknum;
+ BeamThreadStats *stat;
+ } stats_entry_t;
bool enabled;
static BeamEngineStats *myInstance;
- std::map<int, BeamThreadStats*> statClients;
+ std::vector<stats_entry_t> statClients;
+ std::vector<stats_entry_t> statClientsGFX;
+ Ogre::OverlayElement *stats;
+ float updateTimeGUI;
};
-#endif
+#endif // FEAT_TIMING
-#endif
+#endif //__BeamStats_H__
Modified: trunk/source/main/CMakeLists.txt
===================================================================
--- trunk/source/main/CMakeLists.txt 2010-08-06 17:10:41 UTC (rev 1504)
+++ trunk/source/main/CMakeLists.txt 2010-08-07 01:11:21 UTC (rev 1505)
@@ -70,6 +70,10 @@
add_definitions("-DUSE_OIS_G27")
endif(ROR_USE_OIS_G27)
+if(ROR_FEAT_TIMING)
+ add_definitions("-DFEAT_TIMING")
+endif(ROR_FEAT_TIMING)
+
add_executable(RoR ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(RoR ${Ogre_LIBRARIES} ${Ogre_Terrain_LIBRARIES}
${Ogre_Paging_LIBRARIES} ${Ois_LIBRARIES} ${OS_LIBS} ${optional_libs})
windows_hacks(RoR)
Modified: trunk/source/main/Landusemap.cpp
===================================================================
--- trunk/source/main/Landusemap.cpp 2010-08-06 17:10:41 UTC (rev 1504)
+++ trunk/source/main/Landusemap.cpp 2010-08-07 01:11:21 UTC (rev 1505)
@@ -36,7 +36,7 @@
// this is the Height-Finder for the standart ogre Terrain Manager
Landusemap::Landusemap(String configFilename, Collisions *c, int _mapsizex,
int _mapsizez) :
- coll(c), mapsizex(_mapsizex), mapsizez(_mapsizez)
+ data(0), coll(c), mapsizex(_mapsizex), mapsizez(_mapsizez)
{
loadConfig(configFilename);
#ifndef USE_PAGED
@@ -51,6 +51,7 @@
ground_model_t *Landusemap::getGroundModelAt(int x, int z)
{
+ if(!data) return 0;
#ifdef USE_PAGED
// we return the default ground model if we are not anymore in this map
if (x < 0 || x >= mapsizex || z < 0 || z >= mapsizez)
@@ -131,6 +132,7 @@
}
}
}
+
#ifdef USE_PAGED
// process the config data and load the buffers finally
Forests::ColorMap *colourMap = Forests::ColorMap::load(textureFilename,
Forests::CHANNEL_COLOR);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel