improving allocator

This commit is contained in:
2025-05-20 23:12:54 +02:00
parent 410d247c7f
commit c7dfc64f26
15 changed files with 145 additions and 35 deletions

View File

@@ -28,7 +28,7 @@ void Chunk::GenerateChunk()
for(std::uint32_t z = 0; z < CHUNK_SIZE.z; z++)
{
// Implement noise here
std::uint32_t height = std::min(static_cast<std::uint32_t>(4 + (std::sin(m_position.x) * std::sin(m_position.y)) * 10 + x), CHUNK_SIZE.y);
std::uint32_t height = std::abs(std::sin((float)m_offset.x / 20.0f) * std::cos((float)m_offset.y / 20.0f) * 60.0f) + 1;
for(std::uint32_t y = 0; y < height; y++)
m_data[x][z][y] = 1;
}
@@ -37,12 +37,9 @@ void Chunk::GenerateChunk()
void Chunk::GenerateMesh()
{
if(p_actor)
if(!m_mesh_data.empty())
return;
m_mesh_data.clear();
m_mesh_index_data.clear();
std::size_t offset = 0;
for(std::uint32_t x = 0; x < CHUNK_SIZE.x; x++)
@@ -176,6 +173,8 @@ void Chunk::UploadMesh()
std::uint32_t Chunk::GetBlock(Scop::Vec3i position) const noexcept
{
//if(position.x < 0 || position.x >= m_data.size() || position.z < 0 || position.z >= m_data[position.x >= m_data.size() ? m_data.size() - 1 : position.x].size() || position.y < 0)
// return 1;
if(position.x < m_data.size() && position.z < m_data[position.x].size() && position.y < m_data[position.x][position.z].size())
return m_data[position.x][position.z][position.y];
return 0;

View File

@@ -9,8 +9,8 @@
#include <Chunk.h>
#include <Utils.h>
constexpr std::uint8_t RENDER_DISTANCE = 10;
constexpr std::uint8_t CHUNKS_UPLOAD_PER_FRAME = 1;
constexpr std::uint8_t RENDER_DISTANCE = 12;
constexpr std::uint8_t CHUNKS_UPLOAD_PER_FRAME = 3;
enum class GenerationState: std::uint8_t
{

View File

@@ -11,8 +11,20 @@ int main(int ac, char** av)
std::shared_ptr<Scop::Scene> splash_scene = SplashScreen();
Scop::ShaderLayout shader_layout(
{
{ 1,
Scop::ShaderSetLayout({
{ 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER },
{ 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER }
})
}
}, {}
);
std::shared_ptr<Scop::Shader> shader = Scop::LoadShaderFromFile(GetExecutablePath().parent_path().parent_path() / "Resources/Fragment.spv", Scop::ShaderType::Fragment, std::move(shader_layout));
Scop::SceneDescriptor main_scene_desc;
main_scene_desc.fragment_shader = Scop::RenderCore::Get().GetDefaultFragmentShader();
main_scene_desc.fragment_shader = shader;
main_scene_desc.camera = std::make_shared<Scop::FirstPerson3D>(Scop::Vec3f{ 0.0f, 20.0f, 0.0f }, 80.f);
main_scene_desc.culling = Scop::CullMode::Front;
Scop::Scene& main_scene = splash_scene->AddChildScene("main", std::move(main_scene_desc));