Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
SelectionFinder Class Reference

Helper class to perform raycasting and find selected entities in the game world. More...

#include <SelectionFinder.hpp>

+ Collaboration diagram for SelectionFinder:

Classes

struct  Selection
 

Public Types

enum class  EntityType { None , Player , Egg , Tile }
 

Static Public Member Functions

static Selection findFromRay (const Ray &ray, const GameState &state, float tileSize, const Model &playerModel, float playerModelSize, const Model &eggModel, float eggModelSize, const TileSlotMap &slotMap)
 Performs raycast and finds closest entity.
 
static Selection getEmptySelection ()
 Returns an empty selection (type None).
 

Detailed Description

Helper class to perform raycasting and find selected entities in the game world.

Definition at line 14 of file SelectionFinder.hpp.

Member Enumeration Documentation

◆ EntityType

enum class SelectionFinder::EntityType
strong
Enumerator
None 
Player 
Egg 
Tile 

Definition at line 16 of file SelectionFinder.hpp.

Member Function Documentation

◆ findFromRay()

SelectionFinder::Selection SelectionFinder::findFromRay ( const Ray &  ray,
const GameState state,
float  tileSize,
const Model &  playerModel,
float  playerModelSize,
const Model &  eggModel,
float  eggModelSize,
const TileSlotMap slotMap 
)
static

Performs raycast and finds closest entity.

Parameters
rayMouse ray from camera.
stateGame state to check entities against.
tileSizeSize of each tile in world units.
playerModelPlayer model for mesh-accurate raycasting.
playerModelSizePlayer model scale scalar.
eggModelEgg model for mesh-accurate raycasting.
eggModelSizeEgg model scale scalar.
Returns
Selection struct with closest hit entity.

Definition at line 9 of file SelectionFinder.cpp.

References Egg, WorldState::eggs, TileSlotMap::eggSlot(), WorldState::height, SelectionFinder::Selection::id, Player, WorldState::players, TileSlotMap::slotOffset(), Tile, RenderingHelper::tileToWorld(), SelectionFinder::Selection::tileX, SelectionFinder::Selection::tileY, SelectionFinder::Selection::type, WorldState::width, and GameState::world.

Referenced by RaylibRenderer::_performRaycast().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEmptySelection()

SelectionFinder::Selection SelectionFinder::getEmptySelection ( )
static

Returns an empty selection (type None).

Returns
Selection with type None and default values.

Definition at line 82 of file SelectionFinder.cpp.

References None, and SelectionFinder::Selection::type.

Referenced by RaylibRenderer::_performRaycast(), and RaylibRenderer::init().

+ Here is the caller graph for this function:

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