~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to extern/bullet2/src/LinearMath/btAabbUtil2.h

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#ifndef AABB_UTIL2
18
18
#define AABB_UTIL2
19
19
 
 
20
#include "btTransform.h"
20
21
#include "btVector3.h"
21
 
#include "btSimdMinMax.h"
22
 
 
23
 
 
24
 
#define btMin(a,b) ((a < b ? a : b))
25
 
#define btMax(a,b) ((a > b ? a : b))
 
22
#include "btMinMax.h"
 
23
 
 
24
SIMD_FORCE_INLINE void AabbExpand (btVector3& aabbMin,
 
25
                                                                   btVector3& aabbMax,
 
26
                                                                   const btVector3& expansionMin,
 
27
                                                                   const btVector3& expansionMax)
 
28
{
 
29
        aabbMin = aabbMin + expansionMin;
 
30
        aabbMax = aabbMax + expansionMax;
 
31
}
26
32
 
27
33
 
28
34
/// conservative test for overlap between two aabbs
67
73
}
68
74
 
69
75
 
 
76
SIMD_FORCE_INLINE bool btRayAabb2(const btVector3& rayFrom,
 
77
                                                                  const btVector3& rayInvDirection,
 
78
                                                                  const unsigned int raySign[3],
 
79
                                                                  const btVector3 bounds[2],
 
80
                                                                  btScalar& tmin,
 
81
                                                                  btScalar lambda_min,
 
82
                                                                  btScalar lambda_max)
 
83
{
 
84
        btScalar tmax, tymin, tymax, tzmin, tzmax;
 
85
        tmin = (bounds[raySign[0]][0] - rayFrom[0]) * rayInvDirection[0];
 
86
        tmax = (bounds[1-raySign[0]][0] - rayFrom[0]) * rayInvDirection[0];
 
87
        tymin = (bounds[raySign[1]][1] - rayFrom[1]) * rayInvDirection[1];
 
88
        tymax = (bounds[1-raySign[1]][1] - rayFrom[1]) * rayInvDirection[1];
 
89
 
 
90
        if ( (tmin > tymax) || (tymin > tmax) )
 
91
                return false;
 
92
 
 
93
        if (tymin > tmin)
 
94
                tmin = tymin;
 
95
 
 
96
        if (tymax < tmax)
 
97
                tmax = tymax;
 
98
 
 
99
        tzmin = (bounds[raySign[2]][2] - rayFrom[2]) * rayInvDirection[2];
 
100
        tzmax = (bounds[1-raySign[2]][2] - rayFrom[2]) * rayInvDirection[2];
 
101
 
 
102
        if ( (tmin > tzmax) || (tzmin > tmax) )
 
103
                return false;
 
104
        if (tzmin > tmin)
 
105
                tmin = tzmin;
 
106
        if (tzmax < tmax)
 
107
                tmax = tzmax;
 
108
        return ( (tmin < lambda_max) && (tmax > lambda_min) );
 
109
}
 
110
 
70
111
SIMD_FORCE_INLINE bool btRayAabb(const btVector3& rayFrom, 
71
112
                                                                 const btVector3& rayTo, 
72
113
                                                                 const btVector3& aabbMin, 
123
164
}
124
165
 
125
166
 
 
167
 
 
168
SIMD_FORCE_INLINE       void btTransformAabb(const btVector3& halfExtents, btScalar margin,const btTransform& t,btVector3& aabbMinOut,btVector3& aabbMaxOut)
 
169
{
 
170
        btVector3 halfExtentsWithMargin = halfExtents+btVector3(margin,margin,margin);
 
171
        btMatrix3x3 abs_b = t.getBasis().absolute();  
 
172
        btVector3 center = t.getOrigin();
 
173
        btVector3 extent = btVector3(abs_b[0].dot(halfExtentsWithMargin),
 
174
                   abs_b[1].dot(halfExtentsWithMargin),
 
175
                  abs_b[2].dot(halfExtentsWithMargin));
 
176
        aabbMinOut = center - extent;
 
177
        aabbMaxOut = center + extent;
 
178
}
 
179
 
 
180
 
 
181
SIMD_FORCE_INLINE       void btTransformAabb(const btVector3& localAabbMin,const btVector3& localAabbMax, btScalar margin,const btTransform& trans,btVector3& aabbMinOut,btVector3& aabbMaxOut)
 
182
{
 
183
                btAssert(localAabbMin.getX() <= localAabbMax.getX());
 
184
                btAssert(localAabbMin.getY() <= localAabbMax.getY());
 
185
                btAssert(localAabbMin.getZ() <= localAabbMax.getZ());
 
186
                btVector3 localHalfExtents = btScalar(0.5)*(localAabbMax-localAabbMin);
 
187
                localHalfExtents+=btVector3(margin,margin,margin);
 
188
 
 
189
                btVector3 localCenter = btScalar(0.5)*(localAabbMax+localAabbMin);
 
190
                btMatrix3x3 abs_b = trans.getBasis().absolute();  
 
191
                btVector3 center = trans(localCenter);
 
192
                btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
 
193
                           abs_b[1].dot(localHalfExtents),
 
194
                          abs_b[2].dot(localHalfExtents));
 
195
                aabbMinOut = center-extent;
 
196
                aabbMaxOut = center+extent;
 
197
}
 
198
 
 
199
 
126
200
#endif
127
201
 
 
202