- points[2] *= scale;
- points[3] *= scale;
- if (!done && where.x + radius > points[0].x && where.x - radius < points[2].x && where.z + radius > points[0].z && where.z - radius < points[2].z) {
- patchobjects[i][j][patchobjectnum[i][j]] = id;
- patchobjectnum[i][j]++;
- done = 1;
+ if (where.x + radius > points[0].x && where.x - radius < points[1].x && where.z + radius > points[0].z && where.z - radius < points[1].z) {
+ patchobjects[i][j].push_back(id);
+ }
+ }
+ }
+ }
+ }
+}
+
+void Terrain::DeleteObject(unsigned int id)
+{
+ for (int i = 0; i < subdivision; i++) {
+ for (int j = 0; j < subdivision; j++) {
+ for (unsigned int k = 0; k < patchobjects[i][j].size();) {
+ if (patchobjects[i][j][k] == id) {
+ /* Remove all occurences of id (there should never be more than 1 though) */
+ patchobjects[i][j].erase(patchobjects[i][j].begin() + k);
+ } else {
+ /* Update id of other objects if needed */
+ if (patchobjects[i][j][k] > id) {
+ patchobjects[i][j][k]--;