I wrote: > This drop includes a new, non-Nasal FlightGear subsystem: > FGTimerMgr. This is a heap-based priority queue implementation that > manages timeout callbacks for anyone that asks.
Curt rapidly pointed out that I'd missed the existence of the SGEventMgr class, which does very similar things. It didn't *quite* do what I wanted, so I ported my new stuff onto its interface instead. But I want everyone to try/test the script engine, so you can't have it independently. :) http://www.plausible.org/andy/fg-nasal-1.2.tar.gz [It's really easy: drop the "SimGear" files into your simgear tree and rebuild. Drop the "source" files into your FlightGear tree and rebuilt. Drop the "data" files into your base package and run. Press Shift-C to rotate through the various example Nasal functions.] API changes: There used to be an API where you could add a SGSubsystem to the event manager, which would call the subsystem's update() method periodically. This was unused. It also duplicated functionality in the SGSubsystemMgr, which *also* calls the update() method out of the main loop. This is probably dangerous, since someone who misunderstands the API will get doubled update() calls with no way to tell the difference. It was dead code; I yanked it. The add() methods have split into addTask(), which adds a repeating callback that matches the old API, and addEvent(), which adds a one-shot event which matches my Nasal settimer() usage model. There is a boolean "simtime" you can pass to indicate that you want "simulated" time or "real" time. The default, which matches the old implementation, is real time. I ported the existing usages over to the realtime model, since that preserves compatibility. I didn't audit the existing stuff to see if it "should" have been using simtime all along. [NEWS FLASH: I just discovered that this feature doesn't work. The main loop passes a zero "dt" argument to update() when the simulator is paused. I'll look at ways of fixing this, but I'll leave the API as-is. Clearly some things, like user-interface timeouts and animations, are going to want access to real timeouts independant of simulator time.] The time numbers used to be integers specifying milliseconds. They are now doubles in units of seconds; this matches the usage in SGSubsystem::update(), and is generally cleaner IMHO. Internal changes: The add methods still accept the "name" argument for debugging. But they throw it away. It doesn't get stored in the event objects. Copying a string for every event invocation seemed a little like overkill to me. Algorithmic superiority. This one is a priority queue, so it takes O(logN) time to insert a new event or extract the next one. The old one had to do an O(N) search through all the events every frame. It's a non-issue now, but as we move towards thousands of events (who was it that was talking about AI handling for hundreds of ground vehicles?), this will be significant. Anyway, try it and see if anything breaks. Andy _______________________________________________ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel
