1 #ifndef CONVEX_BUILDER_H
2 #define CONVEX_BUILDER_H
4 /*----------------------------------------------------------------------
5 Copyright (c) 2004 Open Dynamics Framework Group
9 Redistribution and use in source and binary forms, with or without modification, are permitted provided
10 that the following conditions are met:
12 Redistributions of source code must retain the above copyright notice, this list of conditions
13 and the following disclaimer.
15 Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 Neither the name of the Open Dynamics Framework Group nor the names of its contributors may
20 be used to endorse or promote products derived from this software without specific prior written permission.
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE INTEL OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
27 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 -----------------------------------------------------------------------*/
31 // http://codesuppository.blogspot.com
33 // mailto: jratcliff@infiniplex.net
35 // http://www.amillionpixels.us
39 #include "ConvexDecomposition.h"
41 #include "LinearMath/btAlignedObjectArray.h"
43 using namespace ConvexDecomposition;
49 CHull(const ConvexResult &result);
53 bool overlap(const CHull &h) const;
58 float mDiagonal; // long edge..
59 ConvexResult *mResult;
62 // Usage: std::sort( list.begin(), list.end(), StringSortRef() );
67 inline bool operator()(const CHull *a,const CHull *b) const
69 return a->mVolume < b->mVolume;
74 typedef btAlignedObjectArray< CHull * > CHullVector;
78 class ConvexBuilder : public ConvexDecompInterface
81 ConvexBuilder(ConvexDecompInterface *callback);
83 virtual ~ConvexBuilder(void);
85 bool isDuplicate(unsigned int i1,unsigned int i2,unsigned int i3,
86 unsigned int ci1,unsigned int ci2,unsigned int ci3);
88 void getMesh(const ConvexResult &cr,VertexLookup vc,UintVector &indices);
90 CHull * canMerge(CHull *a,CHull *b);
92 bool combineHulls(void);
94 unsigned int process(const DecompDesc &desc);
96 virtual void ConvexDebugTri(const float *p1,const float *p2,const float *p3,unsigned int color);
98 virtual void ConvexDebugOBB(const float *sides, const float *matrix,unsigned int color);
99 virtual void ConvexDebugPoint(const float *p,float dist,unsigned int color);
101 virtual void ConvexDebugBound(const float *bmin,const float *bmax,unsigned int color);
103 virtual void ConvexDecompResult(ConvexResult &result);
105 void sortChulls(CHullVector &hulls);
108 ConvexDecompInterface *mCallback;
111 #endif //CONVEX_BUILDER_H