Blender V4.3
btBoxBoxCollisionAlgorithm.cpp
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
20#include "btBoxBoxDetector.h"
22#define USE_PERSISTENT_CONTACTS 1
23
25 : btActivatingCollisionAlgorithm(ci, body0Wrap, body1Wrap),
26 m_ownManifold(false),
28{
29 if (!m_manifoldPtr && m_dispatcher->needsCollision(body0Wrap->getCollisionObject(), body1Wrap->getCollisionObject()))
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 btBoxShape* box0 = (btBoxShape*)body0Wrap->getCollisionShape();
51 const btBoxShape* box1 = (btBoxShape*)body1Wrap->getCollisionShape();
52
54 resultOut->setPersistentManifold(m_manifoldPtr);
55#ifndef USE_PERSISTENT_CONTACTS
56 m_manifoldPtr->clearManifold();
57#endif //USE_PERSISTENT_CONTACTS
58
61 input.m_transformA = body0Wrap->getWorldTransform();
62 input.m_transformB = body1Wrap->getWorldTransform();
63
64 btBoxBoxDetector detector(box0, box1);
65 detector.getClosestPoints(input, *resultOut, dispatchInfo.m_debugDraw);
66
67#ifdef USE_PERSISTENT_CONTACTS
68 // refreshContactPoints is only necessary when using persistent contact points. otherwise all points are newly added
69 if (m_ownManifold)
70 {
71 resultOut->refreshContactPoints();
72 }
73#endif //USE_PERSISTENT_CONTACTS
74}
75
76btScalar btBoxBoxCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* /*body0*/, btCollisionObject* /*body1*/, const btDispatcherInfo& /*dispatchInfo*/, btManifoldResult* /*resultOut*/)
77{
78 //not yet
79 return 1.f;
80}
btBoxShape(const btVector3 &boxHalfExtents)
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
This class is not enabled yet (work-in-progress) to more aggressively activate objects.
virtual btScalar calculateTimeOfImpact(btCollisionObject *body0, btCollisionObject *body1, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
btBoxBoxCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo &ci)
virtual void processCollision(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, const btDispatcherInfo &dispatchInfo, btManifoldResult *resultOut)
virtual void releaseManifold(btPersistentManifold *manifold)=0
virtual bool needsCollision(const btCollisionObject *body0, const btCollisionObject *body1)=0
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)=0
btManifoldResult is a helper class to manage contact results.
void setPersistentManifold(btPersistentManifold *manifoldPtr)
SIMD_FORCE_INLINE void refreshContactPoints()
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