diff --git a/legacy/ephysics/src/bin/test_flag.c b/legacy/ephysics/src/bin/test_flag.c index d5893bc9af..1f8a75ce73 100644 --- a/legacy/ephysics/src/bin/test_flag.c +++ b/legacy/ephysics/src/bin/test_flag.c @@ -97,7 +97,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); - 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_soft_body_hardness_set(flag_body, 1); evas_obj = ephysics_body_evas_object_set(flag_body, evas_obj, EINA_TRUE); diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h index 5a7b2db9fe..bfb354c063 100644 --- a/legacy/ephysics/src/lib/EPhysics.h +++ b/legacy/ephysics/src/lib/EPhysics.h @@ -2070,25 +2070,21 @@ EAPI EPhysics_Body *ephysics_body_soft_box_add(EPhysics_World *world); * Create a new deformable cloth physics body. * * A cloth has its points of deformation conceptually split into rows and - * columns - * where every square is also split into two triangles - afore named nodes. To - * fine tune the deformation one can increase this granularity by increasing the - * @p granularity parameter. + * columns where every square is also split into two triangles - afore named + * nodes. To fine tune the deformation one can increase this granularity by + * increasing the number of @p rows and @p columns. * - * The number of rows is always proportional to the number of columns, for - * example passing @p granularity of 20 will create a cloth with 20 rows and 20 - * columns. + * By default - if passed 0 as @p rows and @p columns - EPhysics creates a cloth + * with 15 rows and 15 columns, these default values will generally fit the most + * common scenarios. * - * By default EPhysics creates a cloth with 15 rows and 15 columns, these - * default values will generally fit the most common scenarios. - * - * If the informed @p granularity is of 0 then the default value - of 15 - is - * assumed. + * If the informed @p rows is of 0 then the default value - of 15 - is + * assumed. The same is true for @p columns. * * @param world The world this body will belong to. - * @param granularity Define - proportionally - the number of rows and columns, - * if 0 the default value - of 15 - is assumed. - * @return a bew body or @c NULL on erros. + * @param rows The number os rows. + * @param columns The number of columns. + * @return a new body or @c NULL on erros. * * @see ephysics_body_del(). * @see ephysics_body_evas_object_set(). @@ -2098,7 +2094,7 @@ EAPI EPhysics_Body *ephysics_body_soft_box_add(EPhysics_World *world); * * @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 diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp index c1ec7983c6..e616912ccf 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -1613,13 +1613,13 @@ ephysics_body_soft_body_position_iterations_get(EPhysics_Body *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; btSoftBodyWorldInfo *world_info; btSoftBody *soft_body; - const int rows = (!granularity) ? 15 : granularity; - const int columns = (!granularity) ? 15 : granularity; + const int body_rows = (!rows) ? 15 : rows; + const int body_columns = (!columns) ? 15 : columns; if (!world) { @@ -1633,7 +1633,8 @@ ephysics_body_cloth_add(EPhysics_World *world, unsigned short granularity) btVector3(2, 1, 0), btVector3(1, 2, 0), btVector3(1, 1, 0), - rows, columns, 0, false); + body_rows, body_columns, 0, false); + if (!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(); 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_cloth_constraints_rebuild(body); @@ -1677,8 +1678,8 @@ ephysics_body_cloth_add(EPhysics_World *world, unsigned short granularity) goto no_slices; } - body->cloth_columns = columns; - body->cloth_rows = rows; + body->cloth_columns = body_columns; + body->cloth_rows = body_rows; body->type = EPHYSICS_BODY_TYPE_CLOTH; ephysics_world_soft_body_add(world, body);