forked from enlightenment/efl
EPhysics: cloth add receives the number of rows and
columns Patch by: Leandro Dorileo <dorileo@profusion.mobi> SVN revision: 78487
This commit is contained in:
parent
b0bd7beac3
commit
6eb262cdbb
|
@ -97,7 +97,7 @@ _world_populate(Test_Data *test_data)
|
||||||
evas_object_show(evas_obj);
|
evas_object_show(evas_obj);
|
||||||
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
|
test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
|
||||||
|
|
||||||
flag_body = ephysics_body_cloth_add(test_data->world, 0);
|
flag_body = ephysics_body_cloth_add(test_data->world, 0, 0);
|
||||||
ephysics_body_mass_set(flag_body, 10);
|
ephysics_body_mass_set(flag_body, 10);
|
||||||
ephysics_body_soft_body_hardness_set(flag_body, 1);
|
ephysics_body_soft_body_hardness_set(flag_body, 1);
|
||||||
evas_obj = ephysics_body_evas_object_set(flag_body, evas_obj, EINA_TRUE);
|
evas_obj = ephysics_body_evas_object_set(flag_body, evas_obj, EINA_TRUE);
|
||||||
|
|
|
@ -2070,25 +2070,21 @@ EAPI EPhysics_Body *ephysics_body_soft_box_add(EPhysics_World *world);
|
||||||
* Create a new deformable cloth physics body.
|
* Create a new deformable cloth physics body.
|
||||||
*
|
*
|
||||||
* A cloth has its points of deformation conceptually split into rows and
|
* A cloth has its points of deformation conceptually split into rows and
|
||||||
* columns
|
* columns where every square is also split into two triangles - afore named
|
||||||
* where every square is also split into two triangles - afore named nodes. To
|
* nodes. To fine tune the deformation one can increase this granularity by
|
||||||
* fine tune the deformation one can increase this granularity by increasing the
|
* increasing the number of @p rows and @p columns.
|
||||||
* @p granularity parameter.
|
|
||||||
*
|
*
|
||||||
* The number of rows is always proportional to the number of columns, for
|
* By default - if passed 0 as @p rows and @p columns - EPhysics creates a cloth
|
||||||
* example passing @p granularity of 20 will create a cloth with 20 rows and 20
|
* with 15 rows and 15 columns, these default values will generally fit the most
|
||||||
* columns.
|
* common scenarios.
|
||||||
*
|
*
|
||||||
* By default EPhysics creates a cloth with 15 rows and 15 columns, these
|
* If the informed @p rows is of 0 then the default value - of 15 - is
|
||||||
* default values will generally fit the most common scenarios.
|
* assumed. The same is true for @p columns.
|
||||||
*
|
|
||||||
* If the informed @p granularity is of 0 then the default value - of 15 - is
|
|
||||||
* assumed.
|
|
||||||
*
|
*
|
||||||
* @param world The world this body will belong to.
|
* @param world The world this body will belong to.
|
||||||
* @param granularity Define - proportionally - the number of rows and columns,
|
* @param rows The number os rows.
|
||||||
* if 0 the default value - of 15 - is assumed.
|
* @param columns The number of columns.
|
||||||
* @return a bew body or @c NULL on erros.
|
* @return a new body or @c NULL on erros.
|
||||||
*
|
*
|
||||||
* @see ephysics_body_del().
|
* @see ephysics_body_del().
|
||||||
* @see ephysics_body_evas_object_set().
|
* @see ephysics_body_evas_object_set().
|
||||||
|
@ -2098,7 +2094,7 @@ EAPI EPhysics_Body *ephysics_body_soft_box_add(EPhysics_World *world);
|
||||||
*
|
*
|
||||||
* @ingroup EPhysics_Body
|
* @ingroup EPhysics_Body
|
||||||
*/
|
*/
|
||||||
EAPI EPhysics_Body *ephysics_body_cloth_add(EPhysics_World *world, unsigned short granularity);
|
EAPI EPhysics_Body *ephysics_body_cloth_add(EPhysics_World *world, unsigned short rows, unsigned short columns);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
|
|
|
@ -1613,13 +1613,13 @@ ephysics_body_soft_body_position_iterations_get(EPhysics_Body *body)
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI EPhysics_Body *
|
EAPI EPhysics_Body *
|
||||||
ephysics_body_cloth_add(EPhysics_World *world, unsigned short granularity)
|
ephysics_body_cloth_add(EPhysics_World *world, unsigned short rows, unsigned short columns)
|
||||||
{
|
{
|
||||||
EPhysics_Body *body;
|
EPhysics_Body *body;
|
||||||
btSoftBodyWorldInfo *world_info;
|
btSoftBodyWorldInfo *world_info;
|
||||||
btSoftBody *soft_body;
|
btSoftBody *soft_body;
|
||||||
const int rows = (!granularity) ? 15 : granularity;
|
const int body_rows = (!rows) ? 15 : rows;
|
||||||
const int columns = (!granularity) ? 15 : granularity;
|
const int body_columns = (!columns) ? 15 : columns;
|
||||||
|
|
||||||
if (!world)
|
if (!world)
|
||||||
{
|
{
|
||||||
|
@ -1633,7 +1633,8 @@ ephysics_body_cloth_add(EPhysics_World *world, unsigned short granularity)
|
||||||
btVector3(2, 1, 0),
|
btVector3(2, 1, 0),
|
||||||
btVector3(1, 2, 0),
|
btVector3(1, 2, 0),
|
||||||
btVector3(1, 1, 0),
|
btVector3(1, 1, 0),
|
||||||
rows, columns, 0, false);
|
body_rows, body_columns, 0, false);
|
||||||
|
|
||||||
if (!soft_body)
|
if (!soft_body)
|
||||||
{
|
{
|
||||||
ERR("Couldn't create a new soft body.");
|
ERR("Couldn't create a new soft body.");
|
||||||
|
@ -1648,7 +1649,7 @@ ephysics_body_cloth_add(EPhysics_World *world, unsigned short granularity)
|
||||||
|
|
||||||
soft_body->appendMaterial();
|
soft_body->appendMaterial();
|
||||||
body->material_index = 1;
|
body->material_index = 1;
|
||||||
soft_body->m_cfg.piterations = rows / 5;
|
soft_body->m_cfg.piterations = body_rows / 5;
|
||||||
|
|
||||||
_ephysics_body_soft_body_default_config(body, soft_body);
|
_ephysics_body_soft_body_default_config(body, soft_body);
|
||||||
_ephysics_body_cloth_constraints_rebuild(body);
|
_ephysics_body_cloth_constraints_rebuild(body);
|
||||||
|
@ -1677,8 +1678,8 @@ ephysics_body_cloth_add(EPhysics_World *world, unsigned short granularity)
|
||||||
goto no_slices;
|
goto no_slices;
|
||||||
}
|
}
|
||||||
|
|
||||||
body->cloth_columns = columns;
|
body->cloth_columns = body_columns;
|
||||||
body->cloth_rows = rows;
|
body->cloth_rows = body_rows;
|
||||||
body->type = EPHYSICS_BODY_TYPE_CLOTH;
|
body->type = EPHYSICS_BODY_TYPE_CLOTH;
|
||||||
|
|
||||||
ephysics_world_soft_body_add(world, body);
|
ephysics_world_soft_body_add(world, body);
|
||||||
|
|
Loading…
Reference in New Issue