aboutsummaryrefslogtreecommitdiffstats
path: root/legacy/ephysics/src/lib
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-12-11 21:11:00 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2012-12-11 21:11:00 +0000
commit44a9b9a350589b53682381f2a5b0dfceb3acd7fc (patch)
tree62150a284f2f732fa9c9f9d5784e04225eebbae6 /legacy/ephysics/src/lib
parentc90d6c58426c40ebbd15e7d409fb61c195eecb31 (diff)
downloadefl-44a9b9a350589b53682381f2a5b0dfceb3acd7fc.tar.gz
efl-44a9b9a350589b53682381f2a5b0dfceb3acd7fc.tar.xz
efl-44a9b9a350589b53682381f2a5b0dfceb3acd7fc.zip
EPhysics: add ephysics_body_sphere_add() API
SVN revision: 80717
Diffstat (limited to 'legacy/ephysics/src/lib')
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h24
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp27
-rw-r--r--legacy/ephysics/src/lib/ephysics_private.h1
3 files changed, 52 insertions, 0 deletions
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index ec6d79981..888e4be00 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -2670,6 +2670,30 @@ EAPI void ephysics_body_soft_body_bending_constraints_add(EPhysics_Body *body, i
/**
* @brief
+ * Create a new sphere physics body.
+ *
+ * Its collision shape will be a sphere of diameter 1. To change its size @ref
+ * ephysics_body_geometry_set(), @p ephysics_body_resize() should be used.
+ *
+ * Any evas object can be associated to it with @p
+ * ephysics_body_evas_object_set(), and it will collid as a sphere(even if
+ * you`ve associated an evas rectangle).
+ *
+ * For deformable sphere use @p ephysics_body_soft_ellipsoid_add() instead.
+ *
+ * @param world The world this body will belong to.
+ * @return a new body or @c NULL, on errors.
+ *
+ * @see ephysics_body_del().
+ * @see ephysics_body_evas_object_set().
+ * @see ephysics_body_face_evas_object_set().
+ *
+ * @ingroup EPhysics_Body
+ */
+EAPI EPhysics_Body *ephysics_body_sphere_add(EPhysics_World *world);
+
+/**
+ * @brief
* Create a new cylinder physics body.
*
* Its collision shape will be a cylinder of diameter 1. To change it's size
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 5c7a061e6..5fde81180 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -2841,6 +2841,33 @@ no_collision_shape:
}
EAPI EPhysics_Body *
+ephysics_body_sphere_add(EPhysics_World *world)
+{
+ btCollisionShape *collision_shape;
+ EPhysics_Body *body;
+
+ if (!world)
+ {
+ ERR("Can't add sphere, world is null.");
+ return NULL;
+ }
+
+ collision_shape = new btSphereShape(0.5);
+ if (!collision_shape)
+ {
+ ERR("Couldn't create a new sphere shape.");
+ return NULL;
+ }
+
+ ephysics_world_lock_take(world);
+ body = _ephysics_body_rigid_body_add(world, collision_shape, "sphere", 0.5,
+ 0.5, 0.5);
+ body->shape = EPHYSICS_BODY_SHAPE_SPHERE;
+ ephysics_world_lock_release(world);
+ return body;
+}
+
+EAPI EPhysics_Body *
ephysics_body_cylinder_add(EPhysics_World *world)
{
btCollisionShape *collision_shape;
diff --git a/legacy/ephysics/src/lib/ephysics_private.h b/legacy/ephysics/src/lib/ephysics_private.h
index 3e7050b48..994561a4a 100644
--- a/legacy/ephysics/src/lib/ephysics_private.h
+++ b/legacy/ephysics/src/lib/ephysics_private.h
@@ -66,6 +66,7 @@ typedef enum _EPhysics_Body_Shape
EPHYSICS_BODY_SHAPE_BOX,
EPHYSICS_BODY_SHAPE_CUSTOM,
EPHYSICS_BODY_SHAPE_CYLINDER,
+ EPHYSICS_BODY_SHAPE_SPHERE,
EPHYSICS_BODY_SHAPE_ELLIPSOID,
EPHYSICS_BODY_SHAPE_LAST,
} EPhysics_Body_Shape;