forked from enlightenment/efl
ephysics: improve body struct readability a bit
Actually ephysics body deserves a redesign, since it differs a lot between types. It wasn't previewed. SVN revision: 79038
This commit is contained in:
parent
5d465e1c04
commit
560c3e6fa8
|
@ -895,9 +895,9 @@ _ephysics_body_resize(EPhysics_Body *body, Evas_Coord w, Evas_Coord h, Evas_Coor
|
|||
_ephysics_body_mass_set(body, ephysics_body_mass_get(body));
|
||||
}
|
||||
|
||||
body->w = w;
|
||||
body->h = h;
|
||||
body->d = d;
|
||||
body->size.w = w;
|
||||
body->size.h = h;
|
||||
body->size.d = d;
|
||||
|
||||
ephysics_body_activate(body, EINA_TRUE);
|
||||
|
||||
|
@ -917,9 +917,9 @@ _ephysics_body_move(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Evas_Coord
|
|||
NULL, &height, NULL);
|
||||
height += wy;
|
||||
|
||||
mx = (x + body->w * body->cm.x) / rate;
|
||||
my = (height - (y + body->h * body->cm.y)) / rate;
|
||||
mz = (z + body->d * body->cm.z) / rate;
|
||||
mx = (x + body->size.w * body->cm.x) / rate;
|
||||
my = (height - (y + body->size.h * body->cm.y)) / rate;
|
||||
mz = (z + body->size.d * body->cm.z) / rate;
|
||||
|
||||
trans = _ephysics_body_transform_get(body);
|
||||
trans.setOrigin(btVector3(mx, my, mz));
|
||||
|
@ -986,9 +986,9 @@ _ephysics_body_geometry_set(EPhysics_Body *body, Evas_Coord x, Evas_Coord y, Eva
|
|||
_ephysics_body_transform_set(body, trans);
|
||||
ephysics_body_activate(body, EINA_TRUE);
|
||||
|
||||
body->w = w;
|
||||
body->h = h;
|
||||
body->d = d;
|
||||
body->size.w = w;
|
||||
body->size.h = h;
|
||||
body->size.d = d;
|
||||
body->scale = body_scale;
|
||||
|
||||
DBG("Body %p position changed to (%lf, %lf, %lf).", body, mx, my, mz);
|
||||
|
@ -1002,12 +1002,12 @@ _ephysics_body_evas_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *o
|
|||
int w, h;
|
||||
|
||||
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
||||
if ((w == body->w) && (h == body->h))
|
||||
if ((w == body->size.w) && (h == body->size.h))
|
||||
return;
|
||||
|
||||
DBG("Resizing body %p to w=%i, h=%i, d=%i", body, w, h, body->d);
|
||||
DBG("Resizing body %p to w=%i, h=%i, d=%i", body, w, h, body->size.d);
|
||||
ephysics_world_lock_take(body->world);
|
||||
_ephysics_body_resize(body, w, h, body->d);
|
||||
_ephysics_body_resize(body, w, h, body->size.d);
|
||||
ephysics_world_lock_release(body->world);
|
||||
}
|
||||
|
||||
|
@ -2485,9 +2485,9 @@ ephysics_body_geometry_get(const EPhysics_Body *body, Evas_Coord *x, Evas_Coord
|
|||
if (y) *y = height - round((trans.getOrigin().getY() + scale.y() / 2)
|
||||
* rate);
|
||||
if (z) *z = round((trans.getOrigin().getZ() - scale.z() / 2) * rate);
|
||||
if (w) *w = body->w;
|
||||
if (h) *h = body->h;
|
||||
if (d) *d = body->d;
|
||||
if (w) *w = body->size.w;
|
||||
if (h) *h = body->size.h;
|
||||
if (d) *d = body->size.d;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
|
|
@ -48,7 +48,11 @@ extern "C" {
|
|||
|
||||
#define RAD_TO_DEG 57.29582 /* 2 * pi radians == 360 degree */
|
||||
|
||||
typedef struct _EPhysics_Force EPhysics_Force;
|
||||
typedef struct _EPhysics_Body_Center_Mass EPhysics_Body_Center_Mass;
|
||||
typedef struct _EPhysics_Body_Size EPhysics_Body_Size;
|
||||
typedef struct _EPhysics_Point EPhysics_Point;
|
||||
typedef struct _EPhysics_Dragging_Data EPhysics_Dragging_Data;
|
||||
typedef struct _EPhysics_Body_Soft_Body_Data EPhysics_Body_Soft_Body_Data;
|
||||
|
||||
typedef enum _EPhysics_World_Boundary
|
||||
|
@ -62,6 +66,13 @@ typedef enum _EPhysics_World_Boundary
|
|||
EPHYSICS_WORLD_BOUNDARY_LAST
|
||||
} EPhysics_World_Boundary;
|
||||
|
||||
typedef enum _EPhysics_Body_Type
|
||||
{
|
||||
EPHYSICS_BODY_TYPE_RIGID,
|
||||
EPHYSICS_BODY_TYPE_SOFT,
|
||||
EPHYSICS_BODY_TYPE_CLOTH,
|
||||
} EPhysics_Body_Type;
|
||||
|
||||
struct _EPhysics_Point {
|
||||
EINA_INLIST;
|
||||
double x;
|
||||
|
@ -69,12 +80,32 @@ struct _EPhysics_Point {
|
|||
double z;
|
||||
};
|
||||
|
||||
typedef enum _EPhysics_Body_Type
|
||||
{
|
||||
EPHYSICS_BODY_TYPE_RIGID,
|
||||
EPHYSICS_BODY_TYPE_SOFT,
|
||||
EPHYSICS_BODY_TYPE_CLOTH,
|
||||
} EPhysics_Body_Type;
|
||||
struct _EPhysics_Force {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
double torque_x;
|
||||
double torque_y;
|
||||
double torque_z;
|
||||
};
|
||||
|
||||
struct _EPhysics_Dragging_Data {
|
||||
int triangle;
|
||||
double mass[3];
|
||||
Eina_Bool dragging:1;
|
||||
};
|
||||
|
||||
struct _EPhysics_Body_Center_Mass {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
};
|
||||
|
||||
struct _EPhysics_Body_Size {
|
||||
Evas_Coord w;
|
||||
Evas_Coord h;
|
||||
Evas_Coord d;
|
||||
};
|
||||
|
||||
struct _EPhysics_Body {
|
||||
EINA_INLIST;
|
||||
|
@ -84,9 +115,7 @@ struct _EPhysics_Body {
|
|||
Evas_Object *evas_obj;
|
||||
EPhysics_World *world;
|
||||
int walking;
|
||||
Evas_Coord w;
|
||||
Evas_Coord h;
|
||||
Evas_Coord d;
|
||||
EPhysics_Body_Size size;
|
||||
btVector3 scale;
|
||||
void *data;
|
||||
Eina_Inlist *callbacks;
|
||||
|
@ -96,19 +125,8 @@ struct _EPhysics_Body {
|
|||
EPhysics_Body_Material material;
|
||||
double mass;
|
||||
double density;
|
||||
struct {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
double torque_x;
|
||||
double torque_y;
|
||||
double torque_z;
|
||||
} force;
|
||||
struct {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
} cm;
|
||||
EPhysics_Force force;
|
||||
EPhysics_Body_Center_Mass cm;
|
||||
int slices;
|
||||
int *points_deform;
|
||||
EPhysics_Body_Type type;
|
||||
|
@ -117,11 +135,7 @@ struct _EPhysics_Body {
|
|||
int material_index;
|
||||
int collision_cb;
|
||||
EPhysics_Body_Soft_Body_Data *soft_data;
|
||||
struct {
|
||||
int triangle;
|
||||
double mass[3];
|
||||
Eina_Bool dragging;
|
||||
} dragging_data;
|
||||
EPhysics_Dragging_Data dragging_data;
|
||||
|
||||
Eina_Bool active:1;
|
||||
Eina_Bool deleted:1;
|
||||
|
|
Loading…
Reference in New Issue