mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
WIP checkpoint
This commit is contained in:
parent
23affb570b
commit
515d13a4c1
4 changed files with 79 additions and 3 deletions
|
@ -1820,7 +1820,8 @@ void MyAvatar::postUpdate(float deltaTime, const render::ScenePointer& scene) {
|
||||||
|
|
||||||
if (_skeletonModel->isLoaded() && !_skeletonModel->getRig().getAnimNode()) {
|
if (_skeletonModel->isLoaded() && !_skeletonModel->getRig().getAnimNode()) {
|
||||||
initHeadBones();
|
initHeadBones();
|
||||||
_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
// AJT HACK DISABLE CAUTERIZE
|
||||||
|
//_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
||||||
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
||||||
initAnimGraph();
|
initAnimGraph();
|
||||||
_isAnimatingScale = true;
|
_isAnimatingScale = true;
|
||||||
|
@ -1912,7 +1913,9 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) {
|
||||||
// toggle using the cauterizedBones depending on where the camera is and the rendering pass type.
|
// toggle using the cauterizedBones depending on where the camera is and the rendering pass type.
|
||||||
const bool shouldDrawHead = shouldRenderHead(renderArgs);
|
const bool shouldDrawHead = shouldRenderHead(renderArgs);
|
||||||
if (shouldDrawHead != _prevShouldDrawHead) {
|
if (shouldDrawHead != _prevShouldDrawHead) {
|
||||||
_skeletonModel->setEnableCauterization(!shouldDrawHead);
|
// AJT: DISABLE CAUTER
|
||||||
|
// _skeletonModel->setEnableCauterization(!shouldDrawHead);
|
||||||
|
_skeletonModel->setEnableCauterization(false);
|
||||||
|
|
||||||
for (int i = 0; i < _attachmentData.size(); i++) {
|
for (int i = 0; i < _attachmentData.size(); i++) {
|
||||||
if (_attachmentData[i].jointName.compare("Head", Qt::CaseInsensitive) == 0 ||
|
if (_attachmentData[i].jointName.compare("Head", Qt::CaseInsensitive) == 0 ||
|
||||||
|
|
|
@ -69,6 +69,27 @@ AnimPose AnimPose::mirror() const {
|
||||||
return AnimPose(_scale, glm::quat(_rot.w, _rot.x, -_rot.y, -_rot.z), glm::vec3(-_trans.x, _trans.y, _trans.z));
|
return AnimPose(_scale, glm::quat(_rot.w, _rot.x, -_rot.y, -_rot.z), glm::vec3(-_trans.x, _trans.y, _trans.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AnimPose::fuzzyEqual(const AnimPose& rhs) const {
|
||||||
|
const float SCALE_EPSILON = 0.00001f;
|
||||||
|
const float ROT_EPSILON = 0.00001f;
|
||||||
|
const float TRANS_EPSILON = 0.001f;
|
||||||
|
if ((fabsf(rhs._scale.x - _scale.x) < SCALE_EPSILON) &&
|
||||||
|
(fabsf(rhs._scale.y - _scale.y) < SCALE_EPSILON) &&
|
||||||
|
(fabsf(rhs._scale.z - _scale.z) < SCALE_EPSILON)) {
|
||||||
|
if ((fabsf(rhs._rot.x - _rot.x) < ROT_EPSILON) &&
|
||||||
|
(fabsf(rhs._rot.y - _rot.y) < ROT_EPSILON) &&
|
||||||
|
(fabsf(rhs._rot.z - _rot.z) < ROT_EPSILON) &&
|
||||||
|
(fabsf(rhs._rot.w - _rot.w) < ROT_EPSILON)) {
|
||||||
|
if ((fabsf(rhs._trans.x - _trans.x) < TRANS_EPSILON) &&
|
||||||
|
(fabsf(rhs._trans.y - _trans.y) < TRANS_EPSILON) &&
|
||||||
|
(fabsf(rhs._trans.z - _trans.z) < TRANS_EPSILON)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
AnimPose::operator glm::mat4() const {
|
AnimPose::operator glm::mat4() const {
|
||||||
glm::vec3 xAxis = _rot * glm::vec3(_scale.x, 0.0f, 0.0f);
|
glm::vec3 xAxis = _rot * glm::vec3(_scale.x, 0.0f, 0.0f);
|
||||||
glm::vec3 yAxis = _rot * glm::vec3(0.0f, _scale.y, 0.0f);
|
glm::vec3 yAxis = _rot * glm::vec3(0.0f, _scale.y, 0.0f);
|
||||||
|
@ -76,3 +97,5 @@ AnimPose::operator glm::mat4() const {
|
||||||
return glm::mat4(glm::vec4(xAxis, 0.0f), glm::vec4(yAxis, 0.0f),
|
return glm::mat4(glm::vec4(xAxis, 0.0f), glm::vec4(yAxis, 0.0f),
|
||||||
glm::vec4(zAxis, 0.0f), glm::vec4(_trans, 1.0f));
|
glm::vec4(zAxis, 0.0f), glm::vec4(_trans, 1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ public:
|
||||||
const glm::vec3& trans() const { return _trans; }
|
const glm::vec3& trans() const { return _trans; }
|
||||||
glm::vec3& trans() { return _trans; }
|
glm::vec3& trans() { return _trans; }
|
||||||
|
|
||||||
|
bool fuzzyEqual(const AnimPose& rhs) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend QDebug operator<<(QDebug debug, const AnimPose& pose);
|
friend QDebug operator<<(QDebug debug, const AnimPose& pose);
|
||||||
glm::vec3 _scale { 1.0f };
|
glm::vec3 _scale { 1.0f };
|
||||||
|
|
|
@ -104,6 +104,12 @@ void CauterizedModel::updateClusterMatrices() {
|
||||||
_needsUpdateClusterMatrices = false;
|
_needsUpdateClusterMatrices = false;
|
||||||
const FBXGeometry& geometry = getFBXGeometry();
|
const FBXGeometry& geometry = getFBXGeometry();
|
||||||
|
|
||||||
|
bool debug = false;
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
qDebug() << "AJT: CauterizedModel::updateClusterMatrices(), url =" << _url;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < (int)_meshStates.size(); i++) {
|
for (int i = 0; i < (int)_meshStates.size(); i++) {
|
||||||
Model::MeshState& state = _meshStates[i];
|
Model::MeshState& state = _meshStates[i];
|
||||||
const FBXMesh& mesh = geometry.meshes.at(i);
|
const FBXMesh& mesh = geometry.meshes.at(i);
|
||||||
|
@ -117,8 +123,14 @@ void CauterizedModel::updateClusterMatrices() {
|
||||||
glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterMatrices[j]);
|
glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterMatrices[j]);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SKIN_COMP
|
#ifdef SKIN_COMP
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
qDebug() << "AJT: _meshState[" << i << "], cluster[" << j << "]";
|
||||||
|
}
|
||||||
|
|
||||||
AnimPose jointPose = _rig.getJointPose(cluster.jointIndex);
|
AnimPose jointPose = _rig.getJointPose(cluster.jointIndex);
|
||||||
AnimPose result = jointPose * AnimPose(cluster.inverseBindMatrix);
|
AnimPose result = jointPose * AnimPose(cluster.inverseBindMatrix);
|
||||||
|
result.rot() = glm::normalize(result.rot());
|
||||||
|
|
||||||
// pack scale rotation and translation into a mat4.
|
// pack scale rotation and translation into a mat4.
|
||||||
state.clusterMatrices[j][0].x = result.scale().x;
|
state.clusterMatrices[j][0].x = result.scale().x;
|
||||||
|
@ -133,6 +145,18 @@ void CauterizedModel::updateClusterMatrices() {
|
||||||
state.clusterMatrices[j][2].x = result.trans().x;
|
state.clusterMatrices[j][2].x = result.trans().x;
|
||||||
state.clusterMatrices[j][2].y = result.trans().y;
|
state.clusterMatrices[j][2].y = result.trans().y;
|
||||||
state.clusterMatrices[j][2].z = result.trans().z;
|
state.clusterMatrices[j][2].z = result.trans().z;
|
||||||
|
|
||||||
|
// AJT REMOVE
|
||||||
|
if (debug) {
|
||||||
|
glm::mat4 jointMatrix = _rig.getJointTransform(cluster.jointIndex);
|
||||||
|
glm::mat4 m;
|
||||||
|
glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, m);
|
||||||
|
qDebug() << "AJT: m =" << m;
|
||||||
|
qDebug() << "AJT: (AnimPose)m =" << AnimPose(m);
|
||||||
|
qDebug() << "AJT: result =" << result;
|
||||||
|
qDebug() << "AJT: (mat4)result =" << (glm::mat4)result;
|
||||||
|
SKIN_ASSERT(result.fuzzyEqual(AnimPose(m)));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +170,6 @@ void CauterizedModel::updateClusterMatrices() {
|
||||||
glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),
|
glm::vec4(0.0f, 0.0f, 0.0f, 0.0f),
|
||||||
glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
auto cauterizeMatrix = _rig.getJointTransform(geometry.neckJointIndex) * zeroScale;
|
auto cauterizeMatrix = _rig.getJointTransform(geometry.neckJointIndex) * zeroScale;
|
||||||
auto cauterizePose = AnimPose(cauterizeMatrix);
|
|
||||||
|
|
||||||
for (int i = 0; i < _cauterizeMeshStates.size(); i++) {
|
for (int i = 0; i < _cauterizeMeshStates.size(); i++) {
|
||||||
Model::MeshState& state = _cauterizeMeshStates[i];
|
Model::MeshState& state = _cauterizeMeshStates[i];
|
||||||
|
@ -164,11 +187,19 @@ void CauterizedModel::updateClusterMatrices() {
|
||||||
glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterMatrices[j]);
|
glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterMatrices[j]);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SKIN_COMP
|
#ifdef SKIN_COMP
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
qDebug() << "AJT: CAUTERIZED _meshState[" << i << "], cluster[" << j << "]";
|
||||||
|
}
|
||||||
|
|
||||||
auto jointPose = _rig.getJointPose(cluster.jointIndex);
|
auto jointPose = _rig.getJointPose(cluster.jointIndex);
|
||||||
|
/*
|
||||||
if (_cauterizeBoneSet.find(cluster.jointIndex) != _cauterizeBoneSet.end()) {
|
if (_cauterizeBoneSet.find(cluster.jointIndex) != _cauterizeBoneSet.end()) {
|
||||||
jointPose = cauterizePose;
|
jointPose = cauterizePose;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
AnimPose result = jointPose * AnimPose(cluster.inverseBindMatrix);
|
AnimPose result = jointPose * AnimPose(cluster.inverseBindMatrix);
|
||||||
|
result.rot() = glm::normalize(result.rot());
|
||||||
|
|
||||||
// pack scale rotation and translation into a mat4.
|
// pack scale rotation and translation into a mat4.
|
||||||
state.clusterMatrices[j][0].x = result.scale().x;
|
state.clusterMatrices[j][0].x = result.scale().x;
|
||||||
|
@ -183,6 +214,23 @@ void CauterizedModel::updateClusterMatrices() {
|
||||||
state.clusterMatrices[j][2].x = result.trans().x;
|
state.clusterMatrices[j][2].x = result.trans().x;
|
||||||
state.clusterMatrices[j][2].y = result.trans().y;
|
state.clusterMatrices[j][2].y = result.trans().y;
|
||||||
state.clusterMatrices[j][2].z = result.trans().z;
|
state.clusterMatrices[j][2].z = result.trans().z;
|
||||||
|
|
||||||
|
// AJT REMOVE
|
||||||
|
auto jointMatrix = _rig.getJointTransform(cluster.jointIndex);
|
||||||
|
/*
|
||||||
|
if (_cauterizeBoneSet.find(cluster.jointIndex) != _cauterizeBoneSet.end()) {
|
||||||
|
jointMatrix = cauterizeMatrix;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (debug) {
|
||||||
|
glm::mat4 m;
|
||||||
|
glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, m);
|
||||||
|
qDebug() << "AJT: m =" << m;
|
||||||
|
qDebug() << "AJT: (AnimPose)m =" << AnimPose(m);
|
||||||
|
qDebug() << "AJT: result =" << result;
|
||||||
|
qDebug() << "AJT: (mat4)result =" << (glm::mat4)result;
|
||||||
|
SKIN_ASSERT(result.fuzzyEqual(AnimPose(m)));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue