Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
commitbdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch)
treed00eb50b749cb001e2b08272c91791e66740b05d /extern/bullet2/src/BulletCollision/Gimpact/gim_contact.h
parent78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff)
parent7e4db234cee71ead34ee81a12e27da4bd548eb4b (diff)
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416 Issues: * GHOST/X11 had conflicting changes. Some code was added in 2.5, which was later added in trunk also, but reverted partially, specifically revision 16683. I have left out this reversion in the 2.5 branch since I think it is needed there. http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683 * Scons had various conflicting changes, I decided to go with trunk version for everything except priorities and some library renaming. * In creator.c, there were various fixes and fixes for fixes related to the -w -W and -p options. In 2.5 -w and -W is not coded yet, and -p is done differently. Since this is changed so much, and I don't think those fixes would be needed in 2.5, I've left them out. * Also in creator.c: there was code for a python bugfix where the screen was not initialized when running with -P. The code that initializes the screen there I had to disable, that can't work in 2.5 anymore but left it commented as a reminder. Further I had to disable some new function calls. using src/ and python/, as was done already in this branch, disabled function calls: * bpath.c: error reporting * BME_conversions.c: editmesh conversion functions. * SHD_dynamic: disabled almost completely, there is no python/. * KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled. * text.c: clipboard copy call. * object.c: OB_SUPPORT_MATERIAL. * DerivedMesh.c and subsurf_ccg, stipple_quarttone. Still to be done: * Go over files and functions that were moved to a different location but could still use changes that were done in trunk.
Diffstat (limited to 'extern/bullet2/src/BulletCollision/Gimpact/gim_contact.h')
-rw-r--r--extern/bullet2/src/BulletCollision/Gimpact/gim_contact.h172
1 files changed, 172 insertions, 0 deletions
diff --git a/extern/bullet2/src/BulletCollision/Gimpact/gim_contact.h b/extern/bullet2/src/BulletCollision/Gimpact/gim_contact.h
new file mode 100644
index 00000000000..62df51b782f
--- /dev/null
+++ b/extern/bullet2/src/BulletCollision/Gimpact/gim_contact.h
@@ -0,0 +1,172 @@
+#ifndef GIM_CONTACT_H_INCLUDED
+#define GIM_CONTACT_H_INCLUDED
+
+/*! \file gim_contact.h
+\author Francisco Len Nßjera
+*/
+/*
+-----------------------------------------------------------------------------
+This source file is part of GIMPACT Library.
+
+For the latest info, see http://gimpact.sourceforge.net/
+
+Copyright (c) 2006 Francisco Leon Najera. C.C. 80087371.
+email: projectileman@yahoo.com
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of EITHER:
+ (1) The GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 2.1 of the License, or (at
+ your option) any later version. The text of the GNU Lesser
+ General Public License is included with this library in the
+ file GIMPACT-LICENSE-LGPL.TXT.
+ (2) The BSD-style license that is included with this library in
+ the file GIMPACT-LICENSE-BSD.TXT.
+ (3) The zlib/libpng license that is included with this library in
+ the file GIMPACT-LICENSE-ZLIB.TXT.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
+ GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
+
+-----------------------------------------------------------------------------
+*/
+#include "gim_geometry.h"
+#include "gim_radixsort.h"
+#include "gim_array.h"
+
+/*! \defgroup CONTACTS
+\brief
+Functions for managing and sorting contacts resulting from a collision query.
+<ul>
+<li> Contact lists must be create by calling \ref GIM_CREATE_CONTACT_LIST
+<li> After querys, contact lists must be destroy by calling \ref GIM_DYNARRAY_DESTROY
+<li> Contacts can be merge for avoid duplicate results by calling \ref gim_merge_contacts
+</ul>
+
+*/
+//! @{
+
+/**
+Configuration var for applying interpolation of contact normals
+*/
+#define NORMAL_CONTACT_AVERAGE 1
+#define CONTACT_DIFF_EPSILON 0.00001f
+
+/// Structure for collision results
+class GIM_CONTACT
+{
+public:
+ btVector3 m_point;
+ btVector3 m_normal;
+ GREAL m_depth;//Positive value indicates interpenetration
+ GREAL m_distance;//Padding not for use
+ GUINT m_feature1;//Face number
+ GUINT m_feature2;//Face number
+public:
+ GIM_CONTACT()
+ {
+ }
+
+ GIM_CONTACT(const GIM_CONTACT & contact):
+ m_point(contact.m_point),
+ m_normal(contact.m_normal),
+ m_depth(contact.m_depth),
+ m_feature1(contact.m_feature1),
+ m_feature2(contact.m_feature2)
+ {
+ m_point = contact.m_point;
+ m_normal = contact.m_normal;
+ m_depth = contact.m_depth;
+ m_feature1 = contact.m_feature1;
+ m_feature2 = contact.m_feature2;
+ }
+
+ GIM_CONTACT(const btVector3 &point,const btVector3 & normal,
+ GREAL depth, GUINT feature1, GUINT feature2):
+ m_point(point),
+ m_normal(normal),
+ m_depth(depth),
+ m_feature1(feature1),
+ m_feature2(feature2)
+ {
+ }
+
+ //! Calcs key for coord classification
+ SIMD_FORCE_INLINE GUINT calc_key_contact() const
+ {
+ GINT _coords[] = {
+ (GINT)(m_point[0]*1000.0f+1.0f),
+ (GINT)(m_point[1]*1333.0f),
+ (GINT)(m_point[2]*2133.0f+3.0f)};
+ GUINT _hash=0;
+ GUINT *_uitmp = (GUINT *)(&_coords[0]);
+ _hash = *_uitmp;
+ _uitmp++;
+ _hash += (*_uitmp)<<4;
+ _uitmp++;
+ _hash += (*_uitmp)<<8;
+ return _hash;
+ }
+
+ SIMD_FORCE_INLINE void interpolate_normals( btVector3 * normals,GUINT normal_count)
+ {
+ btVector3 vec_sum(m_normal);
+ for(GUINT i=0;i<normal_count;i++)
+ {
+ vec_sum += normals[i];
+ }
+
+ GREAL vec_sum_len = vec_sum.length2();
+ if(vec_sum_len <CONTACT_DIFF_EPSILON) return;
+
+ GIM_INV_SQRT(vec_sum_len,vec_sum_len); // 1/sqrt(vec_sum_len)
+
+ m_normal = vec_sum*vec_sum_len;
+ }
+
+};
+
+
+class gim_contact_array:public gim_array<GIM_CONTACT>
+{
+public:
+ gim_contact_array():gim_array<GIM_CONTACT>(64)
+ {
+ }
+
+ SIMD_FORCE_INLINE void push_contact(const btVector3 &point,const btVector3 & normal,
+ GREAL depth, GUINT feature1, GUINT feature2)
+ {
+ push_back_mem();
+ GIM_CONTACT & newele = back();
+ newele.m_point = point;
+ newele.m_normal = normal;
+ newele.m_depth = depth;
+ newele.m_feature1 = feature1;
+ newele.m_feature2 = feature2;
+ }
+
+ SIMD_FORCE_INLINE void push_triangle_contacts(
+ const GIM_TRIANGLE_CONTACT_DATA & tricontact,
+ GUINT feature1,GUINT feature2)
+ {
+ for(GUINT i = 0;i<tricontact.m_point_count ;i++ )
+ {
+ push_back_mem();
+ GIM_CONTACT & newele = back();
+ newele.m_point = tricontact.m_points[i];
+ newele.m_normal = tricontact.m_separating_normal;
+ newele.m_depth = tricontact.m_penetration_depth;
+ newele.m_feature1 = feature1;
+ newele.m_feature2 = feature2;
+ }
+ }
+
+ void merge_contacts(const gim_contact_array & contacts, bool normal_contact_average = true);
+ void merge_contacts_unique(const gim_contact_array & contacts);
+};
+
+//! @}
+#endif // GIM_CONTACT_H_INCLUDED