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 | 661 | bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier); |
| 662 | 662 | bool isMeta = event->modifiers().testFlag(Qt::ControlModifier); |
| 663 | 663 | switch (event->key()) { |
| 664 | − case Qt::Key_N: | |
| 665 | − shootParticle(); | |
| 666 | 664 | break; |
| 667 | 665 | case Qt::Key_Shift: |
| 668 | 666 | if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) { |
| @@ -1466,60 +1464,6 @@ void Application::removeVoxel(glm::vec3 position, · 797 unmodified lines | ||
| 1466 | 1464 | _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s); |
| 1467 | 1465 | } |
| 1468 | 1466 | |
| 1469 | −void Application::shootParticle() { | |
| 1470 | − | |
| 1471 | − glm::vec3 position = _viewFrustum.getPosition(); | |
| 1472 | − glm::vec3 direction = _viewFrustum.getDirection(); | |
| 1473 | − const float LINEAR_VELOCITY = 5.f; | |
| 1474 | − glm::vec3 lookingAt = position + (direction * LINEAR_VELOCITY); | |
| 1475 | − | |
| 1476 | − const float radius = 0.125 / TREE_SCALE; | |
| 1477 | − xColor color = { 0, 255, 255}; | |
| 1478 | − glm::vec3 velocity = lookingAt - position; | |
| 1479 | − glm::vec3 gravity = DEFAULT_GRAVITY * 0.f; | |
| 1480 | − float damping = DEFAULT_DAMPING * 0.01f; | |
| 1481 | − QString script( | |
| 1482 | − " function collisionWithVoxel(voxel) { " | |
| 1483 | − " print('collisionWithVoxel(voxel)... '); " | |
| 1484 | − " print('myID=' + Particle.getID() + '\\n'); " | |
| 1485 | − " var voxelColor = voxel.getColor();" | |
| 1486 | − " print('voxelColor=' + voxelColor.red + ', ' + voxelColor.green + ', ' + voxelColor.blue + '\\n'); " | |
| 1487 | − " var myColor = Particle.getColor();" | |
| 1488 | − " print('myColor=' + myColor.red + ', ' + myColor.green + ', ' + myColor.blue + '\\n'); " | |
| 1489 | − " Particle.setColor(voxelColor); " | |
| 1490 | − " var voxelAt = voxel.getPosition();" | |
| 1491 | − " var voxelScale = voxel.getScale();" | |
| 1492 | − " Voxels.queueVoxelDelete(voxelAt.x, voxelAt.y, voxelAt.z, voxelScale); " | |
| 1493 | − " print('Voxels.queueVoxelDelete(' + voxelAt.x + ', ' + voxelAt.y + ', ' + voxelAt.z + ', ' + voxelScale + ')... \\n'); " | |
| 1494 | − " } " | |
| 1495 | − " Particle.collisionWithVoxel.connect(collisionWithVoxel); " ); | |
| 1496 | − | |
| 1497 | − | |
| 1498 | − ParticleEditHandle* particleEditHandle = makeParticle(position / (float)TREE_SCALE, radius, color, | |
| 1499 | − velocity / (float)TREE_SCALE, gravity, damping, NOT_IN_HAND, script); | |
| 1500 | − | |
| 1501 | − // If we wanted to be able to edit this particle after shooting, then we could store this value | |
| 1502 | − // and use it for editing later. But we don't care about that for "shooting" and therefore we just | |
| 1503 | − // clean up our memory now. deleting a ParticleEditHandle does not effect the underlying particle, | |
| 1504 | − // it just removes your ability to edit that particle later. | |
| 1505 | − delete particleEditHandle; | |
| 1506 | −} | |
| 1507 | − | |
| 1508 | −// Caller is responsible for managing this EditableParticle | |
| 1509 | −ParticleEditHandle* Application::newParticleEditHandle(uint32_t id) { | |
| 1510 | − ParticleEditHandle* particleEditHandle = new ParticleEditHandle(&_particleEditSender, _particles.getTree(), id); | |
| 1511 | − return particleEditHandle; | |
| 1512 | −} | |
| 1513 | − | |
| 1514 | −// Caller is responsible for managing this EditableParticle | |
| 1515 | −ParticleEditHandle* Application::makeParticle(glm::vec3 position, float radius, xColor color, glm::vec3 velocity, | |
| 1516 | − glm::vec3 gravity, float damping, bool inHand, QString updateScript) { | |
| 1517 | − | |
| 1518 | − ParticleEditHandle* particleEditHandle = newParticleEditHandle(); | |
| 1519 | − particleEditHandle->createParticle(position, radius, color, velocity, gravity, damping, inHand, updateScript); | |
| 1520 | − return particleEditHandle; | |
| 1521 | −} | |
| 1522 | − | |
| 1523 | 1467 | |
| 1524 | 1468 | void Application::makeVoxel(glm::vec3 position, |
| 1525 | 1469 | float scale, |
| @@ -2049,7 +1993,7 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { · 523 unmodified lines | ||
| 2049 | 1993 | glm::vec3 rayOrigin, rayDirection; |
| 2050 | 1994 | _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection); |
| 2051 | 1995 | lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE; |
| 2052 | − | |
| 1996 | + | |
| 2053 | 1997 | } else if (!_lookatTargetAvatar) { |
| 2054 | 1998 | if (_isHoverVoxel) { |
| 2055 | 1999 | // Look at the hovered voxel |
| @@ -4133,11 +4077,12 @@ void Application::processDatagrams() { · 2077 unmodified lines | ||
| 4133 | 4077 | break; |
| 4134 | 4078 | |
| 4135 | 4079 | case PACKET_TYPE_PARTICLE_ADD_RESPONSE: |
| 4136 | − // look up our ParticleEditHanders.... | |
| 4137 | − ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived); | |
| 4080 | + // this will keep creatorTokenIDs to IDs mapped correctly | |
| 4081 | + Particle::handleAddParticleResponse(_incomingPacket, bytesReceived); | |
| 4138 | 4082 | break; |
| 4139 | 4083 | |
| 4140 | 4084 | case PACKET_TYPE_PARTICLE_DATA: |
| 4085 | + case PACKET_TYPE_PARTICLE_ERASE: | |
| 4141 | 4086 | case PACKET_TYPE_VOXEL_DATA: |
| 4142 | 4087 | case PACKET_TYPE_VOXEL_ERASE: |
| 4143 | 4088 | case PACKET_TYPE_OCTREE_STATS: |
| @@ -4257,6 +4202,7 @@ void Application::loadScript(const QString& fileNameString){ · 113 unmodified lines | ||
| 4257 | 4202 | // we can use the same ones from the application. |
| 4258 | 4203 | scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender); |
| 4259 | 4204 | scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender); |
| 4205 | + scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree()); | |
| 4260 | 4206 | |
| 4261 | 4207 | // hook our avatar object into this script engine |
| 4262 | 4208 | scriptEngine->setAvatarData(&_myAvatar, "MyAvatar"); |