fixing vicious bug in scene code

This commit is contained in:
2024-12-27 23:28:51 +01:00
parent 4e326db10d
commit 49002fdd98
8 changed files with 45 additions and 43 deletions

View File

@@ -34,7 +34,7 @@ namespace mlx
{
if(!drawable || drawable->GetType() != DrawableType::Sprite)
return false;
return static_cast<Sprite*>(drawable.get())->GetTexture() == texture &&
return static_cast<Sprite*>(drawable.get())->GetTexture().Get() == texture.Get() &&
drawable->GetPosition() == position &&
drawable->GetScale() == Vec2f{ scale_x, scale_y } &&
drawable->GetRotation().ToEulerAngles() == EulerAnglesf{ 0.0f, 0.0f, rotation };

View File

@@ -307,7 +307,7 @@ namespace mlx
void Texture::Clear(VkCommandBuffer cmd, Vec4f color)
{
MLX_PROFILE_FUNCTION();
Image::Clear(cmd, std::move(color));
Image::Clear(cmd, color);
if(m_staging_buffer.has_value())
{
mlx_color processed_color;
@@ -324,7 +324,7 @@ namespace mlx
MLX_PROFILE_FUNCTION();
if(!m_has_been_modified)
return;
std::memcpy(m_staging_buffer->GetMap(), m_cpu_buffer.data(), m_cpu_buffer.size() * kvfFormatSize(m_format));
std::memcpy(m_staging_buffer->GetMap(), m_cpu_buffer.data(), m_cpu_buffer.size() * sizeof(mlx_color));
VkImageLayout old_layout = m_layout;
TransitionLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, cmd);
@@ -362,7 +362,7 @@ namespace mlx
kvfDestroyFence(RenderCore::Get().GetDevice(), fence);
m_cpu_buffer.resize(m_width * m_height);
std::memcpy(m_cpu_buffer.data(), m_staging_buffer->GetMap(), m_cpu_buffer.size());
std::memcpy(m_cpu_buffer.data(), m_staging_buffer->GetMap(), m_cpu_buffer.size() * sizeof(mlx_color));
}
Texture* StbTextureLoad(const std::filesystem::path& file, int* w, int* h)

View File

@@ -113,7 +113,7 @@ namespace mlx
drawable_data.model_matrix = Mat4f::Identity();
drawable_data.model_matrix.ApplyTranslation(Vec3f{ -drawable->GetCenter() / 2.0f, 0.0f });
drawable_data.model_matrix.ApplyRotation(drawable->GetRotation());
drawable_data.model_matrix.ApplyTranslation(Vec3f{ drawable->GetPosition() + drawable->GetCenter(), 0.0f });
drawable_data.model_matrix.ApplyTranslation(Vec3f{ drawable->GetPosition() + drawable->GetCenter() / 2.0f, 0.0f });
drawable_data.model_matrix.ApplyScale(Vec3f{ drawable->GetScale(), 1.0f });
drawable->Bind(frame_index, cmd);