58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "Base/Render/RenderResource.hpp"
|
|
#include "IRecordable.hpp"
|
|
#include "Scene/Camera.hpp"
|
|
#include "Vulkan/Resources/UniformBuffer.hpp"
|
|
|
|
namespace OpenVulkano::Vulkan
|
|
{
|
|
class VulkanNode : public IRenderResource<Scene::Node>, public IRecordable
|
|
{
|
|
public:
|
|
Unique<UniformBuffer> buffer = nullptr;
|
|
|
|
~VulkanNode() override = default;
|
|
|
|
VulkanNode(Scene::Node* node, UniformBuffer* uniformBuffer)
|
|
: IRenderResource<Scene::Node>(node), buffer(uniformBuffer)
|
|
{
|
|
}
|
|
|
|
void Record(VulkanDrawContext* context) override
|
|
{
|
|
buffer->Record(context);
|
|
}
|
|
|
|
void Release() override
|
|
{
|
|
//TODO
|
|
}
|
|
};
|
|
|
|
struct VulkanNodeDynamic : VulkanNode
|
|
{
|
|
//uint32_t lastUpdate = -1;
|
|
|
|
VulkanNodeDynamic(Scene::Node* node, UniformBuffer* uniformBuffer)
|
|
: VulkanNode(node, uniformBuffer)
|
|
{}
|
|
|
|
void Record(VulkanDrawContext* context) override
|
|
{
|
|
//if(context->currentImageId != lastUpdate) //TODO fix
|
|
{
|
|
//lastUpdate = bufferId;
|
|
buffer->Update(&GetOwner()->worldMat, sizeof(Math::Matrix4f), context->currentImageId);
|
|
}
|
|
buffer->Record(context);
|
|
}
|
|
};
|
|
}
|