forked from enlightenment/efl
EPhysics: add data setter / getter for bodies
Useful when you need structures per bodies to be updated on collision callbacks. SVN revision: 74495
This commit is contained in:
parent
7dc1e7b4b7
commit
564c23a80f
|
@ -1669,6 +1669,39 @@ EAPI void ephysics_body_linear_movement_enable_get(const EPhysics_Body *body, Ei
|
||||||
*/
|
*/
|
||||||
EAPI double ephysics_body_rotation_get(const EPhysics_Body *body);
|
EAPI double ephysics_body_rotation_get(const EPhysics_Body *body);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Set data to @p body.
|
||||||
|
*
|
||||||
|
* If a previous data was set, it's reference will be lost and body
|
||||||
|
* will point to the new data.
|
||||||
|
*
|
||||||
|
* It can be useful when you need to store a structure per body. For example,
|
||||||
|
* some values that must to be updated when a collision occurs between two
|
||||||
|
* bodies.
|
||||||
|
*
|
||||||
|
* @param body The physics body.
|
||||||
|
* @param data The data to be set.
|
||||||
|
*
|
||||||
|
* @see ephysics_body_data_get()
|
||||||
|
*
|
||||||
|
* @ingroup EPhysics_Body
|
||||||
|
*/
|
||||||
|
EAPI void ephysics_body_data_set(EPhysics_Body *body, void *data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Return data previously set to body.
|
||||||
|
*
|
||||||
|
* @param body The physics body.
|
||||||
|
* @return The data set or @c NULL on error.
|
||||||
|
*
|
||||||
|
* @see ephysics_body_data_get() for more details
|
||||||
|
*
|
||||||
|
* @ingroup EPhysics_Body
|
||||||
|
*/
|
||||||
|
EAPI void *ephysics_body_data_get(const EPhysics_Body *body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,6 +26,7 @@ struct _EPhysics_Body {
|
||||||
btRigidBody *rigid_body;
|
btRigidBody *rigid_body;
|
||||||
Evas_Object *evas_obj;
|
Evas_Object *evas_obj;
|
||||||
EPhysics_World *world;
|
EPhysics_World *world;
|
||||||
|
void *data;
|
||||||
Eina_Inlist *callbacks;
|
Eina_Inlist *callbacks;
|
||||||
double mass;
|
double mass;
|
||||||
Eina_Bool active:1;
|
Eina_Bool active:1;
|
||||||
|
@ -934,6 +935,30 @@ ephysics_body_rotation_get(const EPhysics_Body *body)
|
||||||
return rot;
|
return rot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
ephysics_body_data_set(EPhysics_Body *body, void *data)
|
||||||
|
{
|
||||||
|
if (!body)
|
||||||
|
{
|
||||||
|
ERR("Can't set data, body is null.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
body->data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void *
|
||||||
|
ephysics_body_data_get(const EPhysics_Body *body)
|
||||||
|
{
|
||||||
|
if (!body)
|
||||||
|
{
|
||||||
|
ERR("Can't get data, body is null.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return body->data;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue