\hypertarget{test_delete_8c-example}{\section{test\+\_\+delete.\+c}
}

\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#ifdef HAVE\_CONFIG\_H}
\textcolor{preprocessor}{# include <config.h>}
\textcolor{preprocessor}{#endif}

\textcolor{preprocessor}{#include "ephysics\_test.h"}

\textcolor{keyword}{typedef} \textcolor{keyword}{struct }\_Collision\_Data Collision\_Data;

\textcolor{keyword}{struct }\_Collision\_Data \{
     Test\_Data base;
     \hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body} *sphere;
     \hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body} *sphere2;
\};

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_del\_cb(\textcolor{keywordtype}{void} *data, \hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body} *body, \textcolor{keywordtype}{void} *event\_info \_\_UNUSED\_\_)
\{
   Collision\_Data *collision\_data = data;
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj, *shadow;

   obj = \hyperlink{group__EPhysics__Body_ga47ea07534cc809cd5d132495ebf2793a}{ephysics\_body\_evas\_object\_get}(body);
   shadow = \hyperlink{group__Evas__Object__Group__Extras_gafbad43015793eda4ae50202c0ce0e652}{evas\_object\_data\_get}(obj, \textcolor{stringliteral}{"shadow"});

   collision\_data->base.evas\_objs = \hyperlink{group__Eina__List__Group_ga7c0c6e07aa592a1cb2e010049a718035}{eina\_list\_remove}(
      collision\_data->base.evas\_objs, shadow);
   collision\_data->base.evas\_objs = \hyperlink{group__Eina__List__Group_ga7c0c6e07aa592a1cb2e010049a718035}{eina\_list\_remove}(
      collision\_data->base.evas\_objs, obj);

   \hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}(shadow);
   \hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}(obj);

   collision\_data->sphere = NULL;
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_collision\_cb(\textcolor{keywordtype}{void} *data, \hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body} *body, \textcolor{keywordtype}{void} *event\_info)
\{
   \hyperlink{group__EPhysics__Body_ga454052288e957641ff40f79ca3c72792}{EPhysics\_Body\_Collision} *collision = event\_info;
   Collision\_Data *collision\_data = data;
   \hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body} *contact\_body;

   contact\_body = \hyperlink{group__EPhysics__Body_gae94b1bd402657e11208cc90c5c3bbba4}{ephysics\_body\_collision\_contact\_body\_get}(
      collision);
   \textcolor{keywordflow}{if} (contact\_body != collision\_data->sphere2) \textcolor{keywordflow}{return};

   collision\_data->base.bodies = \hyperlink{group__Eina__List__Group_ga7c0c6e07aa592a1cb2e010049a718035}{eina\_list\_remove}(collision\_data->base.bodies,
                                                  body);

   \hyperlink{group__Eina__File__Group_gaa0bb6435252613b1a74175af3d60045f}{INF}(\textcolor{stringliteral}{"Collision Detected"});
   \hyperlink{group__EPhysics__Body_ga9f47ada6fe8ee0abb234bc4aaab7dd1c}{ephysics\_body\_del}(body);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_world\_populate(Collision\_Data *collision\_data)
\{
   \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *sphere1, *sphere2, *sh1, *sh2;
   \hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body} *sphere\_body1, *sphere\_body2;

   sh1 = elm\_layout\_add(collision\_data->base.win);
   elm\_layout\_file\_set(
      sh1, PACKAGE\_DATA\_DIR \textcolor{stringliteral}{"/"} EPHYSICS\_TEST\_THEME \textcolor{stringliteral}{".edj"}, \textcolor{stringliteral}{"shadow-ball"});
   evas\_object\_move(sh1, WIDTH / 2, FLOOR\_Y);
   evas\_object\_resize(sh1, 70, 3);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(sh1);
   collision\_data->base.evas\_objs = \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(
      collision\_data->base.evas\_objs, sh1);

   sphere1 = elm\_image\_add(collision\_data->base.win);
   elm\_image\_file\_set(
      sphere1, PACKAGE\_DATA\_DIR \textcolor{stringliteral}{"/"} EPHYSICS\_TEST\_THEME \textcolor{stringliteral}{".edj"},
      \textcolor{stringliteral}{"big-red-ball"});
   evas\_object\_move(sphere1, WIDTH / 2, FLOOR\_Y - 70 + 1);
   evas\_object\_resize(sphere1, 70, 70);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(sphere1);
   \hyperlink{group__Evas__Object__Group__Extras_ga70134a7068c9bff4107a761abe0a2ad4}{evas\_object\_data\_set}(sphere1, \textcolor{stringliteral}{"shadow"}, sh1);
   collision\_data->base.evas\_objs = \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(
      collision\_data->base.evas\_objs, sphere1);

   sphere\_body1 = \hyperlink{group__EPhysics__Body_gab26c09b5a98dabfb0323dbdb7f2a64af}{ephysics\_body\_sphere\_add}(collision\_data->base.world);
   \hyperlink{group__EPhysics__Body_ga39cb9e95bbe1d097926a09365c501db3}{ephysics\_body\_evas\_object\_set}(sphere\_body1, sphere1, 
      \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
   \hyperlink{group__EPhysics__Body_gada176f4748a4c2fc4ba2042021ea7067}{ephysics\_body\_event\_callback\_add}(sphere\_body1,
                                    \hyperlink{group__EPhysics__Body_gga904d0d1462e71c1f32cb27f540b5277cacb2363cd59bc8642e74ad916c6658e0a}{EPHYSICS\_CALLBACK\_BODY\_UPDATE},
                                    update\_object\_cb, sh1);
   \hyperlink{group__EPhysics__Body_gada176f4748a4c2fc4ba2042021ea7067}{ephysics\_body\_event\_callback\_add}(sphere\_body1,
                                    \hyperlink{group__EPhysics__Body_gga904d0d1462e71c1f32cb27f540b5277cab8f46f167ee3872ea35fe645bf14a5d2}{EPHYSICS\_CALLBACK\_BODY\_DEL},
                                    \_del\_cb, collision\_data);
   \hyperlink{group__EPhysics__Body_ga731c9a6443f7c4294fce23fc1287b778}{ephysics\_body\_restitution\_set}(sphere\_body1, 0.8);
   \hyperlink{group__EPhysics__Body_ga986d45060bf6ba1689a56889a2bcabce}{ephysics\_body\_friction\_set}(sphere\_body1, 0.4);
   collision\_data->base.bodies = \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(
      collision\_data->base.bodies, sphere\_body1);
   collision\_data->sphere = sphere\_body1;

   sh2 = elm\_layout\_add(collision\_data->base.win);
   elm\_layout\_file\_set(
      sh2, PACKAGE\_DATA\_DIR \textcolor{stringliteral}{"/"} EPHYSICS\_TEST\_THEME \textcolor{stringliteral}{".edj"}, \textcolor{stringliteral}{"shadow-ball"});
   evas\_object\_move(sh2, WIDTH / 8, FLOOR\_Y);
   evas\_object\_resize(sh2, 70, 3);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(sh2);
   collision\_data->base.evas\_objs = \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(
      collision\_data->base.evas\_objs, sh2);

   sphere2 = elm\_image\_add(collision\_data->base.win);
   elm\_image\_file\_set(
      sphere2, PACKAGE\_DATA\_DIR \textcolor{stringliteral}{"/"} EPHYSICS\_TEST\_THEME \textcolor{stringliteral}{".edj"},
      \textcolor{stringliteral}{"big-green-ball"});
   evas\_object\_move(sphere2, WIDTH / 8, FLOOR\_Y - 70 + 1);
   evas\_object\_resize(sphere2, 70, 70);
   \hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}(sphere2);
   collision\_data->base.evas\_objs = \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(
      collision\_data->base.evas\_objs, sphere2);

   sphere\_body2 = \hyperlink{group__EPhysics__Body_gab26c09b5a98dabfb0323dbdb7f2a64af}{ephysics\_body\_sphere\_add}(collision\_data->base.world);
   \hyperlink{group__EPhysics__Body_ga39cb9e95bbe1d097926a09365c501db3}{ephysics\_body\_evas\_object\_set}(sphere\_body2, sphere2, 
      \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE});
   \hyperlink{group__EPhysics__Body_gada176f4748a4c2fc4ba2042021ea7067}{ephysics\_body\_event\_callback\_add}(sphere\_body2,
                                    \hyperlink{group__EPhysics__Body_gga904d0d1462e71c1f32cb27f540b5277cacb2363cd59bc8642e74ad916c6658e0a}{EPHYSICS\_CALLBACK\_BODY\_UPDATE},
                                    update\_object\_cb, sh2);
   \hyperlink{group__EPhysics__Body_ga731c9a6443f7c4294fce23fc1287b778}{ephysics\_body\_restitution\_set}(sphere\_body2, 1);
   \hyperlink{group__EPhysics__Body_ga986d45060bf6ba1689a56889a2bcabce}{ephysics\_body\_friction\_set}(sphere\_body2, 0.4);
   \hyperlink{group__EPhysics__Body_ga9109b39047a724640f6a18c683c9eb07}{ephysics\_body\_central\_impulse\_apply}(sphere\_body2, 360, 0, 0);
   collision\_data->sphere2 = sphere\_body2;
   collision\_data->base.bodies = \hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}(
      collision\_data->base.bodies, sphere\_body2);

   \hyperlink{group__EPhysics__Body_gada176f4748a4c2fc4ba2042021ea7067}{ephysics\_body\_event\_callback\_add}(collision\_data->sphere,
                                    \hyperlink{group__EPhysics__Body_gga904d0d1462e71c1f32cb27f540b5277caa002e2d26e86261221dc643f19071754}{EPHYSICS\_CALLBACK\_BODY\_COLLISION},
                                    \_collision\_cb, collision\_data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_restart(\textcolor{keywordtype}{void} *data, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj \_\_UNUSED\_\_, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *emission \_\_UNUSED\_\_, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *
      source \_\_UNUSED\_\_)
\{
   Collision\_Data *collision\_data = data;

   \hyperlink{group__Eina__File__Group_gae8924623ca601364965e3d88fb7f40fa}{DBG}(\textcolor{stringliteral}{"Restart pressed"});
   test\_clean((Test\_Data *)collision\_data);
   \_world\_populate(collision\_data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_win\_del(\textcolor{keywordtype}{void} *data, \hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas} *e \_\_UNUSED\_\_, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj \_\_UNUSED\_\_, \textcolor{keywordtype}{void} *event\_info 
      \_\_UNUSED\_\_)
\{
   Collision\_Data *collision\_data = data;

   test\_clean((Test\_Data *)collision\_data);
   \hyperlink{group__Evas__Object__Group__Basic_ga7e7a625dab7a3890532aa13b43117076}{evas\_object\_del}(collision\_data->base.layout);
   \hyperlink{group__EPhysics__World_ga99ebd1425f258f895c0089d6eb13def9}{ephysics\_world\_del}(collision\_data->base.world);
   free(collision\_data);
   \hyperlink{group__EPhysics_ga07e695074fb4d5d125b36c3a1d963f49}{ephysics\_shutdown}();
\}

\textcolor{keywordtype}{void}
test\_delete(\textcolor{keywordtype}{void} *data \_\_UNUSED\_\_, \hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object} *obj \_\_UNUSED\_\_, \textcolor{keywordtype}{void} *event\_info \_\_UNUSED\_\_)
\{
   Collision\_Data *collision\_data;
   \hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body} *boundary;
   \hyperlink{group__EPhysics__World_ga83c0d22744748525aa2dac11726c58e6}{EPhysics\_World} *world;

   \textcolor{keywordflow}{if} (!\hyperlink{group__EPhysics_gaca8fc170d73b3f688349cc4dbaf219fd}{ephysics\_init}())
     \textcolor{keywordflow}{return};

   collision\_data = calloc(1, \textcolor{keyword}{sizeof}(Collision\_Data));
   \textcolor{keywordflow}{if} (!collision\_data)
     \{
        \hyperlink{group__Eina__File__Group_ga24e93be9c5baa3aeab7021b64e290672}{ERR}(\textcolor{stringliteral}{"Failed to create test data"});
        \hyperlink{group__EPhysics_ga07e695074fb4d5d125b36c3a1d963f49}{ephysics\_shutdown}();
        \textcolor{keywordflow}{return};
     \}

   test\_win\_add((Test\_Data *)collision\_data, \textcolor{stringliteral}{"Delete Body"}, \hyperlink{group__Eina__Types__Group_ga1feb115f8e9913e806e090d9bd5a7301}{EINA\_FALSE});
   \hyperlink{group__Evas__Object__Group__Events_ga23be30ac5cdfb780f1ff82e9108ec26b}{evas\_object\_event\_callback\_add}(collision\_data->base.win, 
      \hyperlink{Evas__Common_8h_a99e208e463a20499aabe6faac8a8cb8aa4471afbcbb4a754b7b0bbde00fb9a277}{EVAS\_CALLBACK\_DEL},
                                  \_win\_del, collision\_data);
   elm\_object\_signal\_emit(collision\_data->base.layout, \textcolor{stringliteral}{"borders,show"},
                          \textcolor{stringliteral}{"ephysics\_test"});
   elm\_layout\_signal\_callback\_add(collision\_data->base.layout, \textcolor{stringliteral}{"restart"},
                                  \textcolor{stringliteral}{"test-theme"}, \_restart, collision\_data);

   world = \hyperlink{group__EPhysics__World_ga108e2d7df8c81321b8d5bde8497f0d45}{ephysics\_world\_new}();
   \hyperlink{group__EPhysics__World_gaabf8abaf9c41b0c1e5daa4acf3df0356}{ephysics\_world\_render\_geometry\_set}(world, 50, 40, -50,
                                      WIDTH - 100, FLOOR\_Y - 40, DEPTH);
   collision\_data->base.world = world;

   boundary = \hyperlink{group__EPhysics__Body_gac5fc5a1817ac81e2f1fcdcd8908614f2}{ephysics\_body\_bottom\_boundary\_add}(collision\_data->base.world
      );
   \hyperlink{group__EPhysics__Body_ga731c9a6443f7c4294fce23fc1287b778}{ephysics\_body\_restitution\_set}(boundary, 0);
   \hyperlink{group__EPhysics__Body_ga986d45060bf6ba1689a56889a2bcabce}{ephysics\_body\_friction\_set}(boundary, 20);

   \hyperlink{group__EPhysics__Body_ga4ad52252b2537c6f41e14b9135847fe9}{ephysics\_body\_left\_boundary\_add}(collision\_data->base.world);
   \hyperlink{group__EPhysics__Body_gab7e598db12a5270311c429f0ee12271c}{ephysics\_body\_right\_boundary\_add}(collision\_data->base.world);

   \_world\_populate(collision\_data);

   \hyperlink{group__EPhysics__Body_gada176f4748a4c2fc4ba2042021ea7067}{ephysics\_body\_event\_callback\_add}(collision\_data->sphere,
                                    \hyperlink{group__EPhysics__Body_gga904d0d1462e71c1f32cb27f540b5277caa002e2d26e86261221dc643f19071754}{EPHYSICS\_CALLBACK\_BODY\_COLLISION},
                                    \_collision\_cb, collision\_data);
\}
\end{DoxyCodeInclude}
 