mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 04:36:09 +02:00
Splitting avatar collision check in two: vs hands and vs skeleton.
This commit is contained in:
parent
570b872eda
commit
f3f1539111
4 changed files with 20 additions and 7 deletions
|
@ -285,9 +285,7 @@ bool Avatar::findSpherePenetration(const glm::vec3& penetratorCenter, float pene
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Avatar::findSphereCollision(const glm::vec3& sphereCenter, float sphereRadius, CollisionInfo& collision) {
|
bool Avatar::findSphereCollisionWithHands(const glm::vec3& sphereCenter, float sphereRadius, CollisionInfo& collision) {
|
||||||
// TODO: provide an early exit using bounding sphere of entire avatar
|
|
||||||
|
|
||||||
const HandData* handData = getHandData();
|
const HandData* handData = getHandData();
|
||||||
if (handData) {
|
if (handData) {
|
||||||
for (int i = 0; i < NUM_HANDS; i++) {
|
for (int i = 0; i < NUM_HANDS; i++) {
|
||||||
|
@ -326,7 +324,10 @@ bool Avatar::findSphereCollision(const glm::vec3& sphereCenter, float sphereRadi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Avatar::findSphereCollisionWithSkeleton(const glm::vec3& sphereCenter, float sphereRadius, CollisionInfo& collision) {
|
||||||
if (_skeletonModel.findSpherePenetration(sphereCenter, sphereRadius, collision._penetration)) {
|
if (_skeletonModel.findSpherePenetration(sphereCenter, sphereRadius, collision._penetration)) {
|
||||||
collision._penetration /= (float)(TREE_SCALE);
|
collision._penetration /= (float)(TREE_SCALE);
|
||||||
collision._addedVelocity = getVelocity();
|
collision._addedVelocity = getVelocity();
|
||||||
|
|
|
@ -105,12 +105,19 @@ public:
|
||||||
bool findSpherePenetration(const glm::vec3& penetratorCenter, float penetratorRadius,
|
bool findSpherePenetration(const glm::vec3& penetratorCenter, float penetratorRadius,
|
||||||
glm::vec3& penetration, int skeletonSkipIndex = -1) const;
|
glm::vec3& penetration, int skeletonSkipIndex = -1) const;
|
||||||
|
|
||||||
/// Checks for collision between the a sphere and the avatar.
|
/// Checks for collision between the a sphere and the avatar's (paddle) hands.
|
||||||
/// \param collisionCenter the center of the penetration test sphere
|
/// \param collisionCenter the center of the penetration test sphere
|
||||||
/// \param collisionRadius the radius of the penetration test sphere
|
/// \param collisionRadius the radius of the penetration test sphere
|
||||||
/// \param collision[out] the details of the collision point
|
/// \param collision[out] the details of the collision point
|
||||||
/// \return whether or not the sphere collided
|
/// \return whether or not the sphere collided
|
||||||
virtual bool findSphereCollision(const glm::vec3& sphereCenter, float sphereRadius, CollisionInfo& collision);
|
bool findSphereCollisionWithHands(const glm::vec3& sphereCenter, float sphereRadius, CollisionInfo& collision);
|
||||||
|
|
||||||
|
/// Checks for collision between the a sphere and the avatar's skeleton (including hand capsules).
|
||||||
|
/// \param collisionCenter the center of the penetration test sphere
|
||||||
|
/// \param collisionRadius the radius of the penetration test sphere
|
||||||
|
/// \param collision[out] the details of the collision point
|
||||||
|
/// \return whether or not the sphere collided
|
||||||
|
bool findSphereCollisionWithSkeleton(const glm::vec3& sphereCenter, float sphereRadius, CollisionInfo& collision);
|
||||||
|
|
||||||
virtual bool isMyAvatar() { return false; }
|
virtual bool isMyAvatar() { return false; }
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,11 @@ public:
|
||||||
virtual bool findSpherePenetration(const glm::vec3& penetratorCenter, float penetratorRadius,
|
virtual bool findSpherePenetration(const glm::vec3& penetratorCenter, float penetratorRadius,
|
||||||
glm::vec3& penetration, int skeletonSkipIndex = -1) const { return false; }
|
glm::vec3& penetration, int skeletonSkipIndex = -1) const { return false; }
|
||||||
|
|
||||||
virtual bool findSphereCollision(const glm::vec3& sphereCenter, float sphereRadius, CollisionInfo& collision) {
|
virtual bool findSphereCollisionWithHands(const glm::vec3& sphereCenter, float sphereRadius, CollisionInfo& collision) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool findSphereCollisionWithSkeleton(const glm::vec3& sphereCenter, float sphereRadius, CollisionInfo& collision) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,8 @@ void ParticleCollisionSystem::updateCollisionWithAvatars(Particle* particle) {
|
||||||
CollisionInfo collisionInfo;
|
CollisionInfo collisionInfo;
|
||||||
collisionInfo._damping = DAMPING;
|
collisionInfo._damping = DAMPING;
|
||||||
collisionInfo._elasticity = ELASTICITY;
|
collisionInfo._elasticity = ELASTICITY;
|
||||||
if (avatar->findSphereCollision(center, radius, collisionInfo)) {
|
if (avatar->findSphereCollisionWithHands(center, radius, collisionInfo) ||
|
||||||
|
avatar->findSphereCollisionWithSkeleton(center, radius, collisionInfo)) {
|
||||||
collisionInfo._addedVelocity /= (float)(TREE_SCALE);
|
collisionInfo._addedVelocity /= (float)(TREE_SCALE);
|
||||||
glm::vec3 relativeVelocity = collisionInfo._addedVelocity - particle->getVelocity();
|
glm::vec3 relativeVelocity = collisionInfo._addedVelocity - particle->getVelocity();
|
||||||
if (glm::dot(relativeVelocity, collisionInfo._penetration) < 0.f) {
|
if (glm::dot(relativeVelocity, collisionInfo._penetration) < 0.f) {
|
||||||
|
|
Loading…
Reference in a new issue