History

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

Stephen Birarda committed 12 years ago

Commit abddb962 parents 120001e 135f96a46 files · +2067 −894Browse files

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

Unified · Split

interface/src/Application.cpp+6−60
@@ -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)) {
@@ -1467,60 +1465,6 @@ void Application::removeVoxel(glm::vec3 position, · 798 unmodified lines
14671465 _voxels.deleteVoxelAt(voxel.x, voxel.y, voxel.z, voxel.s);
14681466 }
14691467
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−
15241468
15251469 void Application::makeVoxel(glm::vec3 position,
15261470 float scale,
@@ -2053,14 +1997,14 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 526 unmodified lines
20531997 glm::vec3 rayOrigin, rayDirection;
20541998 _viewFrustum.computePickRay(0.5f, 0.5f, rayOrigin, rayDirection);
20551999 lookAtSpot = rayOrigin + rayDirection * FAR_AWAY_STARE;
2056−
2000+
20572001 } else if (!_lookatTargetAvatar) {
20582002 if (_isHoverVoxel) {
20592003 // Look at the hovered voxel
20602004 lookAtSpot = getMouseVoxelWorldCoordinates(_hoverVoxel);
20612005
20622006 } else {
2063− // Just look in direction of the mouse ray
2007+ // Just look in direction of the mouse ray
20642008 lookAtSpot = lookAtRayOrigin + lookAtRayDirection * FAR_AWAY_STARE;
20652009 }
20662010 }
@@ -4139,11 +4083,12 @@ void Application::processDatagrams() { · 2072 unmodified lines
41394083 break;
41404084
41414085 case PACKET_TYPE_PARTICLE_ADD_RESPONSE:
4142− // look up our ParticleEditHanders....
4143− ParticleEditHandle::handleAddResponse(_incomingPacket, bytesReceived);
4086+ // this will keep creatorTokenIDs to IDs mapped correctly
4087+ Particle::handleAddParticleResponse(_incomingPacket, bytesReceived);
41444088 break;
41454089
41464090 case PACKET_TYPE_PARTICLE_DATA:
4091+ case PACKET_TYPE_PARTICLE_ERASE:
41474092 case PACKET_TYPE_VOXEL_DATA:
41484093 case PACKET_TYPE_VOXEL_ERASE:
41494094 case PACKET_TYPE_OCTREE_STATS:
@@ -4263,6 +4208,7 @@ void Application::loadScript(const QString& fileNameString){ · 113 unmodified lines
42634208 // we can use the same ones from the application.
42644209 scriptEngine->getVoxelsScriptingInterface()->setPacketSender(&_voxelEditSender);
42654210 scriptEngine->getParticlesScriptingInterface()->setPacketSender(&_particleEditSender);
4211+ scriptEngine->getParticlesScriptingInterface()->setParticleTree(_particles.getTree());
42664212
42674213 // hook our avatar object into this script engine
42684214 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