Cogs.Core
Classes | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Cogs::Core::RayPicking Class Reference

Classes

struct  RayPickFilter
 
struct  RayPickHit
 

Public Member Functions

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 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 void removePickable (IRayPickable *pickable)
 Remove Component / System from custom picking.
 

Static Public Attributes

static constexpr glm::vec2 NoPickTextureCoords = { std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN() }
 Marks no match in texture.
 
static constexpr size_t NoPickEntityType = static_cast<size_t>(-1)
 

Private Attributes

std::vector< IRayPickable * > pickables
 Storage for registered pick extensions (addPickable)
 

Detailed Description

Definition at line 28 of file RayPick.h.

Member Function Documentation

◆ addPickable()

void Cogs::Core::RayPicking::addPickable ( IRayPickable pickable)

Add Component / System for custom picking.

Definition at line 160 of file RayPick.cpp.

◆ pickCamera()

bool Cogs::Core::RayPicking::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.

Parameters
contextCogs context.
cameraCamera used for picking.
cameraPositionCamera Position typically from a mouse.
rayLengthMax length of ray.
radiusRadius of ray.
pickingFlagsFlag for picking. Sprite picking root, or sub-entity return.
returnFlag Flag for specifying what picks to return: just the first hit, all hits in an unsorted order or all hits sorted from closest to furthest.
filterFilters used to narrow down picked objects.
hitsReturned hits, detected.
Returns
true if an object was hit, false otherwise.

Definition at line 89 of file RayPick.cpp.

References Cogs::Core::AllSorted, Cogs::Core::AllUnsorted, Cogs::Core::EnablePicking, Cogs::Core::CameraComponent::flags, and pickables.

◆ pickRay()

bool Cogs::Core::RayPicking::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.

Parameters
contextCogs context.
positionStart position of ray.
rotationDirection of the ray.
rayLengthMax length of ray.
radiusRadius of ray.
pickingFlagsFlag for picking. Sprite picking root, or sub-entity return.
returnFlag Flag for specifying what picks to return: just the first hit, all hits in an unsorted order or all hits sorted from closest to furthest.
filterFilters used to narrow down picked objects.
hitsReturned hits, detected.Type with given hash value (Cogs::StringView(type).hash()). Default = RayPicking::NoPickEntityType
Returns
true if an object was hit, false otherwise.

Definition at line 129 of file RayPick.cpp.

References Cogs::Core::AllSorted, and Cogs::Core::AllUnsorted.

◆ removePickable()

void Cogs::Core::RayPicking::removePickable ( IRayPickable pickable)

Remove Component / System from custom picking.

Definition at line 165 of file RayPick.cpp.

Member Data Documentation

◆ NoPickEntityType

constexpr size_t Cogs::Core::RayPicking::NoPickEntityType = static_cast<size_t>(-1)
staticconstexpr

Definition at line 33 of file RayPick.h.

◆ NoPickTextureCoords

constexpr glm::vec2 Cogs::Core::RayPicking::NoPickTextureCoords = { std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN() }
staticconstexpr

Marks no match in texture.

Definition at line 32 of file RayPick.h.

◆ pickables

std::vector<IRayPickable *> Cogs::Core::RayPicking::pickables
private

Storage for registered pick extensions (addPickable)

Definition at line 135 of file RayPick.h.

Referenced by pickCamera().


The documentation for this class was generated from the following files: