mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 06:33:35 +00:00
fixing transformations
This commit is contained in:
@@ -143,7 +143,7 @@ namespace mlx
|
||||
m_pixelput_called = false;
|
||||
}
|
||||
Sprite& new_sprite = p_scene->CreateSprite(texture);
|
||||
new_sprite.SetCenter(Vec2f{ texture->GetWidth() / 2.0f, texture->GetHeight() / 2.0f });
|
||||
new_sprite.SetCenter(Vec2f{ texture->GetWidth() * 0.5f, texture->GetHeight() * 0.5f });
|
||||
new_sprite.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
||||
new_sprite.SetScale(Vec2f{ scale_x, scale_y });
|
||||
new_sprite.SetRotation(angle);
|
||||
|
||||
@@ -100,9 +100,9 @@ namespace mlx
|
||||
for(auto& drawable : drawables)
|
||||
{
|
||||
// Check every textures and update modified ones to GPU before starting the render pass
|
||||
drawable->Update(cmd);
|
||||
if(!drawable->IsSetInit())
|
||||
drawable->UpdateDescriptorSet(p_texture_set);
|
||||
drawable->Update(cmd);
|
||||
}
|
||||
|
||||
m_pipeline.BindPipeline(cmd, 0, {});
|
||||
@@ -110,11 +110,19 @@ namespace mlx
|
||||
{
|
||||
DrawableData drawable_data;
|
||||
drawable_data.color = drawable->GetColor();
|
||||
|
||||
Mat4f rotation_matrix = Mat4f::Identity();
|
||||
rotation_matrix.ApplyTranslation(Vec3f{ -drawable->GetCenter(), 0.0f });
|
||||
rotation_matrix.ApplyRotation(drawable->GetRotation());
|
||||
rotation_matrix.ApplyTranslation(Vec3f{ drawable->GetCenter(), 0.0f });
|
||||
|
||||
Mat4f translation_matrix = Mat4f::Identity().ApplyTranslation(Vec3f{ drawable->GetPosition(), 0.0f });
|
||||
Mat4f scale_matrix = Mat4f::Identity().ApplyScale(Vec3f{ drawable->GetScale(), 1.0f });
|
||||
|
||||
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() / 2.0f, 0.0f });
|
||||
drawable_data.model_matrix.ApplyScale(Vec3f{ drawable->GetScale(), 1.0f });
|
||||
drawable_data.model_matrix.ConcatenateTransform(rotation_matrix);
|
||||
drawable_data.model_matrix.ConcatenateTransform(scale_matrix);
|
||||
drawable_data.model_matrix.ConcatenateTransform(translation_matrix);
|
||||
|
||||
drawable->Bind(frame_index, cmd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user