summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-07-03 02:09:34 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-07-03 02:09:34 +0000
commiteb857cbfe1dcf71d44fa73d320507b18896a868d (patch)
tree1d484e494d2070f1c1be0a515a0a73d8e502551f /legacy
parent068e1711b02b8e9cbc244b3f4d4d98514b654874 (diff)
EPhysics: split the callback enum for body and world
Should avoid a mess in the future. SVN revision: 73179
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h89
-rw-r--r--legacy/ephysics/src/lib/ephysics_body.cpp11
-rw-r--r--legacy/ephysics/src/lib/ephysics_world.cpp11
3 files changed, 57 insertions, 54 deletions
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index 2b88d847b4..2a1a2cd933 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -89,42 +89,6 @@ extern "C" {
89 */ 89 */
90 90
91/** 91/**
92 * @enum _EPhysics_Callback_Type
93 * @typedef EPhysics_Callback_Type
94 *
95 * Identifier of callbacks to be set for EPhysics bodies and worlds.
96 *
97 * @see ephysics_body_event_callback_add()
98 * @see ephysics_world_event_callback_add()
99 *
100 * @ingroup EPhysics
101 */
102typedef enum _EPhysics_Callback_Type
103{
104 /*
105 * The following events are only for use with EPhysics world objects, with
106 * @ref ephysics_world_event_callback_add():
107 */
108 EPHYSICS_CALLBACK_WORLD_FIRST, /**< kept as sentinel, not really an event */
109 EPHYSICS_CALLBACK_WORLD_DEL, /**< World being deleted (called before free) */
110 EPHYSICS_CALLBACK_WORLD_STOPPED, /**< no objects are moving any more */
111 EPHYSICS_CALLBACK_WORLD_LAST, /**< kept as sentinel, not really an event */
112
113 /*
114 * The following events are only for use with EPhysics body objects, with
115 * @ref ephysics_body_event_callback_add():
116 */
117 EPHYSICS_CALLBACK_BODY_FIRST, /**< kept as sentinel, not really an event */
118 EPHYSICS_CALLBACK_BODY_UPDATE, /**< Body being updated */
119 EPHYSICS_CALLBACK_BODY_COLLISION, /**< Body collided with other body */
120 EPHYSICS_CALLBACK_BODY_DEL, /**< Body being deleted (called before free) */
121 EPHYSICS_CALLBACK_BODY_STOPPED, /**< Body is not moving any more */
122 EPHYSICS_CALLBACK_BODY_LAST, /**< kept as sentinel, not really an event */
123
124 EPHYSICS_CALLBACK_LAST /**< kept as sentinel, not really an event */
125} EPhysics_Callback_Type; /**< The types of events triggering a callback */
126
127/**
128 * Initialize EPhysics 92 * Initialize EPhysics
129 * 93 *
130 * Initializes Bullet physics engine. 94 * Initializes Bullet physics engine.
@@ -288,6 +252,25 @@ EAPI double ephysics_camera_zoom_get(const EPhysics_Camera *camera);
288typedef 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(). */ 252typedef 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(). */
289 253
290/** 254/**
255 * @enum _EPhysics_Callback_World_Type
256 * @typedef EPhysics_Callback_World_Type
257 *
258 * Identifier of callbacks to be set for EPhysics worlds.
259 *
260 * @see ephysics_world_event_callback_add()
261 * @see ephysics_world_event_callback_del()
262 * @see ephysics_world_event_callback_del_full()
263 *
264 * @ingroup EPhysics_World
265 */
266typedef enum _EPhysics_Callback_World_Type
267{
268 EPHYSICS_CALLBACK_WORLD_DEL, /**< World being deleted (called before free) */
269 EPHYSICS_CALLBACK_WORLD_STOPPED, /**< no objects are moving any more */
270 EPHYSICS_CALLBACK_WORLD_LAST, /**< kept as sentinel, not really an event */
271} EPhysics_Callback_World_Type;
272
273/**
291 * @typedef EPhysics_World_Event_Cb 274 * @typedef EPhysics_World_Event_Cb
292 * 275 *
293 * EPhysics world event callback function signature. 276 * EPhysics world event callback function signature.
@@ -544,7 +527,7 @@ EAPI EPhysics_Camera *ephysics_world_camera_get(const EPhysics_World *world);
544 * 527 *
545 * @ingroup EPhysics_World 528 * @ingroup EPhysics_World
546 */ 529 */
547EAPI void ephysics_world_event_callback_add(EPhysics_World *world, EPhysics_Callback_Type type, EPhysics_World_Event_Cb func, const void *data); 530EAPI void ephysics_world_event_callback_add(EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func, const void *data);
548 531
549/** 532/**
550 * @brief 533 * @brief
@@ -565,7 +548,7 @@ EAPI void ephysics_world_event_callback_add(EPhysics_World *world, EPhysics_Call
565 * 548 *
566 * @ingroup EPhysics_World 549 * @ingroup EPhysics_World
567 */ 550 */
568EAPI void *ephysics_world_event_callback_del(EPhysics_World *world, EPhysics_Callback_Type type, EPhysics_World_Event_Cb func); 551EAPI void *ephysics_world_event_callback_del(EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func);
569 552
570/** 553/**
571 * @brief 554 * @brief
@@ -587,7 +570,7 @@ EAPI void *ephysics_world_event_callback_del(EPhysics_World *world, EPhysics_Cal
587 * 570 *
588 * @ingroup EPhysics_World 571 * @ingroup EPhysics_World
589 */ 572 */
590EAPI void *ephysics_world_event_callback_del_full(EPhysics_World *world, EPhysics_Callback_Type type, EPhysics_World_Event_Cb func, void *data); 573EAPI void *ephysics_world_event_callback_del_full(EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func, void *data);
591 574
592/** 575/**
593 * @brief 576 * @brief
@@ -669,6 +652,28 @@ EAPI double ephysics_world_linear_slop_get(EPhysics_World *world);
669typedef struct _EPhysics_Body EPhysics_Body; /**< Body handle, represents an object on EPhysics world. Created with @ref ephysics_body_circle_add() or @ref ephysics_body_box_add() and deleted with @ref ephysics_body_del(). */ 652typedef struct _EPhysics_Body EPhysics_Body; /**< Body handle, represents an object on EPhysics world. Created with @ref ephysics_body_circle_add() or @ref ephysics_body_box_add() and deleted with @ref ephysics_body_del(). */
670 653
671/** 654/**
655 * @enum _EPhysics_Callback_Body_Type
656 * @typedef EPhysics_Callback_Body_Type
657 *
658 * Identifier of callbacks to be set for EPhysics bodies.
659 *
660 * @see ephysics_body_event_callback_add()
661 * @see ephysics_body_event_callback_del()
662 * @see ephysics_body_event_callback_del_full()
663 *
664 * @ingroup EPhysics_Body
665 */
666typedef enum _EPhysics_Callback_Body_Type
667{
668 EPHYSICS_CALLBACK_BODY_UPDATE, /**< Body being updated */
669 EPHYSICS_CALLBACK_BODY_COLLISION, /**< Body collided with other body */
670 EPHYSICS_CALLBACK_BODY_DEL, /**< Body being deleted (called before free) */
671 EPHYSICS_CALLBACK_BODY_STOPPED, /**< Body is not moving any more */
672 EPHYSICS_CALLBACK_BODY_LAST, /**< kept as sentinel, not really an event */
673} EPhysics_Callback_Body_Type; /**< The types of events triggering a callback */
674
675
676/**
672 * @typedef EPhysics_Body_Event_Cb 677 * @typedef EPhysics_Body_Event_Cb
673 * 678 *
674 * EPhysics bode event callback function signature. 679 * EPhysics bode event callback function signature.
@@ -1049,7 +1054,7 @@ EAPI void ephysics_body_evas_object_update(EPhysics_Body *body);
1049 * 1054 *
1050 * @ingroup EPhysics_Body 1055 * @ingroup EPhysics_Body
1051 */ 1056 */
1052EAPI void ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callback_Type type, EPhysics_Body_Event_Cb func, const void *data); 1057EAPI void ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, const void *data);
1053 1058
1054/** 1059/**
1055 * @brief 1060 * @brief
@@ -1070,7 +1075,7 @@ EAPI void ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callbac
1070 * 1075 *
1071 * @ingroup EPhysics_Body 1076 * @ingroup EPhysics_Body
1072 */ 1077 */
1073EAPI void *ephysics_body_event_callback_del(EPhysics_Body *body, EPhysics_Callback_Type type, EPhysics_Body_Event_Cb func); 1078EAPI void *ephysics_body_event_callback_del(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func);
1074 1079
1075/** 1080/**
1076 * @brief 1081 * @brief
@@ -1092,7 +1097,7 @@ EAPI void *ephysics_body_event_callback_del(EPhysics_Body *body, EPhysics_Callba
1092 * 1097 *
1093 * @ingroup EPhysics_Body 1098 * @ingroup EPhysics_Body
1094 */ 1099 */
1095EAPI void *ephysics_body_event_callback_del_full(EPhysics_Body *body, EPhysics_Callback_Type type, EPhysics_Body_Event_Cb func, void *data); 1100EAPI void *ephysics_body_event_callback_del_full(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, void *data);
1096 1101
1097/** 1102/**
1098 * @brief 1103 * @brief
diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp
index ba35db5721..b179c3a14e 100644
--- a/legacy/ephysics/src/lib/ephysics_body.cpp
+++ b/legacy/ephysics/src/lib/ephysics_body.cpp
@@ -18,7 +18,7 @@ struct _EPhysics_Body_Callback {
18 EINA_INLIST; 18 EINA_INLIST;
19 void (*func) (void *data, EPhysics_Body *body, void *event_info); 19 void (*func) (void *data, EPhysics_Body *body, void *event_info);
20 void *data; 20 void *data;
21 EPhysics_Callback_Type type; 21 EPhysics_Callback_Body_Type type;
22}; 22};
23 23
24struct _EPhysics_Body { 24struct _EPhysics_Body {
@@ -560,7 +560,7 @@ ephysics_body_evas_object_update(EPhysics_Body *body)
560} 560}
561 561
562EAPI void 562EAPI void
563ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callback_Type type, EPhysics_Body_Event_Cb func, const void *data) 563ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, const void *data)
564{ 564{
565 EPhysics_Body_Callback *cb; 565 EPhysics_Body_Callback *cb;
566 566
@@ -576,8 +576,7 @@ ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callback_Type typ
576 return; 576 return;
577 } 577 }
578 578
579 if ((type <= EPHYSICS_CALLBACK_BODY_FIRST) || 579 if ((type < 0) || (type >= EPHYSICS_CALLBACK_BODY_LAST))
580 (type >= EPHYSICS_CALLBACK_BODY_LAST))
581 { 580 {
582 ERR("Can't set body event callback, callback type is wrong."); 581 ERR("Can't set body event callback, callback type is wrong.");
583 return; 582 return;
@@ -598,7 +597,7 @@ ephysics_body_event_callback_add(EPhysics_Body *body, EPhysics_Callback_Type typ
598} 597}
599 598
600EAPI void * 599EAPI void *
601ephysics_body_event_callback_del(EPhysics_Body *body, EPhysics_Callback_Type type, EPhysics_Body_Event_Cb func) 600ephysics_body_event_callback_del(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func)
602{ 601{
603 EPhysics_Body_Callback *cb; 602 EPhysics_Body_Callback *cb;
604 void *cb_data; 603 void *cb_data;
@@ -624,7 +623,7 @@ ephysics_body_event_callback_del(EPhysics_Body *body, EPhysics_Callback_Type typ
624} 623}
625 624
626EAPI void * 625EAPI void *
627ephysics_body_event_callback_del_full(EPhysics_Body *body, EPhysics_Callback_Type type, EPhysics_Body_Event_Cb func, void *data) 626ephysics_body_event_callback_del_full(EPhysics_Body *body, EPhysics_Callback_Body_Type type, EPhysics_Body_Event_Cb func, void *data)
628{ 627{
629 EPhysics_Body_Callback *cb; 628 EPhysics_Body_Callback *cb;
630 void *cb_data; 629 void *cb_data;
diff --git a/legacy/ephysics/src/lib/ephysics_world.cpp b/legacy/ephysics/src/lib/ephysics_world.cpp
index 0eafe47b81..c50a372bd0 100644
--- a/legacy/ephysics/src/lib/ephysics_world.cpp
+++ b/legacy/ephysics/src/lib/ephysics_world.cpp
@@ -16,7 +16,7 @@ struct _EPhysics_World_Callback {
16 EINA_INLIST; 16 EINA_INLIST;
17 void (*func) (void *data, EPhysics_World *world, void *event_info); 17 void (*func) (void *data, EPhysics_World *world, void *event_info);
18 void *data; 18 void *data;
19 EPhysics_Callback_Type type; 19 EPhysics_Callback_World_Type type;
20}; 20};
21 21
22struct _EPhysics_World { 22struct _EPhysics_World {
@@ -529,7 +529,7 @@ ephysics_world_camera_get(const EPhysics_World *world)
529} 529}
530 530
531EAPI void 531EAPI void
532ephysics_world_event_callback_add(EPhysics_World *world, EPhysics_Callback_Type type, EPhysics_World_Event_Cb func, const void *data) 532ephysics_world_event_callback_add(EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func, const void *data)
533{ 533{
534 EPhysics_World_Callback *cb; 534 EPhysics_World_Callback *cb;
535 535
@@ -545,8 +545,7 @@ ephysics_world_event_callback_add(EPhysics_World *world, EPhysics_Callback_Type
545 return; 545 return;
546 } 546 }
547 547
548 if ((type <= EPHYSICS_CALLBACK_WORLD_FIRST) || 548 if ((type < 0) || (type >= EPHYSICS_CALLBACK_WORLD_LAST))
549 (type >= EPHYSICS_CALLBACK_WORLD_LAST))
550 { 549 {
551 ERR("Can't set world event callback, callback type is wrong."); 550 ERR("Can't set world event callback, callback type is wrong.");
552 return; 551 return;
@@ -567,7 +566,7 @@ ephysics_world_event_callback_add(EPhysics_World *world, EPhysics_Callback_Type
567} 566}
568 567
569EAPI void * 568EAPI void *
570ephysics_world_event_callback_del(EPhysics_World *world, EPhysics_Callback_Type type, EPhysics_World_Event_Cb func) 569ephysics_world_event_callback_del(EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func)
571{ 570{
572 EPhysics_World_Callback *cb; 571 EPhysics_World_Callback *cb;
573 void *cb_data; 572 void *cb_data;
@@ -593,7 +592,7 @@ ephysics_world_event_callback_del(EPhysics_World *world, EPhysics_Callback_Type
593} 592}
594 593
595EAPI void * 594EAPI void *
596ephysics_world_event_callback_del_full(EPhysics_World *world, EPhysics_Callback_Type type, EPhysics_World_Event_Cb func, void *data) 595ephysics_world_event_callback_del_full(EPhysics_World *world, EPhysics_Callback_World_Type type, EPhysics_World_Event_Cb func, void *data)
597{ 596{
598 EPhysics_World_Callback *cb; 597 EPhysics_World_Callback *cb;
599 void *cb_data; 598 void *cb_data;