\hypertarget{test_forces_8c-example}{}\section{test\+\_\+forces.\+c}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifdef HAVE\_CONFIG\_H}}
\DoxyCodeLine{\textcolor{preprocessor}{\# include <config.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include "ephysics\_test.h"}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_update\_object\_cb(\textcolor{keywordtype}{void} *data \_\_UNUSED\_\_, \mbox{\hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body}} *body, \textcolor{keywordtype}{void} *event\_info \_\_UNUSED\_\_)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keywordtype}{double} x, y, z, torque, vx, vy, vz, va;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga7209e650176e0612efb2a2cc2af0ec27}{ephysics\_body\_evas\_object\_update}}(body);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_gaa4ff8dc0e1edefd2ad6a52361ff23edd}{ephysics\_body\_forces\_get}}(body, \&x, \&y, \&z);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga7d494e105a7f3a16e658b36ff00e8f17}{ephysics\_body\_torques\_get}}(body, NULL, NULL, \&torque);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__File__Group_gae8924623ca601364965e3d88fb7f40fa}{DBG}}(\textcolor{stringliteral}{"Body \%p, fx: \%lf, fy: \%lf, fz: \%lf, torque: \%lf"}, body, x, y, z,}
\DoxyCodeLine{       torque);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga45dadf9123da25dd007b6c458f86d589}{ephysics\_body\_linear\_velocity\_get}}(body, \&vx, \&vy, \&vz);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga4aa2211390aefa191a13639a672f21e8}{ephysics\_body\_angular\_velocity\_get}}(body, NULL, NULL, \&va);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__File__Group_gae8924623ca601364965e3d88fb7f40fa}{DBG}}(\textcolor{stringliteral}{"Body \%p, vx: \%lf, vy: \%lf, vz: \%lf, va: \%lf"}, body, vx, vy, vz, va);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_world\_populate(Test\_Data *test\_data)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body}} *box\_body1, *box\_body2;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *box1, *box2;}
\DoxyCodeLine{}
\DoxyCodeLine{   box1 = \mbox{\hyperlink{group__Elm__Image_ga5d211c8af4f6e297a24fc4e8737c81a9}{elm\_image\_add}}(test\_data->win);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Image_gad1a96ede5f513042cef3c1dac4572f73}{elm\_image\_file\_set}}(}
\DoxyCodeLine{      box1, PACKAGE\_DATA\_DIR \textcolor{stringliteral}{"/"} EPHYSICS\_TEST\_THEME \textcolor{stringliteral}{".edj"}, \textcolor{stringliteral}{"blue-cube"});}
\DoxyCodeLine{   evas\_object\_move(box1, 80, FLOOR\_Y - 200);}
\DoxyCodeLine{   evas\_object\_resize(box1, 70, 70);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(box1);}
\DoxyCodeLine{   test\_data->evas\_objs = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(test\_data->evas\_objs, box1);}
\DoxyCodeLine{}
\DoxyCodeLine{   box\_body1 = \mbox{\hyperlink{group__EPhysics__Body_gaf8f30587da7453114397d64dd9704d7f}{ephysics\_body\_box\_add}}(test\_data->world);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga39cb9e95bbe1d097926a09365c501db3}{ephysics\_body\_evas\_object\_set}}(box\_body1, box1, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_gada176f4748a4c2fc4ba2042021ea7067}{ephysics\_body\_event\_callback\_add}}(box\_body1, \mbox{\hyperlink{group__EPhysics__Body_gga904d0d1462e71c1f32cb27f540b5277cacb2363cd59bc8642e74ad916c6658e0a}{EPHYSICS\_CALLBACK\_BODY\_UPDATE}},}
\DoxyCodeLine{                                    \_update\_object\_cb, NULL);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga731c9a6443f7c4294fce23fc1287b778}{ephysics\_body\_restitution\_set}}(box\_body1, 0.7);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga986d45060bf6ba1689a56889a2bcabce}{ephysics\_body\_friction\_set}}(box\_body1, 0);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga5fe14931bd89326182bdf021d84ec40c}{ephysics\_body\_force\_apply}}(box\_body1, 60, 0, 0, 0, 10, 0);}
\DoxyCodeLine{   test\_data->bodies = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(test\_data->bodies, box\_body1);}
\DoxyCodeLine{}
\DoxyCodeLine{   box2 = \mbox{\hyperlink{group__Elm__Image_ga5d211c8af4f6e297a24fc4e8737c81a9}{elm\_image\_add}}(test\_data->win);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Image_gad1a96ede5f513042cef3c1dac4572f73}{elm\_image\_file\_set}}(}
\DoxyCodeLine{      box2, PACKAGE\_DATA\_DIR \textcolor{stringliteral}{"/"} EPHYSICS\_TEST\_THEME \textcolor{stringliteral}{".edj"}, \textcolor{stringliteral}{"purple-cube"});}
\DoxyCodeLine{   evas\_object\_move(box2, 80, FLOOR\_Y - 100);}
\DoxyCodeLine{   evas\_object\_resize(box2, 70, 70);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(box2);}
\DoxyCodeLine{   test\_data->evas\_objs = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(test\_data->evas\_objs, box2);}
\DoxyCodeLine{}
\DoxyCodeLine{   box\_body2 = \mbox{\hyperlink{group__EPhysics__Body_gaf8f30587da7453114397d64dd9704d7f}{ephysics\_body\_box\_add}}(test\_data->world);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga39cb9e95bbe1d097926a09365c501db3}{ephysics\_body\_evas\_object\_set}}(box\_body2, box2, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_gada176f4748a4c2fc4ba2042021ea7067}{ephysics\_body\_event\_callback\_add}}(box\_body2, \mbox{\hyperlink{group__EPhysics__Body_gga904d0d1462e71c1f32cb27f540b5277cacb2363cd59bc8642e74ad916c6658e0a}{EPHYSICS\_CALLBACK\_BODY\_UPDATE}},}
\DoxyCodeLine{                                    \_update\_object\_cb, NULL);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga731c9a6443f7c4294fce23fc1287b778}{ephysics\_body\_restitution\_set}}(box\_body2, 0.7);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga986d45060bf6ba1689a56889a2bcabce}{ephysics\_body\_friction\_set}}(box\_body2, 0);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga2134702db807dc4f7dc604d72e5b73db}{ephysics\_body\_central\_force\_apply}}(box\_body2, 60, 0, 0);}
\DoxyCodeLine{   test\_data->bodies = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(test\_data->bodies, box\_body2);}
\DoxyCodeLine{   test\_data->data = box\_body2;}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_restart(\textcolor{keywordtype}{void} *data, \mbox{\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\_\_)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   Test\_Data *test\_data = data;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__File__Group_gae8924623ca601364965e3d88fb7f40fa}{DBG}}(\textcolor{stringliteral}{"Restart pressed"});}
\DoxyCodeLine{   test\_clean(test\_data);}
\DoxyCodeLine{   \_world\_populate(test\_data);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{void}}
\DoxyCodeLine{test\_forces(\textcolor{keywordtype}{void} *data \_\_UNUSED\_\_, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *obj \_\_UNUSED\_\_, \textcolor{keywordtype}{void} *event\_info \_\_UNUSED\_\_)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_gaf39ad724f8a2f81f9139c63263900bf1}{EPhysics\_Body}} *boundary;}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__World_ga83c0d22744748525aa2dac11726c58e6}{EPhysics\_World}} *world;}
\DoxyCodeLine{   Test\_Data *test\_data;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__EPhysics_gaca8fc170d73b3f688349cc4dbaf219fd}{ephysics\_init}}())}
\DoxyCodeLine{     \textcolor{keywordflow}{return};}
\DoxyCodeLine{}
\DoxyCodeLine{   test\_data = test\_data\_new();}
\DoxyCodeLine{   test\_win\_add(test\_data, \textcolor{stringliteral}{"Forces"}, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__General_ga1beada7edf5d714c0dba5459bcc993fc}{elm\_object\_signal\_emit}}(test\_data->layout, \textcolor{stringliteral}{"borders,show"}, \textcolor{stringliteral}{"ephysics\_test"});}
\DoxyCodeLine{   \mbox{\hyperlink{group__Elm__Layout_gadab42e647f164fc8ab585c0e1bd34cc0}{elm\_layout\_signal\_callback\_add}}(test\_data->layout, \textcolor{stringliteral}{"restart"}, \textcolor{stringliteral}{"test-theme"},}
\DoxyCodeLine{                                  \_restart, test\_data);}
\DoxyCodeLine{}
\DoxyCodeLine{   world = \mbox{\hyperlink{group__EPhysics__World_ga108e2d7df8c81321b8d5bde8497f0d45}{ephysics\_world\_new}}();}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__World_gaabf8abaf9c41b0c1e5daa4acf3df0356}{ephysics\_world\_render\_geometry\_set}}(world, 50, 40, -50,}
\DoxyCodeLine{                                      WIDTH - 100, FLOOR\_Y - 40, DEPTH);}
\DoxyCodeLine{   test\_data->world = world;}
\DoxyCodeLine{}
\DoxyCodeLine{   boundary = \mbox{\hyperlink{group__EPhysics__Body_gac5fc5a1817ac81e2f1fcdcd8908614f2}{ephysics\_body\_bottom\_boundary\_add}}(test\_data->world);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga731c9a6443f7c4294fce23fc1287b778}{ephysics\_body\_restitution\_set}}(boundary, 1);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga986d45060bf6ba1689a56889a2bcabce}{ephysics\_body\_friction\_set}}(boundary, 0);}
\DoxyCodeLine{}
\DoxyCodeLine{   boundary = \mbox{\hyperlink{group__EPhysics__Body_ga2a3e40784ef30f15d5d7e9f1f2a814b3}{ephysics\_body\_top\_boundary\_add}}(test\_data->world);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga731c9a6443f7c4294fce23fc1287b778}{ephysics\_body\_restitution\_set}}(boundary, 1);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga986d45060bf6ba1689a56889a2bcabce}{ephysics\_body\_friction\_set}}(boundary, 0);}
\DoxyCodeLine{}
\DoxyCodeLine{   boundary = \mbox{\hyperlink{group__EPhysics__Body_ga4ad52252b2537c6f41e14b9135847fe9}{ephysics\_body\_left\_boundary\_add}}(test\_data->world);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga731c9a6443f7c4294fce23fc1287b778}{ephysics\_body\_restitution\_set}}(boundary, 1);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga986d45060bf6ba1689a56889a2bcabce}{ephysics\_body\_friction\_set}}(boundary, 0);}
\DoxyCodeLine{}
\DoxyCodeLine{   boundary = \mbox{\hyperlink{group__EPhysics__Body_gab7e598db12a5270311c429f0ee12271c}{ephysics\_body\_right\_boundary\_add}}(test\_data->world);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga731c9a6443f7c4294fce23fc1287b778}{ephysics\_body\_restitution\_set}}(boundary, 1);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__Body_ga986d45060bf6ba1689a56889a2bcabce}{ephysics\_body\_friction\_set}}(boundary, 0);}
\DoxyCodeLine{}
\DoxyCodeLine{   \_world\_populate(test\_data);}
\DoxyCodeLine{   \mbox{\hyperlink{group__EPhysics__World_ga849f9d794ce5da7bf07f0bfc71aa5b6c}{ephysics\_world\_gravity\_set}}(world, 0, 0, 0);}
\DoxyCodeLine{\}}
\end{DoxyCodeInclude}
 