aboutsummaryrefslogtreecommitdiffstats
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
parentefl/eeze: fix typo (diff)
downloadefl-9e0788cc2e261ec66cf740e35a3e71f4485df763.tar.gz
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 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ephysics_private.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct _EPhysics_Shape {
+ Eina_Inlist *points;
+};
+
+static EPhysics_Point *
+_ephysics_shape_point_new(void)
+{
+ EPhysics_Point *point;
+
+ point = (EPhysics_Point *)calloc(1, sizeof(EPhysics_Point));
+ if (!point)
+ {
+ ERR("Failed to allocate point.");
+ return NULL;
+ }
+
+ return point;
+}
+
+const Eina_Inlist *
+ephysics_shape_points_get(const EPhysics_Shape *shape)
+{
+ return shape->points;
+}
+
+EAPI EPhysics_Shape *
+ephysics_shape_new(void)
+{
+ EPhysics_Shape *shape;
+
+ shape = (EPhysics_Shape *)calloc(1, sizeof(EPhysics_Shape));
+ if (!shape)
+ {
+ ERR("Failed to allocate shape.");
+ return NULL;
+ }
+
+ return shape;
+}
+
+EAPI void
+ephysics_shape_del(EPhysics_Shape *shape)
+{
+ EPhysics_Point *point;
+
+ if (!shape)
+ {
+ ERR("Can't delete shape, it's null.");
+ return;
+ }
+
+ while (shape->points)
+ {
+ point = EINA_INLIST_CONTAINER_GET(shape->points, EPhysics_Point);
+ shape->points = eina_inlist_remove(shape->points, shape->points);
+ free(point);
+ }
+
+ free(shape);
+}
+
+EAPI Eina_Bool
+ephysics_shape_point_add(EPhysics_Shape *shape, double x, double y, double z)
+{
+ EPhysics_Point *point;
+
+ if (!shape)
+ {
+ ERR("Can't add point to shape, it's null.");
+ return EINA_FALSE;;
+ }
+
+ point = _ephysics_shape_point_new();
+ if (!point)
+ return EINA_FALSE;;
+
+ point->x = x;
+ point->y = y;
+ point->z = z;
+
+ shape->points = eina_inlist_append(shape->points, EINA_INLIST_GET(point));
+
+ return EINA_TRUE;
+}
+
+/* TODO: load points from file */
+EAPI EPhysics_Shape *
+ephysics_shape_load(const char *filename EINA_UNUSED)
+{
+ EPhysics_Shape *shape;
+
+ shape = ephysics_shape_new();
+ if (!shape)
+ return NULL;
+
+ return shape;
+}
+
+/* TODO: save points to file */
+EAPI Eina_Bool
+ephysics_shape_save(const EPhysics_Shape *shape EINA_UNUSED, const char *filename EINA_UNUSED)
+{
+ return EINA_TRUE;
+}
+
+#ifdef __cplusplus
+}
+#endif