| 165 | } |
| 166 | |
| 167 | void DescriptionEditService::duplicate(ClusteredDataDescription& data, IntVector2D const& origSize, IntVector2D const& size) |
| 168 | { |
| 169 | ClusteredDataDescription result; |
| 170 | |
| 171 | for (int incX = 0; incX < size.x; incX += origSize.x) { |
| 172 | for (int incY = 0; incY < size.y; incY += origSize.y) { |
| 173 | generateNewCreatureIds(data); |
| 174 | |
| 175 | for (auto cluster : data.clusters) { |
| 176 | auto origPos = cluster.getClusterPosFromCells(); |
| 177 | RealVector2D clusterPos = {origPos.x + incX, origPos.y + incY}; |
| 178 | if (clusterPos.x < size.x && clusterPos.y < size.y) { |
| 179 | for (auto& cell : cluster.cells) { |
| 180 | cell.pos = RealVector2D{cell.pos.x + incX, cell.pos.y + incY}; |
| 181 | if (incX > 0 || incY > 0) { |
| 182 | removeMetadata(cell); |
| 183 | } |
| 184 | } |
| 185 | generateNewIds(cluster); |
| 186 | |
| 187 | result.addCluster(cluster); |
| 188 | } |
| 189 | } |
| 190 | for (auto particle : data.particles) { |
| 191 | auto origPos = particle.pos; |
| 192 | particle.pos = RealVector2D{origPos.x + incX, origPos.y + incY}; |
| 193 | if (particle.pos.x < size.x && particle.pos.y < size.y) { |
| 194 | particle.setId(NumberGenerator::get().getId()); |
| 195 | result.addParticle(particle); |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | data = result; |
| 201 | } |
| 202 | |
| 203 | namespace |
| 204 | { |
no test coverage detected