edje: make it possible to set body's material
And density as well. SVN revision: 80600
This commit is contained in:
parent
f96d02f8b3
commit
75ceec585a
|
@ -215,7 +215,9 @@ enum State_Param
|
|||
STATE_PHYSICS_FRICTION = 44,
|
||||
STATE_PHYSICS_RESTITUTION = 45,
|
||||
STATE_PHYSICS_DAMPING = 46,
|
||||
STATE_PHYSICS_SLEEP = 47
|
||||
STATE_PHYSICS_SLEEP = 47,
|
||||
STATE_PHYSICS_MATERIAL = 48,
|
||||
STATE_PHYSICS_DENSITY = 49
|
||||
};
|
||||
|
||||
native set_state_val(part_id, State_Param:p, ...);
|
||||
|
|
|
@ -315,6 +315,8 @@ static void st_collections_group_parts_part_description_physics_restitution(void
|
|||
static void st_collections_group_parts_part_description_physics_friction(void);
|
||||
static void st_collections_group_parts_part_description_physics_damping(void);
|
||||
static void st_collections_group_parts_part_description_physics_sleep(void);
|
||||
static void st_collections_group_parts_part_description_physics_material(void);
|
||||
static void st_collections_group_parts_part_description_physics_density(void);
|
||||
static void st_collections_group_parts_part_description_physics_ignore_part_position(void);
|
||||
#endif
|
||||
static void st_collections_group_parts_part_description_map_perspective(void);
|
||||
|
@ -603,6 +605,8 @@ New_Statement_Handler statement_handlers[] =
|
|||
{"collections.group.parts.part.description.physics.friction", st_collections_group_parts_part_description_physics_friction},
|
||||
{"collections.group.parts.part.description.physics.damping", st_collections_group_parts_part_description_physics_damping},
|
||||
{"collections.group.parts.part.description.physics.sleep", st_collections_group_parts_part_description_physics_sleep},
|
||||
{"collections.group.parts.part.description.physics.material", st_collections_group_parts_part_description_physics_material},
|
||||
{"collections.group.parts.part.description.physics.density", st_collections_group_parts_part_description_physics_density},
|
||||
{"collections.group.parts.part.description.physics.ignore_part_position", st_collections_group_parts_part_description_physics_ignore_part_position},
|
||||
#endif
|
||||
{"collections.group.parts.part.description.map.perspective", st_collections_group_parts_part_description_map_perspective},
|
||||
|
@ -7193,6 +7197,8 @@ st_collections_group_parts_part_description_table_min(void)
|
|||
restitution: 0.82;
|
||||
damping: 0.4 0.24;
|
||||
sleep: 32 18.9;
|
||||
material: IRON;
|
||||
density: 3.2;
|
||||
}
|
||||
..
|
||||
}
|
||||
|
@ -7367,6 +7373,71 @@ st_collections_group_parts_part_description_physics_sleep(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
@property
|
||||
material
|
||||
@parameters
|
||||
[body's material]
|
||||
@effect
|
||||
Set the type (all caps) from among the available material types,
|
||||
it's set to CUSTOM by default.
|
||||
Each material has specific properties to be
|
||||
applied on the body, as density, friction and restitution.
|
||||
So if a material different of CUSTOM is set, the properties cited above
|
||||
won't be considered.
|
||||
Valid types:
|
||||
* CUSTOM
|
||||
* CONCRETE
|
||||
* IRON
|
||||
* PLASTIC
|
||||
* POLYSTYRENE
|
||||
* RUBBER
|
||||
* WOOD
|
||||
@endproperty
|
||||
@since 1.8.0
|
||||
*/
|
||||
#ifdef HAVE_EPHYSICS
|
||||
static void
|
||||
st_collections_group_parts_part_description_physics_material(void)
|
||||
{
|
||||
check_arg_count(1);
|
||||
|
||||
current_desc->physics.material = parse_enum(0,
|
||||
"CUSTOM", EPHYSICS_BODY_MATERIAL_CUSTOM,
|
||||
"CONCRETE", EPHYSICS_BODY_MATERIAL_CONCRETE,
|
||||
"IRON", EPHYSICS_BODY_MATERIAL_IRON,
|
||||
"PLASTIC", EPHYSICS_BODY_MATERIAL_PLASTIC,
|
||||
"POLYSTYRENE", EPHYSICS_BODY_MATERIAL_POLYSTYRENE,
|
||||
"RUBBER", EPHYSICS_BODY_MATERIAL_RUBBER,
|
||||
"WOOD", EPHYSICS_BODY_MATERIAL_WOOD,
|
||||
NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
@property
|
||||
density
|
||||
@parameters
|
||||
[body's material density]
|
||||
@effect
|
||||
It will set the body mass considering its volume. While a density is
|
||||
set, resizing a body will always recalculate its mass.
|
||||
When a mass is explicitely set the density will be unset.
|
||||
@endproperty
|
||||
@since 1.8.0
|
||||
*/
|
||||
#ifdef HAVE_EPHYSICS
|
||||
static void
|
||||
st_collections_group_parts_part_description_physics_density(void)
|
||||
{
|
||||
check_arg_count(1);
|
||||
|
||||
current_desc->physics.density = parse_float(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@edcsubsection{collections_group_parts_description_map,Map}
|
||||
*/
|
||||
|
|
|
@ -80,7 +80,7 @@ collections {
|
|||
}
|
||||
physics {
|
||||
ignore_part_position: 0;
|
||||
restitution: 0.6;
|
||||
material: IRON;
|
||||
}
|
||||
}
|
||||
description {
|
||||
|
@ -88,6 +88,10 @@ collections {
|
|||
inherit: "default" 0.0;
|
||||
rel1.relative: 0 0.1;
|
||||
rel2.relative: 0.25 0.3;
|
||||
physics {
|
||||
material: CUSTOM;
|
||||
density: 40;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2304,6 +2304,8 @@ _edje_part_recalc_single(Edje *ed,
|
|||
params->physics.damping.angular = desc->physics.damping.angular;
|
||||
params->physics.sleep.linear = desc->physics.sleep.linear;
|
||||
params->physics.sleep.angular = desc->physics.sleep.angular;
|
||||
params->physics.material = desc->physics.material;
|
||||
params->physics.density = desc->physics.density;
|
||||
params->ignore_part_position = desc->physics.ignore_part_position;
|
||||
#endif
|
||||
_edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params);
|
||||
|
@ -2476,11 +2478,23 @@ _edje_physics_body_props_update(Edje_Real_Part *ep, Edje_Calc_Params *pf, Eina_B
|
|||
ep->w = pf->w;
|
||||
ep->h = pf->h;
|
||||
}
|
||||
ephysics_body_mass_set(ep->body, pf->physics.mass);
|
||||
|
||||
ephysics_body_material_set(ep->body, pf->physics.material);
|
||||
if (!pf->physics.material)
|
||||
{
|
||||
if (pf->physics.density)
|
||||
ephysics_body_density_set(ep->body, pf->physics.density);
|
||||
else
|
||||
ephysics_body_mass_set(ep->body, pf->physics.mass);
|
||||
}
|
||||
}
|
||||
|
||||
if (!pf->physics.material)
|
||||
{
|
||||
ephysics_body_restitution_set(ep->body, pf->physics.restitution);
|
||||
ephysics_body_friction_set(ep->body, pf->physics.friction);
|
||||
}
|
||||
|
||||
ephysics_body_restitution_set(ep->body, pf->physics.restitution);
|
||||
ephysics_body_friction_set(ep->body, pf->physics.friction);
|
||||
ephysics_body_damping_set(ep->body, pf->physics.damping.linear,
|
||||
pf->physics.damping.angular);
|
||||
ephysics_body_sleeping_threshold_set(ep->body, pf->physics.sleep.linear,
|
||||
|
@ -2936,6 +2950,8 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
|
|||
pos));
|
||||
p3->physics.friction = TO_DOUBLE(FINTP(p1->physics.friction,
|
||||
p2->physics.friction, pos));
|
||||
p3->physics.density = TO_DOUBLE(FINTP(p1->physics.density,
|
||||
p2->physics.density, pos));
|
||||
|
||||
p3->physics.damping.linear = TO_DOUBLE(FINTP(
|
||||
p1->physics.damping.linear, p2->physics.damping.linear, pos));
|
||||
|
@ -2951,6 +2967,11 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
|
|||
p3->ignore_part_position = 1;
|
||||
else
|
||||
p3->ignore_part_position = 0;
|
||||
|
||||
if ((p1->physics.material) && (p2->physics.material))
|
||||
p3->physics.material = p1->physics.material;
|
||||
else
|
||||
p3->physics.material = EPHYSICS_BODY_MATERIAL_CUSTOM;
|
||||
#endif
|
||||
|
||||
switch (part_type)
|
||||
|
|
|
@ -526,6 +526,8 @@ _edje_edd_init(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.damping.angular", physics.damping.angular, EET_T_DOUBLE); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.sleep.linear", physics.sleep.linear, EET_T_DOUBLE); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.sleep.angular", physics.sleep.angular, EET_T_DOUBLE); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.material", physics.material, EET_T_UCHAR); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.density", physics.density, EET_T_DOUBLE); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.ignore_part_position", physics.ignore_part_position, EET_T_UCHAR); \
|
||||
}
|
||||
#else
|
||||
|
@ -598,6 +600,8 @@ _edje_edd_init(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.damping.angular", Dec.physics.damping.angular, EET_T_DOUBLE); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.sleep.linear", Dec.physics.sleep.linear, EET_T_DOUBLE); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.sleep.angular", Dec.physics.sleep.angular, EET_T_DOUBLE); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.material", Dec.physics.material, EET_T_UCHAR); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.density", Dec.physics.density, EET_T_DOUBLE); \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.ignore_part_position", Dec.physics.ignore_part_position, EET_T_UCHAR); \
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -2291,6 +2291,16 @@ _edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params)
|
|||
GETFLOAT_T(rp->custom->description->physics.sleep.linear, params[3]);
|
||||
GETFLOAT_T(rp->custom->description->physics.sleep.angular, params[4]);
|
||||
|
||||
break;
|
||||
case EDJE_STATE_PARAM_PHYSICS_MATERIAL:
|
||||
CHKPARAM(3);
|
||||
|
||||
GETINT(rp->custom->description->physics.material, params[3]);
|
||||
break;
|
||||
case EDJE_STATE_PARAM_PHYSICS_DENSITY:
|
||||
CHKPARAM(3);
|
||||
|
||||
GETFLOAT_T(rp->custom->description->physics.density, params[3]);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -2775,6 +2785,16 @@ _edje_embryo_fn_get_state_val(Embryo_Program *ep, Embryo_Cell *params)
|
|||
SETFLOAT_T(rp->custom->description->physics.sleep.linear, params[3]);
|
||||
SETFLOAT_T(rp->custom->description->physics.sleep.angular, params[4]);
|
||||
|
||||
break;
|
||||
case EDJE_STATE_PARAM_PHYSICS_MATERIAL:
|
||||
CHKPARAM(3);
|
||||
|
||||
SETINT(rp->custom->description->physics.material, params[3]);
|
||||
break;
|
||||
case EDJE_STATE_PARAM_PHYSICS_DENSITY:
|
||||
CHKPARAM(3);
|
||||
|
||||
SETFLOAT_T(rp->custom->description->physics.density, params[3]);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
|
|
@ -419,7 +419,9 @@ typedef struct _Edje_Markup_Filter_Callback Edje_Markup_Filter_Callback;
|
|||
#define EDJE_STATE_PARAM_PHYSICS_RESTITUTION 45
|
||||
#define EDJE_STATE_PARAM_PHYSICS_DAMPING 46
|
||||
#define EDJE_STATE_PARAM_PHYSICS_SLEEP 47
|
||||
#define EDJE_STATE_PARAM_LAST 48
|
||||
#define EDJE_STATE_PARAM_PHYSICS_MATERIAL 48
|
||||
#define EDJE_STATE_PARAM_PHYSICS_DENSITY 49
|
||||
#define EDJE_STATE_PARAM_LAST 50
|
||||
|
||||
#define EDJE_ENTRY_EDIT_MODE_NONE 0
|
||||
#define EDJE_ENTRY_EDIT_MODE_SELECTABLE 1
|
||||
|
@ -975,6 +977,7 @@ struct _Edje_Part_Description_Common
|
|||
double mass;
|
||||
double restitution;
|
||||
double friction;
|
||||
double density;
|
||||
struct {
|
||||
double linear;
|
||||
double angular;
|
||||
|
@ -983,6 +986,7 @@ struct _Edje_Part_Description_Common
|
|||
double linear;
|
||||
double angular;
|
||||
} sleep;
|
||||
unsigned char material; /* (custom, iron, wood, ...) */
|
||||
unsigned char ignore_part_position;
|
||||
} physics;
|
||||
#endif
|
||||
|
@ -1320,6 +1324,7 @@ struct _Edje_Calc_Params
|
|||
double mass; // 8
|
||||
double restitution; // 8
|
||||
double friction; // 8
|
||||
double density; // 8
|
||||
struct {
|
||||
double linear; //8
|
||||
double angular; //8
|
||||
|
@ -1328,8 +1333,9 @@ struct _Edje_Calc_Params
|
|||
double linear; //8
|
||||
double angular; //8
|
||||
} sleep; // 16
|
||||
} physics; // 56
|
||||
unsigned char ignore_part_position : 1;
|
||||
unsigned char material; // 1
|
||||
} physics; // 65
|
||||
unsigned char ignore_part_position : 1; //1
|
||||
#endif
|
||||
unsigned char persp_on : 1;
|
||||
unsigned char lighted : 1;
|
||||
|
|
Loading…
Reference in New Issue