Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_graphics
Elements
PickableSlot.cpp
Go to the documentation of this file.
1
#include "
PickableSlot.hpp
"
2
3
#include <
ivorium_core/ivorium_core.hpp
>
4
#include <
ivorium_systems/ivorium_systems.hpp
>
5
6
namespace
iv
7
{
8
9
PickableSlot::PickableSlot
(
Instance
* inst ) :
10
Slot
( inst ),
11
Position_InputNode
::Tester(),
12
cm( inst, this,
"PickableSlot"
),
13
input( inst, this, false ),
14
pickable( nullptr )
15
{
16
this->
cm
.
inherits
( this->
Slot::cm
);
17
this->
cm
.
owns
( this->
input
.
cm
);
18
19
this->
Add_InputNode
( &this->
input
);
20
}
21
22
void
PickableSlot::pickable_elem
(
Pickable
* pickable )
23
{
24
this->pickable =
pickable
;
25
}
26
27
float2
PickableSlot::input_position_local
()
28
{
29
// select pickable
30
Pickable
*
pickable
=
this
;
31
if
( this->pickable )
32
pickable
= this->
pickable
;
33
34
//
35
if
( !pickable->
elem
()->
elem_getRoot
() )
36
return
float2
( 0.0, 0.0 );
37
38
int2
pos = this->
input
.
input_position_screen
();
39
return
pickable->
elem
()->
FromScreenPlaneToLocalPlane
(
float2
( pos ) );
40
}
41
42
bool
PickableSlot::position_test
(
int2
input_pos )
43
{
44
// select pickable
45
Pickable
*
pickable
=
this
;
46
if
( this->pickable )
47
pickable
= this->
pickable
;
48
49
//
50
return
pickable->
picking_test
( input_pos );
51
}
52
53
}