Mercurial > fife-parpg
annotate engine/core/view/camera.cpp @ 634:5f381fa34769
* Added the clearBackBuffer() function to the renderbackends.
* Renamed setClearScreen() to setClearBackBuffer()
* The SDL render backend now honors what was set with setClearBackBuffer()
* Documented testRenderedViewPort()
* The OpenGL backend no longer clears the screen every frame by default. testRenderedViewPort() takes care of clearing the screen for now. Note: if the user overrides the default and enables clearing of the backbuffer that it may be cleared twice in one frame (OpenGL only)!
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 06 Oct 2010 15:49:53 +0000 |
parents | 46b95d06c8c2 |
children | 07b1cf8e92b5 |
rev | line source |
---|---|
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 /*************************************************************************** |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 * Copyright (C) 2005-2008 by the FIFE team * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 * http://www.fifengine.de * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 * This file is part of FIFE. * |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
6 * FIFE is free software; you can redistribute it and/or * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
8 * License as published by the Free Software Foundation; either * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
11 * This library is distributed in the hope that it will be useful, * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
14 * Lesser General Public License for more details. * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 * * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public * |
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
17 * License along with this library; if not, write to the * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 * Free Software Foundation, Inc., * |
46
90005975cdbb
* Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
34
diff
changeset
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 ***************************************************************************/ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 // Standard C++ library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 // 3rd party library includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 #include <SDL.h> |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 // FIFE includes |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 // These includes are split up in two parts, separated by one empty line |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 // First block: files included from the FIFE root src directory |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 // Second block: files included from the same folder |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 #include "model/metamodel/grids/cellgrid.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 #include "model/metamodel/action.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 #include "model/metamodel/timeprovider.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 #include "model/structures/map.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 #include "model/structures/layer.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 #include "model/structures/instancetree.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 #include "model/structures/instance.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 #include "model/structures/location.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 #include "util/log/logger.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 #include "util/math/fife_math.h" |
407
f27880d4c08c
Moved getAngleBetween() form Camera to angles.h and updated it to not use the camera angle in it's calculation.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
405
diff
changeset
|
42 #include "util/math/angles.h" |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 #include "util/time/timemanager.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 #include "video/renderbackend.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 #include "video/image.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 #include "video/imagepool.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 #include "video/animation.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 #include "video/animationpool.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 #include "camera.h" |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
51 #include "layercache.h" |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 #include "visual.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 namespace FIFE { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 static Logger _log(LM_CAMERA); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
58 class MapObserver : public MapChangeListener { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
59 Camera* m_camera; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
60 |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
61 public: |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
62 MapObserver(Camera* camera) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
63 m_camera = camera; |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
64 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
65 virtual ~MapObserver() {} |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
66 |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
67 virtual void onMapChanged(Map* map, std::vector<Layer*>& changedLayers) { |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
68 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
69 |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
70 virtual void onLayerCreate(Map* map, Layer* layer) { |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
71 m_camera->addLayer(layer); |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
72 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
73 |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
74 virtual void onLayerDelete(Map* map, Layer* layer) { |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
75 m_camera->removeLayer(layer); |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
76 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
77 }; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
78 |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
79 Camera::Camera(const std::string& id, |
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
80 Layer *layer, |
422
9d94f4676d17
Moved the management of cameras into the Map class. The View class no longer exists since it now serves no purpose. The engine class itself holds the renderers and these get passed to each map that is loaded and then passed to each camera on each map. This change makes it possible for multiple maps to be loaded at the same time with the same camera id without a name clash. fixes[t:342]
vtchill@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
408
diff
changeset
|
81 const Rect& viewport, |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 RenderBackend* renderbackend, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 ImagePool* ipool, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 AnimationPool* apool): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 m_id(id), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 m_matrix(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 m_inverse_matrix(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 m_tilt(0), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 m_rotation(0), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 m_zoom(1), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 m_location(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 m_prev_origo(ScreenPoint(0,0,0)), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 m_cur_origo(ScreenPoint(0,0,0)), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 m_viewport(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 m_screen_cell_width(1), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 m_screen_cell_height(1), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
97 m_reference_scale(1), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 m_enabled(true), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 m_attachedto(NULL), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 m_image_dimensions(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 m_iswarped(false), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 m_renderers(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 m_pipeline(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 m_updated(false), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
105 m_renderbackend(renderbackend), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
106 m_ipool(ipool), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 m_apool(apool), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 m_layer_to_instances() { |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
109 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 m_viewport = viewport; |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
111 m_map_observer = new MapObserver(this); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
112 m_map = 0; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
113 Location location; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
114 location.setLayer(layer); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
115 setLocation(location); |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
116 if(m_renderbackend->getName() == "SDL") { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
117 m_backendSDL = true; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
118 } else { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
119 m_backendSDL = false; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
120 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 Camera::~Camera() { |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
124 // Trigger removal of LayerCaches and MapObserver |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
125 updateMap(NULL); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
126 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
127 std::map<std::string, RendererBase*>::iterator r_it = m_renderers.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
128 for(; r_it != m_renderers.end(); ++r_it) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
129 delete r_it->second; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
131 m_renderers.clear(); |
634
5f381fa34769
* Added the clearBackBuffer() function to the renderbackends.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
633
diff
changeset
|
132 m_renderbackend->setClearBackBuffer(true); |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
133 delete m_map_observer; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
134 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
135 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
136 void Camera::setTilt(double tilt) { |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
137 if(m_tilt != tilt) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
138 m_tilt = tilt; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
139 updateReferenceScale(); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
140 updateMatrices(); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
141 m_iswarped = true; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
142 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
143 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
144 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
145 double Camera::getTilt() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
146 return m_tilt; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
147 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
148 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
149 void Camera::setRotation(double rotation) { |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
150 if(m_rotation != rotation) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
151 m_rotation = rotation; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
152 updateReferenceScale(); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
153 updateMatrices(); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
154 m_iswarped = true; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
155 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
156 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
157 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
158 double Camera::getRotation() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
159 return m_rotation; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
160 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
161 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
162 void Camera::setZoom(double zoom) { |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
163 if(m_zoom!=zoom) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
164 m_zoom = zoom; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
165 if (m_zoom < 0.001) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
166 m_zoom = 0.001; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
167 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
168 updateMatrices(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
169 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
170 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
171 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
172 double Camera::getZoom() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
173 return m_zoom; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
174 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
175 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
176 void Camera::setCellImageDimensions(unsigned int width, unsigned int height) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
177 m_screen_cell_width = width; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
178 m_screen_cell_height = height; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
179 updateReferenceScale(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
180 updateMatrices(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
181 m_iswarped = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
182 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
183 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
184 void Camera::setLocation(const Location& location) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
185 // initialize first set properly |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
186 if ((m_prev_origo == m_cur_origo) && (m_prev_origo == ScreenPoint(0,0,0))) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
187 m_cur_origo = toScreenCoordinates(ExactModelCoordinate(0,0,0)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
188 m_prev_origo = m_cur_origo; |
245
ed1565a5a2a0
Fixed second camera in rio.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
240
diff
changeset
|
189 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
190 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
191 CellGrid* cell_grid = NULL; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
192 if (location.getLayer()) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
193 cell_grid = location.getLayer()->getCellGrid(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
194 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
195 throw Exception("Location without layer given to Camera::setLocation"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
196 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
197 if (!cell_grid) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
198 throw Exception("Camera layer has no cellgrid specified"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
199 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
200 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
201 m_location = location; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
202 updateMatrices(); |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
203 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
204 // WARNING |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
205 // It is important that m_location is already set, |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
206 // as the updates which are triggered here |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
207 // need to calculate screen-coordinates |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
208 // which depend on m_location. |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
209 updateMap(location.getMap()); |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
210 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
211 m_cur_origo = toScreenCoordinates(ExactModelCoordinate(0,0,0)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
212 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
213 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
214 void Camera::updateMap(Map* map) |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
215 { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
216 if(m_map == map) |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
217 { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
218 return; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
219 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
220 if(m_map) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
221 m_map->removeChangeListener(m_map_observer); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
222 const std::list<Layer*>& layers = m_map->getLayers(); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
223 for(std::list<Layer*>::const_iterator i = layers.begin(); i !=layers.end(); ++i) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
224 removeLayer(*i); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
225 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
226 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
227 if(map) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
228 map->addChangeListener(m_map_observer); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
229 const std::list<Layer*>& layers = map->getLayers(); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
230 for(std::list<Layer*>::const_iterator i = layers.begin(); i !=layers.end(); ++i) |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
231 addLayer(*i); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
232 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
233 m_map = map; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
234 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
235 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
236 Point Camera::getCellImageDimensions() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
237 return getCellImageDimensions(m_location.getLayer()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
238 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
239 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
240 Point Camera::getCellImageDimensions(Layer* layer) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
241 if (layer == m_location.getLayer()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
242 return Point( m_screen_cell_width, m_screen_cell_height ); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
243 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
244 std::map<Layer*, Point>::iterator it = m_image_dimensions.find(layer); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
245 if (it != m_image_dimensions.end()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
246 return it->second; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
247 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
248 Point p; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
249 CellGrid* cg = layer->getCellGrid(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
250 assert(cg); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
251 DoublePoint dimensions = getLogicalCellDimensions(layer); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
252 p.x = static_cast<int>(round(m_reference_scale * dimensions.x)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
253 p.y = static_cast<int>(round(m_reference_scale * dimensions.y)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
254 m_image_dimensions[layer] = p; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
255 return p; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
256 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
257 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
258 Location Camera::getLocation() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
259 return m_location; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
260 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
261 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
262 Location& Camera::getLocationRef() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
263 return m_location; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
264 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
265 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
266 void Camera::setViewPort(const Rect& viewport) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
267 m_viewport = viewport; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
268 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
269 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
270 const Rect& Camera::getViewPort() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
271 return m_viewport; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
272 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
273 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
274 void Camera::setEnabled(bool enabled) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
275 m_enabled = enabled; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
276 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
277 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
278 bool Camera::isEnabled() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
279 return m_enabled; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
280 } |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
281 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
282 Point3D Camera::getOrigin() const { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
283 return m_cur_origo; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
284 } |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
285 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
286 void Camera::updateMatrices() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
287 double scale = m_reference_scale; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
288 m_matrix.loadScale(scale, scale, scale); |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
289 m_vs_matrix.loadScale(scale,scale,scale); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
290 if (m_location.getLayer()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
291 CellGrid* cg = m_location.getLayer()->getCellGrid(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
292 if (cg) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
293 ExactModelCoordinate pt = m_location.getMapCoordinates(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
294 m_matrix.applyTranslate( -pt.x *m_reference_scale,-pt.y *m_reference_scale, 0); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
295 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
296 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
297 scale = m_zoom; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
298 m_matrix.applyScale(scale, scale, scale); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
299 m_matrix.applyRotate(-m_rotation, 0.0, 0.0, 1.0); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
300 m_matrix.applyRotate(-m_tilt, 1.0, 0.0, 0.0); |
548
f45e3e2995e0
* Corrected the h,w calculation for zooming in layercache.cpp.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
482
diff
changeset
|
301 m_matrix.applyTranslate(+m_viewport.x+m_viewport.w/2, +m_viewport.y+m_viewport.h/2, 0); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
302 m_inverse_matrix = m_matrix.inverse(); |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
303 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
304 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
305 m_vs_matrix.applyTranslate(0,0,0); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
306 m_vs_matrix.applyRotate(-m_rotation, 0.0, 0.0, 1.0); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
307 m_vs_matrix.applyRotate(-m_tilt, 1.0, 0.0, 0.0); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
308 m_vs_inverse_matrix = m_vs_matrix.inverse(); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
309 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
310 // calculate the screen<->virtual screen transformation |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
311 // this explicitly ignores the z-value. |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
312 m_vscreen_2_screen = m_matrix; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
313 // NOTE: mult4by4 is an in-place modification. |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
314 m_vscreen_2_screen.mult4by4(m_vs_inverse_matrix); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
315 // set the z transformation to unity |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
316 const int N=4; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
317 for(int i=0; i!=N; ++i) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
318 m_vscreen_2_screen[2*N + i] = 0; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
319 m_vscreen_2_screen[i*N + 2] = 0; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
320 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
321 m_vscreen_2_screen[2*N + 2] = 1; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
322 m_screen_2_vscreen = m_vscreen_2_screen.inverse(); |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
323 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
324 // FL_WARN(_log, LMsg("matrix: ") << m_matrix << " 1: " << m_matrix.inverse().mult4by4(m_matrix)); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
325 // FL_WARN(_log, LMsg("vs2s matrix: ") << m_vscreen_2_screen << " s2vs matrix: " << m_screen_2_vscreen); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
326 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
327 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
328 void Camera::calculateZValue(ScreenPoint& screen_coords) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
329 int dy = -(screen_coords.y - toScreenCoordinates(m_location.getMapCoordinates()).y); |
621
356634098bd9
* Removed the image chunking size variable from engine settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
605
diff
changeset
|
330 screen_coords.z = static_cast<int>(tan(m_tilt * (DBL_PI / 180.0)) * static_cast<double>(dy)); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
331 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
332 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
333 ExactModelCoordinate Camera::toMapCoordinates(ScreenPoint screen_coords, bool z_calculated) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
334 if (!z_calculated) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
335 calculateZValue(screen_coords); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
336 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
337 return m_inverse_matrix * intPt2doublePt(screen_coords); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
338 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
339 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
340 ScreenPoint Camera::toScreenCoordinates(ExactModelCoordinate elevation_coords) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
341 ExactModelCoordinate p = elevation_coords; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
342 ScreenPoint pt = doublePt2intPt( m_matrix* p ); |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
343 return pt; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
344 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
345 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
346 DoublePoint3D Camera::toVirtualScreenCoordinates(ExactModelCoordinate elevation_coords) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
347 ExactModelCoordinate p = elevation_coords; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
348 DoublePoint3D pt = (m_vs_matrix * p); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
349 return pt; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
350 } |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
351 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
352 ScreenPoint Camera::virtualScreenToScreen(const DoublePoint3D& p) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
353 return doublePt2intPt(m_vscreen_2_screen * p); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
354 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
355 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
356 DoublePoint3D Camera::screenToVirtualScreen(const ScreenPoint& p) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
357 return m_screen_2_vscreen * intPt2doublePt(p); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
358 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
359 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
360 DoublePoint Camera::getLogicalCellDimensions(Layer* layer) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
361 CellGrid* cg = NULL; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
362 if (layer) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
363 cg = layer->getCellGrid(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
364 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
365 assert(cg); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
366 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
367 ModelCoordinate cell(0,0); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
368 std::vector<ExactModelCoordinate> vertices; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
369 cg->getVertices(vertices, cell); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
370 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
371 DoubleMatrix mtx; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
372 mtx.loadRotate(m_rotation, 0.0, 0.0, 1.0); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
373 mtx.applyRotate(m_tilt, 1.0, 0.0, 0.0); |
605
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
374 |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
375 double x1 = 0; |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
376 double x2 = 0; |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
377 double y1 = 0; |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
378 double y2 = 0; |
d242e6ce6f9f
Fixed a few compiler warning messages. Also removed a bunch of extra whitespace.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
579
diff
changeset
|
379 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
380 for (unsigned int i = 0; i < vertices.size(); i++) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
381 vertices[i] = cg->toMapCoordinates(vertices[i]); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
382 vertices[i] = mtx * vertices[i]; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
383 if (i == 0) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
384 x1 = x2 = vertices[0].x; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
385 y1 = y2 = vertices[0].y; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
386 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
387 x1 = std::min(vertices[i].x, x1); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
388 x2 = std::max(vertices[i].x, x2); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
389 y1 = std::min(vertices[i].y, y1); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
390 y2 = std::max(vertices[i].y, y2); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
391 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
392 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
393 return DoublePoint( x2 - x1, y2 - y1 ); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
394 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
395 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
396 void Camera::updateReferenceScale() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
397 DoublePoint dim = getLogicalCellDimensions(m_location.getLayer()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
398 m_reference_scale = static_cast<double>(m_screen_cell_width) / dim.x; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
399 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
400 FL_DBG(_log, "Updating reference scale"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
401 FL_DBG(_log, LMsg(" tilt=") << m_tilt << " rot=" << m_rotation); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
402 FL_DBG(_log, LMsg(" m_screen_cell_width=") << m_screen_cell_width); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
403 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
404 |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
405 bool Camera::testRenderedViewPort() { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
406 Map* map = m_location.getMap(); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
407 Rect cv = m_viewport; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
408 int cv2x = cv.x+cv.w; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
409 int cv2y = cv.y+cv.h; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
410 bool trec1 = false, trec2 = false, trec3 = false, trec4 = false; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
411 Rect rec1 = Rect(cv.x, cv.y, 1, 1); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
412 Rect rec2 = Rect(cv.x, cv2y, 1, 1); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
413 Rect rec3 = Rect(cv2x, cv.y, 1, 1); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
414 Rect rec4 = Rect(cv2x, cv2y, 1, 1); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
415 |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
416 const std::list<Layer*>& layers = map->getLayers(); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
417 std::list<Layer*>::const_iterator layer_it = layers.begin(); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
418 const RenderList& layer_instances = m_layer_to_instances[*layer_it]; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
419 RenderList::const_iterator instance_it = layer_instances.begin(); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
420 for(; instance_it != layer_instances.end(); ++instance_it) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
421 Instance* i = (*instance_it)->instance; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
422 const RenderItem& vc = **instance_it; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
423 if(vc.dimensions.intersects(rec1) && !trec1) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
424 trec1 = true; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
425 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
426 if(vc.dimensions.intersects(rec2) && !trec2) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
427 trec2 = true; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
428 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
429 if(trec1 && trec2) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
430 break; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
431 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
432 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
433 if(trec1 && trec2) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
434 RenderList::const_reverse_iterator instance_itr = layer_instances.rbegin(); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
435 for(; instance_itr != layer_instances.rend(); ++instance_itr) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
436 Instance* i = (*instance_itr)->instance; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
437 const RenderItem& vc = **instance_itr; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
438 if(vc.dimensions.intersects(rec3) && !trec3) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
439 trec3 = true; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
440 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
441 if(vc.dimensions.intersects(rec4) && !trec4) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
442 trec4 = true; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
443 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
444 if(trec3 && trec4) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
445 break; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
446 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
447 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
448 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
449 |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
450 if(trec1 && trec2 && trec3 && trec4) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
451 return false; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
452 } |
634
5f381fa34769
* Added the clearBackBuffer() function to the renderbackends.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
633
diff
changeset
|
453 m_renderbackend->clearBackBuffer(); |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
454 return true; |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
455 } |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
456 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
457 void Camera::getMatchingInstances(ScreenPoint screen_coords, Layer& layer, std::list<Instance*>& instances) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
458 instances.clear(); |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
459 const RenderList& layer_instances = m_layer_to_instances[&layer]; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
460 RenderList::const_iterator instance_it = layer_instances.end(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
461 while (instance_it != layer_instances.begin()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
462 --instance_it; |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
463 Instance* i = (*instance_it)->instance; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
464 const RenderItem& vc = **instance_it; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
465 if ((vc.dimensions.contains(Point(screen_coords.x, screen_coords.y)))) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
466 assert(vc.image); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
467 Uint8 r, g, b, a; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
468 int x = screen_coords.x - vc.dimensions.x; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
469 int y = screen_coords.y - vc.dimensions.y; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
470 if (m_zoom != 1.0) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
471 double fx = static_cast<double>(x); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
472 double fy = static_cast<double>(y); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
473 double fow = static_cast<double>(vc.image->getWidth()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
474 double foh = static_cast<double>(vc.image->getHeight()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
475 double fsw = static_cast<double>(vc.dimensions.w); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
476 double fsh = static_cast<double>(vc.dimensions.h); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
477 x = static_cast<int>(round(fx / fsw * fow)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
478 y = static_cast<int>(round(fy / fsh * foh)); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
479 } |
34
d66538926e78
fix getPixelRGBA - it should return r g b and not r b g...
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
28
diff
changeset
|
480 vc.image->getPixelRGBA(x, y, &r, &g, &b, &a); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
481 // instance is hit with mouse if not totally transparent |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
482 if (a != 0) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
483 instances.push_back(i); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
484 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
485 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
486 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
487 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
488 |
18
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
489 void Camera::getMatchingInstances(Rect screen_rect, Layer& layer, std::list<Instance*>& instances) { |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
490 instances.clear(); |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
491 const RenderList& layer_instances = m_layer_to_instances[&layer]; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
492 RenderList::const_iterator instance_it = layer_instances.end(); |
18
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
493 while (instance_it != layer_instances.begin()) { |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
494 --instance_it; |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
495 Instance* i = (*instance_it)->instance;; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
496 const RenderItem& vc = **instance_it; |
18
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
497 if ((vc.dimensions.intersects(screen_rect))) { |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
498 assert(vc.image); |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
499 Uint8 r, g, b, a; |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
500 for(int xx = screen_rect.x; xx < screen_rect.x + screen_rect.w; xx++) { |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
501 for(int yy = screen_rect.y; yy < screen_rect.y + screen_rect.h; yy++) { |
155
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
502 if ((vc.dimensions.contains(Point(xx, yy)))) { |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
503 int x = xx - vc.dimensions.x; |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
504 int y = yy - vc.dimensions.y; |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
505 if (m_zoom != 1.0) { |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
506 double fx = static_cast<double>(x); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
507 double fy = static_cast<double>(y); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
508 double fow = static_cast<double>(vc.image->getWidth()); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
509 double foh = static_cast<double>(vc.image->getHeight()); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
510 double fsw = static_cast<double>(vc.dimensions.w); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
511 double fsh = static_cast<double>(vc.dimensions.h); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
512 x = static_cast<int>(round(fx / fsw * fow)); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
513 y = static_cast<int>(round(fy / fsh * foh)); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
514 } |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
515 vc.image->getPixelRGBA(x, y, &r, &g, &b, &a); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
516 // instance is hit with mouse if not totally transparent |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
517 if (a != 0) { |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
518 instances.push_back(i); |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
519 goto found_non_transparent_pixel; |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
520 } |
18
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
521 } |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
522 } |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
523 } |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
524 found_non_transparent_pixel:; |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
525 } |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
526 } |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
527 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
528 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
529 void Camera::getMatchingInstances(Location& loc, std::list<Instance*>& instances, bool use_exactcoordinates) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
530 instances.clear(); |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
531 const RenderList& layer_instances = m_layer_to_instances[loc.getLayer()]; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
532 RenderList::const_iterator instance_it = layer_instances.end(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
533 while (instance_it != layer_instances.begin()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
534 --instance_it; |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
535 Instance* i = (*instance_it)->instance; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
536 if (use_exactcoordinates) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
537 if (i->getLocationRef().getExactLayerCoordinatesRef() == loc.getExactLayerCoordinatesRef()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
538 instances.push_back(i); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
539 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
540 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
541 if (i->getLocationRef().getLayerCoordinates() == loc.getLayerCoordinates()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
542 instances.push_back(i); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
543 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
544 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
545 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
546 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
547 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
548 void Camera::attach(Instance *instance) { |
10
ab09325f901e
Camera was attached to instance on a different layer, resulting in strange scrolling. Fixed it, and added a check to prevent this happening again (attach-to-other-layer fails and logs a warning).
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
549 // fail if the layers aren't the same |
ab09325f901e
Camera was attached to instance on a different layer, resulting in strange scrolling. Fixed it, and added a check to prevent this happening again (attach-to-other-layer fails and logs a warning).
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
550 if (m_location.getLayer()->getId() != instance->getLocation().getLayer()->getId()) { |
ab09325f901e
Camera was attached to instance on a different layer, resulting in strange scrolling. Fixed it, and added a check to prevent this happening again (attach-to-other-layer fails and logs a warning).
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
551 FL_WARN(_log, "Tried to attach camera to instance on different layer."); |
ab09325f901e
Camera was attached to instance on a different layer, resulting in strange scrolling. Fixed it, and added a check to prevent this happening again (attach-to-other-layer fails and logs a warning).
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
552 return ; |
ab09325f901e
Camera was attached to instance on a different layer, resulting in strange scrolling. Fixed it, and added a check to prevent this happening again (attach-to-other-layer fails and logs a warning).
jwt@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
553 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
554 m_attachedto = instance; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
555 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
556 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
557 void Camera::detach() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
558 m_attachedto = NULL; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
559 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
560 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
561 void Camera::update() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
562 if( !m_attachedto ) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
563 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
564 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
565 Location loc(m_location); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
566 loc.setExactLayerCoordinates( m_attachedto->getLocationRef().getExactLayerCoordinates(m_location.getLayer()) ); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
567 setLocation(loc); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
568 updateMatrices(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
569 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
570 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
571 void Camera::refresh() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
572 updateMatrices(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
573 m_iswarped = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
574 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
575 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
576 void Camera::resetUpdates() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
577 m_iswarped = false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
578 m_prev_origo = m_cur_origo; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
579 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
580 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
581 bool pipelineSort(const RendererBase* lhs, const RendererBase* rhs) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
582 return (lhs->getPipelinePosition() < rhs->getPipelinePosition()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
583 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
584 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
585 void Camera::addRenderer(RendererBase* renderer) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
586 renderer->setRendererListener(this); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
587 m_renderers[renderer->getName()] = renderer; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
588 if (renderer->isEnabled()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
589 m_pipeline.push_back(renderer); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
590 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
591 m_pipeline.sort(pipelineSort); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
592 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
593 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
594 void Camera::onRendererPipelinePositionChanged(RendererBase* renderer) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
595 m_pipeline.sort(pipelineSort); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
596 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
597 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
598 void Camera::onRendererEnabledChanged(RendererBase* renderer) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
599 assert(m_renderers[renderer->getName()]); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
600 if (renderer->isEnabled()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
601 FL_LOG(_log, LMsg("Enabling renderer ") << renderer->getName()); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
602 m_pipeline.push_back(renderer); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
603 m_pipeline.sort(pipelineSort); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
604 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
605 m_pipeline.remove(renderer); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
606 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
607 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
608 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
609 RendererBase* Camera::getRenderer(const std::string& name) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
610 return m_renderers[name]; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
611 } |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
612 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
613 void Camera::resetRenderers() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
614 std::map<std::string, RendererBase*>::iterator r_it = m_renderers.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
615 for (; r_it != m_renderers.end(); ++r_it) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
616 Map* map = m_location.getMap(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
617 r_it->second->reset(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
618 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
619 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
620 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
621 void Camera::addLayer(Layer* layer) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
622 m_cache[layer] = new LayerCache(this, m_ipool, m_apool); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
623 m_cache[layer]->setLayer(layer); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
624 m_layer_to_instances[layer] = RenderList(); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
625 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
626 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
627 void Camera::removeLayer(Layer* layer) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
628 delete m_cache[layer]; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
629 m_cache.erase(layer); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
630 m_layer_to_instances.erase(layer); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
631 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
632 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
633 void Camera::render() { |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
634 Transform transform = NormalTransform; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
635 if(m_iswarped) |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
636 transform = WarpedTransform; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
637 m_iswarped = false; |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
638 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
639 Map* map = m_location.getMap(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
640 if (!map) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
641 FL_ERR(_log, "No map for camera found"); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
642 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
643 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
644 //if ((!map->isChanged()) && (!m_iswarped) && (cammove == ScreenPoint(0,0,0))) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
645 // return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
646 //} |
405
cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
399
diff
changeset
|
647 |
579
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
648 if(m_backendSDL) { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
649 m_renderbackend->pushClipArea(getViewPort()); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
650 } else { |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
651 m_renderbackend->pushClipArea(getViewPort(), testRenderedViewPort()); |
b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
549
diff
changeset
|
652 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
653 // update each layer |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
654 // m_layer_to_instances.clear(); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
655 const std::list<Layer*>& layers = map->getLayers(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
656 std::list<Layer*>::const_iterator layer_it = layers.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
657 for (;layer_it != layers.end(); ++layer_it) { |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
658 LayerCache* cache = m_cache[*layer_it]; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
659 if(!cache) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
660 addLayer(*layer_it); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
661 cache = m_cache[*layer_it]; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
662 FL_ERR(_log, LMsg("Layer Cache miss! (This shouldn't happen!)") << (*layer_it)->getId()); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
663 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
664 RenderList& instances_to_render = m_layer_to_instances[*layer_it]; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
665 cache->update(transform, instances_to_render); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
666 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
667 std::list<RendererBase*>::iterator r_it = m_pipeline.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
668 for (; r_it != m_pipeline.end(); ++r_it) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
669 if ((*r_it)->isActivedLayer(*layer_it)) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
670 (*r_it)->render(this, *layer_it, instances_to_render); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
671 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
672 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
673 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
674 m_renderbackend->popClipArea(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
675 resetUpdates(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
676 m_updated = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
677 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
678 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
679 } |