Mercurial > fife-parpg
annotate engine/core/view/camera.cpp @ 579:b2feacaed53c
* Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
* Improved the most renderers with setColor() function.
* Fixed the genericrenderer, is now tested whether the images are in the viewport.
* Fixed the gridrenderer, the grid is now drawn only up to the viewport.
* Changed the vertex functions in opengl/renderbackendopengl.cpp from vertex3f() to vertex2f().
* Improved the Editor, now you can use blocking, grid and coordinate renderer over gui or keys. Additionally, the colors can be changed with the settings.xml.
author | helios2000@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 31 Jul 2010 17:46:19 +0000 |
parents | c9113e23b004 |
children | d242e6ce6f9f |
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 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
61 public: |
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; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
64 } |
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 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
67 virtual void onMapChanged(Map* map, std::vector<Layer*>& changedLayers) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
68 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
69 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
70 virtual void onLayerCreate(Map* map, Layer* layer) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
71 m_camera->addLayer(layer); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
72 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
73 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
74 virtual void onLayerDelete(Map* map, Layer* layer) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
75 m_camera->removeLayer(layer); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
76 } |
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(); |
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
|
132 m_renderbackend->isClearNeeded(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()); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
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 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
281 |
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 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
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(); |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
323 |
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); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
330 screen_coords.z = static_cast<int>(tan(m_tilt * (M_PI / 180.0)) * static_cast<double>(dy)); |
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 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
351 |
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); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
374 double x1, x2, y1, y2; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
375 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
|
376 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
|
377 vertices[i] = mtx * vertices[i]; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
378 if (i == 0) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
379 x1 = x2 = vertices[0].x; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
380 y1 = y2 = vertices[0].y; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
381 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
382 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
|
383 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
|
384 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
|
385 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
|
386 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
387 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
388 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
|
389 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
390 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
391 void Camera::updateReferenceScale() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
392 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
|
393 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
|
394 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
395 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
|
396 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
|
397 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
|
398 } |
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
|
399 |
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
|
400 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
|
401 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
|
402 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
|
403 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
|
404 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
|
405 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
|
406 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
|
407 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
|
408 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
|
409 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
|
410 |
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 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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 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
|
417 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
|
418 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
|
419 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
|
420 } |
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 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
|
422 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
|
423 } |
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 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
|
425 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
|
426 } |
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 } |
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 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 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
|
434 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
|
435 } |
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 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
|
437 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
|
438 } |
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 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
|
440 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
|
441 } |
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 } |
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 |
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 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
|
446 m_renderbackend->isClearNeeded(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
|
447 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
|
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 m_renderbackend->isClearNeeded(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
|
450 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
|
451 } |
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 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
453 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
|
454 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
|
455 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
|
456 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
|
457 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
|
458 --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
|
459 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
|
460 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
|
461 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
|
462 assert(vc.image); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
463 Uint8 r, g, b, a; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
464 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
|
465 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
|
466 if (m_zoom != 1.0) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
467 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
|
468 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
|
469 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
|
470 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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 } |
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
|
476 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
|
477 // 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
|
478 if (a != 0) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
479 instances.push_back(i); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
480 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
481 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
482 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
483 } |
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
|
484 |
18
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
485 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
|
486 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
|
487 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
|
488 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
|
489 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
|
490 --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
|
491 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
|
492 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
|
493 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
|
494 assert(vc.image); |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
495 Uint8 r, g, b, a; |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
496 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
|
497 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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 } |
29309cd5e240
fix searching for instances in a rect - old code had false positives
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
57
diff
changeset
|
511 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
|
512 // 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
|
513 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
|
514 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
|
515 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
|
516 } |
18
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
517 } |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
518 } |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
519 } |
40a7c9618ade
* new function which lists instances in a rect
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
10
diff
changeset
|
520 found_non_transparent_pixel:; |
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 } |
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
|
524 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
525 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
|
526 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
|
527 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
|
528 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
|
529 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
|
530 --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
|
531 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
|
532 if (use_exactcoordinates) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
533 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
|
534 instances.push_back(i); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
535 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
536 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
537 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
|
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 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
541 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
542 } |
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 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
|
545 // 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
|
546 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
|
547 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
|
548 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
|
549 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
550 m_attachedto = instance; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
551 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
552 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
553 void Camera::detach() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
554 m_attachedto = NULL; |
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::update() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
558 if( !m_attachedto ) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
559 return; |
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 Location loc(m_location); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
562 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
|
563 setLocation(loc); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
564 updateMatrices(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
565 } |
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
|
566 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
567 void Camera::refresh() { |
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 m_iswarped = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
570 } |
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
|
571 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
572 void Camera::resetUpdates() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
573 m_iswarped = false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
574 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
|
575 } |
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
|
576 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
577 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
|
578 return (lhs->getPipelinePosition() < rhs->getPipelinePosition()); |
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 void Camera::addRenderer(RendererBase* renderer) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
582 renderer->setRendererListener(this); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
583 m_renderers[renderer->getName()] = renderer; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
584 if (renderer->isEnabled()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
585 m_pipeline.push_back(renderer); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
586 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
587 m_pipeline.sort(pipelineSort); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
588 } |
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
|
589 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
590 void Camera::onRendererPipelinePositionChanged(RendererBase* renderer) { |
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::onRendererEnabledChanged(RendererBase* renderer) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
595 assert(m_renderers[renderer->getName()]); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
596 if (renderer->isEnabled()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
597 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
|
598 m_pipeline.push_back(renderer); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
599 m_pipeline.sort(pipelineSort); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
600 } else { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
601 m_pipeline.remove(renderer); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
602 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
603 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
604 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
605 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
|
606 return m_renderers[name]; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
607 } |
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
|
608 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
609 void Camera::resetRenderers() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
610 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
|
611 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
|
612 Map* map = m_location.getMap(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
613 r_it->second->reset(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
614 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
615 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
616 |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
617 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
|
618 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
|
619 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
|
620 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
|
621 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
622 |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
623 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
|
624 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
|
625 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
|
626 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
|
627 } |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
628 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
629 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
|
630 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
|
631 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
|
632 transform = WarpedTransform; |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
633 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
|
634 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
635 Map* map = m_location.getMap(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
636 if (!map) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
637 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
|
638 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
639 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
640 //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
|
641 // return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
642 //} |
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
|
643 |
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
|
644 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
|
645 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
|
646 } 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
|
647 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
|
648 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
649 // 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
|
650 // 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
|
651 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
|
652 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
|
653 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
|
654 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
|
655 if(!cache) { |
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
656 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
|
657 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
|
658 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
|
659 } |
482
16c2b3ee59ce
* Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
432
diff
changeset
|
660 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
|
661 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
|
662 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
663 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
|
664 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
|
665 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
|
666 (*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
|
667 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
668 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
669 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
670 m_renderbackend->popClipArea(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
671 resetUpdates(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
672 m_updated = true; |
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 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
675 } |