From c80ade98ecfcea0d1a8eeb712647a033e78cd660 Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 13 Nov 2018 12:10:10 -0800 Subject: [PATCH] cleaned up white space --- .../qml/hifi/tablet/OpenVrConfiguration.qml | 4 +- interface/src/avatar/MySkeletonModel.cpp | 3 - libraries/animation/src/AnimClip.cpp | 2 - libraries/animation/src/AnimSkeleton.cpp | 84 +++++-------------- libraries/fbx/src/FBXReader.cpp | 13 +-- tools/skeleton-dump/src/SkeletonDumpApp.cpp | 2 - 6 files changed, 24 insertions(+), 84 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index f91642105f..2fc5cc4196 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -9,9 +9,9 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 -import "../../styles-uit" +import stylesUit 1.0 import "../../controls" -import "../../controls-uit" as HifiControls +import controlsUit 1.0 as HifiControls import "." diff --git a/interface/src/avatar/MySkeletonModel.cpp b/interface/src/avatar/MySkeletonModel.cpp index 720bbd1066..2a21f78b21 100644 --- a/interface/src/avatar/MySkeletonModel.cpp +++ b/interface/src/avatar/MySkeletonModel.cpp @@ -90,7 +90,6 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) { // Called within Model::simulate call, below. void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { - const HFMModel& hfmModel = getHFMModel(); Head* head = _owningAvatar->getHead(); @@ -230,7 +229,6 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { params.primaryControllerFlags[Rig::PrimaryControllerType_Hips] = (uint8_t)Rig::ControllerFlags::Enabled | (uint8_t)Rig::ControllerFlags::Estimated; // set spine2 if we have hand controllers - //qCDebug(interfaceapp) << "spine 2 joint offset " << jointOffsetMap[13]; if (myAvatar->getControllerPoseInAvatarFrame(controller::Action::RIGHT_HAND).isValid() && myAvatar->getControllerPoseInAvatarFrame(controller::Action::LEFT_HAND).isValid() && !(params.primaryControllerFlags[Rig::PrimaryControllerType_Spine2] & (uint8_t)Rig::ControllerFlags::Enabled)) { @@ -241,7 +239,6 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) { bool spine2Exists = _rig.getAbsoluteJointPoseInRigFrame(_rig.indexOfJoint("Spine2"), currentSpine2Pose); bool headExists = _rig.getAbsoluteJointPoseInRigFrame(_rig.indexOfJoint("Head"), currentHeadPose); bool hipsExists = _rig.getAbsoluteJointPoseInRigFrame(_rig.indexOfJoint("Hips"), currentHipsPose); - if (spine2Exists && headExists && hipsExists) { AnimPose rigSpaceYaw(myAvatar->getSpine2RotationRigSpace()); diff --git a/libraries/animation/src/AnimClip.cpp b/libraries/animation/src/AnimClip.cpp index a3d55726d6..eeac8fadce 100644 --- a/libraries/animation/src/AnimClip.cpp +++ b/libraries/animation/src/AnimClip.cpp @@ -101,10 +101,8 @@ void AnimClip::copyFromNetworkAnim() { // build a mapping from animation joint indices to skeleton joint indices. // by matching joints with the same name. - const HFMModel& hfmModel = _networkAnim->getHFMModel(); AnimSkeleton animSkeleton(hfmModel); - const auto animJointCount = animSkeleton.getNumJoints(); const auto skeletonJointCount = _skeleton->getNumJoints(); std::vector jointMap; diff --git a/libraries/animation/src/AnimSkeleton.cpp b/libraries/animation/src/AnimSkeleton.cpp index 790c898674..85c9999788 100644 --- a/libraries/animation/src/AnimSkeleton.cpp +++ b/libraries/animation/src/AnimSkeleton.cpp @@ -15,76 +15,38 @@ #include #include "AnimationLogging.h" -static bool notBound = true; AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) { - qCDebug(animation) << "in the animSkeleton"; // convert to std::vector of joints std::vector joints; joints.reserve(hfmModel.joints.size()); for (auto& joint : hfmModel.joints) { joints.push_back(joint); } - - glm::quat offset1(0.5f, 0.5f, 0.5f, -0.5f); - glm::quat offset2(0.7071f, 0.0f, -0.7071f, 0.0f); - buildSkeletonFromJoints(joints, hfmModel.jointRotationOffsets); - // add offsets for spine2 and the neck - static bool once = true; - qCDebug(animation) << "the hfm model path is " << hfmModel.originalURL; - //if (once && hfmModel.originalURL == "/angus/avatars/engineer_hifinames/engineer_hifinames/engineer_hifinames.fbx") { - //if (once && hfmModel.originalURL == "/angus/avatars/pei_z_neckNexX_spine2NegY_fwd/pei_z_neckNexX_spine2NegY_fwd/pei_z_neckNexX_spine2NegY_fwd.fbx") { - once = false; - for (int i = 0; i < (int)hfmModel.meshes.size(); i++) { - const HFMMesh& mesh = hfmModel.meshes.at(i); - for (int j = 0; j < mesh.clusters.size(); j++) { + for (int i = 0; i < (int)hfmModel.meshes.size(); i++) { + const HFMMesh& mesh = hfmModel.meshes.at(i); + for (int j = 0; j < mesh.clusters.size(); j++) { - // cast into a non-const reference, so we can mutate the FBXCluster - HFMCluster& cluster = const_cast(mesh.clusters.at(j)); + // cast into a non-const reference, so we can mutate the FBXCluster + HFMCluster& cluster = const_cast(mesh.clusters.at(j)); - // AJT: mutate bind pose! this allows us to oreint the skeleton back into the authored orientaiton before - // rendering, with no runtime overhead. - // this works if clusters match joints one for one. - if (hfmModel.jointRotationOffsets.contains(cluster.jointIndex)) { - qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset2 << " cluster " << cluster.jointIndex; - AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3()); - //AnimPose localOffset(offset2, glm::vec3()); - cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * hfmModel.clusterBindMatrixOriginalValues[i][j]; - qCDebug(animation) << "the new bind matrix num: " << cluster.jointIndex << cluster.inverseBindMatrix; - if ((hfmModel.clusterBindMatrixOriginalValues.size() > i) && (hfmModel.clusterBindMatrixOriginalValues[i].size() > cluster.jointIndex)) { - qCDebug(animation) << "the saved orig matrix num: " << cluster.jointIndex << hfmModel.clusterBindMatrixOriginalValues[i][j]; - } - cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix); + // AJT: mutate bind pose! this allows us to oreint the skeleton back into the authored orientaiton before + // rendering, with no runtime overhead. + if (hfmModel.jointRotationOffsets.contains(cluster.jointIndex)) { + qCDebug(animation) << "found a cluster " << cluster.jointIndex; + AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3()); + cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * hfmModel.clusterBindMatrixOriginalValues[i][j]; + qCDebug(animation) << "the new bind matrix num: " << cluster.jointIndex << cluster.inverseBindMatrix; + if ((hfmModel.clusterBindMatrixOriginalValues.size() > i) && (hfmModel.clusterBindMatrixOriginalValues[i].size() > cluster.jointIndex)) { + qCDebug(animation) << "the saved orig matrix num: " << cluster.jointIndex << hfmModel.clusterBindMatrixOriginalValues[i][j]; } - - /* - - if (cluster.jointIndex == 62) { - qCDebug(animation) << "Neck"; - qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset2 << " cluster " << cluster.jointIndex; - AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3()); - //AnimPose localOffset(offset2, glm::vec3()); - cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix; - cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix); - } - if (cluster.jointIndex == 13) { - qCDebug(animation) << "Spine2"; - qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset1 << " cluster " << cluster.jointIndex; - AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3()); - //AnimPose localOffset(offset1, glm::vec3()); - cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix; - cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix); - } - */ + cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix); } } - //} - - - -} + } +} AnimSkeleton::AnimSkeleton(const std::vector& joints, const QMap jointOffsets) { buildSkeletonFromJoints(joints, jointOffsets); @@ -253,19 +215,15 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector& joints, qCDebug(animation) << "relative default pose for joint " << i << " " << relDefaultPose.trans() << " " << relDefaultPose.rot(); int parentIndex = getParentIndex(i); - AnimPose newAbsPose; if (parentIndex >= 0) { newAbsPose = _absoluteDefaultPoses[parentIndex] * relDefaultPose; - _absoluteDefaultPoses.push_back(newAbsPose); } else { - _absoluteDefaultPoses.push_back(relDefaultPose); } - } - + for (int k = 0; k < _jointsSize; k++) { int parentIndex2 = getParentIndex(k); if (jointOffsets.contains(k)) { @@ -273,19 +231,15 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector& joints, _absoluteDefaultPoses[k] = _absoluteDefaultPoses[k] * localOffset; } if (parentIndex2 >= 0) { - _relativeDefaultPoses.push_back(_absoluteDefaultPoses[parentIndex2].inverse() * _absoluteDefaultPoses[k]); } else { - _relativeDefaultPoses.push_back(_absoluteDefaultPoses[k]); } } - - // re-compute relative poses + // re-compute relative poses //_relativeDefaultPoses = _absoluteDefaultPoses; //convertAbsolutePosesToRelative(_relativeDefaultPoses); - for (int i = 0; i < _jointsSize; i++) { _jointIndicesByName[_joints[i].name] = i; } diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 7a49874abb..da0fe4fe01 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -632,14 +632,10 @@ QMap getJointRotationOffsets(const QVariantHash& mapping) { if (!isNaN(quatX) && !isNaN(quatY) && !isNaN(quatZ) && !isNaN(quatW)) { glm::quat rotationOffset = glm::quat(quatW, quatX, quatY, quatZ); jointRotationOffsets.insert(jointName, rotationOffset); - } } - qCDebug(modelformat) << "found an offset in fst"; } - qCDebug(modelformat) << "found an offset in fst 2"; } - qCDebug(modelformat) << "found an offset in fst 3"; return jointRotationOffsets; } @@ -2031,18 +2027,15 @@ HFMModel* FBXReader::extractHFMModel(const QVariantHash& mapping, const QString& } qCDebug(modelformat) << "Joint Rotation Offset added to Rig._jointRotationOffsets : " << " jointName: " << jointName << " jointIndex: " << jointIndex << " rotation offset: " << rotationOffset; } - //hfmModel.jointRotationOffsets.insert(13, glm::quat(0.5f, 0.5f, 0.5f, -0.5f)); - //hfmModel.jointRotationOffsets.insert(62, glm::quat(0.7071f, 0.0f, -0.7071f, 0.0f)); - + + // create a backup copy of the bindposes, + // these are needed when we recompute the bindpose offsets on reset. for (int i = 0; i < (int)hfmModel.meshes.size(); i++) { const HFMMesh& mesh = hfmModel.meshes.at(i); vector tempBindMat; for (int j = 0; j < mesh.clusters.size(); j++) { const HFMCluster& cluster = mesh.clusters.at(j); tempBindMat.push_back(cluster.inverseBindMatrix); - //if(hfmModel.clusterBindMatrixOriginalValues[i]) - //hfmModel.clusterBindMatrixOriginalValues[i].insert(cluster.jointIndex,Matrices::IDENTITY);// cluster.inverseBindMatrix; - //glm::mat4 testMat = cluster.inverseBindMatrix; } hfmModel.clusterBindMatrixOriginalValues.push_back(tempBindMat); } diff --git a/tools/skeleton-dump/src/SkeletonDumpApp.cpp b/tools/skeleton-dump/src/SkeletonDumpApp.cpp index 2bb5c758ce..10b13aef36 100644 --- a/tools/skeleton-dump/src/SkeletonDumpApp.cpp +++ b/tools/skeleton-dump/src/SkeletonDumpApp.cpp @@ -54,10 +54,8 @@ SkeletonDumpApp::SkeletonDumpApp(int argc, char* argv[]) : QCoreApplication(argc return; } QByteArray blob = file.readAll(); - std::unique_ptr geometry(readFBX(blob, QVariantHash())); std::unique_ptr skeleton(new AnimSkeleton(*geometry)); - skeleton->dump(verbose); }