summaryrefslogtreecommitdiff
path: root/src/lib/ephysics/ephysics_shape.cpp
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-03 22:10:40 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-03 22:10:40 +0000
commit9e0788cc2e261ec66cf740e35a3e71f4485df763 (patch)
tree8c1230e446edd6966d39c1b8959c7f97f5c0f731 /src/lib/ephysics/ephysics_shape.cpp
parent9edec477ebb83e64f3e464d82665e2b9f01f9bb0 (diff)
efl: merge ephysics
changes: * __UNUSED__ -> EINA_UNUSED * Fixed doc hierarchy SVN revision: 82126
Diffstat (limited to 'src/lib/ephysics/ephysics_shape.cpp')
-rw-r--r--src/lib/ephysics/ephysics_shape.cpp118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/lib/ephysics/ephysics_shape.cpp b/src/lib/ephysics/ephysics_shape.cpp
new file mode 100644
index 0000000000..e2fa6d25a6
--- /dev/null
+++ b/src/lib/ephysics/ephysics_shape.cpp
@@ -0,0 +1,118 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "ephysics_private.h"
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11struct _EPhysics_Shape {
12 Eina_Inlist *points;
13};
14
15static EPhysics_Point *
16_ephysics_shape_point_new(void)
17{
18 EPhysics_Point *point;
19
20 point = (EPhysics_Point *)calloc(1, sizeof(EPhysics_Point));
21 if (!point)
22 {
23 ERR("Failed to allocate point.");
24 return NULL;
25 }
26
27 return point;
28}
29
30const Eina_Inlist *
31ephysics_shape_points_get(const EPhysics_Shape *shape)
32{
33 return shape->points;
34}
35
36EAPI EPhysics_Shape *
37ephysics_shape_new(void)
38{
39 EPhysics_Shape *shape;
40
41 shape = (EPhysics_Shape *)calloc(1, sizeof(EPhysics_Shape));
42 if (!shape)
43 {
44 ERR("Failed to allocate shape.");
45 return NULL;
46 }
47
48 return shape;
49}
50
51EAPI void
52ephysics_shape_del(EPhysics_Shape *shape)
53{
54 EPhysics_Point *point;
55
56 if (!shape)
57 {
58 ERR("Can't delete shape, it's null.");
59 return;
60 }
61
62 while (shape->points)
63 {
64 point = EINA_INLIST_CONTAINER_GET(shape->points, EPhysics_Point);
65 shape->points = eina_inlist_remove(shape->points, shape->points);
66 free(point);
67 }
68
69 free(shape);
70}
71
72EAPI Eina_Bool
73ephysics_shape_point_add(EPhysics_Shape *shape, double x, double y, double z)
74{
75 EPhysics_Point *point;
76
77 if (!shape)
78 {
79 ERR("Can't add point to shape, it's null.");
80 return EINA_FALSE;;
81 }
82
83 point = _ephysics_shape_point_new();
84 if (!point)
85 return EINA_FALSE;;
86
87 point->x = x;
88 point->y = y;
89 point->z = z;
90
91 shape->points = eina_inlist_append(shape->points, EINA_INLIST_GET(point));
92
93 return EINA_TRUE;
94}
95
96/* TODO: load points from file */
97EAPI EPhysics_Shape *
98ephysics_shape_load(const char *filename EINA_UNUSED)
99{
100 EPhysics_Shape *shape;
101
102 shape = ephysics_shape_new();
103 if (!shape)
104 return NULL;
105
106 return shape;
107}
108
109/* TODO: save points to file */
110EAPI Eina_Bool
111ephysics_shape_save(const EPhysics_Shape *shape EINA_UNUSED, const char *filename EINA_UNUSED)
112{
113 return EINA_TRUE;
114}
115
116#ifdef __cplusplus
117}
118#endif