material serialization fixes
This commit is contained in:
@@ -26,5 +26,6 @@ void MaterialAsset::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
material = new Material();
|
||||
material->load(buffer);
|
||||
material->compile();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,12 @@ template<class F, class... Args>
|
||||
concept invocable = std::invocable<F, Args...>;
|
||||
|
||||
template<class T, class Archive>
|
||||
concept serializable = requires(T t, Archive& a)
|
||||
concept serializable = requires(const T t, Archive& a)
|
||||
{
|
||||
t->save(a);
|
||||
t->load(a);
|
||||
t.save(a);
|
||||
} && requires(T t, Archive& a)
|
||||
{
|
||||
t.load(a);
|
||||
};
|
||||
template<typename T>
|
||||
concept enumeration = std::is_enum_v<T>;
|
||||
|
||||
@@ -52,8 +52,9 @@ Gfx::PDescriptorSet Material::createDescriptorSet()
|
||||
void Material::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
MaterialInterface::save(buffer);
|
||||
Serialization::save(buffer,materialName);
|
||||
Serialization::save(buffer, materialName);
|
||||
Serialization::save(buffer, layout->getSetIndex());
|
||||
Serialization::save2(buffer, brdf);
|
||||
const auto& bindings = layout->getBindings();
|
||||
Serialization::save(buffer, bindings.size());
|
||||
for (const auto& binding : bindings)
|
||||
@@ -73,6 +74,7 @@ void Material::load(ArchiveBuffer& buffer)
|
||||
Serialization::load(buffer, materialName);
|
||||
uint32 setIndex;
|
||||
Serialization::load(buffer, setIndex);
|
||||
Serialization::load2(buffer, brdf);
|
||||
uint64 numBindings;
|
||||
Serialization::load(buffer, numBindings);
|
||||
layout = graphics->createDescriptorLayout();
|
||||
|
||||
@@ -65,6 +65,16 @@ namespace Serialization
|
||||
{
|
||||
buffer.readBytes(&type, sizeof(type));
|
||||
}
|
||||
template<typename T>
|
||||
static void save2(ArchiveBuffer& buffer, const T& type) requires(serializable<T>)
|
||||
{
|
||||
type.save(buffer);
|
||||
}
|
||||
template<typename T>
|
||||
static void load2(ArchiveBuffer& buffer, T& type) requires(serializable<T>)
|
||||
{
|
||||
type.load(buffer);
|
||||
}
|
||||
//template<class T>
|
||||
//static void save(ArchiveBuffer& buffer, const T& type)
|
||||
//{
|
||||
|
||||
@@ -19,11 +19,7 @@ GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreate
|
||||
SkyboxRenderPass(graphics)
|
||||
))
|
||||
{
|
||||
scene = new Scene(graphics);
|
||||
gameInterface.reload(instance);
|
||||
|
||||
systemGraph = new SystemGraph();
|
||||
gameInterface.getGame()->setupScene(scene, systemGraph);
|
||||
reloadGame();
|
||||
renderGraph.updateViewport(viewport);
|
||||
}
|
||||
|
||||
@@ -74,6 +70,15 @@ void GameView::render()
|
||||
});
|
||||
}
|
||||
|
||||
void GameView::reloadGame()
|
||||
{
|
||||
scene = new Scene(graphics);
|
||||
gameInterface.reload(instance);
|
||||
|
||||
systemGraph = new SystemGraph();
|
||||
gameInterface.getGame()->setupScene(scene, systemGraph);
|
||||
}
|
||||
|
||||
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
||||
{
|
||||
scene->view<Component::KeyboardInput>([=](Component::KeyboardInput& input)
|
||||
@@ -99,6 +104,10 @@ void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
||||
// showDebug = !showDebug;
|
||||
// debugPassData.vertices.clear();
|
||||
//}
|
||||
if(code == KeyCode::KEY_R && action == InputAction::PRESS)
|
||||
{
|
||||
reloadGame();
|
||||
}
|
||||
|
||||
input.keys[code] = action != InputAction::RELEASE;
|
||||
});
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
|
||||
virtual void prepareRender() override;
|
||||
virtual void render() override;
|
||||
|
||||
void reloadGame();
|
||||
private:
|
||||
GameInterface gameInterface;
|
||||
RenderGraph<
|
||||
|
||||
Reference in New Issue
Block a user