summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/xe_engine.cpp6
-rw-r--r--engine/xe_engine.hpp5
-rw-r--r--engine/xe_game_object.hpp3
-rw-r--r--engine/xe_model.cpp4
-rw-r--r--engine/xe_model.hpp2
-rw-r--r--engine/xe_render_system.cpp2
6 files changed, 12 insertions, 10 deletions
diff --git a/engine/xe_engine.cpp b/engine/xe_engine.cpp
index 44e5a4e..6392d78 100644
--- a/engine/xe_engine.cpp
+++ b/engine/xe_engine.cpp
@@ -32,18 +32,18 @@ void Engine::loadDescriptorPool() {
.build();
}
-std::shared_ptr<Model> Engine::loadModelFromFile(const std::string &filename) {
+Model* Engine::loadModelFromFile(const std::string &filename) {
return Model::createModelFromFile(xeDevice, filename);
}
-std::shared_ptr<Model> Engine::loadModelFromData(std::vector<unsigned char> vertexData, uint32_t vertexSize, std::vector<uint32_t> indices) {
+Model* Engine::loadModelFromData(std::vector<unsigned char> vertexData, uint32_t vertexSize, std::vector<uint32_t> indices) {
Model::Builder builder{};
builder.vertexData.data = vertexData;
builder.vertexSize = vertexSize;
if(indices.size() > 0) {
builder.indices = indices;
}
- return std::make_shared<Model>(xeDevice, builder);
+ return new Model(xeDevice, builder);
}
Image* Engine::loadImageFromFile(const std::string &filename, bool anisotropic) {
diff --git a/engine/xe_engine.hpp b/engine/xe_engine.hpp
index 1a208d6..eff2d13 100644
--- a/engine/xe_engine.hpp
+++ b/engine/xe_engine.hpp
@@ -7,6 +7,7 @@
#include "xe_image.hpp"
#include "xe_input.hpp"
#include "xe_sound.hpp"
+#include "xe_model.hpp"
#include <chrono>
#include <string>
@@ -31,8 +32,8 @@ class Engine {
Camera& getCamera() {return xeCamera;}
Device& getDevice() {return xeDevice;}
- std::shared_ptr<Model> loadModelFromFile(const std::string &filename);
- std::shared_ptr<Model> loadModelFromData(std::vector<unsigned char> vertexData, uint32_t vertexSize, std::vector<uint32_t> indices);
+ Model* loadModelFromFile(const std::string &filename);
+ Model* loadModelFromData(std::vector<unsigned char> vertexData, uint32_t vertexSize, std::vector<uint32_t> indices);
Image* loadImageFromFile(const std::string &filename, bool anisotropic = true);
bool beginFrame() { return xeRenderer.beginFrame(); }
diff --git a/engine/xe_game_object.hpp b/engine/xe_game_object.hpp
index 7c4149e..7d7e698 100644
--- a/engine/xe_game_object.hpp
+++ b/engine/xe_game_object.hpp
@@ -37,8 +37,7 @@ class GameObject {
id_t getId() { return id; }
- std::shared_ptr<Model> model{};
- // glm::vec3 color{};
+ Model* model{};
TransformComponent transform;
private:
diff --git a/engine/xe_model.cpp b/engine/xe_model.cpp
index fd97f44..ff0d630 100644
--- a/engine/xe_model.cpp
+++ b/engine/xe_model.cpp
@@ -20,10 +20,10 @@ Model::Model(Device &device, const Model::Builder &builder) : xeDevice{device} {
Model::~Model() {}
-std::unique_ptr<Model> Model::createModelFromFile(Device &device, const std::string &filepath) {
+Model* Model::createModelFromFile(Device &device, const std::string &filepath) {
Builder builder{};
builder.loadModel(filepath);
- return std::make_unique<Model>(device, builder);
+ return new Model(device, builder);
}
void Model::createVertexBuffers(const std::vector<unsigned char> &vertexData, uint32_t vertexSize) {
diff --git a/engine/xe_model.hpp b/engine/xe_model.hpp
index 41dccd5..1886657 100644
--- a/engine/xe_model.hpp
+++ b/engine/xe_model.hpp
@@ -40,7 +40,7 @@ class Model {
Model(const Model &) = delete;
Model operator=(const Model &) = delete;
- static std::unique_ptr<Model> createModelFromFile(Device &device, const std::string &filepath);
+ static Model* createModelFromFile(Device &device, const std::string &filepath);
void bind(VkCommandBuffer commandBuffer);
void draw(VkCommandBuffer commandBuffer);
diff --git a/engine/xe_render_system.cpp b/engine/xe_render_system.cpp
index f2f0e43..1ceff78 100644
--- a/engine/xe_render_system.cpp
+++ b/engine/xe_render_system.cpp
@@ -208,6 +208,8 @@ void RenderSystem::loadTextureArray(uint32_t binding, std::vector<Image*>& image
void RenderSystem::render(GameObject &gameObject) {
+ if(gameObject.model == nullptr) return;
+
gameObject.model->bind(xeRenderer.getCurrentCommandBuffer());
gameObject.model->draw(xeRenderer.getCurrentCommandBuffer());