Pass by reference in asset functions
This commit is contained in:
parent
d91cd98fcb
commit
82eab9bd91
2 changed files with 11 additions and 12 deletions
|
@ -126,11 +126,11 @@ using AssetManager = AssetPool<Mesh, Material, Texture>;
|
||||||
|
|
||||||
inline std::unique_ptr<AssetManager> assetm;
|
inline std::unique_ptr<AssetManager> assetm;
|
||||||
|
|
||||||
std::unique_ptr<Mesh> load_mesh(prism::path path);
|
std::unique_ptr<Mesh> load_mesh(const prism::path& path);
|
||||||
std::unique_ptr<Material> load_material(prism::path path);
|
std::unique_ptr<Material> load_material(const prism::path& path);
|
||||||
std::unique_ptr<Texture> load_texture(prism::path path);
|
std::unique_ptr<Texture> load_texture(const prism::path& path);
|
||||||
|
|
||||||
void save_material(Material* material, prism::path path);
|
void save_material(Material* material, const prism::path& path);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::unique_ptr<T> load_asset(const prism::path& path) {
|
std::unique_ptr<T> load_asset(const prism::path& path) {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "physics.hpp"
|
#include "physics.hpp"
|
||||||
#include "imgui_backend.hpp"
|
#include "imgui_backend.hpp"
|
||||||
|
|
||||||
std::unique_ptr<Mesh> load_mesh(const prism::path path) {
|
std::unique_ptr<Mesh> load_mesh(const prism::path& path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = prism::open_file(path, true);
|
auto file = prism::open_file(path, true);
|
||||||
|
@ -91,7 +91,7 @@ std::unique_ptr<Mesh> load_mesh(const prism::path path) {
|
||||||
file->read(&mesh->global_inverse_transformation);
|
file->read(&mesh->global_inverse_transformation);
|
||||||
|
|
||||||
std::map<std::string, uint32_t> boneMapping;
|
std::map<std::string, uint32_t> boneMapping;
|
||||||
std::map<int, std::string> parentQueue;
|
std::map<size_t, std::string> parentQueue;
|
||||||
|
|
||||||
for (int v = 0; v < bone_len; v++) {
|
for (int v = 0; v < bone_len; v++) {
|
||||||
std::string bone, parent;
|
std::string bone, parent;
|
||||||
|
@ -189,7 +189,7 @@ std::unique_ptr<Mesh> load_mesh(const prism::path path) {
|
||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Texture> load_texture(const prism::path path) {
|
std::unique_ptr<Texture> load_texture(const prism::path& path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = prism::open_file(path, true);
|
auto file = prism::open_file(path, true);
|
||||||
|
@ -233,12 +233,11 @@ std::unique_ptr<Texture> load_texture(const prism::path path) {
|
||||||
engine->get_gfx()->copy_texture(texture->handle, data, width * height * 4);
|
engine->get_gfx()->copy_texture(texture->handle, data, width * height * 4);
|
||||||
|
|
||||||
if(createInfo.mip_count > 1) {
|
if(createInfo.mip_count > 1) {
|
||||||
GFXCommandBuffer* cmd_buf = engine->get_gfx()->acquire_command_buffer();
|
GFXCommandBuffer* cmd_buf = engine->get_gfx()->acquire_command_buffer(false);
|
||||||
|
|
||||||
|
|
||||||
cmd_buf->generate_mipmaps(texture->handle, createInfo.mip_count);
|
cmd_buf->generate_mipmaps(texture->handle, createInfo.mip_count);
|
||||||
|
|
||||||
engine->get_gfx()->submit(cmd_buf);
|
engine->get_gfx()->submit(cmd_buf, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
stbi_image_free(data);
|
stbi_image_free(data);
|
||||||
|
@ -246,7 +245,7 @@ std::unique_ptr<Texture> load_texture(const prism::path path) {
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Material> load_material(const prism::path path) {
|
std::unique_ptr<Material> load_material(const prism::path& path) {
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
auto file = prism::open_file(path);
|
auto file = prism::open_file(path);
|
||||||
|
@ -287,7 +286,7 @@ std::unique_ptr<Material> load_material(const prism::path path) {
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_material(Material* material, const prism::path path) {
|
void save_material(Material* material, const prism::path& path) {
|
||||||
Expects(material != nullptr);
|
Expects(material != nullptr);
|
||||||
Expects(!path.empty());
|
Expects(!path.empty());
|
||||||
|
|
||||||
|
|
Reference in a new issue