Mercurial > fife-parpg
annotate engine/core/model/structures/layer.cpp @ 405:cfe2f6db4964
Reverting my last change to camera.cpp. It caused unexpected results with rotated tiles.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 29 Jan 2010 15:55:47 +0000 |
parents | ab41334e8a57 |
children | 16c2b3ee59ce |
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:
6
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:
6
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:
6
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:
6
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:
6
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:
6
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:
6
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:
6
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:
6
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:
6
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 |
92
746df66978da
* Fix by Sleek & GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
91
diff
changeset
|
31 #include "util/log/logger.h" |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 #include "util/structures/purge.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 #include "layer.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 #include "instance.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 #include "map.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 #include "instancetree.h" |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 namespace FIFE { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 |
92
746df66978da
* Fix by Sleek & GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
91
diff
changeset
|
41 static Logger _log(LM_STRUCTURES); |
746df66978da
* Fix by Sleek & GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
91
diff
changeset
|
42 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 Layer::Layer(const std::string& identifier, Map* map, CellGrid* grid) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 : m_id(identifier), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 m_map(map), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 m_instances_visibility(true), |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
47 m_transparency(0), |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 m_instanceTree(new InstanceTree()), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 m_grid(grid), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 m_pathingstrategy(CELL_EDGES_ONLY), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 m_changelisteners(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 m_changedinstances(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 m_changed(false) { |
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 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 Layer::~Layer() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 purge(m_instances); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 delete m_instanceTree; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 bool Layer::hasInstances() const { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 return !m_instances.empty(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 Instance* Layer::createInstance(Object* object, const ModelCoordinate& p, const std::string& id) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 ExactModelCoordinate emc(static_cast<double>(p.x), static_cast<double>(p.y), static_cast<double>(p.z)); |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
67 return createInstance(object, emc, id); |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
70 Instance* Layer::createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 Location l; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 l.setLayer(this); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 l.setExactLayerCoordinates(p); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 Instance* instance = new Instance(object, l, id); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 m_instances.push_back(instance); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 m_instanceTree->addInstance(instance); |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
78 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 while (i != m_changelisteners.end()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 (*i)->onInstanceCreate(this, instance); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 ++i; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 m_changed = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 return instance; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
87 |
90
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
88 bool Layer::addInstance(Instance* instance, const ExactModelCoordinate& p){ |
91
e7b55b2b398f
Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
90
diff
changeset
|
89 if( !instance ){ |
90
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
90 FL_ERR(_log, "Tried to add an instance to layer, but given instance is invalid"); |
91
e7b55b2b398f
Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
90
diff
changeset
|
91 return false; |
e7b55b2b398f
Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
90
diff
changeset
|
92 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
93 |
90
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
94 Location l; |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
95 l.setLayer(this); |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
96 l.setExactLayerCoordinates(p); |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
97 |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
98 m_instances.push_back(instance); |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
99 m_instanceTree->addInstance(instance); |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
100 |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
101 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin(); |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
102 while (i != m_changelisteners.end()) { |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
103 (*i)->onInstanceCreate(this, instance); |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
104 ++i; |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
105 } |
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
106 m_changed = true; |
91
e7b55b2b398f
Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
90
diff
changeset
|
107 return true; |
90
9855464762c1
Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
46
diff
changeset
|
108 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
109 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 void Layer::deleteInstance(Instance* instance) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 while (i != m_changelisteners.end()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 (*i)->onInstanceDelete(this, instance); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 ++i; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
115 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
116 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 std::vector<Instance*>::iterator it = m_instances.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 for(; it != m_instances.end(); ++it) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 if(*it == instance) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 m_instanceTree->removeInstance(*it); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 delete *it; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 m_instances.erase(it); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 break; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
125 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
126 m_changed = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
127 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
128 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
129 Instance* Layer::getInstance(const std::string& id) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 std::vector<Instance*>::iterator it = m_instances.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
131 for(; it != m_instances.end(); ++it) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
132 if((*it)->getId() == id) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
133 return *it; |
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 throw NotFound(id); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
137 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
138 |
99
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
139 std::vector<Instance*> Layer::getInstances(const std::string& id) { |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
140 std::vector<Instance*> matching_instances; |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
141 std::vector<Instance*>::iterator it = m_instances.begin(); |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
142 for(; it != m_instances.end(); ++it) { |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
143 if((*it)->getId() == id) |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
144 matching_instances.push_back(*it); |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
145 } |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
146 return matching_instances; |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
147 } |
64e7fe3d4288
- added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
92
diff
changeset
|
148 |
255
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
149 std::vector<Instance*> Layer::getInstancesAt(Location& loc, bool use_exactcoordinates) { |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
150 std::vector<Instance*> matching_instances; |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
151 std::vector<Instance*>::iterator it = m_instances.begin(); |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
152 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
153 for(; it != m_instances.end(); ++it) { |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
154 if (use_exactcoordinates) { |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
155 if ((*it)->getLocationRef().getExactLayerCoordinatesRef() == loc.getExactLayerCoordinatesRef()) { |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
156 matching_instances.push_back(*it); |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
157 } |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
158 } else { |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
159 if ((*it)->getLocationRef().getLayerCoordinates() == loc.getLayerCoordinates()) { |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
160 matching_instances.push_back(*it); |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
161 } |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
162 } |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
163 } |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
164 |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
165 return matching_instances; |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
166 } |
51cc05d862f2
Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
181
diff
changeset
|
167 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
168 void Layer::getMinMaxCoordinates(ModelCoordinate& min, ModelCoordinate& max, const Layer* layer) const { |
6
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
169 if (!layer) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
170 layer = this; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
171 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
172 |
6
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
173 bool first_found = false; |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
174 for (std::vector<Instance*>::const_iterator i = m_instances.begin(); i != m_instances.end(); ++i) { |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
175 if (!first_found) { |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
176 min = m_instances.front()->getLocationRef().getLayerCoordinates(layer); |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
177 max = min; |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
178 first_found = true; |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
179 } else { |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
180 ModelCoordinate coord = (*i)->getLocationRef().getLayerCoordinates(layer); |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
181 |
6
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
182 if(coord.x < min.x) { |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
183 min.x = coord.x; |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
184 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
185 |
6
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
186 if(coord.x > max.x) { |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
187 max.x = coord.x; |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
188 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
189 |
6
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
190 if(coord.y < min.y) { |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
191 min.y = coord.y; |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
192 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
193 |
6
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
194 if(coord.y > max.y) { |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
195 max.y = coord.y; |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
196 } |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
197 } |
6
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
198 } |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
199 if (!first_found) { |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
200 min = ModelCoordinate(); |
61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
201 max = min; |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
202 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
203 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
204 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
205 void Layer::setInstancesVisible(bool vis) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
206 m_instances_visibility = vis; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
207 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
208 |
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
209 void Layer::setLayerTransparency(uint8_t transparency) { |
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
210 m_transparency = transparency; |
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
211 } |
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
212 |
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
213 uint8_t Layer::getLayerTransparency() { |
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
214 return m_transparency; |
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
215 } |
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
216 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
217 void Layer::toggleInstancesVisible() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
218 m_instances_visibility = !m_instances_visibility; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
219 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
220 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
221 bool Layer::cellContainsBlockingInstance(const ModelCoordinate& cellCoordinate) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
222 std::list<Instance*> adjacentInstances; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
223 m_instanceTree->findInstances(cellCoordinate, 0, 0, adjacentInstances); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
224 bool blockingInstance = false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
225 for(std::list<Instance*>::const_iterator j = adjacentInstances.begin(); j != adjacentInstances.end(); ++j) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
226 if((*j)->getObject()->isBlocking() && (*j)->getLocationRef().getLayerCoordinates() == cellCoordinate) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
227 blockingInstance = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
228 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
229 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
230 return blockingInstance; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
231 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
232 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
233 bool Layer::update() { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
234 m_changedinstances.clear(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
235 std::vector<Instance*>::iterator it = m_instances.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
236 for(; it != m_instances.end(); ++it) { |
181
56ac89189bc4
fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
99
diff
changeset
|
237 if ((*it)->update() != ICHANGE_NO_CHANGES) { |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
238 m_changedinstances.push_back(*it); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
239 m_changed = true; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
240 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
241 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
242 if (!m_changedinstances.empty()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
243 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
244 while (i != m_changelisteners.end()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
245 (*i)->onLayerChanged(this, m_changedinstances); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
246 ++i; |
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 //std::cout << "Layer named " << Id() << " changed = 1\n"; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
249 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
250 //std::cout << "Layer named " << Id() << " changed = 0\n"; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
251 bool retval = m_changed; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
252 m_changed = false; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
253 return retval; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
254 } |
356
ab41334e8a57
Added or1andov's code with a few adjustments to fix instance transparencies fixed[t:378]
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
255 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
256 void Layer::addChangeListener(LayerChangeListener* listener) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
257 m_changelisteners.push_back(listener); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
258 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
259 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
260 void Layer::removeChangeListener(LayerChangeListener* listener) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
261 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin(); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
262 while (i != m_changelisteners.end()) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
263 if ((*i) == listener) { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
264 m_changelisteners.erase(i); |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
265 return; |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
266 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
267 ++i; |
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 } // FIFE |