edje: initial support to physics block inside

description

Only mass is set by now.



SVN revision: 80082
This commit is contained in:
Bruno Dilly 2012-12-03 16:36:32 +00:00
parent 71334e1a16
commit 9af2e7f69b
5 changed files with 127 additions and 7 deletions

View File

@ -96,6 +96,7 @@
* <li>@ref sec_collections_group_parts_items "Items"</li>
* </ul>
* <li>@ref sec_collections_group_parts_description_table "Table"</li>
* <li>@ref sec_collections_group_parts_description_physics "Physics"</li>
* <li>@ref sec_collections_group_parts_description_map "Map (3d/transformations)"</li>
* <ul>
* <li>@ref sec_collections_group_parts_description_map_rotation "Rotation"</li>
@ -308,6 +309,9 @@ static void st_collections_group_parts_part_description_table_homogeneous(void);
static void st_collections_group_parts_part_description_table_align(void);
static void st_collections_group_parts_part_description_table_padding(void);
static void st_collections_group_parts_part_description_table_min(void);
#ifdef HAVE_EPHYSICS
static void st_collections_group_parts_part_description_physics_mass(void);
#endif
static void st_collections_group_parts_part_description_map_perspective(void);
static void st_collections_group_parts_part_description_map_light(void);
static void st_collections_group_parts_part_description_map_rotation_center(void);
@ -588,6 +592,9 @@ New_Statement_Handler statement_handlers[] =
{"collections.group.parts.part.description.table.align", st_collections_group_parts_part_description_table_align},
{"collections.group.parts.part.description.table.padding", st_collections_group_parts_part_description_table_padding},
{"collections.group.parts.part.description.table.min", st_collections_group_parts_part_description_table_min},
#ifdef HAVE_EPHYSICS
{"collections.group.parts.part.description.physics.mass", st_collections_group_parts_part_description_physics_mass},
#endif
{"collections.group.parts.part.description.map.perspective", st_collections_group_parts_part_description_map_perspective},
{"collections.group.parts.part.description.map.light", st_collections_group_parts_part_description_map_light},
{"collections.group.parts.part.description.map.rotation.center", st_collections_group_parts_part_description_map_rotation_center},
@ -833,6 +840,9 @@ New_Object_Handler object_handlers[] =
{"collections.group.parts.part.description.styles.style", ob_styles_style}, /* dup */
{"collections.group.parts.part.description.box", NULL},
{"collections.group.parts.part.description.table", NULL},
#ifdef HAVE_EPHYSICS
{"collections.group.parts.part.description.physics", NULL},
#endif
{"collections.group.parts.part.description.map", NULL},
{"collections.group.parts.part.description.map.rotation", NULL},
{"collections.group.parts.part.description.perspective", NULL},
@ -1072,6 +1082,10 @@ _edje_part_description_alloc(unsigned char type, const char *collection, const c
exit(-1);
}
#ifdef HAVE_EPHYSICS
result->physics.mass = FROM_DOUBLE(1.0);
#endif
return result;
}
@ -3328,7 +3342,6 @@ st_collections_group_parts_part_type(void)
current_part->type = type;
}
#ifdef HAVE_EPHYSICS
/**
@page edcref
@property
@ -3355,6 +3368,7 @@ st_collections_group_parts_part_type(void)
@endproperty
@since 1.8.0
*/
#ifdef HAVE_EPHYSICS
static void
st_collections_group_parts_part_physics_body(void)
{
@ -7145,6 +7159,49 @@ st_collections_group_parts_part_description_table_min(void)
ed->table.min.v = parse_bool(1);
}
/**
@edcsubsection{collections_group_parts_description_physics,Physics}
*/
/**
@page edcref
@block
physics
@context
description {
..
physics {
mass: 5.31;
}
..
}
@description
@endblock
@property
mass
@parameters
[body's mass in kilograms]
@effect
Double value used to set inertial mass of the body.
It is a quantitative measure of an object's resistance to the change of
its speed. If mass is set to 0 the body will have infinite mass,
so it will be immovable, static.
@endproperty
@since 1.8.0
*/
#ifdef HAVE_EPHYSICS
static void
st_collections_group_parts_part_description_physics_mass(void)
{
check_arg_count(1);
current_desc->physics.mass = parse_float(0);
}
#endif
/**
@edcsubsection{collections_group_parts_description_map,Map}
*/

View File

@ -31,6 +31,16 @@ collections {
rel1.relative: 0.55 0.1;
rel2.relative: 0.75 0.3;
aspect: 1 1;
physics {
mass: 10.8;
}
}
description {
state: "light" 0.0;
inherit: "default" 0.0;
physics {
mass: 6.66;
}
}
}
@ -60,5 +70,16 @@ collections {
}
}
programs {
program {
name: "load";
signal: "load";
in: 2 0;
action: STATE_SET "light" 0.0;
transition: LINEAR 0.5;
target: "red_box";
}
}
}
}

View File

@ -2289,6 +2289,9 @@ _edje_part_recalc_single(Edje *ed,
break;
}
#ifdef HAVE_EPHYSICS
params->physics.mass = desc->physics.mass;
#endif
_edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params);
}
@ -2802,6 +2805,11 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
p3->color.b = INTP(p1->color.b, p2->color.b, pos2);
p3->color.a = INTP(p1->color.a, p2->color.a, pos2);
#ifdef HAVE_EPHYSICS
p3->physics.mass = TO_DOUBLE(FINTP(p1->physics.mass, p2->physics.mass,
pos));
#endif
switch (part_type)
{
case EDJE_PART_TYPE_IMAGE:
@ -2992,6 +3000,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
NULL, NULL, NULL);
ephysics_body_move(ep->body,
ed->x + pf->x, ed->y + pf->y, z);
ephysics_body_mass_set(ep->body, pf->physics.mass);
}
else
#endif

View File

@ -451,8 +451,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "d", d, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "s", s, EET_T_STRING);
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(Edd, Type) \
{ \
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_FIELDS(Edd, Type) \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", state.name, EET_T_STRING); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", state.value, EET_T_DOUBLE); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", visible, EET_T_CHAR); \
@ -508,11 +507,22 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.persp_on", map.persp_on, EET_T_UCHAR); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", map.backcull, EET_T_UCHAR); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", persp.zplane, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", persp.focal, EET_T_INT); \
}
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", persp.focal, EET_T_INT);
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(Edd, Type, Dec) \
{ \
#ifdef HAVE_EPHYSICS
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(Edd, Type) \
{ \
EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_FIELDS(Edd, Type) \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.mass", physics.mass, EET_T_DOUBLE); \
}
#else
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(Edd, Type) \
{ \
EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_FIELDS(Edd, Type) \
}
#endif
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB_FIELDS(Edd, Type, Dec) \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", Dec.state.name, EET_T_STRING); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", Dec.state.value, EET_T_DOUBLE); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", Dec.visible, EET_T_CHAR); \
@ -563,7 +573,19 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", Dec.map.backcull, EET_T_UCHAR); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", Dec.persp.zplane, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", Dec.persp.focal, EET_T_INT); \
#ifdef HAVE_EPHYSICS
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(Edd, Type, Dec) \
{ \
EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB_FIELDS(Edd, Type, Dec) \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.mass", Dec.physics.mass, EET_T_DOUBLE); \
}
#else
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(Edd, Type, Dec) \
{ \
EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB_FIELDS(Edd, Type, Dec) \
}
#endif
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common);
eddc.func.mem_free = mem_free_rectangle;

View File

@ -958,6 +958,12 @@ struct _Edje_Part_Description_Common
int focal;
} persp;
#ifdef HAVE_EPHYSICS
struct {
double mass;
} physics;
#endif
unsigned char visible; /* is it shown */
unsigned char limit; /* 0 == no, 1 = width, 2 = height, 3 = both */
};
@ -1286,6 +1292,11 @@ struct _Edje_Calc_Params
int focal;
} persp;
} map;
#ifdef HAVE_EPHYSICS
struct {
double mass; // 8
} physics; // 8
#endif
unsigned char persp_on : 1;
unsigned char lighted : 1;
unsigned char mapped : 1;