HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Collider.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 __UT_Collider_h__
9 #define __UT_Collider_h__
10 
11 #include "UT_API.h"
12 #include <SYS/SYS_Types.h>
13 #include "UT_Vector3.h"
14 
15 /// This is a class for various primitive collisions
16 //
17 // TODO: it really doesn't belong in UT. It could possibly go in BV, since
18 // it's kind of a "follow-up" stage after using a bounding-volume
19 // hierarchy.
21 {
22 public:
23 
24  /// Find times when the given four moving points are coplanar. Only
25  /// returns times between 0 and timestep. Returns the number of times
26  /// found (maximum of three), or -1 if the points are coplanar for the
27  /// entire timestep.
28  static int findTimes4PointsCoplanar(const UT_Vector3 *pos[4],
29  const UT_Vector3 *vels[4],
30  fpreal times[3],
31  fpreal timestep);
32 
33  /// Find times when the three given moving points are collinear. Only
34  /// returns times between 0 and timestep. Returns the number of times
35  /// found (maximum of two), or -1 if the points are collinear for the
36  /// entire timestep.
37  static int findTimes3PointsCollinear(const UT_Vector3 *pos[3],
38  const UT_Vector3 *vels[3],
39  fpreal times[2],
40  fpreal timestep);
41 
42  /// Finds the first time when the given two moving points are within dist.
43  /// Only returns times between 0 and timestep. Returns the number of times
44  /// found (either 0 or 1).
45  ///
46  /// Requires two points to be collinear for entire timestep, which
47  /// makes it simpler and more robust than collideMovingPoints.
48  static int findTimes2CollinearPointsCoincident(const UT_Vector3 &pos0,
49  const UT_Vector3 &pos1,
50  const UT_Vector3 &vel0,
51  const UT_Vector3 &vel1,
52  fpreal &time,
53  fpreal timestep,
54  fpreal dist);
55 
56  /// Finds the first time when the given two moving points are within dist.
57  /// Only returns times between 0 and timestep. Returns the number of times
58  /// found (either 0 or 1).
59  /// Warning: I'm not convinced this works for dist != 0.
60  /// ... and in fact, it's probably fragile for dist != 0 too.
61  static int collideMovingPoints(const UT_Vector3 &pos1,
62  const UT_Vector3 &pos2,
63  const UT_Vector3 &vel1,
64  const UT_Vector3 &vel2,
65  fpreal &time,
66  fpreal timestep,
67  fpreal dist);
68 
69  /// Finds the first time when the given point and line are within dist.
70  /// Only returns times between 0 and timestep. Returns the number of times
71  /// found (max of 1), or -1 if the point and the line are exactly
72  /// dist away for the entire timestep. pos0 is the point.
73  static int collideMovingPointLine(const UT_Vector3 &pos0,
74  const UT_Vector3 &pos1,
75  const UT_Vector3 &pos2,
76  const UT_Vector3 &vel0,
77  const UT_Vector3 &vel1,
78  const UT_Vector3 &vel2,
79  fpreal &time,
80  fpreal timestep,
81  fpreal dist);
82 
83  /// Finds the first time when the given lines are within dist of eachother.
84  /// Only returns times between 0 and timestep. Returns the number of times
85  /// found (max of 1), or -1 if the lines are exactly dist away for the
86  /// entire timestep. <pos0, pos1> forms one line, <pos2, pos3> forms the
87  /// other
88  static int collideMovingLineLine(const UT_Vector3 &pos0,
89  const UT_Vector3 &pos1,
90  const UT_Vector3 &pos2,
91  const UT_Vector3 &pos3,
92  const UT_Vector3 &vel0,
93  const UT_Vector3 &vel1,
94  const UT_Vector3 &vel2,
95  const UT_Vector3 &vel3,
96  fpreal &time,
97  fpreal timestep,
98  fpreal dist);
99 
100 };
101 
102 #endif
103 
104 
GA_API const UT_StringHolder dist
GT_API const UT_StringHolder time
#define UT_API
Definition: UT_API.h:14
fpreal64 fpreal
Definition: SYS_Types.h:277
This is a class for various primitive collisions.
Definition: UT_Collider.h:20