Fix NPC animations.

This commit is contained in:
Howard Stearns 2015-07-28 12:34:10 -07:00
parent e7516aab02
commit 4754615159
5 changed files with 14 additions and 5 deletions

View file

@ -116,7 +116,8 @@ void SkeletonModel::updateClusterMatrices() {
}
void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
_rig->simulateInternal(deltaTime, parentTransform, _owningAvatar->getPosition(), _owningAvatar->getVelocity(), _owningAvatar->getOrientation());
_rig->computeMotionAnimationState(deltaTime, _owningAvatar->getPosition(), _owningAvatar->getVelocity(), _owningAvatar->getOrientation());
Model::updateRig(deltaTime, parentTransform);
}
void SkeletonModel::simulate(float deltaTime, bool fullUpdate) {

View file

@ -341,7 +341,7 @@ glm::mat4 Rig::getJointVisibleTransform(int jointIndex) const {
return maybeCauterizeHead(jointIndex).getVisibleTransform();
}
void Rig::simulateInternal(float deltaTime, glm::mat4 parentTransform, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation) {
void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation) {
if (_enableRig) {
glm::vec3 front = worldRotation * IDENTITY_FRONT;
@ -374,8 +374,9 @@ void Rig::simulateInternal(float deltaTime, glm::mat4 parentTransform, const glm
_isTurning = isTurning;
_isIdle = isIdle;
}
}
// update animations
void Rig::updateAnimations(float deltaTime, glm::mat4 parentTransform) {
foreach (const AnimationHandlePointer& handle, _runningAnimations) {
handle->simulate(deltaTime);
}

View file

@ -108,7 +108,10 @@ public:
void setJointTransform(int jointIndex, glm::mat4 newTransform);
glm::mat4 getJointVisibleTransform(int jointIndex) const;
void setJointVisibleTransform(int jointIndex, glm::mat4 newTransform);
void simulateInternal(float deltaTime, glm::mat4 parentTransform, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation);
// Start or stop animations as needed.
void computeMotionAnimationState(float deltaTime, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation);
// Regardless of who started the animations or how many, update the joints.
void updateAnimations(float deltaTime, glm::mat4 parentTransform);
bool setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation, bool useRotation,
int lastFreeIndex, bool allIntermediatesFree, const glm::vec3& alignment, float priority,
const QVector<int>& freeLineage, glm::mat4 parentTransform);

View file

@ -1326,6 +1326,10 @@ void Model::simulate(float deltaTime, bool fullUpdate) {
}
}
//virtual
void Model::updateRig(float deltaTime, glm::mat4 parentTransform) {
_rig->updateAnimations(deltaTime, parentTransform);
}
void Model::simulateInternal(float deltaTime) {
// update the world space transforms for all joints

View file

@ -269,7 +269,7 @@ protected:
void snapToRegistrationPoint();
void simulateInternal(float deltaTime);
virtual void updateRig(float deltaTime, glm::mat4 parentTransform) {}; // Subclasses may be more interesting
virtual void updateRig(float deltaTime, glm::mat4 parentTransform);
/// Updates the state of the joint at the specified index.
virtual void updateJointState(int index);