00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __GU_OldOBBTree_h__
00032 #define __GU_OldOBBTree_h__
00033
00034 #include "GU_API.h"
00035 #include <UT/UT_VectorTypes.h>
00036 class GU_Detail;
00037 class GU_PrimPoly;
00038 class bvTriangle;
00039 struct guOBB;
00040
00041 typedef void (*GU_ContactCreateFunc)
00042 (const UT_Vector3 &hitpt, const UT_Vector3 &normal,
00043 const UT_Vector3 &ea, const UT_Vector3 &eb,
00044 int isVF, int isJustTouching, int swapAB);
00045
00046 class GU_API GU_OldOBBTree
00047 {
00048 public:
00049 GU_OldOBBTree();
00050 ~GU_OldOBBTree();
00051
00052 void build( const GU_Detail *gdp, float lod );
00053 void intersect( const GU_OldOBBTree &tree,
00054 const UT_Matrix3 &ar, const UT_Matrix3 &br,
00055 const UT_Vector3 &at, const UT_Vector3 &bt,
00056 GU_ContactCreateFunc contactCreate,
00057 float tol ) const;
00058
00059 private:
00060 static int compareTriangles( const void *t1, const void *t2 );
00061 void createTriangles( const GU_Detail *gdp, float lod );
00062 guOBB *createTree( bvTriangle *triangles, int numTriangles,
00063 const UT_Matrix3 &rootBasis,
00064 const UT_Vector3 &rootPos );
00065 void getBasis( UT_Matrix3 &c );
00066 void getBounds( const UT_Matrix3 &basis,
00067 const bvTriangle &triangle,
00068 UT_Vector3 &minpos, UT_Vector3 &maxpos );
00069 void intersect( const guOBB *a, const guOBB *b,
00070 const UT_Matrix3 &R, const UT_Vector3 &T,
00071 float tol ) const;
00072 int checkBoxInsideSphere( const guOBB *a, const guOBB *b,
00073 const UT_Matrix3 &R, const UT_Vector3 &T,
00074 float tol ) const;
00075 void findContacts( const guOBB *a, const guOBB *b,
00076 float tol ) const;
00077 void findSphereContacts( const guOBB *a, const guOBB *b,
00078 float tol ) const;
00079 void findSphereSphereContacts( const guOBB *a,
00080 const guOBB *b, float tol ) const;
00081
00082 int myNumTriangles;
00083 bvTriangle *myTriangles;
00084 guOBB *myRoot;
00085 static UT_Matrix3 theAR;
00086 static UT_Matrix3 theBR;
00087 static UT_Vector3 theAT;
00088 static UT_Vector3 theBT;
00089 };
00090
00091 #endif