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