Fix negative skinning weight
parent
b1984804a9
commit
4eddbaa2b7
|
@ -3,7 +3,6 @@
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QMatrix4x4>
|
#include <QMatrix4x4>
|
||||||
#include <iostream>
|
|
||||||
#include "strokemeshbuilder.h"
|
#include "strokemeshbuilder.h"
|
||||||
#include "strokemodifier.h"
|
#include "strokemodifier.h"
|
||||||
#include "meshrecombiner.h"
|
#include "meshrecombiner.h"
|
||||||
|
@ -1488,13 +1487,6 @@ void MeshGenerator::generate()
|
||||||
|
|
||||||
std::vector<std::pair<QUuid, QUuid>> sourceNodes;
|
std::vector<std::pair<QUuid, QUuid>> sourceNodes;
|
||||||
triangleSourceNodeResolve(*outcome, sourceNodes, &outcome->vertexSourceNodes);
|
triangleSourceNodeResolve(*outcome, sourceNodes, &outcome->vertexSourceNodes);
|
||||||
{
|
|
||||||
for (const auto &it: outcome->vertexSourceNodes) {
|
|
||||||
if (!it.first.isNull() && !it.second.isNull())
|
|
||||||
continue;
|
|
||||||
std::cout << "source node:" << it.first.toString().toUtf8().constData() << " " << it.second.toString().toUtf8().constData() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outcome->setTriangleSourceNodes(sourceNodes);
|
outcome->setTriangleSourceNodes(sourceNodes);
|
||||||
|
|
||||||
std::map<std::pair<QUuid, QUuid>, QColor> sourceNodeToColorMap;
|
std::map<std::pair<QUuid, QUuid>, QColor> sourceNodeToColorMap;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include <QQuaternion>
|
#include <QQuaternion>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <iostream>
|
|
||||||
#include "poser.h"
|
#include "poser.h"
|
||||||
|
|
||||||
Poser::Poser(const std::vector<RiggerBone> &bones) :
|
Poser::Poser(const std::vector<RiggerBone> &bones) :
|
||||||
|
@ -96,12 +95,4 @@ void Poser::fetchChains(const std::vector<QString> &boneNames, std::map<QString,
|
||||||
return first < second;
|
return first < second;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//std::cout << "======= poser begin ================" << std::endl;
|
|
||||||
//for (const auto &chain: chains) {
|
|
||||||
// std::cout << "poser chain:" << chain.first.toUtf8().constData() << std::endl;
|
|
||||||
// for (const auto &it: chain.second) {
|
|
||||||
// std::cout << " poser name:" << it.toUtf8().constData() << std::endl;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//std::cout << "======= poser end ================" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <tbb/parallel_for.h>
|
#include <tbb/parallel_for.h>
|
||||||
#include <tbb/blocked_range.h>
|
#include <tbb/blocked_range.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
|
||||||
#include "projectfacestonodes.h"
|
#include "projectfacestonodes.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <iostream>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "riggenerator.h"
|
#include "riggenerator.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -166,7 +165,6 @@ void RigGenerator::buildNeighborMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::vector<std::tuple<QVector3D, QVector3D, float, float, QColor>> debugBoxes;
|
//std::vector<std::tuple<QVector3D, QVector3D, float, float, QColor>> debugBoxes;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
std::vector<std::unordered_set<size_t>> groups;
|
std::vector<std::unordered_set<size_t>> groups;
|
||||||
groupNodeIndices(m_neighborMap, &groups);
|
groupNodeIndices(m_neighborMap, &groups);
|
||||||
|
@ -422,6 +420,7 @@ void RigGenerator::buildSkeleton()
|
||||||
bone.tailPosition = firstSpineNode.origin;
|
bone.tailPosition = firstSpineNode.origin;
|
||||||
bone.headRadius = 0;
|
bone.headRadius = 0;
|
||||||
bone.tailRadius = firstSpineNode.radius;
|
bone.tailRadius = firstSpineNode.radius;
|
||||||
|
bone.color = Theme::white;
|
||||||
bone.name = QString("Body");
|
bone.name = QString("Body");
|
||||||
bone.index = m_resultBones->size();
|
bone.index = m_resultBones->size();
|
||||||
bone.parent = -1;
|
bone.parent = -1;
|
||||||
|
@ -788,6 +787,8 @@ void RigGenerator::computeBranchSkinWeights(size_t fromBoneIndex,
|
||||||
if (QVector3D::dotProduct(direction, cutNormal) > 0) {
|
if (QVector3D::dotProduct(direction, cutNormal) > 0) {
|
||||||
float angle = radianBetweenVectors(direction, currentDirection);
|
float angle = radianBetweenVectors(direction, currentDirection);
|
||||||
auto projectedLength = std::cos(angle) * (position - currentBone.headPosition).length();
|
auto projectedLength = std::cos(angle) * (position - currentBone.headPosition).length();
|
||||||
|
if (projectedLength < 0)
|
||||||
|
projectedLength = 0;
|
||||||
if (projectedLength <= endGradientLength) {
|
if (projectedLength <= endGradientLength) {
|
||||||
auto factor = 0.5 * (1.0 - projectedLength / endGradientLength);
|
auto factor = 0.5 * (1.0 - projectedLength / endGradientLength);
|
||||||
(*m_resultWeights)[vertexIndex].addBone(previousBoneIndex, factor);
|
(*m_resultWeights)[vertexIndex].addBone(previousBoneIndex, factor);
|
||||||
|
@ -804,6 +805,8 @@ void RigGenerator::computeBranchSkinWeights(size_t fromBoneIndex,
|
||||||
}
|
}
|
||||||
float angle = radianBetweenVectors(direction, -parentDirection);
|
float angle = radianBetweenVectors(direction, -parentDirection);
|
||||||
auto projectedLength = std::cos(angle) * (position - currentBone.headPosition).length();
|
auto projectedLength = std::cos(angle) * (position - currentBone.headPosition).length();
|
||||||
|
if (projectedLength < 0)
|
||||||
|
projectedLength = 0;
|
||||||
if (projectedLength <= endGradientLength) {
|
if (projectedLength <= endGradientLength) {
|
||||||
(*m_resultWeights)[vertexIndex].addBone(previousBoneIndex, 0.5 + 0.5 * projectedLength / endGradientLength);
|
(*m_resultWeights)[vertexIndex].addBone(previousBoneIndex, 0.5 + 0.5 * projectedLength / endGradientLength);
|
||||||
(*m_resultWeights)[vertexIndex].addBone(currentBoneIndex, 0.5 * (1.0 - projectedLength / endGradientLength));
|
(*m_resultWeights)[vertexIndex].addBone(currentBoneIndex, 0.5 * (1.0 - projectedLength / endGradientLength));
|
||||||
|
@ -1039,13 +1042,11 @@ void RigGenerator::buildDemoMesh()
|
||||||
int blendR = 0, blendG = 0, blendB = 0;
|
int blendR = 0, blendG = 0, blendB = 0;
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
int boneIndex = weight.boneIndices[i];
|
int boneIndex = weight.boneIndices[i];
|
||||||
if (boneIndex > 0) {
|
|
||||||
const auto &bone = resultBones[boneIndex];
|
const auto &bone = resultBones[boneIndex];
|
||||||
blendR += bone.color.red() * weight.boneWeights[i];
|
blendR += bone.color.red() * weight.boneWeights[i];
|
||||||
blendG += bone.color.green() * weight.boneWeights[i];
|
blendG += bone.color.green() * weight.boneWeights[i];
|
||||||
blendB += bone.color.blue() * weight.boneWeights[i];
|
blendB += bone.color.blue() * weight.boneWeights[i];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
QColor blendColor = QColor(blendR, blendG, blendB, 255);
|
QColor blendColor = QColor(blendR, blendG, blendB, 255);
|
||||||
inputVerticesColors[vertexIndex] = blendColor;
|
inputVerticesColors[vertexIndex] = blendColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ subject to the following restrictions:
|
||||||
#pragma warning(disable : 4556) // value of intrinsic immediate argument '4294967239' is out of range '0 - 255'
|
#pragma warning(disable : 4556) // value of intrinsic immediate argument '4294967239' is out of range '0 - 255'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BT_SHUFFLE(x, y, z, w) ((w) << 6 | (z) << 4 | (y) << 2 | (x))
|
#define BT_SHUFFLE(x, y, z, w) (((w) << 6 | (z) << 4 | (y) << 2 | (x)) & 0xff)
|
||||||
//#define bt_pshufd_ps( _a, _mask ) (__m128) _mm_shuffle_epi32((__m128i)(_a), (_mask) )
|
//#define bt_pshufd_ps( _a, _mask ) (__m128) _mm_shuffle_epi32((__m128i)(_a), (_mask) )
|
||||||
#define bt_pshufd_ps(_a, _mask) _mm_shuffle_ps((_a), (_a), (_mask))
|
#define bt_pshufd_ps(_a, _mask) _mm_shuffle_ps((_a), (_a), (_mask))
|
||||||
#define bt_splat3_ps(_a, _i) bt_pshufd_ps((_a), BT_SHUFFLE(_i, _i, _i, 3))
|
#define bt_splat3_ps(_a, _i) bt_pshufd_ps((_a), BT_SHUFFLE(_i, _i, _i, 3))
|
||||||
|
|
Loading…
Reference in New Issue