Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/toonshader/src/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.cpp @ 4070

Last change on this file since 4070 was 2662, checked in by rgrieder, 16 years ago

Merged presentation branch back to trunk.

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16
17#include "btConvexInternalShape.h"
18
19
20
21btConvexInternalShape::btConvexInternalShape()
22: m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
23m_collisionMargin(CONVEX_DISTANCE_MARGIN)
24{
25}
26
27
28void    btConvexInternalShape::setLocalScaling(const btVector3& scaling)
29{
30        m_localScaling = scaling.absolute();
31}
32
33
34
35void    btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const
36{
37
38        btScalar margin = getMargin();
39        for (int i=0;i<3;i++)
40        {
41                btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
42                vec[i] = btScalar(1.);
43
44                btVector3 sv = localGetSupportingVertex(vec*trans.getBasis());
45
46                btVector3 tmp = trans(sv);
47                maxAabb[i] = tmp[i]+margin;
48                vec[i] = btScalar(-1.);
49                tmp = trans(localGetSupportingVertex(vec*trans.getBasis()));
50                minAabb[i] = tmp[i]-margin;
51        }
52}
53
54
55
56btVector3       btConvexInternalShape::localGetSupportingVertex(const btVector3& vec)const
57{
58#ifndef __SPU__
59
60         btVector3      supVertex = localGetSupportingVertexWithoutMargin(vec);
61
62        if ( getMargin()!=btScalar(0.) )
63        {
64                btVector3 vecnorm = vec;
65                if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
66                {
67                        vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
68                } 
69                vecnorm.normalize();
70                supVertex+= getMargin() * vecnorm;
71        }
72        return supVertex;
73
74#else
75        btAssert(0);
76        return btVector3(0,0,0);
77#endif //__SPU__
78
79 }
80
81
Note: See TracBrowser for help on using the repository browser.