Bullet Collision Detection & Physics Library: btContactProcessingStructs.h Source File

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btContactProcessingStructs.h
Go to the documentation of this file.
1#ifndef BT_CONTACT_H_STRUCTS_INCLUDED
2#define BT_CONTACT_H_STRUCTS_INCLUDED
3
7/*
8This source file is part of GIMPACT Library.
9
10For the latest info, see http://gimpact.sourceforge.net/
11
12Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
13email: projectileman@yahoo.com
14
15
16This software is provided 'as-is', without any express or implied warranty.
17In no event will the authors be held liable for any damages arising from the use of this software.
18Permission is granted to anyone to use this software for any purpose,
19including commercial applications, and to alter it and redistribute it freely,
20subject to the following restrictions:
21
221. 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.
232. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
243. This notice may not be removed or altered from any source distribution.
25*/
26
27#include "LinearMath/btTransform.h"
28#include "LinearMath/btAlignedObjectArray.h"
29#include "btTriangleShapeEx.h"
30
34#define NORMAL_CONTACT_AVERAGE 1
35
36#define CONTACT_DIFF_EPSILON 0.00001f
37
40 class GIM_CONTACT
41{
42public:
43 btVector3 m_point;
44 btVector3 m_normal;
45 btScalar m_depth; //Positive value indicates interpenetration
46 btScalar m_distance; //Padding not for use
47 int m_feature1; //Face number
48 int m_feature2; //Face number
49public:
50 GIM_CONTACT()
51 {
52 }
53
54 GIM_CONTACT(const GIM_CONTACT &contact) : m_point(contact.m_point),
55 m_normal(contact.m_normal),
56 m_depth(contact.m_depth),
57 m_feature1(contact.m_feature1),
58 m_feature2(contact.m_feature2)
59 {
60 }
61
62 GIM_CONTACT(const btVector3 &point, const btVector3 &normal,
63 btScalar depth, int feature1, int feature2) : m_point(point),
64 m_normal(normal),
65 m_depth(depth),
66 m_feature1(feature1),
67 m_feature2(feature2)
68 {
69 }
70
72 SIMD_FORCE_INLINE unsigned int calc_key_contact() const
73 {
74 int _coords[] = {
75 (int)(m_point[0] * 1000.0f + 1.0f),
76 (int)(m_point[1] * 1333.0f),
77 (int)(m_point[2] * 2133.0f + 3.0f)};
78 unsigned int _hash = 0;
79 unsigned int *_uitmp = (unsigned int *)(&_coords[0]);
80 _hash = *_uitmp;
81 _uitmp++;
82 _hash += (*_uitmp) << 4;
83 _uitmp++;
84 _hash += (*_uitmp) << 8;
85 return _hash;
86 }
87
88 SIMD_FORCE_INLINE void interpolate_normals(btVector3 *normals, int normal_count)
89 {
90 btVector3 vec_sum(m_normal);
91 for (int i = 0; i < normal_count; i++)
92 {
93 vec_sum += normals[i];
94 }
95
96 btScalar vec_sum_len = vec_sum.length2();
97 if (vec_sum_len < CONTACT_DIFF_EPSILON) return;
98
99 //GIM_INV_SQRT(vec_sum_len,vec_sum_len); // 1/sqrt(vec_sum_len)
100
101 m_normal = vec_sum / btSqrt(vec_sum_len);
102 }
103};
104
105#endif // BT_CONTACT_H_STRUCTS_INCLUDED
btAlignedObjectArray.h
btScalar
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:314
btSqrt
btScalar btSqrt(btScalar y)
Definition btScalar.h:466
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition btScalar.h:98
btTransform.h
btTriangleShapeEx.h
GIM_CONTACT
The GIM_CONTACT is an internal GIMPACT structure, similar to btManifoldPoint.
Definition btContactProcessingStructs.h:41
GIM_CONTACT::m_distance
btScalar m_distance
Definition btContactProcessingStructs.h:46
GIM_CONTACT::GIM_CONTACT
GIM_CONTACT()
Definition btContactProcessingStructs.h:50
GIM_CONTACT::m_point
btVector3 m_point
Definition btContactProcessingStructs.h:43
GIM_CONTACT::m_feature1
int m_feature1
Definition btContactProcessingStructs.h:47
GIM_CONTACT::m_feature2
int m_feature2
Definition btContactProcessingStructs.h:48
GIM_CONTACT::interpolate_normals
void interpolate_normals(btVector3 *normals, int normal_count)
Definition btContactProcessingStructs.h:88
GIM_CONTACT::GIM_CONTACT
GIM_CONTACT(const btVector3 &point, const btVector3 &normal, btScalar depth, int feature1, int feature2)
Definition btContactProcessingStructs.h:62
GIM_CONTACT::calc_key_contact
unsigned int calc_key_contact() const
Calcs key for coord classification.
Definition btContactProcessingStructs.h:72
GIM_CONTACT::m_depth
btScalar m_depth
Definition btContactProcessingStructs.h:45
GIM_CONTACT::m_normal
btVector3 m_normal
Definition btContactProcessingStructs.h:44
GIM_CONTACT::GIM_CONTACT
GIM_CONTACT(const GIM_CONTACT &contact)
Definition btContactProcessingStructs.h:54
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:82
btVector3::length2
btScalar length2() const
Return the length of the vector squared.
Definition btVector3.h:251
CONTACT_DIFF_EPSILON
#define CONTACT_DIFF_EPSILON
Definition gim_contact.h:47