Skip to content

Commit

Permalink
Change the type of the second parameter of frRaycastQueryFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeokkim committed Oct 7, 2024
1 parent 8a5d928 commit 8597603
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions examples/src/raycast.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void DeinitExample(void);

static void DrawCursor(void);

static void OnRaycastQuery(frRaycastHit raycastHit, frContextNode queryResult);
static void OnRaycastQuery(frRaycastHit raycastHit, void *ctx);

/* Public Functions ======================================================== */

Expand Down Expand Up @@ -228,8 +228,8 @@ static void DrawCursor(void) {
WHITE);
}

static void OnRaycastQuery(frRaycastHit raycastHit, frContextNode queryResult) {
const Color *ringColor = queryResult.ctx;
static void OnRaycastQuery(frRaycastHit raycastHit, void *ctx) {
const Color *ringColor = (Color *) ctx;

frDrawBodyAABB(raycastHit.body, 1.0f, *ringColor);

Expand Down
5 changes: 2 additions & 3 deletions include/ferox.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ typedef struct frContextNode_ {
typedef struct frSpatialHash_ frSpatialHash;

/* A callback function type for `frQuerySpatialHash()`. */
typedef bool (*frHashQueryFunc)(frContextNode queryResult);
typedef bool (*frHashQueryFunc)(frContextNode ctxNode);

/* (From 'collision.c') ==================================================== */

Expand Down Expand Up @@ -252,8 +252,7 @@ typedef struct frCollisionHandler_ {
} frCollisionHandler;

/* A callback function type for `frComputeRaycastForWorld()`. */
typedef void (*frRaycastQueryFunc)(frRaycastHit raycastHit,
frContextNode queryResult);
typedef void (*frRaycastQueryFunc)(frRaycastHit raycastHit, void *ctx);

/* Public Function Prototypes ============================================== */

Expand Down
10 changes: 4 additions & 6 deletions src/world.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,17 @@ static bool frPreStepHashQueryCallback(frContextNode queryResult) {
A callback function for `frQuerySpatialHash()`
that will be called during `frComputeRaycastForWorld()`.
*/
static bool frRaycastHashQueryCallback(frContextNode queryResult) {
frRaycastHashQueryCtx *queryCtx = queryResult.ctx;
static bool frRaycastHashQueryCallback(frContextNode ctxNode) {
frRaycastHashQueryCtx *queryCtx = ctxNode.ctx;

frRaycastHit raycastHit = { .distance = 0.0f };

if (!frComputeRaycast(queryCtx->world->bodies[queryResult.id],
if (!frComputeRaycast(queryCtx->world->bodies[ctxNode.id],
queryCtx->ray,
&raycastHit))
return false;

queryCtx->func(raycastHit,
(frContextNode) { .id = queryResult.id,
.ctx = queryCtx->ctx });
queryCtx->func(raycastHit, queryCtx->ctx);

return true;
}
Expand Down

0 comments on commit 8597603

Please sign in to comment.