mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:58:03 +02:00
Particles now collide with avatars, but avatars don't react yet.
This commit is contained in:
parent
d520adba98
commit
934b0f619b
1 changed files with 20 additions and 3 deletions
|
@ -137,8 +137,13 @@ void ParticleCollisionSystem::updateCollisionWithAvatars(Particle* particle) {
|
||||||
// check hands...
|
// check hands...
|
||||||
const HandData* handData = avatar->getHandData();
|
const HandData* handData = avatar->getHandData();
|
||||||
|
|
||||||
// if the particle penetrates the hand, then apply a hard collision
|
// TODO: combine hand and collision check into one. Note: would need to supply
|
||||||
|
// CollisionInfo class rather than just vec3 (penetration) so we can get back
|
||||||
|
// added velocity.
|
||||||
|
|
||||||
if (handData->findSpherePenetration(center, radius, penetration, collidingPalm)) {
|
if (handData->findSpherePenetration(center, radius, penetration, collidingPalm)) {
|
||||||
|
// TODO: dot collidingPalm and hand velocities and skip collision when they are moving apart.
|
||||||
|
// apply a hard collision when ball collides with hand
|
||||||
penetration /= (float)TREE_SCALE;
|
penetration /= (float)TREE_SCALE;
|
||||||
updateCollisionSound(particle, penetration, VOXEL_COLLISION_FREQUENCY);
|
updateCollisionSound(particle, penetration, VOXEL_COLLISION_FREQUENCY);
|
||||||
|
|
||||||
|
@ -150,6 +155,12 @@ void ParticleCollisionSystem::updateCollisionWithAvatars(Particle* particle) {
|
||||||
addedVelocity = palmVelocity;
|
addedVelocity = palmVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applyHardCollision(particle, penetration, VOXEL_ELASTICITY, VOXEL_DAMPING, addedVelocity);
|
||||||
|
} else if (avatar->findSpherePenetration(center, radius, penetration)) {
|
||||||
|
// apply hard collision when particle collides with avatar
|
||||||
|
penetration /= (float)TREE_SCALE;
|
||||||
|
updateCollisionSound(particle, penetration, VOXEL_COLLISION_FREQUENCY);
|
||||||
|
glm::vec3 addedVelocity = avatar->getVelocity();
|
||||||
applyHardCollision(particle, penetration, VOXEL_ELASTICITY, VOXEL_DAMPING, addedVelocity);
|
applyHardCollision(particle, penetration, VOXEL_ELASTICITY, VOXEL_DAMPING, addedVelocity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,14 +170,15 @@ void ParticleCollisionSystem::updateCollisionWithAvatars(Particle* particle) {
|
||||||
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
|
||||||
//qDebug() << "updateCollisionWithAvatars()... node:" << *node << "\n";
|
//qDebug() << "updateCollisionWithAvatars()... node:" << *node << "\n";
|
||||||
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
|
||||||
|
// TODO: dot collidingPalm and hand velocities and skip collision when they are moving apart.
|
||||||
AvatarData* avatar = static_cast<AvatarData*>(node->getLinkedData());
|
AvatarData* avatar = static_cast<AvatarData*>(node->getLinkedData());
|
||||||
//printf("updateCollisionWithAvatars()...avatar=%p\n", avatar);
|
//printf("updateCollisionWithAvatars()...avatar=%p\n", avatar);
|
||||||
|
|
||||||
// check hands...
|
// check hands...
|
||||||
const HandData* handData = avatar->getHandData();
|
const HandData* handData = avatar->getHandData();
|
||||||
|
|
||||||
// if the particle penetrates the hand, then apply a hard collision
|
|
||||||
if (handData->findSpherePenetration(center, radius, penetration, collidingPalm)) {
|
if (handData->findSpherePenetration(center, radius, penetration, collidingPalm)) {
|
||||||
|
// apply a hard collision when ball collides with hand
|
||||||
penetration /= (float)TREE_SCALE;
|
penetration /= (float)TREE_SCALE;
|
||||||
updateCollisionSound(particle, penetration, VOXEL_COLLISION_FREQUENCY);
|
updateCollisionSound(particle, penetration, VOXEL_COLLISION_FREQUENCY);
|
||||||
|
|
||||||
|
@ -180,6 +192,11 @@ void ParticleCollisionSystem::updateCollisionWithAvatars(Particle* particle) {
|
||||||
|
|
||||||
applyHardCollision(particle, penetration, VOXEL_ELASTICITY, VOXEL_DAMPING, addedVelocity);
|
applyHardCollision(particle, penetration, VOXEL_ELASTICITY, VOXEL_DAMPING, addedVelocity);
|
||||||
|
|
||||||
|
} else if (avatar->findSpherePenetration(center, radius, penetration)) {
|
||||||
|
penetration /= (float)TREE_SCALE;
|
||||||
|
updateCollisionSound(particle, penetration, VOXEL_COLLISION_FREQUENCY);
|
||||||
|
glm::vec3 addedVelocity = avatar->getVelocity();
|
||||||
|
applyHardCollision(particle, penetration, VOXEL_ELASTICITY, VOXEL_DAMPING, addedVelocity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue