1 #ifndef EPHYSICS_H
2 #define EPHYSICS_H
3 
4 /**
5  * @page ephysics_main EPhysics
6  *
7  * @date 2012 (created)
8  *
9  * @section ephysics_toc Table of Contents
10  *
11  * @li @ref ephysics_main_intro
12  * @li @ref ephysics_main_compiling
13  * @li @ref ephysics_main_next_steps
14  * @li @ref ephysics_main_intro_example
15  *
16  * @section ephysics_main_intro Introduction
17  *
18  * EPhysics is a library that makes it easy to use Ecore, Evas and Bullet
19  * Physics together. It's a kind of wrapper, a glue, between these libraries.
20  * It's not intended to be a physics library (we already have many out there).
21  *
22  * @image html diagram_ephysics.png
23  * @image latex diagram_ephysics.eps
24  *
25  * @section ephysics_main_compiling How to compile
26  *
27  * Ephysics is a library your application links to. The procedure for this is
28  * very simple. You simply have to compile your application with the
29  * appropriate compiler flags that the @c pkg-config script outputs. For
30  * example:
31  *
32  * Compiling C or C++ files into object files:
33  *
34  * @verbatim
35    gcc -c -o main.o main.c `pkg-config --cflags ephysics`
36    @endverbatim
37  *
38  * Linking object files into a binary executable:
39  *
40  * @verbatim
41    gcc -o my_application main.o `pkg-config --libs ephysics`
42    @endverbatim
43  *
44  * See @ref pkgconfig
45  *
46  * @section ephysics_main_next_steps Next Steps
47  *
48  * After you understood what EPhysics is and installed it in your system
49  * you should proceed understanding the programming interface.
50  *
51  * Recommended reading:
52  * @li @ref EPhysics
53  * @li @ref EPhysics_World
54  * @li @ref EPhysics_Body
55  * @li @ref EPhysics_Camera
56  * @li @ref EPhysics_Constraint
57  * @li @ref EPhysics_Quaternion
58  * @li @ref EPhysics_Shape
59  *
60  * @section ephysics_main_intro_example Introductory Example
61  *
62  * @include test_bouncing_ball.c
63  *
64  * More examples can be found at @ref ephysics_examples.
65  */
66 
67 #include <Evas.h>
68 #include <Efl_Config.h>
69 
70 #ifdef EAPI
71 # undef EAPI
72 #endif
73 
74 #ifdef _WIN32
75 # ifdef EFL_BUILD
76 #  ifdef DLL_EXPORT
77 #   define EAPI __declspec(dllexport)
78 #  else
79 #   define EAPI
80 #  endif
81 # else
82 #  define EAPI __declspec(dllimport)
83 # endif
84 #else
85 # ifdef __GNUC__
86 #  if __GNUC__ >= 4
87 #   define EAPI __attribute__ ((visibility("default")))
88 #  else
89 #   define EAPI
90 #  endif
91 # else
92 #  define EAPI
93 # endif
94 #endif
95 
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
99 
100 #define EPHYSICS_VERSION_MAJOR EFL_VERSION_MAJOR
101 #define EPHYSICS_VERSION_MINOR EFL_VERSION_MINOR
102 
103 /**
104  * @file
105  * @brief These routines are used for EPhysics library interaction.
106  */
107 
108 /**
109  * @brief Physics simulation integration and visual effects.
110  * @defgroup EPhysics EPhysics
111  *
112  * @{
113  *
114  */
115 
116 /**
117  * Initialize EPhysics
118  *
119  * Initializes Bullet physics engine.
120  *
121  * @return The init counter value.
122  *
123  * @see ephysics_shutdown().
124  *
125  * @ingroup EPhysics
126  */
127 EAPI int ephysics_init(void);
128 
129 /**
130  * Shutdown EPhysics
131  *
132  * Shutdown Bullet physics engine. If init count reaches 0, all the existing
133  * worlds will be deleted, and consequently all the bodies.
134  *
135  * @return EPhysics' init counter value.
136  *
137  * @see ephysics_init().
138  *
139  * @ingroup EPhysics
140  */
141 EAPI int ephysics_shutdown(void);
142 
143 /**
144  * @}
145  */
146 
147 /**
148  * @defgroup EPhysics_Quaternion EPhysics Quaternion
149  * @ingroup EPhysics
150  *
151  * @{
152  *
153  * Quaternions are used to perform linear algebra rotations.
154  *
155  * Functions regarding rotation, like @ref ephysics_body_rotation_set()
156  * and @ref ephysics_body_rotation_get() would need that. Quaternions
157  * can be used to rotate evas maps as well, with evas_map_util_quat_rotate(),
158  * but in this case quaternion values need to be get with
159  * @ref ephysics_quaternion_get(), since evas don't accept
160  * EPhysics_Quaternion type.
161  *
162  * A quaternion can be created with ephysics_quaternion_new(), and many
163  * operations can be performed with that, as:
164  * @li Sum: @ref ephysics_quaternion_sum()
165  * @li Difference: @ref ephysics_quaternion_diff()
166  * @li Multiple by another quaternion: @ref ephysics_quaternion_multiply()
167  * @li Multiply by scalar: @ref ephysics_quaternion_scale()
168  * @li Divide by scalar: @ref ephysics_quaternion_inverse_scale()
169  * @li Calculate length: @ref ephysics_quaternion_length_get()
170  * @li Calculate angle between quaternions: @ref ephysics_quaternion_angle_get()
171  */
172 
173 /**
174  * @typedef EPhysics_Quaternion
175  *
176  * Quaternion handle, represents a quaternion to be used to rotate bodies.
177  *
178  * Created with @ref ephysics_quaternion_new() and deleted with free().
179  *
180  * @ingroup EPhysics_Quaternion
181  */
182 typedef struct _EPhysics_Quaternion EPhysics_Quaternion;
183 
184 /**
185  * @struct _EPhysics_Quaternion
186  *
187  * Quaternion coordinates and rotation (w, x, y, z)
188  */
189 struct _EPhysics_Quaternion
190 {
191    double w; /**< rotation */
192    double x; /**< x coordinate */
193    double y; /**< y coordinate */
194    double z; /**< z coordinate */
195 };
196 
197 /**
198  * @brief
199  * Create a new quaternion.
200  *
201  * By default a quaternion is created as identity  (w = 1, x = 0, y = 0, z = 0).
202  * This values can be modified later by quaternion operations or set directly.
203  *
204  * @return The created quaternion or @c NULL on error.
205  *
206  * @note It should be deleted with free() after usage is concluded.
207  *
208  * @see ephysics_quaternion_set();
209  * @see ephysics_quaternion_axis_angle_set();
210  * @see ephysics_quaternion_euler_set();
211  * @see ephysics_quaternion_scale();
212  * @see ephysics_quaternion_sum();
213  *
214  * @ingroup EPhysics_Quaternion
215  */
216 EAPI EPhysics_Quaternion *ephysics_quaternion_new(void);
217 
218 /**
219  * @brief
220  * Get quaternion values.
221  *
222  * @param quat Quaternion to get values from.
223  * @param x The x coordinate.
224  * @param y The y coordinate.
225  * @param z The z coordinate.
226  * @param w The rotation.
227  *
228  * @see ephysics_quaternion_set();
229  *
230  * @ingroup EPhysics_Quaternion
231  */
232 EAPI void ephysics_quaternion_get(const EPhysics_Quaternion *quat, double *x, double *y, double *z, double *w);
233 
234 /**
235  * @brief
236  * Get quaternion axis and angle.
237  *
238  * @param quat Quaternion to get values from.
239  * @param nx The x component of the axis of rotation.
240  * @param ny The y component of the axis of rotation.
241  * @param nz The z component of the axis of rotation.
242  * @param a The angle of rotation.
243  *
244  * @see ephysics_quaternion_axis_angle_set();
245  * @see ephysics_quaternion_get();
246  * @see ephysics_quaternion_set();
247  *
248  * @ingroup EPhysics_Quaternion
249  */
250 EAPI void ephysics_quaternion_axis_angle_get(const EPhysics_Quaternion *quat, double *nx, double *ny, double *nz, double *a);
251 
252 /**
253  * @brief
254  * Set quaternion values.
255  *
256  * @param quat Quaternion to be set.
257  * @param x The x coordinate.
258  * @param y The y coordinate.
259  * @param z The z coordinate.
260  * @param w The rotation.
261  *
262  * @see ephysics_quaternion_get();
263  * @see ephysics_quaternion_euler_set();
264  *
265  * @ingroup EPhysics_Quaternion
266  */
267 EAPI void ephysics_quaternion_set(EPhysics_Quaternion *quat, double x, double y, double z, double w);
268 
269 /**
270  * @brief
271  * Set quaternion using axis angle notation.
272  *
273  * [w, x, y, z] = [cos(a/2), sin(a/2) * nx, sin(a/2)* ny, sin(a/2) * nz]
274  *
275  * @param quat Quaternion to be set.
276  * @param nx The x component of the axis of rotation.
277  * @param ny The y component of the axis of rotation.
278  * @param nz The z component of the axis of rotation.
279  * @param a The angle of rotation.
280  *
281  * @see ephysics_quaternion_axis_angle_get();
282  * @see ephysics_quaternion_set();
283  * @see ephysics_quaternion_euler_set();
284  *
285  * @ingroup EPhysics_Quaternion
286  */
287 EAPI void ephysics_quaternion_axis_angle_set(EPhysics_Quaternion *quat, double nx, double ny, double nz, double a);
288 
289 /**
290  * @brief
291  * Set quaternion using Euler angles.
292  *
293  * It's an alternative to @ref ephysics_quaternion_set() usage. Euler angles
294  * will be converted.
295  *
296  * @param quat Quaternion to be set.
297  * @param yaw The angle around Y axis.
298  * @param pitch The angle around X axis.
299  * @param roll The angle around Z axis.
300  *
301  * @see ephysics_quaternion_get();
302  * @see ephysics_quaternion_set();
303  *
304  * @ingroup EPhysics_Quaternion
305  */
306 EAPI void ephysics_quaternion_euler_set(EPhysics_Quaternion *quat, double yaw, double pitch, double roll);
307 
308 /**
309  * @brief
310  * Normalize the quaternion.
311  *
312  * A normalized quaternion is such that x^2 + y^2 + z^2 + w^2 = 1.
313  *
314  * @param quat Quaternion to be normalized.
315  *
316  * @ingroup EPhysics_Quaternion
317  */
318 EAPI void ephysics_quaternion_normalize(EPhysics_Quaternion *quat);
319 
320 /**
321  * @brief
322  * Invert the quaternion.
323  *
324  * @param quat Quaternion to be inverted.
325  *
326  * @ingroup EPhysics_Quaternion
327  */
328 EAPI void ephysics_quaternion_invert(EPhysics_Quaternion *quat);
329 
330 /**
331  * @brief
332  * Scale the quaternion.
333  *
334  * @param quat Quaternion to be scaled.
335  * @param scale The scale factor.
336  *
337  * @see ephysics_quaternion_inverse_scale()
338  *
339  * @ingroup EPhysics_Quaternion
340  */
341 EAPI void ephysics_quaternion_scale(EPhysics_Quaternion *quat, double scale);
342 
343 /**
344  * @brief
345  * Inversely scale the quaternion.
346  *
347  * @param quat Quaternion to be scaled.
348  * @param scale The scale factor.
349  *
350  * @see ephysics_quaternion_scale()
351  *
352  * @ingroup EPhysics_Quaternion
353  */
354 EAPI void ephysics_quaternion_inverse_scale(EPhysics_Quaternion *quat, double scale);
355 
356 /**
357  * @brief
358  * Returns a sum of two quaternions.
359  *
360  * @param quat1 First quaternion to sum.
361  * @param quat2 Second quaternion to sum.
362  * @param result Quaternion used to store the result. If it's @c NULL, a new
363  * quaternion will be allocated (and should be freed after usage).
364  * @return The sum quaternion or @c NULL on error.
365  *
366  * @ingroup EPhysics_Quaternion
367  */
368 EAPI EPhysics_Quaternion *ephysics_quaternion_sum(const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2, EPhysics_Quaternion *result);
369 
370 /**
371  * @brief
372  * Returns a difference between two quaternions.
373  *
374  * @param quat1 First quaternion.
375  * @param quat2 Second quaternion.
376  * @param result Quaternion used to store the result. If it's @c NULL, a new
377  * quaternion will be allocated (and should be freed after usage).
378  * @return The difference between @p quat1 and @p quat2, or @c NULL on error.
379  *
380  * @ingroup EPhysics_Quaternion
381  */
382 EAPI EPhysics_Quaternion *ephysics_quaternion_diff(const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2, EPhysics_Quaternion *result);
383 
384 /**
385  * @brief
386  * Multiply two quaternions.
387  *
388  * @param quat1 First quaternion.
389  * @param quat2 Second quaternion.
390  * @param result Quaternion used to store the result. If it's @c NULL, a new
391  * quaternion will be allocated (and should be freed after usage).
392  * @return The @p quat1 multiplied by @p quat2 on the right, or @c NULL
393  * on error.
394  *
395  * @ingroup EPhysics_Quaternion
396  */
397 EAPI EPhysics_Quaternion *ephysics_quaternion_multiply(const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2, EPhysics_Quaternion *result);
398 
399 /**
400  * @brief
401  * Return the quaternion which is the result of Spherical Linear Interpolation
402  * between two quaternions.
403  *
404  * Slerp interpolates assuming constant velocity.
405  *
406  * @param quat1 First quaternion.
407  * @param quat2 Second quaternion.
408  * @param ratio The ratio between @p quat1 and @p quat2 to interpolate. If
409  * @p ratio = 0, the result is @p quat1, if @p ratio = 1, the result is
410  * @p quat2.
411  * @param result Quaternion used to store the result. If it's @c NULL, a new
412  * quaternion will be allocated (and should be freed after usage).
413  * @return The result of slerp between @p quat1 and @p quat2, or @c NULL
414  * on error.
415  *
416  * @ingroup EPhysics_Quaternion
417  */
418 EAPI EPhysics_Quaternion *ephysics_quaternion_slerp(const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2, double ratio, EPhysics_Quaternion *result);
419 
420 /**
421  * @brief
422  * Return the dot product between two quaternions.
423  *
424  * @param quat1 First quaternion.
425  * @param quat2 Second quaternion.
426  * @return The dot product between @p quat1 and @p quat2 or @c 0 on error.
427  *
428  * @ingroup EPhysics_Quaternion
429  */
430 EAPI double ephysics_quaternion_dot(const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2);
431 
432 /**
433  * @brief
434  * Return the angle between two quaternions.
435  *
436  * @param quat1 First quaternion.
437  * @param quat2 Second quaternion.
438  * @return The angle between @p quat1 and @p quat2 or @c 0 on error.
439  *
440  * @ingroup EPhysics_Quaternion
441  */
442 EAPI double ephysics_quaternion_angle_get(const EPhysics_Quaternion *quat1, const EPhysics_Quaternion *quat2);
443 
444 /**
445  * @brief
446  * Return the length of the quaternion.
447  *
448  * @param quat Quaternion to get length of.
449  * @return The length of @p quat or @c 0 on error.
450  *
451  * @ingroup EPhysics_Quaternion
452  */
453 EAPI double ephysics_quaternion_length_get(const EPhysics_Quaternion *quat);
454 
455 /**
456  * @brief
457  * Return the length squared of the quaternion.
458  *
459  * @param quat Quaternion to get length of.
460  * @return The length of @p quat or @c 0 on error.
461  *
462  * @ingroup EPhysics_Quaternion
463  */
464 EAPI double ephysics_quaternion_length2_get(const EPhysics_Quaternion *quat);
465 
466 /**
467  * @}
468  */
469 
470 /**
471  * @defgroup EPhysics_Shape EPhysics Shape
472  * @ingroup EPhysics
473  *
474  * @{
475  *
476  * Shapes are used to create bodies with shapes that differ from primitive
477  * ones, like box and cylinder.
478  *
479  * A shape consists in a group of points, the vertices of the body to be
480  * created later with @ref ephysics_body_shape_add().
481  *
482  * A new shape is created with @ref ephysics_shape_new() and points are
483  * set with @ref ephysics_shape_point_add(). A shape can be used to
484  * create many bodies. When done, it's required to delete the shape
485  * with @ref ephysics_shape_del().
486  *
487  * A shape can be loaded from a file describing it with
488  * @ref ephysics_shape_load(), and can be saved to a file with
489  * @ref ephysics_shape_save(). With that shapes can be done or visualized
490  * on design applications.
491  *
492  * @note Using primitive shapes has better performance than generic shapes.
493  * @note For now, only convex shapes are supported.
494  *
495  */
496 
497 /**
498  * @typedef EPhysics_Shape
499  *
500  * Shape handle, represents a shape to be used to create a body.
501  *
502  * Created with @ref ephysics_shape_new() and deleted with
503  * @ref ephysics_shape_del().
504  *
505  * @ingroup EPhysics_Shape
506  */
507 typedef struct _EPhysics_Shape EPhysics_Shape;
508 
509 /**
510  * @brief
511  * Create a new shape.
512  *
513  * The returned shape initially doesn't has points set, so it's required
514  * to set vertices with @ref ephysics_shape_point_add().
515  *
516  * After the shape is completely defined, all the points were added,
517  * it's possible to create one or more bodies with
518  * @ref ephysics_body_shape_add().
519  *
520  * @return The created shape or @c NULL on error.
521  *
522  * @see ephysics_shape_del().
523  * @see ephysics_shape_load().
524  *
525  * @ingroup EPhysics_Shape
526  */
527 EAPI EPhysics_Shape *ephysics_shape_new(void);
528 
529 /**
530  * @brief
531  * Delete a shape.
532  *
533  * After a shape is used to create the wanted bodies, it's required
534  * to delete it. It won't be deleted automatically by ephysics
535  * at any point, even on shutdown. The creator is responsible to
536  * free it after usage is concluded.
537  *
538  * @param shape The shape to be deleted.
539  *
540  * @see ephysics_shape_new().
541  *
542  * @ingroup EPhysics_Shape
543  */
544 EAPI void ephysics_shape_del(EPhysics_Shape *shape);
545 
546 /**
547  * @brief
548  * Add a new point to the shape.
549  *
550  * Any point can be added to a shape, but only vertices matter.
551  * A vertex is a special kind of point that describes a corner of
552  * geometric shapes. The final shape will be constructed in such a way
553  * it will have all the added points and will be convex.
554  *
555  * The center of mass will be the centroid, or geometric center of the
556  * shape.
557  *
558  * The order of points doesn't matter.
559  *
560  * For example, to create a pentagon:
561  *
562  * @code
563  * EPhysics_Shape *shape = ephysics_shape_new();
564  *
565  * ephysics_shape_point_add(shape, 0, 24, -10);
566  * ephysics_shape_point_add(shape, 0, 24, 10);
567  * ephysics_shape_point_add(shape, 35, 0, -10);
568  * ephysics_shape_point_add(shape, 35, 0, 10);
569  * ephysics_shape_point_add(shape, 70, 24, -10);
570  * ephysics_shape_point_add(shape, 70, 24, 10);
571  * ephysics_shape_point_add(shape, 56, 66, -10);
572  * ephysics_shape_point_add(shape, 56, 66, 10);
573  * ephysics_shape_point_add(shape, 14, 66, -10);
574  * ephysics_shape_point_add(shape, 14, 66, 10);
575  *
576  * ephysics_body_shape_add(world, shape);
577  *
578  * ephysics_shape_del(shape);
579  * @endcode
580  *
581  * @param shape The shape to be modified.
582  * @param x Point position at x axis.
583  * @param y Point position at y axis.
584  * @param z Point position at z axis.
585  * @return @c EINA_TRUE on success or EINA_FALSE on error.
586  *
587  * @see ephysics_shape_new().
588  *
589  * @ingroup EPhysics_Shape
590  */
591 EAPI Eina_Bool ephysics_shape_point_add(EPhysics_Shape *shape, double x, double y, double z);
592 
593 /**
594  * @brief
595  * Load the shape from a file.
596  *
597  * Useful to edit shapes on design tools and load it from an exported file.
598  *
599  * Also it helps to avoid lots of @ref ephysics_shape_point_add() in
600  * the code, and keep a better separation between code logic and
601  * design stuff.
602  *
603  * @param filename The path to the file describing the shape.
604  * @return The loaded shape or @c NULL on error.
605  *
606  * @note Not implemented yet.
607  *
608  * @see ephysics_shape_new() for more details.
609  * @see ephysics_shape_save().
610  *
611  * @ingroup EPhysics_Shape
612  */
613 EAPI EPhysics_Shape *ephysics_shape_load(const char *filename);
614 
615 /**
616  * @brief
617  * Save the shape to a file.
618  *
619  * It can be useful to visualize it on design tools.
620  *
621  * @param shape The shape to be saved.
622  * @param filename The path to save the shape.
623  * @return @c EINA_TRUE on success or EINA_FALSE on error.
624  *
625  * @note Not implemented yet.
626  *
627  * @see ephysics_shape_new().
628  * @see ephysics_shape_load().
629  *
630  * @ingroup EPhysics_Shape
631  */
632 EAPI Eina_Bool ephysics_shape_save(const EPhysics_Shape *shape, const char *filename);
633 
634 /**
635  * @}
636  */
637 
638 
639 /**
640  * @typedef EPhysics_Body
641  *
642  * Body handle, represents an object on EPhysics world.
643  *
644  * Many types of bodies can be created:
645  * @li @ref ephysics_body_cylinder_add()
646  * @li @ref ephysics_body_box_add()
647  * @li @ref ephysics_body_shape_add()
648  * @li @ref ephysics_body_soft_cylinder_add()
649  * @li @ref ephysics_body_soft_box_add()
650  *
651  * and it can be deleted with @ref ephysics_body_del().
652  *
653  * @ingroup EPhysics_Body
654  */
655 typedef struct _EPhysics_Body EPhysics_Body;
656 
657 /**
658  * @defgroup EPhysics_Camera EPhysics Camera
659  * @ingroup EPhysics
660  *
661  * @{
662  *
663  * A camera defines the region of the physics world that will be rendered
664  * on the canvas. It sets the point of view.
665  *
666  * Every world has a camera, that can be gotten with
667  * @ref ephysics_world_camera_get().
668  * Its position can be set with @ref ephysics_camera_position_set() or
669  * can be set to track a body, with @ref ephysics_camera_body_track();
670  *
671  */
672 
673 typedef struct _EPhysics_Camera EPhysics_Camera; /**< Camera handle, used to change the position of the frame to be rendered. Every world have a camera that can be gotten with @ref ephysics_world_camera_get(). */
674 
675 /**
676  * @brief
677  * Set camera's position.
678  *
679  * Camera's position referes to the position of the top-left point of the
680  * camera.
681  *
682  * By default a camera is created to map the first quadrant of physics
683  * world from the point (0, 0) to
684  * (render area width / world rate, render area height / world rate).
685  *
686  * When render area is set with @ref ephysics_world_render_geometry_set(),
687  * the camera geometry is updated to match it. So, for most cases, camera
688  * won't need to be handled by the user.
689  *
690  * But it can be modified passing another top-left point position, so another
691  * region of the physics world will be rendered on the render area.
692  * So if you have a scene larger than the render area, camera handling can
693  * be very useful.
694  *
695  * This function will make camera stop tracking a body set with
696  * @ref ephysics_camera_body_track().
697  *
698  * @note This change will be noticed on the next physics tick, so evas objects
699  * will be updated taking the camera's new position in account.
700  *
701  * @param camera The camera to be positioned.
702  * @param x The new position on x axis, in pixels.
703  * @param y The new position on y axis, in pixels.
704  *
705  * @see ephysics_camera_position_get().
706  * @see ephysics_world_camera_get().
707  * @see ephysics_world_rate_get().
708  *
709  * @ingroup EPhysics_Camera
710  */
711 EAPI void ephysics_camera_position_set(EPhysics_Camera *camera, Evas_Coord x, Evas_Coord y);
712 
713 /**
714  * @brief
715  * Get camera's position.
716  *
717  * @param camera The world's camera.
718  * @param x Position on x axis, in pixels.
719  * @param y Position on y axis, in pixels.
720  *
721  * @see ephysics_camera_position_set() for more details.
722  *
723  * @ingroup EPhysics_Camera
724  */
725 EAPI void ephysics_camera_position_get(const EPhysics_Camera *camera, Evas_Coord *x, Evas_Coord *y);
726 
727 /**
728  * @brief
729  * Set camera to track a body.
730  *
731  * When a body is tracked, the camera will move automatically, following
732  * this body. It will keeps the body centralized on rendered area.
733  * If it will be centralized horizontally and / or vertically depends
734  * if parameters @p horizontal and @p vertical are set to @c EINA_TRUE.
735  *
736  * Default updates (@ref ephysics_body_evas_object_update())
737  * will take care of updating evas objects associated
738  * to the bodies correctly. But if you need to do it yourself, you'll need
739  * to take camera's position in consideration, using
740  * @ref ephysics_camera_position_get().
741  *
742  * @note This change will be noticed on the next physics tick, so evas objects
743  * will be updated taking the camera's new position in account.
744  *
745  * @param camera The world's camera.
746  * @param body The body tracked by the @p camera, or @c NULL if camera isn't
747  * tracking any body.
748  * @param horizontal @c EINA_TRUE if @p body is tracked on x axis,
749  * @c EINA_FALSE otherwise;
750  * @param vertical @c EINA_TRUE if @p body is tracked on y axis,
751  * @c EINA_FALSE otherwise;
752  *
753  * @see ephysics_camera_tracked_body_get().
754  * @see ephysics_camera_position_set().
755  * @see ephysics_world_camera_get().
756  *
757  * @ingroup EPhysics_Camera
758  */
759 EAPI void ephysics_camera_body_track(EPhysics_Camera *camera, EPhysics_Body *body, Eina_Bool horizontal, Eina_Bool vertical);
760 
761 /**
762  * @brief
763  * Get body tracked by camera.
764  *
765  * @param camera The world's camera.
766  * @param body The body tracked by the @p camera, or @c NULL if camera isn't
767  * tracking any body.
768  * @param horizontal @c EINA_TRUE if @p body is tracked on x axis,
769  * @c EINA_FALSE otherwise;
770  * @param vertical @c EINA_TRUE if @p body is tracked on y axis,
771  * @c EINA_FALSE otherwise;
772  *
773  * @see ephysics_camera_body_track() for more details.
774  *
775  * @ingroup EPhysics_Camera
776  */
777 EAPI void ephysics_camera_tracked_body_get(EPhysics_Camera *camera, EPhysics_Body **body, Eina_Bool *horizontal, Eina_Bool *vertical);
778 
779 /**
780  * @brief
781  * Set perspective to be applied on the scene.
782  *
783  * This applies a given perspective (3D) to the world rendering.
784  * It will be used when the scene is rendered, after each simulation step,
785  * by @ref ephysics_body_evas_object_update().
786  *
787  * The @p px and @p py points specify the "infinite distance" point in the 3D
788  * conversion (where all lines converge to like when artists draw 3D by hand).
789  * The @p z0 value specifies the z value at which there is a 1:1 mapping between
790  * spatial coordinates and screen coordinates. Any points on this z value will
791  * not have their X and Y values modified in the transform.
792  * Those further away (Z value higher) will shrink into the distance, and those
793  * less than this value will expand and become bigger. The foc value determines
794  * the "focal length" of the camera. This is in reality the distance between
795  * the camera lens plane itself (at or closer than this rendering results are
796  * undefined) and the @p z0 z value. This allows for some "depth" control and
797  * @p foc must be greater than 0.
798  *
799  * Considering the world geometry, by default, perspective is set to
800  * px = x + w / 2, py = y + h / 2, z0 = z + d / 2 and foc = 10 * (z + d).
801  * This means the conversion point is centered on render area, and @p z0
802  * is on the center of render area z axis. It is set when
803  * @ref ephysics_world_render_geometry_set() is called.
804  *
805  * @note The unit used for all parameters is Evas coordinates.
806  *
807  * @note To be used, perspective need to be enabled with
808  * @ref ephysics_camera_perspective_enabled_set().
809  *
810  * @param camera The world's camera.
811  * @param px The perspective distance X coordinate
812  * @param py The perspective distance Y coordinate
813  * @param z0 The "0" z plane value
814  * @param foc The focal distance
815  *
816  * @see ephysics_camera_perspective_get().
817  * @see ephysics_camera_perspective_enabled_set().
818  *
819  * @ingroup EPhysics_Camera
820  */
821 EAPI void ephysics_camera_perspective_set(EPhysics_Camera *camera, Evas_Coord px, Evas_Coord py, Evas_Coord z0, Evas_Coord foc);
822 
823 /**
824  * @brief
825  * Get perspective applied on the scene.
826  *
827  * @param camera The world's camera.
828  * @param px The perspective distance X coordinate
829  * @param py The perspective distance Y coordinate
830  * @param z0 The "0" z plane value
831  * @param foc The focal distance
832  *
833  * @see ephysics_camera_perspective_set() for more details.
834  * @see ephysics_camera_perspective_enabled_get().
835  *
836  * @ingroup EPhysics_Camera
837  */
838 EAPI void ephysics_camera_perspective_get(const EPhysics_Camera *camera, Evas_Coord *px, Evas_Coord *py, Evas_Coord *z0, Evas_Coord *foc);
839 
840 /**
841  * @brief
842  * Set if perspective should be applied.
843  *
844  * The applied perspective can be set with
845  * @ref ephysics_camera_perspective_set().
846  *
847  * @param camera The world's camera.
848  * @param enabled @c EINA_TRUE if perspective should be used, or @c EINA_FALSE
849  * if it shouldn't.
850  *
851  * @see ephysics_camera_perspective_set() for more details.
852  * @see ephysics_camera_perspective_enabled_get().
853  *
854  * @ingroup EPhysics_Camera
855  */
856 EAPI void ephysics_camera_perspective_enabled_set(EPhysics_Camera *camera, Eina_Bool enabled);
857 
858 /**
859  * @brief
860  * Return if perspective is enabled or not.
861  *
862  * @param camera The world's camera.
863  * @return @c EINA_TRUE if perspective is enabled, or @c EINA_FALSE if it
864  * isn't, or on error.
865  *
866  * @see ephysics_camera_perspective_set() for more details.
867  * @see ephysics_camera_perspective_enabled_set().
868  *
869  * @ingroup EPhysics_Camera
870  */
871 EAPI Eina_Bool ephysics_camera_perspective_enabled_get(const EPhysics_Camera *camera);
872 
873 /**
874  * @}
875  */
876 
877 /**
878  * @defgroup EPhysics_World EPhysics World
879  * @ingroup EPhysics
880  *
881  * @{
882  *
883  * A world is required to simulate physics between bodies.
884  * It will setup collision configuration,
885  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
886  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
887  * constraint solver</a></b>,
888  * the
889  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Broadphase">
890  * broadphase</a></b>
891  * interface and a dispatcher to dispatch calculations
892  * for overlapping pairs.
893  *
894  * A new world can be created with @ref ephysics_world_new() and deleted with
895  * @ref ephysics_world_del(). It can have its gravity changed with
896  * @ref ephysics_world_gravity_set() and play / paused with
897  * @ref ephysics_world_running_set(). When running, the simulation will be
898  * gradually stepped.
899  */
900 
901 typedef struct _EPhysics_World EPhysics_World; /**< World handle, most basic type of EPhysics. Created with @ref ephysics_world_new() and deleted with @ref ephysics_world_del(). */
902 
903 /**
904  * @enum _EPhysics_Callback_World_Type
905  * @typedef EPhysics_Callback_World_Type
906  *
907  * Identifier of callbacks to be set for EPhysics worlds.
908  *
909  * @see ephysics_world_event_callback_add()
910  * @see ephysics_world_event_callback_del()
911  * @see ephysics_world_event_callback_del_full()
912  *
913  * @ingroup EPhysics_World
914  */
915 typedef enum _EPhysics_Callback_World_Type
916 {
917    EPHYSICS_CALLBACK_WORLD_DEL, /**< World being deleted (called before free) */
918    EPHYSICS_CALLBACK_WORLD_STOPPED, /**< no objects are moving any more */
919    EPHYSICS_CALLBACK_WORLD_CAMERA_MOVED, /**< camera position changed */
920    EPHYSICS_CALLBACK_WORLD_UPDATE, /**< world being updated */
921    EPHYSICS_CALLBACK_WORLD_LAST, /**< kept as sentinel, not really an event */
922 } EPhysics_Callback_World_Type;
923 
924 /**
925  * @enum _EPhysics_World_Constraint_Solver_Mode
926  * typedef EPhysics_World_Constraint_Solver_Mode
927  *
928  * Identifies the worlds contact and
929  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Glossary_of_
930  * Terms#Joint.2C_constraint"> joint constraint</a></b>
931  * solver mode. By default
932  * EPHYSICS_WORLD_SOLVER_USE_WARMSTARTING is the only enabled solver mode.
933  *
934  * @see ephysics_world_constraint_solver_mode_enable_set()
935  * @see ephysics_world_constraint_solver_mode_enable_get()
936  *
937  * @ingroup EPhysics_World
938  */
939 typedef enum _EPhysics_World_Constraint_Solver_Mode
940 {
941    EPHYSICS_WORLD_SOLVER_RANDMIZE_ORDER = 1, /**< Randomize the order of solving the constraint rows*/
942    EPHYSICS_WORLD_SOLVER_USE_WARMSTARTING = 4, /**< The PGS is an iterative algorithm where each iteration is based on the solution of previous iteration, if no warmstarting is used, the initial solution for PGS is set to zero each frame (by default this mode is enabled, disabling this mode the user can face a better performance depending on the amount of objects in the simulation)*/
943    EPHYSICS_WORLD_SOLVER_USE_2_FRICTION_DIRECTIONS = 16, /**< While calculating a friction impulse consider this should be applied on both bodies (this mode cause a better stacking stabilization)*/
944    EPHYSICS_WORLD_SOLVER_SIMD = 256, /**< Use a SSE optimized innerloop, using assembly intrinsics, this is implemented and can be enabled/disabled for Windows and Mac OSX versions, single-precision floating point, 32bit(disabled by default)*/
945 } EPhysics_World_Solver_Mode;
946 
947 /**
948  * @typedef EPhysics_World_Event_Cb
949  *
950  * EPhysics world event callback function signature.
951  *
952  * Callbacks can be registered for events like world deleting.
953  *
954  * @param data User data that will be set when registering the callback.
955  * @param world Physics world.
956  * @param event_info Data specific to a kind of event. Some types of events
957  * don't have @p event_info.
958  *
959  * @see ephysics_world_event_callback_add() for more info.
960  *
961  * @ingroup EPhysics_World
962  */
963 typedef void (*EPhysics_World_Event_Cb)(void *data, EPhysics_World *world, void *event_info);
964 
965 /**
966  * @brief
967  * Create a new physics world.
968  *
969  * A new world will be created with set collision configuration,
970  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
971  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
972  * constraint solver</a></b>,
973  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Broadphase">
974  * broadphase</a></b>
975  * interface and dispatcher.
976  *
977  * It can be paused / unpaused with @ref ephysics_world_running_set() and its
978  * gravity can be changed with @ref ephysics_world_gravity_set().
979  *
980  * By default it starts with gravity y = 294 Evas coordinates per second ^ 2
981  * and playing.
982  *
983  * If default updates between physics bodies and evas objects will be used
984  * it's mandatory to set the size of the area to be rendered with
985  * @ref ephysics_world_render_geometry_set().
986  *
987  * @return A new world or @c NULL, on errors.
988  *
989  * @see ephysics_world_del().
990  *
991  * @ingroup EPhysics_World
992  */
993 EAPI EPhysics_World *ephysics_world_new(void);
994 
995 /**
996  * @brief
997  * Set dimensions of rendered area to be take on account by default updates.
998  *
999  * By default it starts with null x, y, width and height.
1000  *
1001  * The physics world won't be limited, but boundaries can be added with:
1002  * @li @ref ephysics_body_top_boundary_add(),
1003  * @li @ref ephysics_body_bottom_boundary_add(),
1004  * @li @ref ephysics_body_left_boundary_add(),
1005  * @li @ref ephysics_body_right_boundary_add(),
1006  * @li @ref ephysics_body_front_boundary_add(),
1007  * @li @ref ephysics_body_back_boundary_add().
1008  *
1009  * @param world the world to be configured.
1010  * @param x Coordinate x of the top left point of rendered area, in pixels.
1011  * @param y Coordinate y of the top left point of rendered area, in pixels.
1012  * @param z Coordinate z of the rendered area, in pixels.
1013  * @param w rendered area width, in pixels.
1014  * @param h rendered area height, in pixels.
1015  * @param d rendered area depth, in pixels.
1016  *
1017  * @note The unit used for geometry is Evas coordinates.
1018  *
1019  * @see ephysics_body_event_callback_add() for more info.
1020  * @see ephysics_world_rate_get().
1021  * @see ephysics_world_render_geometry_get().
1022  *
1023  * @ingroup EPhysics_World
1024  */
1025 EAPI void ephysics_world_render_geometry_set(EPhysics_World *world, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d);
1026 
1027 /**
1028  * @brief
1029  * Get dimensions of rendered area to be take on account by default updates.
1030  *
1031  * @param world the world to be configured.
1032  * @param x Coordinate x of the top left point of rendered area, in pixels.
1033  * @param y Coordinate y of the top left point of rendered area, in pixels.
1034  * @param z Coordinate z of the rendered area, in pixels.
1035  * @param w rendered area width, in pixels.
1036  * @param h rendered area height, in pixels.
1037  * @param d rendered area depth, in pixels.
1038  *
1039  * @see ephysics_world_render_geometry_set() for more information.
1040  *
1041  * @ingroup EPhysics_World
1042  */
1043 EAPI void ephysics_world_render_geometry_get(const EPhysics_World *world, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z, Evas_Coord *w, Evas_Coord *h, Evas_Coord *d);
1044 
1045 /**
1046  * @brief
1047  * Serializes the @p world to @p path.
1048  *
1049  * Save the dynamics world to a binary dump, a .bullet file.
1050  *
1051  * @note Should be used only for debugging purposes.
1052  *
1053  * @param world the world to be serialized.
1054  * @param path where the serialized world should be written to.
1055  *
1056  * @return EINA_TRUE on success, EINA_FALSE otherwise
1057  *
1058  * @ingroup EPhysics_World
1059  */
1060 EAPI Eina_Bool ephysics_world_serialize(EPhysics_World *world, const char *path);
1061 
1062 /**
1063  * @brief
1064  * Deletes a physics world.
1065  *
1066  * It will also delete all bodies associated to it.
1067  *
1068  * @param world The world to be deleted.
1069  *
1070  * @see ephysics_world_new() for more details.
1071  *
1072  * @ingroup EPhysics_World
1073  */
1074 EAPI void ephysics_world_del(EPhysics_World *world);
1075 
1076 /**
1077  * @brief
1078  * Set running status of world.
1079  *
1080  * A world can be played / paused. When running, it will simulate the
1081  * physics step by step. When paused, it will stop simulation. Consequently
1082  * all the registered callbacks won't be called since no event will occur
1083  * (no collisions, no object updates).
1084  *
1085  * When a world is created it starts running.
1086  *
1087  * @param world The world to be played / paused.
1088  * @param running If @c EINA_TRUE it will play, otherwise it will pause.
1089  *
1090  * @see ephysics_world_running_get()
1091  *
1092  * @ingroup EPhysics_World
1093  */
1094 EAPI void ephysics_world_running_set(EPhysics_World *world, Eina_Bool running);
1095 
1096 /**
1097  * @brief
1098  * Get running status of world.
1099  *
1100  * By default a world starts running.
1101  *
1102  * @param world The physics world.
1103  * @return @c EINA_TRUE if it's running, or @c EINA_FALSE if it's paused or on
1104  * error.
1105  *
1106  * @see ephysics_world_running_set() for more details.
1107  *
1108  * @ingroup EPhysics_World
1109  */
1110 EAPI Eina_Bool ephysics_world_running_get(const EPhysics_World *world);
1111 
1112 /**
1113  * @brief
1114  * Set the max sleeping time value.
1115  *
1116  * This value determines how long(in seconds) a rigid body under the linear and
1117  * angular threshold is supposed to be marked as sleeping. Default value is set
1118  * to 2.0.
1119  *
1120  * @param world The world to set the max sleeping time.
1121  * @param sleeping_time The max sleeping time to set to @p world.
1122  *
1123  * @see ephysics_world_max_sleeping_time_get()
1124  * @see ephysics_body_sleeping_threshold_set() for sleeping thresholds details.
1125  * @ingroup EPhysics_World
1126  */
1127 EAPI void ephysics_world_max_sleeping_time_set(EPhysics_World *world, double sleeping_time);
1128 
1129 /**
1130  * @brief
1131  * Get the max sleeping time value for @p world.
1132  *
1133  * @param world The world to get the max sleeping time from.
1134  * @return The max sleeping time from @p world.
1135  *
1136  * @see ephysics_world_max_sleeping_time_set()
1137  * @ingroup EPhysics_World
1138  */
1139 EAPI double ephysics_world_max_sleeping_time_get(const EPhysics_World *world);
1140 
1141 /**
1142  * @brief
1143  * Set world gravity in the 3 axes (x, y, z).
1144  *
1145  * Gravity will act over bodies with mass over all the time.
1146  *
1147  * By default values are 0, 294, 0 Evas Coordinates per second ^ 2
1148  * (9.8 m/s^2, since we've a default rate of 30 pixels).
1149  *
1150  * If you change the rate but wants to keep 9.8 m/s^2, you well need
1151  * to set world gravity with: 9.8 * new_rate.
1152  *
1153  * @param world The world object.
1154  * @param gx Gravity on x axis.
1155  * @param gy Gravity on y axis.
1156  * @param gz Gravity on z axis.
1157  *
1158  * @note The unit used for acceleration is Evas coordinates per second ^ 2.
1159  *
1160  * @see ephysics_world_gravity_get().
1161  * @see ephysics_world_rate_set().
1162  *
1163  * @ingroup EPhysics_World
1164  */
1165 EAPI void ephysics_world_gravity_set(EPhysics_World *world, double gx, double gy, double gz);
1166 
1167 /**
1168  * @brief
1169  * Set the number of iterations the
1170  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
1171  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
1172  * constraint solver</a></b>
1173  * will have for contact and
1174  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Glossary_of_
1175  * Terms#Joint.2C_constraint">
1176  * joint constraints</a></b>.
1177  *
1178  * The default value is set to 10. The greater number of iterations more
1179  * quality and precise the result but with performance penalty.
1180  *
1181  * By default, the Projected Gauss Seidel
1182  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
1183  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
1184  * constraint solver</a></b>
1185  * is used for contact and
1186  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Glossary_of_
1187  * Terms#Joint.2C_constraint">
1188  * joint constraints</a></b>.
1189  * The algorithm is an iterative LCP solver, informally known as 'sequential
1190  * impulse'.
1191  *
1192  * A reasonable range of iterations is from 4 (low quality, good performance)
1193  * to 20 (good quality, less but still reasonable performance).
1194  *
1195  * @param world The world to be set.
1196  * @param iterations The number of iterations to be set.
1197  *
1198  * @see ephysics_world_constraint_solver_iterations_get().
1199  * @ingroup EPhysics_World
1200  */
1201 EAPI void ephysics_world_constraint_solver_iterations_set(EPhysics_World *world, int iterations);
1202 
1203 /**
1204  * @brief
1205  * Get the number of iterations the
1206  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
1207  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
1208  * constraint solver</a></b>
1209  * will have for contact and
1210  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Glossary_of_
1211  * Terms#Joint.2C_constraint">
1212  * joint constraints</a></b>.
1213  *
1214  * @param world The world to get number of iterations from.
1215  * @return the number of iterations set to @p world, or 0 on failure.
1216  *
1217  * @see ephysics_world_constraint_solver_iterations_set() for its meaning.
1218  * @ingroup EPhysics_World
1219  */
1220 EAPI int ephysics_world_constraint_solver_iterations_get(const EPhysics_World *world);
1221 
1222 /**
1223  * @brief
1224  * Enable or disable a
1225  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
1226  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
1227  * constraint solver</a></b>
1228  * mode to @p world. A world can operate
1229  * on several
1230  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
1231  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
1232  * constraint solver</a></b>
1233  * modes.
1234  *
1235  * @param world The world to be set.
1236  * @param solver_mode The solver mode to set.
1237  * @param enable If @c EINA_TRUE enable the mode, if EINA_FALSE, disable it.
1238  *
1239  * @see EPhysics_World_Solver_Mode for supported solver modes.
1240  * @see ephysics_world_constraint_solver_mode_enable_get()
1241  * @ingroup EPhysics_World
1242  */
1243 EAPI void ephysics_world_constraint_solver_mode_enable_set(EPhysics_World *world, EPhysics_World_Solver_Mode solver_mode, Eina_Bool enable);
1244 
1245 /**
1246  * @brief
1247  * Get the @p solver_mode status on @p world.
1248  *
1249  * @param world The world to be queried.
1250  * @param solver_mode The solver mode of interest.
1251  * @return EINA_TRUE if @p solver_mode is enabled, EINA_FALSE otherwise.
1252  *
1253  * @see ephysics_world_constraint_solver_mode_enable_set()
1254  * @ingroup EPhysics_World
1255  */
1256 EAPI Eina_Bool ephysics_world_constraint_solver_mode_enable_get(const EPhysics_World *world, EPhysics_World_Solver_Mode solver_mode);
1257 
1258 /**
1259  * @brief
1260  * Get world gravity values for axis x, y and z.
1261  *
1262  * @param world The world object.
1263  * @param gx Gravity on x axis.
1264  * @param gy Gravity on y axis.
1265  * @param gz Gravity on y axis.
1266  *
1267  * @see ephysics_world_gravity_set().
1268  *
1269  * @ingroup EPhysics_World
1270  */
1271 EAPI void ephysics_world_gravity_get(const EPhysics_World *world, double *gx, double *gy, double *gz);
1272 
1273 /**
1274  * @brief
1275  * Set rate between pixels on evas canvas and meters on ephysics world.
1276  *
1277  * It will be used by automatic updates of evas objects associated to
1278  * physics bodies.
1279  *
1280  * By default its value is 30 Evas coordinates (pixels) per meter.
1281  *
1282  * If you change the rate but wants to keep gravity as (0, 9.8 m/s^2),
1283  * you well need to set world gravity with: 9.8 * new_rate.
1284  * For this, use @ref ephysics_world_gravity_set();
1285  *
1286  * @param world The world object.
1287  * @param rate Rate between pixels and meters. Value must be > 0.
1288  *
1289  * @see ephysics_body_event_callback_add() for more info.
1290  * @see ephysics_world_rate_get().
1291  *
1292  * @ingroup EPhysics_World
1293  */
1294 EAPI void ephysics_world_rate_set(EPhysics_World *world, double rate);
1295 
1296 /**
1297  * @brief
1298  * Get rate between pixels on evas canvas and meters on ephysics world.
1299  *
1300  * @param world The world object.
1301  * @return The rate between pixels and meters.
1302  *
1303  * @see ephysics_world_rate_set() for details.
1304  *
1305  * @ingroup EPhysics_World
1306  */
1307 EAPI double ephysics_world_rate_get(const EPhysics_World *world);
1308 
1309 /**
1310  * @brief
1311  * Gets the world's bodies list.
1312  *
1313  * @param world The world object.
1314  * @return The list of bodies that belongs to this @p world.
1315  *
1316  * @note The list should be freed after usage.
1317  *
1318  * @see ephysics_body_cylinder_add().
1319  * @see ephysics_body_box_add().
1320  * @see ephysics_body_del().
1321  *
1322  * @ingroup EPhysics_World
1323  */
1324 EAPI Eina_List *ephysics_world_bodies_get(const EPhysics_World *world);
1325 
1326 /**
1327  * @brief
1328  * Get the camera used by an ephysics world.
1329  *
1330  * @param world The world object.
1331  * @return The camera.
1332  *
1333  * @see ephysics_camera_position_set().
1334  * @see ephysics_camera_body_track().
1335  *
1336  * @ingroup EPhysics_World
1337  */
1338 EAPI EPhysics_Camera *ephysics_world_camera_get(const EPhysics_World *world);
1339 
1340 /**
1341  * @brief
1342  * Register a callback to a type of physics world event.
1343  *
1344  * The registered callback will receives the world and extra user data that
1345  * can be passed.
1346  *
1347  * What follows is a list of details about each callback type:
1348  *
1349  *  - #EPHYSICS_CALLBACK_WORLD_DEL: Called just before a world is freed.
1350  * No event_info is passed to the callback.
1351  *
1352  *  - #EPHYSICS_CALLBACK_WORLD_STOPPED: Called when all the bodies
1353  * are stopped. No event_info is passed to the callback.
1354  *
1355  *  - #EPHYSICS_CALLBACK_WORLD_CAMERA_MOVED: Called if camera position changed
1356  * on physics simulation tick. Camera is passed as event_info to the callback.
1357  * Useful to move backgrounds, since objects would be already updated
1358  * considering camera's position.
1359  *
1360  * @param world The physics world.
1361  * @param type Type of callback to be listened by @p func.
1362  * @param func Callback function that will be called when event occurs.
1363  * @param data User data that will be passed to callback function. It won't
1364  * be used by ephysics in any way.
1365  *
1366  * @ingroup EPhysics_World
1367  */
1368 EAPI void ephysics_world_event_callback_add(EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func, const void *data);
1369 
1370 /**
1371  * @brief
1372  * Unregister an ephysics world event callback.
1373  *
1374  * A previously added callback that match @p world, @p type and @p func
1375  * will be deleted.
1376  *
1377  * @param world The physics world.
1378  * @param type The type of callback to be unregistered.
1379  * @param func The callback function to be unregistered.
1380  * @return The user data passed when the callback was registered, or @c NULL
1381  * on error.
1382  *
1383  * @see ephysics_world_event_callback_add() for details.
1384  * @see ephysics_world_event_callback_del_full() if you need to match data
1385  * pointer.
1386  *
1387  * @ingroup EPhysics_World
1388  */
1389 EAPI void *ephysics_world_event_callback_del(EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func);
1390 
1391 /**
1392  * @brief
1393  * Unregister an ephysics world event callback matching data pointer.
1394  *
1395  * A previously added callback that match @p world, @p type, @p func
1396  * and @p data will be deleted.
1397  *
1398  * @param world The physics world.
1399  * @param type The type of callback to be unregistered.
1400  * @param func The callback function to be unregistered.
1401  * @param data The data pointer that was passed to the callback.
1402  * @return The user data passed when the callback was registered, or @c NULL
1403  * on error.
1404  *
1405  * @see ephysics_world_event_callback_add() for details.
1406  * @see ephysics_world_event_callback_del() if you don't need to match data
1407  * pointer.
1408  *
1409  * @ingroup EPhysics_World
1410  */
1411 EAPI void *ephysics_world_event_callback_del_full(EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func, void *data);
1412 
1413 /**
1414  * @brief
1415  * Set linear slop to be used by world.
1416  *
1417  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
1418  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
1419  * Constraint solver</a></b>
1420  * can be configured using some advanced settings, like
1421  * the solver slop factor.
1422  *
1423  * The default value is set to 0 with a small value results in a smoother
1424  * stabilization for stacking bodies.
1425  *
1426  * Linear slop on sequencial impulse
1427  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
1428  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
1429  * constraint solver</a></b>
1430  * is used as a factor for penetration. The penetration will the manifold
1431  * distance + linear slop.
1432  *
1433  * @param world The physics world.
1434  * @param linear_slop New linear slop value to be used by
1435  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
1436  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
1437  * constraint solver</a></b>
1438  * of physics engine.
1439  *
1440  * @ingroup EPhysics_World
1441  */
1442 EAPI void ephysics_world_linear_slop_set(EPhysics_World *world, double linear_slop);
1443 
1444 /**
1445  * @brief
1446  * Get linear slop used by world.
1447  *
1448  * @param world The physics world.
1449  * @return Linear slop value used by
1450  * <b><a href="http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_
1451  * Detection_and_Physics_FAQ#How_do_most_physics_engines_solve_constraints.3F">
1452  * constraint solver</a></b>
1453  * of physics engine or 0 on failure.
1454  *
1455  * @see ephysics_world_linear_slop_set() for details.
1456  *
1457  * @ingroup EPhysics_World
1458  */
1459 EAPI double ephysics_world_linear_slop_get(const EPhysics_World *world);
1460 
1461 /**
1462  * @brief
1463  * Set world autodeleting bodies mode when they're outside of render area
1464  * by the top.
1465  *
1466  * It's useful when you don't care about bodies leaving the render
1467  * area set with @ref ephysics_world_render_geometry_set(), and don't think
1468  * they could / should return. So you can safely delete them and save resources.
1469  *
1470  * Also, it's useful if you have only a bottom border set with
1471  * @ref ephysics_body_top_boundary_add() and gravity set,
1472  * and want to listen for @ref EPHYSICS_CALLBACK_WORLD_STOPPED event.
1473  * If a body goes out of the render area, they will be acting by gravity
1474  * and won't collide to anything, so they could be moving forever and
1475  * world would never stop. For this case, enabling autodel for left and right
1476  * borders seems to be a good idea.
1477  *
1478  * @param world The physics world.
1479  * @param autodel If @c EINA_TRUE delete bodies when they are outside render
1480  * area, otherwise, don't delete.
1481  *
1482  * @see ephysics_world_bodies_outside_top_autodel_get().
1483  * @see ephysics_world_bodies_outside_bottom_autodel_set().
1484  * @see ephysics_world_bodies_outside_left_autodel_set().
1485  * @see ephysics_world_bodies_outside_right_autodel_set().
1486  * @see ephysics_world_bodies_outside_front_autodel_set().
1487  * @see ephysics_world_bodies_outside_back_autodel_set().
1488  *
1489  * @ingroup EPhysics_World
1490  */
1491 EAPI void ephysics_world_bodies_outside_top_autodel_set(EPhysics_World *world, Eina_Bool autodel);
1492 
1493 /**
1494  * @brief
1495  * Get world autodeleting bodies mode when they're outside of render area by
1496  * the top.
1497  *
1498  * @param world The physics world.
1499  * @return @c EINA_TRUE if bodies will be deleted or @c EINA_FALSE if they
1500  * won't, or on error.
1501  *
1502  * @see ephysics_world_bodies_outside_top_autodel_set() for details.
1503  *
1504  * @ingroup EPhysics_World
1505  */
1506 EAPI Eina_Bool ephysics_world_bodies_outside_top_autodel_get(const EPhysics_World *world);
1507 
1508 /**
1509  * @brief
1510  * Set world autodeleting bodies mode when they're outside of render area
1511  * by the bottom.
1512  *
1513  * @param world The physics world.
1514  * @param autodel If @c EINA_TRUE delete bodies when they are outside render
1515  * area, otherwise, don't delete.
1516  *
1517  * @see ephysics_world_bodies_outside_top_autodel_set() for more details.
1518  * @see ephysics_world_bodies_outside_bottom_autodel_get().
1519  * @see ephysics_world_bodies_outside_left_autodel_set().
1520  * @see ephysics_world_bodies_outside_right_autodel_set().
1521  * @see ephysics_world_bodies_outside_front_autodel_set().
1522  * @see ephysics_world_bodies_outside_back_autodel_set().
1523  *
1524  * @ingroup EPhysics_World
1525  */
1526 EAPI void ephysics_world_bodies_outside_bottom_autodel_set(EPhysics_World *world, Eina_Bool autodel);
1527 
1528 /**
1529  * @brief
1530  * Get world autodeleting bodies mode when they're outside of render area by
1531  * the bottom.
1532  *
1533  * @param world The physics world.
1534  * @return @c EINA_TRUE if bodies will be deleted or @c EINA_FALSE if they
1535  * won't, or on error.
1536  *
1537  * @see ephysics_world_bodies_outside_bottom_autodel_set() for details.
1538  *
1539  * @ingroup EPhysics_World
1540  */
1541 EAPI Eina_Bool ephysics_world_bodies_outside_bottom_autodel_get(const EPhysics_World *world);
1542 
1543 /**
1544  * @brief
1545  * Set world autodeleting bodies mode when they're outside of render area
1546  * by the right.
1547  *
1548  * @param world The physics world.
1549  * @param autodel If @c EINA_TRUE delete bodies when they are outside render
1550  * area, otherwise, don't delete.
1551  *
1552  * @see ephysics_world_bodies_outside_top_autodel_set() for more details.
1553  * @see ephysics_world_bodies_outside_right_autodel_get().
1554  * @see ephysics_world_bodies_outside_bottom_autodel_set().
1555  * @see ephysics_world_bodies_outside_left_autodel_set().
1556  * @see ephysics_world_bodies_outside_front_autodel_set().
1557  * @see ephysics_world_bodies_outside_back_autodel_set().
1558  *
1559  * @ingroup EPhysics_World
1560  */
1561 EAPI void ephysics_world_bodies_outside_right_autodel_set(EPhysics_World *world, Eina_Bool autodel);
1562 
1563 /**
1564  * @brief
1565  * Get world autodeleting bodies mode when they're outside of render area by
1566  * the right.
1567  *
1568  * @param world The physics world.
1569  * @return @c EINA_TRUE if bodies will be deleted or @c EINA_FALSE if they
1570  * won't, or on error.
1571  *
1572  * @see ephysics_world_bodies_outside_right_autodel_set() for details.
1573  *
1574  * @ingroup EPhysics_World
1575  */
1576 EAPI Eina_Bool ephysics_world_bodies_outside_right_autodel_get(const EPhysics_World *world);
1577 
1578 /**
1579  * @brief
1580  * Set world autodeleting bodies mode when they're outside of render area
1581  * by the left.
1582  *
1583  * @param world The physics world.
1584  * @param autodel If @c EINA_TRUE delete bodies when they are outside render
1585  * area, otherwise, don't delete.
1586  *
1587  * @see ephysics_world_bodies_outside_top_autodel_set() for more details.
1588  * @see ephysics_world_bodies_outside_left_autodel_get().
1589  * @see ephysics_world_bodies_outside_bottom_autodel_set().
1590  * @see ephysics_world_bodies_outside_right_autodel_set().
1591  * @see ephysics_world_bodies_outside_front_autodel_set().
1592  * @see ephysics_world_bodies_outside_back_autodel_set().
1593  *
1594  * @ingroup EPhysics_World
1595  */
1596 EAPI void ephysics_world_bodies_outside_left_autodel_set(EPhysics_World *world, Eina_Bool autodel);
1597 
1598 /**
1599  * @brief
1600  * Get world autodeleting bodies mode when they're outside of render area by
1601  * the left.
1602  *
1603  * @param world The physics world.
1604  * @return @c EINA_TRUE if bodies will be deleted or @c EINA_FALSE if they
1605  * won't, or on error.
1606  *
1607  * @see ephysics_world_bodies_outside_left_autodel_set() for details.
1608  *
1609  * @ingroup EPhysics_World
1610  */
1611 EAPI Eina_Bool ephysics_world_bodies_outside_left_autodel_get(const EPhysics_World *world);
1612 
1613 /**
1614  * @brief
1615  * Set world autodeleting bodies mode when they're outside of render area
1616  * by the front.
1617  *
1618  * @param world The physics world.
1619  * @param autodel If @c EINA_TRUE delete bodies when they are outside render
1620  * area, otherwise, don't delete.
1621  *
1622  * @see ephysics_world_bodies_outside_top_autodel_set() for more details.
1623  * @see ephysics_world_bodies_outside_left_autodel_get().
1624  * @see ephysics_world_bodies_outside_bottom_autodel_set().
1625  * @see ephysics_world_bodies_outside_right_autodel_set().
1626  * @see ephysics_world_bodies_outside_front_autodel_set().
1627  * @see ephysics_world_bodies_outside_back_autodel_set().
1628  *
1629  * @ingroup EPhysics_World
1630  */
1631 EAPI void ephysics_world_bodies_outside_front_autodel_set(EPhysics_World *world, Eina_Bool autodel);
1632 
1633 /**
1634  * @brief
1635  * Get world autodeleting bodies mode when they're outside of render area by
1636  * the front.
1637  *
1638  * @param world The physics world.
1639  * @return @c EINA_TRUE if bodies will be deleted or @c EINA_FALSE if they
1640  * won't, or on error.
1641  *
1642  * @see ephysics_world_bodies_outside_front_autodel_set() for details.
1643  *
1644  * @ingroup EPhysics_World
1645  */
1646 EAPI Eina_Bool ephysics_world_bodies_outside_front_autodel_get(const EPhysics_World *world);
1647 
1648 /**
1649  * @brief
1650  * Set world autodeleting bodies mode when they're outside of render area
1651  * by the back.
1652  *
1653  * @param world The physics world.
1654  * @param autodel If @c EINA_TRUE delete bodies when they are outside render
1655  * area, otherwise, don't delete.
1656  *
1657  * @see ephysics_world_bodies_outside_top_autodel_set() for more details.
1658  * @see ephysics_world_bodies_outside_left_autodel_get().
1659  * @see ephysics_world_bodies_outside_bottom_autodel_set().
1660  * @see ephysics_world_bodies_outside_right_autodel_set().
1661  * @see ephysics_world_bodies_outside_front_autodel_set().
1662  * @see ephysics_world_bodies_outside_back_autodel_set().
1663  *
1664  * @ingroup EPhysics_World
1665  */
1666 EAPI void ephysics_world_bodies_outside_back_autodel_set(EPhysics_World *world, Eina_Bool autodel);
1667 
1668 /**
1669  * @brief
1670  * Get world autodeleting bodies mode when they're outside of render area by
1671  * the back.
1672  *
1673  * @param world The physics world.
1674  * @return @c EINA_TRUE if bodies will be deleted or @c EINA_FALSE if they
1675  * won't, or on error.
1676  *
1677  * @see ephysics_world_bodies_outside_back_autodel_set() for details.
1678  *
1679  * @ingroup EPhysics_World
1680  */
1681 EAPI Eina_Bool ephysics_world_bodies_outside_back_autodel_get(const EPhysics_World *world);
1682 
1683 /**
1684  * @brief
1685  * Set world simulation's fixed time step and max number of sub steps
1686  * configuration.
1687  *
1688  * It's important that time step is always less than
1689  * @p max_sub_steps * @p fixed_time_step, otherwise you are losing time.
1690  * Mathematically:
1691  *
1692  * time step < @p max_sub_steps * @p fixed_time_step;
1693  *
1694  * If you're a using a very large time step
1695  * [say, five times the size of the fixed internal time step],
1696  * then you must increase the number of max sub steps to compensate for this,
1697  * otherwise your simulation is “losing” time.
1698  *
1699  * The time step may vary. Simulation ticks are called by an animator,
1700  * so, by default, time step is @c 1/30 secs. If you're using elementary,
1701  * default FPS configuration is 60 fps, i.e. time step is @c 1/60 secs.
1702  * You can change that setting a
1703  * different time with ecore_animator_frametime_set().
1704  *
1705  * Also, keep in mind
1706  * that if you're using CPU intense calculations maybe this framerate won't
1707  * be achieved, so the time step will be bigger. You need to define
1708  * what range of frames per seconds you need to support and configure
1709  * @p max_sub_steps and @p fixed_time_step according to this.
1710  *
1711  * By decreasing the size of @p fixed_time_step, you are increasing the
1712  * “resolution” of the simulation.
1713  *
1714  * If you are finding that your objects are moving very fast and escaping
1715  * from your walls instead of colliding with them, then one way to help fix
1716  * this problem is by decreasing @p fixed_time_step. If you do this,
1717  * then you will need to increase @p max_sub_steps to ensure the equation
1718  * listed above is still satisfied.
1719  *
1720  * The issue with this is that each internal “tick” takes an amount of
1721  * computation. More of them means your CPU will be spending more time on
1722  * physics and therefore less time on other stuff. Say you want twice the
1723  * resolution, you'll need twice the @p max_sub_steps, which could chew up
1724  * twice as much CPU for the same amount of simulation time.
1725  *
1726  * When you pass @p max_sub_steps > 1, it will interpolate movement for you.
1727  * This means that if your @p fixed_time_step is 3 units, and you pass
1728  * a timeStep of 4, then it will do exactly one tick, and estimate the
1729  * remaining movement by 1/3. This saves you having to do interpolation
1730  * yourself, but keep in mind that maxSubSteps needs to be greater than 1.
1731  *
1732  * By default @p fixed_time_step is 1/60 seconds and @p max_sub_steps is 3.
1733  *
1734  * @param world The physics world.
1735  * @param fixed_time_step size of the internal simulation step, in seconds.
1736  * @param max_sub_steps maximum number of steps that simulation is allowed
1737  * to take at each simulation tick.
1738  *
1739  * @note The unit used for time is seconds.
1740  *
1741  * @see ephysics_world_simulation_get().
1742  *
1743  * @ingroup EPhysics_World
1744  */
1745 EAPI void ephysics_world_simulation_set(EPhysics_World *world, double fixed_time_step, int max_sub_steps);
1746 
1747 /**
1748  * @brief
1749  * Get world simulation's fixed time step and max number of sub steps
1750  * configuration.
1751  *
1752  * @param world The physics world.
1753  * @param fixed_time_step size of the internal simulation step, in seconds.
1754  * @param max_sub_steps maximum number of steps that simulation is allowed
1755  * to take at each simulation tick.
1756  *
1757  * @see ephysics_world_simulation_set() for details.
1758  *
1759  * @ingroup EPhysics_World
1760  */
1761 EAPI void ephysics_world_simulation_get(const EPhysics_World *world, double *fixed_time_step, int *max_sub_steps);
1762 
1763 /**
1764  * @brief
1765  * Set position of point light to be applied on the scene.
1766  *
1767  * It will perform lighting calculations on the evas map applied on evas
1768  * objects associated with all the bodies to have light applied over.
1769  *
1770  * This is used to apply lighting calculations (from a single light source)
1771  * to a given object. The R, G and B values of each vertex will be modified to
1772  * reflect the lighting based on the lixth point coordinates, the light color
1773  * and the ambient color, and at what angle the map is facing the light source.
1774  * A surface should have its points be declared in a clockwise fashion if the
1775  * face is "facing" towards you (as opposed to away from you) as faces have a
1776  * "logical" side for lighting.
1777  *
1778  * More details can be found on evas_map_util_3d_lighting() documentation,
1779  * since this function is used internally by EPhysics.
1780  *
1781  * There are two ways of setting a body to receive lighting. One is to simple
1782  * set all the bodies to be affected, with
1783  * @ref ephysics_world_light_all_bodies_set(). The other, is to set each body
1784  * individually, with @ref ephysics_body_light_set().
1785  *
1786  * By default, point light is set to position (0, 0, -200) and has white color
1787  * (r=255, g=255, b=255). The ambient color is black (r=0, g=0, b=0).
1788  * But no body will be affected. No change will be visible until
1789  * some bodies are set to be enlightened.
1790  *
1791  * @param world The physics world.
1792  * @param lx X coordinate in space of light point
1793  * @param ly Y coordinate in space of light point
1794  * @param lz Z coordinate in space of light point
1795  *
1796  * @see ephysics_world_point_light_position_get().
1797  * @see ephysics_world_point_light_color_set().
1798  * @see ephysics_world_ambient_light_color_set().
1799  *
1800  * @ingroup EPhysics_World
1801  */
1802 EAPI void ephysics_world_point_light_position_set(EPhysics_World *world, Evas_Coord lx, Evas_Coord ly, Evas_Coord lz);
1803 
1804 /**
1805  * @brief
1806  * Set color of point light to be applied on the scene.
1807  *
1808  * By default color of point light is r=255, g=255, b=255.
1809  *
1810  * @param world The physics world.
1811  * @param lr light red value (0 - 255)
1812  * @param lg light green value (0 - 255)
1813  * @param lb light blue value (0 - 255)
1814  *
1815  * @see ephysics_world_point_light_position_set() for more details.
1816  * @see ephysics_world_point_light_color_get().
1817  *
1818  * @ingroup EPhysics_World
1819  */
1820 EAPI void ephysics_world_point_light_color_set(EPhysics_World *world, int lr, int lg, int lb);
1821 
1822 /**
1823  * @brief
1824  * Set color of the ambient light to be applied on the scene.
1825  *
1826  * By default, ambient color is set to r=0, g=0, b=0.
1827  *
1828  * @param world The physics world.
1829  * @param ar ambient color red value (0 - 255)
1830  * @param ag ambient color green value (0 - 255)
1831  * @param ab ambient color blue value (0 - 255)
1832  *
1833  * @see ephysics_world_point_light_position_set() for more details.
1834  * @see ephysics_world_ambient_light_color_get().
1835  *
1836  * @ingroup EPhysics_World
1837  */
1838 EAPI void ephysics_world_ambient_light_color_set(EPhysics_World *world, int ar, int ag, int ab);
1839 
1840 /**
1841  * @brief
1842  * Get position of point light applied on the scene.
1843  *
1844  * @param world The physics world.
1845  * @param lx X coordinate in space of light point
1846  * @param ly Y coordinate in space of light point
1847  * @param lz Z coordinate in space of light point
1848  *
1849  * @see ephysics_world_point_light_position_set() for details.
1850  *
1851  * @ingroup EPhysics_World
1852  */
1853 EAPI void ephysics_world_point_light_position_get(const EPhysics_World *world, Evas_Coord *lx, Evas_Coord *ly, Evas_Coord *lz);
1854 
1855 /**
1856  * @brief
1857  * Get color of point light applied on the scene.
1858  *
1859  * By default color of point light is r=255, g=255, b=255.
1860  *
1861  * @param world The physics world.
1862  * @param lr light red value (0 - 255)
1863  * @param lg light green value (0 - 255)
1864  * @param lb light blue value (0 - 255)
1865  *
1866  * @see ephysics_world_point_light_position_set() for more details.
1867  * @see ephysics_world_point_light_color_set().
1868  *
1869  * @ingroup EPhysics_World
1870  */
1871 EAPI void ephysics_world_point_light_color_get(const EPhysics_World *world, int *lr, int *lg, int *lb);
1872 
1873 /**
1874  * @brief
1875  * Set color of the ambient light to be applied on the scene.
1876  *
1877  * By default, ambient color is set to r=0, g=0, b=0.
1878  *
1879  * @param world The physics world.
1880  * @param ar ambient color red value (0 - 255)
1881  * @param ag ambient color green value (0 - 255)
1882  * @param ab ambient color blue value (0 - 255)
1883  *
1884  * @see ephysics_world_point_light_position_set() for more details.
1885  * @see ephysics_world_ambient_light_color_set().
1886  *
1887  * @ingroup EPhysics_World
1888  */
1889 EAPI void ephysics_world_ambient_light_color_get(const EPhysics_World *world, int *ar, int *ag, int *ab);
1890 
1891 /**
1892  * @brief
1893  * Set if light should be applied over all the bodies.
1894  *
1895  * @param world The physics world.
1896  * @param enable @c EINA_TRUE if light should be obligatory applied over
1897  * all the bodies, or @c EINA_FALSE if it only should be applied on bodies with
1898  * light property set.
1899  *
1900  * @see ephysics_world_point_light_position_set() for more details.
1901  * @see ephysics_world_light_all_bodies_get().
1902  *
1903  * @ingroup EPhysics_World
1904  */
1905 EAPI void ephysics_world_light_all_bodies_set(EPhysics_World *world, Eina_Bool enable);
1906 
1907 /**
1908  * @brief
1909  * Get light setting regarding being applied over all the bodies.
1910  *
1911  * @param world The physics world.
1912  * @return @c EINA_TRUE if light will be obligatory applied over all the bodies,
1913  * or @c EINA_FALSE if it only will be applied on bodies with light property
1914  * set, or on error.
1915  *
1916  * @see ephysics_world_light_all_bodies_set() for details.
1917  *
1918  * @ingroup EPhysics_World
1919  */
1920 EAPI Eina_Bool ephysics_world_light_all_bodies_get(const EPhysics_World *world);
1921 
1922 /**
1923  * @brief
1924  * Enable / disable stacking based on bodies z coordinates.
1925  *
1926  * Evas objects associated to bodies will be restacked when it's enabled.
1927  * So if a body A has coordinates x = 10, y = 10, z = 8 and a body B
1928  * has coordinates x = 10, y = 10, z = 10, the evas object associated to B
1929  * will be displayed below the evas object associated to A.
1930  *
1931  * Evas objects will be restacked at each simulation tick. It's enabled by
1932  * default, and disabling it can lead to wrong scenarios when movement
1933  * on Z axis is enabled or when cloths are used.
1934  *
1935  * But disabling it can save performance, so if you won't face these
1936  * scenarios, it safe to disable it, since no evas object will be moved to
1937  * be below or above others.
1938  *
1939  * @param world The physics world.
1940  * @param enabled If @c EINA_TRUE, stacking based on Z coordinates will be
1941  * enabled, otherwise it will be disabled.
1942  *
1943  * @see ephysics_world_stack_enable_get()
1944  * @see ephysics_body_evas_object_set()
1945  *
1946  * @ingroup EPhysics_World
1947  */
1948 EAPI void ephysics_world_stack_enable_set(EPhysics_World *world, Eina_Bool enabled);
1949 
1950 /**
1951  * @brief
1952  * Get stacking status of world.
1953  *
1954  * Stacking based on bodies z coordinates can be enabled or disabled.
1955  *
1956  * @param world The physics world.
1957  * @return @c EINA_TRUE if it's running, or @c EINA_FALSE if it's paused or on
1958  * error.
1959  *
1960  * @see ephysics_world_stack_enable_set() for more details.
1961  *
1962  * @ingroup EPhysics_World
1963  */
1964 EAPI Eina_Bool ephysics_world_stack_enable_get(const EPhysics_World *world);
1965 
1966 /**
1967  * @}
1968  */
1969 
1970 /**
1971  * @defgroup EPhysics_Body EPhysics Body
1972  * @ingroup EPhysics
1973  *
1974  * @{
1975  *
1976  * A body is a representation of an object inside a physics world.
1977  *
1978  * Bodies can have different shapes that can be created with:
1979  * @li @ref ephysics_body_cylinder_add();
1980  * @li @ref ephysics_body_box_add();
1981  * @li or @ref ephysics_body_shape_add().
1982  *
1983  * Also they can be soft bodies, that won't act as rigid bodies. They will
1984  * deform its shape under certain circumstances, like under collisions.
1985  * Soft bodies can be created with:
1986  * @li @ref ephysics_body_soft_cylinder_add();
1987  * @li @ref ephysics_body_soft_box_add();
1988  *
1989  * They can collide and have customizable properties, like:
1990  * @li mass, set with @ref ephysics_body_mass_set();
1991  * @li coefficient of restitution, set with
1992  * @ref ephysics_body_restitution_set();
1993  * @li and friction, set with @ref ephysics_body_friction_set().
1994  *
1995  * Bodies can have its position and size directly set by:
1996  * @ref ephysics_body_move();
1997  * @ref ephysics_body_resize();
1998  * @ref ephysics_body_geometry_set().
1999  *
2000  * Their rotation can be set directly with @ref ephysics_body_rotation_set().
2001  *
2002  * Also, they can have an associated evas object, done with
2003  * @ref ephysics_body_evas_object_set() function, being responsible for
2004  * updating its position and rotation, or letting a user callback be set
2005  * for this task with @ref ephysics_body_event_callback_add().
2006  *
2007  * Bodies can have velocity set with @ref ephysics_body_linear_velocity_set()
2008  * and @ref ephysics_body_angular_velocity_set().
2009  *
2010  * Also, bodies can have forces and impulses applied over them, and they will
2011  * be affected by gravity.
2012  *
2013  * Forces will be acting while they're set, changing bodies velocity over time.
2014  * Impulses are applied only once, modifying bodies velocity immediately to the
2015  * new value.
2016  *
2017  * Forces can be managed with:
2018  * @li @ref ephysics_body_central_force_apply();
2019  * @li @ref ephysics_body_torque_apply().
2020  * @li @ref ephysics_body_force_apply();
2021  * @li @ref ephysics_body_forces_clear();
2022  *
2023  * Impulses can be applied with:
2024  * @li @ref ephysics_body_central_impulse_apply();
2025  * @li @ref ephysics_body_torque_impulse_apply().
2026  * @li @ref ephysics_body_impulse_apply();
2027  *
2028  * Bodies can be removed from the world being directly deleted with
2029  * @ref ephysics_body_del() or when the world is deleted, case when all the
2030  * bodies belonging to it will be deleted as well. Evas objects associated
2031  * to these bodies won't be affected in any way, but they will stop being
2032  * moved or rotated.
2033  */
2034 
2035 /**
2036  * @def EPHYSICS_BODY_MASS_STATIC
2037  * @brief Mass amount used to makes a body static.
2038  *
2039  * Body will be set with infinite mass, so it will be immovable.
2040  *
2041  * @see ephysics_body_mass_set() for details.
2042  */
2043 #define EPHYSICS_BODY_MASS_STATIC (0.0)
2044 
2045 /**
2046  * @def EPHYSICS_BODY_DENSITY_WOOD
2047  * @brief Density of wood in kg / m ^ 3.
2048  *
2049  * It can be set to a body with @ref ephysics_body_density_set().
2050  */
2051 #define EPHYSICS_BODY_DENSITY_WOOD (680.0)
2052 /**
2053  * @def EPHYSICS_BODY_DENSITY_IRON
2054  * @brief Density of iron in kg / m ^ 3.
2055  *
2056  * It can be set to a body with @ref ephysics_body_density_set().
2057  */
2058 #define EPHYSICS_BODY_DENSITY_IRON (7400.0)
2059 /**
2060  * @def EPHYSICS_BODY_DENSITY_CONCRETE
2061  * @brief Density of concrete in kg / m ^ 3.
2062  *
2063  * It can be set to a body with @ref ephysics_body_density_set().
2064  */
2065 #define EPHYSICS_BODY_DENSITY_CONCRETE (2300.0)
2066 /**
2067  * @def EPHYSICS_BODY_DENSITY_RUBBER
2068  * @brief Density of rubber in kg / m ^ 3.
2069  *
2070  * It can be set to a body with @ref ephysics_body_density_set().
2071  */
2072 #define EPHYSICS_BODY_DENSITY_RUBBER (920.0)
2073 /**
2074  * @def EPHYSICS_BODY_DENSITY_POLYSTYRENE
2075  * @brief Density of polystyrene in kg / m ^ 3.
2076  *
2077  * It can be set to a body with @ref ephysics_body_density_set().
2078  */
2079 #define EPHYSICS_BODY_DENSITY_POLYSTYRENE (80.0)
2080 /**
2081  * @def EPHYSICS_BODY_DENSITY_PLASTIC
2082  * @brief Density of plastic in kg / m ^ 3.
2083  *
2084  * It can be set to a body with @ref ephysics_body_density_set().
2085  */
2086 #define EPHYSICS_BODY_DENSITY_PLASTIC (1300.0)
2087 
2088 /**
2089  * @def EPHYSICS_BODY_FRICTION_WOOD
2090  * @brief Friction coefficient of wood.
2091  *
2092  * It can be set to a body with @ref ephysics_body_friction_set().
2093  */
2094 #define EPHYSICS_BODY_FRICTION_WOOD (0.4)
2095 /**
2096  * @def EPHYSICS_BODY_FRICTION_IRON
2097  * @brief Friction coefficient of iron.
2098  *
2099  * It can be set to a body with @ref ephysics_body_friction_set().
2100  */
2101 #define EPHYSICS_BODY_FRICTION_IRON (0.8)
2102 /**
2103  * @def EPHYSICS_BODY_FRICTION_CONCRETE
2104  * @brief Friction coefficient of concrete.
2105  *
2106  * It can be set to a body with @ref ephysics_body_friction_set().
2107  */
2108 #define EPHYSICS_BODY_FRICTION_CONCRETE (0.65)
2109 /**
2110  * @def EPHYSICS_BODY_FRICTION_RUBBER
2111  * @brief Friction coefficient of rubber.
2112  *
2113  * It can be set to a body with @ref ephysics_body_friction_set().
2114  */
2115 #define EPHYSICS_BODY_FRICTION_RUBBER (0.75)
2116 /**
2117  * @def EPHYSICS_BODY_FRICTION_POLYSTYRENE
2118  * @brief Friction coefficient of polystyrene.
2119  *
2120  * It can be set to a body with @ref ephysics_body_friction_set().
2121  */
2122 #define EPHYSICS_BODY_FRICTION_POLYSTYRENE (0.5)
2123 /**
2124  * @def EPHYSICS_BODY_FRICTION_PLASTIC
2125  * @brief Friction coefficient of plastic.
2126  *
2127  * It can be set to a body with @ref ephysics_body_friction_set().
2128  */
2129 #define EPHYSICS_BODY_FRICTION_PLASTIC (0.35)
2130 
2131 /**
2132  * @def EPHYSICS_BODY_RESTITUTION_WOOD
2133  * @brief Restitution coefficient of wood.
2134  *
2135  * It can be set to a body with @ref ephysics_body_restitution_set().
2136  */
2137 #define EPHYSICS_BODY_RESTITUTION_WOOD (0.7)
2138 /**
2139  * @def EPHYSICS_BODY_RESTITUTION_IRON
2140  * @brief Restitution coefficient of iron.
2141  *
2142  * It can be set to a body with @ref ephysics_body_restitution_set().
2143  */
2144 #define EPHYSICS_BODY_RESTITUTION_IRON (0.85)
2145 /**
2146  * @def EPHYSICS_BODY_RESTITUTION_CONCRETE
2147  * @brief Restitution coefficient of concrete.
2148  *
2149  * It can be set to a body with @ref ephysics_body_restitution_set().
2150  */
2151 #define EPHYSICS_BODY_RESTITUTION_CONCRETE (0.75)
2152 /**
2153  * @def EPHYSICS_BODY_RESTITUTION_RUBBER
2154  * @brief Restitution coefficient of rubber.
2155  *
2156  * It can be set to a body with @ref ephysics_body_restitution_set().
2157  */
2158 #define EPHYSICS_BODY_RESTITUTION_RUBBER (0.3)
2159 /**
2160  * @def EPHYSICS_BODY_RESTITUTION_POLYSTYRENE
2161  * @brief Restitution coefficient of polystyrene.
2162  *
2163  * It can be set to a body with @ref ephysics_body_restitution_set().
2164  */
2165 #define EPHYSICS_BODY_RESTITUTION_POLYSTYRENE (0.5)
2166 /**
2167  * @def EPHYSICS_BODY_RESTITUTION_PLASTIC
2168  * @brief Restitution coefficient of plastic.
2169  *
2170  * It can be set to a body with @ref ephysics_body_restitution_set().
2171  */
2172 #define EPHYSICS_BODY_RESTITUTION_PLASTIC (0.6)
2173 
2174 /**
2175  * @enum _EPhysics_Body_Cloth_Anchor_Side
2176  * @typedef EPhysics_Body_Cloth_Anchor_Side
2177  *
2178  * Identifier of cloth anchor sides.
2179  *
2180  * @see ephysics_body_cloth_anchor_full_add()
2181  *
2182  * @ingroup EPhysics_Body
2183  */
2184 typedef enum _EPhysics_Body_Cloth_Anchor_Side
2185 {
2186   EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_LEFT,
2187   EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_RIGHT,
2188   EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_TOP,
2189   EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_BOTTOM,
2190   EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_LAST,
2191 } EPhysics_Body_Cloth_Anchor_Side;
2192 
2193 /**
2194  * @enum _EPhysics_Body_Face
2195  * @typedef EPhysics_Body_Face
2196  *
2197  * Define in which body's face the evas object should be set.
2198  *
2199  * @see ephysics_body_face_evas_object_set()
2200  * @see ephysics_body_face_evas_object_unset()
2201  * @see ephysics_body_face_evas_object_get()
2202  *
2203  * @ingroup EPhysics_Body
2204  */
2205 typedef enum _EPhysics_Body_Face
2206 {
2207   EPHYSICS_BODY_BOX_FACE_MIDDLE_FRONT,
2208   EPHYSICS_BODY_BOX_FACE_MIDDLE_BACK,
2209   EPHYSICS_BODY_BOX_FACE_FRONT,
2210   EPHYSICS_BODY_BOX_FACE_BACK,
2211   EPHYSICS_BODY_BOX_FACE_LEFT,
2212   EPHYSICS_BODY_BOX_FACE_RIGHT,
2213   EPHYSICS_BODY_BOX_FACE_TOP,
2214   EPHYSICS_BODY_BOX_FACE_BOTTOM,
2215 
2216   EPHYSICS_BODY_CLOTH_FACE_FRONT,
2217   EPHYSICS_BODY_CLOTH_FACE_BACK,
2218 
2219   EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_FRONT,
2220   EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_BACK,
2221   EPHYSICS_BODY_CYLINDER_FACE_FRONT,
2222   EPHYSICS_BODY_CYLINDER_FACE_BACK,
2223   EPHYSICS_BODY_CYLINDER_FACE_CURVED,
2224 
2225   EPHYSICS_BODY_SPHERE_FACE_FRONT,
2226   EPHYSICS_BODY_SPHERE_FACE_BACK,
2227 
2228   EPHYSICS_BODY_FACE_LAST,
2229 } EPhysics_Body_Face;
2230 
2231 /**
2232  * @typedef EPhysics_Body_Collision
2233  *
2234  * Body collision wraps collision informations.
2235  *
2236  * EPhysics_Body_Collision is used on EPHYSICS_CALLBACK_BODY_COLLISION callback
2237  * and is mostly interested to hold informations like:
2238  * @li contact_body - the body which the collision occurred against;
2239  * @li position - points the position where the collision happened;
2240  *
2241  * @see ephysics_body_collision_position_get()
2242  * @see ephysics_body_collision_contact_body_get()
2243  * @see EPHYSICS_CALLBACK_BODY_COLLISION and @ref
2244  * ephysics_body_event_callback_add() for collision callback.
2245  * @ingroup EPhysics_Body
2246  */
2247 typedef struct _EPhysics_Body_Collision EPhysics_Body_Collision;
2248 
2249 /**
2250  * @enum _EPhysics_Callback_Body_Type
2251  * @typedef EPhysics_Callback_Body_Type
2252  *
2253  * Identifier of callbacks to be set for EPhysics bodies.
2254  *
2255  * @see ephysics_body_event_callback_add()
2256  * @see ephysics_body_event_callback_del()
2257  * @see ephysics_body_event_callback_del_full()
2258  *
2259  * @ingroup EPhysics_Body
2260  */
2261 typedef enum _EPhysics_Callback_Body_Type
2262 {
2263    EPHYSICS_CALLBACK_BODY_UPDATE, /**< Body being updated */
2264    EPHYSICS_CALLBACK_BODY_COLLISION, /**< Body collided with other body */
2265    EPHYSICS_CALLBACK_BODY_DEL, /**< Body being deleted (called before free) */
2266    EPHYSICS_CALLBACK_BODY_STOPPED, /**< Body is not moving any more */
2267    EPHYSICS_CALLBACK_BODY_LAST, /**< kept as sentinel, not really an event */
2268 } EPhysics_Callback_Body_Type; /**< The types of events triggering a callback */
2269 
2270 /**
2271  * @enum _EPhysics_Body_Material
2272  * @typedef EPhysics_Body_Material
2273  *
2274  * EPhysics bodies materials. Each material has specific properties to be
2275  * applied on the body, as density, friction and restitution.
2276  *
2277  * @see ephysics_body_material_set() for details.
2278  *
2279  * @ingroup EPhysics_Body
2280  */
2281 typedef enum _EPhysics_Body_Material
2282 {
2283    EPHYSICS_BODY_MATERIAL_CUSTOM, /**< Custom properties set by the user */
2284    EPHYSICS_BODY_MATERIAL_CONCRETE, /**< Density:2300,Fric:0.65,Rest:0.75 */
2285    EPHYSICS_BODY_MATERIAL_IRON, /**< Density:7400,Fric:0.8,Rest:0.85 */
2286    EPHYSICS_BODY_MATERIAL_PLASTIC, /**< Density:1300,Fric:0.35,Rest:0.6 */
2287    EPHYSICS_BODY_MATERIAL_POLYSTYRENE, /**< Density:80,Fric:0.5,Rest:0.5*/
2288    EPHYSICS_BODY_MATERIAL_RUBBER, /**< Density:920,Fric:0.75,Rest:0.3*/
2289    EPHYSICS_BODY_MATERIAL_WOOD, /**< Density:680,Fric:0.4,Rest:0.7*/
2290    EPHYSICS_BODY_MATERIAL_LAST, /**< kept as sentinel, not really a material */
2291 } EPhysics_Body_Material; /**< The types of materials to be set on a body */
2292 
2293 /**
2294  * @typedef EPhysics_Body_Event_Cb
2295  *
2296  * EPhysics body event callback function signature.
2297  *
2298  * Callbacks can be registered for events like body updating or deleting.
2299  *
2300  * @param data User data that will be set when registering the callback.
2301  * @param body Physics body.
2302  * @param event_info Data specific to a kind of event. Some types of events
2303  * don't have @p event_info.
2304  *
2305  * @see ephysics_body_event_callback_add() for more info.
2306  *
2307  * @ingroup EPhysics_Body
2308  */
2309 typedef void (*EPhysics_Body_Event_Cb)(void *data, EPhysics_Body *body, void *event_info);
2310 
2311 /**
2312  * @brief
2313  * Set the soft body hardness percentage.
2314  *
2315  * The hardness percentage will define how the soft body is supposed to deform,
2316  * its default is set to 100%. The soft body mass will also interfere on soft
2317  * body deformation, so bare in mind that the bodies mass must also be changed
2318  * to have different deformation results.
2319  *
2320  * Valid values vary from 0 to 100.
2321  *
2322  * @param body The body to be set.
2323  * @param hardness The percentage of deformation.
2324  *
2325  * @see ephysics_body_soft_body_hardness_get()
2326  * @see ephysics_body_mass_set() form body mass changing.
2327  *
2328  * @ingroup EPhysics_Body
2329  */
2330 EAPI void ephysics_body_soft_body_hardness_set(EPhysics_Body *body, double hardness);
2331 
2332 /**
2333  * @brief
2334  * Get the soft body hardness percentage.
2335  *
2336  * @param body The body of interest.
2337  * @return The deformation percentage.
2338  *
2339  * @see ephysics_body_soft_body_hardness_set()
2340  *
2341  * @ingroup EPhysics_Body
2342  */
2343 EAPI double ephysics_body_soft_body_hardness_get(const EPhysics_Body *body);
2344 
2345 /**
2346  * @brief
2347  * Set the soft body anchor hardness percentage.
2348  *
2349  * The anchor hardness percentage(together with general hardness settings
2350  * set with ephysics_body_soft_body_hardness_set()) will define how the soft
2351  * body is supposed to deform.
2352  *
2353  * By default EPhysics will calculate the anchor hardness depending on the
2354  * general hardness settings, by default it`s set to 70% of general hardness on
2355  * soft body and a fixed 80% for cloths.
2356  *
2357  * Anchor hardness will result on a contrary force to impulse and velocities
2358  * applied to soft bodies. So it implies on force reduction.
2359  *
2360  * @note Since it`s a percentage value @p hardness will range from 0 - 100.
2361  *
2362  * @param body The body to be set.
2363  * @param hardness The hardness to be set to @p body.
2364  *
2365  * @see ephysics_body_soft_body_hardness_set() for general hardness.
2366  * @see ephysics_body_soft_body_anchor_hardness_get().
2367  *
2368  * @ingroup EPhysics_Body
2369  */
2370 EAPI void ephysics_body_soft_body_anchor_hardness_set(EPhysics_Body *body, double hardness);
2371 
2372 /**
2373  * @brief
2374  * Get the soft body anchor hardnees percentage.
2375  *
2376  * @param body The body to get the anchor hardness percentage from.
2377  * @return The anchor hardness percentage on success -1 on failure.
2378  *
2379  * @see ephysics_body_soft_body_anchor_hardness_set().
2380  *
2381  * @ingroup EPhysics_Body
2382  */
2383 EAPI double ephysics_body_soft_body_anchor_hardness_get(EPhysics_Body *body);
2384 
2385 /**
2386  * @brief
2387  * Set the drag coefficient of a soft body.
2388  *
2389  * Drag coefficient is a dimensionless quantity used to quantify an objects drag
2390  * or resistance in the environment - like air or water resistance. It is used in
2391  * the drag equation, where a lower drag coefficient indicates the object will
2392  * have less aerodynamic or hydrodynamic drag.
2393  *
2394  * The drag coefficient is defined as:
2395  *
2396  * cd = 2Fd / (pv ^ 2)A
2397  *
2398  * Where:
2399  *
2400  * - @c Fd is the drag force, which is by definition the force component in the
2401  * direction of the flow velocity;
2402  * - @c p is the mass density;
2403  * - @c v is the speed;
2404  * - @c A is the reference area;
2405  *
2406  * The reference area depends on what type of drag coefficient is being measured.
2407  *
2408  * @note default value set to 0.
2409  *
2410  * @param body The body to be set.
2411  * @param coefficient  The drag coefficient.
2412  *
2413  * @see ephysics_body_soft_body_drag_coefficient_get().
2414  *
2415  * @ingroup EPhysics_Body
2416  */
2417 EAPI void ephysics_body_soft_body_drag_coefficient_set(EPhysics_Body *body, double coefficient);
2418 
2419 /**
2420  * @brief
2421  * Get the drag coefficient of a soft body.
2422  *
2423  * @param body The body to get the drag coefficient from.
2424  * @return The drag coefficient set to @p body on success, -1 on failure.
2425  *
2426  * @see ephysics_body_soft_body_drag_coefficient_set().
2427  *
2428  * @ingroup EPhysics_Body
2429  */
2430 EAPI double ephysics_body_soft_body_drag_coefficient_get(const EPhysics_Body *body);
2431 
2432 /**
2433  * @brief
2434  * Set the soft body dragging status.
2435  *
2436  * While dragging a soft body the user may want to freeze a specific trimesh
2437  * face, after calling this function EPhysics will do freeze the @p triangle
2438  * until it gets a call to unset it with
2439  * ephysics_body_soft_body_dragging_unset().
2440  *
2441  * @note Freezing a specific trimesh face means no forces are applied to it, no
2442  * gravity enforced, that's @p triangle will have no mass until it dragging
2443  * gets unset.
2444  *
2445  * @param body The body of interest.
2446  * @param triangle The triangle to freeze.
2447  *
2448  * @see ephysics_body_soft_body_dragging_unset().
2449  * @see ephysics_body_soft_body_triangle_index_get().
2450  *
2451  * @ingroup EPhysics_Body
2452  */
2453 EAPI void ephysics_body_soft_body_dragging_set(EPhysics_Body *body, int triangle);
2454 
2455 /**
2456  * @brief
2457  * Unset the soft body dragging status.
2458  *
2459  * This function will tell EPhysics to not freeze - the previously dragging
2460  * triangle set - any more.
2461  *
2462  * @param body The body to unset the dragging status.
2463  *
2464  * @see ephysics_body_soft_body_dragging_set() for dragging details.
2465  *
2466  * @ingroup EPhysics_Body
2467  */
2468 EAPI void ephysics_body_soft_body_dragging_unset(EPhysics_Body *body);
2469 
2470 /**
2471  * @brief
2472  * Get the triangle index of a soft body in @p x and @p y.
2473  *
2474  * Given a point in @p x and @p y a ray cast is performed and if a triangle is
2475  * found its index is returned.
2476  *
2477  * @param body The body to get the triangle index from.
2478  * @param x The x coord.
2479  * @param y The y coord.
2480  * @return -1 If no triangle is found, a triangle index otherwise.
2481  *
2482  * @see ephysics_body_soft_body_triangle_move().
2483  *
2484  * @ingroup EPhysics_Body
2485  */
2486 EAPI int ephysics_body_soft_body_triangle_index_get(EPhysics_Body *body, Evas_Coord x, Evas_Coord y);
2487 
2488 /**
2489  * @brief
2490  * Get the slice index of a soft body based on its slice`s Evas Object.
2491  *
2492  * Registering a mouse event callback on an associated evas object one can get
2493  * the clicked slice evas object. With that pointer the user can get the slice
2494  * index based on its related evas object.
2495  *
2496  * @param body The body to get the slice index from.
2497  * @param slice The slice evas object.
2498  * @return The slice index on success, -1 otherwise.
2499  *
2500  * @see ephysics_body_soft_body_triangle_index_get().
2501  *
2502  * @ingroup EPhysics_Body
2503  */
2504 EAPI int ephysics_body_soft_body_slice_index_get(EPhysics_Body *body, Evas_Object *slice);
2505 
2506 /**
2507  * @brief
2508  * Add a soft sphere.
2509  *
2510  * Add a new soft 3d sphere to the simulation. The @p granularity defines how
2511  * many triangles are to be added.
2512  *
2513  * @note if no @p granularity is informed(i.e @p granularity = 0) the soft body
2514  * will be created with a triangle mesh of 100.
2515  *
2516  * @param world The world the new soft sphere is to be added.
2517  * @param granularity How many triangles the soft body triangle mesh must have.
2518  * @return a new body or @c NULL on errors.
2519  *
2520  * @see ephysics_body_del().
2521  * @see ephysics_body_evas_object_set().
2522  * @see ephysics_body_face_evas_object_set().
2523  *
2524  * @ingroup EPhysics_Body
2525  */
2526 EAPI EPhysics_Body *ephysics_body_soft_sphere_add(EPhysics_World *world, int granularity);
2527 
2528 /**
2529  * @brief
2530  * Get a list of triangles indexes inside an area.
2531  *
2532  * Get a list of triangles indexes given an area defined by @p x, @p y, @p z, @p
2533  * w, @p h and @p d, the z axis components are represented by @p x and @p d
2534  * where all triangles between @p z and @p d are considered, that's triangles
2535  * with their z component greater than @p z and smaller than @p d.
2536  *
2537  * @note EPhysics will not free the returned list, remember to do so.
2538  *
2539  * @param body The body to get triangles indexes from.
2540  * @param x The x component.
2541  * @param y The y component.
2542  * @param z The z component.
2543  * @param w The w component.
2544  * @param h The h component.
2545  * @param d The d component.
2546  *
2547  * @return NULL on errors or no triangles found, a list of triangles indexes
2548  * otherwhise.
2549  *
2550  * @see ephysics_body_soft_body_triangle_index_get().
2551  * @see ephysics_body_soft_body_slice_index_get().
2552  *
2553  * @ingroup EPhysics_Body
2554  */
2555 EAPI Eina_List *ephysics_body_soft_body_triangles_inside_get(const EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d);
2556 
2557 /**
2558  * @brief
2559  * Apply an impulse on a given soft body triangle.
2560  *
2561  * The impulse is equal to the change of momentum of the body.
2562  * Impulse is the product of the force over the time this force is applied. In
2563  * ephysics case, it would be the time of a tick, so it behaves just summing
2564  * current linear velocity to impulse per mass(per triangle mass).
2565  *
2566  * When a impulse is applied over a body, it will have its velocity changed. This
2567  * impulse will be applied on body's specified triangle @p idx, so it won't
2568  * imply in rotating the body.
2569  *
2570  * @note Impulse is measured in kg * p / s.
2571  *
2572  * @param body The body to apply impulse to.
2573  * @param idx The soft body triangle index.
2574  * @param x The axis @p x component of impulse.
2575  * @param y The axis @p y component of impulse
2576  * @param z The axis @p z component of impulse
2577  *
2578  * @see ephysics_body_soft_body_triangle_index_get().
2579  *
2580  * @ingroup EPhysics_Body
2581  */
2582 EAPI void ephysics_body_soft_body_triangle_impulse_apply(EPhysics_Body * body, int idx, double x, double y, double z);
2583 
2584 /**
2585  * @brief
2586  * Apply impulse in a list of triangles.
2587  *
2588  * Apply impulse in a list of triangles all at once considering the same impulse
2589  * values on @p x, @p y and @p z.
2590  *
2591  * @param body The body to apply impulse.
2592  * @param triangles A list of triangles indexes.
2593  * @param x The axis @p x component of impulse.
2594  * @param y The axis @p y component of impulse.
2595  * @param z The axis @p z component of impulse.
2596  *
2597  * @see ephysics_body_soft_body_triangle_impulse_apply() to see about impulse
2598  * applying on soft bodies.
2599  * @see ephysics_body_soft_body_triangles_inside_get().
2600  *
2601  * @ingroup EPhysics_Body
2602  */
2603 EAPI void ephysics_body_soft_body_triangle_list_impulse_apply(EPhysics_Body *body, Eina_List *triangles, double x, double y, double z);
2604 
2605 /**
2606  * @brief
2607  * Set the soft body number of position iterations.
2608  *
2609  * Both soft body and cloth can have its number of position iterations changed.
2610  * The number of position iterations will change how many time the physics
2611  * engine
2612  * will iterate the position solver, a greater value will change deformation
2613  * behaves and how hard the soft body looks like. The greater position
2614  * iterations the harder the soft body will be.
2615  *
2616  * @note For soft bodies the default value is set to 1, and for cloth it's set
2617  * to the number of rows / 5;
2618  *
2619  * @param body The body to be set.
2620  * @param iterations The number of iterations.
2621  *
2622  * @see ephysics_body_cloth_add() for more informations about cloth.
2623  * @see ephysics_body_soft_body_position_iterations_get().
2624  *
2625  * @ingroup EPhysics_Body
2626  */
2627 EAPI void ephysics_body_soft_body_position_iterations_set(EPhysics_Body *body, int iterations);
2628 
2629 /**
2630  * @brief
2631  * Get the soft body number of position iterations.
2632  *
2633  * @param body The body to get the number os position iterations from.
2634  * @return The number of position solver iterations of a soft @p body.
2635  *
2636  * @see ephysics_body_soft_body_position_iterations_set().
2637  *
2638  * @ingroup EPhysics_Body
2639  */
2640 EAPI int ephysics_body_soft_body_position_iterations_get(EPhysics_Body *body);
2641 
2642 /**
2643  * @brief
2644  * Move a body's triangle.
2645  *
2646  * Move the triangle of @p idx of @p body to @p x, @p y and @p z.
2647  *
2648  * @param body The body of interest.
2649  * @param idx The triangle index.
2650  * @param x The x coordinate.
2651  * @param y The y coordinate.
2652  * @param z The z coordinate.
2653  *
2654  * @see ephysics_body_soft_body_triangle_index_get().
2655  *
2656  * @ingroup EPhysics_Body
2657  */
2658 EAPI void ephysics_body_soft_body_triangle_move(EPhysics_Body *body, int idx, Evas_Coord x, Evas_Coord y, Evas_Coord z);
2659 
2660 /**
2661  * @brief
2662  * Add new bending constraints to some @p body.
2663  *
2664  * Bending constraints define how a soft body is to be deformeable. In fact a
2665  * bending constraints represents a link between a soft body mesh triangle and
2666  * other. The hardness property is used to define the bending constraint of
2667  * those new links.
2668  *
2669  * By default EPhysics create a new soft body or cloth with a single bending
2670  * constraint.
2671  *
2672  * @param body The body to add bending constraints to.
2673  * @param number The number of bending constraints to be added, it must be
2674  * greater than 0.
2675  *
2676  * @see ephysics_body_soft_body_hardness_set().
2677  *
2678  * @ingroup EPhysics_Body
2679  */
2680 EAPI void ephysics_body_soft_body_bending_constraints_add(EPhysics_Body *body, int number);
2681 
2682 /**
2683  * @brief
2684  * Create a new sphere physics body.
2685  *
2686  * Its collision shape will be a sphere of diameter 1. To change its size @ref
2687  * ephysics_body_geometry_set(), @p ephysics_body_resize() should be used.
2688  *
2689  * Any evas object can be associated to it with @p
2690  * ephysics_body_evas_object_set(), and it will collid as a sphere(even if
2691  * you`ve associated an evas rectangle).
2692  *
2693  * For deformable sphere use @p ephysics_body_soft_sphere_add() instead.
2694  *
2695  * @param world The world this body will belong to.
2696  * @return a new body or @c NULL, on errors.
2697  *
2698  * @see ephysics_body_del().
2699  * @see ephysics_body_evas_object_set().
2700  * @see ephysics_body_face_evas_object_set().
2701  *
2702  * @ingroup EPhysics_Body
2703  */
2704 EAPI EPhysics_Body *ephysics_body_sphere_add(EPhysics_World *world);
2705 
2706 /**
2707  * @brief
2708  * Create a new cylinder physics body.
2709  *
2710  * Its collision shape will be a cylinder of diameter 1. To change it's size
2711  * @ref ephysics_body_geometry_set() should be used.
2712  *
2713  * Any evas object can be associated to it with
2714  * @ref ephysics_body_evas_object_set(),
2715  * and it will collide as a cylinder (even if you have an evas rectangle).
2716  *
2717  * If a cylinder that could have its shape deformed is required, use
2718  * @ref ephysics_body_soft_cylinder_add().
2719  *
2720  * @param world The world this body will belongs to.
2721  * @return a new body or @c NULL, on errors.
2722  *
2723  * @see ephysics_body_del().
2724  * @see ephysics_body_evas_object_set().
2725  * @see ephysics_body_face_evas_object_set().
2726  *
2727  * @ingroup EPhysics_Body
2728  */
2729 EAPI EPhysics_Body *ephysics_body_cylinder_add(EPhysics_World *world);
2730 
2731 /**
2732  * @brief
2733  * Create a new deformable cylinder physics body.
2734  *
2735  * Its collision shape will be a cylinder of diameter 1. To change it's size
2736  * @ref ephysics_body_geometry_set() should be used.
2737  *
2738  * Any evas object can be associated to it with
2739  * @ref ephysics_body_evas_object_set(),
2740  * and it will collide and deform as a cylinder (even if you have an evas
2741  * rectangle).
2742  *
2743  * Just like rotation, deformation will be applied on associated
2744  * evas object using evas map.
2745  *
2746  * @note When working with soft bodies it's importante to adjust the
2747  * simulation's fixed time step due its multi point nature.
2748  *
2749  * For a rigid cylinder, check @ref ephysics_body_cylinder_add().
2750  *
2751  * @param world The world this body will belongs to.
2752  * @return a new body or @c NULL, on errors.
2753  *
2754  * @see ephysics_body_del().
2755  * @see ephysics_body_evas_object_set().
2756  * @see ephysics_body_face_evas_object_set().
2757  * @see ephysics_world_simulation_set().
2758  *
2759  * @ingroup EPhysics_Body
2760  */
2761 EAPI EPhysics_Body *ephysics_body_soft_cylinder_add(EPhysics_World *world);
2762 
2763 /**
2764  * @brief
2765  * Create a new box physics body.
2766  *
2767  * Its collision shape will be a box of dimensions 1 on all the axes.
2768  * To change it's size @ref ephysics_body_geometry_set() should be used.
2769  *
2770  * If a box that could have its shape deformed is required, use
2771  * @ref ephysics_body_soft_box_add().
2772  *
2773  * @param world The world this body will belongs to.
2774  * @return a new body or @c NULL, on errors.
2775  *
2776  * @see ephysics_body_del().
2777  * @see ephysics_body_evas_object_set().
2778  * @see ephysics_body_face_evas_object_set().
2779  *
2780  * @ingroup EPhysics_Body
2781  */
2782 EAPI EPhysics_Body *ephysics_body_box_add(EPhysics_World *world);
2783 
2784 /**
2785  * @brief
2786  * Create a new deformable box physics body.
2787  *
2788  * Its collision shape will be a box of dimensions 1 on all the axes.
2789  * To change it's size @ref ephysics_body_geometry_set() should be used.
2790  *
2791  * Just like rotation, deformation will be applied on associated
2792  * evas object using evas map.
2793  *
2794  * @note When working with soft bodies it's importante to adjust the
2795  * simulation's fixed time step due its multi point nature.
2796  *
2797  * For a rigid cylinder, check @ref ephysics_body_cylinder_add().
2798  *
2799  * @param world The world this body will belong to.
2800  * @return a new body or @c NULL on errors.
2801  *
2802  * @see ephysics_body_del().
2803  * @see ephysics_body_evas_object_set().
2804  * @see ephysics_body_face_evas_object_set().
2805  * @see ephysics_world_simulation_set().
2806  *
2807  * @ingroup EPhysics_Body
2808  */
2809 EAPI EPhysics_Body *ephysics_body_soft_box_add(EPhysics_World *world);
2810 
2811 /**
2812  * @brief
2813  * Create a new deformable cloth physics body.
2814  *
2815  * A cloth has its points of deformation conceptually split into rows and
2816  * columns where every square is also split into two triangles - afore named
2817  * nodes. To fine tune the deformation one can increase this granularity by
2818  * increasing the number of  @p rows and @p columns.
2819  *
2820  * By default - if passed 0 as @p rows and @p columns - EPhysics creates a cloth
2821  * with 15 rows and 15 columns, these default values will generally fit the most
2822  * common scenarios.
2823  *
2824  * If the informed @p rows is of 0 then the default value - of 15 - is
2825  * assumed. The same is true for @p columns.
2826  *
2827  * @param world The world this body will belong to.
2828  * @param rows The number os rows.
2829  * @param columns The number of columns.
2830  * @return a new body or @c NULL on erros.
2831  *
2832  * @see ephysics_body_del().
2833  * @see ephysics_body_evas_object_set().
2834  * @see ephysics_body_face_evas_object_set().
2835  * @see ephysics_world_simulation_set().
2836  * @see ephysics_body_cloth_anchor_add().
2837  * @see ephysics_body_cloth_anchor_full_add().
2838  *
2839  * @ingroup EPhysics_Body
2840  */
2841 EAPI EPhysics_Body *ephysics_body_cloth_add(EPhysics_World *world, unsigned short rows, unsigned short columns);
2842 
2843 /**
2844  * @brief
2845  * Anchors a cloth with a rigid body.
2846  *
2847  * All the informed @p side of @p body1 will be anchored to @p body2 wherever
2848  * it's in time of anchoring. That is, all the nodes in the informed "edge".
2849  *
2850  * An anchor assumes the @p body1 positions, if it's 20px far from @p body2 then
2851  * this distance is always kept, moving @p body1 or @p body2 will respect a 20px
2852  * difference.
2853  *
2854  * @param body1 The cloth body to be anchored.
2855  * @param body2 The body to be anchored to.
2856  * @param side The side to be anchored.
2857  *
2858  * @see ephysics_body_cloth_anchor_add().
2859  * @see ephysics_body_cloth_anchor_del().
2860  * @see ephysics_body_cloth_add() to know more about the cloth physics
2861  * representation.
2862  * @ingroup EPhysics_Body
2863  */
2864 EAPI void ephysics_body_cloth_anchor_full_add(EPhysics_Body *body1, EPhysics_Body *body2, EPhysics_Body_Cloth_Anchor_Side side);
2865 
2866 /**
2867  * @brief
2868  * Anchors an arbitrary cloth's node with a rigid body.
2869  *
2870  * The informed @p node of @p body1 will be anchored to @p body2 wherever it's
2871  * in time of anchoring.
2872  *
2873  * @see ephysics_body_cloth_add() to know more about the cloth physics
2874  * representation, nodes and so on.
2875  *
2876  * An anchor assumes the @p body1 positions, if it's 20px far from @p body2 then
2877  * this distance is always kept, moving @p body1 or @p body2 will respect a 20px
2878  * difference.
2879  *
2880  * @param body1 The cloth body to be anchored.
2881  * @param body2 The body to be anchored to.
2882  * @param node The node index to be anchored.
2883  *
2884  * @see ephysics_body_cloth_anchor_full_add().
2885  * @see ephysics_body_cloth_anchor_del().
2886 
2887  *
2888  * @ingroup EPhysics_Body
2889  */
2890 EAPI void ephysics_body_cloth_anchor_add(EPhysics_Body *body1, EPhysics_Body *body2, int node);
2891 
2892 /**
2893  * @brief
2894  * Removes the anchors in a cloth body.
2895  *
2896  * @param body The body to delete anchors from.
2897  *
2898  * @see ephysics_body_cloth_anchor_full_add().
2899  * @see ephysics_body_cloth_anchor_add().
2900  *
2901  * @ingroup EPhysics_Body
2902  */
2903 EAPI void ephysics_body_cloth_anchor_del(EPhysics_Body *body);
2904 
2905 /**
2906  * @brief
2907  * Create a new physics body using a custom shape.
2908  *
2909  * Its collision shape will be a convex shape that has all the points
2910  * added to this @p shape. A shape can be created with
2911  * @ref ephysics_shape_new().
2912  *
2913  * To change it's size @ref ephysics_body_geometry_set() should be used,
2914  * so it can be deformed on x, y and z axes.
2915  *
2916  * The center of mass of this body can be get with
2917  * @ref ephysics_body_center_mass_get().
2918  *
2919  * @param world The world this body will belongs to.
2920  * @param shape The custom shape to be used.
2921  * @return a new body or @c NULL, on errors.
2922  *
2923  * @see ephysics_body_del().
2924  * @see ephysics_body_evas_object_set().
2925  *
2926  * @ingroup EPhysics_Body
2927  */
2928 EAPI EPhysics_Body *ephysics_body_shape_add(EPhysics_World *world, EPhysics_Shape *shape);
2929 
2930 /**
2931  * @brief
2932  * Create a physic top boundary.
2933  *
2934  * A physic top boundary will limit the bodies area and placed on top edge of
2935  * worlds render geometry - defined with
2936  * @ref ephysics_world_render_geometry_set().
2937  *
2938  * @param world The world this body will belong to.
2939  * @return a new body or @c NULL, on erros.
2940  * @see ephysics_world_render_geometry_set()
2941  *
2942  * @ingroup EPhysics_Body
2943  */
2944 EAPI EPhysics_Body *ephysics_body_top_boundary_add(EPhysics_World *world);
2945 
2946 /**
2947  * @brief
2948  * Create a physic bottom boundary.
2949  *
2950  * A physic bottom boundary will limit the bodies area and placed on bottom
2951  * edge of worlds render geometry - defined with
2952  * @ref ephysics_world_render_geometry_set().
2953  *
2954  * @param world The world this body will belong to.
2955  * @return a new body or @c NULL, on erros.
2956  * @see ephysics_world_render_geometry_set()
2957  *
2958  * @ingroup EPhysics_Body
2959  */
2960 EAPI EPhysics_Body *ephysics_body_bottom_boundary_add(EPhysics_World *world);
2961 
2962 /**
2963  * @brief
2964  * Create a physic left boundary.
2965  *
2966  * A physic left boundary will limit the bodies area and placed right o the
2967  * left edge of worlds render geometry - defined with
2968  * @ref ephysics_world_render_geometry_set().
2969  *
2970  * @param world The world this body will belong to.
2971  * @return a new body or @c NULL, on erros.
2972  * @see ephysics_world_render_geometry_set()
2973  *
2974  * @ingroup EPhysics_Body
2975  */
2976 EAPI EPhysics_Body *ephysics_body_left_boundary_add(EPhysics_World *world);
2977 
2978 /**
2979  * @brief
2980  * Create a physic right boundary.
2981  *
2982  * A physic right boundary will limit the bodies area and placed right o the
2983  * right edge of worlds render geometry - defined with
2984  * @ref ephysics_world_render_geometry_set().
2985  *
2986  * @param world The world this body will belong to.
2987  * @return a new body or @c NULL, on erros.
2988  * @see ephysics_world_render_geometry_set()
2989  *
2990  * @ingroup EPhysics_Body
2991  */
2992 EAPI EPhysics_Body *ephysics_body_right_boundary_add(EPhysics_World *world);
2993 
2994 /**
2995  * @brief
2996  * Create a physic front boundary.
2997  *
2998  * A physic front boundary will limit the bodies area and placed on the
2999  * front of worlds render geometry - defined with
3000  * @ref ephysics_world_render_geometry_set().
3001  * It is placed on x-y plane, from x to x + width, from y to y + height.
3002  *
3003  * @param world The world this body will belong to.
3004  * @return a new body or @c NULL, on erros.
3005  * @see ephysics_world_render_geometry_set()
3006  *
3007  * @ingroup EPhysics_Body
3008  */
3009 EAPI EPhysics_Body *ephysics_body_front_boundary_add(EPhysics_World *world);
3010 
3011 /**
3012  * @brief
3013  * Create a physic back boundary.
3014  *
3015  * A physic front boundary will limit the bodies area and placed on the
3016  * back of worlds render geometry - defined with
3017  * @ref ephysics_world_render_geometry_set().
3018  * It is placed on x-y plane, from x to x + width, from y to y + height.
3019  *
3020  * @param world The world this body will belong to.
3021  * @return a new body or @c NULL, on erros.
3022  * @see ephysics_world_render_geometry_set()
3023  *
3024  * @ingroup EPhysics_Body
3025  */
3026 EAPI EPhysics_Body *ephysics_body_back_boundary_add(EPhysics_World *world);
3027 
3028 /**
3029  * @brief
3030  * Delete a physics body.
3031  *
3032  * This function will remove this body from its world and will
3033  * free all the memory used. It won't delete or modify an associated evas
3034  * object, what can be done with @ref ephysics_body_evas_object_set(). So after
3035  * it is removed the evas object will stop being updated, but will continue
3036  * to be rendered on canvas.
3037  *
3038  * @param body The body to be deleted.
3039  *
3040  * @see ephysics_body_box_add().
3041  * @see ephysics_body_cylinder_add().
3042  *
3043  * @ingroup EPhysics_Body
3044  */
3045 EAPI void ephysics_body_del(EPhysics_Body *body);
3046 
3047 /**
3048  * @brief
3049  * Get the world a body belongs to.
3050  *
3051  * It will return the world where the body was added to.
3052  *
3053  * @param body The physics body.
3054  * @return The world, or @c NULL on error.
3055  *
3056  * @ingroup EPhysics_Body
3057  */
3058 EAPI EPhysics_World *ephysics_body_world_get(const EPhysics_Body *body);
3059 
3060 /**
3061  * @brief
3062  * Set an evas object to a physics body.
3063  *
3064  * It will create a direct association between a physics body and an
3065  * evas object. With that EPhysics will be able to update evas object
3066  * position and rotation automatically.
3067  *
3068  * This association should be 1:1. You can have physics bodies without evas
3069  * objects, but you can't have more than an evas object directly associated
3070  * to this body. If you want more, you can use
3071  * @ref ephysics_body_event_callback_add() to register a callback that
3072  * will update the other evas objects. This function can be used to disable
3073  * updates of associated evas objects, or complement updates, like changing
3074  * evas objects properties under certain conditions of position or rotation.
3075  *
3076  * If it's required to associate evas object to specific faces of the body,
3077  * function @ref ephysics_body_face_evas_object_set() could be used.
3078  *
3079  * @param body The body to associate to an evas object.
3080  * @param evas_obj The evas object that will be associated to this @p body.
3081  * @param use_obj_pos If @c EINA_TRUE it will set the physics body position
3082  * to match evas object position taking world rate on consideration.
3083  *
3084  * @see ephysics_body_box_add().
3085  * @see ephysics_body_soft_box_add().
3086  * @see ephysics_body_cylinder_add().
3087  * @see ephysics_body_soft_cylinder_add().
3088  * @see ephysics_body_evas_object_unset().
3089  * @see ephysics_world_rate_set().
3090  *
3091  * @ingroup EPhysics_Body
3092  */
3093 EAPI void ephysics_body_evas_object_set(EPhysics_Body *body, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
3094 
3095 /**
3096  * @brief
3097  * Unset the evas object associated to a physics body.
3098  *
3099  * @param body The body to unset an evas object from.
3100  * @return The associated evas object, or @c NULL if no object is associated
3101  * or on error.
3102  *
3103  * @see ephysics_body_evas_object_set() for more details.
3104  *
3105  * @ingroup EPhysics_Body
3106  */
3107 EAPI Evas_Object *ephysics_body_evas_object_unset(EPhysics_Body *body);
3108 
3109 /**
3110  * @brief
3111  * Get the evas object associated to a physics body.
3112  *
3113  * @param body The body to get an evas object from.
3114  * @return The associated evas object, or @c NULL if no object is associated
3115  * or on error.
3116  *
3117  * @see ephysics_body_evas_object_set() for more details.
3118  *
3119  * @ingroup EPhysics_Body
3120  */
3121 EAPI Evas_Object *ephysics_body_evas_object_get(const EPhysics_Body *body);
3122 
3123 /**
3124  * @brief
3125  * Set an evas object to a physics body face.
3126  *
3127  * It will create a direct association between a specific face of the physics
3128  * body and an evas object.
3129  * With that EPhysics will be able to update evas object
3130  * position and rotation automatically.
3131  *
3132  * If it's required to associate only one evas object to this body, a more
3133  * generic function @see ephysics_body_evas_object_set() can be used.
3134  *
3135  * @param body The body to associate to an evas object.
3136  * @param face The specific face of @p body where the evas object will be
3137  * placed.
3138  * @param evas_obj The evas object that will be associated to this @p body.
3139  * @param use_obj_pos If @c EINA_TRUE it will set the physics body position
3140  * to match evas object position taking world rate on consideration.
3141  *
3142  * @see ephysics_body_face_evas_object_unset().
3143  * @see ephysics_body_face_evas_object_get().
3144  * @see ephysics_body_evas_object_set().
3145  * @see ephysics_world_rate_set().
3146  *
3147  * @ingroup EPhysics_Body
3148  */
3149 EAPI void ephysics_body_face_evas_object_set(EPhysics_Body *body, EPhysics_Body_Face face, Evas_Object *evas_obj, Eina_Bool use_obj_pos);
3150 
3151 /**
3152  * @brief
3153  * Get the evas object associated to a physics body face.
3154  *
3155  * @param body The body to get an evas object from.
3156  * @param face The specific face of @p body where the evas object was placed.
3157  * @return The associated evas object, or @c NULL if no object is associated
3158  * or on error.
3159  *
3160  * @see ephysics_body_face_evas_object_set() for more details.
3161  *
3162  * @ingroup EPhysics_Body
3163  */
3164 EAPI Evas_Object *ephysics_body_face_evas_object_get(const EPhysics_Body *body, EPhysics_Body_Face face);
3165 
3166 /**
3167  * @brief
3168  * Unset the evas object associated to a physics body face.
3169  *
3170  * @param body The body to unset an evas object from.
3171  * @param face The specific face of @p body where the evas object was placed.
3172  * @return The associated evas object, or @c NULL if no object is associated
3173  * or on error.
3174  *
3175  * @see ephysics_body_face_evas_object_set() for more details.
3176  *
3177  * @ingroup EPhysics_Body
3178  */
3179 EAPI Evas_Object *ephysics_body_face_evas_object_unset(EPhysics_Body *body, EPhysics_Body_Face face);
3180 
3181 /**
3182  * @brief
3183  * Set physics body size.
3184  *
3185  * By default cylinders have diameter equal to 1 meter * rate, boxes have
3186  * dimensions 1 meter * rate on all the axes.
3187  *
3188  * There are three direct ways of modifying it's size:
3189  * @li With @ref ephysics_body_resize();
3190  * @li With @ref ephysics_body_geometry_set();
3191  * @li When associating an evas object with
3192  * @ref ephysics_body_evas_object_set().
3193  *
3194  * @note The unit used for size is Evas coordinates.
3195  *
3196  * @param body The body to be resized.
3197  * @param w The body width, in pixels.
3198  * @param h The body height, in pixels.
3199  * @param d The body depth, in pixels.
3200  *
3201  * @see ephysics_body_geometry_get().
3202  * @see ephysics_body_geometry_set().
3203  * @see ephysics_body_move().
3204  *
3205  * @ingroup EPhysics_Body
3206  */
3207 EAPI void ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coord d);
3208 
3209 /**
3210  * @brief
3211  * Set physics body position.
3212  *
3213  * All the physics bodies are created centered on origin (0, 0, 0).
3214  *
3215  * There are three direct ways of modifying this position:
3216  * @li With @ref ephysics_body_move();
3217  * @li With @ref ephysics_body_geometry_set();
3218  * @li When associating an evas object with
3219  * @ref ephysics_body_evas_object_set().
3220  *
3221  * When the world is simulated forces will be applied on objects
3222  * with mass and position will be modified too.
3223  *
3224  * @note The unit used for position is Evas coordinates.
3225  *
3226  * @param body The body to be positioned.
3227  * @param x The position on axis x, in pixels.
3228  * @param y The position on axis y, in pixels.
3229  * @param z The position on axis z, in pixels.
3230  *
3231  * @see ephysics_body_geometry_get().
3232  * @see ephysics_body_geometry_set().
3233  * @see ephysics_body_resize().
3234  *
3235  * @ingroup EPhysics_Body
3236  */
3237 EAPI void ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z);
3238 
3239 /**
3240  * @brief
3241  * Set physics body geometry.
3242  *
3243  * All the physics bodies are created centered on origin (0, 0) and with
3244  * canonical dimensions. Cylinder have diameter 1, boxes have dimensions 1
3245  * on all the axes.
3246  *
3247  * There are four direct ways of modifying this geometry:
3248  * @li With @ref ephysics_body_geometry_set();
3249  * @li With @ref ephysics_body_move();
3250  * @li With @ref ephysics_body_resize();
3251  * @li When associating an evas object with
3252  * @ref ephysics_body_evas_object_set().
3253  *
3254  * If you just need to move the body, no changes are required to it's size,
3255  * use @ref ephysics_body_move(). If you just need to modify the size of
3256  * @p body use @ref ephysics_body_resize().
3257  *
3258  * When the world is simulated forces will be applied on objects
3259  * with mass and position will be modified too.
3260  *
3261  * @note The unit used for geometry is Evas coordinates.
3262  *
3263  * @param body The body to be modified.
3264  * @param x The position on axis x, in pixels.
3265  * @param y The position on axis y, in pixels.
3266  * @param z The position on axis z, in pixels.
3267  * @param w The body width, in pixels.
3268  * @param h The body height, in pixels.
3269  * @param d The body depth, in pixels.
3270  *
3271  * @see ephysics_body_geometry_get().
3272  * @see ephysics_body_move().
3273  * @see ephysics_body_resize().
3274  *
3275  * @ingroup EPhysics_Body
3276  */
3277 EAPI void ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord z, Evas_Coord w, Evas_Coord h, Evas_Coord d);
3278 
3279 /**
3280  * @brief
3281  * Get physics body position.
3282  *
3283  * @param body The physics body.
3284  * @param x The position on axis x, in pixels.
3285  * @param y The position on axis y, in pixels.
3286  * @param z The position on axis z, in pixels.
3287  * @param w The body width, in pixels.
3288  * @param h The body height, in pixels.
3289  * @param d The body depth, in pixels.
3290  *
3291  * @see ephysics_body_geometry_set() for more details.
3292  * @see ephysics_body_move().
3293  * @see ephysics_body_resize().
3294  *
3295  * @ingroup EPhysics_Body
3296  */
3297 EAPI void ephysics_body_geometry_get(const EPhysics_Body *body, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z, Evas_Coord *w, Evas_Coord *h, Evas_Coord *d);
3298 
3299 /**
3300  * @brief
3301  * Set body's mass.
3302  *
3303  * It will set inertial mass of the body. It is a quantitative measure of
3304  * an object's resistance to the change of its speed. It's required to apply
3305  * more force on objects with more mass to increase its speed.
3306  *
3307  * If mass is set to 0 the body will have infinite mass, so it will be
3308  * immovable, static. @ref EPHYSICS_BODY_MASS_STATIC can be used too.
3309  *
3310  * Negative mass is not allowed.
3311  *
3312  * By default, a body is created with 1 kg.
3313  *
3314  * @note The unit used for mass is kilograms.
3315  *
3316  * @param body The body to has its mass set.
3317  * @param mass The @p body's mass, in kilograms.
3318  *
3319  * @see ephysics_body_mass_get().
3320  *
3321  * @ingroup EPhysics_Body
3322  */
3323 EAPI void ephysics_body_mass_set(EPhysics_Body *body, double mass);
3324 
3325 /**
3326  * @brief
3327  * Get body's mass.
3328  *
3329  * It will get inertial mass of the body.
3330  *
3331  * @param body The physics body.
3332  * @return the @p body mass, in kilograms.
3333  *
3334  * @see ephysics_body_mass_set() for details.
3335  *
3336  * @ingroup EPhysics_Body
3337  */
3338 EAPI double ephysics_body_mass_get(const EPhysics_Body *body);
3339 
3340 /**
3341  * @brief
3342  * Set body's linear velocity on x, y and z axes.
3343  *
3344  * @param body The physics body.
3345  * @param x The linear velocity on axis x.
3346  * @param y The linear velocity on axis y.
3347  * @param z The linear velocity on axis z.
3348  *
3349  * @note EPhysics unit for linear velocity is Evas coordinates per second.
3350  *
3351  * @see ephysics_body_linear_velocity_get().
3352  * @see ephysics_body_angular_velocity_set().
3353  *
3354  * @ingroup EPhysics_Body
3355  */
3356 EAPI void ephysics_body_linear_velocity_set(EPhysics_Body *body, double x, double y, double z);
3357 
3358 /**
3359  * @brief
3360  * Get body's linear velocity on x, y and z axes.
3361  *
3362  * @param body The physics body.
3363  * @param x The linear velocity on axis x.
3364  * @param y The linear velocity on axis y.
3365  * @param z The linear velocity on axis z.
3366  *
3367  * @note EPhysics unit for linear velocity is Evas coordinates per second.
3368  * @note For cloth bodies the returned value is a velocity average of nodes
3369  * velocities.
3370  *
3371  * @see ephysics_body_linear_velocity_set().
3372  * @see ephysics_body_angular_velocity_get().
3373  *
3374  * @ingroup EPhysics_Body
3375  */
3376 EAPI void ephysics_body_linear_velocity_get(const EPhysics_Body *body, double *x, double *y, double *z);
3377 
3378 /**
3379  * @brief
3380  * Set body's angular velocity on x, y and z axes.
3381  *
3382  * @param body The physics body.
3383  * @param x The angular velocity on axis x.
3384  * @param y The angular velocity on axis y.
3385  * @param z The angular velocity on axis z.
3386  *
3387  * @note EPhysics unit for angular velocity is degrees per second.
3388  *
3389  * @see ephysics_body_angular_velocity_get().
3390  * @see ephysics_body_linear_velocity_set().
3391  *
3392  * @ingroup EPhysics_Body
3393  */
3394 EAPI void ephysics_body_angular_velocity_set(EPhysics_Body *body, double x, double y, double z);
3395 
3396 /**
3397  * @brief
3398  * Get body's angular velocity on x, y and z axes.
3399  *
3400  * @param body The physics body.
3401  * @param x The angular velocity on axis x.
3402  * @param y The angular velocity on axis y.
3403  * @param z The angular velocity on axis z.
3404  *
3405  * @note EPhysics unit for angular velocity is degrees per second.
3406  *
3407  * @see ephysics_body_angular_velocity_set().
3408  * @see ephysics_body_linear_velocity_get().
3409  *
3410  * @ingroup EPhysics_Body
3411  */
3412 EAPI void ephysics_body_angular_velocity_get(const EPhysics_Body *body, double *x, double *y, double *z);
3413 
3414 /**
3415  * @brief
3416  * Set the linear and angular sleeping threshold.
3417  *
3418  * These factors are used to determine whenever a rigid body is supposed to
3419  * increment the sleeping time.
3420  *
3421  * After every tick the sleeping time is incremented, if the body's linear and
3422  * angular speed is less than the respective thresholds the sleeping time is
3423  * incremented by the current time step (delta time).
3424  *
3425  * After reaching the max sleeping time the body is marked to sleep, that means
3426  * the rigid body is to be deactivated.
3427  *
3428  * @note The expected value to be informed as @p linear_threshold is
3429  * the body's speed. It is measured in Evas coordinates per second.
3430  *
3431  * @note The expected angular velocity to be informed as @p angular_threshold
3432  * is measured in degrees per second.
3433  *
3434  * @param body The body to be set.
3435  * @param linear_threshold The linear sleeping threshold factor, default value
3436  * is 24.
3437  * @param angular_threshold The angular sleeping threshold factor, default value
3438  * is 57.29 (1 rad).
3439  *
3440  * @see ephysics_body_sleeping_threshold_get().
3441  * @see ephysics_world_max_sleeping_time_set() for sleeping time details.
3442  *
3443  * @ingroup EPhysics_Body
3444  */
3445 EAPI void ephysics_body_sleeping_threshold_set(EPhysics_Body *body, double linear_threshold, double angular_threshold);
3446 
3447 /**
3448  * @brief
3449  * Get the linear sleeping threshold.
3450  *
3451  * @note The linear sleeping threshold is measured in Evas coordinates per
3452  * second and the angular sleeping threshold is measured in degrees per second.
3453  *
3454  * @param body The body to get the linear sleeping threshold from.
3455  * @param linear_threshold The linear sleeping threshold factor.
3456  * @param angular_threshold The angular sleeping threshold factor.
3457  *
3458  * @see ephysics_body_sleeping_threshold_set() for more details.
3459  *
3460  * @ingroup EPhysics_Body
3461  */
3462 EAPI void ephysics_body_sleeping_threshold_get(const EPhysics_Body *body, double *linear_threshold, double *angular_threshold);
3463 
3464 /**
3465  * @brief
3466  * Stop angular and linear body movement.
3467  *
3468  * It's equivalent to set linear velocity to 0 on both axis and
3469  * angular velocity to 0 as well.
3470  *
3471  * It's a momentary situation. If it receives impulse, directly or
3472  * by collision, if gravity acts over this body,
3473  * it will stop but it will accelerate again.
3474  *
3475  * @param body The physics body.
3476  *
3477  * @see ephysics_body_angular_velocity_set().
3478  * @see ephysics_body_linear_velocity_set().
3479  *
3480  * @ingroup EPhysics_Body
3481  */
3482 EAPI void ephysics_body_stop(EPhysics_Body *body);
3483 
3484 /**
3485  * @brief
3486  * Set the angular and linear damping values.
3487  *
3488  * Damping(linear and angular) values are applied to body's linear and angular
3489  * velocity.
3490  *
3491  * By applying a bodies damping factor the user will face a velocity reduction,
3492  * with a force applied to it - like air resistance. The force is applied to
3493  * slow it down. Different factors can be applied to angular and linear
3494  * velocity to fine tune translation and rotation.
3495  *
3496  * The damping is a force synchronous with the velocity of the object but in
3497  * opposite direction.
3498  *
3499  * Damping is specified as a value between 0 and 1, which is the proportion of
3500  * velocity lost per second. If specified damping value - either for angular or
3501  * linear - is greater or equal to 1, velocities are nulled(that means, will
3502  * become 0 on every axis), resulting on a frozen body.
3503  *
3504  * Default linear damping is set to 0. The same is true for angular damping
3505  * factor.
3506  *
3507  * @param body The physics body.
3508  * @param linear_damping The linear damping factor to apply on @p body.
3509  * @param angular_damping The angular damping factor to apply on @p body.
3510  *
3511  * @see ephysics_body_damping_get().
3512  *
3513  * @ingroup EPhysics_Body
3514  */
3515 EAPI void ephysics_body_damping_set(EPhysics_Body *body, double linear_damping, double angular_damping);
3516 
3517 /**
3518  * @brief
3519  * Get the angular and linear damping values.
3520  *
3521  * Damping(linear and angular) values are applied to body's linear and angular
3522  * velocity.
3523  *
3524  * @param body The physics body.
3525  * @param linear_damping The linear damping factor applied over @p body.
3526  * @param angular_damping The angular damping factor applied over @p body.
3527  *
3528  * @see ephysics_body_damping_set() for details.
3529  *
3530  * @ingroup EPhysics_Body
3531  */
3532 EAPI void ephysics_body_damping_get(const EPhysics_Body *body, double *linear_damping, double *angular_damping);
3533 
3534 /**
3535  * @brief
3536  * Add a @p body to a given collision group.
3537  *
3538  * After calling this function the body is said to be added to collision @p
3539  * group.
3540  *
3541  * If not added to any group the body will collide against any other body.
3542  * Otherwise this body will collide only against those in the same groups.
3543  *
3544  * If @p body was already part of @p group, nothing will happen.
3545  *
3546  * @param body The body to be added to @p group.
3547  * @param group The group the @p body will belong to.
3548  * @return @c EINA_TRUE if body is added to group, or @c EINA_FALSE on error.
3549  *
3550  * @see ephysics_body_collision_group_del()
3551  * @see ephysics_body_collision_group_list_get()
3552  * @ingroup EPhysics_Body
3553  */
3554 EAPI Eina_Bool ephysics_body_collision_group_add(EPhysics_Body *body, const char *group);
3555 
3556 /**
3557  * @brief
3558  * Removes @p body from collision @p group.
3559  *
3560  * This @p body will not belong to @p group any more and the collisions filter
3561  * must take that on account.
3562  *
3563  * If @p body wasn't part of @p group before, nothing will happen.
3564  *
3565  * @param body The body to be removed from @p group.
3566  * @param group The group @p body must be removed from.
3567  * @return @c EINA_TRUE if body is removed from group, or @c EINA_FALSE on
3568  * error.
3569  *
3570  * @see ephysics_body_collision_group_add()
3571  * @ingroup EPhysics_Body
3572  */
3573 EAPI Eina_Bool ephysics_body_collision_group_del(EPhysics_Body *body, const char *group);
3574 
3575 /**
3576  * @brief
3577  * Get the collision group list of @p body.
3578  *
3579  * @param body The body of interest.
3580  * @return The collision group list of @p body, NULL on failure or case no
3581  * group has been added to @p body.
3582  *
3583  * @warning The collision group list is an EPhysics internal data structure and
3584  * should @b never be modified by its callers.
3585  *
3586  * @see ephysics_body_collision_group_add()
3587  * @ingroup EPhysics_Body
3588  */
3589 EAPI const Eina_List *ephysics_body_collision_group_list_get(const EPhysics_Body *body);
3590 
3591 /**
3592  * @brief
3593  * Update the evas object associated to the body.
3594  *
3595  * This function should be called to update position and rotation of
3596  * the evas object associated to the body with
3597  * @ref ephysics_body_evas_object_set().
3598  * It will take rate between pixels and meters set with
3599  * @ref ephysics_world_rate_set() in account.
3600  *
3601  * If an update callback wasn't set with
3602  * @ref ephysics_body_event_callback_add(), this function will be executed
3603  * after each physics simulation tick. If a callback was set, it won't be
3604  * called automatically. So inside this callback it could be called, or
3605  * a customized update could be implemented.
3606  *
3607  * @see ephysics_body_event_callback_add() for more details.
3608  *
3609  * @ingroup EPhysics_Body
3610  */
3611 EAPI void ephysics_body_evas_object_update(EPhysics_Body *body);
3612 
3613 /**
3614  * @brief
3615  * Register a callback to a type of physics body event.
3616  *
3617  * The registered callback will receives the body and extra user data that
3618  * can be passed. From body it's possible to get the world it belongs to
3619  * with @ref ephysics_body_world_get(), the rate between pixels and meters
3620  * with @ref ephysics_world_rate_get() and the associated evas object with
3621  * @ref ephysics_body_evas_object_get().
3622  *
3623  * So it's enough to do customized updates or fix pointers in your program.
3624  *
3625  * Regarding EPHYSICS_CALLBACK_BODY_UPDATE:
3626  *
3627  * This update event happens after each physics world tick. Its main use
3628  * could be updating the evas object associated to a physics body.
3629  *
3630  * If no callback is registered, the evas object associated to physics body
3631  * will be automatically moved and rotated, taking rate between meters and
3632  * pixels on account. This rate is set by @ref ephysics_world_rate_set().
3633  *
3634  * If callbacks are registered, these function will be called and will
3635  * be responsible for updating the evas object. If the default update
3636  * is wanted, function @ref ephysics_body_evas_object_update() can be called
3637  * inside the callback. So you could make changes before and after
3638  * the evas object is updated.
3639  *
3640  * A callback could be something like this:
3641  * @code
3642  *   static void
3643  *   _update_cb(void *data, EPhysics_Body *body, void *event_info)
3644  *   {
3645  *     // Something you want to do before updating the evas object
3646  *     ephysics_body_evas_object_update(body);
3647  *     // Something to be done after the update, like checking the new position
3648  *     // of the evas object to change a property.
3649  *   }
3650  *
3651  *  ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_UPDATE,
3652  *                                   _update_cb, NULL);
3653  * @endcode
3654  *
3655  * Update callbacks receives evas object set to body as event_info argument.
3656  *
3657  * What follows is a list of details about each callback type:
3658  *
3659  * - #EPHYSICS_CALLBACK_BODY_UPDATE: Called after every physics iteration. @p
3660  *   body points to the EPhysics_Body itself and @p event_info points to the
3661  *   evas object associated to the body.
3662  *
3663  * - #EPHYSICS_CALLBACK_BODY_COLLISION: Called just after the collision has
3664  *   been actually processed by the physics engine. The body involved in the
3665  *   collision is passed as @p body argument. @p event_info is a pointer to
3666  *   @ref EPhysics_Body_Collision - note, this structure(@p event_info) is
3667  *   discarded/freed right after callback returns.
3668  *
3669  * - #EPHYSICS_CALLBACK_BODY_DEL: Called when a body deletion has been issued
3670  *   and just before the deletion actually happens. @p body points to the body
3671  *   being deleted and @p event_info is a pointer to the evas object
3672  *   associated to it.
3673  *
3674  * - #EPHYSICS_CALLBACK_BODY_STOPPED: Called when a body is found to be
3675  *   stopped. @p body points to the body of interest and @p event_info is a
3676  *   pointer to the evas object associated to it.
3677  *
3678  * @param body The physics body.
3679  * @param type Type of callback to be listened by @p func.
3680  * @param func Callback function that will be called when event occurs.
3681  * @param data User data that will be passed to callback function. It won't
3682  * be used by ephysics in any way.
3683  *
3684  * @ingroup EPhysics_Body
3685  */
3686 EAPI void ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, const void *data);
3687 
3688 /**
3689  * @brief
3690  * Unregister an ephysics body event callback.
3691  *
3692  * A previously added callback that match @p body, @p type and @p func
3693  * will be deleted.
3694  *
3695  * @param body The physics body.
3696  * @param type The type of callback to be unregistered.
3697  * @param func The callback function to be unregistered.
3698  * @return The user data passed when the callback was registered, or @c NULL
3699  * on error.
3700  *
3701  * @see ephysics_body_event_callback_add() for details.
3702  * @see ephysics_body_event_callback_del_full() if you need to match data
3703  * pointer.
3704  *
3705  * @ingroup EPhysics_Body
3706  */
3707 EAPI void *ephysics_body_event_callback_del(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func);
3708 
3709 /**
3710  * @brief
3711  * Unregister an ephysics body event callback matching data pointer.
3712  *
3713  * A previously added callback that match @p body, @p type, @p func
3714  * and @p data will be deleted.
3715  *
3716  * @param body The physics body.
3717  * @param type The type of callback to be unregistered.
3718  * @param func The callback function to be unregistered.
3719  * @param data The data pointer that was passed to the callback.
3720  * @return The user data passed when the callback was registered, or @c NULL
3721  * on error.
3722  *
3723  * @see ephysics_body_event_callback_add() for details.
3724  * @see ephysics_body_event_callback_del() if you don't need to match data
3725  * pointer.
3726  *
3727  * @ingroup EPhysics_Body
3728  */
3729 EAPI void *ephysics_body_event_callback_del_full(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, void *data);
3730 
3731 /**
3732  * @brief
3733  * Get the position(x, y) of a body's collision.
3734  *
3735  * Given a body collision data, fills @p x and @p y pointers with the position
3736  * where the collision occurred.
3737  *
3738  * @param collision The body collision data of interest.
3739  * @param x The x coordinate of collision point, in pixels.
3740  * @param y The y coordinate of collision point, in pixels.
3741  * @param z The z coordinate of collision point, in pixels.
3742  *
3743  * @see EPHYSICS_CALLBACK_BODY_COLLISION and @ref
3744  * ephysics_body_event_callback_add() for collision callback.
3745  * @ingroup EPhysics_Body
3746  */
3747 EAPI void ephysics_body_collision_position_get(const EPhysics_Body_Collision *collision, Evas_Coord *x, Evas_Coord *y, Evas_Coord *z);
3748 
3749 /**
3750  * @brief
3751  * Get the body's collision contact body.
3752  *
3753  * Given a body collision data returns the contact body which a collision
3754  * occurred against.
3755  *
3756  * @param collision The body collision of interest.
3757  * @return The contact body of @p collision.
3758  *
3759  * @see EPHYSICS_CALLBACK_BODY_COLLISION and @ref
3760  * ephysics_body_event_callback_add() for collision callback.
3761  * @ingroup EPhysics_Body
3762  */
3763 EAPI EPhysics_Body *ephysics_body_collision_contact_body_get(const EPhysics_Body_Collision *collision);
3764 
3765 /**
3766  * @brief
3767  * Set body's coefficient of restitution.
3768  *
3769  * The coefficient of restitution is proporcion between speed after and
3770  * before a collision:
3771  * COR = relative speed after collision / relative speed before collision
3772  *
3773  * The body COR is the coefficient of restitution with respect to a perfectly
3774  * rigid and elastic object. Bodies will collide between them with different
3775  * behaviors depending on COR:
3776  * @li they will elastically collide for COR == 1;
3777  * @li they will inelastically collide for 0 < COR < 1;
3778  * @li they will completelly stop (no bouncing at all) for COR == 0.
3779  *
3780  * By default restitution coefficient of each body is 0.
3781  *
3782  * EPhysics has some pre-defined restitution coefficients for materials:
3783  * @li @ref EPHYSICS_BODY_RESTITUTION_CONCRETE
3784  * @li @ref EPHYSICS_BODY_RESTITUTION_IRON
3785  * @li @ref EPHYSICS_BODY_RESTITUTION_PLASTIC
3786  * @li @ref EPHYSICS_BODY_RESTITUTION_POLYSTYRENE
3787  * @li @ref EPHYSICS_BODY_RESTITUTION_RUBBER
3788  * @li @ref EPHYSICS_BODY_RESTITUTION_WOOD
3789  *
3790  * @param body The body to has its restitution coefficient set.
3791  * @param restitution The new @p body's restitution coefficient.
3792  *
3793  * @see ephysics_body_restitution_get().
3794  *
3795  * @ingroup EPhysics_Body
3796  */
3797 EAPI void ephysics_body_restitution_set(EPhysics_Body *body, double restitution);
3798 
3799 /**
3800  * @brief
3801  * Get body's restitution.
3802  *
3803  * @param body The physics body.
3804  * @return the @p body's restitution value.
3805  *
3806  * @see ephysics_body_restitution_set() for details.
3807  *
3808  * @ingroup EPhysics_Body
3809  */
3810 EAPI double ephysics_body_restitution_get(const EPhysics_Body *body);
3811 
3812 /**
3813  * @brief
3814  * Set body's friction.
3815  *
3816  * Friction is used to make objects slide along each other realistically.
3817  *
3818  * The friction parameter is usually set between 0 and 1, but can be any
3819  * non-negative value. A friction value of 0 turns off friction and a value
3820  * of 1 makes the friction strong.
3821  *
3822  * By default friction value is 0.5 and simulation results will be better
3823  * when friction in non-zero.
3824  *
3825  * EPhysics has some pre-defined friction coefficients for materials:
3826  * @li @ref EPHYSICS_BODY_FRICTION_CONCRETE
3827  * @li @ref EPHYSICS_BODY_FRICTION_IRON
3828  * @li @ref EPHYSICS_BODY_FRICTION_PLASTIC
3829  * @li @ref EPHYSICS_BODY_FRICTION_POLYSTYRENE
3830  * @li @ref EPHYSICS_BODY_FRICTION_RUBBER
3831  * @li @ref EPHYSICS_BODY_FRICTION_WOOD
3832  *
3833  * @param body The body to has its friction set.
3834  * @param friction The new @p body's friction value.
3835  *
3836  * @see ephysics_body_friction_get().
3837  *
3838  * @ingroup EPhysics_Body
3839  */
3840 EAPI void ephysics_body_friction_set(EPhysics_Body *body, double friction);
3841 
3842 /**
3843  * @brief
3844  * Get body's friction.
3845  *
3846  * @param body The physics body.
3847  * @return the @p body's friction value.
3848  *
3849  * @see ephysics_body_friction_set() for details.
3850  *
3851  * @ingroup EPhysics_Body
3852  */
3853 EAPI double ephysics_body_friction_get(const EPhysics_Body *body);
3854 
3855 /**
3856  * @brief
3857  * Apply an impulse on the center of a body.
3858  *
3859  * The impulse is equal to the change of momentum of the body.
3860  *
3861  * Impulse is the product of the force over the time this force is applied.
3862  * In ephysics case, it would be the time of a tick, so it behaves just
3863  * summing current linear velocity to impulse per mass.
3864  *
3865  * Example:
3866  * A body of 2kg of mass has an initial velocity of 30 p/s.
3867  * After a impulse of 30 kg * p / s in the same direction is applied,
3868  * the velocity will be * 45 p/s.
3869  *
3870  *    (0, 30, 0) + (0, 300, 0) / 2 = (0, 30, 0) + (0, 15, 0) = (0, 45, 0)
3871  *
3872  * When a impulse is applied over a body, it will has its velocity changed.
3873  * This impulse will be applied on body's center, so it won't implies in
3874  * rotating the body. For that is possible to apply a torque impulse with
3875  * @ref ephysics_body_torque_impulse_apply().
3876  *
3877  * @note Impulse is measured in kg * p / s.
3878  *
3879  * @param body The physics body that will receive the impulse.
3880  * @param x The axis x component of impulse.
3881  * @param y The axis y component of impulse.
3882  * @param z The axis z component of impulse.
3883  *
3884  * @see ephysics_body_torque_impulse_apply().
3885  * @see ephysics_body_impulse_apply().
3886  *
3887  * @ingroup EPhysics_Body
3888  */
3889 EAPI void ephysics_body_central_impulse_apply(EPhysics_Body *body, double x, double y, double z);
3890 
3891 /**
3892  * @brief
3893  * Apply a torque impulse over a body.
3894  *
3895  * An impulse will be applied over the body to make it rotate.
3896  * Impulse is the product of the force over the time this force is applied.
3897  * In ephysics case, it would be the time of a tick, so it behaves just
3898  * summing current angular velocity to the result of a calculation involving
3899  * torque impulse and body's inertia.
3900  *
3901  * @param body The physics body that will receive the impulse.
3902  * @param pitch Impulse to rotate body around X axis (rotate on y - z plane).
3903  * Negative values will impulse body on counter clockwise rotation.
3904  * @param yaw Impulse to rotate body around Y axis (rotate on x - z plane).
3905  * Negative values will impulse body on counter clockwise rotation.
3906  * @param roll Impulse to rotate body around Z axis (rotate on x - y plane).
3907  * Negative values will impulse body on counter clockwise rotation.
3908  *
3909  * @see ephysics_body_central_impulse_apply().
3910  * @see ephysics_body_impulse_apply().
3911  *
3912  * @ingroup EPhysics_Body
3913  */
3914 EAPI void ephysics_body_torque_impulse_apply(EPhysics_Body *body, double pitch, double yaw, double roll);
3915 
3916 /**
3917  * @brief
3918  * Apply an impulse over a body.
3919  *
3920  * An impulse will be applied over the body to make it move and rotate.
3921  *
3922  * Impulse is the product of the force over the time this force is applied.
3923  * It can be applied in the center of the body, avoiding rotating it,
3924  * with @ref ephysics_body_central_impulse_apply(), it can be applied only
3925  * to make a body rotate, with @ref ephysics_body_torque_impulse_apply(),
3926  * or can be used to lead to both behaviors with
3927  * @ref ephysics_body_impulse_apply().
3928  *
3929  * It will result in a central impulse with impulse (@p x, @p y, @p z) and a
3930  * torque impulse that will be calculated as a cross product on impulse
3931  * and relative position.
3932  *
3933  * @param body The physics body that will receive the impulse.
3934  * @param x The axis x component of impulse.
3935  * @param y The axis y component of impulse.
3936  * @param z The axis z component of impulse.
3937  * @param pos_x The axis x component of the relative position to apply impulse.
3938  * @param pos_y The axis y component of the relative position to apply impulse.
3939  * @param pos_z The axis z component of the relative position to apply impulse.
3940  *
3941  * @note Impulse is measured in kg * p / s and position in pixels
3942  * (Evas coordinates).
3943  *
3944  * @see ephysics_body_central_impulse_apply().
3945  * @see ephysics_body_torque_impulse_apply().
3946  *
3947  * @ingroup EPhysics_Body
3948  */
3949 EAPI void ephysics_body_impulse_apply(EPhysics_Body *body, double x, double y, double z, Evas_Coord pos_x, Evas_Coord pos_y, Evas_Coord pos_z);
3950 
3951 /**
3952  * @brief
3953  * Enable or disable body's rotation on z axis.
3954  *
3955  * Enabled by default for z axis, so the body only will rotate on x-y plane.
3956  *
3957  * @param body The physics body.
3958  * @param enable_x If @c EINA_TRUE allow rotation on x axis (y-z plane),
3959  * if @c EINA_FALSE disallow it.
3960  * @param enable_y If @c EINA_TRUE allow rotation on y axis (x-z plane),
3961  *if @c EINA_FALSE disallow it.
3962  * @param enable_z If @c EINA_TRUE allow rotation on z axis (x-y plane),
3963  * if @c EINA_FALSE disallow it.
3964  *
3965  * @see ephysics_body_angular_movement_enable_get().
3966  *
3967  * @ingroup EPhysics_Body
3968  */
3969 EAPI void ephysics_body_angular_movement_enable_set(EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y, Eina_Bool enable_z);
3970 
3971 /**
3972  * @brief
3973  * Return body's rotation on z axis state.
3974  *
3975  * @param body The physics body.
3976  * @param enable_x @c EINA_TRUE if rotation on x axis (y-z plane) is allowed, or
3977  * @c EINA_FALSE if it's not.
3978  * @param enable_y @c EINA_TRUE if rotation on y axis (x-z plane) is allowed, or
3979  * @c EINA_FALSE if it's not.
3980  * @param enable_z @c EINA_TRUE if rotation on z axis (x-y plane) is allowed, or
3981  * @c EINA_FALSE if it's not.
3982  *
3983  * @see ephysics_body_angular_movement_enable_set() for more details.
3984  *
3985  * @ingroup EPhysics_Body
3986  */
3987 EAPI void ephysics_body_angular_movement_enable_get(const EPhysics_Body *body, Eina_Bool *enable_x, Eina_Bool *enable_y, Eina_Bool *enable_z);
3988 
3989 /**
3990  * @brief
3991  * Enable or disable body's movement on x, y and z axes.
3992  *
3993  * Enabled by default on x and y axes, disabled on z axis.
3994  *
3995  * @param body The physics body.
3996  * @param enable_x If @c EINA_TRUE allow movement on x axis, if @c EINA_FALSE
3997  * disallow it.
3998  * @param enable_y If @c EINA_TRUE allow movement on y axis, if @c EINA_FALSE
3999  * disallow it.
4000  * @param enable_z If @c EINA_TRUE allow movement on z axis, if @c EINA_FALSE
4001  * disallow it.
4002  *
4003  * @see ephysics_body_linear_movement_enable_get().
4004  * @see ephysics_body_angular_movement_enable_set().
4005  *
4006  * @ingroup EPhysics_Body
4007  */
4008 EAPI void ephysics_body_linear_movement_enable_set(EPhysics_Body *body, Eina_Bool enable_x, Eina_Bool enable_y, Eina_Bool enable_z);
4009 
4010 /**
4011  * @brief
4012  * Get body's movement on x, y and z axes behavior.
4013  *
4014  * @param body The physics body.
4015  * @param enable_x @c EINA_TRUE if movement on x axis is allowed, or
4016  * @c EINA_FALSE if it's not.
4017  * @param enable_y @c EINA_TRUE if movement on y axis is allowed, or
4018  * @c EINA_FALSE if it's not.
4019  * @param enable_z @c EINA_TRUE if movement on z axis is allowed, or
4020  * @c EINA_FALSE if it's not.
4021  *
4022  * @see ephysics_body_linear_movement_enable_set().
4023  * @see ephysics_body_angular_movement_enable_get().
4024  *
4025  * @ingroup EPhysics_Body
4026  */
4027 EAPI void ephysics_body_linear_movement_enable_get(const EPhysics_Body *body, Eina_Bool *enable_x, Eina_Bool *enable_y, Eina_Bool *enable_z);
4028 
4029 /**
4030  * @brief
4031  * Get body's rotation quaternion.
4032  *
4033  * By default rotation is 0 degree on all axes (1, 0, 0, 0).
4034  *
4035  * @param body The physics body.
4036  * @param rotation Quaternion used to store the result. If it's @c NULL, a new
4037  * quaternion will be allocated (and should be freed after usage).
4038  * @return A quaternion or @c NULL on error.
4039  *
4040  * @see ephysics_body_rotation_set()
4041  * @see ephysics_quaternion_get()
4042  *
4043  * @ingroup EPhysics_Body
4044  */
4045 EAPI EPhysics_Quaternion *ephysics_body_rotation_get(const EPhysics_Body *body, EPhysics_Quaternion *rotation);
4046 
4047 /**
4048  * @brief
4049  * Set body's rotation.
4050  *
4051  * By default rotation is 0 degrees on all axes.
4052  *
4053  * @param body The physics body.
4054  * @param quat Quaternion representing the rotation.
4055  *
4056  * @see ephysics_body_rotation_get()
4057  * @see ephysics_quaternion_new()
4058  *
4059  * @ingroup EPhysics_Body
4060  */
4061 EAPI void ephysics_body_rotation_set(EPhysics_Body *body, EPhysics_Quaternion *quat);
4062 
4063 /**
4064  * @brief
4065  * Set data to @p body.
4066  *
4067  * If a previous data was set, it's reference will be lost and body
4068  * will point to the new data.
4069  *
4070  * It can be useful when you need to store a structure per body. For example,
4071  * some values that must to be updated when a collision occurs between two
4072  * bodies.
4073  *
4074  * @note EPhysics won't handle this data, it won't be used in any way
4075  * by the library. If it need to be freed when the body is deleted, a
4076  * callback for @ref EPHYSICS_CALLBACK_BODY_DEL can be added and
4077  * data should be explicity freed.
4078  *
4079  * @param body The physics body.
4080  * @param data The data to be set.
4081  *
4082  * @see ephysics_body_data_get()
4083  *
4084  * @ingroup EPhysics_Body
4085  */
4086 EAPI void ephysics_body_data_set(EPhysics_Body *body, void *data);
4087 
4088 /**
4089  * @brief
4090  * Return data previously set to body.
4091  *
4092  * @param body The physics body.
4093  * @return The data set or @c NULL on error.
4094  *
4095  * @see ephysics_body_data_get() for more details
4096  *
4097  * @ingroup EPhysics_Body
4098  */
4099 EAPI void *ephysics_body_data_get(const EPhysics_Body *body);
4100 
4101 /**
4102  * @brief
4103  * Apply a force on the center of a body.
4104  *
4105  * Applying a force to a body will lead it to change its velocity.
4106  *
4107  * Force is the product of mass and acceleration. So, keeping the mass
4108  * fixed, when force is applied acceleration will change, and consequently,
4109  * velocity will gradually be changes.
4110  *
4111  * Force = mass * acceleration
4112  *
4113  * Final velocity = initial velocity + acceleration * time
4114  *
4115  * While a force is applied, it will be acting over a body. It can be canceled
4116  * by applying an inverse force, or just calling
4117  * @ref ephysics_body_forces_clear().
4118  *
4119  * This force will be applied on body's center, so it won't implies in
4120  * changing angular acceleration. For that, it is possible to apply a torque
4121  * with @ref ephysics_body_torque_apply().
4122  *
4123  * If the force shouldn't be applied on body's center, it can be applied on
4124  * a relative point with @ref ephysics_body_force_apply().
4125  *
4126  * @note Force is measured in kg * p / s / s.
4127  *
4128  * @param body The physics body which over the force will be applied.
4129  * @param x The axis x component of force.
4130  * @param y The axis y component of force.
4131  * @param z The axis z component of force.
4132  *
4133  * @see ephysics_body_torque_apply().
4134  * @see ephysics_body_force_apply().
4135  * @see ephysics_body_forces_get().
4136  * @see ephysics_body_torques_get().
4137  *
4138  * @ingroup EPhysics_Body
4139  */
4140 EAPI void ephysics_body_central_force_apply(EPhysics_Body *body, double x, double y, double z);
4141 
4142 /**
4143  * @brief
4144  * Apply a torque over a body.
4145  *
4146  * A torque will be applied over the @p body to change the angular acceleration
4147  * of this body. It will leads to a change on angular velocity over time.
4148  *
4149  * @param body The physics body that will receive the torque.
4150  * @param torque_x Torque to change angular acceleration of the body around X
4151  * axis (rotate on y - z plane).
4152  * Negative values will accelerate it on counter clockwise rotation.
4153  * @param torque_y Torque to change angular acceleration of the body around Y
4154  * axis (rotate on x - z plane).
4155  * Negative values will accelerate it on counter clockwise rotation.
4156  * @param torque_z Torque to change angular acceleration of the body around Z
4157  * axis (rotate on x - y plane).
4158  * Negative values will accelerate it on counter clockwise rotation.
4159  *
4160  * @see ephysics_body_central_force_apply().
4161  * @see ephysics_body_force_apply().
4162  * @see ephysics_body_forces_get().
4163  * @see ephysics_body_torques_get().
4164  *
4165  * @ingroup EPhysics_Body
4166  */
4167 EAPI void ephysics_body_torque_apply(EPhysics_Body *body, double torque_x, double torque_y, double torque_z);
4168 
4169 /**
4170  * @brief
4171  * Apply a force over a body.
4172  *
4173  * A force will be applied over the body to change it's linear and angular
4174  * accelerations.
4175  *
4176  * It can be applied in the center of the body, avoiding affecting angular
4177  * acceleration, with @ref ephysics_body_central_force_apply(),
4178  * it can be applied only to change angular acceleration, with
4179  * @ref ephysics_body_torque_apply(), or can be used to lead to both
4180  * behaviors with @ref ephysics_body_force_apply().
4181  *
4182  * It will result in a central force with force (@p x, @p y, @p z) and a
4183  * torque that will be calculated as a cross product on force
4184  * and relative position.
4185  *
4186  * @param body The physics body that will receive the impulse.
4187  * @param x The axis x component of force.
4188  * @param y The axis y component of force.
4189  * @param z The axis z component of force.
4190  * @param pos_x The axis x component of the relative position to apply force.
4191  * @param pos_y The axis y component of the relative position to apply force.
4192  * @param pos_z The axis z component of the relative position to apply force.
4193  *
4194  * @note Force is measured in kg * p / s / s and position in p (pixels, or
4195  * Evas coordinates).
4196  *
4197  * @see ephysics_body_central_force_apply().
4198  * @see ephysics_body_torque_apply().
4199  * @see ephysics_body_forces_get().
4200  * @see ephysics_body_torques_get().
4201  *
4202  * @ingroup EPhysics_Body
4203  */
4204 EAPI void ephysics_body_force_apply(EPhysics_Body *body, double x, double y, double z, Evas_Coord pos_x, Evas_Coord pos_y, Evas_Coord pos_z);
4205 
4206 /**
4207  * @brief
4208  * Get physics body forces.
4209  *
4210  * Get all the forces applied over a body, including gravity.
4211  * Damping is not considered.
4212  *
4213  * @param body The physics body.
4214  * @param x The axis x component of total force.
4215  * @param y The axis y component of total force.
4216  * @param z The axis z component of total force.
4217  *
4218  * @see ephysics_body_force_apply() for more details.
4219  * @see ephysics_body_central_force_apply().
4220  * @see ephysics_body_torque_apply().
4221  * @see ephysics_body_torques_get().
4222  * @see ephysics_body_forces_clear().
4223  * @see ephysics_world_gravity_set().
4224  *
4225  * @ingroup EPhysics_Body
4226  */
4227 EAPI void ephysics_body_forces_get(const EPhysics_Body *body, double *x, double *y, double *z);
4228 
4229 /**
4230  * @brief
4231  * Get physics body torques.
4232  *
4233  * Get all the torques applied over a body.
4234  * Damping is not considered.
4235  *
4236  * @param body The physics body.
4237  * @param x The torque on x axis.
4238  * @param y The torque on y axis.
4239  * @param z The torque on z axis.
4240  *
4241  * @see ephysics_body_torque_apply() for more details.
4242  * @see ephysics_body_force_apply().
4243  * @see ephysics_body_forces_clear().
4244  *
4245  * @ingroup EPhysics_Body
4246  */
4247 EAPI void ephysics_body_torques_get(const EPhysics_Body *body, double *x, double *y, double *z);
4248 
4249 /**
4250  * @brief
4251  * Clear all the forces applied to a body.
4252  *
4253  * It will remove all the forces previously applied. So linear acceleration
4254  * and angular acceleration will be set to 0.
4255  *
4256  * It won't interfere with world's gravity, the body will continue to be
4257  * accelerated considering gravity.
4258  *
4259  * It won't affect damping.
4260  *
4261  * @param body The physics body that will have applied forces set to 0.
4262  *
4263  * @see ephysics_body_central_force_apply().
4264  * @see ephysics_body_torque_apply().
4265  * @see ephysics_body_force_apply().
4266  * @see ephysics_body_forces_get().
4267  * @see ephysics_body_torques_get().
4268  *
4269  * @ingroup EPhysics_Body
4270  */
4271 EAPI void ephysics_body_forces_clear(EPhysics_Body *body);
4272 
4273 /**
4274  * @brief
4275  * Get the center of mass of physics body.
4276  *
4277  * It returns a value from 0 to 1 representing where is the center of the mass
4278  * considering the height, width and depth of the body.
4279  *
4280  * If a body of width = 30, height = 20 and depth = 20, and has the center of
4281  * mass at x component = 20, y component = 10 and z = 10, it will return
4282  * @p x = 0.666, @p y = 0.5 and @p z = 0.5.
4283  *
4284  * For primitive shapes, like box and cylinder, the center of mass
4285  * is (0.5, 0.5, 0.5).
4286  *
4287  * This function can be useful when updating evas objects for bodies
4288  * with custom shapes.
4289  *
4290  * @param body The physics body.
4291  * @param x The axis x component of center of mass.
4292  * @param y The axis y component of center of mass.
4293  * @param z The axis z component of center of mass.
4294  *
4295  * @see ephysics_body_shape_add().
4296  *
4297  * @ingroup EPhysics_Body
4298  */
4299 EAPI void ephysics_body_center_mass_get(const EPhysics_Body *body, double *x, double *y, double *z);
4300 
4301 /**
4302  * @brief
4303  * Set body's material density.
4304  *
4305  * The density of a material is its mass per unit volume. It will set the
4306  * body mass considering its volume. While a density is set, resizing
4307  * a body will always recalculate its mass.
4308  *
4309  * When a mass is explicitely set with @ref ephysics_body_mass_set(),
4310  * the density will be unset.
4311  *
4312  * It's useful in cases where a specific material needs to be simulated,
4313  * so its density can be set and ephysics will calcute the body's mass.
4314  *
4315  * By default, no density is set.
4316  *
4317  * EPhysics has some pre-defined density values for materials:
4318  * @li @ref EPHYSICS_BODY_DENSITY_CONCRETE
4319  * @li @ref EPHYSICS_BODY_DENSITY_IRON
4320  * @li @ref EPHYSICS_BODY_DENSITY_PLASTIC
4321  * @li @ref EPHYSICS_BODY_DENSITY_POLYSTYRENE
4322  * @li @ref EPHYSICS_BODY_DENSITY_RUBBER
4323  * @li @ref EPHYSICS_BODY_DENSITY_WOOD
4324  *
4325  * @note The unit used for density is kilograms / meters ^ 3.
4326  *
4327  * @param body The body to has its material density set.
4328  * @param density The @p body's material density, in kilograms / meters ^ 3.
4329  *
4330  * @see ephysics_body_density_get().
4331  *
4332  * @ingroup EPhysics_Body
4333  */
4334 EAPI void ephysics_body_density_set(EPhysics_Body *body, double density);
4335 
4336 /**
4337  * @brief
4338  * Get body's material density.
4339  *
4340  * @param body The physics body.
4341  * @return the @p body material's density, in kilograms / meters ^ 3 or 0
4342  * if no density is set.
4343  *
4344  * @see ephysics_body_density_set() for details.
4345  *
4346  * @ingroup EPhysics_Body
4347  */
4348 EAPI double ephysics_body_density_get(const EPhysics_Body *body);
4349 
4350 /**
4351  * @brief
4352  * Get body's volume.
4353  *
4354  * @note The unit of the returned value is meters ^ 3. Not pixels. Useful
4355  * for calculation with mass and density.
4356  *
4357  * @param body The physics body.
4358  * @return the @p body's volume, in meters ^ 3 or -1 on error.
4359  *
4360  * @see ephysics_body_geometry_set().
4361  * @see ephysics_body_geometry_get().
4362  *
4363  * @ingroup EPhysics_Body
4364  */
4365 EAPI double ephysics_body_volume_get(const EPhysics_Body *body);
4366 
4367 /**
4368  * @brief
4369  * Set body's material.
4370  *
4371  * This function makes properties setting easy. When a material is set to
4372  * a body, it will update its friction, restitution and density,
4373  * recalculating its mass.
4374  *
4375  * EPhysics support some materials defined by @ref EPhysics_Body_Material.
4376  *
4377  * So, for example, if @ref EPHYSICS_BODY_MATERIAL_WOOD is set, it will
4378  * set body's density to @ref EPHYSICS_BODY_DENSITY_WOOD, restitution
4379  * to @ref EPHYSICS_BODY_RESTITUTION_WOOD and friction to
4380  * @ref EPHYSICS_BODY_FRICTION_WOOD.
4381  *
4382  * If any of these values are later explicitely set, the material will
4383  * be set back to @ref EPHYSICS_BODY_MATERIAL_CUSTOM, the default.
4384  *
4385  * @param body The body to has its material set.
4386  * @param material The @p material to be used by the body.
4387  *
4388  * @see ephysics_body_material_get().
4389  *
4390  * @ingroup EPhysics_Body
4391  */
4392 EAPI void ephysics_body_material_set(EPhysics_Body *body, EPhysics_Body_Material material);
4393 
4394 /**
4395  * @brief
4396  * Get body's material.
4397  *
4398  * @param body The physics body.
4399  * @return the @p material used by the body.
4400  *
4401  * @see ephysics_body_material_set() for more details.
4402  *
4403  * @ingroup EPhysics_Body
4404  */
4405 EAPI EPhysics_Body_Material ephysics_body_material_get(const EPhysics_Body *body);
4406 
4407 /**
4408  * @brief
4409  * Set light effect over body.
4410  *
4411  * @param body The physics body.
4412  * @param enable If @c EINA_TRUE, light will be applied over this @p body,
4413  * otherwise it won't.
4414  *
4415  * It's possible to set the light to apply over all the bodies with
4416  * @ref ephysics_world_light_all_bodies_set(). This will have priority
4417  * over body's individual light settings.
4418  *
4419  * So, if @p body is set to doesn't be affect by the light, but light
4420  * is set to be applied over all the bodies, @p body will be displayed
4421  * with light over it.
4422  *
4423  * @see ephysics_body_light_get().
4424  * @see ephysics_world_point_light_position_set() for more details
4425  * regarding lighting.
4426  *
4427  * @ingroup EPhysics_Body
4428  */
4429 EAPI void ephysics_body_light_set(EPhysics_Body *body, Eina_Bool enable);
4430 
4431 /**
4432  * @brief
4433  * Get light effect over body.
4434  *
4435  * @param body The physics body.
4436  * @return @c EINA_TRUE if light is applied over this @p body or @c EINA_FALSE
4437  * in the other case, or on error.
4438  *
4439  * @note If light is applied over all the bodies it may return @c EINA_FALSE
4440  * even if it's being affect by lights. This need to be checked with
4441  * @ref ephysics_world_light_all_bodies_get().
4442  *
4443  * @see ephysics_body_light_set() for more details.
4444  *
4445  * @ingroup EPhysics_Body
4446  */
4447 EAPI Eina_Bool ephysics_body_light_get(const EPhysics_Body *body);
4448 
4449 /**
4450  * @brief
4451  * Set body's evas object to be hidden when it is counter-clockwise.
4452  *
4453  * @param body The physics body.
4454  * @param enable If @c EINA_TRUE, evas object will be hidden,
4455  * otherwise it will be visible, rotated.
4456  *
4457  * An object is said to be facing the user when all its points are placed in
4458  * a clockwise fashion.
4459  *
4460  * @note When back-face culling is enabled, evas object visibility
4461  * will be handled by @ref ephysics_body_evas_object_update().
4462  *
4463  * @see ephysics_body_back_face_culling_get().
4464  * @see ephysics_body_clockwise_get().
4465  * @see ephysics_body_evas_object_set().
4466  *
4467  * @ingroup EPhysics_Body
4468  */
4469 EAPI void ephysics_body_back_face_culling_set(EPhysics_Body *body, Eina_Bool enable);
4470 
4471 /**
4472  * @brief
4473  * Return if body's evas object will be hidden when it is counter-clockwise or
4474  * not.
4475  *
4476  * @param body The physics body.
4477  * @return @c EINA_TRUE if evas object will be hidden, or @c EINA_FALSE
4478  * in the other case, or on error.
4479  *
4480  * @see ephysics_body_back_face_culling_set() for more details.
4481  * @see ephysics_body_clockwise_get().
4482  *
4483  * @ingroup EPhysics_Body
4484  */
4485 EAPI Eina_Bool ephysics_body_back_face_culling_get(const EPhysics_Body *body);
4486 
4487 /**
4488  * @brief
4489  * Get the clockwise state of a body.
4490  *
4491  * This determines if the points of the evas object associated to the @p body
4492  * are clockwise or counter-clockwise. This can be used for "back-face culling". * This is where you hide objects that "face away" from you.
4493  * In this case objects that are not clockwise.
4494  *
4495  * It can be set with @ref ephysics_body_back_face_culling_set(), so EPhysics
4496  * will handle visibility automatically on evas object update.
4497  *
4498  * @note This information only will be updated on
4499  * ephysics_body_evas_object_update(). So if a custom rendering is being done,
4500  * this function won't return the current value of the evas object.
4501  *
4502  * @param body The physics body.
4503  * @return @c EINA_TRUE if clockwise, @c EINA_FALSE otherwise or on error.
4504  *
4505  * @see ephysics_body_back_face_culling_set() for more details.
4506  *
4507  * @ingroup EPhysics_Body
4508  */
4509 EAPI Eina_Bool ephysics_body_clockwise_get(const EPhysics_Body *body);
4510 
4511 /**
4512  * @}
4513  */
4514 
4515 /**
4516  * @defgroup EPhysics_Constraint EPhysics Constraint
4517  * @ingroup EPhysics
4518  *
4519  * @{
4520  *
4521  * Constraints can be used to limit bodies movements, between bodies or
4522  * between bodies and the world. Constraints can limit movement angle,
4523  * translation, or work like a motor.
4524  *
4525  * Constraints can be created with @ref ephysics_constraint_linked_add()
4526  * or @ref ephysics_constraint_add() and removed
4527  * with @ref ephysics_constraint_del().
4528  * Can be applied between two bodies or between a body and the world.
4529  */
4530 
4531 typedef struct _EPhysics_Constraint EPhysics_Constraint; /**< Constraint handle, used to limit bodies movements. Created with @ref ephysics_constraint_linked_add() or @ref ephysics_constraint_add() and deleted with @ref ephysics_constraint_del(). */
4532 
4533 /**
4534  * @brief
4535  * Create a new constraint between 2 bodies(Point to Point constraint).
4536  *
4537  * The constraint will join two bodies(@p body1 and @p body2) with angular and
4538  * linear movements limited by calling ephysics_constraint_linear_limit_set()
4539  * and ephysics_constraint_angular_limit_set(). Anchors values can be defined
4540  * with ephysics_constraint_anchor_set().
4541  *
4542  * @param body1 The first body to apply the constraint.
4543  * @param body2 The second body to apply the constraint.
4544  * @return A new linked(joining 2 bodies) constraint or @c NULL, on errors.
4545  *
4546  * @see ephysics_constraint_del().
4547  *
4548  * @ingroup EPhysics_Constraint
4549  */
4550 EAPI EPhysics_Constraint *ephysics_constraint_linked_add(EPhysics_Body *body1, EPhysics_Body *body2);
4551 
4552 /**
4553  * @brief
4554  * Change the constraints anchors values on both constrained bodies.
4555  *
4556  * @note By default the anchors are in the middle of a body, if a body of 20, 20
4557  * is positioned at (10, 10) then its anchor is set to (20, 20).
4558  *
4559  * @note There`s no need to inform @p anchor_b2_x, @p anchor_b2_y and @p
4560  * anchor_b2_z if the constraint has been created using
4561  * ephysics_constraint_add().
4562  *
4563  * @param constraint The constraint to be set.
4564  * @param anchor_b1_x The first body X anchor.
4565  * @param anchor_b1_y The first body Y anchor.
4566  * @param anchor_b1_z The first body Z anchor.
4567  * @param anchor_b2_x The second body X anchor.
4568  * @param anchor_b2_y The second body Y anchor.
4569  * @param anchor_b2_z The second body Z anchor.
4570  *
4571  * @see ephysics_constraint_anchor_get().
4572  * @see ephysics_constraint_linked_add().
4573  *
4574  * @ingroup EPhysics_Constraint
4575  */
4576 EAPI void ephysics_constraint_anchor_set(EPhysics_Constraint *constraint, Evas_Coord anchor_b1_x, Evas_Coord anchor_b1_y, Evas_Coord anchor_b1_z, Evas_Coord anchor_b2_x, Evas_Coord anchor_b2_y, Evas_Coord anchor_b2_z);
4577 
4578 /**
4579  * @brief
4580  * Get the constraints anchors values on both constrained bodies.
4581  *
4582  * @param constraint The constraint to get anchor values from.
4583  * @param anchor_b1_x Pointer to an Evas_Coord in which to store the first body
4584  * X anchor value.
4585  * @param anchor_b1_y Pointer to an Evas_Coord in which to store the first body
4586  * Y anchor value.
4587  * @param anchor_b1_z Pointer to an Evas_Coord in which to store the first body
4588  * Z anchor value.
4589  * @param anchor_b2_x Pointer to an Evas_Coord in which to store the second body
4590  * X anchor value.
4591  * @param anchor_b2_y Pointer to an Evas_Coord in which to store the second body
4592  * Y anchor value.
4593  * @param anchor_b2_z Pointer to an Evas_Coord in which to store the second body
4594  * Z anchor value.
4595  *
4596  * @see ephysics_constraint_anchor_set().
4597  * @see ephysics_constraint_linked_add().
4598  *
4599  * @ingroup EPhysics_Constraint
4600  */
4601 EAPI void ephysics_constraint_anchor_get(const EPhysics_Constraint *constraint, Evas_Coord *anchor_b1_x, Evas_Coord *anchor_b1_y, Evas_Coord *anchor_b1_z, Evas_Coord *anchor_b2_x, Evas_Coord *anchor_b2_y, Evas_Coord *anchor_b2_z);
4602 
4603 /**
4604  * @brief
4605  * Create a new constraint.
4606  *
4607  * The constraint will limit the linear and angular moving of a body. This simple
4608  * constraint is designated to constraint a single body.
4609  *
4610  * @param body The body to apply the constraint.
4611  *
4612  * @see ephysics_constraint_linear_limit_set() for linear moving limit
4613  * configuration.
4614  * @see ephysics_constraint_angular_limit_set() for angular moving limit
4615  * configuration.
4616  * @return A new constraint or @c NULL on erros.
4617  *
4618  * @see ephysics_constraint_del().
4619  *
4620  * @ingroup EPhysics_Constraint
4621  */
4622 EAPI EPhysics_Constraint *ephysics_constraint_add(EPhysics_Body *body);
4623 
4624 /**
4625  * @brief
4626  * Define the linear moving limits of a @p constraint.
4627  *
4628  * The linear limits are defined from the body's position on. The user will
4629  * want to limit the movements on X, Y and Z axis where lower == upper axis
4630  * will be locked, lower > upper axis is free, lower < upper axis is limited to
4631  * the range.
4632  *
4633  * The unit for every limits are defined on Evas coordinates.
4634  *
4635  * @param constraint The constraint to be set.
4636  * @param lower_x The lower linear moving limit on X axis.
4637  * @param upper_x The upper linear moving limit on X axis.
4638  * @param lower_y The lower linear moving limit on Y axis.
4639  * @param upper_y The upper linear moving limit on Y axis.
4640  * @param lower_z The lower linear moving limit on Z axis.
4641  * @param upper_z The upper linear moving limit on Z axis.
4642  *
4643  *
4644  * @see ephysics_constraint_linear_limit_get()
4645  * @ingroup EPhysics_Constraint
4646  */
4647 EAPI void ephysics_constraint_linear_limit_set(EPhysics_Constraint *constraint, Evas_Coord lower_x, Evas_Coord upper_x, Evas_Coord lower_y, Evas_Coord upper_y, Evas_Coord lower_z, Evas_Coord upper_z);
4648 
4649 /**
4650  * @brief
4651  * Get the linear moving limits of a @p constraint.
4652  *
4653  * @param constraint The constraint to get linear limits from.
4654  * @param lower_x Pointer to set with the lower limit to the X axis.
4655  * @param upper_x Pointer to set with the upper limit to the X axis.
4656  * @param lower_y Pointer to set with the lower limit to the Y axis.
4657  * @param upper_y Pointer to set with the upper limit to the Y axis.
4658  * @param lower_z Pointer to set with the lower limit to the Z axis.
4659  * @param upper_z Pointer to set with the upper limit to the Z axis.
4660  *
4661  * @see ephysics_constraint_linear_limit_set()
4662  * @ingroup EPhysics_Constraint
4663  */
4664 EAPI void ephysics_constraint_linear_limit_get(const EPhysics_Constraint *constraint, Evas_Coord *lower_x, Evas_Coord *upper_x, Evas_Coord *lower_y, Evas_Coord *upper_y, Evas_Coord *lower_z, Evas_Coord *upper_z);
4665 
4666 /**
4667  * @brief
4668  * Set the angular moving limits of a @p constraint.
4669  *
4670  * The angular moving limits is defined in degrees and will limit the moving on
4671  * Z axis - counter clockwise and clockwise directions.
4672  *
4673  * @param constraint The constraint to be set.
4674  * @param counter_clock_x Amount of degrees from 0.0 to 360.0 to limit counter
4675  * clockwise rotation on X axis.
4676  * @param clock_wise_x Amount of degrees from 0.0 to 360.0 to limit clockwise
4677  * rotation on X axis.
4678  * @param counter_clock_y Amount of degrees from 0.0 to 360.0 to limit counter
4679  * clockwise rotation o Y axis.
4680  * @param clock_wise_y Amount of degrees from 0.0 to 360.0 to limit clockwise
4681  * rotation on Y axis.
4682  * @param counter_clock_z Amount of degrees from 0.0 to 360.0 to limit
4683  * counter clockwise rotation on Z axis.
4684  * @param clock_wise_z Amount of degrees from 0.0 to 360.0 to limit clockwise
4685  * rotation on Z axis.
4686  *
4687  * @see ephysics_constraint_angular_limit_get()
4688  * @ingroup EPhysics_Constraint
4689  */
4690 EAPI void ephysics_constraint_angular_limit_set(EPhysics_Constraint *constraint, double counter_clock_x, double clock_wise_x, double counter_clock_y, double clock_wise_y, double counter_clock_z, double clock_wise_z);
4691 
4692 /**
4693  * @brief
4694  * Get the angular moving limits of a @p constraint.
4695  *
4696  * @param constraint The constraint to get the angular limits from.
4697  * @param counter_clock_x Pointer to set with the counter clockwise limmit
4698  * degrees on X axis.
4699  * @param clock_wise_x Pointer to set with the clockwise limit degrees on X axis.
4700  * @param counter_clock_y Pointer to set with the  counter clockwise limit
4701  * degrees on Y axis.
4702  * @param clock_wise_y Pointer to set with the clockwise limit degrees on Y axis.
4703  * @param counter_clock_z Pointer to set with the counter clockwise limit
4704  * degrees on Z axis.
4705  * @param clock_wise_z Pointer to set with the clockwise limit degrees on Z axis.
4706  *
4707  * @see ephysics_constraint_angular_limit_set()
4708  * @ingroup EPhysics_Constraint
4709  */
4710 EAPI void ephysics_constraint_angular_limit_get(const EPhysics_Constraint *constraint, double *counter_clock_x, double *clock_wise_x, double *counter_clock_y, double *clock_wise_y, double *counter_clock_z, double *clock_wise_z);
4711 
4712 /**
4713  * @brief
4714  * Deletes a physics constraint.
4715  *
4716  * @param constraint The constraint to be deleted.
4717  *
4718  * @see ephysics_constraint_linked_add() for more details.
4719  * @see ephysics_constraint_slider_add() for more details.
4720  *
4721  * @ingroup EPhysics_Constraint
4722  */
4723 EAPI void ephysics_constraint_del(EPhysics_Constraint *constraint);
4724 
4725 /**
4726  * @}
4727  */
4728 #ifdef __cplusplus
4729 }
4730 #endif
4731 
4732 #undef EAPI
4733 #define EAPI
4734 
4735 #endif
4736