More changes

This commit is contained in:
2026-09-26 02:03:11 -07:00
parent 8a82df59ca
commit 0b09aeb5d9
6 changed files with 64 additions and 45 deletions
+17
View File
@@ -66,6 +66,14 @@ struct SpriteComponent {
// Higher draws on top. Ties are broken by the transform's position.z.
s32 sortOrder = 0;
// Maps the unit quad (0, 0)-(1, 1) to world space: to the sprite's
// rectangle around its pivot, then by `transform`.
glm::mat4 getModel(const TransformComponent& transform) const {
return transform.mat4() *
glm::translate(glm::mat4{1.f}, glm::vec3{-pivot * size, 0.f}) *
glm::scale(glm::mat4{1.f}, glm::vec3{size, 1.f});
}
};
struct CameraComponent {
@@ -98,6 +106,15 @@ struct CameraComponent {
return glm::ortho(-halfWidth, halfWidth, -halfHeight, halfHeight,
ortho.nearPlane, ortho.farPlane);
}
// World -> clip space for this camera placed by `transform`. The view
// ignores the transform's scale; zoom is the projection's job.
glm::mat4 getViewProjection(const TransformComponent& transform,
float aspect) const {
glm::mat4 world = glm::translate(glm::mat4{1.f}, transform.position) *
glm::mat4_cast(transform.rotation);
return getProjection(aspect) * glm::inverse(world);
}
};
} // namespace sophia
+2
View File
@@ -19,6 +19,8 @@ class SceneRegistry {
const Scene& get(SceneHandle handle) const { return pool.get(handle); }
Scene& get(SceneHandle handle) { return pool.get(handle); }
const Scene& peek(SceneHandle handle) const { return pool.get(handle); }
void release(SceneHandle handle) { pool.release(handle); }
bool isAlive(SceneHandle handle) const { return pool.isAlive(handle); }
@@ -35,6 +35,10 @@ class SceneViewRegistry {
return pool.get(handle);
}
const SceneView& peek(SceneViewHandle handle) const {
return pool.get(handle);
}
void release(SceneViewHandle handle) {
isRenderQueueDirty = true;
pool.release(handle);