Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
PhysicsRaycaster Class Reference

Class responsible for raycasting in the physics world. More...

#include <physics_raycaster.h>

Public Member Functions

 PhysicsRaycaster (b2WorldId world_id)
 
ColliderRayResult raycast_closest (const b2Vec2 &origin, const b2Vec2 &translation)
 Closest hit.
 
std::vector< ColliderRayResultraycast_all (const b2Vec2 &origin, const b2Vec2 &translation, b2QueryFilter filter={})
 All hits.
 
std::vector< ColliderRayResultraycast_filtered (const b2Vec2 &origin, const b2Vec2 &translation, uint16_t category_mask)
 Filtered hits by category mask.
 
ColliderRayResult raycast_segment (const b2Vec2 &start, const b2Vec2 &end)
 Raycast segment.
 

Detailed Description

Class responsible for raycasting in the physics world.

This class provides functionality to perform raycasting operations within the Box2D physics simulation.

Constructor & Destructor Documentation

◆ PhysicsRaycaster()

PhysicsRaycaster::PhysicsRaycaster ( b2WorldId  world_id)

Member Function Documentation

◆ raycast_all()

std::vector< ColliderRayResult > PhysicsRaycaster::raycast_all ( const b2Vec2 &  origin,
const b2Vec2 &  translation,
b2QueryFilter  filter = {} 
)

All hits.

Returns all hits along the ray, sorted by distance from the origin.

Parameters
originThe starting point of the ray.
translationThe direction and length of the ray.
filterThe query filter to apply.
Returns
std::vector<ColliderRayResult> A vector of all raycast results.

◆ raycast_closest()

ColliderRayResult PhysicsRaycaster::raycast_closest ( const b2Vec2 &  origin,
const b2Vec2 &  translation 
)

Closest hit.

Meant for simple raycasts where only the closest hit is needed.

Parameters
originThe starting point of the ray.
translationThe direction and length of the ray.
Returns
ColliderRayResult The result of the closest hit.

◆ raycast_filtered()

std::vector< ColliderRayResult > PhysicsRaycaster::raycast_filtered ( const b2Vec2 &  origin,
const b2Vec2 &  translation,
uint16_t  category_mask 
)

Filtered hits by category mask.

Returns all hits along the ray that match the given category mask.

Parameters
originThe starting point of the ray.
translationThe direction and length of the ray.
category_maskThe category mask to filter results.
Returns
std::vector<ColliderRayResult> A vector of filtered raycast results

◆ raycast_segment()

ColliderRayResult PhysicsRaycaster::raycast_segment ( const b2Vec2 &  start,
const b2Vec2 &  end 
)

Raycast segment.

Performs a raycast between two points, returning the first hit encountered.

Parameters
startThe starting point of the segment.
endThe ending point of the segment.
Returns
ColliderRayResult The result of the segment raycast.

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