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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/***
* libccd
* ---------------------------------
* Copyright (c)2010 Daniel Fiser <danfis@danfis.cz>
*
*
* This file is part of libccd.
*
* Distributed under the OSI-approved BSD License (the "License");
* see accompanying file BDS-LICENSE for details or see
* <http://www.opensource.org/licenses/bsd-license.php>.
*
* This software is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the License for more information.
*/
/***
* Some support() functions for some convex shapes.
*/
#ifndef __CCD_SUPPORT_H__
#define __CCD_SUPPORT_H__
#include <ccd/quat.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define CCD_OBJ_BOX 1
#define CCD_OBJ_SPHERE 2
#define CCD_OBJ_CYL 3
#define __CCD_OBJ__ \
int type; \
ccd_vec3_t pos; \
ccd_quat_t quat;
struct _ccd_obj_t {
__CCD_OBJ__
};
typedef struct _ccd_obj_t ccd_obj_t;
struct _ccd_box_t {
__CCD_OBJ__
ccd_real_t x, y, z; //!< Lengths of box's edges
};
typedef struct _ccd_box_t ccd_box_t;
struct _ccd_sphere_t {
__CCD_OBJ__
ccd_real_t radius;
};
typedef struct _ccd_sphere_t ccd_sphere_t;
struct _ccd_cyl_t {
__CCD_OBJ__
ccd_real_t radius;
ccd_real_t height;
};
typedef struct _ccd_cyl_t ccd_cyl_t;
#define CCD_BOX(name) \
ccd_box_t name = { .type = CCD_OBJ_BOX, \
.pos = { .v = { 0., 0., 0. } }, \
.quat = { .q = { 0., 0., 0., 1. } }, \
.x = 0., \
.y = 0., \
.z = 0. }
#define CCD_SPHERE(name) \
ccd_sphere_t name = { .type = CCD_OBJ_SPHERE, \
.pos = { .v = { 0., 0., 0. } }, \
.quat = { .q = { 0., 0., 0., 1. } }, \
.radius = 0. }
#define CCD_CYL(name) \
ccd_cyl_t name = { .type = CCD_OBJ_CYL, \
.pos = { .v = { 0., 0., 0. } }, \
.quat = { .q = { 0., 0., 0., 1. } }, \
.radius = 0., \
.height = 0. }
/**
* Returns supporting vertex via v.
* Supporting vertex is fathest vertex from object in direction dir.
*/
void ccdSupport(const void *obj, const ccd_vec3_t *dir,
ccd_vec3_t *v);
/**
* Returns center of object.
*/
void ccdObjCenter(const void *obj, ccd_vec3_t *center);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif /* __CCD_SUPPORT_H__ */
|