HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIM_PhysicalParms.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  */
7 
8 #ifndef __SIM_PhysicalParms_h__
9 #define __SIM_PhysicalParms_h__
10 
11 #include "SIM_API.h"
12 #include "SIM_Data.h"
13 #include "SIM_DataUtils.h"
14 #include "SIM_OptionsUser.h"
15 
16 class SIM_Object;
17 class SIM_Solver;
18 class GEO_PointTree;
19 class SIM_PointTree;
20 class SIM_Geometry;
21 class ut_KDPQueue;
22 class SIM_RawField;
23 class SIM_VectorField;
24 
26 #include <GU/GU_Detail.h>
27 #include <GU/GU_DetailHandle.h>
28 
29 
30 /// This enumeration lists all the properties that can be accessed using
31 /// the getPropertyAtPosition() and getPropertyAtPoint() functions.
32 typedef enum {
38  // If you add any, you have to update Gas Calculate which
39  // hard codes PROPERTY COUNT
40  SIM_PROPERTY_COUNT // Tracks number of properties.
41 } SIM_Property;
42 
43 /// This simple verb class is designed to create a fast and
44 /// usually threadsafe way to lookup lots of property value queries.
45 /// For threadsafety it is important you act on a resolver local
46 /// to your thread, you can create such a thing with the copy() function.
48 {
49 public:
51  virtual ~SIM_PropertyResolver() {}
52 
53  /// Duplicates this.
54  virtual SIM_PropertyResolver *copy() const = 0;
55 
56  virtual fpreal getF(const UT_Vector3 &pos) = 0;
57  virtual UT_Vector3 getV3(const UT_Vector3 &pos) = 0;
58 
59  /// Sometimes despite our best efforts the lookup isn't threadsafe.
60  virtual bool threadsafe() const { return true; }
61 };
62 
64 {
65 public:
68 
69  virtual SIM_PropertyResolver *copy() const
70  {
71  return new SIM_PropertyResolverConstant(*this);
72  }
73 
74  virtual fpreal getF(const UT_Vector3 &pos) { return myValue.x(); }
75  virtual UT_Vector3 getV3(const UT_Vector3 &pos) { return myValue; }
76 protected:
78 };
79 
81 {
82 public:
84  const SIM_Geometry *geo,
85  const char *attribname,
86  const UT_DMatrix4 &worldtogdp);
88 
89  virtual SIM_PropertyResolver *copy() const;
90 
91  virtual fpreal getF(const UT_Vector3 &pos);
92  virtual UT_Vector3 getV3(const UT_Vector3 &pos);
93  GA_Offset getPtOff(const UT_Vector3 &pos);
94 protected:
95 
97  const GU_Detail *myGdp;
102  ut_KDPQueue *myQueue;
103 };
104 
106 {
107 public:
108  SIM_PropertyResolverVelNearestPoint(const SIM_Engine &engine, const SIM_Object *object);
110 
111  virtual SIM_PropertyResolver *copy() const;
112 
113  virtual UT_Vector3 getV3(const UT_Vector3 &pos);
114  virtual fpreal getF(const UT_Vector3 &pos) { return getV3(pos).x(); }
115 protected:
116 
118  const GU_Detail *myGdp;
122  ut_KDPQueue *myQueue;
123 
124  UT_Vector3 myPivot, myLinVel, myAngVel;
126 
127  bool myHasOld;
134 };
135 
137 {
138 public:
141 
142  virtual SIM_PropertyResolver *copy() const
143  {
144  return new SIM_PropertyResolverField(*this);
145  }
146 
147 
148  virtual fpreal getF(const UT_Vector3 &pos);
149  virtual UT_Vector3 getV3(const UT_Vector3 &pos);
150 protected:
151  const SIM_RawField *myField[3];
152 };
153 
155 {
156 public:
158  const UT_Vector3 &pivot,
159  const UT_Vector3 &angvel);
160 
161  virtual SIM_PropertyResolver *copy() const
162  {
163  return new SIM_PropertyResolverMotion(*this);
164  }
165 
166  virtual fpreal getF(const UT_Vector3 &pos) { return getV3(pos).x(); }
167  virtual UT_Vector3 getV3(const UT_Vector3 &pos);
168 
169 protected:
170  UT_Vector3 myPivot, myLinVel, myAngVel;
171 };
172 
174 {
175 public:
177  bool usesdfhistory,
178  bool usegeohistory,
179  fpreal integrateovertime)
180  {
181  myObject = obj;
182  myUseSDF = usesdfhistory;
183  myUseGeo = usegeohistory;
184  myIntegrate = integrateovertime;
185  }
186 
187  virtual SIM_PropertyResolver *copy() const
188  {
189  return new SIM_PropertyResolverVelAtPosition(*this);
190  }
191 
192  virtual fpreal getF(const UT_Vector3 &pos) { return getV3(pos).x(); }
193  virtual UT_Vector3 getV3(const UT_Vector3 &pos);
194 
195  virtual bool threadsafe() const { return false; }
196 protected:
198  bool myUseSDF, myUseGeo;
200 };
201 
202 /// This simple verb class is designed to create a fast and
203 /// usually threadsafe way to lookup lots of property value queries.
204 /// For threadsafety it is important you act on a resolver local
205 /// to your thread, you can create such a thing with the copy() function.
207 {
208 public:
210  const SIM_Object *obj)
211  {
212  mySolver = solver;
213  myObject = obj;
214  }
216 
217  virtual void get(GA_Index ptnum, UT_DMatrix3 &immatrix) const;
218 
219  /// The default implementation just calls
220  /// SIM_Solver::getPointImpulseMassMatrix and is not threadsafe.
221  virtual bool threadsafe() const { return false; }
222 
223 protected:
226 };
227 
228 
229 /// A simple, threadsafe mass matrix resolver that just looks up the mass point
230 /// attribute and returns 1/mass if exists else 1.
233 {
234 public:
236  const SIM_Object *obj);
238 
239  virtual void get(GA_Index ptnum, UT_DMatrix3 &immatrix) const;
240 
241  virtual bool threadsafe() const { return true; }
242 
243 protected:
245  const GU_Detail *myGdp;
247 };
248 
249 /// This class contains physical attributes that apply to all objects.
251  public SIM_OptionsUser
252 {
253 public:
254  /// Coefficient of friction.
256  /// Dynamic friction multiplier.
258  /// Bounce coefficient.
260  /// Temperature coefficient
262  /// Forward bounce coefficient
264 
265  fpreal getProperty(const SIM_Property &property) const;
266 
267 protected:
268  explicit SIM_PhysicalParms(const SIM_DataFactory *factory);
269  virtual ~SIM_PhysicalParms();
270 
271 private:
272  static const SIM_DopDescription *getPhysicalParmsDopDescription();
273 
276  SIM_Data,
277  "Physical Parameters",
278  getPhysicalParmsDopDescription());
279 };
280 
281 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
virtual SIM_PropertyResolver * copy() const
Duplicates this.
virtual fpreal getF(const UT_Vector3 &pos)
virtual fpreal getF(const UT_Vector3 &pos)
virtual fpreal getF(const UT_Vector3 &pos)
const GLdouble * v
Definition: glcorearb.h:836
virtual SIM_PropertyResolver * copy() const
Duplicates this.
This class contains physical attributes that apply to all objects.
virtual UT_Vector3 getV3(const UT_Vector3 &pos)=0
SIM_PropertyResolverConstant(UT_Vector3 v)
#define SIM_NAME_TEMPERATURE
Definition: SIM_Names.h:199
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:581
3D Vector class.
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
GA_Size GA_Offset
Definition: GA_Types.h:617
virtual SIM_PropertyResolver * copy() const
Duplicates this.
virtual bool threadsafe() const
Sometimes despite our best efforts the lookup isn't threadsafe.
SIM_PropertyResolverVelAtPosition(const SIM_Object *obj, bool usesdfhistory, bool usegeohistory, fpreal integrateovertime)
virtual bool threadsafe() const
Sometimes despite our best efforts the lookup isn't threadsafe.
virtual SIM_PropertyResolver * copy() const =0
Duplicates this.
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
virtual SIM_PropertyResolver * copy() const
Duplicates this.
virtual fpreal getF(const UT_Vector3 &pos)
#define SIM_NAME_FRICTION
Definition: SIM_Names.h:131
#define SIM_NAME_DYNAMICFRICTION
Definition: SIM_Names.h:111
virtual UT_Vector3 getV3(const UT_Vector3 &pos)
double fpreal
Definition: SYS_Types.h:269
virtual fpreal getF(const UT_Vector3 &pos)=0
#define SIM_API
Definition: SIM_API.h:10
GA_API const UT_StringHolder pivot
SIM_PointImpulseMassMatrixResolver(const SIM_Solver *solver, const SIM_Object *obj)
This class holds a three dimensional vector field.
#define SIM_NAME_BOUNCEFORWARD
Definition: SIM_Names.h:109
#define SIM_NAME_BOUNCE
Definition: SIM_Names.h:80
SIM_Property