Actually it will have to run in a child thread, or communication with Orbiter will get difficult, using protocols and stuff. But that's not the problem, we can run irrlicht in a child thread and let it render into a Dialog Box within orbiter. The problem is also not really a big problem:
The eventreceiver will have to receive the events from the orbiter thread though, so you have to post them manually (I have all the code for that ready, don't worry. With the structure as it currently is, it's really just a matter of switching out main.cpp). However, last time I did this trick, there was trouble with double clicks. For some reason the event didn't get posted, I had to create the event manually by measuring the time between two mouse clicks. Which was a bit easier then since I had one global eventhandler. With the event-handling architecture of StackEditor (which is perfectly well suited for its purposes with all nodes being able to receive their own events independantly), I'm not sure yet where to move the timer. Probably right where the events are posted from the orbiter thread. I'm sure it'll be solvable, that's just one problem I had with the implementation the last time I worked with it.
:uhh:
Why complicate things?
Just let Irrlicht run in it's own window. I just whipped together a quick integration test (the relevant changes are
here), and it works fine. Just go F4->custom->stackEditor
You'll have to do a git pull and then checkout the testOrbiterIntegration branch
Code:
git pull
git checkout -b testOrbiterIntegration origin/testOrbiterIntegration
As a side effect, it has my partially un-finished docking code. Also, for some reason the debugger really, really hates relative paths, so you'll have to start Orbiter manually and enable stackEditor's module.
If you just let Irrlicht make a new window, we don't have to modify
any of the event handler code, nor worry about manually posting events or some of the issues you described above.
Right now, it just creates a new thread for SE and detaches it so Orbiter doesn't hang.
For future integration, we could just create a normal Orbiter module with some functions/members that SE could access. Then, we just manage multi-threading by protecting those members with CriticalSections. I imagine we would create some structs that represent docked vessels, and create a vector of these structs inside the Orbiter module. Any access to the vector is protected by CriticalSections. Then, the import function is as simple as pushing structs to the vector, and letting SE access them, then clear the vector, and the export function is as simple as having SE push structs to the vector, and the orbiter module access them and create the vessels.
As a note, let's continue developing StackEditor as a stand-alone executable at the moment (just continue working off of the develop branch, not testOrbiterIntegration), as it is easier to debug. This method of integration is simple, so we can just redo the integration when we reach a release-able point.
---------- Post added at 08:19 PM ---------- Previous post was at 07:42 PM ----------
As to the abysmal loading times, I think I have a solution. Due to the excellent way you have set up GetGlobalMesh, the solution is just to background load the meshes.
Basically, at load, split off another thread that continues to load meshes, so SE doesn't hang. Then, if the user selects a mesh that has not been background loaded, it just manually loads because of the design of GetGlobalMesh, and the user may see a slight unresponsiveness as the mesh loads. If the user selects a mesh that already has been background loaded, then it is created without any lag time.
The only caveat is that you have to again protect the vector with CriticalSections (basically just wrap all the code in GetGlobalMesh/GetGlobalConfig in the protection code), but that isn't that bad.