Mercurial > fife-parpg
comparison engine/core/model/structures/layer.cpp @ 6:61fdc090b0d4
both techdemo maps are now loaded correctly. Still segfaulting when scripts end
author | jasoka@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 05 Jul 2008 09:14:21 +0000 |
parents | 4a0efb7baf70 |
children | 90005975cdbb |
comparison
equal
deleted
inserted
replaced
5:427bb0de3e29 | 6:61fdc090b0d4 |
---|---|
117 | 117 |
118 throw NotFound(id); | 118 throw NotFound(id); |
119 } | 119 } |
120 | 120 |
121 void Layer::getMinMaxCoordinates(ModelCoordinate& min, ModelCoordinate& max, const Layer* layer) const { | 121 void Layer::getMinMaxCoordinates(ModelCoordinate& min, ModelCoordinate& max, const Layer* layer) const { |
122 if (!layer) { | |
123 layer = this; | |
124 } | |
122 | 125 |
123 if(layer == 0) { | 126 bool first_found = false; |
124 layer = this; | 127 for (std::vector<Instance*>::const_iterator i = m_instances.begin(); i != m_instances.end(); ++i) { |
125 } | 128 if (!first_found) { |
126 | 129 min = m_instances.front()->getLocationRef().getLayerCoordinates(layer); |
127 min = m_instances.front()->getLocationRef().getLayerCoordinates(layer); | 130 max = min; |
128 max = min; | 131 first_found = true; |
129 | 132 } else { |
130 for(std::vector<Instance*>::const_iterator i = m_instances.begin(); | 133 ModelCoordinate coord = (*i)->getLocationRef().getLayerCoordinates(layer); |
131 i != m_instances.end(); | 134 |
132 ++i) { | 135 if(coord.x < min.x) { |
133 | 136 min.x = coord.x; |
134 ModelCoordinate coord = (*i)->getLocationRef().getLayerCoordinates(layer); | 137 } |
135 | 138 |
136 if(coord.x < min.x) { | 139 if(coord.x > max.x) { |
137 min.x = coord.x; | 140 max.x = coord.x; |
138 } | 141 } |
139 | 142 |
140 if(coord.x > max.x) { | 143 if(coord.y < min.y) { |
141 max.x = coord.x; | 144 min.y = coord.y; |
142 } | 145 } |
143 | 146 |
144 if(coord.y < min.y) { | 147 if(coord.y > max.y) { |
145 min.y = coord.y; | 148 max.y = coord.y; |
146 } | 149 } |
147 | 150 } |
148 if(coord.y > max.y) { | 151 } |
149 max.y = coord.y; | 152 if (!first_found) { |
150 } | 153 min = ModelCoordinate(); |
154 max = min; | |
151 } | 155 } |
152 } | 156 } |
153 | 157 |
154 void Layer::setInstancesVisible(bool vis) { | 158 void Layer::setInstancesVisible(bool vis) { |
155 m_instances_visibility = vis; | 159 m_instances_visibility = vis; |