gel.applet: Add mouse picking for box2d.
This commit is contained in:
@@ -754,9 +754,9 @@ is
|
|||||||
is
|
is
|
||||||
use world_Vectors;
|
use world_Vectors;
|
||||||
|
|
||||||
the_Event : gel.mouse.button_press_Event renames gel.Mouse.button_press_Event (to_Event);
|
the_Event : gel.mouse.button_press_Event renames gel.Mouse.button_press_Event (to_Event);
|
||||||
Cursor : world_Vectors.Cursor := Self.Applet.Worlds.First;
|
Cursor : world_Vectors.Cursor := Self.Applet.Worlds.First;
|
||||||
the_world_Info : world_Info_view;
|
the_world_Info : world_Info_view;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
while has_Element (Cursor)
|
while has_Element (Cursor)
|
||||||
@@ -765,6 +765,7 @@ is
|
|||||||
|
|
||||||
declare
|
declare
|
||||||
use gel.World;
|
use gel.World;
|
||||||
|
use type physics.space_Kind;
|
||||||
|
|
||||||
the_Camera : constant gel.Camera.view := the_world_Info.Cameras.first_Element;
|
the_Camera : constant gel.Camera.view := the_world_Info.Cameras.first_Element;
|
||||||
|
|
||||||
@@ -774,16 +775,37 @@ is
|
|||||||
|
|
||||||
Site_world_space : constant Vector_3 := the_Camera.to_world_Site (Site_window_space);
|
Site_world_space : constant Vector_3 := the_Camera.to_world_Site (Site_window_space);
|
||||||
|
|
||||||
Collision : ray_Collision := the_world_Info.World.cast_Ray (From => the_Camera.Site,
|
sprite_Event : constant gel.Events.sprite_click_down_Event := (mouse_Button => the_Event.Button,
|
||||||
To => Site_world_space);
|
|
||||||
|
|
||||||
Event : constant gel.Events.sprite_click_down_Event := (mouse_Button => the_Event.Button,
|
|
||||||
world_Site => Site_world_space);
|
world_Site => Site_world_space);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Collision.near_Sprite /= null
|
case the_world_Info.World.space_Kind
|
||||||
then
|
is
|
||||||
Collision.near_Sprite.emit (Event);
|
when physics.Bullet =>
|
||||||
end if;
|
declare
|
||||||
|
the_Collision : ray_Collision := the_world_Info.World.cast_Ray (From => the_Camera.Site,
|
||||||
|
To => Site_world_space);
|
||||||
|
begin
|
||||||
|
if the_Collision.near_Sprite /= null
|
||||||
|
then
|
||||||
|
the_Collision.near_Sprite.emit (sprite_Event);
|
||||||
|
end if;
|
||||||
|
end;
|
||||||
|
|
||||||
|
when physics.Box2D =>
|
||||||
|
declare
|
||||||
|
use gel.linear_Algebra_3D;
|
||||||
|
|
||||||
|
Intersect : constant Vector_3 := intersect_Line_and_z0_Plane (Line_p1 => the_Camera.Site,
|
||||||
|
Line_p2 => Site_world_space);
|
||||||
|
the_Collision : constant point_Collision := the_world_Info.World.cast_Point (Point => Intersect);
|
||||||
|
begin
|
||||||
|
if the_Collision.near_Sprite /= null
|
||||||
|
then
|
||||||
|
the_Collision.near_Sprite.emit (sprite_Event);
|
||||||
|
end if;
|
||||||
|
end;
|
||||||
|
end case;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
next (Cursor);
|
next (Cursor);
|
||||||
@@ -797,10 +819,11 @@ is
|
|||||||
is
|
is
|
||||||
use world_Vectors;
|
use world_Vectors;
|
||||||
|
|
||||||
the_Event : gel.Mouse.button_release_Event renames gel.Mouse.button_release_Event (to_Event);
|
the_Event : gel.mouse.button_release_Event renames gel.Mouse.button_release_Event (to_Event);
|
||||||
Cursor : world_Vectors.Cursor := Self.Applet.Worlds.First;
|
Cursor : world_Vectors.Cursor := Self.Applet.Worlds.First;
|
||||||
the_world_Info : world_Info_view;
|
the_world_Info : world_Info_view;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
while has_Element (Cursor)
|
while has_Element (Cursor)
|
||||||
loop
|
loop
|
||||||
@@ -817,16 +840,36 @@ is
|
|||||||
|
|
||||||
Site_world_space : constant Vector_3 := the_Camera.to_world_Site (Site_window_space);
|
Site_world_space : constant Vector_3 := the_Camera.to_world_Site (Site_window_space);
|
||||||
|
|
||||||
Collision : ray_Collision := the_world_Info.World.cast_Ray (From => the_Camera.Site,
|
sprite_Event : constant gel.Events.sprite_click_up_Event := (mouse_Button => the_Event.Button,
|
||||||
To => Site_world_space);
|
|
||||||
|
|
||||||
Event : constant gel.Events.sprite_click_up_Event := (mouse_Button => the_Event.Button,
|
|
||||||
world_Site => Site_world_space);
|
world_Site => Site_world_space);
|
||||||
begin
|
begin
|
||||||
if Collision.near_Sprite /= null
|
case the_world_Info.World.space_Kind
|
||||||
then
|
is
|
||||||
Collision.near_Sprite.emit (Event);
|
when physics.Bullet =>
|
||||||
end if;
|
declare
|
||||||
|
the_Collision : ray_Collision := the_world_Info.World.cast_Ray (From => the_Camera.Site,
|
||||||
|
To => Site_world_space);
|
||||||
|
begin
|
||||||
|
if the_Collision.near_Sprite /= null
|
||||||
|
then
|
||||||
|
the_Collision.near_Sprite.emit (sprite_Event);
|
||||||
|
end if;
|
||||||
|
end;
|
||||||
|
|
||||||
|
when physics.Box2D =>
|
||||||
|
declare
|
||||||
|
use gel.linear_Algebra_3D;
|
||||||
|
|
||||||
|
Intersect : constant Vector_3 := intersect_Line_and_z0_Plane (Line_p1 => the_Camera.Site,
|
||||||
|
Line_p2 => Site_world_space);
|
||||||
|
the_Collision : constant point_Collision := the_world_Info.World.cast_Point (Point => Intersect);
|
||||||
|
begin
|
||||||
|
if the_Collision.near_Sprite /= null
|
||||||
|
then
|
||||||
|
the_Collision.near_Sprite.emit (sprite_Event);
|
||||||
|
end if;
|
||||||
|
end;
|
||||||
|
end case;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
next (Cursor);
|
next (Cursor);
|
||||||
|
|||||||
Reference in New Issue
Block a user