};
static void
+_ephysics_body_cloth_anchor_mass_reset(EPhysics_Body *body)
+{
+ double anchor_mass;
+ anchor_mass = 1 / (body->soft_body->m_nodes.size() * 0.025);
+
+ for (int i = 0; i < body->soft_body->m_anchors.size(); i++)
+ body->soft_body->m_anchors[i].m_node->m_im = anchor_mass;
+
+ DBG("Cloth anchors mass reset.");
+}
+
+static void
_ephysics_body_soft_body_slices_apply(EPhysics_Body *body, Evas_Object *evas_obj, Eina_List *slices)
{
double rate;
}
else if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
{
+ body->soft_body->setTotalMass(body->mass, true);
body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
body->soft_body->scale(body_scale);
_ephysics_body_transform_set(body, trans);
_ephysics_body_cloth_constraints_rebuild(body);
+ body->soft_body->setTotalMass(body->mass, false);
+ _ephysics_body_cloth_anchor_mass_reset(body);
}
else
{
static void
_ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d)
{
+ Evas_Coord bx, by, bz;
double rate, sx, sy, sz;
btVector3 body_scale, center;
btTransform trans;
sy = h / rate;
sz = d / rate;
+ DBG("Body %p scale changed to (%lf, %lf, %lf).", body, sx, sy, sz);
+
body_scale = btVector3(sx, sy, sz);
if (body->type == EPHYSICS_BODY_TYPE_SOFT)
{
}
else if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
{
- body->soft_body->scale(btVector3(1, 1, 1) / body->scale);
- body->soft_body->scale(body_scale);
- _ephysics_body_cloth_constraints_rebuild(body);
+ ephysics_body_geometry_get(body, &bx, &by, &bz, NULL, NULL, NULL);
+ _ephysics_body_geometry_set(body, bx, by, bz, w, h, d, rate);
+ return;
}
else
{
body->scale = body_scale;
ephysics_body_activate(body, EINA_TRUE);
-
- DBG("Body %p scale changed to (%lf, %lf, %lf).", body, sx, sy, sz);
}
static void
ephysics_world_lock_take(body->world);
_ephysics_body_resize(body, w, h, body->size.d);
+
+ if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
+ {
+ _ephysics_body_soft_body_slices_clean(body->default_face->slices);
+ _ephysics_body_soft_body_slices_init(body, body->evas_obj,
+ body->default_face->slices);
+ }
+
ephysics_world_lock_release(body->world);
}
{
int rows;
int columns;
- double anchor_mass;
if (!body1 || !body2)
{
rows = body1->cloth_rows + 1;
columns = body1->cloth_columns + 1;
- anchor_mass = body1->soft_body->m_nodes.size() * 0.025;
if (side == EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_RIGHT)
{
for (int i = 0; i < rows; i++)
- {
- body1->soft_body->setMass(i, anchor_mass);
- body1->soft_body->appendAnchor(i, body2->rigid_body);
- }
- return;
+ body1->soft_body->appendAnchor(i, body2->rigid_body);
+ goto mass_reset;
}
if (side == EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_LEFT)
{
for (int i = 1; i <= rows; i++)
- {
- body1->soft_body->setMass((rows * columns) - i, anchor_mass);
- body1->soft_body->appendAnchor((rows * columns) - i,
- body2->rigid_body);
- }
- return;
+ body1->soft_body->appendAnchor((rows * columns) - i,
+ body2->rigid_body);
+ goto mass_reset;
}
if (side == EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_BOTTOM)
{
for (int i = 0; i <= rows; i++)
- {
- body1->soft_body->setMass((i * rows), anchor_mass);
- body1->soft_body->appendAnchor(i * rows, body2->rigid_body);
- }
- return;
+ body1->soft_body->appendAnchor(i * rows, body2->rigid_body);
+ goto mass_reset;
}
if (side == EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_TOP)
{
for (int i = 0; i < columns; i++)
- {
- body1->soft_body->setMass((rows - 1) + rows * i, anchor_mass);
- body1->soft_body->appendAnchor((rows - 1) + rows * i,
- body2->rigid_body);
- }
+ body1->soft_body->appendAnchor((rows - 1) + rows * i,
+ body2->rigid_body);
}
+
+ mass_reset:
+ _ephysics_body_cloth_anchor_mass_reset(body1);
}
EAPI void
}
body1->soft_body->appendAnchor(node, body2->rigid_body);
+ _ephysics_body_cloth_anchor_mass_reset(body1);
}
EAPI void
}
body->soft_body->m_anchors.resize(0);
+ body->soft_body->setTotalMass(body->mass);
}
static Eina_List *