@@ -100,21 +100,29 @@ namespace mlx
100
100
for (auto & drawable : drawables)
101
101
{
102
102
// Check every textures and update modified ones to GPU before starting the render pass
103
- drawable->Update (cmd);
104
103
if (!drawable->IsSetInit ())
105
104
drawable->UpdateDescriptorSet (p_texture_set);
105
+ drawable->Update (cmd);
106
106
}
107
107
108
108
m_pipeline.BindPipeline (cmd, 0 , {});
109
109
for (auto & drawable : drawables)
110
110
{
111
111
DrawableData drawable_data;
112
112
drawable_data.color = drawable->GetColor ();
113
+
114
+ Mat4f rotation_matrix = Mat4f::Identity ();
115
+ rotation_matrix.ApplyTranslation (Vec3f{ -drawable->GetCenter (), 0 .0f });
116
+ rotation_matrix.ApplyRotation (drawable->GetRotation ());
117
+ rotation_matrix.ApplyTranslation (Vec3f{ drawable->GetCenter (), 0 .0f });
118
+
119
+ Mat4f translation_matrix = Mat4f::Identity ().ApplyTranslation (Vec3f{ drawable->GetPosition (), 0 .0f });
120
+ Mat4f scale_matrix = Mat4f::Identity ().ApplyScale (Vec3f{ drawable->GetScale (), 1 .0f });
121
+
113
122
drawable_data.model_matrix = Mat4f::Identity ();
114
- drawable_data.model_matrix .ApplyTranslation (Vec3f{ -drawable->GetCenter () / 2 .0f , 0 .0f });
115
- drawable_data.model_matrix .ApplyRotation (drawable->GetRotation ());
116
- drawable_data.model_matrix .ApplyTranslation (Vec3f{ drawable->GetPosition () + drawable->GetCenter () / 2 .0f , 0 .0f });
117
- drawable_data.model_matrix .ApplyScale (Vec3f{ drawable->GetScale (), 1 .0f });
123
+ drawable_data.model_matrix .ConcatenateTransform (rotation_matrix);
124
+ drawable_data.model_matrix .ConcatenateTransform (scale_matrix);
125
+ drawable_data.model_matrix .ConcatenateTransform (translation_matrix);
118
126
119
127
drawable->Bind (frame_index, cmd);
120
128
0 commit comments