mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:09:24 +02:00
sphere-cube: add the penetration don't subtract it
This commit is contained in:
parent
22bf10a9e7
commit
9ceda573cc
1 changed files with 4 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "GeometryUtil.h"
|
#include "GeometryUtil.h"
|
||||||
#include "ShapeCollider.h"
|
#include "ShapeCollider.h"
|
||||||
|
#include "StreamUtils.h" // adebug
|
||||||
|
|
||||||
// NOTE:
|
// NOTE:
|
||||||
//
|
//
|
||||||
|
@ -591,7 +592,8 @@ bool listList(const ListShape* listA, const ListShape* listB, CollisionList& col
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function
|
// helper function
|
||||||
bool sphereAACube(const glm::vec3& sphereCenter, float sphereRadius, const glm::vec3& cubeCenter, float cubeSide, CollisionList& collisions) {
|
bool sphereAACube(const glm::vec3& sphereCenter, float sphereRadius, const glm::vec3& cubeCenter,
|
||||||
|
float cubeSide, CollisionList& collisions) {
|
||||||
glm::vec3 BA = cubeCenter - sphereCenter;
|
glm::vec3 BA = cubeCenter - sphereCenter;
|
||||||
float distance = glm::length(BA);
|
float distance = glm::length(BA);
|
||||||
if (distance > EPSILON) {
|
if (distance > EPSILON) {
|
||||||
|
@ -649,7 +651,7 @@ bool sphereAACube(const glm::vec3& sphereCenter, float sphereRadius, const glm::
|
||||||
// penetration is the projection of surfaceAB on direction
|
// penetration is the projection of surfaceAB on direction
|
||||||
collision->_penetration = glm::dot(surfaceAB, direction) * direction;
|
collision->_penetration = glm::dot(surfaceAB, direction) * direction;
|
||||||
// contactPoint is on surface of A
|
// contactPoint is on surface of A
|
||||||
collision->_contactPoint = sphereCenter - sphereRadius * direction;
|
collision->_contactPoint = sphereCenter + sphereRadius * direction;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue