summaryrefslogtreecommitdiff
path: root/legacy/ephysics
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-12-10 17:15:27 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2012-12-10 17:15:27 +0000
commit8f8cf756ee402c6d991e7e9520066df70f1619fd (patch)
tree464855227f02acd1449a33fccf607a673846b714 /legacy/ephysics
parent0941fad05f8bded47634e2c3917018e15f95bbf4 (diff)
EPHysics: introduce a generic resize_cb for soft body faces
Introduce a generic resize_cb for soft body faces and fix the "not pre-resized evas object issue" for multi faces implementation as well. --This line, and those below, will be ignored-- SVN revision: 80615
Diffstat (limited to 'legacy/ephysics')
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp46
1 files changed, 40 insertions, 6 deletions
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index 7c3b3d2782..4ff432e6bf 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -4793,8 +4793,38 @@ _ephysics_body_cylinder_face_evas_object_unset(EPhysics_Body *body, EPhysics_Bod
4793} 4793}
4794 4794
4795static void 4795static void
4796_ephysics_body_soft_body_face_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
4797{
4798 int w, h;
4799 EPhysics_Body_Face_Obj *face;
4800 EPhysics_Body_Face_Slice *face_slice = (EPhysics_Body_Face_Slice *)data;
4801 EPhysics_Body *body = face_slice->body;
4802
4803 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
4804 if ((w == body->size.w) && (h == body->size.h))
4805 return;
4806
4807 DBG("Resizing body %p to w=%i, h=%i, d=%i", body, w, h, body->size.d);
4808
4809 face = _ephysics_body_face_evas_object_get(body, face_slice->face);
4810
4811 ephysics_world_lock_take(body->world);
4812 _ephysics_body_resize(body, w, h, body->size.d);
4813
4814 if (body->type == EPHYSICS_BODY_TYPE_CLOTH)
4815 {
4816 _ephysics_body_soft_body_slices_clean(face_slice->slices);
4817 _ephysics_body_soft_body_slices_init(body, face->obj,
4818 face_slice->slices);
4819 }
4820
4821 ephysics_world_lock_release(body->world);
4822}
4823
4824static void
4796_ephysics_body_cloth_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos) 4825_ephysics_body_cloth_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos)
4797{ 4826{
4827 EPhysics_Body_Face_Slice *face_slice;
4798 int obj_x, obj_y, obj_w, obj_h, bz, bd; 4828 int obj_x, obj_y, obj_w, obj_h, bz, bd;
4799 double rate; 4829 double rate;
4800 4830
@@ -4806,13 +4836,15 @@ _ephysics_body_cloth_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Fac
4806 } 4836 }
4807 4837
4808 _ephysics_body_face_evas_object_add(body, face, evas_obj, 4838 _ephysics_body_face_evas_object_add(body, face, evas_obj,
4809 _ephysics_body_evas_obj_resize_cb); 4839 _ephysics_body_soft_body_face_resize_cb);
4810 evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_DEL, 4840 evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_DEL,
4811 _ephysics_body_face_obj_del_cb, body); 4841 _ephysics_body_face_obj_del_cb, body);
4812 4842
4813 if (!use_obj_pos) 4843 if (!use_obj_pos)
4814 return; 4844 return;
4815 4845
4846 face_slice = _ephysics_body_face_slice_get(body, face);
4847
4816 rate = ephysics_world_rate_get(body->world); 4848 rate = ephysics_world_rate_get(body->world);
4817 evas_object_geometry_get(evas_obj, &obj_x, &obj_y, &obj_w, &obj_h); 4849 evas_object_geometry_get(evas_obj, &obj_x, &obj_y, &obj_w, &obj_h);
4818 4850
@@ -4821,8 +4853,8 @@ _ephysics_body_cloth_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Fac
4821 _ephysics_body_geometry_set(body, obj_x, obj_y, bz, obj_w, obj_h, bd, rate); 4853 _ephysics_body_geometry_set(body, obj_x, obj_y, bz, obj_w, obj_h, bd, rate);
4822 ephysics_world_lock_release(body->world); 4854 ephysics_world_lock_release(body->world);
4823 evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_RESIZE, 4855 evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_RESIZE,
4824 _ephysics_body_evas_obj_resize_cb, 4856 _ephysics_body_soft_body_face_resize_cb,
4825 body); 4857 face_slice);
4826} 4858}
4827 4859
4828static Evas_Object * 4860static Evas_Object *
@@ -4871,7 +4903,7 @@ _ephysics_body_cloth_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_F
4871 { 4903 {
4872 Evas_Object *obj = face_obj->obj; 4904 Evas_Object *obj = face_obj->obj;
4873 _ephysics_body_face_obj_unset( 4905 _ephysics_body_face_obj_unset(
4874 obj, _ephysics_body_evas_obj_resize_cb); 4906 obj, _ephysics_body_soft_body_face_resize_cb);
4875 body->face_objs = eina_list_remove(body->face_objs, face_obj); 4907 body->face_objs = eina_list_remove(body->face_objs, face_obj);
4876 free(face_obj); 4908 free(face_obj);
4877 return obj; 4909 return obj;
@@ -4925,8 +4957,7 @@ _ephysics_body_ellipsoid_face_evas_object_clean(EPhysics_Body *body, EPhysics_Bo
4925 evas_object_map_enable_set(face_obj->obj, EINA_FALSE); 4957 evas_object_map_enable_set(face_obj->obj, EINA_FALSE);
4926 evas_object_event_callback_del(face_obj->obj, EVAS_CALLBACK_DEL, 4958 evas_object_event_callback_del(face_obj->obj, EVAS_CALLBACK_DEL,
4927 _ephysics_body_ellipsoid_face_evas_object_del_cb); 4959 _ephysics_body_ellipsoid_face_evas_object_del_cb);
4928 evas_object_event_callback_del(face_obj->obj, EVAS_CALLBACK_RESIZE, 4960
4929 _ephysics_body_evas_obj_resize_cb);
4930 evas_object_event_callback_del(face_obj->obj, EVAS_CALLBACK_RESTACK, 4961 evas_object_event_callback_del(face_obj->obj, EVAS_CALLBACK_RESTACK,
4931 _ephysics_body_soft_body_evas_restack_cb); 4962 _ephysics_body_soft_body_evas_restack_cb);
4932 _ephysics_body_soft_body_slices_clean(slices); 4963 _ephysics_body_soft_body_slices_clean(slices);
@@ -4975,6 +5006,9 @@ _ephysics_body_ellipsoid_face_evas_object_set(EPhysics_Body *body, EPhysics_Body
4975 _ephysics_body_ellipsoid_face_evas_object_clean(body, face_obj, 5006 _ephysics_body_ellipsoid_face_evas_object_clean(body, face_obj,
4976 face_slice->slices); 5007 face_slice->slices);
4977 5008
5009 evas_object_geometry_get(evas_obj, NULL, NULL, &obj_w, &obj_h);
5010 if (!obj_w && !obj_h) evas_object_resize(evas_obj, 1, 1);
5011
4978 _ephysics_body_face_evas_object_add(body, face, evas_obj, 5012 _ephysics_body_face_evas_object_add(body, face, evas_obj,
4979 _ephysics_body_ellipsoid_face_obj_resize_cb); 5013 _ephysics_body_ellipsoid_face_obj_resize_cb);
4980 5014