mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 05:53:10 +02:00
Skeleton gets custom update for visible transforms
This commit is contained in:
parent
b012c0a008
commit
7e4efa6c73
2 changed files with 38 additions and 2 deletions
|
@ -135,6 +135,7 @@ void MyAvatar::simulate(float deltaTime) {
|
||||||
setScale(scale);
|
setScale(scale);
|
||||||
Application::getInstance()->getCamera()->setScale(scale);
|
Application::getInstance()->getCamera()->setScale(scale);
|
||||||
}
|
}
|
||||||
|
_skeletonModel.setShowTrueJointTransforms(! Menu::getInstance()->isOptionChecked(MenuOption::CollideAsRagdoll));
|
||||||
|
|
||||||
// no extra movement of the hand here any more ...
|
// no extra movement of the hand here any more ...
|
||||||
_handState = HAND_STATE_NULL;
|
_handState = HAND_STATE_NULL;
|
||||||
|
|
|
@ -537,8 +537,43 @@ void SkeletonModel::buildRagdollConstraints() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonModel::updateVisibleJointStates() {
|
void SkeletonModel::updateVisibleJointStates() {
|
||||||
Model::updateVisibleJointStates();
|
if (_showTrueJointTransforms) {
|
||||||
// TODO: implement this to move visible joints to agree with joint shape positions
|
// no need to update visible transforms
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < _jointStates.size(); i++) {
|
||||||
|
JointState& state = _jointStates[i];
|
||||||
|
|
||||||
|
// get the parent state (this is the state that we want to rotate)
|
||||||
|
int parentIndex = state.getParentIndex();
|
||||||
|
if (parentIndex == -1) {
|
||||||
|
_jointStates[i].slaveVisibleTransform();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
JointState& parentState = _jointStates[parentIndex];
|
||||||
|
|
||||||
|
// check the grand-parent index (for now we don't want to rotate any root states)
|
||||||
|
int grandParentIndex = parentState.getParentIndex();
|
||||||
|
if (grandParentIndex == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure state's visibleTransform is up to date
|
||||||
|
const glm::mat4& parentTransform = parentState.getVisibleTransform();
|
||||||
|
state.computeVisibleTransform(parentTransform);
|
||||||
|
|
||||||
|
// we're looking for the rotation that moves visible bone parallel to ragdoll bone
|
||||||
|
glm::vec3 pivot = extractTranslation(parentTransform);
|
||||||
|
glm::vec3 tip = state.getVisiblePosition();
|
||||||
|
glm::vec3 shapeTip = _ragdollPoints[i]._position;
|
||||||
|
glm::quat delta = rotationBetween(tip - pivot, shapeTip - pivot);
|
||||||
|
|
||||||
|
// apply
|
||||||
|
parentState.mixVisibleRotationDelta(delta, 0.01f);
|
||||||
|
// update transforms
|
||||||
|
parentState.computeVisibleTransform(_jointStates[grandParentIndex].getVisibleTransform());
|
||||||
|
state.computeVisibleTransform(parentState.getVisibleTransform());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// virtual
|
// virtual
|
||||||
|
|
Loading…
Reference in a new issue