4 #ifndef _SimulationAnimationPATCH_H_
5 #define _SimulationAnimationPATCH_H_
9 #include "LumiverseCoreConfig.h"
11 #include "../lib/libjson/libjson.h"
29 INTERACTIVE, RECORDING, RENDERING, STOPPED
39 std::set<Device *> devices;
49 for (
Device *d : devices) {
61 for (
Device *d : other.devices) {
62 devices.insert(
new Device(d));
82 m_startPoint(
std::chrono::system_clock::from_time_t(0)),
84 m_mem_frameManager(NULL), m_file_frameManager(NULL),
101 typedef function<void()> FinishedCallbackFunction;
102 typedef function<bool(set<Device *>)> IsUpdateRequiredFunction;
103 typedef function<void(FrameDeviceInfo&)> CreateFrameInfoBodyFunction;
104 typedef function<void()> InterruptFunction;
105 typedef function<void()> ClearUpdateFlagsFunction;
119 m_mem_frameManager->clear();
122 if (m_file_frameManager)
123 m_file_frameManager->reset();
125 m_mode = SimulationAnimationMode::RECORDING;
154 virtual string getType() {
return "SimulationAnimationPatch"; }
164 void update(set<Device *> devices, IsUpdateRequiredFunction isUpdateRequired,
165 InterruptFunction interruptRender,
166 ClearUpdateFlagsFunction clearUpdateFlags);
186 virtual ArnoldFrameManager *getFrameManager()
const;
194 virtual void reset(InterruptFunction interruptRender);
196 virtual void reset() = 0;
245 virtual void onRecording() { }
247 virtual void onRendering() { }
249 virtual void workerRender(FrameDeviceInfo frame) = 0;
251 virtual void createFrameInfoHeader(FrameDeviceInfo &frame);
253 virtual void createFrameInfoBody(set<Device *> devices, FrameDeviceInfo &frame,
bool forceUpdate =
false) = 0;
255 virtual void enqueueFrameInfo(
const FrameDeviceInfo &frame);
258 std::thread *m_worker;
264 std::vector<FrameDeviceInfo> m_queuedFrameDeviceInfo;
269 std::chrono::time_point<std::chrono::system_clock> m_startPoint;
273 ArnoldMemoryFrameManager *m_mem_frameManager;
274 ArnoldFileFrameManager *m_file_frameManager;
virtual void workerLoop()
Worker loop.
Definition: SimulationAnimationPatch.cpp:230
void loadJSON(const JSONNode data)
Loads data from a parsed JSON object.
Definition: SimulationAnimationPatch.cpp:32
virtual void deleteFinishedCallback(int id)
Deletes a registered callback for parameter change.
Definition: SimulationAnimationPatch.cpp:211
The state info for worker thread.
Definition: SimulationAnimationPatch.h:33
FrameDeviceInfo()
Constructor.
Definition: SimulationAnimationPatch.h:43
void init()
Initializes Arnold with function of its parent class and starts a worker thread.
Definition: SimulationAnimationPatch.cpp:52
An implemnetation for frame manager using in-memory buffer.
SimulationAnimationMode
Four working modes of SimulationAnimationPatch. INTERACTIVE: Patch renders the latest sent frame with...
Definition: SimulationAnimationPatch.h:28
virtual ~SimulationAnimationPatch()
Destroys the object.
Definition: SimulationAnimationPatch.cpp:21
virtual void startRecording()
Starts recording. Main thread starts to send frame labeled as RECORDING info to worker.
Definition: SimulationAnimationPatch.h:117
An implemnetation for frame manager using in-memory buffer.
void copyByValue(const FrameDeviceInfo &other)
Deep copy.
Definition: SimulationAnimationPatch.h:58
virtual void onWorkerFinished()
Helper to call all the registered callbacks for rendering finished event.
Definition: SimulationAnimationPatch.cpp:219
virtual void endRecording()
Ends recording. Main thread stops to send frame labeled as RECORDING info to worker. It starts to send INTERACTIVE frame instead.
Definition: SimulationAnimationPatch.cpp:197
map< int, FinishedCallbackFunction > m_onFinishedFunctions
The list for callback functions.
Definition: SimulationAnimationPatch.h:283
SimulationAnimationPatch()
Constructs a SimulationAnimationPatch object.
Definition: SimulationAnimationPatch.h:81
A subclass of ArnoldPatch. Instead of interrupting the worker thread every time a new rendering task ...
Definition: SimulationAnimationPatch.h:75
virtual void startInteractive()
Starts interactive mode. Worker thread can get interrupted. It always takes the most fresh info...
Definition: SimulationAnimationPatch.h:140
void close()
Waits for the worker thread and closes the Arnold session.
Definition: SimulationAnimationPatch.cpp:125
Implementation of a patch for Arnold.
void clear()
Releases the copies for devices.
Definition: SimulationAnimationPatch.h:46
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
virtual void stop()
Stops the patch.
Definition: SimulationAnimationPatch.cpp:193
virtual string getType()
Gets the type of this object.
Definition: SimulationAnimationPatch.h:154
SimulationAnimationMode m_mode
Indicates the mode of SimulationAnimationPatch.
Definition: SimulationAnimationPatch.h:279
A Device in Lumiverse maintains information about a lighting device.
Definition: Device.h:55
void update(set< Device * > devices, IsUpdateRequiredFunction isUpdateRequired, InterruptFunction interruptRender, ClearUpdateFlagsFunction clearUpdateFlags)
Updates the rendering queue given the list of devices in the rig.
Definition: SimulationAnimationPatch.cpp:57
virtual int addFinishedCallback(FinishedCallbackFunction func)
Registers a callback function for parameter changed event.
Definition: SimulationAnimationPatch.cpp:204
virtual SimulationAnimationMode getMode()
Returns the mode/state in which the patch is.
Definition: SimulationAnimationPatch.h:147