edje: add flag to set parts to be lighted

Won't be visible until world's light is implemented



SVN revision: 80605
This commit is contained in:
Bruno Dilly 2012-12-10 12:51:53 +00:00
parent 9bd842922e
commit 3de757a6d5
8 changed files with 92 additions and 21 deletions

View File

@ -217,7 +217,9 @@ enum State_Param
STATE_PHYSICS_DAMPING = 46,
STATE_PHYSICS_SLEEP = 47,
STATE_PHYSICS_MATERIAL = 48,
STATE_PHYSICS_DENSITY = 49
STATE_PHYSICS_DENSITY = 49,
STATE_PHYSICS_IGNORE_PART_POS = 50,
STATE_PHYSICS_LIGHT_ON = 51
};
native set_state_val(part_id, State_Param:p, ...);

View File

@ -317,7 +317,8 @@ 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);
static void st_collections_group_parts_part_description_physics_ignore_part_pos(void);
static void st_collections_group_parts_part_description_physics_light_on(void);
#endif
static void st_collections_group_parts_part_description_map_perspective(void);
static void st_collections_group_parts_part_description_map_light(void);
@ -607,7 +608,8 @@ New_Statement_Handler statement_handlers[] =
{"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},
{"collections.group.parts.part.description.physics.ignore_part_pos", st_collections_group_parts_part_description_physics_ignore_part_pos},
{"collections.group.parts.part.description.physics.light_on", st_collections_group_parts_part_description_physics_light_on},
#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},
@ -1101,7 +1103,7 @@ _edje_part_description_alloc(unsigned char type, const char *collection, const c
result->physics.friction = FROM_DOUBLE(0.5);
result->physics.sleep.linear = FROM_DOUBLE(24);
result->physics.sleep.angular = FROM_DOUBLE(57.29);
result->physics.ignore_part_position = 1;
result->physics.ignore_part_pos = 1;
#endif
return result;
@ -7191,7 +7193,7 @@ st_collections_group_parts_part_description_table_min(void)
description {
..
physics {
ignore_part_position: 1;
ignore_part_pos: 1;
mass: 5.31;
friction: 0.5;
restitution: 0.82;
@ -7199,6 +7201,7 @@ st_collections_group_parts_part_description_table_min(void)
sleep: 32 18.9;
material: IRON;
density: 3.2;
light_on: 1;
}
..
}
@ -7292,7 +7295,7 @@ st_collections_group_parts_part_description_physics_friction(void)
/**
@page edcref
@property
ignore_part_position
ignore_part_pos
@parameters
[1 or 0]
@effect
@ -7306,11 +7309,11 @@ st_collections_group_parts_part_description_physics_friction(void)
*/
#ifdef HAVE_EPHYSICS
static void
st_collections_group_parts_part_description_physics_ignore_part_position(void)
st_collections_group_parts_part_description_physics_ignore_part_pos(void)
{
check_arg_count(1);
current_desc->physics.ignore_part_position = parse_bool(0);
current_desc->physics.ignore_part_pos = parse_bool(0);
}
#endif
@ -7438,6 +7441,30 @@ st_collections_group_parts_part_description_physics_density(void)
}
#endif
/**
@page edcref
@property
light_on
@parameters
[1 or 0]
@effect
Set body to be affected by world's light or not.
It won't be respected if world's property "all_bodies" is enabled.
Disabled by default (0).
@endproperty
@since 1.8.0
*/
#ifdef HAVE_EPHYSICS
static void
st_collections_group_parts_part_description_physics_light_on(void)
{
check_arg_count(1);
current_desc->physics.light_on = parse_bool(0);
}
#endif
/**
@edcsubsection{collections_group_parts_description_map,Map}
*/

View File

@ -457,6 +457,7 @@ collections {
script {
new Float: mass, Float:rest, Float:fric;
new Float: linear, Float:angular;
new val;
custom_state(PART:"red_circle", "default", 0.0);
set_state_val(PART:"red_circle", STATE_COLOR, 0, 0, 0, 255);
@ -467,6 +468,9 @@ collections {
0.1);
set_state_val(PART:"red_circle", STATE_PHYSICS_SLEEP, 34.1,
12.83);
set_state_val(PART:"red_circle", STATE_PHYSICS_LIGHT_ON, 1);
set_state_val(PART:"red_circle",
STATE_PHYSICS_IGNORE_PART_POS, 1);
set_state(PART:"red_circle", "custom", 0.0);
get_state_val(PART:"red_circle", STATE_PHYSICS_MASS, mass);
@ -487,6 +491,13 @@ collections {
linear, angular);
send_message(MSG_STRING_FLOAT_SET, 1, "Sleep", linear,
angular);
get_state_val(PART:"red_circle", STATE_PHYSICS_LIGHT_ON, val);
send_message(MSG_STRING_INT, 1, "Light On", val);
get_state_val(PART:"red_circle",
STATE_PHYSICS_IGNORE_PART_POS, val);
send_message(MSG_STRING_INT, 1, "Ignore Part Pos", val);
}
}

View File

@ -34,6 +34,7 @@ collections {
mass: 10.8;
restitution: 0.85;
friction: 1.0;
light_on: 1;
}
}
description {
@ -79,7 +80,7 @@ collections {
normal: "bubble-blue.png";
}
physics {
ignore_part_position: 0;
ignore_part_pos: 0;
material: IRON;
}
}

View File

@ -2305,7 +2305,8 @@ _edje_part_recalc_single(Edje *ed,
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;
params->physics.ignore_part_pos = desc->physics.ignore_part_pos;
params->physics.light_on = desc->physics.light_on;
#endif
_edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params);
}
@ -2498,6 +2499,7 @@ _edje_physics_body_props_update(Edje_Real_Part *ep, Edje_Calc_Params *pf, Eina_B
pf->physics.damping.angular);
ephysics_body_sleeping_threshold_set(ep->body, pf->physics.sleep.linear,
pf->physics.sleep.angular);
ephysics_body_light_set(ep->body, pf->physics.light_on);
}
static void
@ -2962,15 +2964,17 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
p3->physics.sleep.angular = TO_DOUBLE(FINTP(
p1->physics.sleep.angular, p2->physics.sleep.angular, pos));
if ((p1->ignore_part_position) && (p2->ignore_part_position))
p3->ignore_part_position = 1;
if ((p1->physics.ignore_part_pos) && (p2->physics.ignore_part_pos))
p3->physics.ignore_part_pos = 1;
else
p3->ignore_part_position = 0;
p3->physics.ignore_part_pos = 0;
if ((p1->physics.material) && (p2->physics.material))
p3->physics.material = p1->physics.material;
else
p3->physics.material = EPHYSICS_BODY_MATERIAL_CUSTOM;
p3->physics.light_on = p1->physics.light_on || p2->physics.light_on;
#endif
switch (part_type)
@ -3180,8 +3184,8 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
if (((ep->prev_description) &&
(chosen_desc != ep->prev_description)) ||
(pf != p1))
_edje_physics_body_props_update(ep, pf,
!pf->ignore_part_position);
_edje_physics_body_props_update(
ep, pf, !pf->physics.ignore_part_pos);
}
else
#endif

View File

@ -528,7 +528,8 @@ _edje_edd_init(void)
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); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.ignore_part_pos", physics.ignore_part_pos, EET_T_UCHAR); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.light_on", physics.light_on, EET_T_UCHAR); \
}
#else
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(Edd, Type) \
@ -602,7 +603,8 @@ _edje_edd_init(void)
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); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.ignore_part_pos", Dec.physics.ignore_part_pos, EET_T_UCHAR); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "physics.light_on", Dec.physics.light_on, EET_T_UCHAR); \
}
#else
#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(Edd, Type, Dec) \

View File

@ -2302,6 +2302,16 @@ _edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params)
GETFLOAT_T(rp->custom->description->physics.density, params[3]);
break;
case EDJE_STATE_PARAM_PHYSICS_IGNORE_PART_POS:
CHKPARAM(3);
GETINT(rp->custom->description->physics.ignore_part_pos, params[3]);
break;
case EDJE_STATE_PARAM_PHYSICS_LIGHT_ON:
CHKPARAM(3);
GETINT(rp->custom->description->physics.light_on, params[3]);
break;
#endif
default:
break;
@ -2796,6 +2806,16 @@ _edje_embryo_fn_get_state_val(Embryo_Program *ep, Embryo_Cell *params)
SETFLOAT_T(rp->custom->description->physics.density, params[3]);
break;
case EDJE_STATE_PARAM_PHYSICS_IGNORE_PART_POS:
CHKPARAM(3);
SETINT(rp->custom->description->physics.ignore_part_pos, params[3]);
break;
case EDJE_STATE_PARAM_PHYSICS_LIGHT_ON:
CHKPARAM(3);
SETINT(rp->custom->description->physics.light_on, params[3]);
break;
#endif
default:
break;

View File

@ -421,7 +421,9 @@ typedef struct _Edje_Markup_Filter_Callback Edje_Markup_Filter_Callback;
#define EDJE_STATE_PARAM_PHYSICS_SLEEP 47
#define EDJE_STATE_PARAM_PHYSICS_MATERIAL 48
#define EDJE_STATE_PARAM_PHYSICS_DENSITY 49
#define EDJE_STATE_PARAM_LAST 50
#define EDJE_STATE_PARAM_PHYSICS_IGNORE_PART_POS 50
#define EDJE_STATE_PARAM_PHYSICS_LIGHT_ON 51
#define EDJE_STATE_PARAM_LAST 52
#define EDJE_ENTRY_EDIT_MODE_NONE 0
#define EDJE_ENTRY_EDIT_MODE_SELECTABLE 1
@ -987,7 +989,8 @@ struct _Edje_Part_Description_Common
double angular;
} sleep;
unsigned char material; /* (custom, iron, wood, ...) */
unsigned char ignore_part_position;
unsigned char light_on;
unsigned char ignore_part_pos;
} physics;
#endif
@ -1334,8 +1337,9 @@ struct _Edje_Calc_Params
double angular; //8
} sleep; // 16
unsigned char material; // 1
} physics; // 65
unsigned char ignore_part_position : 1; //1
unsigned char light_on; // 1
unsigned char ignore_part_pos; //1
} physics; // 67
#endif
unsigned char persp_on : 1;
unsigned char lighted : 1;