Blender  V3.3
btSphereTriangleCollisionAlgorithm.cpp
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15 
20 #include "SphereTriangleDetector.h"
22 
24  : btActivatingCollisionAlgorithm(ci, body0Wrap, body1Wrap),
25  m_ownManifold(false),
26  m_manifoldPtr(mf),
27  m_swapped(swapped)
28 {
29  if (!m_manifoldPtr)
30  {
31  m_manifoldPtr = m_dispatcher->getNewManifold(body0Wrap->getCollisionObject(), body1Wrap->getCollisionObject());
32  m_ownManifold = true;
33  }
34 }
35 
37 {
38  if (m_ownManifold)
39  {
40  if (m_manifoldPtr)
41  m_dispatcher->releaseManifold(m_manifoldPtr);
42  }
43 }
44 
46 {
47  if (!m_manifoldPtr)
48  return;
49 
50  const btCollisionObjectWrapper* sphereObjWrap = m_swapped ? col1Wrap : col0Wrap;
51  const btCollisionObjectWrapper* triObjWrap = m_swapped ? col0Wrap : col1Wrap;
52 
53  btSphereShape* sphere = (btSphereShape*)sphereObjWrap->getCollisionShape();
54  btTriangleShape* triangle = (btTriangleShape*)triObjWrap->getCollisionShape();
55 
57  resultOut->setPersistentManifold(m_manifoldPtr);
58  SphereTriangleDetector detector(sphere, triangle, m_manifoldPtr->getContactBreakingThreshold() + resultOut->m_closestPointDistanceThreshold);
59 
61  input.m_maximumDistanceSquared = btScalar(BT_LARGE_FLOAT);
62  input.m_transformA = sphereObjWrap->getWorldTransform();
63  input.m_transformB = triObjWrap->getWorldTransform();
64 
65  bool swapResults = m_swapped;
66 
67  detector.getClosestPoints(input, *resultOut, dispatchInfo.m_debugDraw, swapResults);
68 
69  if (m_ownManifold)
70  resultOut->refreshContactPoints();
71 }
72 
74 {
75  (void)resultOut;
76  (void)dispatchInfo;
77  (void)col0;
78  (void)col1;
79 
80  //not yet
81  return btScalar(1.);
82 }
btCollisionObject
btPersistentManifold * m_manifoldPtr
btPersistentManifold()
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:314
#define BT_LARGE_FLOAT
Definition: btScalar.h:316
btSphereShape(btScalar radius)
Definition: btSphereShape.h:29
btTriangleShape()
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
virtual void releaseManifold(btPersistentManifold *manifold)=0
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)=0
btManifoldResult is a helper class to manage contact results.
void setPersistentManifold(btPersistentManifold *manifoldPtr)
btScalar m_closestPointDistanceThreshold
SIMD_FORCE_INLINE void refreshContactPoints()
btSphereTriangleCollisionAlgorithm(btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool swapped)
virtual btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
SyclQueue void void size_t num_bytes void
ccl_global KernelShaderEvalInput * input
sphere-triangle to match the btDiscreteCollisionDetectorInterface
virtual void getClosestPoints(const ClosestPointInput &input, Result &output, class btIDebugDraw *debugDraw, bool swapResults=false)
SIMD_FORCE_INLINE const btCollisionShape * getCollisionShape() const
SIMD_FORCE_INLINE const btTransform & getWorldTransform() const
SIMD_FORCE_INLINE const btCollisionObject * getCollisionObject() const
class btIDebugDraw * m_debugDraw
Definition: btDispatcher.h:58