HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DOP_Parent.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: DOP_Parent.h ( SOP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __DOP_Parent_h__
12 #define __DOP_Parent_h__
13 
14 #include "DOP_API.h"
15 #include "DOP_FullPathData.h"
16 #include "DOP_Node.h"
17 
18 #include <SIM/SIM_Utils.h>
19 #include <OP/OP_DopParent.h>
20 
21 class DEP_MicroNode;
22 class DOP_Parent;
23 template <typename T> class UT_Array;
24 
25 typedef enum {
30 
32 
34 {
35 public:
36  DOP_Parent();
37  ~DOP_Parent() override;
38 
39  const DOP_Engine &getEngine() const;
40  DOP_Engine &getNonConstEngine();
41 
42  int dopparentUniqueId() const
43  { return myDopParentUniqueId; }
44 
45  void setNeedsToResimulateLastTimestep();
46  void setNeedsToFilterData();
47  void setNeedsToCompletelyReset() override;
48 
49  /// Sets the current simulation time, solving all intermediate steps.
50  /// Note that the time t passed in to this function is a global
51  /// Houdini time, and may not match the simulation time.
52  void setDOPTime(const SIM_Time &t);
53  /// Returns the simulation time that corresponds to a given global
54  /// Houdini time.
55  const SIM_Time getDOPTime(const SIM_Time &t) const;
56  /// Returns the global Houdini time that corresponds to a given
57  /// simulation time.
58  const SIM_Time getGlobalTime(const SIM_Time &t) const;
59  void resimulate();
60  /// Resets the simulation and cooks to a specific DOP time, this
61  /// avoids double cooking if you are resetting to frame 0.
62  void resimulateToTime(const SIM_Time &t);
63 
64  /// Returns true if the DOP network has changed such that the
65  /// simulation needs to be reset.
66  bool getNeedsResimulation() const;
67 
68  /// Attributes for controlling the simulation behavior.
69  const SIM_Time &getOffsetTime() const;
70  void setOffsetTime(const SIM_Time &t);
71  fpreal getTimeScale() const;
72  void setTimeScale(fpreal scale);
73  bool getAutoResimulation() const;
74  void setAutoResimulation(bool autoreset);
75  bool getInterpolateData(const SIM_Time &t) const;
76  void setInterpolateData(bool interpolate);
77  bool getIsSimulating() const;
78  virtual bool getIsTimeless() const { return false; }
79 
80  /// Used by SIM_Engine to flag this privately if it is during
81  /// an internally generated simulation pass
82  void setIsSimulating(bool val)
83  { mySimulating = val; }
84 
85  /// Used externally to flag that we do not want to resimulate
86  /// due to our setDOPTime() invocations.
87  bool getDisableSimulation() const
88  { return myDisableSimulation; }
89  void setDisableSimulation(bool disable)
90  { myDisableSimulation = disable; }
91 
92  /// Get all objects that match a particular string. This calls the
93  /// SIM_Engine::findAllObjectsFromString() function, but converts the
94  /// time value from global time to simulation time, and passes our
95  /// getInterpolateData() value as the interpolate parameter.
96  void findAllObjectsFromString(const char *objspec,
97  SIM_ConstObjectArray &objects,
98  const SIM_Time &t) const;
99  /// Get the object that matches a particular string. This calls the
100  /// SIM_Engine::findObjectFromString() function, but converts the
101  /// time value from global time to simulation time, and passes our
102  /// getInterpolateData() value as the interpolate parameter.
103  const SIM_Object *findObjectFromString(const char *objspec,
104  int whichmatch, int *nummatch,
105  const SIM_Time &t) const;
106  /// Get all relationships that match a particular string. This calls the
107  /// SIM_Engine::findAllRelationshipsFromString() function, but converts the
108  /// time value from global time to simulation time, and passes our
109  /// getInterpolateData() value as the interpolate parameter.
110  void findAllRelationshipsFromString(
111  const char *relspec,
112  SIM_ConstDataArray &relationships,
113  const SIM_Time &t) const;
114  /// Get the relationship that matches a particular string. This calls the
115  /// SIM_Engine::findRelationshipFromString() function, but converts the
116  /// time value from global time to simulation time, and passes our
117  /// getInterpolateData() value as the interpolate parameter.
118  const SIM_Relationship *findRelationshipFromString(
119  const char *relspec,
120  int whichmatch, int *nummatch,
121  const SIM_Time &t) const;
122 
123  /// Returns data used by DOP_Nodes during their cook process. This is
124  /// information that is global to the DOP Network as it cooks.
125  DOP_Node::DOP_CookData &getDopNodeCookData();
126 
127  /// Sends out a parm changed message so that anyone interested in the
128  /// simulation will know to refresh their data. This call also protects
129  /// the DOP Network from causing infinite recursion when the DOP Network
130  /// is interested in a SOP node which is interested in the DOP Network
131  /// (a common and legal situation when using a SOP Solver, for example).
132  void sendResimulateNotification(
133  bool callnotify,
134  bool changingguideparm);
135 
137  { return getNonConstEngineSubclass().simMicroNode(); }
139  { return getNonConstEngineSubclass().simInputMicroNode(); }
141  { return getNonConstEngineSubclass().resimParmsMicroNode(); }
143  { return getEngineSubclass().resimParmsMicroNode(); }
145  { return getNonConstEngineSubclass().refilterParmsMicroNode(); }
147  { return getEngineSubclass().refilterParmsMicroNode(); }
148 
150  OP_NodeList &extras) const override;
151 
152  /// This static function returns an array of all DOP_Parents.
153  static const DOP_ParentList &getAllDopParents();
154  /// This function moves a particular DOP_Parent to the front of the list
155  /// of all DOP_Parents. This lets us treat this list as a "most recently
156  /// used" stack.
157  static void setMostRecentDopParent(DOP_Parent *dopparent);
158 
159  /// The current dopnet may not be the top of the recently used.
160  /// Dopnets that are inside locked assets, for example, are rather
161  /// useless as destinations.
162  /// Except we do want access to those for tracking cache settings,
163  /// reset flags, etc.
164  static OP_Node *getMostRecentDopOwner();
165  static OP_Node *getMostRecentWriteableDopOwner();
166 
167  bool opGetNeedsResimulation() const override
168  { return getNeedsResimulation(); }
169  bool opGetDisableSimulation() const override;
170  /// Query cache size.
171  void opGetDiskCache(
172  UT_Array<int> &frames) const override;
173  void opGetMemoryCache(
174  UT_Array<int> &frames) const override;
175 
176  /// Update re-simulation parameters, ensuring getOffsetTime and the
177  /// ilk are valid. This is required before getDOPTime will work
178  /// as expected (but note setDOPTime() implicitly invokes this)
179  void updateResimParms(const SIM_Time &t);
180 
181 protected:
182  const SIM_Time &getLastSetTime() const;
183  void resimulateLastTimestep();
184  /// Sets a flag that says we need to re-filter our simulation data the
185  /// next time a request for the data is made.
186  void setNeedsToFilterData(const SIM_Time &t);
187  /// Check if we need to filter our simulation data, and do so if required.
188  void filterDataIfRequired() const;
189  /// This function calls filterDataSubclass() to cache pointers to the
190  /// simulation data that is of interest to us.
191  void filterData(const SIM_Time &t);
192 
193  virtual const DOP_Engine &getEngineSubclass() const = 0;
194  virtual void resimulateLastTimestepSubclass();
195  virtual void setDOPTimeSubclass(const SIM_Time &t);
196  virtual DOP_Engine &getNonConstEngineSubclass() = 0;
197  virtual void filterDataSubclass(const SIM_Time &t) = 0;
198 
199  virtual void handleRefilterParms(const SIM_Time &t) {}
200  virtual void handleResimParms(const SIM_Time &t) {}
201 
202  void notifySimulationChangeSinksOfChange();
203  void notifySimulationChangeSinksOfDelete();
204 
205 private:
206  UT_ValArray<DOP_SimulationChangeSink *> mySimulationChangeSinks;
207  DOP_Node::DOP_CookData myDopNodeCookData;
208  SIM_Time myLastSetTime;
209  SIM_Time myOffsetTime;
210  SIM_Time myNeedsToFilterDataTime;
211  fpreal myTimeScale;
212  bool myNeedsToFilterData;
213  bool mySimulating;
214  bool myNeedsToResimulateFrame;
215  bool myNeedsToResimulateCompletely;
216  bool myAutoResimulation;
217  bool myInterpolateData;
218  bool mySendingResimulateNotification;
219  bool myDisableSimulation;
220  int myDopParentUniqueId;
221 
222  static DOP_ParentList theDopParents;
223 
225  friend class DOP_Engine;
226 };
227 
229 {
230 public:
232  { }
234  { removeAllSimulationChangeSinks(); }
235 
236  virtual void simulationChanged(DOP_Parent *dopparent) = 0;
237  virtual void simulationDeleted(DOP_Parent *dopparent)
238  { removeSimulationChangeSink(dopparent); }
239 
240 protected:
242  {
243  if( !dopparent ) return;
244  dopparent->mySimulationChangeSinks.append(this, 1);
245  myDopParents.append(dopparent, 1);
246  }
248  {
249  if( !dopparent ) return;
250  dopparent->mySimulationChangeSinks.findAndRemove(this);
251  myDopParents.findAndRemove(dopparent);
252  }
254  {
255  for( int i = myDopParents.entries(); i --> 0; )
256  removeSimulationChangeSink(myDopParents(i));
257  }
258 
259 private:
260  UT_ValArray<DOP_Parent *> myDopParents;
261 };
262 
263 #endif
bool getDisableSimulation() const
Definition: DOP_Parent.h:87
int dopparentUniqueId() const
Definition: DOP_Parent.h:42
void addSimulationChangeSink(DOP_Parent *dopparent)
Definition: DOP_Parent.h:241
virtual void simulationDeleted(DOP_Parent *dopparent)
Definition: DOP_Parent.h:237
virtual void setNeedsToCompletelyReset()=0
exint findAndRemove(const S &s)
virtual bool opGetDisableSimulation() const =0
void removeAllSimulationChangeSinks()
Definition: DOP_Parent.h:253
void removeSimulationChangeSink(DOP_Parent *dopparent)
Definition: DOP_Parent.h:247
DEP_MicroNode & resimParmsMicroNode()
Definition: DOP_Parent.h:140
virtual void handleRefilterParms(const SIM_Time &t)
Definition: DOP_Parent.h:199
void setIsSimulating(bool val)
Definition: DOP_Parent.h:82
UT_ValArray< DOP_Parent * > DOP_ParentList
Definition: DOP_Parent.h:31
void setDisableSimulation(bool disable)
Definition: DOP_Parent.h:89
GA_API const UT_StringHolder scale
#define DOP_API
Definition: DOP_API.h:10
const DEP_MicroNode & refilterParmsMicroNode() const
Definition: DOP_Parent.h:146
virtual ~DOP_SimulationChangeSink()
Definition: DOP_Parent.h:233
virtual void handleResimParms(const SIM_Time &t)
Definition: DOP_Parent.h:200
virtual void opGetDiskCache(UT_Array< int > &frames) const =0
DEP_MicroNode & simMicroNode()
Definition: DOP_Parent.h:136
Holds pointers to a number of const SIM_Object objects.
exint append()
Definition: UT_Array.h:142
GLdouble t
Definition: glad.h:2397
virtual void opGetMemoryCache(UT_Array< int > &frames) const =0
virtual bool getIsTimeless() const
Definition: DOP_Parent.h:78
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint GLfloat * val
Definition: glcorearb.h:1608
DEP_MicroNode & refilterParmsMicroNode()
Definition: DOP_Parent.h:144
bool opGetNeedsResimulation() const override
Definition: DOP_Parent.h:167
DEP_MicroNode & simInputMicroNode()
Definition: DOP_Parent.h:138
virtual void opGetSimExtraInputNodes(OP_NodeList &extras) const =0
DOP_ParentEventType
Definition: DOP_Parent.h:25
const DEP_MicroNode & resimParmsMicroNode() const
Definition: DOP_Parent.h:142