This commit is contained in:
Jorijn van der Graaf 2025-05-05 06:00:35 +02:00
commit cb848e7109
7 changed files with 16 additions and 19 deletions

View file

@ -15,14 +15,19 @@ import Crafter.Math;
namespace Crafter {
export template <typename VertexType>
class MeshShader {
class MeshShader : public Component {
public:
MatrixRowMajor<float, 4, 4, 1> transform;
ComponentRefOwning<Mesh<VertexType>> mesh;
ComponentRefOwning<Camera> camera;
Buffer<MatrixRowMajor<float, 4, 4, 1>> mvp;
std::uint32_t threadCount;
MeshShader(Mesh<VertexType>* mesh, Camera* camera) : threadCount(std::ceil(static_cast<double>(mesh->indexCount)/64/3)), mvp(VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT), mesh(mesh), camera(camera) {
EventListener<void> cameraUpdate;
MeshShader(Mesh<VertexType>* mesh, Camera* camera) : threadCount(std::ceil(static_cast<double>(mesh->indexCount)/64/3)), mvp(VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT), mesh(mesh), camera(camera), cameraUpdate(
&camera->onUpdate, [this](){
Update();
}
) {
transform = MatrixRowMajor<float, 4, 4, 1>::Identity();
}
void WriteDescriptors(DescriptorSet& set) {