mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-01-11 22:53:35 +00:00
world generation
This commit is contained in:
@@ -5,12 +5,14 @@ namespace Scop
|
||||
{
|
||||
Actor::Actor()
|
||||
{
|
||||
m_uuid = UUID();
|
||||
if(p_script)
|
||||
p_script->OnInit(this);
|
||||
}
|
||||
|
||||
Actor::Actor(Model model) : m_model(std::move(model))
|
||||
{
|
||||
m_uuid = UUID();
|
||||
if(p_script)
|
||||
p_script->OnInit(this);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace Scop
|
||||
void Mesh::Draw(VkCommandBuffer cmd, std::size_t& drawcalls, std::size_t& polygondrawn, std::size_t submesh_index) const noexcept
|
||||
{
|
||||
Verify(submesh_index < m_sub_meshes.size(), "invalid submesh index");
|
||||
m_sub_meshes[submesh_index].vbo.Bind(cmd);
|
||||
m_sub_meshes[submesh_index].ibo.Bind(cmd);
|
||||
RenderCore::Get().vkCmdDrawIndexed(cmd, static_cast<std::uint32_t>(m_sub_meshes[submesh_index].ibo.GetSize() / sizeof(std::uint32_t)), 1, 0, 0, 0);
|
||||
m_sub_meshes[submesh_index].buffer.BindVertex(cmd);
|
||||
m_sub_meshes[submesh_index].buffer.BindIndex(cmd);
|
||||
RenderCore::Get().vkCmdDrawIndexed(cmd, m_sub_meshes[submesh_index].index_size, 1, 0, 0, 0);
|
||||
polygondrawn += m_sub_meshes[submesh_index].triangle_count;
|
||||
drawcalls++;
|
||||
}
|
||||
@@ -23,9 +23,6 @@ namespace Scop
|
||||
Mesh::~Mesh()
|
||||
{
|
||||
for(auto& mesh : m_sub_meshes)
|
||||
{
|
||||
mesh.vbo.Destroy();
|
||||
mesh.ibo.Destroy();
|
||||
}
|
||||
mesh.buffer.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "Graphics/Narrator.h"
|
||||
#include <Graphics/Scene.h>
|
||||
#include <Renderer/Renderer.h>
|
||||
#include <Renderer/RenderCore.h>
|
||||
@@ -63,6 +64,39 @@ namespace Scop
|
||||
return *sprite;
|
||||
}
|
||||
|
||||
void Scene::RemoveActor(Actor& actor) noexcept
|
||||
{
|
||||
auto it = std::find_if(m_actors.begin(), m_actors.end(), [actor](const std::shared_ptr<Actor> lhs) { return actor.GetUUID() == lhs->GetUUID(); });
|
||||
if(it == m_actors.end())
|
||||
{
|
||||
Error("Actor not found");
|
||||
return;
|
||||
}
|
||||
m_actors.erase(it);
|
||||
}
|
||||
|
||||
void Scene::RemoveNarrator(Narrator& narrator) noexcept
|
||||
{
|
||||
auto it = std::find_if(m_narrators.begin(), m_narrators.end(), [narrator](const std::shared_ptr<Narrator> lhs) { return narrator.GetUUID() == lhs->GetUUID(); });
|
||||
if(it == m_narrators.end())
|
||||
{
|
||||
Error("Narrator not found");
|
||||
return;
|
||||
}
|
||||
m_narrators.erase(it);
|
||||
}
|
||||
|
||||
void Scene::RemoveSprite(Sprite& sprite) noexcept
|
||||
{
|
||||
auto it = std::find_if(m_sprites.begin(), m_sprites.end(), [sprite](const std::shared_ptr<Sprite> lhs) { return sprite.GetUUID() == lhs->GetUUID(); });
|
||||
if(it == m_sprites.end())
|
||||
{
|
||||
Error("Sprite not found");
|
||||
return;
|
||||
}
|
||||
m_sprites.erase(it);
|
||||
}
|
||||
|
||||
void Scene::SwitchToChild(std::string_view name) const noexcept
|
||||
{
|
||||
auto it = std::find_if(m_scene_children.begin(), m_scene_children.end(), [name](const Scene& scene){ return name == scene.GetName(); });
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
#include <Renderer/Image.h>
|
||||
#include <Graphics/MeshFactory.h>
|
||||
#include <Core/Logs.h>
|
||||
#include <Core/UUID.h>
|
||||
|
||||
namespace Scop
|
||||
{
|
||||
Sprite::Sprite(std::shared_ptr<Texture> texture)
|
||||
{
|
||||
Verify((bool)texture, "Sprite: invalid texture");
|
||||
m_uuid = UUID();
|
||||
p_mesh = CreateQuad(0, 0, texture->GetWidth(), texture->GetHeight());
|
||||
p_texture = texture;
|
||||
if(p_script)
|
||||
|
||||
Reference in New Issue
Block a user