Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1422 for code/branches


Ignore:
Timestamp:
May 25, 2008, 8:29:05 PM (16 years ago)
Author:
rgrieder
Message:
  • added a little text box to the HUD that says how much of the main loop we spend with rendering. (can easily be commented)
  • fixed a bug in KeyBinder.cc
Location:
code/branches/network
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/core/InputManager.cc

    r1414 r1422  
    5252  InputManager::InputManager() :
    5353      inputSystem_(0), keyboard_(0), mouse_(0),
    54       keyBinder_(0), buffer_(0),
    5554      joySticksSize_(0),
     55      keyBinder_(0), buffer_(0), keyDetector_(0),
    5656      state_(IS_UNINIT), stateRequest_(IS_UNINIT),
    5757      keyboardModifiers_(0)
  • code/branches/network/src/core/KeyBinder.cc

    r1420 r1422  
    4646{
    4747  // ###############################
    48   // ######      Button       ######
    49   // ###############################
    50 
     48  // ###  BufferedParamCommand   ###
     49  // ###############################
     50
     51  /**
     52  * Executes a buffered command. This is used for commands with additional
     53  * parameters.
     54  * @return True if command execution was successful or value was zero.
     55  */
    5156  bool BufferedParamCommand::execute()
    5257  {
     
    6469  }
    6570
     71  // ###############################
     72  // #####    SimpleCommand    #####
     73  // ###############################
     74
     75  /**
     76  * Executes a simple command with no additional paramters.
     77  * @return True if command execution was successful, false otherwise.
     78  */
    6679  bool SimpleCommand::execute(float abs, float rel)
    6780  {
     
    6982  }
    7083
     84  // ###############################
     85  // #####    ParamCommand     #####
     86  // ###############################
     87
     88  /**
     89  * Executes a parameter command. The commmand string is not directly executed,
     90  * but instead stored in a buffer list so that values can be combined.
     91  * @return Always true.
     92  */
    7193  bool ParamCommand::execute(float abs, float rel)
    7294  {
    73     BufferedParamCommand& paramCommand = *paramCommand_;
     95    BufferedParamCommand& cmd = *paramCommand_;
    7496    // command has an additional parameter
    75     if (bRelative_ && (rel > 0 || rel < 0))
    76     {
    77       // we have to calculate a relative movement.
    78       // paramModifier_ says how much one keystroke is
    79       paramCommand.value_ += paramModifier_ * rel;
    80     }
    81     else if (abs > 0 || abs < 0)
    82     {
    83       // we have to calculate absolute position of the axis.
    84       // Since there might be another axis that is affected, we have to wait and
    85       // store the result in a temporary place
    86       paramCommand.value_ = (paramCommand.value_ * paramCommand.nValuesAdded_ + paramModifier_ * abs)
    87                             /++paramCommand.nValuesAdded_;
     97    if (bRelative_)
     98    {
     99      if (rel != 0.0f)
     100      {
     101        // we have to calculate a relative movement.
     102        // paramModifier_ says how much one keystroke is
     103        cmd.value_ += paramModifier_ * rel;
     104      }
     105    }
     106    else if (abs != 0.0f)
     107    {
     108      // Usually, joy sticks create 'noise' (they return values if they're in 0 position)
     109      // and normally this is caught in tickInput(), but that threshold cannot be to high
     110      // in order to preserve accuracy. Instead, we have to catch the problem here. An example:
     111      // Someone only uses buttons with an active joystick. The joy stick value could then
     112      // be 0.05 for instance and the the key value 1. Without handling the problem, the final
     113      // value would be computed to (1+0.05)/2=0.5025 which is not what the user expects.
     114      float absQ = abs * abs;
     115      float valueQ = cmd.value_ * cmd.value_;
     116      if (absQ > 50.0f * valueQ) // ease up comparison by using quadratics
     117      {
     118        cmd.value_ = abs * paramModifier_;
     119        cmd.nValuesAdded_ = 1;
     120      }
     121      else if (absQ * 50.0f < valueQ)
     122      {
     123        // abs is too small, we just don't do anything
     124      }
     125      else
     126      {
     127        // we have to calculate the absolute position of the axis.
     128        // Since there might be another axis that is affected, we have to wait and
     129        // store the result in a temporary place
     130        cmd.value_ = (cmd.value_ * cmd.nValuesAdded_ + paramModifier_ * abs) / ++cmd.nValuesAdded_;
     131      }
    88132    }
    89133    return true;
    90134  }
     135
     136  // ###############################
     137  // #####       Button        #####
     138  // ###############################
    91139
    92140  void Button::clear()
     
    259307    return true;
    260308  }
     309
     310  // ###############################
     311  // #####      HalfAxis       #####
     312  // ###############################
    261313
    262314  void HalfAxis::clear()
     
    494546    SetConfigValue(mouseSensitivity_, 1.0f)  .description("Mouse sensitivity.");
    495547    SetConfigValue(bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value.");
    496     SetConfigValue(derivePeriod_, 0.1f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
     548    SetConfigValue(derivePeriod_, 0.5f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
    497549    SetConfigValue(mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived.");
    498550
  • code/branches/network/src/orxonox/Orxonox.cc

    r1414 r1422  
    466466    timer_->reset();
    467467
     468    float renderTime = 0.0f;
     469    float frameTime = 0.0f;
     470    clock_t time = 0;
     471
    468472    COUT(3) << "Orxonox: Starting the main loop." << std::endl;
    469473          while (!bAbort_)
     
    480484      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
    481485      evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[1]);
     486      frameTime += evt.timeSinceLastFrame;
    482487
    483488      // show the current time in the HUD
    484489      // HUD::getSingleton().setTime(now);
     490      if (frameTime > 0.4f)
     491      {
     492        HUD::getSingleton().setRenderTimeRatio(renderTime / frameTime);
     493        frameTime = 0.0f;
     494        renderTime = 0.0f;
     495      }
    485496
    486497      // Call those objects that need the real time
     498      for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
     499        it->tick((float)evt.timeSinceLastFrame);
     500      // Call the scene objects
    487501      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    488502        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    489       // Call the scene objects
    490       for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
    491         it->tick((float)evt.timeSinceLastFrame);
    492503      // TODO: currently a hack. Somehow the console doesn't work with OrxonoxClass
    493504      orxonoxConsole_->tick((float)evt.timeSinceLastFrame);
     
    497508      ogreRoot._fireFrameStarted(evt);
    498509
    499       ogreRoot._updateAllRenderTargets(); // only render in non-server mode
    500 
    501510      // get current time
    502511      now = timer_->getMilliseconds();
     512      calculateEventTime(now, eventTimes[2]);
     513
     514      ogreRoot._updateAllRenderTargets(); // only render in non-server mode
     515
     516      // get current time
     517      now = timer_->getMilliseconds();
    503518
    504519      // create an event to pass to the frameEnded method in ogre
    505520      evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]);
    506       evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[2]);
     521      renderTime += calculateEventTime(now, eventTimes[2]);
    507522
    508523      // again, just to be sure ogre works fine
  • code/branches/network/src/orxonox/hud/HUD.cc

    r1414 r1422  
    7575        fpsText->setCaption("init");
    7676
     77        // creating text to display render time ratio
     78        rTRText = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "rTRText"));
     79        rTRText->show();
     80        rTRText->setMetricsMode(Ogre::GMM_PIXELS);
     81        rTRText->setDimensions(0.001, 0.001);
     82        rTRText->setPosition(10, 30);
     83        rTRText->setFontName("Console");
     84        rTRText->setCharHeight(20);
     85        rTRText->setCaption("init");
     86
    7787        // create energy bar
    7888        energyBar = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "energyBar"));
     
    99109        container->setMetricsMode(Ogre::GMM_RELATIVE);
    100110        container->addChild(fpsText);
     111        container->addChild(rTRText);
    101112
    102113        energyBar->init(0.01, 0.94, 0.4, container);
     
    133144        float fps = GraphicsEngine::getSingleton().getAverageFPS();
    134145        fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps));
     146    }
     147
     148    void HUD::setRenderTimeRatio(float ratio)
     149    {
     150      rTRText->setCaption("Render time ratio: " + Ogre::StringConverter::toString(ratio));
    135151    }
    136152
  • code/branches/network/src/orxonox/hud/HUD.h

    r1414 r1422  
    4949        Ogre::OverlayContainer* container;
    5050        Ogre::TextAreaOverlayElement* fpsText;
     51        Ogre::TextAreaOverlayElement* rTRText;
    5152        BarOverlayElement* energyBar;
    5253        BarOverlayElement* speedoBar;
     
    6061        void addRadarObject(Vector3 pos);
    6162        RadarObject* getFirstRadarObject();
     63        void setRenderTimeRatio(float ratio);
    6264
    6365        static HUD* instance_s;
  • code/branches/network/visual_studio/base_properties_release.vsprops

    r1024 r1422  
    99                Name="VCCLCompilerTool"
    1010                Optimization="2"
    11                 WholeProgramOptimization="true"
     11                WholeProgramOptimization="false"
    1212                PreprocessorDefinitions="NDEBUG"
    1313                RuntimeLibrary="2"
Note: See TracChangeset for help on using the changeset viewer.