mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 15:50:37 +02:00
Splitting hand collisions between other avatars and ourself.
This commit is contained in:
parent
3b3359abce
commit
6c4ecb0246
3 changed files with 88 additions and 67 deletions
|
@ -167,21 +167,22 @@ void Hand::simulate(float deltaTime, bool isMine) {
|
|||
}
|
||||
|
||||
void Hand::updateCollisions() {
|
||||
// use position to obtain the left and right palm indices
|
||||
int leftPalmIndex, rightPalmIndex;
|
||||
getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex);
|
||||
collideAgainstOtherAvatars();
|
||||
collideAgainstOurself();
|
||||
}
|
||||
|
||||
void Hand::collideAgainstOtherAvatars() {
|
||||
if (!Menu::getInstance()->isOptionChecked(MenuOption::CollideWithAvatars)) {
|
||||
return;
|
||||
}
|
||||
ModelCollisionList collisions;
|
||||
// check for collisions
|
||||
float scaledPalmRadius = PALM_COLLISION_RADIUS * _owningAvatar->getScale();
|
||||
for (size_t i = 0; i < getNumPalms(); i++) {
|
||||
PalmData& palm = getPalms()[i];
|
||||
if (!palm.isActive()) {
|
||||
continue;
|
||||
}
|
||||
float scaledPalmRadius = PALM_COLLISION_RADIUS * _owningAvatar->getScale();
|
||||
glm::vec3 totalPenetration;
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CollideWithAvatars)) {
|
||||
// check other avatars
|
||||
foreach (const AvatarSharedPointer& avatarPointer, Application::getInstance()->getAvatarManager().getAvatarHash()) {
|
||||
Avatar* avatar = static_cast<Avatar*>(avatarPointer.data());
|
||||
|
@ -189,6 +190,7 @@ void Hand::updateCollisions() {
|
|||
// don't collid with our own hands
|
||||
continue;
|
||||
}
|
||||
collisions.clear();
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::PlaySlaps)) {
|
||||
// Check for palm collisions
|
||||
glm::vec3 myPalmPosition = palm.getPosition();
|
||||
|
@ -231,9 +233,27 @@ void Hand::updateCollisions() {
|
|||
}
|
||||
}
|
||||
}
|
||||
// resolve penetration
|
||||
palm.addToPosition(-totalPenetration);
|
||||
}
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::HandsCollideWithSelf)) {
|
||||
void Hand::collideAgainstOurself() {
|
||||
if (!Menu::getInstance()->isOptionChecked(MenuOption::HandsCollideWithSelf)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ModelCollisionList collisions;
|
||||
int leftPalmIndex, rightPalmIndex;
|
||||
getLeftRightPalmIndices(leftPalmIndex, rightPalmIndex);
|
||||
float scaledPalmRadius = PALM_COLLISION_RADIUS * _owningAvatar->getScale();
|
||||
|
||||
for (size_t i = 0; i < getNumPalms(); i++) {
|
||||
PalmData& palm = getPalms()[i];
|
||||
if (!palm.isActive()) {
|
||||
continue;
|
||||
}
|
||||
glm::vec3 totalPenetration;
|
||||
// and the current avatar (ignoring everything below the parent of the parent of the last free joint)
|
||||
collisions.clear();
|
||||
const Model& skeletonModel = _owningAvatar->getSkeletonModel();
|
||||
|
@ -245,13 +265,8 @@ void Hand::updateCollisions() {
|
|||
totalPenetration = addPenetrations(totalPenetration, collisions[j]._penetration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// un-penetrate
|
||||
// resolve penetration
|
||||
palm.addToPosition(-totalPenetration);
|
||||
|
||||
// we recycle the collisions container, so we clear it for the next loop
|
||||
collisions.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,9 @@ private:
|
|||
void renderLeapFingerTrails();
|
||||
|
||||
void updateCollisions();
|
||||
void collideAgainstOtherAvatars();
|
||||
void collideAgainstOurself();
|
||||
|
||||
void calculateGeometry();
|
||||
|
||||
void handleVoxelCollision(PalmData* palm, const glm::vec3& fingerTipPosition, VoxelTreeElement* voxel, float deltaTime);
|
||||
|
|
|
@ -1052,6 +1052,9 @@ void MyAvatar::updateCollisionWithAvatars(float deltaTime) {
|
|||
setPosition(_position - 0.5f * penetration);
|
||||
glm::vec3 pushOut = 0.5f * penetration;
|
||||
}
|
||||
|
||||
// collide their hands against our movable limbs
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue