mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Add model preparation step to ModelCache using new library model-baker
This commit is contained in:
parent
25e3d49941
commit
566d09dc9c
10 changed files with 127 additions and 5 deletions
|
@ -206,7 +206,7 @@ endif()
|
|||
link_hifi_libraries(
|
||||
shared workload task octree ktx gpu gl procedural graphics graphics-scripting render
|
||||
pointers
|
||||
recording hfm fbx networking model-networking entities avatars trackers
|
||||
recording hfm fbx networking model-networking model-baker entities avatars trackers
|
||||
audio audio-client animation script-engine physics
|
||||
render-utils entities-renderer avatars-renderer ui qml auto-updater midi
|
||||
controllers plugins image trackers
|
||||
|
|
7
libraries/model-baker/CMakeLists.txt
Normal file
7
libraries/model-baker/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
set(TARGET_NAME model-baker)
|
||||
setup_hifi_library()
|
||||
include_hifi_library_headers(shared)
|
||||
include_hifi_library_headers(task)
|
||||
include_hifi_library_headers(gpu)
|
||||
include_hifi_library_headers(graphics)
|
||||
include_hifi_library_headers(hfm)
|
39
libraries/model-baker/src/model-baker/Baker.cpp
Normal file
39
libraries/model-baker/src/model-baker/Baker.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// Baker.cpp
|
||||
// model-baker/src/model-baker
|
||||
//
|
||||
// Created by Sabrina Shanman on 2018/12/04.
|
||||
// Copyright 2018 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 "Baker.h"
|
||||
|
||||
namespace baker {
|
||||
|
||||
class BakerEngineBuilder {
|
||||
public:
|
||||
using Unused = int;
|
||||
|
||||
using Input = VaryingSet1<hfm::Model::Pointer>;
|
||||
using Output = VaryingSet1<hfm::Model::Pointer>;
|
||||
using JobModel = Task::ModelIO<BakerEngineBuilder, Input, Output>;
|
||||
void build(JobModel& model, const Varying& in, Varying& out) {
|
||||
out = Output(in.getN<Input>(0));
|
||||
}
|
||||
};
|
||||
|
||||
Baker::Baker(const hfm::Model::Pointer& hfmModel) :
|
||||
_engine(std::make_shared<Engine>(BakerEngineBuilder::JobModel::create("Baker"), std::make_shared<ImportContext>())) {
|
||||
_engine->feedInput<BakerEngineBuilder::Input>(0, hfmModel);
|
||||
}
|
||||
|
||||
void Baker::run() {
|
||||
_engine->run();
|
||||
auto& output = _engine->getOutput().get<BakerEngineBuilder::Output>();
|
||||
hfmModel = output.get0();
|
||||
}
|
||||
|
||||
};
|
36
libraries/model-baker/src/model-baker/Baker.h
Normal file
36
libraries/model-baker/src/model-baker/Baker.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// Baker.h
|
||||
// model-baker/src/model-baker
|
||||
//
|
||||
// Created by Sabrina Shanman on 2018/12/04.
|
||||
// Copyright 2018 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
|
||||
//
|
||||
|
||||
#ifndef hifi_baker_Baker_h
|
||||
#define hifi_baker_Baker_h
|
||||
|
||||
#include <hfm/HFM.h>
|
||||
|
||||
#include "Engine.h"
|
||||
|
||||
namespace baker {
|
||||
|
||||
class Baker {
|
||||
public:
|
||||
Baker(const hfm::Model::Pointer& hfmModel);
|
||||
|
||||
void run();
|
||||
|
||||
// Outputs, available after run() is called
|
||||
hfm::Model::Pointer hfmModel;
|
||||
|
||||
protected:
|
||||
EnginePointer _engine;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif //hifi_baker_Baker_h
|
32
libraries/model-baker/src/model-baker/Engine.h
Normal file
32
libraries/model-baker/src/model-baker/Engine.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// Engine.h
|
||||
// model-baker/src/model-baker
|
||||
//
|
||||
// Created by Sabrina Shanman on 2018/12/04.
|
||||
// Copyright 2018 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
|
||||
//
|
||||
|
||||
#ifndef hifi_baker_Engine_h
|
||||
#define hifi_baker_Engine_h
|
||||
|
||||
#include <task/Task.h>
|
||||
|
||||
namespace baker {
|
||||
|
||||
class ImportContext : public task::JobContext {
|
||||
public:
|
||||
// No context settings yet for model prep
|
||||
};
|
||||
using ImportContextPointer = std::shared_ptr<ImportContext>;
|
||||
|
||||
Task_DeclareCategoryTimeProfilerClass(BakerTimeProfiler, trace_baker);
|
||||
Task_DeclareTypeAliases(ImportContext, BakerTimeProfiler)
|
||||
|
||||
using EnginePointer = std::shared_ptr<Engine>;
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_baker_Engine_h
|
|
@ -1,5 +1,6 @@
|
|||
set(TARGET_NAME model-networking)
|
||||
setup_hifi_library()
|
||||
link_hifi_libraries(shared shaders networking graphics fbx ktx image gl)
|
||||
link_hifi_libraries(shared shaders networking graphics fbx ktx image gl model-baker)
|
||||
include_hifi_library_headers(gpu)
|
||||
include_hifi_library_headers(hfm)
|
||||
include_hifi_library_headers(task)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <FBXSerializer.h>
|
||||
#include <OBJSerializer.h>
|
||||
#include <GLTFSerializer.h>
|
||||
#include <model-baker/Baker.h>
|
||||
|
||||
Q_LOGGING_CATEGORY(trace_resource_parse_geometry, "trace.resource.parse.geometry")
|
||||
|
||||
|
@ -277,8 +278,12 @@ void GeometryDefinitionResource::downloadFinished(const QByteArray& data) {
|
|||
}
|
||||
|
||||
void GeometryDefinitionResource::setGeometryDefinition(HFMModel::Pointer hfmModel) {
|
||||
// Assume ownership of the HFMModel pointer
|
||||
_hfmModel = hfmModel;
|
||||
// Do processing on the model
|
||||
baker::Baker modelBaker(hfmModel);
|
||||
modelBaker.run();
|
||||
|
||||
// Assume ownership of the processed HFMModel
|
||||
_hfmModel = modelBaker.hfmModel;
|
||||
|
||||
// Copy materials
|
||||
QHash<QString, size_t> materialIDAtlas;
|
||||
|
|
|
@ -29,6 +29,7 @@ Q_LOGGING_CATEGORY(trace_simulation_physics, "trace.simulation.physics")
|
|||
Q_LOGGING_CATEGORY(trace_simulation_physics_detail, "trace.simulation.physics.detail")
|
||||
Q_LOGGING_CATEGORY(trace_startup, "trace.startup")
|
||||
Q_LOGGING_CATEGORY(trace_workload, "trace.workload")
|
||||
Q_LOGGING_CATEGORY(trace_baker, "trace.baker")
|
||||
|
||||
#if defined(NSIGHT_FOUND)
|
||||
#include "nvToolsExt.h"
|
||||
|
|
|
@ -34,6 +34,7 @@ Q_DECLARE_LOGGING_CATEGORY(trace_simulation_physics)
|
|||
Q_DECLARE_LOGGING_CATEGORY(trace_simulation_physics_detail)
|
||||
Q_DECLARE_LOGGING_CATEGORY(trace_startup)
|
||||
Q_DECLARE_LOGGING_CATEGORY(trace_workload)
|
||||
Q_DECLARE_LOGGING_CATEGORY(trace_baker)
|
||||
|
||||
class Duration {
|
||||
public:
|
||||
|
|
|
@ -11,7 +11,7 @@ if (WIN32 AND (NOT USE_GLES))
|
|||
setup_hifi_plugin(Gui Qml Multimedia)
|
||||
link_hifi_libraries(shared task gl qml networking controllers ui
|
||||
plugins display-plugins ui-plugins input-plugins script-engine
|
||||
audio-client render-utils graphics shaders gpu render model-networking hfm fbx ktx image procedural ${PLATFORM_GL_BACKEND})
|
||||
audio-client render-utils graphics shaders gpu render model-networking model-baker hfm fbx ktx image procedural ${PLATFORM_GL_BACKEND})
|
||||
include_hifi_library_headers(octree)
|
||||
|
||||
target_openvr()
|
||||
|
|
Loading…
Reference in a new issue