mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:58:56 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into 21660-updateNitpickForQuest
This commit is contained in:
commit
625e84aa0d
6 changed files with 41 additions and 40 deletions
BIN
.vs/slnx.sqlite
Normal file
BIN
.vs/slnx.sqlite
Normal file
Binary file not shown.
|
@ -37,8 +37,14 @@ sudo apt-get -y install libpulse0 libnss3 libnspr4 libfontconfig1 libxcursor1 li
|
||||||
|
|
||||||
Install build tools:
|
Install build tools:
|
||||||
```bash
|
```bash
|
||||||
|
# For Ubuntu 18.04
|
||||||
sudo apt-get install cmake
|
sudo apt-get install cmake
|
||||||
```
|
```
|
||||||
|
```bash
|
||||||
|
# For Ubuntu 16.04
|
||||||
|
wget https://cmake.org/files/v3.9/cmake-3.9.5-Linux-x86_64.sh
|
||||||
|
sudo sh cmake-3.9.5-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir
|
||||||
|
```
|
||||||
|
|
||||||
Install Python 3:
|
Install Python 3:
|
||||||
```bash
|
```bash
|
||||||
|
@ -61,7 +67,7 @@ git tags
|
||||||
|
|
||||||
Then checkout last tag with:
|
Then checkout last tag with:
|
||||||
```bash
|
```bash
|
||||||
git checkout tags/v0.71.0
|
git checkout tags/v0.79.0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Compiling
|
### Compiling
|
||||||
|
|
|
@ -1043,7 +1043,11 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
cluster.transformLink = createMat4(values);
|
cluster.transformLink = createMat4(values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clusters.insert(getID(object.properties), cluster);
|
|
||||||
|
// skip empty clusters
|
||||||
|
if (cluster.indices.size() > 0 && cluster.weights.size() > 0) {
|
||||||
|
clusters.insert(getID(object.properties), cluster);
|
||||||
|
}
|
||||||
|
|
||||||
} else if (object.properties.last() == "BlendShapeChannel") {
|
} else if (object.properties.last() == "BlendShapeChannel") {
|
||||||
QByteArray name = object.properties.at(1).toByteArray();
|
QByteArray name = object.properties.at(1).toByteArray();
|
||||||
|
@ -1482,8 +1486,8 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we don't have a skinned joint, parent to the model itself
|
// the last cluster is the root cluster
|
||||||
if (extracted.mesh.clusters.isEmpty()) {
|
{
|
||||||
HFMCluster cluster;
|
HFMCluster cluster;
|
||||||
cluster.jointIndex = modelIDs.indexOf(modelID);
|
cluster.jointIndex = modelIDs.indexOf(modelID);
|
||||||
if (cluster.jointIndex == -1) {
|
if (cluster.jointIndex == -1) {
|
||||||
|
@ -1494,13 +1498,11 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
}
|
}
|
||||||
|
|
||||||
// whether we're skinned depends on how many clusters are attached
|
// whether we're skinned depends on how many clusters are attached
|
||||||
const HFMCluster& firstHFMCluster = extracted.mesh.clusters.at(0);
|
|
||||||
glm::mat4 inverseModelTransform = glm::inverse(modelTransform);
|
|
||||||
if (clusterIDs.size() > 1) {
|
if (clusterIDs.size() > 1) {
|
||||||
// this is a multi-mesh joint
|
// this is a multi-mesh joint
|
||||||
const int WEIGHTS_PER_VERTEX = 4;
|
const int WEIGHTS_PER_VERTEX = 4;
|
||||||
int numClusterIndices = extracted.mesh.vertices.size() * WEIGHTS_PER_VERTEX;
|
int numClusterIndices = extracted.mesh.vertices.size() * WEIGHTS_PER_VERTEX;
|
||||||
extracted.mesh.clusterIndices.fill(0, numClusterIndices);
|
extracted.mesh.clusterIndices.fill(extracted.mesh.clusters.size() - 1, numClusterIndices);
|
||||||
QVector<float> weightAccumulators;
|
QVector<float> weightAccumulators;
|
||||||
weightAccumulators.fill(0.0f, numClusterIndices);
|
weightAccumulators.fill(0.0f, numClusterIndices);
|
||||||
|
|
||||||
|
@ -1510,19 +1512,6 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
const HFMCluster& hfmCluster = extracted.mesh.clusters.at(i);
|
const HFMCluster& hfmCluster = extracted.mesh.clusters.at(i);
|
||||||
int jointIndex = hfmCluster.jointIndex;
|
int jointIndex = hfmCluster.jointIndex;
|
||||||
HFMJoint& joint = hfmModel.joints[jointIndex];
|
HFMJoint& joint = hfmModel.joints[jointIndex];
|
||||||
glm::mat4 transformJointToMesh = inverseModelTransform * joint.bindTransform;
|
|
||||||
glm::vec3 boneEnd = extractTranslation(transformJointToMesh);
|
|
||||||
glm::vec3 boneBegin = boneEnd;
|
|
||||||
glm::vec3 boneDirection;
|
|
||||||
float boneLength = 0.0f;
|
|
||||||
if (joint.parentIndex != -1) {
|
|
||||||
boneBegin = extractTranslation(inverseModelTransform * hfmModel.joints[joint.parentIndex].bindTransform);
|
|
||||||
boneDirection = boneEnd - boneBegin;
|
|
||||||
boneLength = glm::length(boneDirection);
|
|
||||||
if (boneLength > EPSILON) {
|
|
||||||
boneDirection /= boneLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 meshToJoint = glm::inverse(joint.bindTransform) * modelTransform;
|
glm::mat4 meshToJoint = glm::inverse(joint.bindTransform) * modelTransform;
|
||||||
ShapeVertices& points = shapeVertices.at(jointIndex);
|
ShapeVertices& points = shapeVertices.at(jointIndex);
|
||||||
|
@ -1535,6 +1524,7 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
int newIndex = it.value();
|
int newIndex = it.value();
|
||||||
|
|
||||||
// remember vertices with at least 1/4 weight
|
// remember vertices with at least 1/4 weight
|
||||||
|
// FIXME: vertices with no weightpainting won't get recorded here
|
||||||
const float EXPANSION_WEIGHT_THRESHOLD = 0.25f;
|
const float EXPANSION_WEIGHT_THRESHOLD = 0.25f;
|
||||||
if (weight >= EXPANSION_WEIGHT_THRESHOLD) {
|
if (weight >= EXPANSION_WEIGHT_THRESHOLD) {
|
||||||
// transform to joint-frame and save for later
|
// transform to joint-frame and save for later
|
||||||
|
@ -1575,20 +1565,24 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
int j = i * WEIGHTS_PER_VERTEX;
|
int j = i * WEIGHTS_PER_VERTEX;
|
||||||
|
|
||||||
// normalize weights into uint16_t
|
// normalize weights into uint16_t
|
||||||
float totalWeight = weightAccumulators[j];
|
float totalWeight = 0.0f;
|
||||||
for (int k = j + 1; k < j + WEIGHTS_PER_VERTEX; ++k) {
|
for (int k = j; k < j + WEIGHTS_PER_VERTEX; ++k) {
|
||||||
totalWeight += weightAccumulators[k];
|
totalWeight += weightAccumulators[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float ALMOST_HALF = 0.499f;
|
||||||
if (totalWeight > 0.0f) {
|
if (totalWeight > 0.0f) {
|
||||||
const float ALMOST_HALF = 0.499f;
|
|
||||||
float weightScalingFactor = (float)(UINT16_MAX) / totalWeight;
|
float weightScalingFactor = (float)(UINT16_MAX) / totalWeight;
|
||||||
for (int k = j; k < j + WEIGHTS_PER_VERTEX; ++k) {
|
for (int k = j; k < j + WEIGHTS_PER_VERTEX; ++k) {
|
||||||
extracted.mesh.clusterWeights[k] = (uint16_t)(weightScalingFactor * weightAccumulators[k] + ALMOST_HALF);
|
extracted.mesh.clusterWeights[k] = (uint16_t)(weightScalingFactor * weightAccumulators[k] + ALMOST_HALF);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
extracted.mesh.clusterWeights[j] = (uint16_t)((float)(UINT16_MAX) + ALMOST_HALF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this is a single-mesh joint
|
// this is a single-joint mesh
|
||||||
|
const HFMCluster& firstHFMCluster = extracted.mesh.clusters.at(0);
|
||||||
int jointIndex = firstHFMCluster.jointIndex;
|
int jointIndex = firstHFMCluster.jointIndex;
|
||||||
HFMJoint& joint = hfmModel.joints[jointIndex];
|
HFMJoint& joint = hfmModel.joints[jointIndex];
|
||||||
|
|
||||||
|
|
|
@ -101,23 +101,24 @@ void PrepareJointsTask::run(const baker::BakeContextPointer& context, const Inpu
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newJointRot) {
|
if (newJointRot) {
|
||||||
for (const auto& jointIn : jointsIn) {
|
for (auto& jointOut : jointsOut) {
|
||||||
|
|
||||||
auto jointNameMapKey = jointNameMapping.key(jointIn.name);
|
auto jointNameMapKey = jointNameMapping.key(jointOut.name);
|
||||||
int mappedIndex = jointIndices.value(jointIn.name);
|
int mappedIndex = jointIndices.value(jointOut.name);
|
||||||
if (jointNameMapping.contains(jointNameMapKey)) {
|
if (jointNameMapping.contains(jointNameMapKey)) {
|
||||||
|
|
||||||
// delete and replace with hifi name
|
// delete and replace with hifi name
|
||||||
jointIndices.remove(jointIn.name);
|
jointIndices.remove(jointOut.name);
|
||||||
jointIndices.insert(jointNameMapKey, mappedIndex);
|
jointOut.name = jointNameMapKey;
|
||||||
|
jointIndices.insert(jointOut.name, mappedIndex);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// nothing mapped to this fbx joint name
|
// nothing mapped to this fbx joint name
|
||||||
if (jointNameMapping.contains(jointIn.name)) {
|
if (jointNameMapping.contains(jointOut.name)) {
|
||||||
// but the name is in the list of hifi names is mapped to a different joint
|
// but the name is in the list of hifi names is mapped to a different joint
|
||||||
int extraIndex = jointIndices.value(jointIn.name);
|
int extraIndex = jointIndices.value(jointOut.name);
|
||||||
jointIndices.remove(jointIn.name);
|
jointIndices.remove(jointOut.name);
|
||||||
jointIndices.insert("", extraIndex);
|
jointOut.name = "";
|
||||||
|
jointIndices.insert(jointOut.name, extraIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ void CauterizedModel::updateRenderItems() {
|
||||||
|
|
||||||
Transform renderTransform = modelTransform;
|
Transform renderTransform = modelTransform;
|
||||||
if (useDualQuaternionSkinning) {
|
if (useDualQuaternionSkinning) {
|
||||||
if (meshState.clusterDualQuaternions.size() == 1) {
|
if (meshState.clusterDualQuaternions.size() == 1 || meshState.clusterDualQuaternions.size() == 2) {
|
||||||
const auto& dq = meshState.clusterDualQuaternions[0];
|
const auto& dq = meshState.clusterDualQuaternions[0];
|
||||||
Transform transform(dq.getRotation(),
|
Transform transform(dq.getRotation(),
|
||||||
dq.getScale(),
|
dq.getScale(),
|
||||||
|
@ -253,7 +253,7 @@ void CauterizedModel::updateRenderItems() {
|
||||||
renderTransform = modelTransform.worldTransform(transform);
|
renderTransform = modelTransform.worldTransform(transform);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (meshState.clusterMatrices.size() == 1) {
|
if (meshState.clusterMatrices.size() == 1 || meshState.clusterMatrices.size() == 2) {
|
||||||
renderTransform = modelTransform.worldTransform(Transform(meshState.clusterMatrices[0]));
|
renderTransform = modelTransform.worldTransform(Transform(meshState.clusterMatrices[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +261,7 @@ void CauterizedModel::updateRenderItems() {
|
||||||
|
|
||||||
renderTransform = modelTransform;
|
renderTransform = modelTransform;
|
||||||
if (useDualQuaternionSkinning) {
|
if (useDualQuaternionSkinning) {
|
||||||
if (cauterizedMeshState.clusterDualQuaternions.size() == 1) {
|
if (cauterizedMeshState.clusterDualQuaternions.size() == 1 || cauterizedMeshState.clusterDualQuaternions.size() == 2) {
|
||||||
const auto& dq = cauterizedMeshState.clusterDualQuaternions[0];
|
const auto& dq = cauterizedMeshState.clusterDualQuaternions[0];
|
||||||
Transform transform(dq.getRotation(),
|
Transform transform(dq.getRotation(),
|
||||||
dq.getScale(),
|
dq.getScale(),
|
||||||
|
@ -269,7 +269,7 @@ void CauterizedModel::updateRenderItems() {
|
||||||
renderTransform = modelTransform.worldTransform(Transform(transform));
|
renderTransform = modelTransform.worldTransform(Transform(transform));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cauterizedMeshState.clusterMatrices.size() == 1) {
|
if (cauterizedMeshState.clusterMatrices.size() == 1 || cauterizedMeshState.clusterMatrices.size() == 2) {
|
||||||
renderTransform = modelTransform.worldTransform(Transform(cauterizedMeshState.clusterMatrices[0]));
|
renderTransform = modelTransform.worldTransform(Transform(cauterizedMeshState.clusterMatrices[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ void Model::updateRenderItems() {
|
||||||
Transform renderTransform = modelTransform;
|
Transform renderTransform = modelTransform;
|
||||||
|
|
||||||
if (useDualQuaternionSkinning) {
|
if (useDualQuaternionSkinning) {
|
||||||
if (meshState.clusterDualQuaternions.size() == 1) {
|
if (meshState.clusterDualQuaternions.size() == 1 || meshState.clusterDualQuaternions.size() == 2) {
|
||||||
const auto& dq = meshState.clusterDualQuaternions[0];
|
const auto& dq = meshState.clusterDualQuaternions[0];
|
||||||
Transform transform(dq.getRotation(),
|
Transform transform(dq.getRotation(),
|
||||||
dq.getScale(),
|
dq.getScale(),
|
||||||
|
@ -255,7 +255,7 @@ void Model::updateRenderItems() {
|
||||||
renderTransform = modelTransform.worldTransform(Transform(transform));
|
renderTransform = modelTransform.worldTransform(Transform(transform));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (meshState.clusterMatrices.size() == 1) {
|
if (meshState.clusterMatrices.size() == 1 || meshState.clusterMatrices.size() == 2) {
|
||||||
renderTransform = modelTransform.worldTransform(Transform(meshState.clusterMatrices[0]));
|
renderTransform = modelTransform.worldTransform(Transform(meshState.clusterMatrices[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue