00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Yin Zhao 00008 * Side Effects Software Inc 00009 * 123 Front Street West, Suite 1401 00010 * Toronto, Ontario 00011 * Canada M5J 2M2 00012 * 416-504-9876 00013 */ 00014 00015 #ifndef __UT_Collider_h__ 00016 #define __UT_Collider_h__ 00017 00018 #include "UT_API.h" 00019 #include <SYS/SYS_Types.h> 00020 #include "UT_Vector3.h" 00021 00022 /// This is a class for various primitive collisions 00023 // 00024 // TODO: it really doesn't belong in UT. It could possibly go in BV, since 00025 // it's kind of a "follow-up" stage after using a bounding-volume 00026 // hierarchy. 00027 class UT_API UT_Collider 00028 { 00029 public: 00030 00031 /// Find times when the given four moving points are coplanar. Only 00032 /// returns times between 0 and timestep. Returns the number of times 00033 /// found (maximum of three), or -1 if the points are coplanar for the 00034 /// entire timestep. 00035 static int findTimes4PointsCoplanar(const UT_Vector3 *pos[4], 00036 const UT_Vector3 *vels[4], 00037 fpreal times[3], 00038 fpreal timestep); 00039 00040 /// Find times when the three given moving points are collinear. Only 00041 /// returns times between 0 and timestep. Returns the number of times 00042 /// found (maximum of two), or -1 if the points are collinear for the 00043 /// entire timestep. 00044 static int findTimes3PointsCollinear(const UT_Vector3 *pos[3], 00045 const UT_Vector3 *vels[3], 00046 fpreal times[2], 00047 fpreal timestep); 00048 00049 /// Finds the first time when the given two moving points are within dist. 00050 /// Only returns times between 0 and timestep. Returns the number of times 00051 /// found (either 0 or 1). 00052 /// 00053 /// Requires two points to be collinear for entire timestep, which 00054 /// makes it simpler and more robust than collideMovingPoints. 00055 static int findTimes2CollinearPointsCoincident(const UT_Vector3 &pos0, 00056 const UT_Vector3 &pos1, 00057 const UT_Vector3 &vel0, 00058 const UT_Vector3 &vel1, 00059 fpreal &time, 00060 fpreal timestep, 00061 fpreal dist); 00062 00063 /// Finds the first time when the given two moving points are within dist. 00064 /// Only returns times between 0 and timestep. Returns the number of times 00065 /// found (either 0 or 1). 00066 /// Warning: I'm not convinced this works for dist != 0. 00067 /// ... and in fact, it's probably fragile for dist != 0 too. 00068 static int collideMovingPoints(const UT_Vector3 &pos1, 00069 const UT_Vector3 &pos2, 00070 const UT_Vector3 &vel1, 00071 const UT_Vector3 &vel2, 00072 fpreal &time, 00073 fpreal timestep, 00074 fpreal dist); 00075 00076 /// Finds the first time when the given point and line are within dist. 00077 /// Only returns times between 0 and timestep. Returns the number of times 00078 /// found (max of 1), or -1 if the point and the line are exactly 00079 /// dist away for the entire timestep. pos0 is the point. 00080 static int collideMovingPointLine(const UT_Vector3 &pos0, 00081 const UT_Vector3 &pos1, 00082 const UT_Vector3 &pos2, 00083 const UT_Vector3 &vel0, 00084 const UT_Vector3 &vel1, 00085 const UT_Vector3 &vel2, 00086 fpreal &time, 00087 fpreal timestep, 00088 fpreal dist); 00089 00090 /// Finds the first time when the given lines are within dist of eachother. 00091 /// Only returns times between 0 and timestep. Returns the number of times 00092 /// found (max of 1), or -1 if the lines are exactly dist away for the 00093 /// entire timestep. <pos0, pos1> forms one line, <pos2, pos3> forms the 00094 /// other 00095 static int collideMovingLineLine(const UT_Vector3 &pos0, 00096 const UT_Vector3 &pos1, 00097 const UT_Vector3 &pos2, 00098 const UT_Vector3 &pos3, 00099 const UT_Vector3 &vel0, 00100 const UT_Vector3 &vel1, 00101 const UT_Vector3 &vel2, 00102 const UT_Vector3 &vel3, 00103 fpreal &time, 00104 fpreal timestep, 00105 fpreal dist); 00106 00107 }; 00108 00109 #endif 00110 00111
1.5.9