4#include "PickingFlags.h"
5#include "Components/Core/RenderComponent.h"
7#include "Rendering/DataFormat.h"
11#include <glm/gtx/quaternion.hpp>
20 class CameraComponent;
25 struct RayIntersectionHit;
32 static constexpr glm::vec2
NoPickTextureCoords = { std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN() };
33 static constexpr size_t NoPickEntityType =
static_cast<size_t>(-1);
38 EntityId entity = NoEntity;
42 EntityId root = NoEntity;
49 glm::vec2 textureCoords = NoPickTextureCoords;
53 float distance = std::numeric_limits<float>::max();
72 size_t entityTypeHash = RayPicking::NoPickEntityType;
94 const glm::vec2& cameraPosition,
100 std::vector<RayPicking::RayPickHit>& hits);
118 const glm::vec3& position,
119 const glm::quat& rotation,
125 std::vector<RayPicking::RayPickHit>& hits);
145 Last = std::numeric_limits<int32_t>::max()
147 Order order = Order::Default;
151 virtual ~IRayPickable() =
default;
158 const glm::vec2& queryClip,
164 std::vector<RayPicking::RayPickHit>& hits) = 0;
176 std::vector<RayPicking::RayPickHit>& ) {
return{}; }
185 const glm::vec2& normPosition,
191 std::vector<RayPicking::RayPickHit>& hits)
override;
194 const glm::vec3& startPos,
195 const glm::quat& rot,
201 std::vector<RayPicking::RayPickHit>& hits)
override;
206 const glm::mat4& worldPickMatrix,
207 const glm::mat4& rawViewProjection,
208 const glm::mat4& viewMatrix,
212 std::vector<RayPicking::RayPickHit>& hits) = 0;
217 const uint8_t* ptr =
nullptr;
218 Cogs::DataFormat format = Cogs::DataFormat::Unknown;
219 uint32_t idOffset = 0;
222 bool hasIdOffset =
false;
225 [[nodiscard]]
static bool clippedByClipComp(
const ClipShapeData& clipData,
const glm::vec4& position);
Base class for Component instances.
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Interface for modules implementing custom picking.
virtual COGSCORE_DLL_API bool pickCamera(Context *context, const CameraComponent &camera, const glm::vec2 &queryClip, float rayLength, float rayRadius, PickingFlags pickingFlags, PicksReturned returnFlag, const RayPicking::RayPickFilter &filter, std::vector< RayPicking::RayPickHit > &hits)=0
Do a ray pick from a normalized screen space position in the camera direction and return all hits.
virtual COGSCORE_DLL_API bool pickRay(Context *, const glm::vec3 &, const glm::quat &, float, float, PickingFlags, PicksReturned, const RayPicking::RayPickFilter &, std::vector< RayPicking::RayPickHit > &)
Do a ray pick from a position and orientation in world space and return all hits.
Order
Specifies run-order of picking extensions when that is needed.
Base class for picking meshes.
bool pickCamera(Context *context, const CameraComponent &camera, const glm::vec2 &normPosition, float, float radius, 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.
bool pickRay(Context *context, const glm::vec3 &startPos, const glm::quat &rot, float rayLength, float radius, PickingFlags pickingFlags, PicksReturned returnFlag, const RayPicking::RayPickFilter &filter, std::vector< RayPicking::RayPickHit > &hits) override
Do a ray pick from a position and orientation in world space and return all hits.
virtual bool pickImpl(Context *context, const glm::mat4 &worldPickMatrix, const glm::mat4 &rawViewProjection, const glm::mat4 &viewMatrix, const RayPicking::RayPickFilter &filter, PickingFlags pickingFlags, PicksReturned returnFlag, std::vector< RayPicking::RayPickHit > &hits)=0
Each mesh rendering system should implement this function that goes through all components and calls ...
COGSCORE_DLL_API bool pickRay(Context *context, const glm::vec3 &position, const glm::quat &rotation, float rayLength, float radius, PickingFlags pickingFlags, PicksReturned returnFlag, const RayPicking::RayPickFilter &filter, std::vector< RayPicking::RayPickHit > &hits)
RayPicking using defined ray starting from pos.
COGSCORE_DLL_API void addPickable(IRayPickable *pickable)
Add Component / System for custom picking.
COGSCORE_DLL_API bool pickCamera(Context *context, const CameraComponent &camera, const glm::vec2 &cameraPosition, float rayLength, float radius, PickingFlags pickingFlags, PicksReturned returnFlag, const RayPicking::RayPickFilter &filter, std::vector< RayPicking::RayPickHit > &hits)
RayPicking using ray from camera position along camera viewing direction.
COGSCORE_DLL_API void removePickable(IRayPickable *pickable)
Remove Component / System from custom picking.
std::vector< IRayPickable * > pickables
Storage for registered pick extensions (addPickable)
static constexpr glm::vec2 NoPickTextureCoords
Marks no match in texture.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
PicksReturned
* Options for returning picking hits.
PickingFlags
Options for COGS picking.
RenderLayers
Contains common render layers.
Meshes contain streams of vertex data in addition to index data and options defining geometry used fo...
glm::vec3 position
The picked position.