The scene file format from last time is generated into a QTextStream and then is saved using a QTemporaryFile ,which stores the scene file to a temporary directory with a unique name which is then accessed and shared later. Currently when generating the scene for more complex parts (e.g. curved surfaces with high tessellation) there is a noticeable delay. I will need to investigate whether this is due to storing textual data or the algorithms for generating the mesh information. Later it may be a nice experiment to try and multi-thread this.
The next steps really were to build up the Render infrastructure and allow the Render Process to be spawned within FreeCAD. With the help of QT and it's QProcess it's pretty straight forward. Just pass the executable path and a string list of arguments and run its start method. To give more flexibility and add different modes subclassing this seemed a good option. The nice thing about spawning a QProcess is that it runs in the background. Apparently launching new processes consumes more memory, but overall arguably is the simplest method of IPC: we don't need to link or include render sources and we can let the user specify the executable path.
Actually the Lux Render Plugin (Luxblender) utilises its Python API and also a C++ API is available. It would be interested to experiment in the future which method works best.
The only difficult with subclassing I found was the QT macros, which didn't seem to work straight away. By subclassing, more events can be handled directly such as errors. The Render Process has some basic methods to control the process - BTW: pause will be dependant on the renderer executable. For example Luxconsole can be paused by initialising another process but with some extra command (see here)
Soon enough I got a process working. Without a GUI front end it was pretty useless though. In practicality it works well and I didn't realise but the external render process also stops when the host application finishes.
The next steps really were to build up the Render infrastructure and allow the Render Process to be spawned within FreeCAD. With the help of QT and it's QProcess it's pretty straight forward. Just pass the executable path and a string list of arguments and run its start method. To give more flexibility and add different modes subclassing this seemed a good option. The nice thing about spawning a QProcess is that it runs in the background. Apparently launching new processes consumes more memory, but overall arguably is the simplest method of IPC: we don't need to link or include render sources and we can let the user specify the executable path.
Actually the Lux Render Plugin (Luxblender) utilises its Python API and also a C++ API is available. It would be interested to experiment in the future which method works best.
Soon enough I got a process working. Without a GUI front end it was pretty useless though. In practicality it works well and I didn't realise but the external render process also stops when the host application finishes.
No comments:
Post a Comment