Initial claude dump
This commit is contained in:
@@ -47,6 +47,27 @@ struct MeshComponent {
|
||||
MeshHandle handle;
|
||||
};
|
||||
|
||||
/**
|
||||
* A textured quad in the XY plane, placed by the entity's TransformComponent.
|
||||
* Only rotation around Z is meaningful.
|
||||
*/
|
||||
struct SpriteComponent {
|
||||
// Invalid draws a solid quad in `color`.
|
||||
TextureHandle texture = INVALID_HANDLE;
|
||||
glm::vec4 color{1.f, 1.f, 1.f, 1.f};
|
||||
|
||||
// Size in world units, before the transform's scale.
|
||||
glm::vec2 size{1.f, 1.f};
|
||||
// Point on the sprite, from (0, 0) to (1, 1) across its size, that sits at
|
||||
// the transform's position and that it rotates around.
|
||||
glm::vec2 pivot{0.5f, 0.5f};
|
||||
// Region of the texture to draw, as normalized (u0, v0, u1, v1).
|
||||
glm::vec4 uvRect{0.f, 0.f, 1.f, 1.f};
|
||||
|
||||
// Higher draws on top. Ties are broken by the transform's position.z.
|
||||
s32 sortOrder = 0;
|
||||
};
|
||||
|
||||
struct CameraComponent {
|
||||
struct Orthographic {
|
||||
float height = 10.f;
|
||||
|
||||
@@ -59,4 +59,11 @@ class Entity {
|
||||
Scene* scene = nullptr;
|
||||
};
|
||||
|
||||
template <typename Fn>
|
||||
void Scene::forEachEntity(Fn&& fn) {
|
||||
for (auto [handle] : registry.storage<entt::entity>().each()) {
|
||||
fn(Entity{handle, this});
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sophia
|
||||
|
||||
@@ -38,11 +38,13 @@ class Panel;
|
||||
class RenderTarget;
|
||||
class Scene;
|
||||
struct SceneView;
|
||||
class Texture;
|
||||
|
||||
using MeshHandle = Handle<Mesh>;
|
||||
using PanelHandle = Handle<Panel>;
|
||||
using RenderTargetHandle = Handle<RenderTarget>;
|
||||
using SceneHandle = Handle<Scene>;
|
||||
using SceneViewHandle = Handle<SceneView>;
|
||||
using TextureHandle = Handle<Texture>;
|
||||
|
||||
} // namespace sophia
|
||||
|
||||
@@ -26,8 +26,10 @@ class ResourceRegistryRef {
|
||||
void requestResize(RenderTargetHandle handle, u32 width, u32 height);
|
||||
|
||||
glm::vec2 getExtent(RenderTargetHandle handle) const;
|
||||
glm::vec2 getExtent(TextureHandle handle) const;
|
||||
|
||||
bool isAlive(RenderTargetHandle handle) const;
|
||||
bool isAlive(TextureHandle handle) const;
|
||||
|
||||
template <typename T>
|
||||
void release(Handle<T> handle);
|
||||
@@ -45,16 +47,25 @@ class ResourceRegistryRef {
|
||||
RenderTargetHandle createResource(std::type_identity<RenderTarget>,
|
||||
u32 width = 1, u32 height = 1);
|
||||
|
||||
TextureHandle createResource(std::type_identity<Texture>, u32 width,
|
||||
u32 height, std::vector<u8> pixels);
|
||||
|
||||
ResourceRegistry* registry;
|
||||
};
|
||||
|
||||
template <>
|
||||
MeshHandle ResourceRegistryRef::load<Mesh>(const std::string& path);
|
||||
|
||||
template <>
|
||||
TextureHandle ResourceRegistryRef::load<Texture>(const std::string& path);
|
||||
|
||||
template <>
|
||||
void ResourceRegistryRef::release<Mesh>(MeshHandle handle);
|
||||
|
||||
template <>
|
||||
void ResourceRegistryRef::release<RenderTarget>(RenderTargetHandle handle);
|
||||
|
||||
template <>
|
||||
void ResourceRegistryRef::release<Texture>(TextureHandle handle);
|
||||
|
||||
} // namespace sophia
|
||||
|
||||
@@ -13,9 +13,14 @@ class Scene {
|
||||
Scene();
|
||||
~Scene();
|
||||
|
||||
void createEntity(const std::string& name = {});
|
||||
// Every entity gets a TagComponent (named `name`) and a TransformComponent.
|
||||
Entity createEntity(const std::string& name = {});
|
||||
void destroyEntity(Entity entity);
|
||||
|
||||
/** Calls `fn(Entity)` for every live entity. Defined in entity.hpp. */
|
||||
template <typename Fn>
|
||||
void forEachEntity(Fn&& fn);
|
||||
|
||||
// The camera a render request uses when it doesn't name one. Null until
|
||||
// set.
|
||||
entt::entity getActiveCamera() const { return activeCamera; }
|
||||
|
||||
Reference in New Issue
Block a user