2015-09-10 05:30:50 +00:00
|
|
|
/********************************************************************************
|
|
|
|
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
|
2016-04-11 18:15:20 +00:00
|
|
|
* Copyright (c) 2010-2016 Daniel Chappuis *
|
2015-09-10 05:30:50 +00:00
|
|
|
*********************************************************************************
|
|
|
|
* *
|
|
|
|
* This software is provided 'as-is', without any express or implied warranty. *
|
|
|
|
* In no event will the authors be held liable for any damages arising from the *
|
|
|
|
* use of this software. *
|
|
|
|
* *
|
|
|
|
* Permission is granted to anyone to use this software for any purpose, *
|
|
|
|
* including commercial applications, and to alter it and redistribute it *
|
|
|
|
* freely, subject to the following restrictions: *
|
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
* *
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and must not be *
|
|
|
|
* misrepresented as being the original software. *
|
|
|
|
* *
|
|
|
|
* 3. This notice may not be removed or altered from any source distribution. *
|
|
|
|
* *
|
|
|
|
********************************************************************************/
|
|
|
|
|
2017-01-08 18:56:59 +00:00
|
|
|
#ifndef REACTPHYSICS3D_NARROW_PHASE_INFO_H
|
|
|
|
#define REACTPHYSICS3D_NARROW_PHASE_INFO_H
|
2015-09-10 05:30:50 +00:00
|
|
|
|
|
|
|
// Libraries
|
|
|
|
#include "shapes/CollisionShape.h"
|
2017-07-30 20:14:46 +00:00
|
|
|
#include "collision/ContactManifoldInfo.h"
|
2015-09-10 05:30:50 +00:00
|
|
|
|
|
|
|
/// Namespace ReactPhysics3D
|
|
|
|
namespace reactphysics3d {
|
|
|
|
|
2015-09-13 11:02:05 +00:00
|
|
|
class OverlappingPair;
|
|
|
|
|
2017-01-08 18:56:59 +00:00
|
|
|
// Class NarrowPhaseInfo
|
2015-09-10 05:30:50 +00:00
|
|
|
/**
|
|
|
|
* This structure regroups different things about a collision shape. This is
|
|
|
|
* used to pass information about a collision shape to a collision algorithm.
|
|
|
|
*/
|
2017-01-08 18:56:59 +00:00
|
|
|
struct NarrowPhaseInfo {
|
2015-09-10 05:30:50 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2015-09-13 11:02:05 +00:00
|
|
|
/// Broadphase overlapping pair
|
|
|
|
OverlappingPair* overlappingPair;
|
2015-09-10 05:30:50 +00:00
|
|
|
|
2017-01-08 18:56:59 +00:00
|
|
|
/// Pointer to the first collision shape to test collision with
|
|
|
|
const CollisionShape* collisionShape1;
|
2015-09-10 05:30:50 +00:00
|
|
|
|
2017-01-08 18:56:59 +00:00
|
|
|
/// Pointer to the second collision shape to test collision with
|
|
|
|
const CollisionShape* collisionShape2;
|
2015-09-10 05:30:50 +00:00
|
|
|
|
2017-01-08 18:56:59 +00:00
|
|
|
/// Transform that maps from collision shape 1 local-space to world-space
|
|
|
|
Transform shape1ToWorldTransform;
|
|
|
|
|
|
|
|
/// Transform that maps from collision shape 2 local-space to world-space
|
|
|
|
Transform shape2ToWorldTransform;
|
|
|
|
|
2017-07-30 20:14:46 +00:00
|
|
|
/// Linked-list of contact points created during the narrow-phase
|
|
|
|
ContactPointInfo* contactPoints;
|
|
|
|
|
2017-01-08 18:56:59 +00:00
|
|
|
/// Cached collision data of the proxy shape
|
|
|
|
// TODO : Check if we can use separating axis in OverlappingPair instead of cachedCollisionData1 and cachedCollisionData2
|
|
|
|
void** cachedCollisionData1;
|
2015-09-10 05:30:50 +00:00
|
|
|
|
|
|
|
/// Cached collision data of the proxy shape
|
2017-01-08 18:56:59 +00:00
|
|
|
// TODO : Check if we can use separating axis in OverlappingPair instead of cachedCollisionData1 and cachedCollisionData2
|
|
|
|
void** cachedCollisionData2;
|
|
|
|
|
|
|
|
/// Pointer to the next element in the linked list
|
|
|
|
NarrowPhaseInfo* next;
|
2015-09-10 05:30:50 +00:00
|
|
|
|
2015-09-13 11:02:05 +00:00
|
|
|
/// Constructor
|
2017-01-08 18:56:59 +00:00
|
|
|
NarrowPhaseInfo(OverlappingPair* pair, const CollisionShape* shape1,
|
|
|
|
const CollisionShape* shape2, const Transform& shape1Transform,
|
2017-07-30 20:14:46 +00:00
|
|
|
const Transform& shape2Transform, void** cachedData1, void** cachedData2);
|
|
|
|
|
|
|
|
/// Destructor
|
|
|
|
~NarrowPhaseInfo();
|
|
|
|
|
|
|
|
/// Add a new contact point
|
|
|
|
void addContactPoint(const Vector3& contactNormal, decimal penDepth,
|
|
|
|
const Vector3& localPt1, const Vector3& localPt2);
|
|
|
|
|
|
|
|
/// Create a new potential contact manifold into the overlapping pair using current contact points
|
|
|
|
void addContactPointsAsPotentialContactManifold();
|
2015-09-13 11:02:05 +00:00
|
|
|
|
2017-07-30 20:14:46 +00:00
|
|
|
/// Reset the remaining contact points
|
|
|
|
void resetContactPoints();
|
2015-09-10 05:30:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|