Fix negative skinning weight
parent
b1984804a9
commit
4eddbaa2b7
|
@ -3,7 +3,6 @@
|
|||
#include <QVector2D>
|
||||
#include <QGuiApplication>
|
||||
#include <QMatrix4x4>
|
||||
#include <iostream>
|
||||
#include "strokemeshbuilder.h"
|
||||
#include "strokemodifier.h"
|
||||
#include "meshrecombiner.h"
|
||||
|
@ -1488,13 +1487,6 @@ void MeshGenerator::generate()
|
|||
|
||||
std::vector<std::pair<QUuid, QUuid>> sourceNodes;
|
||||
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);
|
||||
|
||||
std::map<std::pair<QUuid, QUuid>, QColor> sourceNodeToColorMap;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <QQuaternion>
|
||||
#include <QRegularExpression>
|
||||
#include <iostream>
|
||||
#include "poser.h"
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
//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/blocked_range.h>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include "projectfacestonodes.h"
|
||||
#include "util.h"
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <cmath>
|
||||
#include <QVector2D>
|
||||
#include <queue>
|
||||
#include <iostream>
|
||||
#include <unordered_map>
|
||||
#include "riggenerator.h"
|
||||
#include "util.h"
|
||||
|
@ -166,7 +165,6 @@ void RigGenerator::buildNeighborMap()
|
|||
}
|
||||
|
||||
//std::vector<std::tuple<QVector3D, QVector3D, float, float, QColor>> debugBoxes;
|
||||
|
||||
while (true) {
|
||||
std::vector<std::unordered_set<size_t>> groups;
|
||||
groupNodeIndices(m_neighborMap, &groups);
|
||||
|
@ -422,6 +420,7 @@ void RigGenerator::buildSkeleton()
|
|||
bone.tailPosition = firstSpineNode.origin;
|
||||
bone.headRadius = 0;
|
||||
bone.tailRadius = firstSpineNode.radius;
|
||||
bone.color = Theme::white;
|
||||
bone.name = QString("Body");
|
||||
bone.index = m_resultBones->size();
|
||||
bone.parent = -1;
|
||||
|
@ -788,6 +787,8 @@ void RigGenerator::computeBranchSkinWeights(size_t fromBoneIndex,
|
|||
if (QVector3D::dotProduct(direction, cutNormal) > 0) {
|
||||
float angle = radianBetweenVectors(direction, currentDirection);
|
||||
auto projectedLength = std::cos(angle) * (position - currentBone.headPosition).length();
|
||||
if (projectedLength < 0)
|
||||
projectedLength = 0;
|
||||
if (projectedLength <= endGradientLength) {
|
||||
auto factor = 0.5 * (1.0 - projectedLength / endGradientLength);
|
||||
(*m_resultWeights)[vertexIndex].addBone(previousBoneIndex, factor);
|
||||
|
@ -804,6 +805,8 @@ void RigGenerator::computeBranchSkinWeights(size_t fromBoneIndex,
|
|||
}
|
||||
float angle = radianBetweenVectors(direction, -parentDirection);
|
||||
auto projectedLength = std::cos(angle) * (position - currentBone.headPosition).length();
|
||||
if (projectedLength < 0)
|
||||
projectedLength = 0;
|
||||
if (projectedLength <= endGradientLength) {
|
||||
(*m_resultWeights)[vertexIndex].addBone(previousBoneIndex, 0.5 + 0.5 * projectedLength / endGradientLength);
|
||||
(*m_resultWeights)[vertexIndex].addBone(currentBoneIndex, 0.5 * (1.0 - projectedLength / endGradientLength));
|
||||
|
@ -1039,12 +1042,10 @@ void RigGenerator::buildDemoMesh()
|
|||
int blendR = 0, blendG = 0, blendB = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int boneIndex = weight.boneIndices[i];
|
||||
if (boneIndex > 0) {
|
||||
const auto &bone = resultBones[boneIndex];
|
||||
blendR += bone.color.red() * weight.boneWeights[i];
|
||||
blendG += bone.color.green() * weight.boneWeights[i];
|
||||
blendB += bone.color.blue() * weight.boneWeights[i];
|
||||
}
|
||||
const auto &bone = resultBones[boneIndex];
|
||||
blendR += bone.color.red() * weight.boneWeights[i];
|
||||
blendG += bone.color.green() * weight.boneWeights[i];
|
||||
blendB += bone.color.blue() * weight.boneWeights[i];
|
||||
}
|
||||
QColor blendColor = QColor(blendR, blendG, blendB, 255);
|
||||
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'
|
||||
#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) _mm_shuffle_ps((_a), (_a), (_mask))
|
||||
#define bt_splat3_ps(_a, _i) bt_pshufd_ps((_a), BT_SHUFFLE(_i, _i, _i, 3))
|
||||
|
|
Loading…
Reference in New Issue