Blender  V3.3
btTriangleShapeEx.h
Go to the documentation of this file.
1 
4 /*
5 This source file is part of GIMPACT Library.
6 
7 For the latest info, see http://gimpact.sourceforge.net/
8 
9 Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
10 email: projectileman@yahoo.com
11 
12 
13 This software is provided 'as-is', without any express or implied warranty.
14 In no event will the authors be held liable for any damages arising from the use of this software.
15 Permission is granted to anyone to use this software for any purpose,
16 including commercial applications, and to alter it and redistribute it freely,
17 subject to the following restrictions:
18 
19 1. 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.
20 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
21 3. This notice may not be removed or altered from any source distribution.
22 */
23 
24 #ifndef GIMPACT_TRIANGLE_SHAPE_EX_H
25 #define GIMPACT_TRIANGLE_SHAPE_EX_H
26 
29 #include "btBoxCollision.h"
30 #include "btClipPolygon.h"
31 #include "btGeometryOperations.h"
32 
33 #define MAX_TRI_CLIPPING 16
34 
37 {
42 
44  {
48  int i = m_point_count;
49  while (i--)
50  {
51  m_points[i] = other.m_points[i];
52  }
53  }
54 
56  {
57  }
58 
60  {
61  copy_from(other);
62  }
63 
65  void merge_points(const btVector4& plane,
66  btScalar margin, const btVector3* points, int point_count);
67 };
68 
70 {
71 public:
77  {
78  }
79 
81  {
83  normal.normalize();
85  }
86 
89 
91 
94  SIMD_FORCE_INLINE void get_edge_plane(int edge_index, btVector4& plane) const
95  {
96  const btVector3& e0 = m_vertices[edge_index];
97  const btVector3& e1 = m_vertices[(edge_index + 1) % 3];
98  bt_edge_plane(e0, e1, m_plane, plane);
99  }
100 
102  {
103  m_vertices[0] = t(m_vertices[0]);
104  m_vertices[1] = t(m_vertices[1]);
105  m_vertices[2] = t(m_vertices[2]);
106  }
107 
109 
113  int clip_triangle(btPrimitiveTriangle& other, btVector3* clipped_points);
114 
116 
120 };
121 
123 
127 {
128 public:
130  {
131  }
132 
133  btTriangleShapeEx(const btVector3& p0, const btVector3& p1, const btVector3& p2) : btTriangleShape(p0, p1, p2)
134  {
135  }
136 
138  {
139  }
140 
141  virtual void getAabb(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
142  {
143  btVector3 tv0 = t(m_vertices1[0]);
144  btVector3 tv1 = t(m_vertices1[1]);
145  btVector3 tv2 = t(m_vertices1[2]);
146 
147  btAABB trianglebox(tv0, tv1, tv2, m_collisionMargin);
148  aabbMin = trianglebox.m_min;
149  aabbMax = trianglebox.m_max;
150  }
151 
153  {
154  m_vertices1[0] = t(m_vertices1[0]);
155  m_vertices1[1] = t(m_vertices1[1]);
156  m_vertices1[2] = t(m_vertices1[2]);
157  }
158 
160  {
162  normal.normalize();
163  plane.setValue(normal[0], normal[1], normal[2], m_vertices1[0].dot(normal));
164  }
165 
166  bool overlap_test_conservative(const btTriangleShapeEx& other);
167 };
168 
169 #endif //GIMPACT_TRIANGLE_MESH_SHAPE_H
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
btAABB
Axis aligned box.
btScalar m_collisionMargin
SIMD_FORCE_INLINE void bt_edge_plane(const btVector3 &e1, const btVector3 &e2, const btVector3 &normal, btVector4 &plane)
Calc a plane from a triangle edge an a normal. plane is a vec4f.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define SIMD_FORCE_INLINE
Definition: btScalar.h:280
btTransform
The btTransform class supports rigid transforms with only translation and rotation and no scaling/she...
Definition: btTransform.h:30
#define MAX_TRI_CLIPPING
btTriangleShape()
btVector3 m_vertices1[3]
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
Definition: btVector3.h:82
bool find_triangle_collision_clip_method(btPrimitiveTriangle &other, GIM_TRIANGLE_CONTACT &contacts)
Find collision using the clipping method.
SIMD_FORCE_INLINE void get_edge_plane(int edge_index, btVector4 &plane) const
Calcs the plane which is paralele to the edge and perpendicular to the triangle plane.
int clip_triangle(btPrimitiveTriangle &other, btVector3 *clipped_points)
Clips the triangle against this.
bool overlap_test_conservative(const btPrimitiveTriangle &other)
Test if triangles could collide.
void applyTransform(const btTransform &t)
SIMD_FORCE_INLINE void buildTriPlane()
Helper class for colliding Bullet Triangle Shapes.
SIMD_FORCE_INLINE void buildTriPlane(btVector4 &plane) const
btTriangleShapeEx(const btVector3 &p0, const btVector3 &p1, const btVector3 &p2)
void applyTransform(const btTransform &t)
bool overlap_test_conservative(const btTriangleShapeEx &other)
class btTriangleShapeEx: public btTriangleShape
virtual void getAabb(const btTransform &t, btVector3 &aabbMin, btVector3 &aabbMax) const
btTriangleShapeEx(const btTriangleShapeEx &other)
SIMD_FORCE_INLINE void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z, const btScalar &_w)
Set x,y,z and zero w.
Definition: btVector3.h:1198
IconTextureDrawCall normal
T dot(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
vec_base< T, 3 > cross(const vec_base< T, 3 > &a, const vec_base< T, 3 > &b)
Structure for collision.
btVector3 m_points[MAX_TRI_CLIPPING]
SIMD_FORCE_INLINE void copy_from(const GIM_TRIANGLE_CONTACT &other)
GIM_TRIANGLE_CONTACT(const GIM_TRIANGLE_CONTACT &other)
void merge_points(const btVector4 &plane, btScalar margin, const btVector3 *points, int point_count)
classify points that are closer