HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_ForceVortex.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 
9 #ifndef __SIM_ForceVortex_h__
10 #define __SIM_ForceVortex_h__
11 
12 #include "SIM_API.h"
13 #include "SIM_Force.h"
14 #include "SIM_OptionsUser.h"
15 
16 #include <GA/GA_Handle.h>
17 #include <GA/GA_Types.h>
19 
20 class GU_RayIntersect;
21 class GU_MinInfo;
22 
23 /// This is an implementation of the SIM_Force interface. This implementation
24 /// calculates the interpolated value from a point cloud with force and
25 /// torque attributes attached to it.
27  public SIM_OptionsUser
28 {
29 public:
30  /// The name of the point attribute holding the radius values
31  GETSET_DATA_FUNCS_S(SIM_NAME_RADIUS, RadiusAttribName);
32  /// The name of the velocity of the orbit
33  GETSET_DATA_FUNCS_S(SIM_NAME_VELOCITY, VelocityAttribName);
34  /// Get the veloicty type
36  /// The name of the direction of the orbit
37  GETSET_DATA_FUNCS_S(SIM_NAME_DIRECTION, DirectionAttribName);
38  /// Get the direction type
40  /// The drag constant for going into orbit
42  /// The name of maximum distance we are allowed to search for a point.
43  GETSET_DATA_FUNCS_S(SIM_NAME_MAXDISTANCE, MaxDistanceAttribName);
44  /// The linear orbital density
46  /// The lift force
47  GETSET_DATA_FUNCS_S(SIM_NAME_LIFTFORCE, LiftForceAttribName);
48  /// The falloff of lift force
50  /// The lift radius multiplier
52  /// Whether to sample by point, circle, or sphere.
54 
55 protected:
56  explicit SIM_ForceVortex(const SIM_DataFactory *factory);
57  ~SIM_ForceVortex() override;
58 
59  /// Returns the force and torque on a point. The returned values are
60  /// exact copies of the force and torque attributes. The
61  /// getForceOnCircleSubclass() and getForceOnSphereSubclass()
62  /// functions use the default implementations which scale the point
63  /// force by the area or volume of the circle or sphere. This means
64  /// that regardless of the size of samples used to quantize an object,
65  /// the total force on the object should remain roughly constant.
66  void getForceSubclass(
67  const SIM_Object &object,
68  const UT_Vector3 &position,
69  const UT_Vector3 &velocity,
70  const UT_Vector3 &angvel,
71  const fpreal mass,
73  UT_Vector3 &torque) const override;
74  /// Returns the forces and torques on a set of points. The results
75  /// will be same as those produced by getForceSubclass, with the
76  /// exception that this method computes forces for a set of points
77  /// instead of a single point.
79  const SIM_Object &object,
80  const UT_Vector3Array &positions,
81  const UT_Vector3Array &velocities,
82  const UT_Vector3Array &angvelocities,
83  const UT_FloatArray &masses,
84  UT_Vector3Array &forces,
85  UT_Vector3Array &torques) const override;
86 
88 
89  SIM_Guide *createGuideObjectSubclass() const override;
91  const SIM_RootData &root,
92  const SIM_Options &options,
93  const GU_DetailHandle &gdh,
94  UT_DMatrix4 *xform,
95  const SIM_Time &t) const override;
96 
97  bool shouldMultiThread() const { return true; }
98 
99 private:
100  void createCircleGuide(GU_Detail *gdp,
101  const UT_Vector3 &center,
102  const UT_Quaternion &orient,
103  fpreal rad, fpreal frad,
104  int divisions,
105  const GA_RWHandleV3 &colour_attrib,
106  const UT_Vector3 &colour) const;
107  UT_Vector3 getPolyOrbitalDirection(const GEO_Primitive *prim,
108  int i, int j) const;
109  void getPointData(const GEO_Primitive * &prim,
110  GU_RayIntersect &ray,
111  const UT_DMatrix4 &geoxform,
112  const GA_ROHandleV3 &dir_attrib,
113  const GA_ROHandleF &rad_attrib,
114  const GA_ROHandleF &maxd_attrib,
115  GA_Size ind, int defaultval,
116  GA_Offset &pt,
117  UT_Vector3 &x,
118  UT_Vector3 &dir,
119  fpreal &u,
120  fpreal &rad, fpreal &maxd,
121  UT_Quaternion &rot, fpreal hack) const;
122 
123  /// A threaded algorithm to compute forces on a set of points.
124  THREADED_METHOD6_CONST(SIM_ForceVortex, shouldMultiThread(),
125  calculateForceSet,
126  const UT_Vector3Array &, positions,
127  const UT_Vector3Array &, velocities,
128  const UT_FloatArray &, masses,
129  UT_Vector3Array &, forces,
130  UT_Vector3Array &, torques,
132  void calculateForceSetPartial(
133  const UT_Vector3Array &positions,
134  const UT_Vector3Array &velocities,
135  const UT_FloatArray &masses,
136  UT_Vector3Array &forces,
137  UT_Vector3Array &torques,
139  const UT_JobInfo &info) const;
140 
141  static const SIM_DopDescription *getForceVortexDopDescription();
142 
145  SIM_Force,
146  "Vortex Force",
147  getForceVortexDopDescription());
148 };
149 
150 #endif
151 
virtual void getForceSubclass(const SIM_Object &object, const UT_Vector3 &position, const UT_Vector3 &velocity, const UT_Vector3 &angvel, const fpreal mass, UT_Vector3 &force, UT_Vector3 &torque) const
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
#define SIM_NAME_FALLOFF
Definition: SIM_Names.h:115
#define THREADED_METHOD6_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5, PARMTYPE6, PARMNAME6)
void
Definition: png.h:1083
#define SIM_NAME_DIRECTION
Definition: SIM_Names.h:102
#define SIM_NAME_MAXDISTANCE
Definition: SIM_Names.h:145
#define GETSET_DATA_FUNCS_S(DataName, FuncName)
SIM_API const UT_StringHolder torque
GA_API const UT_StringHolder rot
#define SIM_NAME_RADIUS
Definition: SIM_Names.h:175
SIM_ForceSample
Definition: SIM_Force.h:49
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
#define SIM_NAME_SAMPLEMODE
Definition: SIM_Names.h:181
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:235
virtual void buildGuideGeometrySubclass(const SIM_RootData &root, const SIM_Options &options, const GU_DetailHandle &gdh, UT_DMatrix4 *xform, const SIM_Time &t) const
#define SIM_NAME_DRAGCONSTANT
Definition: SIM_Names.h:111
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:63
GA_Size GA_Offset
Definition: GA_Types.h:641
virtual SIM_ForceSample getOptimalForceSamplingSubclass() const
#define SIM_NAME_VELOCITYTYPE
Definition: SIM_Names.h:215
#define GETSET_DATA_FUNCS_I(DataName, FuncName)
#define SIM_NAME_DIRECTIONTYPE
Definition: SIM_Names.h:103
GLint GLenum GLint x
Definition: glcorearb.h:409
GA_API const UT_StringHolder orient
GLdouble t
Definition: glad.h:2397
GLint j
Definition: glad.h:2733
GA_API const UT_StringHolder mass
SIM_API const UT_StringHolder force
bool shouldMultiThread() const
fpreal64 fpreal
Definition: SYS_Types.h:277
SIM_API const UT_StringHolder position
IMATH_CONSTEXPR14 bool intersect(const Line3< T > &line, const Vec3< T > &v0, const Vec3< T > &v1, const Vec3< T > &v2, Vec3< T > &pt, Vec3< T > &barycentric, bool &front) IMATH_NOEXCEPT
Definition: ImathLineAlgo.h:80
#define SIM_API
Definition: SIM_API.h:12
virtual bool getForceSetSubclass(const SIM_Object &object, const UT_Vector3Array &positions, const UT_Vector3Array &velocities, const UT_Vector3Array &angvelocities, const UT_FloatArray &masses, UT_Vector3Array &forces, UT_Vector3Array &torque) const
#define SIM_NAME_LIFTMULT
Definition: SIM_Names.h:143
#define const
Definition: zconf.h:214
#define SIM_NAME_DENSITY
Definition: SIM_Names.h:100
#define SIM_NAME_LIFTFORCE
Definition: SIM_Names.h:142
#define SIM_NAME_VELOCITY
Definition: SIM_Names.h:214
virtual SIM_Guide * createGuideObjectSubclass() const