mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 14:58:03 +02:00
Fix code style / remove cruft
This commit is contained in:
parent
769a332d22
commit
516debdcb2
10 changed files with 23 additions and 125 deletions
|
@ -24,13 +24,13 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
|
||||||
|
|
||||||
// we make a copy of the inverseBindMatrices in order to prevent mutating the model bind pose
|
// we make a copy of the inverseBindMatrices in order to prevent mutating the model bind pose
|
||||||
// when we are dealing with a joint offset in the model
|
// when we are dealing with a joint offset in the model
|
||||||
for (int i = 0; i < (int)hfmModel.skinDeformers.size(); i++) {
|
for (uint32_t i = 0; i < (uint32_t)hfmModel.skinDeformers.size(); i++) {
|
||||||
const auto& defor = hfmModel.skinDeformers[i];
|
const auto& deformer = hfmModel.skinDeformers[i];
|
||||||
std::vector<HFMCluster> dummyClustersList;
|
std::vector<HFMCluster> dummyClustersList;
|
||||||
|
|
||||||
for (uint32_t j = 0; j < (uint32_t)defor.clusters.size(); j++) {
|
for (uint32_t j = 0; j < (uint32_t)deformer.clusters.size(); j++) {
|
||||||
// cast into a non-const reference, so we can mutate the FBXCluster
|
// cast into a non-const reference, so we can mutate the FBXCluster
|
||||||
HFMCluster& cluster = const_cast<HFMCluster&>(defor.clusters.at(j));
|
HFMCluster& cluster = const_cast<HFMCluster&>(deformer.clusters.at(j));
|
||||||
|
|
||||||
HFMCluster localCluster;
|
HFMCluster localCluster;
|
||||||
localCluster.jointIndex = cluster.jointIndex;
|
localCluster.jointIndex = cluster.jointIndex;
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
void dump(const AnimPoseVec& poses) const;
|
void dump(const AnimPoseVec& poses) const;
|
||||||
|
|
||||||
std::vector<int> lookUpJointIndices(const std::vector<QString>& jointNames) const;
|
std::vector<int> lookUpJointIndices(const std::vector<QString>& jointNames) const;
|
||||||
const HFMCluster getClusterBindMatricesOriginalValues(const int skinDeformerIndex, const int clusterIndex) const { return _clusterBindMatrixOriginalValues[skinDeformerIndex][clusterIndex]; }
|
const HFMCluster getClusterBindMatricesOriginalValues(int skinDeformerIndex, int clusterIndex) const { return _clusterBindMatrixOriginalValues[skinDeformerIndex][clusterIndex]; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void buildSkeletonFromJoints(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets);
|
void buildSkeletonFromJoints(const std::vector<HFMJoint>& joints, const QMap<int, glm::quat> jointOffsets);
|
||||||
|
|
|
@ -260,7 +260,7 @@ void MaterialBaker::addTexture(const QString& materialName, image::TextureUsage:
|
||||||
|
|
||||||
void MaterialBaker::setMaterials(const std::vector<hfm::Material>& materials, const QString& baseURL) {
|
void MaterialBaker::setMaterials(const std::vector<hfm::Material>& materials, const QString& baseURL) {
|
||||||
_materialResource = NetworkMaterialResourcePointer(new NetworkMaterialResource(), [](NetworkMaterialResource* ptr) { ptr->deleteLater(); });
|
_materialResource = NetworkMaterialResourcePointer(new NetworkMaterialResource(), [](NetworkMaterialResource* ptr) { ptr->deleteLater(); });
|
||||||
for (auto& material : materials) {
|
for (const auto& material : materials) {
|
||||||
_materialResource->parsedMaterials.names.push_back(material.name.toStdString());
|
_materialResource->parsedMaterials.names.push_back(material.name.toStdString());
|
||||||
_materialResource->parsedMaterials.networkMaterials[material.name.toStdString()] = std::make_shared<NetworkMaterial>(material, baseURL);
|
_materialResource->parsedMaterials.networkMaterials[material.name.toStdString()] = std::make_shared<NetworkMaterial>(material, baseURL);
|
||||||
|
|
||||||
|
|
|
@ -403,19 +403,11 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
numIndices -= numIndices % TRIANGLE_STRIDE; // WORKAROUND lack of sanity checking in FBXSerializer
|
numIndices -= numIndices % TRIANGLE_STRIDE; // WORKAROUND lack of sanity checking in FBXSerializer
|
||||||
uint32_t indexStart = (uint32_t)part.x;
|
uint32_t indexStart = (uint32_t)part.x;
|
||||||
uint32_t indexEnd = indexStart + numIndices;
|
uint32_t indexEnd = indexStart + numIndices;
|
||||||
for (uint32_t j = indexStart; j < indexEnd; j += TRIANGLE_STRIDE) {
|
for (uint32_t j = indexStart; j < indexEnd; ++j) {
|
||||||
// NOTE: It seems odd to skip vertices when initializing a btConvexHullShape, but let's keep the behavior similar to the old behavior for now
|
// NOTE: It seems odd to skip vertices when initializing a btConvexHullShape, but let's keep the behavior similar to the old behavior for now
|
||||||
glm::vec3 p0 = triangleListMesh.vertices[triangleListMesh.indices[j]];
|
glm::vec3 point = triangleListMesh.vertices[triangleListMesh.indices[j]];
|
||||||
glm::vec3 p1 = triangleListMesh.vertices[triangleListMesh.indices[j + 1]];
|
if (std::find(pointsInPart.cbegin(), pointsInPart.cend(), point) == pointsInPart.cend()) {
|
||||||
glm::vec3 p2 = triangleListMesh.vertices[triangleListMesh.indices[j + 2]];
|
pointsInPart.push_back(point);
|
||||||
if (std::find(pointsInPart.cbegin(), pointsInPart.cend(), p0) == pointsInPart.cend()) {
|
|
||||||
pointsInPart.push_back(p0);
|
|
||||||
}
|
|
||||||
if (std::find(pointsInPart.cbegin(), pointsInPart.cend(), p1) == pointsInPart.cend()) {
|
|
||||||
pointsInPart.push_back(p1);
|
|
||||||
}
|
|
||||||
if (std::find(pointsInPart.cbegin(), pointsInPart.cend(), p2) == pointsInPart.cend()) {
|
|
||||||
pointsInPart.push_back(p2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1462,7 +1462,7 @@ HFMModel* FBXSerializer::extractHFMModel(const hifi::VariantHash& mapping, const
|
||||||
const auto& partMaterialTextures = extracted.partMaterialTextures;
|
const auto& partMaterialTextures = extracted.partMaterialTextures;
|
||||||
|
|
||||||
uint32_t meshIndex = (uint32_t)hfmModel.meshes.size();
|
uint32_t meshIndex = (uint32_t)hfmModel.meshes.size();
|
||||||
meshIDsToMeshIndices.insert(it.key(), meshIndex);
|
meshIDsToMeshIndices.insert(meshID, meshIndex);
|
||||||
hfmModel.meshes.push_back(extracted.mesh);
|
hfmModel.meshes.push_back(extracted.mesh);
|
||||||
hfm::Mesh& mesh = hfmModel.meshes.back();
|
hfm::Mesh& mesh = hfmModel.meshes.back();
|
||||||
|
|
||||||
|
@ -1635,8 +1635,8 @@ HFMModel* FBXSerializer::extractHFMModel(const hifi::VariantHash& mapping, const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the model's dynamic transform, and put its ID in the shapes
|
// Store the model's dynamic transform, and put its ID in the shapes
|
||||||
|
uint32_t skinDeformerID = (uint32_t)hfmModel.skinDeformers.size();
|
||||||
hfmModel.skinDeformers.push_back(skinDeformer);
|
hfmModel.skinDeformers.push_back(skinDeformer);
|
||||||
uint32_t skinDeformerID = (uint32_t)(hfmModel.skinDeformers.size() - 1);
|
|
||||||
for (hfm::Shape& shape : partShapes) {
|
for (hfm::Shape& shape : partShapes) {
|
||||||
shape.skinDeformer = skinDeformerID;
|
shape.skinDeformer = skinDeformerID;
|
||||||
}
|
}
|
||||||
|
|
|
@ -701,9 +701,9 @@ HFMModel::Pointer OBJSerializer::read(const hifi::ByteArray& data, const hifi::V
|
||||||
|
|
||||||
QMap<QString, int> materialMeshIdMap;
|
QMap<QString, int> materialMeshIdMap;
|
||||||
std::vector<HFMMeshPart> hfmMeshParts;
|
std::vector<HFMMeshPart> hfmMeshParts;
|
||||||
for (uint32_t i = 0, meshPartCount = 0; i < (uint32_t)mesh.parts.size(); i++, meshPartCount++) {
|
for (uint32_t meshPartIndex = 0; meshPartIndex < (uint32_t)mesh.parts.size(); ++meshPartIndex) {
|
||||||
HFMMeshPart& meshPart = mesh.parts[i];
|
HFMMeshPart& meshPart = mesh.parts[meshPartIndex];
|
||||||
FaceGroup faceGroup = faceGroups[meshPartCount];
|
FaceGroup faceGroup = faceGroups[meshPartIndex];
|
||||||
bool specifiesUV = false;
|
bool specifiesUV = false;
|
||||||
foreach(OBJFace face, faceGroup) {
|
foreach(OBJFace face, faceGroup) {
|
||||||
// Go through all of the OBJ faces and determine the number of different materials necessary (each different material will be a unique mesh).
|
// Go through all of the OBJ faces and determine the number of different materials necessary (each different material will be a unique mesh).
|
||||||
|
@ -758,8 +758,8 @@ HFMModel::Pointer OBJSerializer::read(const hifi::ByteArray& data, const hifi::V
|
||||||
mesh.parts.clear();
|
mesh.parts.clear();
|
||||||
mesh.parts = hfmMeshParts;
|
mesh.parts = hfmMeshParts;
|
||||||
|
|
||||||
for (uint32_t i = 0, meshPartCount = 0; i < unmodifiedMeshPartCount; i++, meshPartCount++) {
|
for (uint32_t meshPartIndex = 0; meshPartIndex < unmodifiedMeshPartCount; meshPartIndex++) {
|
||||||
FaceGroup faceGroup = faceGroups[meshPartCount];
|
FaceGroup faceGroup = faceGroups[meshPartIndex];
|
||||||
|
|
||||||
// Now that each mesh has been created with its own unique material mappings, fill them with data (vertex data is duplicated, face data is not).
|
// Now that each mesh has been created with its own unique material mappings, fill them with data (vertex data is duplicated, face data is not).
|
||||||
foreach(OBJFace face, faceGroup) {
|
foreach(OBJFace face, faceGroup) {
|
||||||
|
|
|
@ -189,7 +189,7 @@ bool Model::shouldInvalidatePayloadShapeKey(int meshIndex) {
|
||||||
const auto& networkMeshes = getNetworkModel()->getMeshes();
|
const auto& networkMeshes = getNetworkModel()->getMeshes();
|
||||||
// if our index is ever out of range for either meshes or networkMeshes, then skip it, and set our _meshGroupsKnown
|
// if our index is ever out of range for either meshes or networkMeshes, then skip it, and set our _meshGroupsKnown
|
||||||
// to false to rebuild out mesh groups.
|
// to false to rebuild out mesh groups.
|
||||||
if (meshIndex < 0 || meshIndex >= (int)networkMeshes.size() || meshIndex >= (int)hfmModel.meshes.size() /* || meshIndex >= (int)_meshStates.size()*/) {
|
if (meshIndex < 0 || meshIndex >= (int)networkMeshes.size() || meshIndex >= (int)hfmModel.meshes.size()) {
|
||||||
_needsFixupInScene = true; // trigger remove/add cycle
|
_needsFixupInScene = true; // trigger remove/add cycle
|
||||||
invalidCalculatedMeshBoxes(); // if we have to reload, we need to assume our mesh boxes are all invalid
|
invalidCalculatedMeshBoxes(); // if we have to reload, we need to assume our mesh boxes are all invalid
|
||||||
return true;
|
return true;
|
||||||
|
@ -252,9 +252,6 @@ void Model::updateRenderItems() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform renderTransform = modelTransform;
|
Transform renderTransform = modelTransform;
|
||||||
// if (meshState.clusterMatrices.size() <= 1) {
|
|
||||||
// renderTransform = modelTransform.worldTransform(shapeState._rootFromJointTransform);
|
|
||||||
// }
|
|
||||||
data.updateTransform(renderTransform);
|
data.updateTransform(renderTransform);
|
||||||
data.updateTransformAndBound(modelTransform.worldTransform(shapeState._rootFromJointTransform));
|
data.updateTransformAndBound(modelTransform.worldTransform(shapeState._rootFromJointTransform));
|
||||||
|
|
||||||
|
@ -299,7 +296,6 @@ void Model::reset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::updateShapeStatesFromRig() {
|
void Model::updateShapeStatesFromRig() {
|
||||||
{ // Shapes state:
|
|
||||||
for (auto& shape : _shapeStates) {
|
for (auto& shape : _shapeStates) {
|
||||||
uint32_t jointId = shape._jointIndex;
|
uint32_t jointId = shape._jointIndex;
|
||||||
if (jointId < (uint32_t) _rig.getJointStateCount()) {
|
if (jointId < (uint32_t) _rig.getJointStateCount()) {
|
||||||
|
@ -307,7 +303,6 @@ void Model::updateShapeStatesFromRig() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool Model::updateGeometry() {
|
bool Model::updateGeometry() {
|
||||||
bool needFullUpdate = false;
|
bool needFullUpdate = false;
|
||||||
|
|
|
@ -61,8 +61,7 @@ void SoftAttachmentModel::updateClusterMatrices() {
|
||||||
Transform clusterTransform;
|
Transform clusterTransform;
|
||||||
Transform::mult(clusterTransform, jointTransform, cbmov.inverseBindTransform);
|
Transform::mult(clusterTransform, jointTransform, cbmov.inverseBindTransform);
|
||||||
state.clusterDualQuaternions[clusterIndex] = Model::TransformDualQuaternion(clusterTransform);
|
state.clusterDualQuaternions[clusterIndex] = Model::TransformDualQuaternion(clusterTransform);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
auto jointMatrix = rig->getJointTransform(cbmov.jointIndex);
|
auto jointMatrix = rig->getJointTransform(cbmov.jointIndex);
|
||||||
glm_mat4u_mul(jointMatrix, cbmov.inverseBindMatrix, state.clusterMatrices[clusterIndex]);
|
glm_mat4u_mul(jointMatrix, cbmov.inverseBindMatrix, state.clusterMatrices[clusterIndex]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
set(TARGET_NAME fbx-test)
|
|
||||||
# This is not a testcase -- just set it up as a regular hifi project
|
|
||||||
setup_hifi_project(Quick Gui)
|
|
||||||
setup_memory_debugger()
|
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
|
||||||
|
|
||||||
file(GLOB_RECURSE GLB_TEST_FILES "c:/Users/bdavi/git/glTF-Sample-Models/2.0/*.glb")
|
|
||||||
list(JOIN GLB_TEST_FILES "|" GLB_TEST_FILES)
|
|
||||||
target_compile_definitions(${TARGET_NAME} PRIVATE -DGLB_TEST_FILES="${GLB_TEST_FILES}")
|
|
||||||
link_hifi_libraries(shared graphics networking image gpu hfm fbx)
|
|
||||||
package_libraries_for_deployment()
|
|
|
@ -1,77 +0,0 @@
|
||||||
//
|
|
||||||
// Created by Bradley Austin Davis on 2018/01/11
|
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
|
||||||
#include <QtCore/QFile>
|
|
||||||
|
|
||||||
#include <QtGui/QGuiApplication>
|
|
||||||
|
|
||||||
#include <GLTFSerializer.h>
|
|
||||||
#include <shared/FileUtils.h>
|
|
||||||
#include <ResourceManager.h>
|
|
||||||
#include <DependencyManager.h>
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
// Currently only used by testing code
|
|
||||||
inline std::list<std::string> splitString(const std::string& source, const char delimiter = ' ') {
|
|
||||||
std::list<std::string> result;
|
|
||||||
size_t start = 0, next;
|
|
||||||
|
|
||||||
while (std::string::npos != (next = source.find(delimiter, start))) {
|
|
||||||
std::string sub = source.substr(start, next - start);
|
|
||||||
if (!sub.empty()) {
|
|
||||||
result.push_back(sub);
|
|
||||||
}
|
|
||||||
start = next + 1;
|
|
||||||
}
|
|
||||||
if (source.size() > start) {
|
|
||||||
result.push_back(source.substr(start));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<std::string> getGlbTestFiles() {
|
|
||||||
return splitString(GLB_TEST_FILES, '|');
|
|
||||||
}
|
|
||||||
|
|
||||||
QtMessageHandler originalHandler;
|
|
||||||
|
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
OutputDebugStringA(message.toStdString().c_str());
|
|
||||||
OutputDebugStringA("\n");
|
|
||||||
#endif
|
|
||||||
originalHandler(type, context, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray readFileBytes(const std::string& filename) {
|
|
||||||
QFile file(filename.c_str());
|
|
||||||
file.open(QFile::ReadOnly);
|
|
||||||
QByteArray result = file.readAll();
|
|
||||||
file.close();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void processFile(const std::string& filename) {
|
|
||||||
qDebug() << filename.c_str();
|
|
||||||
GLTFSerializer().read(readFileBytes(filename), {}, QUrl::fromLocalFile(filename.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
|
||||||
QCoreApplication app{ argc, argv };
|
|
||||||
originalHandler = qInstallMessageHandler(messageHandler);
|
|
||||||
|
|
||||||
DependencyManager::set<ResourceManager>(false);
|
|
||||||
|
|
||||||
//processFile("c:/Users/bdavi/git/glTF-Sample-Models/2.0/Box/glTF-Binary/Box.glb");
|
|
||||||
|
|
||||||
for (const auto& testFile : getGlbTestFiles()) {
|
|
||||||
processFile(testFile);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue