Refactor
This commit is contained in:
@@ -44,7 +44,7 @@ CoreInstance::CoreInstance()
|
||||
main_config_file.seekg(0, std::ios::beg);
|
||||
payload.resize(size_config);
|
||||
|
||||
main_config_file.read(payload.data(), payload.size());
|
||||
main_config_file.read(payload.data(), static_cast<int>(payload.size()));
|
||||
main_config_file.close();
|
||||
SaveMap load_main_config(payload);
|
||||
|
||||
|
||||
@@ -719,7 +719,7 @@ void RenderEngine::allocate_vertex_buffer()
|
||||
VkBuffer staging_buffer = VK_NULL_HANDLE;
|
||||
VkDeviceMemory staging_buffer_memory = VK_NULL_HANDLE;
|
||||
|
||||
VkDeviceSize size_buffer = sizeof(vertices[0]) * vertices.size();
|
||||
VkDeviceSize size_buffer = sizeof(vertices_[0]) * vertices_.size();
|
||||
create_buffer(size_buffer, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, &staging_buffer, transfer_index);
|
||||
allocate_memory(staging_buffer, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, &staging_buffer_memory);
|
||||
|
||||
@@ -731,7 +731,7 @@ void RenderEngine::allocate_vertex_buffer()
|
||||
|
||||
void* data;
|
||||
VK_CHECK(vkMapMemory(device_, staging_buffer_memory, 0, size_buffer, 0, &data));
|
||||
memcpy(data, vertices.data(), size_buffer);
|
||||
memcpy(data, vertices_.data(), size_buffer);
|
||||
vkUnmapMemory(device_, staging_buffer_memory);
|
||||
|
||||
copy_memory(staging_buffer, vertex_buffer_, size_buffer);
|
||||
@@ -856,7 +856,7 @@ void RenderEngine::record_command_buffer(VkCommandBuffer command_buffer, uint32_
|
||||
scissor.extent = swapchain_extent_;
|
||||
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
|
||||
|
||||
vkCmdDraw(command_buffer, static_cast<uint32_t>(vertices.size()), 1, 0, 0);
|
||||
vkCmdDraw(command_buffer, static_cast<uint32_t>(vertices_.size()), 1, 0, 0);
|
||||
|
||||
vkCmdEndRenderPass(command_buffer);
|
||||
VK_CHECK(vkEndCommandBuffer(command_buffer));
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "ModelManager.hpp"
|
||||
@@ -44,7 +43,7 @@ class RenderEngine
|
||||
static VkVertexInputBindingDescription get_binding_description();
|
||||
static std::array<VkVertexInputAttributeDescription, 2> get_vertex_attribute_descriptions();
|
||||
};
|
||||
std::vector<Vertex> vertices = {
|
||||
std::vector<Vertex> vertices_ = {
|
||||
{{0.0f, -0.5f}, {1.0f, 0.0f, 0.0f}},
|
||||
{{0.5f, 0.5f}, {0.0f, 1.0f, 0.0f}},
|
||||
{{-0.5f, 0.5f}, {0.0f, 0.0f, 1.0f}}
|
||||
@@ -129,6 +128,7 @@ public:
|
||||
void start();
|
||||
void stop_render() const;
|
||||
|
||||
[[nodiscard]]
|
||||
GLFWwindow* get_window() const { return window_; }
|
||||
|
||||
ModelManager* GetActiveModelManager() { return &model_manager_; }
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
class CoreInstance;
|
||||
|
||||
struct CoreCallBacks;
|
||||
|
||||
namespace System {
|
||||
/**
|
||||
* @throws std::exception if the operation finished with failed
|
||||
|
||||
@@ -8,7 +8,7 @@ void Actor::OnDestroy()
|
||||
{
|
||||
}
|
||||
|
||||
Actor::Actor() : loc(new Vector3D), rot(new Vector3D), scale(new Vector3D)
|
||||
Actor::Actor() : loc_(new Vector3D), rot_(new Vector3D), scale_(new Vector3D)
|
||||
{
|
||||
SetType(Classes::Actor);
|
||||
}
|
||||
@@ -16,17 +16,17 @@ Actor::Actor() : loc(new Vector3D), rot(new Vector3D), scale(new Vector3D)
|
||||
std::shared_ptr<SaveMap> Actor::save()
|
||||
{
|
||||
return std::make_shared<SaveMap>("Actor")
|
||||
->SaveObject("loc", static_cast<UType::object_ptr<ISave>>(loc))
|
||||
->SaveObject("rot", static_cast<UType::object_ptr<ISave>>(rot))
|
||||
->SaveObject("scale", UType::object_ptr<ISave>(scale))
|
||||
->SaveObject("loc", static_cast<UType::object_ptr<ISave>>(loc_))
|
||||
->SaveObject("rot", static_cast<UType::object_ptr<ISave>>(rot_))
|
||||
->SaveObject("scale", UType::object_ptr<ISave>(scale_))
|
||||
->SaveListStrings("tags", std::move(tags));
|
||||
}
|
||||
|
||||
void Actor::load(std::shared_ptr<SaveMap> save)
|
||||
{
|
||||
loc = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("loc"));
|
||||
rot = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("rot"));
|
||||
scale = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("scale"));
|
||||
loc_ = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("loc"));
|
||||
rot_ = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("rot"));
|
||||
scale_ = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("scale"));
|
||||
tags = std::move(save->GetListString("tags"));
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ void Actor::Tick(double delta_time)
|
||||
|
||||
void Actor::SetActorLocate(const Vector3D& loc) noexcept
|
||||
{
|
||||
*this->loc = loc;
|
||||
*this->loc_ = loc;
|
||||
OnSetActorLocate.Call(loc);
|
||||
}
|
||||
|
||||
void Actor::SetActorRotate(const Vector3D& rot) noexcept
|
||||
{
|
||||
*this->rot = rot;
|
||||
*this->rot_ = rot;
|
||||
OnSetActorRotate.Call(rot);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class Actor : public ISave, public IRTTI
|
||||
World* world_;
|
||||
std::string name_;
|
||||
|
||||
UType::object_ptr<Vector3D> loc, rot, scale;
|
||||
UType::object_ptr<Vector3D> loc_, rot_, scale_;
|
||||
|
||||
std::list<std::string> tags;
|
||||
|
||||
@@ -30,8 +30,8 @@ public:
|
||||
Delegate<const Vector3D&> OnSetActorRotate;
|
||||
|
||||
#pragma region ISave
|
||||
virtual std::shared_ptr<SaveMap> save() override;
|
||||
virtual void load(std::shared_ptr<SaveMap> save) override;
|
||||
std::shared_ptr<SaveMap> save() override;
|
||||
void load(std::shared_ptr<SaveMap> save) override;
|
||||
#pragma endregion
|
||||
|
||||
virtual void BeginPlay();
|
||||
@@ -42,14 +42,14 @@ public:
|
||||
* Вызывает делегат OnSetActorLocate
|
||||
*/
|
||||
void SetActorLocate(const Vector3D& loc) noexcept;
|
||||
inline const UType::object_ptr<Vector3D> GetActorLocate() const { return loc; }
|
||||
inline const UType::object_ptr<Vector3D> GetActorLocate() const { return loc_; }
|
||||
|
||||
/*
|
||||
* Изменяет ориентацию в пространстве
|
||||
* Вызывает делегат OnSetActorRotate
|
||||
*/
|
||||
void SetActorRotate(const Vector3D& rot) noexcept;
|
||||
inline const UType::object_ptr<Vector3D> GetActorRotate() const { return rot; }
|
||||
inline const UType::object_ptr<Vector3D> GetActorRotate() const { return rot_; }
|
||||
|
||||
void AddTag(const std::string& tag) noexcept;
|
||||
void RemoveTag(const std::string& tag) noexcept;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
|
||||
std::mutex mOutput;
|
||||
static std::mutex mOutput;
|
||||
|
||||
#ifdef _DEBUG
|
||||
void Loging::Log(const char* msg)
|
||||
|
||||
Reference in New Issue
Block a user