| Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, meshing, etc here. |
![]() |
|
|
|
Thread Tools |
|
|
#1 |
|
Crazy dude with a rocket
![]() |
i've come to a point in eveloping the G42 that i'm ready to begin coding the simulation logic behind the workings of the ship
![]() first thing i thought i'd do, is add a "mode switch" delay between engine configurations.... while this could be achieved easily by using "in-transition" states, this isn't much of a reusable approach, and will increase the spaghettiness of my module a bit ![]() so i was wondering how i could proceed with this and similar situations... in Flash and JavaScript, which i'm largely accustomed to, i'd just use setTimeout() and have it call a function after a set amount of milliseconds.... but c++ has no such function ![]() would it be worthy, or even advisable at all, to create my own implementation of setInterval? - and in doing so, should i go with using a separate thread, or do i have a loop checking live intervals? i assume the latter would be more suitable, and safe to use... since Orbiter itself appears to run single-threaded (does it?) ![]() but with the advent of whole-bunch-of-cores-CPU's, i can't help but to feel like threading is the "proper way" of doing things ![]() any thoughts? |
|
|
|
|
|
#2 |
|
Addon Developer
![]() |
Define a double precision counter variable in the vessel class, and subtract the Delta-SimT every time step from it... or use the variable to store the simulation time when the timer was started and compare it to the current simulation time.
|
|
|
|
|
|
#3 |
|
Addon Developer
![]() |
As tiny addition... I usually define 2-3 general purpose timer variables in my add-on code (dfTimerA, dfTimerB, dfTimerC) which can be used in the sequence state automate. I never needed more than three so far.
Usually I initialize the variables with 0.0 and in PreStep decrement them by the length of the time step, if they are bigger than 0.0. A typical application would look like that:
Last edited by Urwumpe; 07-30-2010 at 05:39 PM. |
|
|
|
![]() |
|
| Thread Tools | |
|
|
|||||