From d7d79214a93bc96b38ac018aad4c8d5ee88d51ca Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Tue, 27 Sep 2022 17:38:20 -0300 Subject: feat Allow multiple textures to be used with the same mesh --- src/model.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/model.cpp') diff --git a/src/model.cpp b/src/model.cpp index 6a6e470..b5c4185 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -16,13 +16,14 @@ #include "model.hpp" +#include "mesh.hpp" #include "rotation_3d.hpp" #include "texture.hpp" #include "vector_3d.hpp" #include "vk/model_instance.hpp" void -cg_free_model(mrb_state *mrb, void* obj) +cg_free_model(mrb_state *mrb, void *obj) { auto ptr = static_cast*>(obj); @@ -35,32 +36,27 @@ const struct mrb_data_type cg_model_type = { "CG_Model", cg_free_model }; static mrb_value cg_cModel_initialize(mrb_state *mrb, mrb_value self) { - const char *file_path; - - mrb_sym id_at_texture; - mrb_value texture_v; - + std::shared_ptr *mesh; std::shared_ptr *texture; std::shared_ptr *ptr; - mrb_get_args(mrb, "zd", &file_path, &texture, &cg_texture_type); + mrb_get_args(mrb, "dd", &mesh, &cg_mesh_type, &texture, &cg_texture_type); ptr = (std::shared_ptr*)DATA_PTR(self); if(ptr) mrb_free(mrb, ptr); ptr = (std::shared_ptr*)mrb_malloc( mrb, sizeof(std::shared_ptr)); - std::string path{file_path}; new(ptr)std::shared_ptr( - std::make_shared(path, *texture)); + std::make_shared(*mesh, *texture)); - mrb_data_init(self, ptr, &cg_model_type); + mrb_data_init(self, ptr, &cg_mesh_type); return self; } static mrb_value cg_cModel_draw(mrb_state *mrb, mrb_value self) { - auto *ptr = (std::shared_ptr*)DATA_PTR(self); + auto ptr = (std::shared_ptr*)DATA_PTR(self); VK::ModelInstance instance; std::shared_ptr *position; std::shared_ptr *rotation; -- cgit v1.2.3