1 2 /*************************************************************************\ 3 4 Copyright 1995 The University of North Carolina at Chapel Hill. 5 All Rights Reserved. 6 7 Permission to use, copy, modify and distribute this software and its 8 documentation for educational, research and non-profit purposes, without 9 fee, and without a written agreement is hereby granted, provided that the 10 above copyright notice and the following three paragraphs appear in all 11 copies. 12 13 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE 14 LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR 15 CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE 16 USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY 17 OF NORTH CAROLINA HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH 18 DAMAGES. 19 20 THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY 21 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 23 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 24 NORTH CAROLINA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, 25 UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 26 27 The authors may be contacted via: 28 29 US Mail: S. Gottschalk 30 Department of Computer Science 31 Sitterson Hall, CB #3175 32 University of N. Carolina 33 Chapel Hill, NC 27599-3175 34 35 Phone: (919)962-1749 36 37 EMail: {gottscha}@cs.unc.edu 38 39 40 \**************************************************************************/ 41 42 #ifndef RAPID_H 43 #define RAPID_H 44 45 /****************************************************************************/ 46 47 48 // RAPID API RETURN VALUES 49 50 51 const int RAPID_OK = 0; 52 // Used by all API routines except constructors and destructors. 53 54 55 const int RAPID_ERR_MODEL_OUT_OF_MEMORY = 1; 56 // Returned when an API function cannot obtain enough memory to store 57 // or process a RAPID_model object. 58 59 60 const int RAPID_ERR_COLLIDE_OUT_OF_MEMORY = 2; 61 // Returned when RAPID_Collide() cannot allocate enough storage to hold 62 // collision information. In this case, there is as much collision 63 // detection information available as could be allocated for. 64 65 66 const int RAPID_ERR_UNPROCESSED_MODEL = 3; 67 // Returned when an unprocessed model is passed to a function which 68 // expects only processed models, such as RAPID_Collide(). 69 70 71 const int RAPID_ERR_BUILD_OUT_OF_SEQUENCE = 4; 72 // Returned when: 73 // 1. AddTri() is called before BeginModel(). The triangle will 74 // be added anyway as if BeginModel() had been previously called. 75 // 2. BeginModel() is called immediately after AddTri(). The 76 // model will be placed into an empty initial state. 77 // This error code is something like a warning: the invoked 78 // operation takes place anyway, but the returned error code may tip 79 // off the client that something out of the ordinary is happenning. 80 81 82 const int RAPID_ERR_BUILD_EMPTY_MODEL = 5; 83 // Returned when EndModel() is called on a model to which no 84 // triangles have been added. This is similar in spirit to the 85 // OUT_OF_SEQUENCE return code, except that the requested operation 86 // has FAILED -- the model remains "unprocessed". 87 88 89 /****************************************************************************/ 90 91 92 class box; 93 class tri; 94 95 class RAPID_model 96 { 97 public: 98 99 // Declarations the client doesn't need to see 100 // note -- wherever the file "RAPID.H" gets copied, "RAPID_private.H" 101 // should go with it. 102 103 #include "RAPID_private.H" 104 105 public: 106 107 // These are everything the client needs to use RAPID. 108 109 RAPID_model(); 110 ~RAPID_model(); 111 112 int BeginModel(); 113 int AddTri(const double *p1, const double *p2, const double *p3, int id); 114 int EndModel(); 115 116 }; 117 118 /****************************************************************************/ 119 120 // These are for the client 121 122 // Find all pairwise intersecting triangles 123 const int RAPID_ALL_CONTACTS = 1; 124 125 // Just report one intersecting triangle pair, if there are any. 126 const int RAPID_FIRST_CONTACT = 2; 127 128 129 // This is the collision query invocation. It assumes that the 130 // models are not being scaled up or down, but have their native 131 // dimensions. 132 int 133 RAPID_Collide(double R1[3][3], double T1[3], RAPID_model *o1, 134 double R2[3][3], double T2[3], RAPID_model *o2, 135 int flag = RAPID_ALL_CONTACTS); 136 137 // This collision query permits the models to each be scaled by 138 // some positive factor (must be greater than 0). 139 int 140 RAPID_Collide(double R1[3][3], double T1[3], double s1, RAPID_model *o1, 141 double R2[3][3], double T2[3], double s2, RAPID_model *o2, 142 int flag = RAPID_ALL_CONTACTS); 143 144 // this is for the client 145 struct collision_pair 146 { 147 int id1; 148 int id2; 149 }; 150 151 /****************************************************************************/ 152 153 extern int RAPID_num_box_tests; 154 extern int RAPID_num_tri_tests; 155 extern int RAPID_num_contacts; 156 extern struct collision_pair *RAPID_contact; 157 158 #endif 159 160 161 162 163 164 165 166 167