History

Merge branch 'master' of https://github.com/highfidelity/hifi into metavoxels

Andrzej Kapolka committed 12 years ago

Commit e5521342 parents aabff3f 135f96a46 files · +2066 −893Browse files

Showing the changes to interface/src/Application.cpp (1 of 46 files). Show all

Unified · Split

interface/src/Application.cpp+5−59
@@ -661,8 +661,6 @@ void Application::keyPressEvent(QKeyEvent* event) { · 660 unmodified lines
661661 bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);
662662 bool isMeta = event->modifiers().testFlag(Qt::ControlModifier);
663663 switch (event->key()) {
664− case Qt::Key_N:
665− shootParticle();
666664 break;
667665 case Qt::Key_Shift:
668666 if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode)) {
@@ -1466,60 +1464,6 @@ void Application::removeVoxel(glm::vec3 position, · 797 unmodified lines
14661464 _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s);
14671465 }
14681466
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−
15231467
15241468 void Application::makeVoxel(glm::vec3 position,
15251469 float scale,
@@ -2049,7 +1993,7 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot) { · 523 unmodified lines
20491993 glm::vec3 rayOrigin, rayDirection;
20501994 _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection);
20511995 lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE;
2052−
1996+
20531997 } else if (!_lookatTargetAvatar) {
20541998 if (_isHoverVoxel) {
20551999 // Look at the hovered voxel
@@ -4133,11 +4077,12 @@ void Application::processDatagrams() { · 2077 unmodified lines
41334077 break;
41344078
41354079 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);
41384082 break;
41394083
41404084 case PACKET_TYPE_PARTICLE_DATA:
4085+ case PACKET_TYPE_PARTICLE_ERASE:
41414086 case PACKET_TYPE_VOXEL_DATA:
41424087 case PACKET_TYPE_VOXEL_ERASE:
41434088 case PACKET_TYPE_OCTREE_STATS:
@@ -4257,6 +4202,7 @@ void Application::loadScript(const QString& fileNameString){ · 113 unmodified lines
42574202 // we can use the same ones from the application.
42584203 scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender);
42594204 scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender);
4205+ scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree());
42604206
42614207 // hook our avatar object into this script engine
42624208 scriptEngine->setAvatarData(&_myAvatar, "MyAvatar");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t