mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:02:55 +02:00
Merge pull request #13 from hyperlogic/ajt/model-offset-fix
Clear translation on root joint.
This commit is contained in:
commit
31574521c1
7 changed files with 5 additions and 59 deletions
|
@ -49,7 +49,7 @@ void FaceModel::simulate(float deltaTime, bool fullUpdate) {
|
||||||
setOffset(-_geometry->getFBXGeometry().neckPivot);
|
setOffset(-_geometry->getFBXGeometry().neckPivot);
|
||||||
|
|
||||||
for (int i = 0; i < _rig->getJointStateCount(); i++) {
|
for (int i = 0; i < _rig->getJointStateCount(); i++) {
|
||||||
updateJointState(i);
|
maybeUpdateNeckAndEyeRotation(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
Model::simulateInternal(deltaTime);
|
Model::simulateInternal(deltaTime);
|
||||||
|
@ -90,7 +90,7 @@ void FaceModel::maybeUpdateEyeRotation(Model* model, const JointState& parentSta
|
||||||
joint.rotation, DEFAULT_PRIORITY);
|
joint.rotation, DEFAULT_PRIORITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaceModel::updateJointState(int index) {
|
void FaceModel::maybeUpdateNeckAndEyeRotation(int index) {
|
||||||
const JointState& state = _rig->getJointState(index);
|
const JointState& state = _rig->getJointState(index);
|
||||||
const FBXJoint& joint = state.getFBXJoint();
|
const FBXJoint& joint = state.getFBXJoint();
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
|
|
||||||
void maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, int index);
|
void maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, int index);
|
||||||
void maybeUpdateEyeRotation(Model* model, const JointState& parentState, const FBXJoint& joint, int index);
|
void maybeUpdateEyeRotation(Model* model, const JointState& parentState, const FBXJoint& joint, int index);
|
||||||
void updateJointState(int index);
|
void maybeUpdateNeckAndEyeRotation(int index);
|
||||||
|
|
||||||
/// Retrieve the positions of up to two eye meshes.
|
/// Retrieve the positions of up to two eye meshes.
|
||||||
/// \return whether or not both eye meshes were found
|
/// \return whether or not both eye meshes were found
|
||||||
|
|
|
@ -83,29 +83,6 @@ void SkeletonModel::initJointStates(QVector<JointState> states) {
|
||||||
const float PALM_PRIORITY = DEFAULT_PRIORITY;
|
const float PALM_PRIORITY = DEFAULT_PRIORITY;
|
||||||
const float LEAN_PRIORITY = DEFAULT_PRIORITY;
|
const float LEAN_PRIORITY = DEFAULT_PRIORITY;
|
||||||
|
|
||||||
|
|
||||||
void SkeletonModel::updateClusterMatrices() {
|
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
|
||||||
glm::mat4 modelToWorld = glm::mat4_cast(_rotation);
|
|
||||||
for (int i = 0; i < _meshStates.size(); i++) {
|
|
||||||
MeshState& state = _meshStates[i];
|
|
||||||
const FBXMesh& mesh = geometry.meshes.at(i);
|
|
||||||
if (_showTrueJointTransforms) {
|
|
||||||
for (int j = 0; j < mesh.clusters.size(); j++) {
|
|
||||||
const FBXCluster& cluster = mesh.clusters.at(j);
|
|
||||||
state.clusterMatrices[j] =
|
|
||||||
modelToWorld * _rig->getJointTransform(cluster.jointIndex) * cluster.inverseBindMatrix;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int j = 0; j < mesh.clusters.size(); j++) {
|
|
||||||
const FBXCluster& cluster = mesh.clusters.at(j);
|
|
||||||
state.clusterMatrices[j] =
|
|
||||||
modelToWorld * _rig->getJointVisibleTransform(cluster.jointIndex) * cluster.inverseBindMatrix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
||||||
_rig->computeMotionAnimationState(deltaTime, _owningAvatar->getPosition(), _owningAvatar->getVelocity(), _owningAvatar->getOrientation());
|
_rig->computeMotionAnimationState(deltaTime, _owningAvatar->getPosition(), _owningAvatar->getVelocity(), _owningAvatar->getOrientation());
|
||||||
Model::updateRig(deltaTime, parentTransform);
|
Model::updateRig(deltaTime, parentTransform);
|
||||||
|
@ -264,16 +241,6 @@ void SkeletonModel::applyPalmData(int jointIndex, PalmData& palm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonModel::updateJointState(int index) {
|
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
|
||||||
glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
|
|
||||||
|
|
||||||
_rig->updateJointState(index, parentTransform);
|
|
||||||
|
|
||||||
if (index == _geometry->getFBXGeometry().rootJointIndex) {
|
|
||||||
_rig->clearJointTransformTranslation(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void SkeletonModel::renderJointConstraints(gpu::Batch& batch, int jointIndex) {
|
void SkeletonModel::renderJointConstraints(gpu::Batch& batch, int jointIndex) {
|
||||||
if (jointIndex == -1 || jointIndex >= _rig->getJointStateCount()) {
|
if (jointIndex == -1 || jointIndex >= _rig->getJointStateCount()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -117,19 +117,6 @@ protected:
|
||||||
void applyHandPosition(int jointIndex, const glm::vec3& position);
|
void applyHandPosition(int jointIndex, const glm::vec3& position);
|
||||||
|
|
||||||
void applyPalmData(int jointIndex, PalmData& palm);
|
void applyPalmData(int jointIndex, PalmData& palm);
|
||||||
|
|
||||||
/// Updates the state of the joint at the specified index.
|
|
||||||
virtual void updateJointState(int index);
|
|
||||||
|
|
||||||
void maybeUpdateLeanRotation(const JointState& parentState, int index);
|
|
||||||
void maybeUpdateNeckRotation(const JointState& parentState, const FBXJoint& joint, int index);
|
|
||||||
void maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, int index);
|
|
||||||
|
|
||||||
void updateClusterMatrices();
|
|
||||||
void cauterizeHead();
|
|
||||||
void initHeadBones();
|
|
||||||
void invalidateHeadBones();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void renderJointConstraints(gpu::Batch& batch, int jointIndex);
|
void renderJointConstraints(gpu::Batch& batch, int jointIndex);
|
||||||
|
|
|
@ -23,6 +23,7 @@ void AvatarRig::updateJointState(int index, glm::mat4 parentTransform) {
|
||||||
int parentIndex = joint.parentIndex;
|
int parentIndex = joint.parentIndex;
|
||||||
if (parentIndex == -1) {
|
if (parentIndex == -1) {
|
||||||
state.computeTransform(parentTransform);
|
state.computeTransform(parentTransform);
|
||||||
|
clearJointTransformTranslation(index);
|
||||||
} else {
|
} else {
|
||||||
// guard against out-of-bounds access to _jointStates
|
// guard against out-of-bounds access to _jointStates
|
||||||
if (joint.parentIndex >= 0 && joint.parentIndex < _jointStates.size()) {
|
if (joint.parentIndex >= 0 && joint.parentIndex < _jointStates.size()) {
|
||||||
|
|
|
@ -1383,12 +1383,6 @@ void Model::simulateInternal(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::updateJointState(int index) {
|
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
|
||||||
glm::mat4 parentTransform = glm::scale(_scale) * glm::translate(_offset) * geometry.offset;
|
|
||||||
_rig->updateJointState(index, parentTransform);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Model::setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation, bool useRotation,
|
bool Model::setJointPosition(int jointIndex, const glm::vec3& position, const glm::quat& rotation, bool useRotation,
|
||||||
int lastFreeIndex, bool allIntermediatesFree, const glm::vec3& alignment, float priority) {
|
int lastFreeIndex, bool allIntermediatesFree, const glm::vec3& alignment, float priority) {
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
|
|
|
@ -276,9 +276,6 @@ protected:
|
||||||
void simulateInternal(float deltaTime);
|
void simulateInternal(float deltaTime);
|
||||||
virtual void updateRig(float deltaTime, glm::mat4 parentTransform);
|
virtual void updateRig(float deltaTime, glm::mat4 parentTransform);
|
||||||
|
|
||||||
/// Updates the state of the joint at the specified index.
|
|
||||||
virtual void updateJointState(int index);
|
|
||||||
|
|
||||||
/// \param jointIndex index of joint in model structure
|
/// \param jointIndex index of joint in model structure
|
||||||
/// \param position position of joint in model-frame
|
/// \param position position of joint in model-frame
|
||||||
/// \param rotation rotation of joint in model-frame
|
/// \param rotation rotation of joint in model-frame
|
||||||
|
|
Loading…
Reference in a new issue