mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 09:29:02 +02:00
Make shape extent calculations use slim mesh extents, and rename task to CalculateTransformedExtentsTask
This commit is contained in:
parent
df4ca90d49
commit
d9e441d65e
5 changed files with 21 additions and 27 deletions
|
@ -54,22 +54,16 @@ void calculateExtentsForTriangleListMesh(TriangleListMesh& triangleListMesh) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void calculateExtentsForShape(hfm::Shape& shape, const std::vector<hfm::Mesh>& meshes, const std::vector<hfm::Joint> joints) {
|
void calculateExtentsForShape(hfm::Shape& shape, const std::vector<hfm::TriangleListMesh>& triangleListMeshes, const std::vector<hfm::Joint>& joints) {
|
||||||
auto& shapeExtents = shape.transformedExtents;
|
auto& shapeExtents = shape.transformedExtents;
|
||||||
shapeExtents.reset();
|
shapeExtents.reset();
|
||||||
|
|
||||||
const auto& mesh = meshes[shape.mesh];
|
const auto& triangleListMesh = triangleListMeshes[shape.mesh];
|
||||||
const auto& meshPart = mesh.parts[shape.meshPart];
|
const auto& partExtent = triangleListMesh.partExtents[shape.meshPart];
|
||||||
|
|
||||||
glm::mat4 transform = joints[shape.joint].transform;
|
const glm::mat4& transform = joints[shape.joint].transform;
|
||||||
forEachIndex(meshPart, [&](int32_t idx){
|
shapeExtents = partExtent;
|
||||||
if (mesh.vertices.size() <= idx) {
|
shapeExtents.transform(transform);
|
||||||
return;
|
|
||||||
}
|
|
||||||
const glm::vec3& vertex = mesh.vertices[idx];
|
|
||||||
const glm::vec3 transformedVertex = glm::vec3(transform * glm::vec4(vertex, 1.0f));
|
|
||||||
shapeExtents.addPoint(transformedVertex);
|
|
||||||
});
|
|
||||||
|
|
||||||
thickenFlatExtents(shapeExtents);
|
thickenFlatExtents(shapeExtents);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ void initializeExtents(Extents& extents);
|
||||||
void calculateExtentsForTriangleListMesh(TriangleListMesh& triangleListMesh);
|
void calculateExtentsForTriangleListMesh(TriangleListMesh& triangleListMesh);
|
||||||
|
|
||||||
// This can't be moved to model-baker until
|
// This can't be moved to model-baker until
|
||||||
void calculateExtentsForShape(hfm::Shape& shape, const std::vector<hfm::Mesh>& meshes, const std::vector<hfm::Joint> joints);
|
void calculateExtentsForShape(hfm::Shape& shape, const std::vector<hfm::TriangleListMesh>& triangleListMeshes, const std::vector<hfm::Joint>& joints);
|
||||||
|
|
||||||
void calculateExtentsForModel(Extents& modelExtents, const std::vector<hfm::Shape>& shapes);
|
void calculateExtentsForModel(Extents& modelExtents, const std::vector<hfm::Shape>& shapes);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "CalculateBlendshapeNormalsTask.h"
|
#include "CalculateBlendshapeNormalsTask.h"
|
||||||
#include "CalculateBlendshapeTangentsTask.h"
|
#include "CalculateBlendshapeTangentsTask.h"
|
||||||
#include "PrepareJointsTask.h"
|
#include "PrepareJointsTask.h"
|
||||||
#include "CalculateExtentsTask.h"
|
#include "CalculateTransformedExtentsTask.h"
|
||||||
#include "BuildDracoMeshTask.h"
|
#include "BuildDracoMeshTask.h"
|
||||||
#include "ParseFlowDataTask.h"
|
#include "ParseFlowDataTask.h"
|
||||||
#include <hfm/HFMModelMath.h>
|
#include <hfm/HFMModelMath.h>
|
||||||
|
@ -200,10 +200,10 @@ namespace baker {
|
||||||
const auto jointIndices = jointInfoOut.getN<PrepareJointsTask::Output>(2);
|
const auto jointIndices = jointInfoOut.getN<PrepareJointsTask::Output>(2);
|
||||||
|
|
||||||
// Use transform information to compute extents
|
// Use transform information to compute extents
|
||||||
const auto calculateExtentsInputs = CalculateExtentsTask::Input(modelExtentsIn, meshesIn, shapesIn, jointsOut).asVarying();
|
const auto calculateExtentsInputs = CalculateTransformedExtentsTask::Input(modelExtentsIn, triangleListMeshes, shapesIn, jointsOut).asVarying();
|
||||||
const auto calculateExtentsOutputs = model.addJob<CalculateExtentsTask>("CalculateExtents", calculateExtentsInputs);
|
const auto calculateExtentsOutputs = model.addJob<CalculateTransformedExtentsTask>("CalculateExtents", calculateExtentsInputs);
|
||||||
const auto modelExtentsOut = calculateExtentsOutputs.getN<CalculateExtentsTask::Output>(0);
|
const auto modelExtentsOut = calculateExtentsOutputs.getN<CalculateTransformedExtentsTask::Output>(0);
|
||||||
const auto shapesOut = calculateExtentsOutputs.getN<CalculateExtentsTask::Output>(1);
|
const auto shapesOut = calculateExtentsOutputs.getN<CalculateTransformedExtentsTask::Output>(1);
|
||||||
|
|
||||||
// Parse material mapping
|
// Parse material mapping
|
||||||
const auto parseMaterialMappingInputs = ParseMaterialMappingTask::Input(mapping, materialMappingBaseURL).asVarying();
|
const auto parseMaterialMappingInputs = ParseMaterialMappingTask::Input(mapping, materialMappingBaseURL).asVarying();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// CalculateExtentsTask.cpp
|
// CalculateTransformedExtentsTask.cpp
|
||||||
// model-baker/src/model-baker
|
// model-baker/src/model-baker
|
||||||
//
|
//
|
||||||
// Created by Sabrina Shanman on 2019/10/04.
|
// Created by Sabrina Shanman on 2019/10/04.
|
||||||
|
@ -9,13 +9,13 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "CalculateExtentsTask.h"
|
#include "CalculateTransformedExtentsTask.h"
|
||||||
|
|
||||||
#include "hfm/HFMModelMath.h"
|
#include "hfm/HFMModelMath.h"
|
||||||
|
|
||||||
void CalculateExtentsTask::run(const baker::BakeContextPointer& context, const Input& input, Output& output) {
|
void CalculateTransformedExtentsTask::run(const baker::BakeContextPointer& context, const Input& input, Output& output) {
|
||||||
const auto& modelExtentsIn = input.get0();
|
const auto& modelExtentsIn = input.get0();
|
||||||
const auto& meshes = input.get1();
|
const auto& triangleListMeshes = input.get1();
|
||||||
const auto& shapesIn = input.get2();
|
const auto& shapesIn = input.get2();
|
||||||
const auto& joints = input.get3();
|
const auto& joints = input.get3();
|
||||||
auto& modelExtentsOut = output.edit0();
|
auto& modelExtentsOut = output.edit0();
|
||||||
|
@ -31,7 +31,7 @@ void CalculateExtentsTask::run(const baker::BakeContextPointer& context, const I
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
hfm::calculateExtentsForShape(shapeOut, meshes, joints);
|
hfm::calculateExtentsForShape(shapeOut, triangleListMeshes, joints);
|
||||||
}
|
}
|
||||||
|
|
||||||
modelExtentsOut = modelExtentsIn;
|
modelExtentsOut = modelExtentsIn;
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// CalculateExtentsTask.h
|
// CalculateTransformedExtentsTask.h
|
||||||
// model-baker/src/model-baker
|
// model-baker/src/model-baker
|
||||||
//
|
//
|
||||||
// Created by Sabrina Shanman on 2019/10/04.
|
// Created by Sabrina Shanman on 2019/10/04.
|
||||||
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
// Calculates any undefined extents in the shapes and the model. Precalculated extents will be left alone.
|
// Calculates any undefined extents in the shapes and the model. Precalculated extents will be left alone.
|
||||||
// Bind extents will currently not be calculated
|
// Bind extents will currently not be calculated
|
||||||
class CalculateExtentsTask {
|
class CalculateTransformedExtentsTask {
|
||||||
public:
|
public:
|
||||||
using Input = baker::VaryingSet4<Extents, std::vector<hfm::Mesh>, std::vector<hfm::Shape>, std::vector<hfm::Joint>>;
|
using Input = baker::VaryingSet4<Extents, std::vector<hfm::TriangleListMesh>, std::vector<hfm::Shape>, std::vector<hfm::Joint>>;
|
||||||
using Output = baker::VaryingSet2<Extents, std::vector<hfm::Shape>>;
|
using Output = baker::VaryingSet2<Extents, std::vector<hfm::Shape>>;
|
||||||
using JobModel = baker::Job::ModelIO<CalculateExtentsTask, Input, Output>;
|
using JobModel = baker::Job::ModelIO<CalculateTransformedExtentsTask, Input, Output>;
|
||||||
|
|
||||||
void run(const baker::BakeContextPointer& context, const Input& input, Output& output);
|
void run(const baker::BakeContextPointer& context, const Input& input, Output& output);
|
||||||
};
|
};
|
Loading…
Reference in a new issue