summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-11-23 21:43:19 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-11-23 21:43:19 +0000
commita7e90dc5a777a0b4a954f61f85ff603b8a2a4d1b (patch)
tree00dfbb70d654913b50c641079e7e640d3328fc40 /legacy/ephysics
parentaf8b2ce2cec802913618ce47706420ab3af90d54 (diff)
EPhysics: move just a single node of a triangle
Patch by: Leandro Dorileo <dorileo@profusion.mobi> SVN revision: 79590
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp59
-rw-r--r--legacy/ephysics/src/lib/ephysics_private.h2
2 files changed, 23 insertions, 38 deletions
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 5ad3fdb482..89ca93cfb6 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -819,11 +819,8 @@ _ephysics_body_soft_body_dragging_set(EPhysics_Body *body, int triangle)
819 body->dragging_data.dragging = EINA_TRUE; 819 body->dragging_data.dragging = EINA_TRUE;
820 820
821 face = body->soft_body->m_faces[triangle]; 821 face = body->soft_body->m_faces[triangle];
822 for (int i = 0; i < 3; i++) 822 node = face.m_n[0];
823 { 823 body->dragging_data.mass = node->m_im;
824 node = face.m_n[i];
825 body->dragging_data.mass[i] = node->m_im;
826 }
827} 824}
828 825
829static void 826static void
@@ -850,8 +847,7 @@ _ephysics_body_soft_body_mass_set(EPhysics_Body *body, double mass)
850 { 847 {
851 valid_nodes++; 848 valid_nodes++;
852 inverse_mass = 1 / (mass / valid_nodes); 849 inverse_mass = 1 / (mass / valid_nodes);
853 for (int i = 0; i < 3; i++) 850 body->dragging_data.mass = inverse_mass;
854 body->dragging_data.mass[i] = inverse_mass;
855 } 851 }
856 852
857 for (int i = 0; i < body->soft_body->m_nodes.size(); i++) 853 for (int i = 0; i < body->soft_body->m_nodes.size(); i++)
@@ -1651,13 +1647,10 @@ ephysics_body_soft_body_dragging_unset(EPhysics_Body *body)
1651 1647
1652 ephysics_world_lock_take(body->world); 1648 ephysics_world_lock_take(body->world);
1653 face = body->soft_body->m_faces[body->dragging_data.triangle]; 1649 face = body->soft_body->m_faces[body->dragging_data.triangle];
1654 for (int i = 0; i < 3; i++) 1650 node = face.m_n[0];
1655 { 1651 node->m_im = body->dragging_data.mass;
1656 node = face.m_n[i];
1657 node->m_im = body->dragging_data.mass[i];
1658 body->dragging_data.mass[i] = 0;
1659 }
1660 1652
1653 body->dragging_data.mass = 0;
1661 body->dragging_data.dragging = EINA_FALSE; 1654 body->dragging_data.dragging = EINA_FALSE;
1662 body->dragging_data.triangle = 0; 1655 body->dragging_data.triangle = 0;
1663 ephysics_world_lock_release(body->world); 1656 ephysics_world_lock_release(body->world);
@@ -1994,19 +1987,16 @@ ephysics_body_soft_body_dragging_apply(EPhysics_Body *body)
1994 btSoftBody::Node *node; 1987 btSoftBody::Node *node;
1995 1988
1996 face = body->soft_body->m_faces[body->dragging_data.triangle]; 1989 face = body->soft_body->m_faces[body->dragging_data.triangle];
1997 for (int i = 0; i < 3; i++) 1990 node = face.m_n[0];
1998 { 1991 node->m_v *= 0;
1999 node = face.m_n[i]; 1992 node->m_im *= 0;
2000 node->m_v *= 0;
2001 node->m_im *= 0;
2002 }
2003} 1993}
2004 1994
2005EAPI void 1995EAPI void
2006ephysics_body_soft_body_triangle_move(EPhysics_Body *body, int idx, Evas_Coord x, Evas_Coord y, Evas_Coord z) 1996ephysics_body_soft_body_triangle_move(EPhysics_Body *body, int idx, Evas_Coord x, Evas_Coord y, Evas_Coord z)
2007{ 1997{
2008 btScalar xx, yy, zz; 1998 btScalar xx, yy, zz;
2009 Evas_Coord wh; 1999 Evas_Coord wh, wy;
2010 double rate; 2000 double rate;
2011 btVector3 new_pos; 2001 btVector3 new_pos;
2012 btTransform diff; 2002 btTransform diff;
@@ -2027,34 +2017,29 @@ ephysics_body_soft_body_triangle_move(EPhysics_Body *body, int idx, Evas_Coord x
2027 } 2017 }
2028 2018
2029 rate = ephysics_world_rate_get(body->world); 2019 rate = ephysics_world_rate_get(body->world);
2030 ephysics_world_render_geometry_get(body->world, NULL, NULL, NULL, NULL, &wh, 2020 ephysics_world_render_geometry_get(body->world, NULL, &wy, NULL, NULL, &wh,
2031 NULL); 2021 NULL);
2032 2022
2033 xx = x / rate; 2023 xx = x / rate;
2034 yy = (wh - y) / rate; 2024 yy = ((wh + wy) - y) / rate;
2035 zz = z / rate; 2025 zz = z / rate;
2036 2026
2037 new_pos = btVector3(xx, yy, zz); 2027 new_pos = btVector3(xx, yy, zz);
2038 ephysics_world_lock_take(body->world); 2028 ephysics_world_lock_take(body->world);
2039 2029
2040 face = body->soft_body->m_faces[idx]; 2030 face = body->soft_body->m_faces[idx];
2041 for (int i = 0; i < 3; i++)
2042 {
2043 node = face.m_n[i];
2044 diff.setIdentity();
2045 diff.setOrigin(new_pos - node->m_x);
2046 _ephysics_body_soft_body_single_face_transform(body->soft_body, idx, i,
2047 diff);
2048 2031
2049 if (!i) continue; 2032 node = face.m_n[0];
2033 diff.setIdentity();
2034 diff.setOrigin(new_pos - node->m_x);
2035 _ephysics_body_soft_body_single_face_transform(body->soft_body, idx, 0, diff);
2050 2036
2051 diff.setOrigin(diff.getOrigin() * 0.1); 2037 diff.setOrigin(diff.getOrigin() * 0.1);
2052 for (int m = 0; m < body->soft_body->m_faces.size(); m++) 2038 for (int m = 0; m < body->soft_body->m_faces.size(); m++)
2053 { 2039 {
2054 if (m == idx) continue; 2040 if (m == idx) continue;
2055 _ephysics_body_soft_body_single_face_transform(body->soft_body, m, 2041 _ephysics_body_soft_body_single_face_transform(body->soft_body, m, 0,
2056 i, diff); 2042 diff);
2057 }
2058 } 2043 }
2059 2044
2060 body->soft_body->updateClusters(); 2045 body->soft_body->updateClusters();
diff --git a/legacy/ephysics/src/lib/ephysics_private.h b/legacy/ephysics/src/lib/ephysics_private.h
index f7757301bf..2e5c37345a 100644
--- a/legacy/ephysics/src/lib/ephysics_private.h
+++ b/legacy/ephysics/src/lib/ephysics_private.h
@@ -98,7 +98,7 @@ struct _EPhysics_Force {
98 98
99struct _EPhysics_Dragging_Data { 99struct _EPhysics_Dragging_Data {
100 int triangle; 100 int triangle;
101 double mass[3]; 101 double mass;
102 Eina_Bool dragging:1; 102 Eina_Bool dragging:1;
103}; 103};
104 104