-
Notifications
You must be signed in to change notification settings - Fork 9
/
view.cpp
151 lines (135 loc) · 3.41 KB
/
view.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include "view.h"
namespace eqEarth
{
// ----------------------------------------------------------------------------
View::View( eq::Layout* parent )
: eq::View( parent )
, _proxy( this )
, _sceneID( 0 )
, _overlayID( 0 )
, _viewMatrix( eq::Matrix4f( ))
, _near( 0.01 ), _far( 100.0 )
, _lat( 0.0 ), _lon( 0.0 )
, _origin( )
, _direction( )
{
LBINFO << "=====> View::View(" << (void *)this << ")" << std::endl;
setUserData( &_proxy );
}
View::~View( )
{
setUserData( 0 );
LBINFO << "<===== View::~View(" << (void *)this << ")" << std::endl;
}
void View::setSceneID( const eq::uint128_t& id )
{
if( id != _sceneID )
{
_sceneID = id;
_proxy.setDirty( Proxy::DIRTY_SCENE );
}
}
void View::setOverlayID( const eq::uint128_t& id )
{
if( id != _overlayID )
{
_overlayID = id;
_proxy.setDirty( Proxy::DIRTY_OVERLAY );
}
}
void View::setViewMatrix( const eq::Matrix4f& viewMatrix )
{
_viewMatrix = viewMatrix;
_proxy.setDirty( Proxy::DIRTY_CAMERA );
}
void View::setNearFar( double near, double far )
{
if(( near != _near ) || ( far != _far ))
{
_near = near;
_far = far;
_proxy.setDirty( Proxy::DIRTY_NEARFAR );
}
}
void View::getNearFar( double& near, double& far ) const
{
near = _near;
far = _far;
}
void View::setLatLon( double lat, double lon )
{
if(( lat != _lat ) || ( lon != _lon ))
{
_lat = lat;
_lon = lon;
_proxy.setDirty( Proxy::DIRTY_LATLON );
}
}
void View::getLatLon( double& lat, double& lon ) const
{
lat = _lat;
lon = _lon;
}
void View::setWorldPointer( const eq::Vector3f& origin,
const eq::Vector3f& direction )
{
if(( origin != _origin ) || ( direction != _direction ))
{
_origin = origin;
_direction = direction;
_proxy.setDirty( Proxy::DIRTY_POINTER );
}
}
void View::getWorldPointer( eq::Vector3f& origin,
eq::Vector3f& direction ) const
{
origin = _origin;
direction = _direction;
}
void View::Proxy::serialize( co::DataOStream& os, const uint64_t dirtyBits )
{
if( dirtyBits & DIRTY_SCENE )
os << _view->_sceneID;
if( dirtyBits & DIRTY_OVERLAY )
os << _view->_overlayID;
if( dirtyBits & DIRTY_CAMERA )
os << _view->_viewMatrix;
if( dirtyBits & DIRTY_NEARFAR )
os << _view->_near << _view->_far;
if( dirtyBits & DIRTY_LATLON )
os << _view->_lat << _view->_lon;
if( dirtyBits & DIRTY_POINTER )
os << _view->_origin << _view->_direction;
}
void View::Proxy::deserialize( co::DataIStream& is, const uint64_t dirtyBits )
{
if( dirtyBits & DIRTY_SCENE )
is >> _view->_sceneID;
if( dirtyBits & DIRTY_OVERLAY )
is >> _view->_overlayID;
if( dirtyBits & DIRTY_CAMERA )
{
is >> _view->_viewMatrix;
if( isMaster( ))
setDirty( DIRTY_CAMERA ); // redistribute
}
if( dirtyBits & DIRTY_NEARFAR )
{
is >> _view->_near >> _view->_far;
if( isMaster( ))
setDirty( DIRTY_NEARFAR ); // redistribute
}
if( dirtyBits & DIRTY_LATLON )
{
is >> _view->_lat >> _view->_lon;
if( isMaster( ))
setDirty( DIRTY_LATLON ); // redistribute
}
if( dirtyBits & DIRTY_POINTER )
{
is >> _view->_origin >> _view->_direction;
if( isMaster( ))
setDirty( DIRTY_POINTER ); // redistribute
}
}
}