From: Enlightenment S. <no-...@en...> - 2012-11-23 21:43:26
|
Log: EPhysics: move just a single node of a triangle Patch by: Leandro Dorileo <do...@pr...> Author: bdilly Date: 2012-11-23 13:43:19 -0800 (Fri, 23 Nov 2012) New Revision: 79590 Trac: http://trac.enlightenment.org/e/changeset/79590 Modified: trunk/ephysics/src/lib/ephysics_body.cpp trunk/ephysics/src/lib/ephysics_private.h Modified: trunk/ephysics/src/lib/ephysics_body.cpp =================================================================== --- trunk/ephysics/src/lib/ephysics_body.cpp 2012-11-23 21:28:02 UTC (rev 79589) +++ trunk/ephysics/src/lib/ephysics_body.cpp 2012-11-23 21:43:19 UTC (rev 79590) @@ -819,11 +819,8 @@ body->dragging_data.dragging = EINA_TRUE; face = body->soft_body->m_faces[triangle]; - for (int i = 0; i < 3; i++) - { - node = face.m_n[i]; - body->dragging_data.mass[i] = node->m_im; - } + node = face.m_n[0]; + body->dragging_data.mass = node->m_im; } static void @@ -850,8 +847,7 @@ { valid_nodes++; inverse_mass = 1 / (mass / valid_nodes); - for (int i = 0; i < 3; i++) - body->dragging_data.mass[i] = inverse_mass; + body->dragging_data.mass = inverse_mass; } for (int i = 0; i < body->soft_body->m_nodes.size(); i++) @@ -1651,13 +1647,10 @@ ephysics_world_lock_take(body->world); face = body->soft_body->m_faces[body->dragging_data.triangle]; - for (int i = 0; i < 3; i++) - { - node = face.m_n[i]; - node->m_im = body->dragging_data.mass[i]; - body->dragging_data.mass[i] = 0; - } + node = face.m_n[0]; + node->m_im = body->dragging_data.mass; + body->dragging_data.mass = 0; body->dragging_data.dragging = EINA_FALSE; body->dragging_data.triangle = 0; ephysics_world_lock_release(body->world); @@ -1994,19 +1987,16 @@ btSoftBody::Node *node; face = body->soft_body->m_faces[body->dragging_data.triangle]; - for (int i = 0; i < 3; i++) - { - node = face.m_n[i]; - node->m_v *= 0; - node->m_im *= 0; - } + node = face.m_n[0]; + node->m_v *= 0; + node->m_im *= 0; } EAPI void ephysics_body_soft_body_triangle_move(EPhysics_Body *body, int idx, Evas_Coord x, Evas_Coord y, Evas_Coord z) { btScalar xx, yy, zz; - Evas_Coord wh; + Evas_Coord wh, wy; double rate; btVector3 new_pos; btTransform diff; @@ -2027,34 +2017,29 @@ } rate = ephysics_world_rate_get(body->world); - ephysics_world_render_geometry_get(body->world, NULL, NULL, NULL, NULL, &wh, + ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, NULL, &wh, NULL); xx = x / rate; - yy = (wh - y) / rate; + yy = ((wh + wy) - y) / rate; zz = z / rate; new_pos = btVector3(xx, yy, zz); ephysics_world_lock_take(body->world); face = body->soft_body->m_faces[idx]; - for (int i = 0; i < 3; i++) - { - node = face.m_n[i]; - diff.setIdentity(); - diff.setOrigin(new_pos - node->m_x); - _ephysics_body_soft_body_single_face_transform(body->soft_body, idx, i, - diff); - if (!i) continue; + node = face.m_n[0]; + diff.setIdentity(); + diff.setOrigin(new_pos - node->m_x); + _ephysics_body_soft_body_single_face_transform(body->soft_body, idx, 0, diff); - diff.setOrigin(diff.getOrigin() * 0.1); - for (int m = 0; m < body->soft_body->m_faces.size(); m++) - { - if (m == idx) continue; - _ephysics_body_soft_body_single_face_transform(body->soft_body, m, - i, diff); - } + diff.setOrigin(diff.getOrigin() * 0.1); + for (int m = 0; m < body->soft_body->m_faces.size(); m++) + { + if (m == idx) continue; + _ephysics_body_soft_body_single_face_transform(body->soft_body, m, 0, + diff); } body->soft_body->updateClusters(); Modified: trunk/ephysics/src/lib/ephysics_private.h =================================================================== --- trunk/ephysics/src/lib/ephysics_private.h 2012-11-23 21:28:02 UTC (rev 79589) +++ trunk/ephysics/src/lib/ephysics_private.h 2012-11-23 21:43:19 UTC (rev 79590) @@ -98,7 +98,7 @@ struct _EPhysics_Dragging_Data { int triangle; - double mass[3]; + double mass; Eina_Bool dragging:1; }; |