From 18d683bcedfcce37a69e5fb3dca123b1d73f2135 Mon Sep 17 00:00:00 2001 From: Anthony Thibault Date: Mon, 25 May 2015 12:22:38 -0700 Subject: [PATCH 01/12] Particle entities should avoid resetting simulation when setMaxParticles is called. This caused all particles to disappear when a network packet was received. --- .../entities/src/ParticleEffectEntityItem.cpp | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 0879e49f03..8a9212b6f2 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -490,19 +490,21 @@ void ParticleEffectEntityItem::stepSimulation(float deltaTime) { } void ParticleEffectEntityItem::setMaxParticles(quint32 maxParticles) { - _maxParticles = maxParticles; + if (_maxParticles != maxParticles) { + _maxParticles = maxParticles; - // TODO: try to do something smart here and preserve the state of existing particles. + // TODO: try to do something smart here and preserve the state of existing particles. - // resize vectors - _particleLifetimes.resize(_maxParticles); - _particlePositions.resize(_maxParticles); - _particleVelocities.resize(_maxParticles); + // resize vectors + _particleLifetimes.resize(_maxParticles); + _particlePositions.resize(_maxParticles); + _particleVelocities.resize(_maxParticles); - // effectivly clear all particles and start emitting new ones from scratch. - _particleHeadIndex = 0; - _particleTailIndex = 0; - _timeUntilNextEmit = 0.0f; + // effectivly clear all particles and start emitting new ones from scratch. + _particleHeadIndex = 0; + _particleTailIndex = 0; + _timeUntilNextEmit = 0.0f; + } } // because particles are in a ring buffer, this isn't trivial From cbf4e09a102065f017cbf8e2bb23631b299dfacc Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 25 May 2015 16:10:50 -0700 Subject: [PATCH 02/12] Remove global collision event. --- interface/src/Application.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8e23dd8f38..79ec3b79a9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2155,9 +2155,6 @@ void Application::init() { auto entityScriptingInterface = DependencyManager::get(); - connect(&_entitySimulation, &EntitySimulation::entityCollisionWithEntity, - entityScriptingInterface.data(), &EntityScriptingInterface::entityCollisionWithEntity); - // connect the _entityCollisionSystem to our EntityTreeRenderer since that's what handles running entity scripts connect(&_entitySimulation, &EntitySimulation::entityCollisionWithEntity, &_entities, &EntityTreeRenderer::entityCollisionWithEntity); From 706c837886481bd5d1cb1689bd51096f2e5ed04e Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 25 May 2015 17:12:36 -0700 Subject: [PATCH 03/12] Use collisionSoundURL for billiards.js, instead of the global collision event. --- examples/example/games/billiards.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/examples/example/games/billiards.js b/examples/example/games/billiards.js index 5e08322c77..25ff5e7eae 100644 --- a/examples/example/games/billiards.js +++ b/examples/example/games/billiards.js @@ -33,8 +33,8 @@ var cuePosition; var startStroke = 0; // Sounds to use -hitSounds = []; -hitSounds.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "Collisions-ballhitsandcatches/billiards/collision1.wav")); +var hitSound = HIFI_PUBLIC_BUCKET + "sounds/Collisions-ballhitsandcatches/billiards/collision1.wav"; +SoundCache.getSound(hitSound); HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; var screenSize = Controller.getViewportDimensions(); @@ -127,6 +127,7 @@ function makeBalls(pos) { ignoreCollisions: false, damping: 0.50, shapeType: "sphere", + collisionSoundURL: hitSound, collisionsWillMove: true })); ballPosition.z += (BALL_SIZE + BALL_GAP) * SCALE; ballNumber++; @@ -225,26 +226,11 @@ function update(deltaTime) { } } -function entityCollisionWithEntity(entity1, entity2, collision) { - /* - NOT WORKING YET - if ((entity1.id == cueBall.id) || (entity2.id == cueBall.id)) { - print("Cue ball collision!"); - //audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())); - //Audio.playSound(hitSounds[0], { position: Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())) }); - } - - else if (isObjectBall(entity1.id) || isObjectBall(entity2.id)) { - print("Object ball collision"); - } */ -} - tableCenter = Vec3.sum(MyAvatar.position, Vec3.multiply(4.0, Quat.getFront(Camera.getOrientation()))); makeTable(tableCenter); makeBalls(tableCenter); -Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity); Script.scriptEnding.connect(cleanup); Controller.keyPressEvent.connect(keyPressEvent); Controller.keyReleaseEvent.connect(keyReleaseEvent); From 09e9d353ead27aea0bbde5db0434738d9d876a67 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 25 May 2015 17:15:55 -0700 Subject: [PATCH 04/12] Deprecate globalCollisionsExample.js, and add entityCollisionExample.js --- examples/example/entityCollisionExample.js | 53 +++++++++++++++++++++ examples/example/globalCollisionsExample.js | 17 ++----- 2 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 examples/example/entityCollisionExample.js diff --git a/examples/example/entityCollisionExample.js b/examples/example/entityCollisionExample.js new file mode 100644 index 0000000000..dcbefe1378 --- /dev/null +++ b/examples/example/entityCollisionExample.js @@ -0,0 +1,53 @@ +// +// globalCollisionsExample.js +// examples +// +// Created by Brad Hefta-Gaub on 1/29/14. +// Copyright 2014 High Fidelity, Inc. +// +// This is an example script that demonstrates use of the Controller class +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +function someCollisionFunction(entityA, entityB, collision) { + print("collision: " + JSON.stringify({a: entityA, b: entityB, c: collision})); +} + +var position = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation)); +var properties = { + type: "Box", + position: position, + collisionsWillMove: true, + color: { red: 200, green: 0, blue: 0 } +}; +var collider = Entities.addEntity(properties); +var armed = false; +function togglePrinting() { + print('togglePrinting from ' + armed + ' on ' + collider); + if (armed) { + Script.removeEventHandler(collider, "collisionWithEntity", someCollisionFunction); + } else { + Script.addEventHandler(collider, "collisionWithEntity", someCollisionFunction); + } + armed = !armed; + print("Red box " + (armed ? "will" : "will not") + " print on collision."); +} +togglePrinting(); + +properties.position.y += 0.2; +properties.color.blue += 200; +// A handy target for the collider to hit. +var target = Entities.addEntity(properties); + +properties.position.y += 0.2; +properties.color.green += 200; +var button = Entities.addEntity(properties); +Script.addEventHandler(button, "clickReleaseOnEntity", togglePrinting); + +Script.scriptEnding.connect(function () { + Entities.deleteEntity(collider); + Entities.deleteEntity(target); + Entities.deleteEntity(button); +}); diff --git a/examples/example/globalCollisionsExample.js b/examples/example/globalCollisionsExample.js index 5813cb2472..99fd72696d 100644 --- a/examples/example/globalCollisionsExample.js +++ b/examples/example/globalCollisionsExample.js @@ -12,17 +12,6 @@ // -print("hello..."); - - -function entityCollisionWithEntity(entityA, entityB, collision) { - print("entityCollisionWithParticle().."); - print(" entityA.getID()=" + entityA.id); - print(" entityB.getID()=" + entityB.id); - Vec3.print('penetration=', collision.penetration); - Vec3.print('contactPoint=', collision.contactPoint); -} - -Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity); - -print("here... hello..."); +print("The is obsolete. Please instead use:"); +print(" the collisionSoundURL property on entities, or"); +print(" entityCollisionExample.js"); From 590ad22d89135ff75a4102126c2f97971acab16b Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 25 May 2015 17:16:35 -0700 Subject: [PATCH 05/12] Update spaceInvaders to use per-entity collision handlers. Also fix bitrot: * The 'f' key triggers a profile, after which all bets are off regarding time-dependent behavior such as lifetime and update(). (I'm moving space-invaders "fire" to the space bar as a work-around.) * You don't get a collision without a non-default shapeType property (if the object type is "Model") a truthy collisionsWillMove property * Entity handles (such as returned by Entity.addEntity) no longer have a separate 'id' property, so don't reference that. Just use the handle object itself. * When an entity's lifetime expires, Entities.getEntityProperties(theEntityHandle) returns default values. It looks like the space-invaders script was written at a time when this returned falsey. (I'm changing the script to see if the properties.type === 'Unknown'.) NOT FIXED is that the level of detail is cutting out when showing all the invaders. --- .../example/games/spaceInvadersExample.js | 70 ++++++++++--------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/examples/example/games/spaceInvadersExample.js b/examples/example/games/spaceInvadersExample.js index 819cf6b774..08ad56c04d 100644 --- a/examples/example/games/spaceInvadersExample.js +++ b/examples/example/games/spaceInvadersExample.js @@ -21,6 +21,16 @@ var gameOver = false; var invaderStepsPerCycle = 120; // the number of update steps it takes then invaders to move one column to the right var invaderStepOfCycle = 0; // current iteration in the cycle var invaderMoveDirection = 1; // 1 for moving to right, -1 for moving to left +var LEFT = ","; +var RIGHT = "."; +var FIRE = "SPACE"; +var QUIT = "q"; + +print("Use:"); +print(LEFT + " to move left"); +print(RIGHT + " to move right"); +print(FIRE + " to fire"); +print(QUIT + " to quit"); // game length... var itemLifetimes = 60; // 1 minute @@ -65,8 +75,8 @@ var myShipProperties; // create the rows of space invaders var invaders = new Array(); -var numberOfRows = 5; -var invadersPerRow = 8; +var numberOfRows = 3 // FIXME 5; +var invadersPerRow = 3 // FIXME 8; var emptyColumns = 2; // number of invader width columns not filled with invaders var invadersBottomCorner = { x: gameAt.x, y: middleY , z: gameAt.z }; var rowHeight = ((gameAt.y + gameSize.y) - invadersBottomCorner.y) / numberOfRows; @@ -80,7 +90,6 @@ var stepsToGround = (middleY - gameAt.y) / yPerStep; var maxInvaderRowOffset=stepsToGround; // missile related items -var missileFired = false; var myMissile; // sounds @@ -174,6 +183,7 @@ function initializeInvaders() { invaderPosition = getInvaderPosition(row, column); invaders[row][column] = Entities.addEntity({ type: "Model", + shapeType: "box", position: invaderPosition, velocity: { x: 0, y: 0, z: 0 }, gravity: { x: 0, y: 0, z: 0 }, @@ -181,6 +191,7 @@ function initializeInvaders() { dimensions: { x: invaderSize * 2, y: invaderSize * 2, z: invaderSize * 2 }, color: { red: 255, green: 0, blue: 0 }, modelURL: invaderModels[row].modelURL, + collisionsWillMove: true, lifetime: itemLifetimes }); } @@ -264,17 +275,17 @@ Script.update.connect(update); function cleanupGame() { print("cleaning up game..."); Entities.deleteEntity(myShip); - print("cleanupGame() ... Entities.deleteEntity(myShip)... myShip.id="+myShip.id); + print("cleanupGame() ... Entities.deleteEntity(myShip)... myShip="+myShip); for (var row = 0; row < numberOfRows; row++) { for (var column = 0; column < invadersPerRow; column++) { Entities.deleteEntity(invaders[row][column]); - print("cleanupGame() ... Entities.deleteEntity(invaders[row][column])... invaders[row][column].id=" - +invaders[row][column].id); + print("cleanupGame() ... Entities.deleteEntity(invaders[row][column])... invaders[row][column]=" + +invaders[row][column]); } } // clean up our missile - if (missileFired) { + if (myMissile) { Entities.deleteEntity(myMissile); } @@ -293,15 +304,23 @@ function moveShipTo(position) { Entities.editEntity(myShip, { position: position }); } +function entityCollisionWithEntity(entityA, entityB, collision) { + print("entityCollisionWithEntity() a="+entityA + " b=" + entityB); + Vec3.print('entityCollisionWithEntity() penetration=', collision.penetration); + Vec3.print('entityCollisionWithEntity() contactPoint=', collision.contactPoint); + + deleteIfInvader(entityB); +} + function fireMissile() { // we only allow one missile at a time... var canFire = false; // If we've fired a missile, then check to see if it's still alive - if (missileFired) { + if (myMissile) { var missileProperties = Entities.getEntityProperties(myMissile); - if (!missileProperties) { + if (!missileProperties || (missileProperties.type === 'Unknown')) { print("canFire = true"); canFire = true; } @@ -322,11 +341,12 @@ function fireMissile() { velocity: { x: 0, y: 5, z: 0}, gravity: { x: 0, y: 0, z: 0 }, damping: 0, - dimensions: { x: missileSize * 2, y: missileSize * 2, z: missileSize * 2 }, + collisionsWillMove: true, + dimensions: { x: missileSize, y: missileSize, z: missileSize }, color: { red: 0, green: 0, blue: 255 }, lifetime: 5 }); - + Script.addEventHandler(myMissile, "collisionWithEntity", entityCollisionWithEntity); var options = {} if (soundInMyHead) { options.position = { x: MyAvatar.position.x + 0.0, @@ -335,30 +355,30 @@ function fireMissile() { } else { options.position = missilePosition; } - + Audio.playSound(shootSound, options); - missileFired = true; } } function keyPressEvent(key) { //print("keyPressEvent key.text="+key.text); - if (key.text == ",") { + + if (key.text == LEFT) { myShipProperties.position.x -= 0.1; if (myShipProperties.position.x < gameAt.x) { myShipProperties.position.x = gameAt.x; } moveShipTo(myShipProperties.position); - } else if (key.text == ".") { + } else if (key.text == RIGHT) { myShipProperties.position.x += 0.1; if (myShipProperties.position.x > gameAt.x + gameSize.x) { myShipProperties.position.x = gameAt.x + gameSize.x; } moveShipTo(myShipProperties.position); - } else if (key.text == "f") { + } else if (key.text == FIRE) { fireMissile(); - } else if (key.text == "q") { + } else if (key.text == QUIT) { endGame(); } } @@ -370,7 +390,7 @@ Controller.captureKeyEvents({text: " "}); function deleteIfInvader(possibleInvaderEntity) { for (var row = 0; row < numberOfRows; row++) { for (var column = 0; column < invadersPerRow; column++) { - if (invaders[row][column].id && invaders[row][column].id == possibleInvaderEntity.id) { + if (invaders[row][column] == possibleInvaderEntity) { Entities.deleteEntity(possibleInvaderEntity); Entities.deleteEntity(myMissile); @@ -390,20 +410,6 @@ function deleteIfInvader(possibleInvaderEntity) { } } -function entityCollisionWithEntity(entityA, entityB, collision) { - print("entityCollisionWithEntity() a.id="+entityA.id + " b.id=" + entityB.id); - Vec3.print('entityCollisionWithEntity() penetration=', collision.penetration); - Vec3.print('entityCollisionWithEntity() contactPoint=', collision.contactPoint); - if (missileFired) { - if (myMissile.id == entityA.id) { - deleteIfInvader(entityB); - } else if (myMissile.id == entityB.id) { - deleteIfInvader(entityA); - } - } -} -Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity); - // initialize the game... initializeMyShip(); From 050829e442dbdd84776df090b9c1d415f7b338f4 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 25 May 2015 17:23:22 -0700 Subject: [PATCH 06/12] typo --- examples/example/globalCollisionsExample.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example/globalCollisionsExample.js b/examples/example/globalCollisionsExample.js index 99fd72696d..624ad43219 100644 --- a/examples/example/globalCollisionsExample.js +++ b/examples/example/globalCollisionsExample.js @@ -12,6 +12,6 @@ // -print("The is obsolete. Please instead use:"); +print("The global collision event is obsolete. Please instead use:"); print(" the collisionSoundURL property on entities, or"); print(" entityCollisionExample.js"); From d214f128cd5061c4c70a26b57b89f50501faaa09 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Mon, 25 May 2015 17:39:15 -0700 Subject: [PATCH 07/12] Miniumum change for gun to use per-entity collisions. I have *not* updated this script for other recent changes (e.g., to entityIDs). --- examples/controllers/hydra/gun.js | 43 +++++++++++++++---------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/examples/controllers/hydra/gun.js b/examples/controllers/hydra/gun.js index 7dd2b5974f..146f9daca3 100644 --- a/examples/controllers/hydra/gun.js +++ b/examples/controllers/hydra/gun.js @@ -153,6 +153,26 @@ if (showScore) { var BULLET_VELOCITY = 10.0; +function entityCollisionWithEntity(entity1, entity2, collision) { + if (entity2 === targetID) { + score++; + if (showScore) { + Overlays.editOverlay(text, { text: "Score: " + score } ); + } + + // We will delete the bullet and target in 1/2 sec, but for now we can see them bounce! + Script.setTimeout(deleteBulletAndTarget, 500); + + // Turn the target and the bullet white + Entities.editEntity(entity1, { color: { red: 255, green: 255, blue: 255 }}); + Entities.editEntity(entity2, { color: { red: 255, green: 255, blue: 255 }}); + + // play the sound near the camera so the shooter can hear it + audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())); + Audio.playSound(targetHitSound, audioOptions); + } +} + function shootBullet(position, velocity, grenade) { var BULLET_SIZE = 0.10; var BULLET_LIFETIME = 10.0; @@ -178,6 +198,7 @@ function shootBullet(position, velocity, grenade) { ignoreCollisions: false, collisionsWillMove: true }); + Script.addEventHandler(bulletID, "collisionWithEntity", entityCollisionWithEntity); // Play firing sounds audioOptions.position = position; @@ -310,27 +331,6 @@ function makePlatform(gravity, scale, size) { } -function entityCollisionWithEntity(entity1, entity2, collision) { - if (((entity1.id == bulletID.id) || (entity1.id == targetID.id)) && - ((entity2.id == bulletID.id) || (entity2.id == targetID.id))) { - score++; - if (showScore) { - Overlays.editOverlay(text, { text: "Score: " + score } ); - } - - // We will delete the bullet and target in 1/2 sec, but for now we can see them bounce! - Script.setTimeout(deleteBulletAndTarget, 500); - - // Turn the target and the bullet white - Entities.editEntity(entity1, { color: { red: 255, green: 255, blue: 255 }}); - Entities.editEntity(entity2, { color: { red: 255, green: 255, blue: 255 }}); - - // play the sound near the camera so the shooter can hear it - audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())); - Audio.playSound(targetHitSound, audioOptions); - } -} - function keyPressEvent(event) { // if our tools are off, then don't do anything if (event.text == "t") { @@ -505,7 +505,6 @@ function scriptEnding() { clearPose(); } -Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity); Script.scriptEnding.connect(scriptEnding); Script.update.connect(update); Controller.mouseReleaseEvent.connect(mouseReleaseEvent); From ae73e68f7bdf0282bbf2eda322da8492efb25942 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Tue, 26 May 2015 13:27:37 -0700 Subject: [PATCH 08/12] Update header. --- examples/example/entityCollisionExample.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/example/entityCollisionExample.js b/examples/example/entityCollisionExample.js index dcbefe1378..de50d52753 100644 --- a/examples/example/entityCollisionExample.js +++ b/examples/example/entityCollisionExample.js @@ -1,11 +1,11 @@ // -// globalCollisionsExample.js +// entityCollisionExample.js // examples // -// Created by Brad Hefta-Gaub on 1/29/14. -// Copyright 2014 High Fidelity, Inc. +// Created by Howard Stearns on 5/25/15. +// Copyright 2015 High Fidelity, Inc. // -// This is an example script that demonstrates use of the Controller class +// This is an example script that demonstrates use of the per-entity event handlers. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -20,7 +20,7 @@ var properties = { type: "Box", position: position, collisionsWillMove: true, - color: { red: 200, green: 0, blue: 0 } + color: { red: 200, green: 0, blue: 0 } }; var collider = Entities.addEntity(properties); var armed = false; From a2272d3f42b381cecc5d721be7e5cb1b31127acf Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 27 May 2015 11:49:00 -0700 Subject: [PATCH 09/12] Fix Windows C4351 build warning VS2013 warns about default initialization of arrays because it behaved differently in previous versions. Default initialization is what we expect now that we're using VS2013 so we can disable this warning globally. --- CMakeLists.txt | 3 ++- interface/src/devices/DdeFaceTracker.cpp | 11 ----------- libraries/networking/src/Assignment.cpp | 6 ------ 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 347341efa0..e57e33e3b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,8 @@ if (WIN32) endif () message (WINDOW_SDK_PATH= ${WINDOW_SDK_PATH}) set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WINDOW_SDK_PATH}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + # /wd4351 disables warning C4351: new behavior: elements of array will be default initialized + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4351") # /LARGEADDRESSAWARE enables 32-bit apps to use more than 2GB of memory. # Caveats: http://stackoverflow.com/questions/2288728/drawbacks-of-using-largeaddressaware-for-32-bit-windows-executables # TODO: Remove when building 64-bit. diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index fba37736e3..27e15cea0e 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -141,13 +141,6 @@ static const float STARTING_DDE_MESSAGE_TIME = 0.033f; static const float DEFAULT_DDE_EYE_CLOSING_THRESHOLD = 0.8f; static const int CALIBRATION_SAMPLES = 150; -#ifdef WIN32 -// warning C4351: new behavior: elements of array 'DdeFaceTracker::_lastEyeBlinks' will be default initialized -// warning C4351: new behavior: elements of array 'DdeFaceTracker::_filteredEyeBlinks' will be default initialized -// warning C4351: new behavior: elements of array 'DdeFaceTracker::_lastEyeCoefficients' will be default initialized -#pragma warning(disable:4351) -#endif - DdeFaceTracker::DdeFaceTracker() : DdeFaceTracker(QHostAddress::Any, DDE_SERVER_PORT, DDE_CONTROL_PORT) { @@ -214,10 +207,6 @@ DdeFaceTracker::~DdeFaceTracker() { } } -#ifdef WIN32 -#pragma warning(default:4351) -#endif - void DdeFaceTracker::init() { FaceTracker::init(); setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::UseCamera) && !_isMuted); diff --git a/libraries/networking/src/Assignment.cpp b/libraries/networking/src/Assignment.cpp index 944041730e..a4fa246c93 100644 --- a/libraries/networking/src/Assignment.cpp +++ b/libraries/networking/src/Assignment.cpp @@ -32,12 +32,6 @@ Assignment::Type Assignment::typeForNodeType(NodeType_t nodeType) { } } -#ifdef WIN32 -//warning C4351: new behavior: elements of array 'Assignment::_payload' will be default initialized -// We're disabling this warning because the new behavior which is to initialize the array with 0 is acceptable to us. -#pragma warning(disable:4351) -#endif - Assignment::Assignment() : _uuid(), _command(Assignment::RequestCommand), From ba0467aafe8359add5b4b8cc28d1c5ab56fc900b Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 27 May 2015 14:10:45 -0700 Subject: [PATCH 10/12] =?UTF-8?q?Revert=20"removed=20const=20keyword=20fro?= =?UTF-8?q?m=20Q=5FINVOKABLE=20for=20avatar=20getter=20methods=20such?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interface/src/avatar/Avatar.h | 6 +++--- libraries/avatars/src/AvatarData.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index 939161327b..0cdaf36099 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -147,9 +147,9 @@ public: Q_INVOKABLE glm::vec3 getNeckPosition() const; - Q_INVOKABLE glm::vec3 getAcceleration() { return _acceleration; } - Q_INVOKABLE glm::vec3 getAngularVelocity() { return _angularVelocity; } - Q_INVOKABLE glm::vec3 getAngularAcceleration() { return _angularAcceleration; } + Q_INVOKABLE const glm::vec3& getAcceleration() const { return _acceleration; } + Q_INVOKABLE const glm::vec3& getAngularVelocity() const { return _angularVelocity; } + Q_INVOKABLE const glm::vec3& getAngularAcceleration() const { return _angularAcceleration; } /// Scales a world space position vector relative to the avatar position and scale diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index a27e4256ef..603b5d76ea 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -301,7 +301,7 @@ public: int getReceiveRate() const; void setVelocity(const glm::vec3 velocity) { _velocity = velocity; } - Q_INVOKABLE glm::vec3 getVelocity() const { return _velocity; } + Q_INVOKABLE const glm::vec3& getVelocity() const { return _velocity; } const glm::vec3& getTargetVelocity() const { return _targetVelocity; } bool shouldDie() const { return _owningAvatarMixer.isNull() || getUsecsSinceLastUpdate() > AVATAR_SILENCE_THRESHOLD_USECS; } From ca85401b77dbfb493007ca9bc73fca6258040068 Mon Sep 17 00:00:00 2001 From: Eric Levin Date: Wed, 27 May 2015 15:08:52 -0700 Subject: [PATCH 11/12] added button so user can toggle pointer on/off --- examples/pointer.js | 101 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 20 deletions(-) diff --git a/examples/pointer.js b/examples/pointer.js index 9ca20504b4..722f1d4f11 100644 --- a/examples/pointer.js +++ b/examples/pointer.js @@ -18,22 +18,33 @@ var position, positionOffset, prevPosition; var nearLinePosition; var strokes = []; var STROKE_ADJUST = 0.005; -var DISTANCE_DRAW_THRESHOLD = .03; +var DISTANCE_DRAW_THRESHOLD = .02; var drawDistance = 0; +var LINE_WIDTH = 20; + var userCanDraw = true; +var userCanPoint = true; var BUTTON_SIZE = 32; var PADDING = 3; -var buttonOffColor = {red: 250, green: 10, blue: 10}; -var buttonOnColor = {red: 10, green: 200, blue: 100}; +var buttonOffColor = { + red: 250, + green: 10, + blue: 10 +}; +var buttonOnColor = { + red: 10, + green: 200, + blue: 100 +}; HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; var screenSize = Controller.getViewportDimensions(); var drawButton = Overlays.addOverlay("image", { - x: screenSize.x / 2 - BUTTON_SIZE * 2 + PADDING, + x: screenSize.x / 2 - BUTTON_SIZE + PADDING * 2, y: screenSize.y - (BUTTON_SIZE + PADDING), width: BUTTON_SIZE, height: BUTTON_SIZE, @@ -42,6 +53,15 @@ var drawButton = Overlays.addOverlay("image", { alpha: 1 }); +var pointerButton = Overlays.addOverlay("image", { + x: screenSize.x / 2 - BUTTON_SIZE * 2 + PADDING, + y: screenSize.y - (BUTTON_SIZE + PADDING), + width: BUTTON_SIZE, + height: BUTTON_SIZE, + imageURL: HIFI_PUBLIC_BUCKET + "images/laser.png", + color: buttonOnColor, + alpha: 1 +}) @@ -50,8 +70,16 @@ center.y += 0.5; var whiteBoard = Entities.addEntity({ type: "Box", position: center, - dimensions: {x: 1, y: 1, z: .001}, - color: {red: 255, green: 255, blue: 255} + dimensions: { + x: 1, + y: 1, + z: .001 + }, + color: { + red: 255, + green: 255, + blue: 255 + } }); function calculateNearLinePosition(targetPosition) { @@ -73,6 +101,9 @@ function removeLine() { function createOrUpdateLine(event) { + if (!userCanPoint) { + return; + } var pickRay = Camera.computePickRay(event.x, event.y); var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking var props = Entities.getEntityProperties(intersection.entityID); @@ -82,14 +113,13 @@ function createOrUpdateLine(event) { var subtractVec = Vec3.multiply(Vec3.normalize(pickRay.direction), STROKE_ADJUST); startPosition = Vec3.subtract(startPosition, subtractVec); nearLinePosition = calculateNearLinePosition(intersection.intersection); - positionOffset= Vec3.subtract(startPosition, nearLinePosition); + positionOffset = Vec3.subtract(startPosition, nearLinePosition); if (lineIsRezzed) { Entities.editEntity(lineEntityID, { position: nearLinePosition, dimensions: positionOffset, - lifetime: 15 + props.lifespan // renew lifetime }); - if(userCanDraw){ + if (userCanDraw) { draw(); } } else { @@ -104,7 +134,6 @@ function createOrUpdateLine(event) { green: 255, blue: 255 }, - lifetime: 15 // if someone crashes while pointing, don't leave the line there forever. }); } } else { @@ -112,11 +141,11 @@ function createOrUpdateLine(event) { } } -function draw(){ +function draw() { //We only want to draw line if distance between starting and previous point is large enough drawDistance = Vec3.distance(startPosition, prevPosition); - if( drawDistance < DISTANCE_DRAW_THRESHOLD){ + if (drawDistance < DISTANCE_DRAW_THRESHOLD) { return; } @@ -125,8 +154,12 @@ function draw(){ type: "Line", position: prevPosition, dimensions: offset, - color: {red: 200, green: 40, blue: 200}, - // lifetime: 20 + color: { + red: 200, + green: 40, + blue: 200 + }, + lineWidth: LINE_WIDTH })); prevPosition = startPosition; } @@ -138,12 +171,38 @@ function mousePressEvent(event) { }); if (clickedOverlay == drawButton) { userCanDraw = !userCanDraw; - if(userCanDraw === true){ - Overlays.editOverlay(drawButton, {color: buttonOnColor}); + if (userCanDraw === true) { + Overlays.editOverlay(drawButton, { + color: buttonOnColor + }); } else { - Overlays.editOverlay(drawButton, {color: buttonOffColor}); + Overlays.editOverlay(drawButton, { + color: buttonOffColor + }); } - } + } + + if (clickedOverlay == pointerButton) { + userCanPoint = !userCanPoint; + if (userCanPoint === true) { + Overlays.editOverlay(pointerButton, { + color: buttonOnColor + }); + if (userCanDraw === true) { + + Overlays.editOverlay(drawButton, { + color: buttonOnColor + }); + } + } else { + Overlays.editOverlay(pointerButton, { + color: buttonOffColor + }); + Overlays.editOverlay(drawButton, { + color: buttonOffColor + }); + } + } if (!event.isLeftButton || altHeld) { return; @@ -154,6 +213,7 @@ function mousePressEvent(event) { } + function mouseMoveEvent(event) { createOrUpdateLine(event); } @@ -182,13 +242,14 @@ function keyReleaseEvent(event) { } -function cleanup(){ +function cleanup() { Entities.deleteEntity(whiteBoard); - for(var i =0; i < strokes.length; i++){ + for (var i = 0; i < strokes.length; i++) { Entities.deleteEntity(strokes[i]); } Overlays.deleteOverlay(drawButton); + Overlays.deleteOverlay(pointerButton); } From 07c8fb6c025b354e291dd6b221439e1856ab8994 Mon Sep 17 00:00:00 2001 From: Eric Levin Date: Wed, 27 May 2015 15:11:16 -0700 Subject: [PATCH 12/12] turned pointer and draw funcitonality off be default --- examples/pointer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/pointer.js b/examples/pointer.js index 722f1d4f11..eebe4ec5be 100644 --- a/examples/pointer.js +++ b/examples/pointer.js @@ -23,8 +23,8 @@ var drawDistance = 0; var LINE_WIDTH = 20; -var userCanDraw = true; -var userCanPoint = true; +var userCanPoint = false; +var userCanDraw = false; var BUTTON_SIZE = 32; var PADDING = 3; @@ -49,7 +49,7 @@ var drawButton = Overlays.addOverlay("image", { width: BUTTON_SIZE, height: BUTTON_SIZE, imageURL: HIFI_PUBLIC_BUCKET + "images/pencil.png?v2", - color: buttonOnColor, + color: buttonOffColor, alpha: 1 }); @@ -59,7 +59,7 @@ var pointerButton = Overlays.addOverlay("image", { width: BUTTON_SIZE, height: BUTTON_SIZE, imageURL: HIFI_PUBLIC_BUCKET + "images/laser.png", - color: buttonOnColor, + color: buttonOffColor, alpha: 1 })