edje: add group.physics block
For now, implements wold's gravity, rate, depth and z. More can be added later on demand. SVN revision: 80675
This commit is contained in:
parent
945a413b8c
commit
b1ae408585
|
@ -25,7 +25,7 @@ syn keyword cStructure part parts dragable description rel1 rel2
|
||||||
syn keyword cStatement text image font fill origin size tag
|
syn keyword cStatement text image font fill origin size tag
|
||||||
syn keyword cStructure programs program script script_only lua_script lua_script_only styles style base
|
syn keyword cStructure programs program script script_only lua_script lua_script_only styles style base
|
||||||
syn keyword cStructure spectra spectrum box
|
syn keyword cStructure spectra spectrum box
|
||||||
syn keyword cStructure physics movement_freedom faces face
|
syn keyword cStructure physics movement_freedom faces face world
|
||||||
syn match cType "+ + +;" contained
|
syn match cType "+ + +;" contained
|
||||||
|
|
||||||
syn keyword cLabel item name min max type effect
|
syn keyword cLabel item name min max type effect
|
||||||
|
@ -48,7 +48,7 @@ syn keyword cLabel external params size_range border_scale minmul
|
||||||
syn keyword cLabel mass density material restitution friction
|
syn keyword cLabel mass density material restitution friction
|
||||||
syn keyword cLabel ignore_part_pos light_on damping sleep
|
syn keyword cLabel ignore_part_pos light_on damping sleep
|
||||||
syn keyword cLabel physics_body hardness linear angular
|
syn keyword cLabel physics_body hardness linear angular
|
||||||
syn keyword cLabel backface_cull
|
syn keyword cLabel backface_cull gravity rate z depth
|
||||||
|
|
||||||
syn keyword cConditional if else switch
|
syn keyword cConditional if else switch
|
||||||
syn keyword cRepeat while for do
|
syn keyword cRepeat while for do
|
||||||
|
|
|
@ -114,6 +114,10 @@
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>@ref sec_collections_group_script "Script"</li>
|
* <li>@ref sec_collections_group_script "Script"</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
|
* <li>@ref sec_collections_group_physics "Physics"</li>
|
||||||
|
* <ul>
|
||||||
|
* <li>@ref sec_collections_group_physics_world "World"</li>
|
||||||
|
* </ul>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </ul>
|
* </ul>
|
||||||
|
@ -370,6 +374,13 @@ static void st_collections_group_sound_sample_name(void);
|
||||||
static void st_collections_group_sound_sample_source(void);
|
static void st_collections_group_sound_sample_source(void);
|
||||||
static void st_collections_group_sound_tone(void);
|
static void st_collections_group_sound_tone(void);
|
||||||
|
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
static void st_collections_group_physics_world_gravity(void);
|
||||||
|
static void st_collections_group_physics_world_rate(void);
|
||||||
|
static void st_collections_group_physics_world_z(void);
|
||||||
|
static void st_collections_group_physics_world_depth(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*****/
|
/*****/
|
||||||
|
|
||||||
New_Statement_Handler statement_handlers[] =
|
New_Statement_Handler statement_handlers[] =
|
||||||
|
@ -745,6 +756,12 @@ New_Statement_Handler statement_handlers[] =
|
||||||
{"collections.group.parts.program.target", st_collections_group_programs_program_target}, /* dup */
|
{"collections.group.parts.program.target", st_collections_group_programs_program_target}, /* dup */
|
||||||
{"collections.group.parts.program.after", st_collections_group_programs_program_after}, /* dup */
|
{"collections.group.parts.program.after", st_collections_group_programs_program_after}, /* dup */
|
||||||
{"collections.group.parts.program.api", st_collections_group_programs_program_api}, /* dup */
|
{"collections.group.parts.program.api", st_collections_group_programs_program_api}, /* dup */
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
{"collections.group.physics.world.gravity", st_collections_group_physics_world_gravity},
|
||||||
|
{"collections.group.physics.world.rate", st_collections_group_physics_world_rate},
|
||||||
|
{"collections.group.physics.world.z", st_collections_group_physics_world_z},
|
||||||
|
{"collections.group.physics.world.depth", st_collections_group_physics_world_depth},
|
||||||
|
#endif
|
||||||
{"collections.group.program.name", st_collections_group_programs_program_name}, /* dup */
|
{"collections.group.program.name", st_collections_group_programs_program_name}, /* dup */
|
||||||
{"collections.group.program.signal", st_collections_group_programs_program_signal}, /* dup */
|
{"collections.group.program.signal", st_collections_group_programs_program_signal}, /* dup */
|
||||||
{"collections.group.program.source", st_collections_group_programs_program_source}, /* dup */
|
{"collections.group.program.source", st_collections_group_programs_program_source}, /* dup */
|
||||||
|
@ -921,6 +938,10 @@ New_Object_Handler object_handlers[] =
|
||||||
{"collections.group.parts.programs.program", ob_collections_group_programs_program}, /* dup */
|
{"collections.group.parts.programs.program", ob_collections_group_programs_program}, /* dup */
|
||||||
{"collections.group.parts.programs.program.script", ob_collections_group_programs_program_script}, /* dup */
|
{"collections.group.parts.programs.program.script", ob_collections_group_programs_program_script}, /* dup */
|
||||||
{"collections.group.parts.script", ob_collections_group_script}, /* dup */
|
{"collections.group.parts.script", ob_collections_group_script}, /* dup */
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
{"collections.group.physics", NULL},
|
||||||
|
{"collections.group.physics.world", NULL},
|
||||||
|
#endif
|
||||||
{"collections.group.program", ob_collections_group_programs_program}, /* dup */
|
{"collections.group.program", ob_collections_group_programs_program}, /* dup */
|
||||||
{"collections.group.program.script", ob_collections_group_programs_program_script}, /* dup */
|
{"collections.group.program.script", ob_collections_group_programs_program_script}, /* dup */
|
||||||
{"collections.group.programs", NULL},
|
{"collections.group.programs", NULL},
|
||||||
|
@ -2401,6 +2422,15 @@ ob_collections_group(void)
|
||||||
|
|
||||||
cd = mem_alloc(SZ(Code));
|
cd = mem_alloc(SZ(Code));
|
||||||
codes = eina_list_append(codes, cd);
|
codes = eina_list_append(codes, cd);
|
||||||
|
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
pc->physics.world.gravity.x = 0;
|
||||||
|
pc->physics.world.gravity.y = 294;
|
||||||
|
pc->physics.world.gravity.z = 0;
|
||||||
|
pc->physics.world.depth = 100;
|
||||||
|
pc->physics.world.z = -50;
|
||||||
|
pc->physics.world.rate = FROM_DOUBLE(30);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2570,6 +2600,15 @@ st_collections_group_inherit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
pc->physics.world.gravity.x = pc2->physics.world.gravity.x;
|
||||||
|
pc->physics.world.gravity.y = pc2->physics.world.gravity.y;
|
||||||
|
pc->physics.world.gravity.z = pc2->physics.world.gravity.z;
|
||||||
|
pc->physics.world.depth = pc2->physics.world.depth;
|
||||||
|
pc->physics.world.z = pc2->physics.world.z;
|
||||||
|
pc->physics.world.rate = pc2->physics.world.rate;
|
||||||
|
#endif
|
||||||
|
|
||||||
pc->prop.min.w = pc2->prop.min.w;
|
pc->prop.min.w = pc2->prop.min.w;
|
||||||
pc->prop.min.h = pc2->prop.min.h;
|
pc->prop.min.h = pc2->prop.min.h;
|
||||||
pc->prop.orientation = pc2->prop.orientation;
|
pc->prop.orientation = pc2->prop.orientation;
|
||||||
|
@ -9073,6 +9112,162 @@ ob_collections_group_programs_program_script(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@edcsubsection{collections_group_physics,Physics}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@page edcref
|
||||||
|
@block
|
||||||
|
physics
|
||||||
|
@context
|
||||||
|
group {
|
||||||
|
..
|
||||||
|
physics {
|
||||||
|
world {
|
||||||
|
..
|
||||||
|
}
|
||||||
|
}
|
||||||
|
..
|
||||||
|
}
|
||||||
|
@description
|
||||||
|
The "physics" block consists of blocks related to physics but
|
||||||
|
not to configure a body. By now, it only has a "world" block.
|
||||||
|
@endblock
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@edcsubsection{collections_group_physics_world,World}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@page edcref
|
||||||
|
@block
|
||||||
|
world
|
||||||
|
@context
|
||||||
|
physics {
|
||||||
|
world {
|
||||||
|
gravity: 0 294 0;
|
||||||
|
rate: 30;
|
||||||
|
z: -50;
|
||||||
|
depth: 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@description
|
||||||
|
The "world" block configures the physics world. It's the
|
||||||
|
environment where the part's bodies will be simulated.
|
||||||
|
It can be used to customize gravity, rate, depth and others.
|
||||||
|
@endblock
|
||||||
|
|
||||||
|
@property
|
||||||
|
gravity
|
||||||
|
@parameters
|
||||||
|
[x-axis] [y-axis] [z-axis]
|
||||||
|
@effect
|
||||||
|
Three double values defining the gravity vector.
|
||||||
|
Each one is the component of this same vector over each axis.
|
||||||
|
Its unit is Evas Coordinates per second ^ 2.
|
||||||
|
The default value is 0, 294, 0, since we've a default rate of
|
||||||
|
30 pixels.
|
||||||
|
@endproperty
|
||||||
|
@since 1.8.0
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
static void
|
||||||
|
st_collections_group_physics_world_gravity(void)
|
||||||
|
{
|
||||||
|
Edje_Part_Collection *pc;
|
||||||
|
|
||||||
|
pc = eina_list_data_get(eina_list_last(edje_collections));
|
||||||
|
check_arg_count(3);
|
||||||
|
|
||||||
|
pc->physics.world.gravity.x = parse_int(0);
|
||||||
|
pc->physics.world.gravity.y = parse_int(1);
|
||||||
|
pc->physics.world.gravity.z = parse_int(2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
@page edcref
|
||||||
|
@property
|
||||||
|
rate
|
||||||
|
@parameters
|
||||||
|
[rate pixels / meter]
|
||||||
|
@effect
|
||||||
|
Set rate between pixels on evas canvas and meters on physics world.
|
||||||
|
It will be used by automatic updates of evas objects associated to
|
||||||
|
physics bodies.
|
||||||
|
By default rate is 30 pixels per meter.
|
||||||
|
@endproperty
|
||||||
|
@since 1.8.0
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
static void
|
||||||
|
st_collections_group_physics_world_rate(void)
|
||||||
|
{
|
||||||
|
Edje_Part_Collection *pc;
|
||||||
|
|
||||||
|
pc = eina_list_data_get(eina_list_last(edje_collections));
|
||||||
|
check_arg_count(1);
|
||||||
|
|
||||||
|
pc->physics.world.rate = parse_float(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
@page edcref
|
||||||
|
@property
|
||||||
|
depth
|
||||||
|
@parameters
|
||||||
|
[depth in pixels]
|
||||||
|
@effect
|
||||||
|
World's depth, in pixels. It's only relevant if boundaries are used,
|
||||||
|
since their size depends on this.
|
||||||
|
By default world's depth is 100 pixels.
|
||||||
|
@endproperty
|
||||||
|
@since 1.8.0
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
static void
|
||||||
|
st_collections_group_physics_world_depth(void)
|
||||||
|
{
|
||||||
|
Edje_Part_Collection *pc;
|
||||||
|
|
||||||
|
pc = eina_list_data_get(eina_list_last(edje_collections));
|
||||||
|
check_arg_count(1);
|
||||||
|
|
||||||
|
pc->physics.world.depth = parse_int(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
@page edcref
|
||||||
|
@property
|
||||||
|
z
|
||||||
|
@parameters
|
||||||
|
[world's front border position]
|
||||||
|
@effect
|
||||||
|
Position in z axis, in pixels.
|
||||||
|
It's only relevant if boundaries are used, since their position
|
||||||
|
depends on this.
|
||||||
|
By default world's z is -50 pixels.
|
||||||
|
@endproperty
|
||||||
|
@since 1.8.0
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
static void
|
||||||
|
st_collections_group_physics_world_z(void)
|
||||||
|
{
|
||||||
|
Edje_Part_Collection *pc;
|
||||||
|
|
||||||
|
pc = eina_list_data_get(eina_list_last(edje_collections));
|
||||||
|
check_arg_count(1);
|
||||||
|
|
||||||
|
pc->physics.world.z = parse_int(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@page edcref
|
@page edcref
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -99,6 +99,15 @@ collections {
|
||||||
group {
|
group {
|
||||||
name: "example_group";
|
name: "example_group";
|
||||||
|
|
||||||
|
physics {
|
||||||
|
world {
|
||||||
|
gravity: 0 80 0;
|
||||||
|
rate: 30;
|
||||||
|
z: -100;
|
||||||
|
depth: 200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
script {
|
script {
|
||||||
public message(Msg_Type:type, id, ...) {
|
public message(Msg_Type:type, id, ...) {
|
||||||
if ((id == ID_IMPULSE) && (type == MSG_FLOAT_SET)) {
|
if ((id == ID_IMPULSE) && (type == MSG_FLOAT_SET)) {
|
||||||
|
|
|
@ -985,6 +985,14 @@ _edje_edd_init(void)
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "lua_script_only", lua_script_only, EET_T_UCHAR);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "lua_script_only", lua_script_only, EET_T_UCHAR);
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.orientation", prop.orientation, EET_T_INT);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.orientation", prop.orientation, EET_T_INT);
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "broadcast_signal", broadcast_signal, EET_T_UCHAR);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "broadcast_signal", broadcast_signal, EET_T_UCHAR);
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics.world.rate", physics.world.rate, EET_T_DOUBLE);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics.world.gravity.x", physics.world.gravity.x, EET_T_INT);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics.world.gravity.y", physics.world.gravity.y, EET_T_INT);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics.world.gravity.z", physics.world.gravity.z, EET_T_INT);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics.world.z", physics.world.z, EET_T_INT);
|
||||||
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics.world.depth", physics.world.depth, EET_T_INT);
|
||||||
|
#endif
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics_enabled", physics_enabled, EET_T_UCHAR);
|
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics_enabled", physics_enabled, EET_T_UCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -458,6 +458,12 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
|
||||||
ephysics_world_event_callback_add(
|
ephysics_world_event_callback_add(
|
||||||
ed->world, EPHYSICS_CALLBACK_WORLD_UPDATE,
|
ed->world, EPHYSICS_CALLBACK_WORLD_UPDATE,
|
||||||
_edje_physics_world_update_cb, ed);
|
_edje_physics_world_update_cb, ed);
|
||||||
|
ephysics_world_rate_set(ed->world,
|
||||||
|
ed->collection->physics.world.rate);
|
||||||
|
ephysics_world_gravity_set(
|
||||||
|
ed->world, ed->collection->physics.world.gravity.x,
|
||||||
|
ed->collection->physics.world.gravity.y,
|
||||||
|
ed->collection->physics.world.gravity.z);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ERR("Edje compiled without support to physics.");
|
ERR("Edje compiled without support to physics.");
|
||||||
|
|
|
@ -846,6 +846,21 @@ struct _Edje_Part_Collection
|
||||||
} prog_cache;
|
} prog_cache;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_EPHYSICS
|
||||||
|
struct {
|
||||||
|
struct {
|
||||||
|
double rate;
|
||||||
|
Evas_Coord z;
|
||||||
|
Evas_Coord depth;
|
||||||
|
struct {
|
||||||
|
Evas_Coord x;
|
||||||
|
Evas_Coord y;
|
||||||
|
Evas_Coord z;
|
||||||
|
} gravity;
|
||||||
|
} world;
|
||||||
|
} physics;
|
||||||
|
#endif
|
||||||
|
|
||||||
Embryo_Program *script; /* all the embryo script code for this group */
|
Embryo_Program *script; /* all the embryo script code for this group */
|
||||||
const char *part;
|
const char *part;
|
||||||
|
|
||||||
|
|
|
@ -227,8 +227,9 @@ _edje_smart_resize(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
|
||||||
ed->h = h;
|
ed->h = h;
|
||||||
#ifdef HAVE_EPHYSICS
|
#ifdef HAVE_EPHYSICS
|
||||||
if (ed->world)
|
if (ed->world)
|
||||||
ephysics_world_render_geometry_set(ed->world, ed->x, ed->y, -50,
|
ephysics_world_render_geometry_set(
|
||||||
ed->w, ed->h, 100);
|
ed->world, ed->x, ed->y, ed->collection->physics.world.z,
|
||||||
|
ed->w, ed->h, ed->collection->physics.world.depth);
|
||||||
#endif
|
#endif
|
||||||
#ifdef EDJE_CALC_CACHE
|
#ifdef EDJE_CALC_CACHE
|
||||||
ed->all_part_change = EINA_TRUE;
|
ed->all_part_change = EINA_TRUE;
|
||||||
|
|
Loading…
Reference in New Issue