Showing the changes to interface/src/Application.cpp (1 of 46 files). Show all
Unified · Split
| @@ -661,8 +661,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 660 unmodified lines | |||
| 661 | bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier); | 661 | bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier); |
| 662 | bool isMeta = event->modifiers().testFlag(Qt::ControlModifier); | 662 | bool isMeta = event->modifiers().testFlag(Qt::ControlModifier); |
| 663 | switch (event->key()) { | 663 | switch (event->key()) { |
| 664 | case Qt::Key_N: | ||
| 665 | shootParticle(); | ||
| 666 | break; | 664 | break; |
| 667 | case Qt::Key_Shift: | 665 | case Qt::Key_Shift: |
| 668 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { | 666 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { |
| @@ -1467,60 +1465,6 @@ void Application::removeVoxel(glm::vec3 position, · 798 unmodified lines | |||
| 1467 | _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); | 1465 | _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); |
| 1468 | } | 1466 | } |
| 1469 | 1467 | ||
| 1470 | void Application::shootParticle() { | ||
| 1471 | |||
| 1472 | glm::vec3 position = _viewFrustum.getPosition(); | ||
| 1473 | glm::vec3 direction = _viewFrustum.getDirection(); | ||
| 1474 | const float LINEAR_VELOCITY = 5.f; | ||
| 1475 | glm::vec3 lookingAt = position + (direction * LINEAR_VELOCITY); | ||
| 1476 | |||
| 1477 | const float radius = 0.125 / TREE_SCALE; | ||
| 1478 | xColor color = { 0, 255, 255}; | ||
| 1479 | glm::vec3 velocity = lookingAt - position; | ||
| 1480 | glm::vec3 gravity = DEFAULT_GRAVITY * 0.f; | ||
| 1481 | float damping = DEFAULT_DAMPING * 0.01f; | ||
| 1482 | QString script( | ||
| 1483 | " function collisionWithVoxel(voxel) { " | ||
| 1484 | " print('collisionWithVoxel(voxel)... '); " | ||
| 1485 | " print('myID=' + Particle.getID() + '\\n'); " | ||
| 1486 | " var voxelColor = voxel.getColor();" | ||
| 1487 | " print('voxelColor=' + voxelColor.red + ', ' + voxelColor.green + ', ' + voxelColor.blue + '\\n'); " | ||
| 1488 | " var myColor = Particle.getColor();" | ||
| 1489 | " print('myColor=' + myColor.red + ', ' + myColor.green + ', ' + myColor.blue + '\\n'); " | ||
| 1490 | " Particle.setColor(voxelColor); " | ||
| 1491 | " var voxelAt = voxel.getPosition();" | ||
| 1492 | " var voxelScale = voxel.getScale();" | ||
| 1493 | " Voxels.queueVoxelDelete(voxelAt.x, voxelAt.y, voxelAt.z, voxelScale); " | ||
| 1494 | " print('Voxels.queueVoxelDelete(' + voxelAt.x + ', ' + voxelAt.y + ', ' + voxelAt.z + ', ' + voxelScale + ')... \\n'); " | ||
| 1495 | " } " | ||
| 1496 | " Particle.collisionWithVoxel.connect(collisionWithVoxel); " ); | ||
| 1497 | |||
| 1498 | |||
| 1499 | ParticleEditHandle* particleEditHandle = makeParticle(position / (float)TREE_SCALE, radius, color, | ||
| 1500 | velocity / (float)TREE_SCALE, gravity, damping, NOT_IN_HAND, script); | ||
| 1501 | |||
| 1502 | // If we wanted to be able to edit this particle after shooting, then we could store this value | ||
| 1503 | // and use it for editing later. But we don't care about that for "shooting" and therefore we just | ||
| 1504 | // clean up our memory now. deleting a ParticleEditHandle does not effect the underlying particle, | ||
| 1505 | // it just removes your ability to edit that particle later. | ||
| 1506 | delete particleEditHandle; | ||
| 1507 | } | ||
| 1508 | |||
| 1509 | // Caller is responsible for managing this EditableParticle | ||
| 1510 | ParticleEditHandle* Application::newParticleEditHandle(uint32_t id) { | ||
| 1511 | ParticleEditHandle* particleEditHandle = new ParticleEditHandle(&_particleEditSender, _particles.getTree(), id); | ||
| 1512 | return particleEditHandle; | ||
| 1513 | } | ||
| 1514 | |||
| 1515 | // Caller is responsible for managing this EditableParticle | ||
| 1516 | ParticleEditHandle* Application::makeParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity, | ||
| 1517 | glm::vec3 gravity, float damping, bool inHand, QString updateScript) { | ||
| 1518 | |||
| 1519 | ParticleEditHandle* particleEditHandle = newParticleEditHandle(); | ||
| 1520 | particleEditHandle->createParticle(position, radius, color, velocity, gravity, damping, inHand, updateScript); | ||
| 1521 | return particleEditHandle; | ||
| 1522 | } | ||
| 1523 | |||
| 1524 | 1468 | ||
| 1525 | void Application::makeVoxel(glm::vec3 position, | 1469 | void Application::makeVoxel(glm::vec3 position, |
| 1526 | float scale, | 1470 | float scale, |
| @@ -2053,14 +1997,14 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 526 unmodified lines | |||
| 2053 | glm::vec3 rayOrigin, rayDirection; | 1997 | glm::vec3 rayOrigin, rayDirection; |
| 2054 | _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection); | 1998 | _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection); |
| 2055 | lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE; | 1999 | lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE; |
| 2056 | 2000 | ||
| 2057 | } else if (!_lookatTargetAvatar) { | 2001 | } else if (!_lookatTargetAvatar) { |
| 2058 | if (_isHoverVoxel) { | 2002 | if (_isHoverVoxel) { |
| 2059 | // Look at the hovered voxel | 2003 | // Look at the hovered voxel |
| 2060 | lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel); | 2004 | lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel); |
| 2061 | 2005 | ||
| 2062 | } else { | 2006 | } else { |
| 2063 | // Just look in direction of the mouse ray | 2007 | // Just look in direction of the mouse ray |
| 2064 | lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE; | 2008 | lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE; |
| 2065 | } | 2009 | } |
| 2066 | } | 2010 | } |
| @@ -4139,11 +4083,12 @@ void Application::processDatagrams() { · 2072 unmodified lines | |||
| 4139 | break; | 4083 | break; |
| 4140 | 4084 | ||
| 4141 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: | 4085 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: |
| 4142 | // look up our ParticleEditHanders.... | 4086 | // this will keep creatorTokenIDs to IDs mapped correctly |
| 4143 | ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived); | 4087 | Particle::handleAddParticleResponse(_incomingPacket, bytesReceived); |
| 4144 | break; | 4088 | break; |
| 4145 | 4089 | ||
| 4146 | case PACKET_TYPE_PARTICLE_DATA: | 4090 | case PACKET_TYPE_PARTICLE_DATA: |
| 4091 | case PACKET_TYPE_PARTICLE_ERASE: | ||
| 4147 | case PACKET_TYPE_VOXEL_DATA: | 4092 | case PACKET_TYPE_VOXEL_DATA: |
| 4148 | case PACKET_TYPE_VOXEL_ERASE: | 4093 | case PACKET_TYPE_VOXEL_ERASE: |
| 4149 | case PACKET_TYPE_OCTREE_STATS: | 4094 | case PACKET_TYPE_OCTREE_STATS: |
| @@ -4263,6 +4208,7 @@ void Application::loadScript(const QString& fileNameString){ · 113 unmodified lines | |||
| 4263 | // we can use the same ones from the application. | 4208 | // we can use the same ones from the application. |
| 4264 | scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender); | 4209 | scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender); |
| 4265 | scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender); | 4210 | scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender); |
| 4211 | scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree()); | ||
| 4266 | 4212 | ||
| 4267 | // hook our avatar object into this script engine | 4213 | // hook our avatar object into this script engine |
| 4268 | scriptEngine->setAvatarData(&_myAvatar, "MyAvatar"); | 4214 | scriptEngine->setAvatarData(&_myAvatar, "MyAvatar"); |