[DEV] update etk null
This commit is contained in:
parent
59280cc06c
commit
42f5d84744
@ -18,6 +18,6 @@ ephysics::Body::Body(bodyindex _id):
|
|||||||
m_isActive(true),
|
m_isActive(true),
|
||||||
m_isSleeping(false),
|
m_isSleeping(false),
|
||||||
m_sleepTime(0),
|
m_sleepTime(0),
|
||||||
m_userData(nullptr) {
|
m_userData(null) {
|
||||||
|
|
||||||
}
|
}
|
@ -18,15 +18,15 @@ CollisionBody::CollisionBody(const etk::Transform3D& _transform, CollisionWorld&
|
|||||||
Body(_id),
|
Body(_id),
|
||||||
m_type(DYNAMIC),
|
m_type(DYNAMIC),
|
||||||
m_transform(_transform),
|
m_transform(_transform),
|
||||||
m_proxyCollisionShapes(nullptr),
|
m_proxyCollisionShapes(null),
|
||||||
m_numberCollisionShapes(0),
|
m_numberCollisionShapes(0),
|
||||||
m_contactManifoldsList(nullptr),
|
m_contactManifoldsList(null),
|
||||||
m_world(_world) {
|
m_world(_world) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CollisionBody::~CollisionBody() {
|
CollisionBody::~CollisionBody() {
|
||||||
assert(m_contactManifoldsList == nullptr);
|
assert(m_contactManifoldsList == null);
|
||||||
|
|
||||||
// Remove all the proxy collision shapes of the body
|
// Remove all the proxy collision shapes of the body
|
||||||
removeAllCollisionShapes();
|
removeAllCollisionShapes();
|
||||||
@ -46,7 +46,7 @@ ProxyShape* CollisionBody::addCollisionShape(CollisionShape* _collisionShape,
|
|||||||
// Create a proxy collision shape to attach the collision shape to the body
|
// Create a proxy collision shape to attach the collision shape to the body
|
||||||
ProxyShape* proxyShape = ETK_NEW(ProxyShape, this, _collisionShape,_transform, float(1));
|
ProxyShape* proxyShape = ETK_NEW(ProxyShape, this, _collisionShape,_transform, float(1));
|
||||||
// Add it to the list of proxy collision shapes of the body
|
// Add it to the list of proxy collision shapes of the body
|
||||||
if (m_proxyCollisionShapes == nullptr) {
|
if (m_proxyCollisionShapes == null) {
|
||||||
m_proxyCollisionShapes = proxyShape;
|
m_proxyCollisionShapes = proxyShape;
|
||||||
} else {
|
} else {
|
||||||
proxyShape->m_next = m_proxyCollisionShapes;
|
proxyShape->m_next = m_proxyCollisionShapes;
|
||||||
@ -68,12 +68,12 @@ void CollisionBody::removeCollisionShape(const ProxyShape* _proxyShape) {
|
|||||||
m_world.m_collisionDetection.removeProxyCollisionShape(current);
|
m_world.m_collisionDetection.removeProxyCollisionShape(current);
|
||||||
}
|
}
|
||||||
ETK_DELETE(ProxyShape, current);
|
ETK_DELETE(ProxyShape, current);
|
||||||
current = nullptr;
|
current = null;
|
||||||
m_numberCollisionShapes--;
|
m_numberCollisionShapes--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Look for the proxy shape that contains the collision shape in parameter
|
// Look for the proxy shape that contains the collision shape in parameter
|
||||||
while(current->m_next != nullptr) {
|
while(current->m_next != null) {
|
||||||
// If we have found the collision shape to remove
|
// If we have found the collision shape to remove
|
||||||
if (current->m_next == _proxyShape) {
|
if (current->m_next == _proxyShape) {
|
||||||
// Remove the proxy collision shape
|
// Remove the proxy collision shape
|
||||||
@ -83,7 +83,7 @@ void CollisionBody::removeCollisionShape(const ProxyShape* _proxyShape) {
|
|||||||
m_world.m_collisionDetection.removeProxyCollisionShape(elementToRemove);
|
m_world.m_collisionDetection.removeProxyCollisionShape(elementToRemove);
|
||||||
}
|
}
|
||||||
ETK_DELETE(ProxyShape, elementToRemove);
|
ETK_DELETE(ProxyShape, elementToRemove);
|
||||||
elementToRemove = nullptr;
|
elementToRemove = null;
|
||||||
m_numberCollisionShapes--;
|
m_numberCollisionShapes--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ void CollisionBody::removeCollisionShape(const ProxyShape* _proxyShape) {
|
|||||||
void CollisionBody::removeAllCollisionShapes() {
|
void CollisionBody::removeAllCollisionShapes() {
|
||||||
ProxyShape* current = m_proxyCollisionShapes;
|
ProxyShape* current = m_proxyCollisionShapes;
|
||||||
// Look for the proxy shape that contains the collision shape in parameter
|
// Look for the proxy shape that contains the collision shape in parameter
|
||||||
while(current != nullptr) {
|
while(current != null) {
|
||||||
// Remove the proxy collision shape
|
// Remove the proxy collision shape
|
||||||
ProxyShape* nextElement = current->m_next;
|
ProxyShape* nextElement = current->m_next;
|
||||||
if (m_isActive) {
|
if (m_isActive) {
|
||||||
@ -106,26 +106,26 @@ void CollisionBody::removeAllCollisionShapes() {
|
|||||||
// Get the next element in the list
|
// Get the next element in the list
|
||||||
current = nextElement;
|
current = nextElement;
|
||||||
}
|
}
|
||||||
m_proxyCollisionShapes = nullptr;
|
m_proxyCollisionShapes = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CollisionBody::resetContactManifoldsList() {
|
void CollisionBody::resetContactManifoldsList() {
|
||||||
// Delete the linked list of contact manifolds of that body
|
// Delete the linked list of contact manifolds of that body
|
||||||
ContactManifoldListElement* currentElement = m_contactManifoldsList;
|
ContactManifoldListElement* currentElement = m_contactManifoldsList;
|
||||||
while (currentElement != nullptr) {
|
while (currentElement != null) {
|
||||||
ContactManifoldListElement* nextElement = currentElement->next;
|
ContactManifoldListElement* nextElement = currentElement->next;
|
||||||
// Delete the current element
|
// Delete the current element
|
||||||
ETK_DELETE(ContactManifoldListElement, currentElement);
|
ETK_DELETE(ContactManifoldListElement, currentElement);
|
||||||
currentElement = nextElement;
|
currentElement = nextElement;
|
||||||
}
|
}
|
||||||
m_contactManifoldsList = nullptr;
|
m_contactManifoldsList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CollisionBody::updateBroadPhaseState() const {
|
void CollisionBody::updateBroadPhaseState() const {
|
||||||
// For all the proxy collision shapes of the body
|
// For all the proxy collision shapes of the body
|
||||||
for (ProxyShape* shape = m_proxyCollisionShapes; shape != nullptr; shape = shape->m_next) {
|
for (ProxyShape* shape = m_proxyCollisionShapes; shape != null; shape = shape->m_next) {
|
||||||
// Update the proxy
|
// Update the proxy
|
||||||
updateProxyShapeInBroadPhase(shape);
|
updateProxyShapeInBroadPhase(shape);
|
||||||
}
|
}
|
||||||
@ -147,13 +147,13 @@ void CollisionBody::setIsActive(bool _isActive) {
|
|||||||
Body::setIsActive(_isActive);
|
Body::setIsActive(_isActive);
|
||||||
// If we have to activate the body
|
// If we have to activate the body
|
||||||
if (_isActive == true) {
|
if (_isActive == true) {
|
||||||
for (ProxyShape* shape = m_proxyCollisionShapes; shape != nullptr; shape = shape->m_next) {
|
for (ProxyShape* shape = m_proxyCollisionShapes; shape != null; shape = shape->m_next) {
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
shape->getCollisionShape()->computeAABB(aabb, m_transform * shape->m_localToBodyTransform);
|
shape->getCollisionShape()->computeAABB(aabb, m_transform * shape->m_localToBodyTransform);
|
||||||
m_world.m_collisionDetection.addProxyCollisionShape(shape, aabb);
|
m_world.m_collisionDetection.addProxyCollisionShape(shape, aabb);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (ProxyShape* shape = m_proxyCollisionShapes; shape != nullptr; shape = shape->m_next) {
|
for (ProxyShape* shape = m_proxyCollisionShapes; shape != null; shape = shape->m_next) {
|
||||||
m_world.m_collisionDetection.removeProxyCollisionShape(shape);
|
m_world.m_collisionDetection.removeProxyCollisionShape(shape);
|
||||||
}
|
}
|
||||||
resetContactManifoldsList();
|
resetContactManifoldsList();
|
||||||
@ -162,7 +162,7 @@ void CollisionBody::setIsActive(bool _isActive) {
|
|||||||
|
|
||||||
|
|
||||||
void CollisionBody::askForBroadPhaseCollisionCheck() const {
|
void CollisionBody::askForBroadPhaseCollisionCheck() const {
|
||||||
for (ProxyShape* shape = m_proxyCollisionShapes; shape != nullptr; shape = shape->m_next) {
|
for (ProxyShape* shape = m_proxyCollisionShapes; shape != null; shape = shape->m_next) {
|
||||||
m_world.m_collisionDetection.askForBroadPhaseCollisionCheck(shape);
|
m_world.m_collisionDetection.askForBroadPhaseCollisionCheck(shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ int32_t CollisionBody::resetIsAlreadyInIslandAndCountManifolds() {
|
|||||||
int32_t nbManifolds = 0;
|
int32_t nbManifolds = 0;
|
||||||
// Reset the m_isAlreadyInIsland variable of the contact manifolds for this body
|
// Reset the m_isAlreadyInIsland variable of the contact manifolds for this body
|
||||||
ContactManifoldListElement* currentElement = m_contactManifoldsList;
|
ContactManifoldListElement* currentElement = m_contactManifoldsList;
|
||||||
while (currentElement != nullptr) {
|
while (currentElement != null) {
|
||||||
currentElement->contactManifold->m_isAlreadyInIsland = false;
|
currentElement->contactManifold->m_isAlreadyInIsland = false;
|
||||||
currentElement = currentElement->next;
|
currentElement = currentElement->next;
|
||||||
nbManifolds++;
|
nbManifolds++;
|
||||||
@ -182,7 +182,7 @@ int32_t CollisionBody::resetIsAlreadyInIslandAndCountManifolds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CollisionBody::testPointInside(const vec3& _worldPoint) const {
|
bool CollisionBody::testPointInside(const vec3& _worldPoint) const {
|
||||||
for (ProxyShape* shape = m_proxyCollisionShapes; shape != nullptr; shape = shape->m_next) {
|
for (ProxyShape* shape = m_proxyCollisionShapes; shape != null; shape = shape->m_next) {
|
||||||
if (shape->testPointInside(_worldPoint)) return true;
|
if (shape->testPointInside(_worldPoint)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -194,7 +194,7 @@ bool CollisionBody::raycast(const Ray& _ray, RaycastInfo& _raycastInfo) {
|
|||||||
}
|
}
|
||||||
bool isHit = false;
|
bool isHit = false;
|
||||||
Ray rayTemp(_ray);
|
Ray rayTemp(_ray);
|
||||||
for (ProxyShape* shape = m_proxyCollisionShapes; shape != nullptr; shape = shape->m_next) {
|
for (ProxyShape* shape = m_proxyCollisionShapes; shape != null; shape = shape->m_next) {
|
||||||
// Test if the ray hits the collision shape
|
// Test if the ray hits the collision shape
|
||||||
if (shape->raycast(rayTemp, _raycastInfo)) {
|
if (shape->raycast(rayTemp, _raycastInfo)) {
|
||||||
rayTemp.maxFraction = _raycastInfo.hitFraction;
|
rayTemp.maxFraction = _raycastInfo.hitFraction;
|
||||||
@ -206,11 +206,11 @@ bool CollisionBody::raycast(const Ray& _ray, RaycastInfo& _raycastInfo) {
|
|||||||
|
|
||||||
AABB CollisionBody::getAABB() const {
|
AABB CollisionBody::getAABB() const {
|
||||||
AABB bodyAABB;
|
AABB bodyAABB;
|
||||||
if (m_proxyCollisionShapes == nullptr) {
|
if (m_proxyCollisionShapes == null) {
|
||||||
return bodyAABB;
|
return bodyAABB;
|
||||||
}
|
}
|
||||||
m_proxyCollisionShapes->getCollisionShape()->computeAABB(bodyAABB, m_transform * m_proxyCollisionShapes->getLocalToBodyTransform());
|
m_proxyCollisionShapes->getCollisionShape()->computeAABB(bodyAABB, m_transform * m_proxyCollisionShapes->getLocalToBodyTransform());
|
||||||
for (ProxyShape* shape = m_proxyCollisionShapes->m_next; shape != nullptr; shape = shape->m_next) {
|
for (ProxyShape* shape = m_proxyCollisionShapes->m_next; shape != null; shape = shape->m_next) {
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
shape->getCollisionShape()->computeAABB(aabb, m_transform * shape->getLocalToBodyTransform());
|
shape->getCollisionShape()->computeAABB(aabb, m_transform * shape->getLocalToBodyTransform());
|
||||||
bodyAABB.mergeWithAABB(aabb);
|
bodyAABB.mergeWithAABB(aabb);
|
||||||
|
@ -23,13 +23,13 @@ RigidBody::RigidBody(const etk::Transform3D& _transform, CollisionWorld& _world,
|
|||||||
m_isGravityEnabled(true),
|
m_isGravityEnabled(true),
|
||||||
m_linearDamping(0.0f),
|
m_linearDamping(0.0f),
|
||||||
m_angularDamping(float(0.0)),
|
m_angularDamping(float(0.0)),
|
||||||
m_jointsList(nullptr) {
|
m_jointsList(null) {
|
||||||
// Compute the inverse mass
|
// Compute the inverse mass
|
||||||
m_massInverse = 1.0f / m_initMass;
|
m_massInverse = 1.0f / m_initMass;
|
||||||
}
|
}
|
||||||
|
|
||||||
RigidBody::~RigidBody() {
|
RigidBody::~RigidBody() {
|
||||||
assert(m_jointsList == nullptr);
|
assert(m_jointsList == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,23 +97,23 @@ void RigidBody::setMass(float _mass) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RigidBody::removeJointFrom_jointsList(const Joint* _joint) {
|
void RigidBody::removeJointFrom_jointsList(const Joint* _joint) {
|
||||||
assert(_joint != nullptr);
|
assert(_joint != null);
|
||||||
assert(m_jointsList != nullptr);
|
assert(m_jointsList != null);
|
||||||
// Remove the joint from the linked list of the joints of the first body
|
// Remove the joint from the linked list of the joints of the first body
|
||||||
if (m_jointsList->joint == _joint) { // If the first element is the one to remove
|
if (m_jointsList->joint == _joint) { // If the first element is the one to remove
|
||||||
JointListElement* elementToRemove = m_jointsList;
|
JointListElement* elementToRemove = m_jointsList;
|
||||||
m_jointsList = elementToRemove->next;
|
m_jointsList = elementToRemove->next;
|
||||||
ETK_DELETE(JointListElement, elementToRemove);
|
ETK_DELETE(JointListElement, elementToRemove);
|
||||||
elementToRemove = nullptr;
|
elementToRemove = null;
|
||||||
}
|
}
|
||||||
else { // If the element to remove is not the first one in the list
|
else { // If the element to remove is not the first one in the list
|
||||||
JointListElement* currentElement = m_jointsList;
|
JointListElement* currentElement = m_jointsList;
|
||||||
while (currentElement->next != nullptr) {
|
while (currentElement->next != null) {
|
||||||
if (currentElement->next->joint == _joint) {
|
if (currentElement->next->joint == _joint) {
|
||||||
JointListElement* elementToRemove = currentElement->next;
|
JointListElement* elementToRemove = currentElement->next;
|
||||||
currentElement->next = elementToRemove->next;
|
currentElement->next = elementToRemove->next;
|
||||||
ETK_DELETE(JointListElement, elementToRemove);
|
ETK_DELETE(JointListElement, elementToRemove);
|
||||||
elementToRemove = nullptr;
|
elementToRemove = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
currentElement = currentElement->next;
|
currentElement = currentElement->next;
|
||||||
@ -129,7 +129,7 @@ ProxyShape* RigidBody::addCollisionShape(CollisionShape* _collisionShape,
|
|||||||
// Create a new proxy collision shape to attach the collision shape to the body
|
// Create a new proxy collision shape to attach the collision shape to the body
|
||||||
ProxyShape* proxyShape = ETK_NEW(ProxyShape, this, _collisionShape, _transform, _mass);
|
ProxyShape* proxyShape = ETK_NEW(ProxyShape, this, _collisionShape, _transform, _mass);
|
||||||
// Add it to the list of proxy collision shapes of the body
|
// Add it to the list of proxy collision shapes of the body
|
||||||
if (m_proxyCollisionShapes == nullptr) {
|
if (m_proxyCollisionShapes == null) {
|
||||||
m_proxyCollisionShapes = proxyShape;
|
m_proxyCollisionShapes = proxyShape;
|
||||||
} else {
|
} else {
|
||||||
proxyShape->m_next = m_proxyCollisionShapes;
|
proxyShape->m_next = m_proxyCollisionShapes;
|
||||||
@ -221,7 +221,7 @@ void RigidBody::recomputeMassInformation() {
|
|||||||
m_centerOfMassLocal *= m_massInverse;
|
m_centerOfMassLocal *= m_massInverse;
|
||||||
m_centerOfMassWorld = m_transform * m_centerOfMassLocal;
|
m_centerOfMassWorld = m_transform * m_centerOfMassLocal;
|
||||||
// Compute the total mass and inertia tensor using all the collision shapes
|
// Compute the total mass and inertia tensor using all the collision shapes
|
||||||
for (ProxyShape* shape = m_proxyCollisionShapes; shape != nullptr; shape = shape->m_next) {
|
for (ProxyShape* shape = m_proxyCollisionShapes; shape != null; shape = shape->m_next) {
|
||||||
// Get the inertia tensor of the collision shape in its local-space
|
// Get the inertia tensor of the collision shape in its local-space
|
||||||
etk::Matrix3x3 inertiaTensor;
|
etk::Matrix3x3 inertiaTensor;
|
||||||
shape->getCollisionShape()->computeLocalInertiaTensor(inertiaTensor, shape->getMass());
|
shape->getCollisionShape()->computeLocalInertiaTensor(inertiaTensor, shape->getMass());
|
||||||
@ -254,7 +254,7 @@ void RigidBody::updateBroadPhaseState() const {
|
|||||||
DynamicsWorld& world = static_cast<DynamicsWorld&>(m_world);
|
DynamicsWorld& world = static_cast<DynamicsWorld&>(m_world);
|
||||||
const vec3 displacement = world.m_timeStep * m_linearVelocity;
|
const vec3 displacement = world.m_timeStep * m_linearVelocity;
|
||||||
// For all the proxy collision shapes of the body
|
// For all the proxy collision shapes of the body
|
||||||
for (ProxyShape* shape = m_proxyCollisionShapes; shape != nullptr; shape = shape->m_next) {
|
for (ProxyShape* shape = m_proxyCollisionShapes; shape != null; shape = shape->m_next) {
|
||||||
// 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());
|
||||||
|
@ -95,7 +95,7 @@ void CollisionDetection::reportCollisionBetweenShapes(CollisionCallback* _callba
|
|||||||
contactPoint->getLocalPointOnBody1(),
|
contactPoint->getLocalPointOnBody1(),
|
||||||
contactPoint->getLocalPointOnBody2());
|
contactPoint->getLocalPointOnBody2());
|
||||||
// Notify the collision callback about this new contact
|
// Notify the collision callback about this new contact
|
||||||
if (_callback != nullptr) {
|
if (_callback != null) {
|
||||||
_callback->notifyContact(contactInfo);
|
_callback->notifyContact(contactInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ void CollisionDetection::computeNarrowPhase() {
|
|||||||
// TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved
|
// TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved
|
||||||
// Destroy the overlapping pair
|
// Destroy the overlapping pair
|
||||||
ETK_DELETE(OverlappingPair, it->second);
|
ETK_DELETE(OverlappingPair, it->second);
|
||||||
it->second = nullptr;
|
it->second = null;
|
||||||
it = m_overlappingPairs.erase(it);
|
it = m_overlappingPairs.erase(it);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
@ -160,7 +160,7 @@ void CollisionDetection::computeNarrowPhase() {
|
|||||||
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
|
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
|
||||||
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = m_collisionMatrix[shape1Type][shape2Type];
|
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = m_collisionMatrix[shape1Type][shape2Type];
|
||||||
// If there is no collision algorithm between those two kinds of shapes
|
// If there is no collision algorithm between those two kinds of shapes
|
||||||
if (narrowPhaseAlgorithm == nullptr) {
|
if (narrowPhaseAlgorithm == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Notify the narrow-phase algorithm about the overlapping pair we are going to test
|
// Notify the narrow-phase algorithm about the overlapping pair we are going to test
|
||||||
@ -223,7 +223,7 @@ void CollisionDetection::computeNarrowPhaseBetweenShapes(CollisionCallback* _cal
|
|||||||
// TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved
|
// TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved
|
||||||
// Destroy the overlapping pair
|
// Destroy the overlapping pair
|
||||||
ETK_DELETE(OverlappingPair, it->second);
|
ETK_DELETE(OverlappingPair, it->second);
|
||||||
it->second = nullptr;
|
it->second = null;
|
||||||
it = m_overlappingPairs.erase(it);
|
it = m_overlappingPairs.erase(it);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
@ -250,7 +250,7 @@ void CollisionDetection::computeNarrowPhaseBetweenShapes(CollisionCallback* _cal
|
|||||||
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
|
const CollisionShapeType shape2Type = shape2->getCollisionShape()->getType();
|
||||||
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = m_collisionMatrix[shape1Type][shape2Type];
|
NarrowPhaseAlgorithm* narrowPhaseAlgorithm = m_collisionMatrix[shape1Type][shape2Type];
|
||||||
// If there is no collision algorithm between those two kinds of shapes
|
// If there is no collision algorithm between those two kinds of shapes
|
||||||
if (narrowPhaseAlgorithm == nullptr) {
|
if (narrowPhaseAlgorithm == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Notify the narrow-phase algorithm about the overlapping pair we are going to test
|
// Notify the narrow-phase algorithm about the overlapping pair we are going to test
|
||||||
@ -295,7 +295,7 @@ void CollisionDetection::broadPhaseNotifyOverlappingPair(ProxyShape* _shape1, Pr
|
|||||||
_shape2->getCollisionShape()->getType());
|
_shape2->getCollisionShape()->getType());
|
||||||
// Create the overlapping pair and add it int32_to the set of overlapping pairs
|
// Create the overlapping pair and add it int32_to the set of overlapping pairs
|
||||||
OverlappingPair* newPair = ETK_NEW(OverlappingPair, _shape1, _shape2, nbMaxManifolds);
|
OverlappingPair* newPair = ETK_NEW(OverlappingPair, _shape1, _shape2, nbMaxManifolds);
|
||||||
assert(newPair != nullptr);
|
assert(newPair != null);
|
||||||
m_overlappingPairs.set(pairID, newPair);
|
m_overlappingPairs.set(pairID, newPair);
|
||||||
// Wake up the two bodies
|
// Wake up the two bodies
|
||||||
_shape1->getBody()->setIsSleeping(false);
|
_shape1->getBody()->setIsSleeping(false);
|
||||||
@ -311,7 +311,7 @@ void CollisionDetection::removeProxyCollisionShape(ProxyShape* _proxyShape) {
|
|||||||
// TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved
|
// TODO : Remove all the contact manifold of the overlapping pair from the contact manifolds list of the two bodies involved
|
||||||
// Destroy the overlapping pair
|
// Destroy the overlapping pair
|
||||||
ETK_DELETE(OverlappingPair, it->second);
|
ETK_DELETE(OverlappingPair, it->second);
|
||||||
it->second = nullptr;
|
it->second = null;
|
||||||
it = m_overlappingPairs.erase(it);
|
it = m_overlappingPairs.erase(it);
|
||||||
} else {
|
} else {
|
||||||
++it;
|
++it;
|
||||||
@ -359,7 +359,7 @@ void CollisionDetection::addAllContactManifoldsToBodies() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CollisionDetection::addContactManifoldToBody(OverlappingPair* _pair) {
|
void CollisionDetection::addContactManifoldToBody(OverlappingPair* _pair) {
|
||||||
assert(_pair != nullptr);
|
assert(_pair != null);
|
||||||
CollisionBody* body1 = _pair->getShape1()->getBody();
|
CollisionBody* body1 = _pair->getShape1()->getBody();
|
||||||
CollisionBody* body2 = _pair->getShape2()->getBody();
|
CollisionBody* body2 = _pair->getShape2()->getBody();
|
||||||
const ContactManifoldSet& manifoldSet = _pair->getContactManifoldSet();
|
const ContactManifoldSet& manifoldSet = _pair->getContactManifoldSet();
|
||||||
|
@ -59,7 +59,7 @@ void ContactManifold::removeContactPoint(uint32_t index) {
|
|||||||
// Call the destructor explicitly and tell the memory allocator that
|
// Call the destructor explicitly and tell the memory allocator that
|
||||||
// the corresponding memory block is now free
|
// the corresponding memory block is now free
|
||||||
ETK_DELETE(ContactPoint, m_contactPoints[index]);
|
ETK_DELETE(ContactPoint, m_contactPoints[index]);
|
||||||
m_contactPoints[index] = nullptr;
|
m_contactPoints[index] = null;
|
||||||
// If we don't remove the last index
|
// If we don't remove the last index
|
||||||
if (index < m_nbContactPoints - 1) {
|
if (index < m_nbContactPoints - 1) {
|
||||||
m_contactPoints[index] = m_contactPoints[m_nbContactPoints - 1];
|
m_contactPoints[index] = m_contactPoints[m_nbContactPoints - 1];
|
||||||
@ -187,7 +187,7 @@ void ContactManifold::clear() {
|
|||||||
// Call the destructor explicitly and tell the memory allocator that
|
// Call the destructor explicitly and tell the memory allocator that
|
||||||
// the corresponding memory block is now free
|
// the corresponding memory block is now free
|
||||||
ETK_DELETE(ContactPoint, m_contactPoints[iii]);
|
ETK_DELETE(ContactPoint, m_contactPoints[iii]);
|
||||||
m_contactPoints[iii] = nullptr;
|
m_contactPoints[iii] = null;
|
||||||
}
|
}
|
||||||
m_nbContactPoints = 0;
|
m_nbContactPoints = 0;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ void ContactManifoldSet::addContactPoint(ContactPoint* contact) {
|
|||||||
if (smallestDepthIndex == -1) {
|
if (smallestDepthIndex == -1) {
|
||||||
// Delete the new contact
|
// Delete the new contact
|
||||||
ETK_DELETE(ContactPoint, contact);
|
ETK_DELETE(ContactPoint, contact);
|
||||||
contact = nullptr;
|
contact = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert(smallestDepthIndex >= 0 && smallestDepthIndex < m_nbManifolds);
|
assert(smallestDepthIndex >= 0 && smallestDepthIndex < m_nbManifolds);
|
||||||
@ -164,7 +164,7 @@ void ContactManifoldSet::removeManifold(int32_t index) {
|
|||||||
assert(index >= 0 && index < m_nbManifolds);
|
assert(index >= 0 && index < m_nbManifolds);
|
||||||
// Delete the new contact
|
// Delete the new contact
|
||||||
ETK_DELETE(ContactManifold, m_manifolds[index]);
|
ETK_DELETE(ContactManifold, m_manifolds[index]);
|
||||||
m_manifolds[index] = nullptr;
|
m_manifolds[index] = null;
|
||||||
for (int32_t i=index; (i+1) < m_nbManifolds; i++) {
|
for (int32_t i=index; (i+1) < m_nbManifolds; i++) {
|
||||||
m_manifolds[i] = m_manifolds[i+1];
|
m_manifolds[i] = m_manifolds[i+1];
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ namespace ephysics {
|
|||||||
RaycastInfo() :
|
RaycastInfo() :
|
||||||
meshSubpart(-1),
|
meshSubpart(-1),
|
||||||
triangleIndex(-1),
|
triangleIndex(-1),
|
||||||
body(nullptr),
|
body(null),
|
||||||
proxyShape(nullptr) {
|
proxyShape(null) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,8 +471,8 @@ int32_t DynamicAABBTree::balanceSubTreeAtNode(int32_t _nodeID) {
|
|||||||
|
|
||||||
/// Report all shapes overlapping with the AABB given in parameter.
|
/// Report all shapes overlapping with the AABB given in parameter.
|
||||||
void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& _aabb, etk::Function<void(int32_t nodeId)> _callback) const {
|
void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& _aabb, etk::Function<void(int32_t nodeId)> _callback) const {
|
||||||
if (_callback == nullptr) {
|
if (_callback == null) {
|
||||||
EPHY_ERROR("call with nullptr callback");
|
EPHY_ERROR("call with null callback");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create a stack with the nodes to visit
|
// Create a stack with the nodes to visit
|
||||||
@ -507,8 +507,8 @@ void DynamicAABBTree::reportAllShapesOverlappingWithAABB(const AABB& _aabb, etk:
|
|||||||
// Ray casting method
|
// Ray casting method
|
||||||
void DynamicAABBTree::raycast(const ephysics::Ray& _ray, etk::Function<float(int32_t _nodeId, const ephysics::Ray& _ray)> _callback) const {
|
void DynamicAABBTree::raycast(const ephysics::Ray& _ray, etk::Function<float(int32_t _nodeId, const ephysics::Ray& _ray)> _callback) const {
|
||||||
PROFILE("DynamicAABBTree::raycast()");
|
PROFILE("DynamicAABBTree::raycast()");
|
||||||
if (_callback == nullptr) {
|
if (_callback == null) {
|
||||||
EPHY_ERROR("call with nullptr callback");
|
EPHY_ERROR("call with null callback");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float maxFraction = _ray.maxFraction;
|
float maxFraction = _ray.maxFraction;
|
||||||
|
@ -71,7 +71,7 @@ void ConvexVsTriangleCallback::testTriangle(const vec3* _trianglePoints) {
|
|||||||
// Select the collision algorithm to use between the triangle and the convex shape
|
// Select the collision algorithm to use between the triangle and the convex shape
|
||||||
NarrowPhaseAlgorithm* algo = m_collisionDetection->getCollisionAlgorithm(triangleShape.getType(), m_convexShape->getType());
|
NarrowPhaseAlgorithm* algo = m_collisionDetection->getCollisionAlgorithm(triangleShape.getType(), m_convexShape->getType());
|
||||||
// If there is no collision algorithm between those two kinds of shapes
|
// If there is no collision algorithm between those two kinds of shapes
|
||||||
if (algo == nullptr) {
|
if (algo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Notify the narrow-phase algorithm about the overlapping pair we are going to test
|
// Notify the narrow-phase algorithm about the overlapping pair we are going to test
|
||||||
|
@ -42,6 +42,6 @@ NarrowPhaseAlgorithm* DefaultCollisionDispatch::selectAlgorithm(int32_t _type1,
|
|||||||
// Convex vs Convex algorithm (GJK algorithm)
|
// Convex vs Convex algorithm (GJK algorithm)
|
||||||
return &m_GJKAlgorithm;
|
return &m_GJKAlgorithm;
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,10 +215,10 @@ void EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& _simpl
|
|||||||
suppPointsB[4] = body2Tobody1 *
|
suppPointsB[4] = body2Tobody1 *
|
||||||
shape2->getLocalSupportPointWithMargin(rotateToBody2 * n, shape2CachedCollisionData);
|
shape2->getLocalSupportPointWithMargin(rotateToBody2 * n, shape2CachedCollisionData);
|
||||||
points[4] = suppPointsA[4] - suppPointsB[4];
|
points[4] = suppPointsA[4] - suppPointsB[4];
|
||||||
TriangleEPA* face0 = nullptr;
|
TriangleEPA* face0 = null;
|
||||||
TriangleEPA* face1 = nullptr;
|
TriangleEPA* face1 = null;
|
||||||
TriangleEPA* face2 = nullptr;
|
TriangleEPA* face2 = null;
|
||||||
TriangleEPA* face3 = nullptr;
|
TriangleEPA* face3 = null;
|
||||||
// If the origin is in the first tetrahedron
|
// If the origin is in the first tetrahedron
|
||||||
if (isOriginInTetrahedron(points[0], points[1],
|
if (isOriginInTetrahedron(points[0], points[1],
|
||||||
points[2], points[3]) == 0) {
|
points[2], points[3]) == 0) {
|
||||||
@ -244,10 +244,10 @@ void EPAAlgorithm::computePenetrationDepthAndContactPoints(const Simplex& _simpl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If the constructed tetrahedron is not correct
|
// If the constructed tetrahedron is not correct
|
||||||
if (!( face0 != nullptr
|
if (!( face0 != null
|
||||||
&& face1 != nullptr
|
&& face1 != null
|
||||||
&& face2 != nullptr
|
&& face2 != null
|
||||||
&& face3 != nullptr
|
&& face3 != null
|
||||||
&& face0->getDistSquare() > 0.0
|
&& face0->getDistSquare() > 0.0
|
||||||
&& face1->getDistSquare() > 0.0
|
&& face1->getDistSquare() > 0.0
|
||||||
&& face2->getDistSquare() > 0.0
|
&& face2->getDistSquare() > 0.0
|
||||||
|
@ -54,7 +54,7 @@ bool EdgeEPA::computeSilhouette(const vec3* _vertices, uint32_t _indexNewVertex,
|
|||||||
getTargetVertexIndex(),
|
getTargetVertexIndex(),
|
||||||
getSourceVertexIndex());
|
getSourceVertexIndex());
|
||||||
// If the triangle has been created
|
// If the triangle has been created
|
||||||
if (triangle != nullptr) {
|
if (triangle != null) {
|
||||||
halfLink(EdgeEPA(triangle, 1), *this);
|
halfLink(EdgeEPA(triangle, 1), *this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ bool EdgeEPA::computeSilhouette(const vec3* _vertices, uint32_t _indexNewVertex,
|
|||||||
getTargetVertexIndex(),
|
getTargetVertexIndex(),
|
||||||
getSourceVertexIndex());
|
getSourceVertexIndex());
|
||||||
// If the triangle has been created
|
// If the triangle has been created
|
||||||
if (triangle != nullptr) {
|
if (triangle != null) {
|
||||||
halfLink(EdgeEPA(triangle, 1), *this);
|
halfLink(EdgeEPA(triangle, 1), *this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
using namespace ephysics;
|
using namespace ephysics;
|
||||||
|
|
||||||
NarrowPhaseAlgorithm::NarrowPhaseAlgorithm():
|
NarrowPhaseAlgorithm::NarrowPhaseAlgorithm():
|
||||||
m_currentOverlappingPair(nullptr) {
|
m_currentOverlappingPair(null) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +41,11 @@ void ConcaveMeshShape::initBVHTree() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConcaveMeshShape::getTriangleVerticesWithIndexPointer(int32_t _subPart, int32_t _triangleIndex, vec3* _outTriangleVertices) const {
|
void ConcaveMeshShape::getTriangleVerticesWithIndexPointer(int32_t _subPart, int32_t _triangleIndex, vec3* _outTriangleVertices) const {
|
||||||
EPHY_ASSERT(_outTriangleVertices != nullptr, "Input check error");
|
EPHY_ASSERT(_outTriangleVertices != null, "Input check error");
|
||||||
// Get the triangle vertex array of the current sub-part
|
// Get the triangle vertex array of the current sub-part
|
||||||
TriangleVertexArray* triangleVertexArray = m_triangleMesh->getSubpart(_subPart);
|
TriangleVertexArray* triangleVertexArray = m_triangleMesh->getSubpart(_subPart);
|
||||||
if (triangleVertexArray == nullptr) {
|
if (triangleVertexArray == null) {
|
||||||
EPHY_ERROR("get nullptr ...");
|
EPHY_ERROR("get null ...");
|
||||||
}
|
}
|
||||||
ephysics::Triangle trianglePoints = triangleVertexArray->getTriangle(_triangleIndex);
|
ephysics::Triangle trianglePoints = triangleVertexArray->getTriangle(_triangleIndex);
|
||||||
_outTriangleVertices[0] = trianglePoints[0] * m_scaling;
|
_outTriangleVertices[0] = trianglePoints[0] * m_scaling;
|
||||||
|
@ -74,9 +74,9 @@ ConvexMeshShape::ConvexMeshShape(float _margin):
|
|||||||
vec3 ConvexMeshShape::getLocalSupportPointWithoutMargin(const vec3& _direction,
|
vec3 ConvexMeshShape::getLocalSupportPointWithoutMargin(const vec3& _direction,
|
||||||
void** _cachedCollisionData) const {
|
void** _cachedCollisionData) const {
|
||||||
assert(m_numberVertices == m_vertices.size());
|
assert(m_numberVertices == m_vertices.size());
|
||||||
assert(_cachedCollisionData != nullptr);
|
assert(_cachedCollisionData != null);
|
||||||
// Allocate memory for the cached collision data if not allocated yet
|
// Allocate memory for the cached collision data if not allocated yet
|
||||||
if ((*_cachedCollisionData) == nullptr) {
|
if ((*_cachedCollisionData) == null) {
|
||||||
*_cachedCollisionData = (int32_t*) malloc(sizeof(int32_t));
|
*_cachedCollisionData = (int32_t*) malloc(sizeof(int32_t));
|
||||||
*((int32_t*)(*_cachedCollisionData)) = 0;
|
*((int32_t*)(*_cachedCollisionData)) = 0;
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,10 @@ namespace ephysics {
|
|||||||
|
|
||||||
}
|
}
|
||||||
ContactPointInfo():
|
ContactPointInfo():
|
||||||
shape1(nullptr),
|
shape1(null),
|
||||||
shape2(nullptr),
|
shape2(null),
|
||||||
collisionShape1(nullptr),
|
collisionShape1(null),
|
||||||
collisionShape2(nullptr) {
|
collisionShape2(null) {
|
||||||
// TODO: add it for etk::Vector
|
// TODO: add it for etk::Vector
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -15,8 +15,8 @@ Joint::Joint(const JointInfo& jointInfo)
|
|||||||
m_positionCorrectionTechnique(jointInfo.positionCorrectionTechnique),
|
m_positionCorrectionTechnique(jointInfo.positionCorrectionTechnique),
|
||||||
m_isCollisionEnabled(jointInfo.isCollisionEnabled), m_isAlreadyInIsland(false) {
|
m_isCollisionEnabled(jointInfo.isCollisionEnabled), m_isAlreadyInIsland(false) {
|
||||||
|
|
||||||
assert(m_body1 != nullptr);
|
assert(m_body1 != null);
|
||||||
assert(m_body2 != nullptr);
|
assert(m_body2 != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Joint::~Joint() {
|
Joint::~Joint() {
|
||||||
|
@ -50,8 +50,8 @@ namespace ephysics {
|
|||||||
bool isCollisionEnabled; //!< True if the two bodies of the joint are allowed to collide with each other
|
bool isCollisionEnabled; //!< True if the two bodies of the joint are allowed to collide with each other
|
||||||
/// Constructor
|
/// Constructor
|
||||||
JointInfo(JointType _constraintType):
|
JointInfo(JointType _constraintType):
|
||||||
body1(nullptr),
|
body1(null),
|
||||||
body2(nullptr),
|
body2(null),
|
||||||
type(_constraintType),
|
type(_constraintType),
|
||||||
positionCorrectionTechnique(NON_LINEAR_GAUSS_SEIDEL),
|
positionCorrectionTechnique(NON_LINEAR_GAUSS_SEIDEL),
|
||||||
isCollisionEnabled(true) {
|
isCollisionEnabled(true) {
|
||||||
|
@ -15,7 +15,7 @@ using namespace std;
|
|||||||
CollisionWorld::CollisionWorld() :
|
CollisionWorld::CollisionWorld() :
|
||||||
m_collisionDetection(this),
|
m_collisionDetection(this),
|
||||||
m_currentBodyID(0),
|
m_currentBodyID(0),
|
||||||
m_eventListener(nullptr) {
|
m_eventListener(null) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ CollisionBody* CollisionWorld::createCollisionBody(const etk::Transform3D& _tran
|
|||||||
EPHY_ASSERT(bodyID < UINT64_MAX, "index too big");
|
EPHY_ASSERT(bodyID < UINT64_MAX, "index too big");
|
||||||
// Create the collision body
|
// Create the collision body
|
||||||
CollisionBody* collisionBody = ETK_NEW(CollisionBody, _transform, *this, bodyID);
|
CollisionBody* collisionBody = ETK_NEW(CollisionBody, _transform, *this, bodyID);
|
||||||
EPHY_ASSERT(collisionBody != nullptr, "empty Body collision");
|
EPHY_ASSERT(collisionBody != null, "empty Body collision");
|
||||||
// Add the collision body to the world
|
// Add the collision body to the world
|
||||||
m_bodies.add(collisionBody);
|
m_bodies.add(collisionBody);
|
||||||
// Return the pointer to the rigid body
|
// Return the pointer to the rigid body
|
||||||
@ -48,7 +48,7 @@ void CollisionWorld::destroyCollisionBody(CollisionBody* _collisionBody) {
|
|||||||
// Remove the collision body from the list of bodies
|
// Remove the collision body from the list of bodies
|
||||||
m_bodies.erase(m_bodies.find(_collisionBody));
|
m_bodies.erase(m_bodies.find(_collisionBody));
|
||||||
ETK_DELETE(CollisionBody, _collisionBody);
|
ETK_DELETE(CollisionBody, _collisionBody);
|
||||||
_collisionBody = nullptr;
|
_collisionBody = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyindex CollisionWorld::computeNextAvailableBodyID() {
|
bodyindex CollisionWorld::computeNextAvailableBodyID() {
|
||||||
@ -115,7 +115,7 @@ void CollisionWorld::testCollision(const CollisionBody* _body, CollisionCallback
|
|||||||
etk::Set<uint32_t> shapes1;
|
etk::Set<uint32_t> shapes1;
|
||||||
// For each shape of the body
|
// For each shape of the body
|
||||||
for (const ProxyShape* shape = _body->getProxyShapesList();
|
for (const ProxyShape* shape = _body->getProxyShapesList();
|
||||||
shape != nullptr;
|
shape != null;
|
||||||
shape = shape->getNext()) {
|
shape = shape->getNext()) {
|
||||||
shapes1.add(shape->m_broadPhaseID);
|
shapes1.add(shape->m_broadPhaseID);
|
||||||
}
|
}
|
||||||
@ -130,13 +130,13 @@ void CollisionWorld::testCollision(const CollisionBody* _body1, const CollisionB
|
|||||||
// Create the sets of shapes
|
// Create the sets of shapes
|
||||||
etk::Set<uint32_t> shapes1;
|
etk::Set<uint32_t> shapes1;
|
||||||
for (const ProxyShape* shape = _body1->getProxyShapesList();
|
for (const ProxyShape* shape = _body1->getProxyShapesList();
|
||||||
shape != nullptr;
|
shape != null;
|
||||||
shape = shape->getNext()) {
|
shape = shape->getNext()) {
|
||||||
shapes1.add(shape->m_broadPhaseID);
|
shapes1.add(shape->m_broadPhaseID);
|
||||||
}
|
}
|
||||||
etk::Set<uint32_t> shapes2;
|
etk::Set<uint32_t> shapes2;
|
||||||
for (const ProxyShape* shape = _body2->getProxyShapesList();
|
for (const ProxyShape* shape = _body2->getProxyShapesList();
|
||||||
shape != nullptr;
|
shape != null;
|
||||||
shape = shape->getNext()) {
|
shape = shape->getNext()) {
|
||||||
shapes2.add(shape->m_broadPhaseID);
|
shapes2.add(shape->m_broadPhaseID);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ ConstraintSolver::ConstraintSolver(const etk::Map<RigidBody*, uint32_t>& _mapBod
|
|||||||
|
|
||||||
void ConstraintSolver::initializeForIsland(float _dt, Island* _island) {
|
void ConstraintSolver::initializeForIsland(float _dt, Island* _island) {
|
||||||
PROFILE("ConstraintSolver::initializeForIsland()");
|
PROFILE("ConstraintSolver::initializeForIsland()");
|
||||||
assert(_island != nullptr);
|
assert(_island != null);
|
||||||
assert(_island->getNbBodies() > 0);
|
assert(_island->getNbBodies() > 0);
|
||||||
assert(_island->getNbJoints() > 0);
|
assert(_island->getNbJoints() > 0);
|
||||||
// Set the current time step
|
// Set the current time step
|
||||||
@ -42,7 +42,7 @@ void ConstraintSolver::initializeForIsland(float _dt, Island* _island) {
|
|||||||
|
|
||||||
void ConstraintSolver::solveVelocityConstraints(Island* _island) {
|
void ConstraintSolver::solveVelocityConstraints(Island* _island) {
|
||||||
PROFILE("ConstraintSolver::solveVelocityConstraints()");
|
PROFILE("ConstraintSolver::solveVelocityConstraints()");
|
||||||
assert(_island != nullptr);
|
assert(_island != null);
|
||||||
assert(_island->getNbJoints() > 0);
|
assert(_island->getNbJoints() > 0);
|
||||||
// For each joint of the island
|
// For each joint of the island
|
||||||
Joint** joints = _island->getJoints();
|
Joint** joints = _island->getJoints();
|
||||||
@ -53,7 +53,7 @@ void ConstraintSolver::solveVelocityConstraints(Island* _island) {
|
|||||||
|
|
||||||
void ConstraintSolver::solvePositionConstraints(Island* _island) {
|
void ConstraintSolver::solvePositionConstraints(Island* _island) {
|
||||||
PROFILE("ConstraintSolver::solvePositionConstraints()");
|
PROFILE("ConstraintSolver::solvePositionConstraints()");
|
||||||
assert(_island != nullptr);
|
assert(_island != null);
|
||||||
assert(_island->getNbJoints() > 0);
|
assert(_island->getNbJoints() > 0);
|
||||||
Joint** joints = _island->getJoints();
|
Joint** joints = _island->getJoints();
|
||||||
for (uint32_t iii=0; iii < _island->getNbJoints(); ++iii) {
|
for (uint32_t iii=0; iii < _island->getNbJoints(); ++iii) {
|
||||||
@ -63,16 +63,16 @@ void ConstraintSolver::solvePositionConstraints(Island* _island) {
|
|||||||
|
|
||||||
void ConstraintSolver::setConstrainedVelocitiesArrays(vec3* _constrainedLinearVelocities,
|
void ConstraintSolver::setConstrainedVelocitiesArrays(vec3* _constrainedLinearVelocities,
|
||||||
vec3* _constrainedAngularVelocities) {
|
vec3* _constrainedAngularVelocities) {
|
||||||
assert(_constrainedLinearVelocities != nullptr);
|
assert(_constrainedLinearVelocities != null);
|
||||||
assert(_constrainedAngularVelocities != nullptr);
|
assert(_constrainedAngularVelocities != null);
|
||||||
m_constraintSolverData.linearVelocities = _constrainedLinearVelocities;
|
m_constraintSolverData.linearVelocities = _constrainedLinearVelocities;
|
||||||
m_constraintSolverData.angularVelocities = _constrainedAngularVelocities;
|
m_constraintSolverData.angularVelocities = _constrainedAngularVelocities;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstraintSolver::setConstrainedPositionsArrays(vec3* _constrainedPositions,
|
void ConstraintSolver::setConstrainedPositionsArrays(vec3* _constrainedPositions,
|
||||||
etk::Quaternion* _constrainedOrientations) {
|
etk::Quaternion* _constrainedOrientations) {
|
||||||
assert(_constrainedPositions != nullptr);
|
assert(_constrainedPositions != null);
|
||||||
assert(_constrainedOrientations != nullptr);
|
assert(_constrainedOrientations != null);
|
||||||
m_constraintSolverData.positions = _constrainedPositions;
|
m_constraintSolverData.positions = _constrainedPositions;
|
||||||
m_constraintSolverData.orientations = _constrainedOrientations;
|
m_constraintSolverData.orientations = _constrainedOrientations;
|
||||||
}
|
}
|
@ -30,10 +30,10 @@ namespace ephysics {
|
|||||||
bool isWarmStartingActive; //!< True if warm starting of the solver is active
|
bool isWarmStartingActive; //!< True if warm starting of the solver is active
|
||||||
/// Constructor
|
/// Constructor
|
||||||
ConstraintSolverData(const etk::Map<RigidBody*, uint32_t>& refMapBodyToConstrainedVelocityIndex):
|
ConstraintSolverData(const etk::Map<RigidBody*, uint32_t>& refMapBodyToConstrainedVelocityIndex):
|
||||||
linearVelocities(nullptr),
|
linearVelocities(null),
|
||||||
angularVelocities(nullptr),
|
angularVelocities(null),
|
||||||
positions(nullptr),
|
positions(null),
|
||||||
orientations(nullptr),
|
orientations(null),
|
||||||
mapBodyToConstrainedVelocityIndex(refMapBodyToConstrainedVelocityIndex) {
|
mapBodyToConstrainedVelocityIndex(refMapBodyToConstrainedVelocityIndex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,10 @@ const float ContactSolver::BETA_SPLIT_IMPULSE = float(0.2);
|
|||||||
const float ContactSolver::SLOP = float(0.01);
|
const float ContactSolver::SLOP = float(0.01);
|
||||||
|
|
||||||
ContactSolver::ContactSolver(const etk::Map<RigidBody*, uint32_t>& _mapBodyToVelocityIndex) :
|
ContactSolver::ContactSolver(const etk::Map<RigidBody*, uint32_t>& _mapBodyToVelocityIndex) :
|
||||||
m_splitLinearVelocities(nullptr),
|
m_splitLinearVelocities(null),
|
||||||
m_splitAngularVelocities(nullptr),
|
m_splitAngularVelocities(null),
|
||||||
m_linearVelocities(nullptr),
|
m_linearVelocities(null),
|
||||||
m_angularVelocities(nullptr),
|
m_angularVelocities(null),
|
||||||
m_mapBodyToConstrainedVelocityIndex(_mapBodyToVelocityIndex),
|
m_mapBodyToConstrainedVelocityIndex(_mapBodyToVelocityIndex),
|
||||||
m_isWarmStartingActive(true),
|
m_isWarmStartingActive(true),
|
||||||
m_isSplitImpulseActive(true),
|
m_isSplitImpulseActive(true),
|
||||||
@ -31,11 +31,11 @@ ContactSolver::ContactSolver(const etk::Map<RigidBody*, uint32_t>& _mapBodyToVel
|
|||||||
|
|
||||||
void ContactSolver::initializeForIsland(float _dt, Island* _island) {
|
void ContactSolver::initializeForIsland(float _dt, Island* _island) {
|
||||||
PROFILE("ContactSolver::initializeForIsland()");
|
PROFILE("ContactSolver::initializeForIsland()");
|
||||||
assert(_island != nullptr);
|
assert(_island != null);
|
||||||
assert(_island->getNbBodies() > 0);
|
assert(_island->getNbBodies() > 0);
|
||||||
assert(_island->getNbContactManifolds() > 0);
|
assert(_island->getNbContactManifolds() > 0);
|
||||||
assert(m_splitLinearVelocities != nullptr);
|
assert(m_splitLinearVelocities != null);
|
||||||
assert(m_splitAngularVelocities != nullptr);
|
assert(m_splitAngularVelocities != null);
|
||||||
// Set the current time step
|
// Set the current time step
|
||||||
m_timeStep = _dt;
|
m_timeStep = _dt;
|
||||||
m_contactConstraints.resize(_island->getNbContactManifolds());
|
m_contactConstraints.resize(_island->getNbContactManifolds());
|
||||||
@ -48,8 +48,8 @@ void ContactSolver::initializeForIsland(float _dt, Island* _island) {
|
|||||||
// Get the two bodies of the contact
|
// Get the two bodies of the contact
|
||||||
RigidBody* body1 = static_cast<RigidBody*>(externalManifold->getContactPoint(0)->getBody1());
|
RigidBody* body1 = static_cast<RigidBody*>(externalManifold->getContactPoint(0)->getBody1());
|
||||||
RigidBody* body2 = static_cast<RigidBody*>(externalManifold->getContactPoint(0)->getBody2());
|
RigidBody* body2 = static_cast<RigidBody*>(externalManifold->getContactPoint(0)->getBody2());
|
||||||
assert(body1 != nullptr);
|
assert(body1 != null);
|
||||||
assert(body2 != nullptr);
|
assert(body2 != null);
|
||||||
// Get the position of the two bodies
|
// Get the position of the two bodies
|
||||||
const vec3& x1 = body1->m_centerOfMassWorld;
|
const vec3& x1 = body1->m_centerOfMassWorld;
|
||||||
const vec3& x2 = body2->m_centerOfMassWorld;
|
const vec3& x2 = body2->m_centerOfMassWorld;
|
||||||
|
@ -48,7 +48,7 @@ ephysics::DynamicsWorld::~DynamicsWorld() {
|
|||||||
for (auto &it: m_islands) {
|
for (auto &it: m_islands) {
|
||||||
// Call the island destructor
|
// Call the island destructor
|
||||||
ETK_DELETE(Island, it);
|
ETK_DELETE(Island, it);
|
||||||
it = nullptr;
|
it = null;
|
||||||
}
|
}
|
||||||
m_islands.clear();
|
m_islands.clear();
|
||||||
// Release the memory allocated for the bodies velocity arrays
|
// Release the memory allocated for the bodies velocity arrays
|
||||||
@ -80,7 +80,7 @@ void ephysics::DynamicsWorld::update(float timeStep) {
|
|||||||
PROFILE("ephysics::DynamicsWorld::update()");
|
PROFILE("ephysics::DynamicsWorld::update()");
|
||||||
m_timeStep = timeStep;
|
m_timeStep = timeStep;
|
||||||
// Notify the event listener about the beginning of an int32_ternal tick
|
// Notify the event listener about the beginning of an int32_ternal tick
|
||||||
if (m_eventListener != nullptr) {
|
if (m_eventListener != null) {
|
||||||
m_eventListener->beginInternalTick();
|
m_eventListener->beginInternalTick();
|
||||||
}
|
}
|
||||||
// Reset all the contact manifolds lists of each body
|
// Reset all the contact manifolds lists of each body
|
||||||
@ -107,7 +107,7 @@ void ephysics::DynamicsWorld::update(float timeStep) {
|
|||||||
updateSleepingBodies();
|
updateSleepingBodies();
|
||||||
}
|
}
|
||||||
// Notify the event listener about the end of an int32_ternal tick
|
// Notify the event listener about the end of an int32_ternal tick
|
||||||
if (m_eventListener != nullptr) {
|
if (m_eventListener != null) {
|
||||||
m_eventListener->endInternalTick();
|
m_eventListener->endInternalTick();
|
||||||
}
|
}
|
||||||
// Reset the external force and torque applied to the bodies
|
// Reset the external force and torque applied to the bodies
|
||||||
@ -326,7 +326,7 @@ ephysics::RigidBody* ephysics::DynamicsWorld::createRigidBody(const etk::Transfo
|
|||||||
assert(bodyID < UINT64_MAX);
|
assert(bodyID < UINT64_MAX);
|
||||||
// Create the rigid body
|
// Create the rigid body
|
||||||
ephysics::RigidBody* rigidBody = ETK_NEW(RigidBody, _transform, *this, bodyID);
|
ephysics::RigidBody* rigidBody = ETK_NEW(RigidBody, _transform, *this, bodyID);
|
||||||
assert(rigidBody != nullptr);
|
assert(rigidBody != null);
|
||||||
// Add the rigid body to the physics world
|
// Add the rigid body to the physics world
|
||||||
m_bodies.add(rigidBody);
|
m_bodies.add(rigidBody);
|
||||||
m_rigidBodies.add(rigidBody);
|
m_rigidBodies.add(rigidBody);
|
||||||
@ -341,7 +341,7 @@ void ephysics::DynamicsWorld::destroyRigidBody(RigidBody* _rigidBody) {
|
|||||||
m_freeBodiesIDs.pushBack(_rigidBody->getID());
|
m_freeBodiesIDs.pushBack(_rigidBody->getID());
|
||||||
// Destroy all the joints in which the rigid body to be destroyed is involved
|
// Destroy all the joints in which the rigid body to be destroyed is involved
|
||||||
for (ephysics::JointListElement* element = _rigidBody->m_jointsList;
|
for (ephysics::JointListElement* element = _rigidBody->m_jointsList;
|
||||||
element != nullptr;
|
element != null;
|
||||||
element = element->next) {
|
element = element->next) {
|
||||||
destroyJoint(element->joint);
|
destroyJoint(element->joint);
|
||||||
}
|
}
|
||||||
@ -352,11 +352,11 @@ void ephysics::DynamicsWorld::destroyRigidBody(RigidBody* _rigidBody) {
|
|||||||
m_rigidBodies.erase(m_rigidBodies.find(_rigidBody));
|
m_rigidBodies.erase(m_rigidBodies.find(_rigidBody));
|
||||||
// Call the destructor of the rigid body
|
// Call the destructor of the rigid body
|
||||||
ETK_DELETE(RigidBody, _rigidBody);
|
ETK_DELETE(RigidBody, _rigidBody);
|
||||||
_rigidBody = nullptr;
|
_rigidBody = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ephysics::Joint* ephysics::DynamicsWorld::createJoint(const ephysics::JointInfo& _jointInfo) {
|
ephysics::Joint* ephysics::DynamicsWorld::createJoint(const ephysics::JointInfo& _jointInfo) {
|
||||||
Joint* newJoint = nullptr;
|
Joint* newJoint = null;
|
||||||
// Allocate memory to create the new joint
|
// Allocate memory to create the new joint
|
||||||
switch(_jointInfo.type) {
|
switch(_jointInfo.type) {
|
||||||
// Ball-and-Socket joint
|
// Ball-and-Socket joint
|
||||||
@ -377,7 +377,7 @@ ephysics::Joint* ephysics::DynamicsWorld::createJoint(const ephysics::JointInfo&
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
return nullptr;
|
return null;
|
||||||
}
|
}
|
||||||
// If the collision between the two bodies of the constraint is disabled
|
// If the collision between the two bodies of the constraint is disabled
|
||||||
if (!_jointInfo.isCollisionEnabled) {
|
if (!_jointInfo.isCollisionEnabled) {
|
||||||
@ -393,8 +393,8 @@ ephysics::Joint* ephysics::DynamicsWorld::createJoint(const ephysics::JointInfo&
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ephysics::DynamicsWorld::destroyJoint(Joint* _joint) {
|
void ephysics::DynamicsWorld::destroyJoint(Joint* _joint) {
|
||||||
if (_joint == nullptr) {
|
if (_joint == null) {
|
||||||
EPHY_WARNING("Request destroy nullptr joint");
|
EPHY_WARNING("Request destroy null joint");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If the collision between the two bodies of the constraint was disabled
|
// If the collision between the two bodies of the constraint was disabled
|
||||||
@ -413,12 +413,12 @@ void ephysics::DynamicsWorld::destroyJoint(Joint* _joint) {
|
|||||||
size_t nbBytes = _joint->getSizeInBytes();
|
size_t nbBytes = _joint->getSizeInBytes();
|
||||||
// Call the destructor of the joint
|
// Call the destructor of the joint
|
||||||
ETK_DELETE(Joint, _joint);
|
ETK_DELETE(Joint, _joint);
|
||||||
_joint = nullptr;
|
_joint = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ephysics::DynamicsWorld::addJointToBody(ephysics::Joint* _joint) {
|
void ephysics::DynamicsWorld::addJointToBody(ephysics::Joint* _joint) {
|
||||||
if (_joint == nullptr) {
|
if (_joint == null) {
|
||||||
EPHY_WARNING("Request add nullptr joint");
|
EPHY_WARNING("Request add null joint");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Add the joint at the beginning of the linked list of joints of the first body
|
// Add the joint at the beginning of the linked list of joints of the first body
|
||||||
@ -433,7 +433,7 @@ void ephysics::DynamicsWorld::computeIslands() {
|
|||||||
// Clear all the islands
|
// Clear all the islands
|
||||||
for (auto &it: m_islands) {
|
for (auto &it: m_islands) {
|
||||||
ETK_DELETE(Island, it);
|
ETK_DELETE(Island, it);
|
||||||
it = nullptr;
|
it = null;
|
||||||
}
|
}
|
||||||
// Call the island destructor
|
// Call the island destructor
|
||||||
m_islands.clear();
|
m_islands.clear();
|
||||||
@ -448,7 +448,7 @@ void ephysics::DynamicsWorld::computeIslands() {
|
|||||||
}
|
}
|
||||||
// Create a stack (using an array) for the rigid bodies to visit during the Depth First Search
|
// Create a stack (using an array) for the rigid bodies to visit during the Depth First Search
|
||||||
etk::Vector<ephysics::RigidBody*> stackBodiesToVisit;
|
etk::Vector<ephysics::RigidBody*> stackBodiesToVisit;
|
||||||
stackBodiesToVisit.resize(nbBodies, nullptr);
|
stackBodiesToVisit.resize(nbBodies, null);
|
||||||
// For each rigid body of the world
|
// For each rigid body of the world
|
||||||
for (etk::Set<ephysics::RigidBody*>::Iterator it = m_rigidBodies.begin(); it != m_rigidBodies.end(); ++it) {
|
for (etk::Set<ephysics::RigidBody*>::Iterator it = m_rigidBodies.begin(); it != m_rigidBodies.end(); ++it) {
|
||||||
ephysics::RigidBody* body = *it;
|
ephysics::RigidBody* body = *it;
|
||||||
@ -489,7 +489,7 @@ void ephysics::DynamicsWorld::computeIslands() {
|
|||||||
// For each contact manifold in which the current body is involded
|
// For each contact manifold in which the current body is involded
|
||||||
ephysics::ContactManifoldListElement* contactElement;
|
ephysics::ContactManifoldListElement* contactElement;
|
||||||
for (contactElement = bodyToVisit->m_contactManifoldsList;
|
for (contactElement = bodyToVisit->m_contactManifoldsList;
|
||||||
contactElement != nullptr;
|
contactElement != null;
|
||||||
contactElement = contactElement->next) {
|
contactElement = contactElement->next) {
|
||||||
ephysics::ContactManifold* contactManifold = contactElement->contactManifold;
|
ephysics::ContactManifold* contactManifold = contactElement->contactManifold;
|
||||||
assert(contactManifold->getNbContactPoints() > 0);
|
assert(contactManifold->getNbContactPoints() > 0);
|
||||||
@ -516,7 +516,7 @@ void ephysics::DynamicsWorld::computeIslands() {
|
|||||||
// For each joint in which the current body is involved
|
// For each joint in which the current body is involved
|
||||||
ephysics::JointListElement* jointElement;
|
ephysics::JointListElement* jointElement;
|
||||||
for (jointElement = bodyToVisit->m_jointsList;
|
for (jointElement = bodyToVisit->m_jointsList;
|
||||||
jointElement != nullptr;
|
jointElement != null;
|
||||||
jointElement = jointElement->next) {
|
jointElement = jointElement->next) {
|
||||||
ephysics::Joint* joint = jointElement->joint;
|
ephysics::Joint* joint = jointElement->joint;
|
||||||
// Check if the current joint has already been added int32_to an island
|
// Check if the current joint has already been added int32_to an island
|
||||||
@ -615,7 +615,7 @@ void ephysics::DynamicsWorld::testCollision(const ephysics::CollisionBody* _body
|
|||||||
etk::Set<uint32_t> shapes1;
|
etk::Set<uint32_t> shapes1;
|
||||||
// For each shape of the body
|
// For each shape of the body
|
||||||
for (const ProxyShape* shape = _body->getProxyShapesList();
|
for (const ProxyShape* shape = _body->getProxyShapesList();
|
||||||
shape != nullptr;
|
shape != null;
|
||||||
shape = shape->getNext()) {
|
shape = shape->getNext()) {
|
||||||
shapes1.add(shape->m_broadPhaseID);
|
shapes1.add(shape->m_broadPhaseID);
|
||||||
}
|
}
|
||||||
@ -627,12 +627,12 @@ void ephysics::DynamicsWorld::testCollision(const ephysics::CollisionBody* _body
|
|||||||
void ephysics::DynamicsWorld::testCollision(const ephysics::CollisionBody* _body1, const ephysics::CollisionBody* _body2, ephysics::CollisionCallback* _callback) {
|
void ephysics::DynamicsWorld::testCollision(const ephysics::CollisionBody* _body1, const ephysics::CollisionBody* _body2, ephysics::CollisionCallback* _callback) {
|
||||||
// Create the sets of shapes
|
// Create the sets of shapes
|
||||||
etk::Set<uint32_t> shapes1;
|
etk::Set<uint32_t> shapes1;
|
||||||
for (const ProxyShape* shape=_body1->getProxyShapesList(); shape != nullptr;
|
for (const ProxyShape* shape=_body1->getProxyShapesList(); shape != null;
|
||||||
shape = shape->getNext()) {
|
shape = shape->getNext()) {
|
||||||
shapes1.add(shape->m_broadPhaseID);
|
shapes1.add(shape->m_broadPhaseID);
|
||||||
}
|
}
|
||||||
etk::Set<uint32_t> shapes2;
|
etk::Set<uint32_t> shapes2;
|
||||||
for (const ProxyShape* shape=_body2->getProxyShapesList(); shape != nullptr;
|
for (const ProxyShape* shape=_body2->getProxyShapesList(); shape != null;
|
||||||
shape = shape->getNext()) {
|
shape = shape->getNext()) {
|
||||||
shapes2.add(shape->m_broadPhaseID);
|
shapes2.add(shape->m_broadPhaseID);
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ namespace ephysics {
|
|||||||
void setTimeBeforeSleep(float timeBeforeSleep);
|
void setTimeBeforeSleep(float timeBeforeSleep);
|
||||||
/**
|
/**
|
||||||
* @brief Set an event listener object to receive events callbacks.
|
* @brief Set an event listener object to receive events callbacks.
|
||||||
* @note If you use nullptr as an argument, the events callbacks will be disabled.
|
* @note If you use null as an argument, the events callbacks will be disabled.
|
||||||
* @param[in] _eventListener Pointer to the event listener object that will receive
|
* @param[in] _eventListener Pointer to the event listener object that will receive
|
||||||
* event callbacks during the simulation
|
* event callbacks during the simulation
|
||||||
*/
|
*/
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
using namespace ephysics;
|
using namespace ephysics;
|
||||||
|
|
||||||
// Initialization of static variables
|
// Initialization of static variables
|
||||||
ProfileNode Profiler::m_rootNode("Root", nullptr);
|
ProfileNode Profiler::m_rootNode("Root", null);
|
||||||
ProfileNode* Profiler::m_currentNode = &Profiler::m_rootNode;
|
ProfileNode* Profiler::m_currentNode = &Profiler::m_rootNode;
|
||||||
long double Profiler::m_profilingStartTime = Timer::getCurrentSystemTime() * 1000.0;
|
long double Profiler::m_profilingStartTime = Timer::getCurrentSystemTime() * 1000.0;
|
||||||
uint32_t Profiler::m_frameCounter = 0;
|
uint32_t Profiler::m_frameCounter = 0;
|
||||||
@ -23,17 +23,17 @@ uint32_t Profiler::m_frameCounter = 0;
|
|||||||
// Constructor
|
// Constructor
|
||||||
ProfileNode::ProfileNode(const char* name, ProfileNode* parentNode)
|
ProfileNode::ProfileNode(const char* name, ProfileNode* parentNode)
|
||||||
:m_name(name), m_numberTotalCalls(0), m_startTime(0), m_totalTime(0),
|
:m_name(name), m_numberTotalCalls(0), m_startTime(0), m_totalTime(0),
|
||||||
m_recursionCounter(0), m_parentNode(parentNode), m_childNode(nullptr),
|
m_recursionCounter(0), m_parentNode(parentNode), m_childNode(null),
|
||||||
m_siblingNode(nullptr) {
|
m_siblingNode(null) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
ProfileNode::~ProfileNode() {
|
ProfileNode::~ProfileNode() {
|
||||||
ETK_DELETE(ProfileNode, m_childNode);
|
ETK_DELETE(ProfileNode, m_childNode);
|
||||||
m_childNode = nullptr;
|
m_childNode = null;
|
||||||
ETK_DELETE(ProfileNode, m_siblingNode);
|
ETK_DELETE(ProfileNode, m_siblingNode);
|
||||||
m_siblingNode = nullptr;
|
m_siblingNode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a pointer to a sub node with a given name
|
// Return a pointer to a sub node with a given name
|
||||||
@ -41,7 +41,7 @@ ProfileNode* ProfileNode::findSubNode(const char* name) {
|
|||||||
|
|
||||||
// Try to find the node among the child nodes
|
// Try to find the node among the child nodes
|
||||||
ProfileNode* child = m_childNode;
|
ProfileNode* child = m_childNode;
|
||||||
while (child != nullptr) {
|
while (child != null) {
|
||||||
if (child->m_name == name) {
|
if (child->m_name == name) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
@ -95,12 +95,12 @@ void ProfileNode::reset() {
|
|||||||
m_totalTime = 0.0;
|
m_totalTime = 0.0;
|
||||||
|
|
||||||
// Reset the child node
|
// Reset the child node
|
||||||
if (m_childNode != nullptr) {
|
if (m_childNode != null) {
|
||||||
m_childNode->reset();
|
m_childNode->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the sibling node
|
// Reset the sibling node
|
||||||
if (m_siblingNode != nullptr) {
|
if (m_siblingNode != null) {
|
||||||
m_siblingNode->reset();
|
m_siblingNode->reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,9 +108,9 @@ void ProfileNode::reset() {
|
|||||||
// Destroy the node
|
// Destroy the node
|
||||||
void ProfileNode::destroy() {
|
void ProfileNode::destroy() {
|
||||||
ETK_DELETE(ProfileNode, m_childNode);
|
ETK_DELETE(ProfileNode, m_childNode);
|
||||||
m_childNode = nullptr;
|
m_childNode = null;
|
||||||
ETK_DELETE(ProfileNode, m_siblingNode);
|
ETK_DELETE(ProfileNode, m_siblingNode);
|
||||||
m_siblingNode = nullptr;
|
m_siblingNode = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
@ -123,12 +123,12 @@ ProfileNodeIterator::ProfileNodeIterator(ProfileNode* startingNode)
|
|||||||
// Enter a given child node
|
// Enter a given child node
|
||||||
void ProfileNodeIterator::enterChild(int32_t index) {
|
void ProfileNodeIterator::enterChild(int32_t index) {
|
||||||
m_currentChildNode = m_currentParentNode->getChildNode();
|
m_currentChildNode = m_currentParentNode->getChildNode();
|
||||||
while ((m_currentChildNode != nullptr) && (index != 0)) {
|
while ((m_currentChildNode != null) && (index != 0)) {
|
||||||
index--;
|
index--;
|
||||||
m_currentChildNode = m_currentChildNode->getSiblingNode();
|
m_currentChildNode = m_currentChildNode->getSiblingNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_currentChildNode != nullptr) {
|
if (m_currentChildNode != null) {
|
||||||
m_currentParentNode = m_currentChildNode;
|
m_currentParentNode = m_currentChildNode;
|
||||||
m_currentChildNode = m_currentParentNode->getChildNode();
|
m_currentChildNode = m_currentParentNode->getChildNode();
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ void ProfileNodeIterator::enterChild(int32_t index) {
|
|||||||
|
|
||||||
// Enter a given parent node
|
// Enter a given parent node
|
||||||
void ProfileNodeIterator::enterParent() {
|
void ProfileNodeIterator::enterParent() {
|
||||||
if (m_currentParentNode->getParentNode() != nullptr) {
|
if (m_currentParentNode->getParentNode() != null) {
|
||||||
m_currentParentNode = m_currentParentNode->getParentNode();
|
m_currentParentNode = m_currentParentNode->getParentNode();
|
||||||
}
|
}
|
||||||
m_currentChildNode = m_currentParentNode->getChildNode();
|
m_currentChildNode = m_currentParentNode->getChildNode();
|
||||||
@ -242,12 +242,12 @@ void Profiler::print32_tRecursiveNodeReport(ProfileNodeIterator* iterator,
|
|||||||
|
|
||||||
// Return true if we are at the root of the profiler tree
|
// Return true if we are at the root of the profiler tree
|
||||||
bool ProfileNodeIterator::isRoot() {
|
bool ProfileNodeIterator::isRoot() {
|
||||||
return (m_currentParentNode->getParentNode() == nullptr);
|
return (m_currentParentNode->getParentNode() == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if we are at the end of a branch of the profiler tree
|
// Return true if we are at the end of a branch of the profiler tree
|
||||||
bool ProfileNodeIterator::isEnd() {
|
bool ProfileNodeIterator::isEnd() {
|
||||||
return (m_currentChildNode == nullptr);
|
return (m_currentChildNode == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the name of the current node
|
// Return the name of the current node
|
||||||
|
@ -29,7 +29,7 @@ class WorldRaycastCallback : public ephysics::RaycastCallback {
|
|||||||
bool isHit;
|
bool isHit;
|
||||||
WorldRaycastCallback() {
|
WorldRaycastCallback() {
|
||||||
isHit = false;
|
isHit = false;
|
||||||
shapeToTest = nullptr;
|
shapeToTest = null;
|
||||||
}
|
}
|
||||||
virtual float notifyRaycastHit(const ephysics::RaycastInfo& info) {
|
virtual float notifyRaycastHit(const ephysics::RaycastInfo& info) {
|
||||||
if (shapeToTest->getBody()->getID() == info.body->getID()) {
|
if (shapeToTest->getBody()->getID() == info.body->getID()) {
|
||||||
@ -44,9 +44,9 @@ class WorldRaycastCallback : public ephysics::RaycastCallback {
|
|||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
void reset() {
|
void reset() {
|
||||||
raycastInfo.body = nullptr;
|
raycastInfo.body = null;
|
||||||
raycastInfo.hitFraction = 0.0f;
|
raycastInfo.hitFraction = 0.0f;
|
||||||
raycastInfo.proxyShape = nullptr;
|
raycastInfo.proxyShape = null;
|
||||||
raycastInfo.worldNormal.setZero();
|
raycastInfo.worldNormal.setZero();
|
||||||
raycastInfo.worldPoint.setZero();
|
raycastInfo.worldPoint.setZero();
|
||||||
isHit = false;
|
isHit = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user