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  ~SIM_ColliderPoint() override;
40 
41  /// Required override of the collision detection function.
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  &objcache,
52  &affectorcache) const override;
53 
54 private:
55  bool doCollide(SIM_Object &object,
56  SIM_Object &affector,
57  const SIM_Time &starttime,
58  const SIM_Time &endtime,
59  SIM_Impacts *impacts,
60  SIM_Impacts *affimpacts,
61  int impactflags,
63  UT_ValArray<SIM_ColliderCacheData *> &affectorcache) const;
64 
65  /// Sends rays against the affector geometry to find the likely
66  /// primitive & uv coordinates of the given hit location.
67  /// affintersect should be null and is modified to allow the
68  /// caching of looking up the ray intersect tree.
69  void calculateCollisionPrimUVW(
70  const SIM_Geometry &affsimgeo,
71  GU_RayIntersect *&affintersect,
72  const UT_Vector3 &hitpos,
73  const UT_Vector3 &hitnormal,
74  fpreal tolerance,
75  int &primnum,
76  fpreal &primu,
77  fpreal &primv,
78  fpreal &primw) const;
79  bool addCollisions(const int objid,
80  const SIM_Geometry &oldsimgeo,
81  const SIM_Geometry &simgeo,
82  const SIM_Geometry &affsimgeo,
83  const UT_DMatrix4 &oldxform,
84  const UT_DMatrix4 &xform,
85  SIM_Impacts *impacts,
86  const int affobjid,
87  const UT_DMatrix4 &oldaffixform,
88  const UT_DMatrix4 &affixform,
89  const UT_DMatrix4 &oldaffxform,
90  const UT_DMatrix4 &affxform,
91  SIM_Impacts *affimpacts,
92  const SIM_Time &starttime,
93  const SIM_Time &endtime,
94  const GU_SDF &affsdf,
95  const SIM_Object &obj,
96  const SIM_Object &affobj,
97  int impactflags,
99  UT_ValArray<SIM_ColliderCacheData *> &affectorcache) const;
100 
101  static SIM_DopDescription *getPointColliderDopDescription();
102 
105  SIM_Collider,
106  "Point Collider",
107  getPointColliderDopDescription());
108 };
109 
110 #endif
111 
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
#define SIM_NAME_TOLERANCE
Definition: SIM_Names.h:202
#define SIM_NAME_VOLUMEOFFSET
Definition: SIM_Names.h:216
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
Definition: GU_SDF.h:302
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:63
SIM_ImpactApplyType
Defines the possible affector types when doing collision detection.
Definition: SIM_Collider.h:56
GETSET_DATA_FUNCS_B(SIM_NAME_REVERSEOBJECTROLES, ReverseObjectRoles)
fpreal64 fpreal
Definition: SYS_Types.h:277
#define SIM_API
Definition: SIM_API.h:12
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