mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 01:23:55 +02:00
fix bad penetration depth for interior of cube
This commit is contained in:
parent
9fc1c765d3
commit
8ec493e85b
1 changed files with 3 additions and 2 deletions
|
@ -664,13 +664,14 @@ bool sphereAACube(const glm::vec3& sphereCenter, float sphereRadius, const glm::
|
||||||
glm::vec3 direction;
|
glm::vec3 direction;
|
||||||
BA /= maxBA;
|
BA /= maxBA;
|
||||||
glm::modf(BA, direction);
|
glm::modf(BA, direction);
|
||||||
direction = glm::normalize(direction);
|
float lengthDirection = glm::length(direction);
|
||||||
|
direction /= lengthDirection;
|
||||||
|
|
||||||
// compute collision details
|
// compute collision details
|
||||||
collision->_type = COLLISION_TYPE_AACUBE;
|
collision->_type = COLLISION_TYPE_AACUBE;
|
||||||
collision->_floatData = cubeSide;
|
collision->_floatData = cubeSide;
|
||||||
collision->_vecData = cubeCenter;
|
collision->_vecData = cubeCenter;
|
||||||
collision->_penetration = (halfCubeSide + sphereRadius - distance * glm::dot(BA, direction)) * direction;
|
collision->_penetration = (halfCubeSide * lengthDirection + sphereRadius - maxBA * glm::dot(BA, direction)) * direction;
|
||||||
collision->_contactPoint = sphereCenter + sphereRadius * direction;
|
collision->_contactPoint = sphereCenter + sphereRadius * direction;
|
||||||
}
|
}
|
||||||
collision->_type = COLLISION_TYPE_AACUBE;
|
collision->_type = COLLISION_TYPE_AACUBE;
|
||||||
|
|
Loading…
Reference in a new issue