Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -1487,6 +1487,44 @@ void Application::doKillLocalVoxels() { · 1486 unmodified lines | ||
| 1487 | 1487 | _wantToKillLocalVoxels = true; |
| 1488 | 1488 | } |
| 1489 | 1489 | |
| 1490 | +void Application::createVoxel(glm::vec3 position, | |
| 1491 | + float scale, | |
| 1492 | + glm::vec3 color, | |
| 1493 | + bool isDestructive) { | |
| 1494 | + VoxelDetail voxel; | |
| 1495 | + voxel.x = position.x / TREE_SCALE; | |
| 1496 | + voxel.y = position.y / TREE_SCALE; | |
| 1497 | + voxel.z = position.z / TREE_SCALE; | |
| 1498 | + voxel.s = scale / TREE_SCALE; | |
| 1499 | + voxel.red = color.x; | |
| 1500 | + voxel.green = color.y; | |
| 1501 | + voxel.blue = color.z; | |
| 1502 | + PACKET_TYPE message = isDestructive ? PACKET_TYPE_SET_VOXEL_DESTRUCTIVE : PACKET_TYPE_SET_VOXEL; | |
| 1503 | + _voxelEditSender.sendVoxelEditMessage(message, voxel); | |
| 1504 | + | |
| 1505 | + // create the voxel locally so it appears immediately | |
| 1506 | + | |
| 1507 | + _voxels.createVoxel(voxel.x, voxel.y, voxel.z, voxel.s, | |
| 1508 | + voxel.red, voxel.green, voxel.blue, | |
| 1509 | + isDestructive); | |
| 1510 | + | |
| 1511 | + // Implement voxel fade effect | |
| 1512 | + VoxelFade fade(VoxelFade::FADE_OUT, 1.0f, 1.0f, 1.0f); | |
| 1513 | + const float VOXEL_BOUNDS_ADJUST = 0.01f; | |
| 1514 | + float slightlyBigger = voxel.s * VOXEL_BOUNDS_ADJUST; | |
| 1515 | + fade.voxelDetails.x = voxel.x - slightlyBigger; | |
| 1516 | + fade.voxelDetails.y = voxel.y - slightlyBigger; | |
| 1517 | + fade.voxelDetails.z = voxel.z - slightlyBigger; | |
| 1518 | + fade.voxelDetails.s = voxel.s + slightlyBigger + slightlyBigger; | |
| 1519 | + _voxelFades.push_back(fade); | |
| 1520 | + | |
| 1521 | + // inject a sound effect | |
| 1522 | + injectVoxelAddedSoundEffect(); | |
| 1523 | + | |
| 1524 | + // remember the position for drag detection | |
| 1525 | + _justEditedVoxel = true; | |
| 1526 | +} | |
| 1527 | + | |
| 1490 | 1528 | const glm::vec3 Application::getMouseVoxelWorldCoordinates(const VoxelDetail _mouseVoxel) { |
| 1491 | 1529 | return glm::vec3((_mouseVoxel.x + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| 1492 | 1530 | (_mouseVoxel.y + _mouseVoxel.s / 2.f) * TREE_SCALE, |
| @@ -4097,6 +4135,8 @@ bool Application::maybeEditVoxelUnderCursor() { · 2604 unmodified lines | ||
| 4097 | 4135 | _voxelEditSender.sendVoxelEditMessage(message, _mouseVoxel); |
| 4098 | 4136 | |
| 4099 | 4137 | // create the voxel locally so it appears immediately |
| 4138 | + printf("create voxel from mouse %.4f, %.4f, %.4f, scale %.6f \n", _mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); | |
| 4139 | + | |
| 4100 | 4140 | _voxels.createVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s, |
| 4101 | 4141 | _mouseVoxel.red, _mouseVoxel.green, _mouseVoxel.blue, |
| 4102 | 4142 | Menu::getInstance()->isOptionChecked(MenuOption::DestructiveAddVoxel)); |