added some get methods and stuff
[blender.git] / extern / bullet / Bullet / CollisionShapes / CylinderShape.h
1 /*
2  * Copyright (c) 2005 Erwin Coumans http://www.erwincoumans.com
3  *
4  * Permission to use, copy, modify, distribute and sell this software
5  * and its documentation for any purpose is hereby granted without fee,
6  * provided that the above copyright notice appear in all copies.
7  * Erwin Coumans makes no representations about the suitability 
8  * of this software for any purpose.  
9  * It is provided "as is" without express or implied warranty.
10  */
11
12 #ifndef CYLINDER_MINKOWSKI_H
13 #define CYLINDER_MINKOWSKI_H
14
15 #include "BoxShape.h"
16 #include "BroadphaseCollision/BroadphaseProxy.h" // for the types
17 #include "SimdVector3.h"
18
19 /// implements cylinder shape interface
20 class CylinderShape : public BoxShape
21
22 {
23
24 public:
25         CylinderShape (const SimdVector3& halfExtents);
26         
27         ///GetAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
28         void GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const
29         {
30                 GetAabbSlow(t,aabbMin,aabbMax);
31         }
32
33         virtual SimdVector3     LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const;
34
35         virtual SimdVector3     LocalGetSupportingVertex(const SimdVector3& vec) const
36         {
37
38                 SimdVector3 supVertex;
39                 supVertex = LocalGetSupportingVertexWithoutMargin(vec);
40                 
41                 if ( GetMargin()!=0.f )
42                 {
43                         SimdVector3 vecnorm = vec;
44                         if (vecnorm .length2() == 0.f)
45                         {
46                                 vecnorm.setValue(-1.f,-1.f,-1.f);
47                         } 
48                         vecnorm.normalize();
49                         supVertex+= GetMargin() * vecnorm;
50                 }
51                 return supVertex;
52         }
53
54
55         //use box inertia
56         //      virtual void    CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia);
57
58         virtual int     GetShapeType() const
59         {
60                 return CYLINDER_SHAPE_PROXYTYPE;
61         }
62         
63
64
65 };
66
67 class CylinderShapeX : public CylinderShape
68 {
69 public:
70         CylinderShapeX (const SimdVector3& halfExtents);
71
72         virtual SimdVector3     LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const;
73 };
74
75 class CylinderShapeZ : public CylinderShape
76 {
77 public:
78         CylinderShapeZ (const SimdVector3& halfExtents);
79
80         virtual SimdVector3     LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const;
81
82 };
83
84
85 #endif //CYLINDER_MINKOWSKI_H