Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/menuanimations/src/external/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp @ 7582

Last change on this file since 7582 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
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
16
17#include "btSphereTriangleCollisionAlgorithm.h"
18#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
19#include "BulletCollision/CollisionShapes/btSphereShape.h"
20#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
21#include "SphereTriangleDetector.h"
22
23
24btSphereTriangleCollisionAlgorithm::btSphereTriangleCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1,bool swapped)
25: btActivatingCollisionAlgorithm(ci,col0,col1),
26m_ownManifold(false),
27m_manifoldPtr(mf),
28m_swapped(swapped)
29{
30        if (!m_manifoldPtr)
31        {
32                m_manifoldPtr = m_dispatcher->getNewManifold(col0,col1);
33                m_ownManifold = true;
34        }
35}
36
37btSphereTriangleCollisionAlgorithm::~btSphereTriangleCollisionAlgorithm()
38{
39        if (m_ownManifold)
40        {
41                if (m_manifoldPtr)
42                        m_dispatcher->releaseManifold(m_manifoldPtr);
43        }
44}
45
46void btSphereTriangleCollisionAlgorithm::processCollision (btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
47{
48        if (!m_manifoldPtr)
49                return;
50
51        btCollisionObject* sphereObj = m_swapped? col1 : col0;
52        btCollisionObject* triObj = m_swapped? col0 : col1;
53
54        btSphereShape* sphere = (btSphereShape*)sphereObj->getCollisionShape();
55        btTriangleShape* triangle = (btTriangleShape*)triObj->getCollisionShape();
56       
57        /// report a contact. internally this will be kept persistent, and contact reduction is done
58        resultOut->setPersistentManifold(m_manifoldPtr);
59        SphereTriangleDetector detector(sphere,triangle, m_manifoldPtr->getContactBreakingThreshold());
60       
61        btDiscreteCollisionDetectorInterface::ClosestPointInput input;
62        input.m_maximumDistanceSquared = btScalar(1e30);///@todo: tighter bounds
63        input.m_transformA = sphereObj->getWorldTransform();
64        input.m_transformB = triObj->getWorldTransform();
65
66        bool swapResults = m_swapped;
67
68        detector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw,swapResults);
69
70        if (m_ownManifold)
71                resultOut->refreshContactPoints();
72       
73}
74
75btScalar btSphereTriangleCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
76{
77        (void)resultOut;
78        (void)dispatchInfo;
79        (void)col0;
80        (void)col1;
81
82        //not yet
83        return btScalar(1.);
84}
Note: See TracBrowser for help on using the repository browser.