Compare commits
3 Commits
42f5d84744
...
08acb860c1
Author | SHA1 | Date | |
---|---|---|---|
08acb860c1 | |||
beba85290c | |||
640d3fdcbe |
@ -23,6 +23,13 @@ CollisionBody::CollisionBody(const etk::Transform3D& _transform, CollisionWorld&
|
|||||||
m_contactManifoldsList(null),
|
m_contactManifoldsList(null),
|
||||||
m_world(_world) {
|
m_world(_world) {
|
||||||
|
|
||||||
|
EPHY_DEBUG(" set transform: " << _transform);
|
||||||
|
if (isnan(_transform.getPosition().x()) == true) { // check NAN
|
||||||
|
EPHY_CRITICAL(" set transform: " << _transform);
|
||||||
|
}
|
||||||
|
if (isinf(_transform.getOrientation().z()) == true) {
|
||||||
|
EPHY_CRITICAL(" set transform: " << _transform);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CollisionBody::~CollisionBody() {
|
CollisionBody::~CollisionBody() {
|
||||||
@ -40,6 +47,17 @@ inline void CollisionBody::setType(BodyType _type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CollisionBody::setTransform(const etk::Transform3D& _transform) {
|
||||||
|
EPHY_DEBUG(" set transform: " << m_transform << " ==> " << _transform);
|
||||||
|
if (isnan(_transform.getPosition().x()) == true) { // check NAN
|
||||||
|
EPHY_CRITICAL(" set transform: " << m_transform << " ==> " << _transform);
|
||||||
|
}
|
||||||
|
if (isinf(_transform.getOrientation().z()) == true) {
|
||||||
|
EPHY_CRITICAL(" set transform: " << m_transform << " ==> " << _transform);
|
||||||
|
}
|
||||||
|
m_transform = _transform;
|
||||||
|
updateBroadPhaseState();
|
||||||
|
}
|
||||||
|
|
||||||
ProxyShape* CollisionBody::addCollisionShape(CollisionShape* _collisionShape,
|
ProxyShape* CollisionBody::addCollisionShape(CollisionShape* _collisionShape,
|
||||||
const etk::Transform3D& _transform) {
|
const etk::Transform3D& _transform) {
|
||||||
|
@ -106,10 +106,7 @@ namespace ephysics {
|
|||||||
* @brief Set the current position and orientation
|
* @brief Set the current position and orientation
|
||||||
* @param transform The transformation of the body that transforms the local-space of the body int32_to world-space
|
* @param transform The transformation of the body that transforms the local-space of the body int32_to world-space
|
||||||
*/
|
*/
|
||||||
void setTransform(const etk::Transform3D& _transform) {
|
virtual void setTransform(const etk::Transform3D& _transform);
|
||||||
m_transform = _transform;
|
|
||||||
updateBroadPhaseState();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @brief Add a collision shape to the body. Note that you can share a collision shape between several bodies using the same collision shape instance to
|
* @brief Add a collision shape to the body. Note that you can share a collision shape between several bodies using the same collision shape instance to
|
||||||
* when you add the shape to the different bodies. Do not forget to delete the collision shape you have created at the end of your program.
|
* when you add the shape to the different bodies. Do not forget to delete the collision shape you have created at the end of your program.
|
||||||
|
@ -182,8 +182,25 @@ void RigidBody::setIsSleeping(bool _isSleeping) {
|
|||||||
Body::setIsSleeping(_isSleeping);
|
Body::setIsSleeping(_isSleeping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RigidBody::updateTransformWithCenterOfMass() {
|
||||||
|
// Translate the body according to the translation of the center of mass position
|
||||||
|
m_transform.setPosition(m_centerOfMassWorld - m_transform.getOrientation() * m_centerOfMassLocal);
|
||||||
|
if (isnan(m_transform.getPosition().x()) == true) {
|
||||||
|
EPHY_CRITICAL("updateTransformWithCenterOfMass: " << m_transform);
|
||||||
|
}
|
||||||
|
if (isinf(m_transform.getOrientation().z()) == true) {
|
||||||
|
EPHY_CRITICAL(" set transform: " << m_transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RigidBody::setTransform(const etk::Transform3D& _transform) {
|
void RigidBody::setTransform(const etk::Transform3D& _transform) {
|
||||||
|
EPHY_DEBUG(" set transform: " << m_transform << " ==> " << _transform);
|
||||||
|
if (isnan(_transform.getPosition().x()) == true) {
|
||||||
|
EPHY_CRITICAL(" set transform: " << m_transform << " ==> " << _transform);
|
||||||
|
}
|
||||||
|
if (isinf(_transform.getOrientation().z()) == true) {
|
||||||
|
EPHY_CRITICAL(" set transform: " << m_transform << " ==> " << _transform);
|
||||||
|
}
|
||||||
m_transform = _transform;
|
m_transform = _transform;
|
||||||
const vec3 oldCenterOfMass = m_centerOfMassWorld;
|
const vec3 oldCenterOfMass = m_centerOfMassWorld;
|
||||||
// Compute the new center of mass in world-space coordinates
|
// Compute the new center of mass in world-space coordinates
|
||||||
@ -258,6 +275,7 @@ void RigidBody::updateBroadPhaseState() const {
|
|||||||
// Recompute the world-space AABB of the collision shape
|
// Recompute the world-space AABB of the collision shape
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
EPHY_VERBOSE(" : " << aabb.getMin() << " " << aabb.getMax());
|
EPHY_VERBOSE(" : " << aabb.getMin() << " " << aabb.getMax());
|
||||||
|
EPHY_VERBOSE(" m_transform: " << m_transform);
|
||||||
shape->getCollisionShape()->computeAABB(aabb, m_transform *shape->getLocalToBodyTransform());
|
shape->getCollisionShape()->computeAABB(aabb, m_transform *shape->getLocalToBodyTransform());
|
||||||
EPHY_VERBOSE(" : " << aabb.getMin() << " " << aabb.getMax());
|
EPHY_VERBOSE(" : " << aabb.getMin() << " " << aabb.getMax());
|
||||||
// Update the broad-phase state for the proxy collision shape
|
// Update the broad-phase state for the proxy collision shape
|
||||||
|
@ -53,10 +53,7 @@ namespace ephysics {
|
|||||||
/**
|
/**
|
||||||
* @brief Update the transform of the body after a change of the center of mass
|
* @brief Update the transform of the body after a change of the center of mass
|
||||||
*/
|
*/
|
||||||
void updateTransformWithCenterOfMass() {
|
void updateTransformWithCenterOfMass();
|
||||||
// Translate the body according to the translation of the center of mass position
|
|
||||||
m_transform.setPosition(m_centerOfMassWorld - m_transform.getOrientation() * m_centerOfMassLocal);
|
|
||||||
}
|
|
||||||
void updateBroadPhaseState() const override;
|
void updateBroadPhaseState() const override;
|
||||||
public :
|
public :
|
||||||
/**
|
/**
|
||||||
@ -75,7 +72,7 @@ namespace ephysics {
|
|||||||
* @brief Set the current position and orientation
|
* @brief Set the current position and orientation
|
||||||
* @param[in] _transform The transformation of the body that transforms the local-space of the body int32_to world-space
|
* @param[in] _transform The transformation of the body that transforms the local-space of the body int32_to world-space
|
||||||
*/
|
*/
|
||||||
virtual void setTransform(const etk::Transform3D& _transform);
|
void setTransform(const etk::Transform3D& _transform) override;
|
||||||
/**
|
/**
|
||||||
* @brief Get the mass of the body
|
* @brief Get the mass of the body
|
||||||
* @return The mass (in kilograms) of the body
|
* @return The mass (in kilograms) of the body
|
||||||
|
@ -107,6 +107,16 @@ void BroadPhaseAlgorithm::updateProxyCollisionShape(ProxyShape* _proxyShape,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool sortFunction(const etk::Pair<int32_t,int32_t>& _pair1, const etk::Pair<int32_t,int32_t>& _pair2) {
|
||||||
|
if (_pair1.first < _pair2.first) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (_pair1.first == _pair2.first) {
|
||||||
|
return _pair1.second < _pair2.second;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void BroadPhaseAlgorithm::computeOverlappingPairs() {
|
void BroadPhaseAlgorithm::computeOverlappingPairs() {
|
||||||
m_potentialPairs.clear();
|
m_potentialPairs.clear();
|
||||||
// For all collision shapes that have moved (or have been created) during the
|
// For all collision shapes that have moved (or have been created) during the
|
||||||
@ -133,17 +143,7 @@ void BroadPhaseAlgorithm::computeOverlappingPairs() {
|
|||||||
// Reset the array of collision shapes that have move (or have been created) during the last simulation step
|
// Reset the array of collision shapes that have move (or have been created) during the last simulation step
|
||||||
m_movedShapes.clear();
|
m_movedShapes.clear();
|
||||||
// Sort the array of potential overlapping pairs in order to remove duplicate pairs
|
// Sort the array of potential overlapping pairs in order to remove duplicate pairs
|
||||||
m_potentialPairs.sort(0,
|
etk::algorithm::quickSort(m_potentialPairs, sortFunction);
|
||||||
m_potentialPairs.size()-1,
|
|
||||||
[](const etk::Pair<int32_t,int32_t>& _pair1, const etk::Pair<int32_t,int32_t>& _pair2) {
|
|
||||||
if (_pair1.first < _pair2.first) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (_pair1.first == _pair2.first) {
|
|
||||||
return _pair1.second < _pair2.second;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
// Check all the potential overlapping pairs avoiding duplicates to report unique
|
// Check all the potential overlapping pairs avoiding duplicates to report unique
|
||||||
// overlapping pairs
|
// overlapping pairs
|
||||||
uint32_t iii=0;
|
uint32_t iii=0;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <ephysics/collision/narrowphase/ConcaveVsConvexAlgorithm.hpp>
|
#include <ephysics/collision/narrowphase/ConcaveVsConvexAlgorithm.hpp>
|
||||||
#include <ephysics/collision/CollisionDetection.hpp>
|
#include <ephysics/collision/CollisionDetection.hpp>
|
||||||
#include <ephysics/engine/CollisionWorld.hpp>
|
#include <ephysics/engine/CollisionWorld.hpp>
|
||||||
|
#include <etk/algorithm.hpp>
|
||||||
|
|
||||||
using namespace ephysics;
|
using namespace ephysics;
|
||||||
|
|
||||||
@ -91,17 +92,17 @@ void ConvexVsTriangleCallback::testTriangle(const vec3* _trianglePoints) {
|
|||||||
algo->testCollision(shapeConvexInfo, shapeConcaveInfo, m_narrowPhaseCallback);
|
algo->testCollision(shapeConvexInfo, shapeConcaveInfo, m_narrowPhaseCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool sortFunction(const SmoothMeshContactInfo& _contact1, const SmoothMeshContactInfo& _contact2) {
|
||||||
|
return _contact1.contactInfo.penetrationDepth <= _contact2.contactInfo.penetrationDepth;
|
||||||
|
}
|
||||||
|
|
||||||
void ConcaveVsConvexAlgorithm::processSmoothMeshCollision(OverlappingPair* _overlappingPair,
|
void ConcaveVsConvexAlgorithm::processSmoothMeshCollision(OverlappingPair* _overlappingPair,
|
||||||
etk::Vector<SmoothMeshContactInfo> _contactPoints,
|
etk::Vector<SmoothMeshContactInfo> _contactPoints,
|
||||||
NarrowPhaseCallback* _callback) {
|
NarrowPhaseCallback* _callback) {
|
||||||
// Set with the triangle vertices already processed to void further contacts with same triangle
|
// Set with the triangle vertices already processed to void further contacts with same triangle
|
||||||
etk::Vector<etk::Pair<int32_t, vec3>> processTriangleVertices;
|
etk::Vector<etk::Pair<int32_t, vec3>> processTriangleVertices;
|
||||||
// Sort the list of narrow-phase contacts according to their penetration depth
|
// Sort the list of narrow-phase contacts according to their penetration depth
|
||||||
_contactPoints.sort(0,
|
etk::algorithm::quickSort(_contactPoints, sortFunction);
|
||||||
_contactPoints.size()-1,
|
|
||||||
[](const SmoothMeshContactInfo& _contact1, const SmoothMeshContactInfo& _contact2) {
|
|
||||||
return _contact1.contactInfo.penetrationDepth < _contact2.contactInfo.penetrationDepth;
|
|
||||||
});
|
|
||||||
// For each contact point (from smaller penetration depth to larger)
|
// For each contact point (from smaller penetration depth to larger)
|
||||||
etk::Vector<SmoothMeshContactInfo>::Iterator it;
|
etk::Vector<SmoothMeshContactInfo>::Iterator it;
|
||||||
for (it = _contactPoints.begin(); it != _contactPoints.end(); ++it) {
|
for (it = _contactPoints.begin(); it != _contactPoints.end(); ++it) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutin.debug as debug
|
import realog.debug as debug
|
||||||
import lutin.tools as tools
|
import lutin.tools as tools
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutin.debug as debug
|
import realog.debug as debug
|
||||||
import lutin.tools as tools
|
import lutin.tools as tools
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user