Thursday, June 28, 2007

Exams are over

Last two weeks I've spend almost all time preparing to my last exam and writing my diploma. Yesterday I've defended my diploma and got bachelor degree in physics. So now I have a lot of time and motivation to work on Step.

Monday, June 11, 2007

Annotations for objects

I've just implemented basic text annotations for Step. Now you can add text items to the scene, very soon you will be able to associate annotations with the objects. What I still can't decide is the appearance of the annotations. I see two possible options:
- text in a frame (like KNotes) resizeable by mouse.
- free-running text without a frame dynamically resizeable as you type

Wednesday, June 6, 2007

Editing and threading

Recently I've implemented threading in Step. This is (still) not parallel computation, but doing all calculations in one dedicated thread to keep GUI responsive and allow the user to abort calculations at any time.

In Step the user can edit the scene while simulation is running but this can't be done in the middle of timestep. So I need to use mutex to serialize access to the scene: the mutex is locked by calculating thread while performing timestep and by GUI thread while altering objects. The problem arises when calculation of one timestep becomes too long (for example if user sets too low tolerance): if GUI tries to lock the mutex it becomes unresponsive till the end of the timestep and the user can't abort the calculation !

The obvious solution is to abort current timestep as soon as the user starts altering the scene and restart it later. But this can slow down the simulation and make it not smooth. My solution is to first try locking with timeout and abort the timestep only if locking fails:

// Try to lock but do not wait mode than one frame
if(!mutex->tryLock(1000/_simulationFps)) {

With such approach simulation will be slowed down only if it is already slow (i.e. when simulation of one frame simulation takes longer then 1/FPS). In the other case simulation will proceed smoothly and user actions will be delayed only slightly.