summaryrefslogtreecommitdiff
path: root/src/ix2.h
blob: 2785f364990ead91976a7a930507def5ea56eee8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 *  Copyright (C) 2018  Vito Caputo - <vcaputo@pengaru.com>
 *
 *  This program is free software: you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License version 3 as published
 *  by the Free Software Foundation.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _IX2_H
#define _IX2_H

typedef struct ix2_object_t ix2_object_t;
typedef struct ix2_t ix2_t;
typedef struct bb2f_t bb2f_t;
typedef struct v2f_t v2f_t;

typedef enum ix2_search_status_t {
	IX2_SEARCH_STOP_MISS,	/* stop && current object is a miss */
	IX2_SEARCH_STOP_HIT,	/* stop && current object is a hit */
	IX2_SEARCH_MORE_MISS,	/* continue && current object is a miss */
	IX2_SEARCH_MORE_HIT,	/* continue && current object is a miss */
} ix2_search_status_t;

typedef ix2_search_status_t (ix2_search_cb)(void *cb_context, ix2_object_t *ix2_object, v2f_t *ix2_object_position, bb2f_t *ix2_object_aabb, void *object);

ix2_t * ix2_new(bb2f_t *aabb, unsigned max_per_node, unsigned max_depth);
void ix2_reset(ix2_t *ix2);
void ix2_free(ix2_t *ix2);
ix2_object_t * ix2_object_new(ix2_t *ix2, v2f_t *position, v2f_t *origin, bb2f_t *aabb, void *object);
void ix2_object_free(ix2_t *ix2, ix2_object_t *object);
ix2_object_t * ix2_object_move(ix2_t *ix2, ix2_object_t *object, v2f_t *object_position, v2f_t *object_origin, bb2f_t *object_aabb);
int ix2_object_aabb_overlap(ix2_t *ix2, ix2_object_t *object, v2f_t *aabb_position, v2f_t *aabb_origin, bb2f_t *aabb);
unsigned ix2_search_by_point(ix2_t *ix2, v2f_t *point, ix2_search_cb *cb, void *arg);
unsigned ix2_search_by_aabb(ix2_t *ix2, v2f_t *search_position, v2f_t *search_origin, bb2f_t *search_aabb, ix2_search_cb *cb, void *arg);
unsigned ix2_search_by_ray(ix2_t *ix2, v2f_t *origin, v2f_t *direction, ix2_search_cb *cb, void *arg);

#endif
© All Rights Reserved