Showing the changes to interface/src/main.cpp (1 of 7 files). Show all
Unified · Split
| @@ -1489,11 +1489,34 @@ void addVoxelUnderCursor() { · 1488 unmodified lines | |||
| 1489 | 1489 | ||
| 1490 | VoxelDetail detail; | 1490 | VoxelDetail detail; |
| 1491 | float distance; | 1491 | float distance; |
| 1492 | if (voxels.findRayIntersection(origin, direction, detail, distance)) { | 1492 | BoxFace face; |
| 1493 | // get the hit location relative to the center of the voxel | 1493 | if (voxels.findRayIntersection(origin, direction, detail, distance, face)) { |
| 1494 | float half = detail.s * 0.5f; | 1494 | // use the face to determine the side on which to create a neighbor |
| 1495 | glm::vec3 hit = origin + distance*direction - glm::vec3(detail.x + half, detail.y + half, detail.z + half); | 1495 | switch (face) { |
| 1496 | 1496 | case MIN_X_FACE: | |
| 1497 | detail.x -= detail.s; | ||
| 1498 | break; | ||
| 1499 | |||
| 1500 | case MAX_X_FACE: | ||
| 1501 | detail.x += detail.s; | ||
| 1502 | break; | ||
| 1503 | |||
| 1504 | case MIN_Y_FACE: | ||
| 1505 | detail.y -= detail.s; | ||
| 1506 | break; | ||
| 1507 | |||
| 1508 | case MAX_Y_FACE: | ||
| 1509 | detail.y += detail.s; | ||
| 1510 | break; | ||
| 1511 | |||
| 1512 | case MIN_Z_FACE: | ||
| 1513 | detail.z -= detail.s; | ||
| 1514 | break; | ||
| 1515 | |||
| 1516 | case MAX_Z_FACE: | ||
| 1517 | detail.z += detail.s; | ||
| 1518 | break; | ||
| 1519 | } | ||
| 1497 | unsigned char* bufferOut; | 1520 | unsigned char* bufferOut; |
| 1498 | int sizeOut; | 1521 | int sizeOut; |
| 1499 | 1522 | ||
| @@ -1510,7 +1533,8 @@ void deleteVoxelUnderCursor() { · 10 unmodified lines | |||
| 1510 | 1533 | ||
| 1511 | VoxelDetail detail; | 1534 | VoxelDetail detail; |
| 1512 | float distance; | 1535 | float distance; |
| 1513 | if (voxels.findRayIntersection(origin, direction, detail, distance)) { | 1536 | BoxFace face; |
| 1537 | if (voxels.findRayIntersection(origin, direction, detail, distance, face)) { | ||
| 1514 | unsigned char* bufferOut; | 1538 | unsigned char* bufferOut; |
| 1515 | int sizeOut; | 1539 | int sizeOut; |
| 1516 | 1540 | ||