forked from enlightenment/efl
EPhysics: add ephysics_body_sphere_add() API
SVN revision: 80717
This commit is contained in:
parent
c90d6c5842
commit
44a9b9a350
|
@ -146,7 +146,7 @@ _type_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
|
|||
}
|
||||
else
|
||||
{
|
||||
body = ephysics_body_cylinder_add(world);
|
||||
body = ephysics_body_sphere_add(world);
|
||||
elm_object_disabled_set(bd->controls.hardness, EINA_TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ _world_populate(Test_Data *test_data)
|
|||
evas_object_show(sphere);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
|
||||
|
||||
fall_body = ephysics_body_cylinder_add(test_data->world);
|
||||
fall_body = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(fall_body, 0.95);
|
||||
ephysics_body_friction_set(fall_body, 0.1);
|
||||
|
|
|
@ -95,10 +95,10 @@ _world_populate(Camera_Data *camera_data)
|
|||
camera_data->base.evas_objs = eina_list_append(camera_data->base.evas_objs,
|
||||
sphere);
|
||||
|
||||
fall_body = ephysics_body_cylinder_add(camera_data->base.world);
|
||||
fall_body = ephysics_body_sphere_add(camera_data->base.world);
|
||||
ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(fall_body, 0.2);
|
||||
ephysics_body_friction_set(fall_body, 0.5);
|
||||
ephysics_body_friction_set(fall_body, 1);
|
||||
ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
update_object_cb, shadow);
|
||||
camera_data->base.bodies = eina_list_append(camera_data->base.bodies,
|
||||
|
@ -123,8 +123,8 @@ _world_populate(Camera_Data *camera_data)
|
|||
camera_data->base.evas_objs = eina_list_append(camera_data->base.evas_objs,
|
||||
sphere);
|
||||
|
||||
fall_body = ephysics_body_cylinder_add(camera_data->base.world);
|
||||
ephysics_body_mass_set(fall_body, 3.7);
|
||||
fall_body = ephysics_body_sphere_add(camera_data->base.world);
|
||||
ephysics_body_mass_set(fall_body, 4.6);
|
||||
ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(fall_body, 0.12);
|
||||
ephysics_body_friction_set(fall_body, 2);
|
||||
|
|
|
@ -126,7 +126,7 @@ _world_populate(Track_Data *track_data)
|
|||
track_data->base.evas_objs = eina_list_append(track_data->base.evas_objs,
|
||||
sphere);
|
||||
|
||||
body = ephysics_body_cylinder_add(track_data->base.world);
|
||||
body = ephysics_body_sphere_add(track_data->base.world);
|
||||
ephysics_body_evas_object_set(body, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(body, 0.95);
|
||||
ephysics_body_friction_set(body, 1);
|
||||
|
|
|
@ -36,13 +36,13 @@ _world_populate(Test_Data *test_data)
|
|||
evas_object_show(sphere);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
|
||||
|
||||
fall_body = ephysics_body_cylinder_add(test_data->world);
|
||||
fall_body = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
|
||||
ephysics_body_event_callback_add(fall_body,
|
||||
EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
update_object_cb, shadow);
|
||||
ephysics_body_restitution_set(fall_body, 0.95);
|
||||
ephysics_body_friction_set(fall_body, 0.1);
|
||||
ephysics_body_friction_set(fall_body, 1);
|
||||
test_data->bodies = eina_list_append(test_data->bodies, fall_body);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ _world_populate(Collision_Data *collision_data)
|
|||
collision_data->base.evas_objs = eina_list_append(
|
||||
collision_data->base.evas_objs, sphere1);
|
||||
|
||||
sphere_body1 = ephysics_body_cylinder_add(collision_data->base.world);
|
||||
sphere_body1 = ephysics_body_sphere_add(collision_data->base.world);
|
||||
ephysics_body_evas_object_set(sphere_body1, sphere1, EINA_TRUE);
|
||||
ephysics_body_event_callback_add(sphere_body1,
|
||||
EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
|
@ -88,7 +88,7 @@ _world_populate(Collision_Data *collision_data)
|
|||
collision_data->base.evas_objs = eina_list_append(
|
||||
collision_data->base.evas_objs, sphere2);
|
||||
|
||||
sphere_body2 = ephysics_body_cylinder_add(collision_data->base.world);
|
||||
sphere_body2 = ephysics_body_sphere_add(collision_data->base.world);
|
||||
ephysics_body_evas_object_set(sphere_body2, sphere2, EINA_TRUE);
|
||||
ephysics_body_event_callback_add(sphere_body2,
|
||||
EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
|
|
|
@ -29,7 +29,7 @@ _world_populate(Test_Data *test_data)
|
|||
evas_object_show(sphere);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
|
||||
|
||||
fall_body = ephysics_body_cylinder_add(test_data->world);
|
||||
fall_body = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(fall_body, 0.95);
|
||||
ephysics_body_friction_set(fall_body, 0.1);
|
||||
|
|
|
@ -50,7 +50,7 @@ _world_populate(Speed_Data *speed_data)
|
|||
speed_data->base.evas_objs = eina_list_append(speed_data->base.evas_objs,
|
||||
sphere);
|
||||
|
||||
ball = ephysics_body_cylinder_add(speed_data->base.world);
|
||||
ball = ephysics_body_sphere_add(speed_data->base.world);
|
||||
ephysics_body_evas_object_set(ball, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(ball, 0.8);
|
||||
ephysics_body_friction_set(ball, 0.2);
|
||||
|
|
|
@ -75,7 +75,7 @@ _world_populate(Collision_Data *collision_data)
|
|||
collision_data->base.evas_objs = eina_list_append(
|
||||
collision_data->base.evas_objs, sphere1);
|
||||
|
||||
sphere_body1 = ephysics_body_cylinder_add(collision_data->base.world);
|
||||
sphere_body1 = ephysics_body_sphere_add(collision_data->base.world);
|
||||
ephysics_body_evas_object_set(sphere_body1, sphere1, EINA_TRUE);
|
||||
ephysics_body_event_callback_add(sphere_body1,
|
||||
EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
|
@ -108,7 +108,7 @@ _world_populate(Collision_Data *collision_data)
|
|||
collision_data->base.evas_objs = eina_list_append(
|
||||
collision_data->base.evas_objs, sphere2);
|
||||
|
||||
sphere_body2 = ephysics_body_cylinder_add(collision_data->base.world);
|
||||
sphere_body2 = ephysics_body_sphere_add(collision_data->base.world);
|
||||
ephysics_body_evas_object_set(sphere_body2, sphere2, EINA_TRUE);
|
||||
ephysics_body_event_callback_add(sphere_body2,
|
||||
EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
|
|
|
@ -41,7 +41,7 @@ _add_sphere(Test_Data *test_data, const char *group, int size, int x, int y)
|
|||
evas_object_show(sphere);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
|
||||
|
||||
sphere_body = ephysics_body_cylinder_add(test_data->world);
|
||||
sphere_body = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(sphere_body, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(sphere_body, 0.5);
|
||||
ephysics_body_central_impulse_apply(sphere_body, 300, 0, 0);
|
||||
|
|
|
@ -19,7 +19,7 @@ _add_sphere(Test_Data *test_data, int i)
|
|||
evas_object_show(sphere);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
|
||||
|
||||
body = ephysics_body_cylinder_add(test_data->world);
|
||||
body = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_restitution_set(body, 0.85);
|
||||
ephysics_body_evas_object_set(body, sphere, EINA_TRUE);
|
||||
test_data->bodies = eina_list_append(test_data->bodies, body);
|
||||
|
|
|
@ -59,14 +59,12 @@ _add_sphere(Test_Data *test_data, int i)
|
|||
evas_object_show(sphere);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
|
||||
|
||||
fall_body = ephysics_body_cylinder_add(test_data->world);
|
||||
ephysics_body_linear_movement_enable_set(fall_body, EINA_TRUE, EINA_TRUE,
|
||||
EINA_TRUE);
|
||||
fall_body = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
|
||||
ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
update_object_cb, shadow);
|
||||
ephysics_body_restitution_set(fall_body, 0.95);
|
||||
ephysics_body_friction_set(fall_body, 0.1);
|
||||
ephysics_body_friction_set(fall_body, 1);
|
||||
test_data->bodies = eina_list_append(test_data->bodies, fall_body);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ _ball_add(Test_Data *test_data, int x)
|
|||
evas_object_show(sphere);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
|
||||
|
||||
ball = ephysics_body_cylinder_add(test_data->world);
|
||||
ball = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(ball, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(ball, 0.95);
|
||||
ephysics_body_friction_set(ball, 0.1);
|
||||
|
|
|
@ -56,7 +56,7 @@ _world_populate(Test_Data *test_data)
|
|||
evas_object_show(sphere);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
|
||||
|
||||
fall_body = ephysics_body_cylinder_add(test_data->world);
|
||||
fall_body = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
|
||||
ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
update_object_cb, shadow);
|
||||
|
|
|
@ -27,7 +27,7 @@ _world_populate(Test_Data *test_data)
|
|||
evas_object_show(sphere1);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere1);
|
||||
|
||||
sphere_body1 = ephysics_body_cylinder_add(test_data->world);
|
||||
sphere_body1 = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(sphere_body1, sphere1, EINA_TRUE);
|
||||
ephysics_body_event_callback_add(sphere_body1,
|
||||
EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
|
@ -55,7 +55,7 @@ _world_populate(Test_Data *test_data)
|
|||
evas_object_show(sphere2);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere2);
|
||||
|
||||
sphere_body2 = ephysics_body_cylinder_add(test_data->world);
|
||||
sphere_body2 = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(sphere_body2, sphere2, EINA_TRUE);
|
||||
ephysics_body_event_callback_add(sphere_body2,
|
||||
EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
|
|
|
@ -76,7 +76,7 @@ _world_populate(Test_Data *test_data)
|
|||
evas_object_show(evas_obj);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
|
||||
|
||||
fall_body = ephysics_body_cylinder_add(test_data->world);
|
||||
fall_body = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_mass_set(fall_body, 2);
|
||||
ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
|
||||
ephysics_body_restitution_set(fall_body, 0.95);
|
||||
|
|
|
@ -106,7 +106,7 @@ _world_populate(Velocity_Data *velocity_data)
|
|||
velocity_data->base.evas_objs = eina_list_append(
|
||||
velocity_data->base.evas_objs, sphere);
|
||||
|
||||
sphere_body = ephysics_body_cylinder_add(velocity_data->base.world);
|
||||
sphere_body = ephysics_body_sphere_add(velocity_data->base.world);
|
||||
ephysics_body_evas_object_set(sphere_body, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(sphere_body, 0.8);
|
||||
ephysics_body_friction_set(sphere_body, 1);
|
||||
|
|
|
@ -136,7 +136,7 @@ _world_populate(Test_Data *test_data)
|
|||
evas_object_show(sphere);
|
||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
|
||||
|
||||
sphere_body = ephysics_body_cylinder_add(test_data->world);
|
||||
sphere_body = ephysics_body_sphere_add(test_data->world);
|
||||
ephysics_body_evas_object_set(sphere_body, sphere, EINA_TRUE);
|
||||
ephysics_body_restitution_set(sphere_body, 1.0);
|
||||
ephysics_body_event_callback_add(sphere_body, EPHYSICS_CALLBACK_BODY_UPDATE,
|
||||
|
|
|
@ -2668,6 +2668,30 @@ EAPI void ephysics_body_soft_body_triangle_move(EPhysics_Body *body, int idx, Ev
|
|||
*/
|
||||
EAPI void ephysics_body_soft_body_bending_constraints_add(EPhysics_Body *body, int number);
|
||||
|
||||
/**
|
||||
* @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.
|
||||
|
|
|
@ -2840,6 +2840,33 @@ no_collision_shape:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue