HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_ColliderPoint.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_ColliderPoint_h__
9 #define __SIM_ColliderPoint_h__
10 
11 #include "SIM_API.h"
12 #include <UT/UT_IntArray.h>
13 #include <UT/UT_ValArray.h>
14 #include <UT/UT_Array.h>
15 #include <UT/UT_DMatrix4.h>
16 #include "SIM_Collider.h"
17 
18 class GU_SDF;
19 class GU_RayIntersect;
20 class SIM_Geometry;
21 class SIM_Position;
22 class SIM_Impacts;
23 
24 /// This class implements a collider that detects collisions of geometry
25 /// points with solid geometry. Each point in the object geometry is tested
26 /// for collision with the geometry attached to each affector object.
28 {
29 public:
32  GETSET_DATA_FUNCS_B("usepointvelocity", UsePointVelocity);
33  GETSET_DATA_FUNCS_B("usesdfvelocity", UseSDFVelocity);
34 
35 protected:
36  /// This SIM_ColliderPoint constructor.
37  explicit SIM_ColliderPoint(const SIM_DataFactory *factory);
38  /// This SIM_ColliderPoint destructor.
39  virtual ~SIM_ColliderPoint();
40 
41  /// Required override of the collision detection function.
42  virtual bool collideObjectsCachedSubclass(SIM_Engine &engine,
43  SIM_Object &object,
44  SIM_Object &affector,
45  const SIM_Time &starttime,
46  const SIM_Time &endtime,
47  SIM_ImpactApplyType impactapplytype,
48  int impactflags,
50  UT_ValArray<SIM_ColliderCacheData *> &affectorcache) const;
51 
52 private:
53  bool doCollide(SIM_Object &object,
54  SIM_Object &affector,
55  const SIM_Time &starttime,
56  const SIM_Time &endtime,
57  SIM_Impacts *impacts,
58  SIM_Impacts *affimpacts,
59  int impactflags,
61  UT_ValArray<SIM_ColliderCacheData *> &affectorcache) const;
62 
63  /// Sends rays against the affector geometry to find the likely
64  /// primitive & uv coordinates of the given hit location.
65  /// affintersect should be null and is modified to allow the
66  /// caching of looking up the ray intersect tree.
67  void calculateCollisionPrimUVW(
68  const SIM_Geometry &affsimgeo,
69  GU_RayIntersect *&affintersect,
70  const UT_Vector3 &hitpos,
71  const UT_Vector3 &hitnormal,
72  fpreal tolerance,
73  int &primnum,
74  fpreal &primu,
75  fpreal &primv,
76  fpreal &primw) const;
77  bool addCollisions(const int objid,
78  const SIM_Geometry &oldsimgeo,
79  const SIM_Geometry &simgeo,
80  const SIM_Geometry &affsimgeo,
81  const UT_DMatrix4 &oldxform,
82  const UT_DMatrix4 &xform,
83  SIM_Impacts *impacts,
84  const int affobjid,
85  const UT_DMatrix4 &oldaffixform,
86  const UT_DMatrix4 &affixform,
87  const UT_DMatrix4 &oldaffxform,
88  const UT_DMatrix4 &affxform,
89  SIM_Impacts *affimpacts,
90  const SIM_Time &starttime,
91  const SIM_Time &endtime,
92  const GU_SDF &affsdf,
93  const SIM_Object &obj,
94  const SIM_Object &affobj,
95  int impactflags,
97  UT_ValArray<SIM_ColliderCacheData *> &affectorcache) const;
98 
99  static SIM_DopDescription *getPointColliderDopDescription();
100 
103  SIM_Collider,
104  "Point Collider",
105  getPointColliderDopDescription());
106 };
107 
108 #endif
109 
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
#define SIM_NAME_TOLERANCE
Definition: SIM_Names.h:201
#define SIM_NAME_VOLUMEOFFSET
Definition: SIM_Names.h:215
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
Definition: GU_SDF.h:302
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
SIM_ImpactApplyType
Defines the possible affector types when doing collision detection.
Definition: SIM_Collider.h:56
GETSET_DATA_FUNCS_B(SIM_NAME_REVERSEOBJECTROLES, ReverseObjectRoles)
double fpreal
Definition: SYS_Types.h:270
#define SIM_API
Definition: SIM_API.h:10
virtual bool collideObjectsCachedSubclass(SIM_Engine &engine, SIM_Object &object, SIM_Object &affector, const SIM_Time &starttime, const SIM_Time &endtime, SIM_ImpactApplyType impactapplytype, int impactflags, UT_ValArray< SIM_ColliderCacheData * > &objcachedata, UT_ValArray< SIM_ColliderCacheData * > &affectorcachedata) const