3#include "Scene/RayPick.h"
4#include "Systems/ComponentSystem.h"
6#include "Components/Core/SpriteRenderComponent.h"
8#include "Resources/Resources.h"
9#include "Resources/MaterialOptions.h"
10#include "Resources/VertexFormats.h"
12#include "Renderer/RenderList.h"
14#include "Foundation/Geometry/BoundingBox.hpp"
21 using SpriteBatchIndex = size_t;
22 const SpriteBatchIndex NoBatchIndex =
static_cast<SpriteBatchIndex
>(-1);
24 using SpriteIndex = size_t;
25 const SpriteIndex NoSpriteIndex =
static_cast<SpriteIndex
>(-1);
29 SpriteBatchIndex batchIndex = NoBatchIndex;
30 SpriteIndex spriteIndex = NoSpriteIndex;
36 Geometry::BoundingBox boundingBox;
46 std::vector<MaterialInstanceHandle> freeInstances;
47 std::vector<MaterialInstanceHandle> frameInstances;
50 using SpriteMaterialKey = size_t;
51 const SpriteMaterialKey NoSpriteMaterial =
static_cast<SpriteMaterialKey
>(-1);
52 const SpriteMaterialKey DefaultSpriteMaterial = 0;
56 SpriteBatchIndex index = NoBatchIndex;
60 glm::mat4 transform = glm::mat4(1.0f);
61 glm::vec3 worldPosition = glm::vec3(0, 0, 0);
62 Geometry::BoundingBox bbox;
69 RenderItemFlags flags = RenderItemFlags::Sprite;
70 bool expanded =
false;
81 return VertexFormats::Pos4fNorm4fTex4f;
96 void initialize(
Context * context)
override;
97 void preUpdate(
Context * context)
override;
98 void postUpdate(
Context * context)
override;
102 SpriteMaterialKey registerSpriteMaterial(
MaterialHandle material);
112 bool alwaysOnTop =
false);
117 void addSprite(
SpriteRenderComponent * spriteRenderer, glm::vec3 position, glm::vec2 size, glm::vec4 texCoords);
118 void addSprite(
SpriteRenderComponent * spriteRenderer, glm::vec3 position, glm::vec2 offset, glm::vec2 size, glm::vec4 texCoords);
120 const SpriteBatch * getSpriteBatch(SpriteBatchIndex index)
const;
121 std::span<const SpriteBatch> getSpriteBatches()
const;
126 void updateBatchMesh();
128 std::vector<SpriteBatch> spriteBatches;
131 std::vector<SpriteMaterial> materials;
135 std::vector<MeshHandle> frameMeshes;
136 std::vector<MeshHandle> freeMeshes;
138 bool expandSpriteGeometry =
true;
151 const glm::vec2& normPosition,
157 std::vector<RayPicking::RayPickHit>& hits)
override;
Component system with parallel data per component stored in a pool similar to how the components them...
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Interface for modules implementing custom picking.
bool pickCamera(Context *context, const CameraComponent &camera, const glm::vec2 &normPosition, float, float, PickingFlags pickingFlags, PicksReturned returnFlag, const RayPicking::RayPickFilter &filter, std::vector< RayPicking::RayPickHit > &hits) override
Do a ray pick from a normalized screen space position in the camera direction and return all hits.
Base allocator implementation.
Provides a weakly referenced view over the contents of a string.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
PositionMode
Positioning mode.
@ World
Position given in world space coordinates.
PicksReturned
* Options for returning picking hits.
PickingFlags
Options for COGS picking.
BlendMode
Defines blending modes for rendering.
@ Blend
Render with regular alpha blending.
@ Pixels
Size given in screen pixels.
uint16_t VariableKey
Used to lookup material properties.
ComponentIndex SizeType
Type used to track the size of pools.
Handle to a Component instance.
Lod data holding the LoD state of the entity this render component belongs to.
static const ResourceHandle_t NoHandle
Handle representing a default (or none if default not present) resource.