~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/bullet/Extras/ConvexDecomposition/ConvexBuilder.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef CONVEX_BUILDER_H
 
2
#define CONVEX_BUILDER_H
 
3
 
 
4
/*----------------------------------------------------------------------
 
5
Copyright (c) 2004 Open Dynamics Framework Group
 
6
www.physicstools.org
 
7
All rights reserved.
 
8
 
 
9
Redistribution and use in source and binary forms, with or without modification, are permitted provided
 
10
that the following conditions are met:
 
11
 
 
12
Redistributions of source code must retain the above copyright notice, this list of conditions
 
13
and the following disclaimer.
 
14
 
 
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.
 
18
 
 
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.
 
21
 
 
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
-----------------------------------------------------------------------*/
 
30
 
 
31
// http://codesuppository.blogspot.com
 
32
//
 
33
// mailto: jratcliff@infiniplex.net
 
34
//
 
35
// http://www.amillionpixels.us
 
36
//
 
37
 
 
38
 
 
39
#include "ConvexDecomposition.h"
 
40
#include "vlookup.h"
 
41
#include "LinearMath/btAlignedObjectArray.h"
 
42
 
 
43
using namespace ConvexDecomposition;
 
44
 
 
45
 
 
46
class CHull
 
47
{
 
48
public:
 
49
        CHull(const ConvexResult &result);
 
50
 
 
51
        ~CHull(void);
 
52
 
 
53
        bool overlap(const CHull &h) const;
 
54
 
 
55
        float          mMin[3];
 
56
        float          mMax[3];
 
57
        float          mVolume;
 
58
        float          mDiagonal; // long edge..
 
59
        ConvexResult  *mResult;
 
60
};
 
61
 
 
62
// Usage: std::sort( list.begin(), list.end(), StringSortRef() );
 
63
class CHullSort
 
64
{
 
65
public:
 
66
 
 
67
        inline bool operator()(const CHull *a,const CHull *b) const
 
68
        {
 
69
                return a->mVolume < b->mVolume;
 
70
        }
 
71
};
 
72
 
 
73
 
 
74
typedef btAlignedObjectArray< CHull * > CHullVector;
 
75
 
 
76
 
 
77
 
 
78
class ConvexBuilder : public ConvexDecompInterface
 
79
{
 
80
public:
 
81
        ConvexBuilder(ConvexDecompInterface *callback);
 
82
 
 
83
        virtual ~ConvexBuilder(void);
 
84
 
 
85
        bool isDuplicate(unsigned int i1,unsigned int i2,unsigned int i3,
 
86
                unsigned int ci1,unsigned int ci2,unsigned int ci3);
 
87
 
 
88
        void getMesh(const ConvexResult &cr,VertexLookup vc,UintVector &indices);
 
89
 
 
90
        CHull * canMerge(CHull *a,CHull *b);
 
91
 
 
92
        bool combineHulls(void);
 
93
 
 
94
        unsigned int process(const DecompDesc &desc);
 
95
 
 
96
        virtual void ConvexDebugTri(const float *p1,const float *p2,const float *p3,unsigned int color);
 
97
 
 
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);
 
100
 
 
101
        virtual void ConvexDebugBound(const float *bmin,const float *bmax,unsigned int color);
 
102
 
 
103
        virtual void ConvexDecompResult(ConvexResult &result);
 
104
 
 
105
        void sortChulls(CHullVector &hulls);
 
106
 
 
107
        CHullVector     mChulls;
 
108
        ConvexDecompInterface *mCallback;
 
109
};
 
110
 
 
111
#endif //CONVEX_BUILDER_H
 
112