From 7f841b3828d78d144b21dea7b5ef7bf1c33c67dc Mon Sep 17 00:00:00 2001
From: James Pollack <james@highfidelity.io>
Date: Thu, 1 Oct 2015 17:55:47 -0700
Subject: [PATCH 1/7] prevent most other-hand accidental firing

---
 examples/toys/ping_pong_gun/pingPongGun.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/examples/toys/ping_pong_gun/pingPongGun.js b/examples/toys/ping_pong_gun/pingPongGun.js
index a980fc1bd3..8610c48a96 100644
--- a/examples/toys/ping_pong_gun/pingPongGun.js
+++ b/examples/toys/ping_pong_gun/pingPongGun.js
@@ -84,6 +84,7 @@
             var _t = this;
             this.canShootTimeout = Script.setTimeout(function() {
                 _t.canShoot = false;
+                _t.whichHand=null;
             }, 250)
         },
 
@@ -97,7 +98,7 @@
             if (this.triggerValue < RELOAD_THRESHOLD) {
                 // print('RELOAD');
                 this.canShoot = true;
-            } else if (this.triggerValue >= RELOAD_THRESHOLD && this.canShoot === true) {
+            } else if (this.triggerValue >= RELOAD_THRESHOLD && this.canShoot === true && this.hand === this.whichHand) {
                 var gunProperties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]);
                 this.shootBall(gunProperties);
                 this.canShoot = false;

From 6131875f674637ef052cf1ab6df7a44617892dfc Mon Sep 17 00:00:00 2001
From: James Pollack <james@highfidelity.io>
Date: Thu, 1 Oct 2015 18:49:07 -0700
Subject: [PATCH 2/7] set whichhand to null on release

---
 examples/toys/ping_pong_gun/pingPongGun.js | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/examples/toys/ping_pong_gun/pingPongGun.js b/examples/toys/ping_pong_gun/pingPongGun.js
index 8610c48a96..1616d9c7e2 100644
--- a/examples/toys/ping_pong_gun/pingPongGun.js
+++ b/examples/toys/ping_pong_gun/pingPongGun.js
@@ -82,10 +82,15 @@
 
         releaseGrab: function() {
             var _t = this;
-            this.canShootTimeout = Script.setTimeout(function() {
-                _t.canShoot = false;
-                _t.whichHand=null;
-            }, 250)
+
+            if (this.whichHand === this.hand) {
+                _t.whichHand = null;
+                this.canShootTimeout = Script.setTimeout(function() {
+                    _t.canShoot = false;
+
+                }, 250)
+            }
+
         },
 
         checkTriggerPressure: function(gunHand) {

From 82828fdd14053fc489fcf7acae5b371adf95080e Mon Sep 17 00:00:00 2001
From: James Pollack <james@highfidelity.io>
Date: Fri, 2 Oct 2015 10:41:49 -0700
Subject: [PATCH 3/7] reduce gravity and gun force so ball goes through less
 objects

---
 examples/toys/ping_pong_gun/pingPongGun.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/toys/ping_pong_gun/pingPongGun.js b/examples/toys/ping_pong_gun/pingPongGun.js
index 1616d9c7e2..7afb467eb0 100644
--- a/examples/toys/ping_pong_gun/pingPongGun.js
+++ b/examples/toys/ping_pong_gun/pingPongGun.js
@@ -23,12 +23,12 @@
     var RELOAD_THRESHOLD = 0.95;
     var GUN_TIP_FWD_OFFSET = 0.45;
     var GUN_TIP_UP_OFFSET = 0.040;
-    var GUN_FORCE = 15;
+    var GUN_FORCE = 8;
     var BALL_RESTITUTION = 0.6;
     var BALL_LINEAR_DAMPING = 0.4;
     var BALL_GRAVITY = {
         x: 0,
-        y: -9.8,
+        y: -5.8,
         z: 0
     };
 

From c6fa132dc2d88f29a547f7b000f076dd755adba5 Mon Sep 17 00:00:00 2001
From: James Pollack <james@highfidelity.io>
Date: Fri, 2 Oct 2015 10:44:26 -0700
Subject: [PATCH 4/7] cleanup

---
 examples/toys/ping_pong_gun/pingPongGun.js | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/examples/toys/ping_pong_gun/pingPongGun.js b/examples/toys/ping_pong_gun/pingPongGun.js
index 7afb467eb0..b3545ce529 100644
--- a/examples/toys/ping_pong_gun/pingPongGun.js
+++ b/examples/toys/ping_pong_gun/pingPongGun.js
@@ -36,14 +36,14 @@
         x: 0.04,
         y: 0.04,
         z: 0.04
-    }
+    };
 
 
     var BALL_COLOR = {
         red: 255,
         green: 255,
         blue: 255
-    }
+    };
 
     PingPongGun.prototype = {
         hand: null,
@@ -87,8 +87,7 @@
                 _t.whichHand = null;
                 this.canShootTimeout = Script.setTimeout(function() {
                     _t.canShoot = false;
-
-                }, 250)
+                }, 250);
             }
 
         },

From 9427ba1a5ac38d9569ddfe2f4c482fe33c566544 Mon Sep 17 00:00:00 2001
From: James Pollack <james@highfidelity.io>
Date: Fri, 2 Oct 2015 15:56:26 -0700
Subject: [PATCH 5/7] ping pong gun

---
 examples/toys/ping_pong_gun/createPingPongGun.js | 12 ++++++------
 examples/toys/ping_pong_gun/pingPongGun.js       | 11 +++++++----
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/examples/toys/ping_pong_gun/createPingPongGun.js b/examples/toys/ping_pong_gun/createPingPongGun.js
index 4b7ed27643..4969a0bc72 100644
--- a/examples/toys/ping_pong_gun/createPingPongGun.js
+++ b/examples/toys/ping_pong_gun/createPingPongGun.js
@@ -13,8 +13,8 @@ Script.include("../../utilities.js");
 
 var scriptURL = Script.resolvePath('pingPongGun.js');
 
-var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun.fbx'
-var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun_collision_hull.obj';
+var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun.fbx?123'
+var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun_collision_hull.obj?123';
 
 var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
     x: 0,
@@ -30,9 +30,9 @@ var pingPongGun = Entities.addEntity({
     script: scriptURL,
     position: center,
     dimensions: {
-        x:0.67,
-        y: 0.14,
-        z: 0.09
+        x: 0.08,
+        y: 0.21,
+        z: 0.47
     },
     collisionsWillMove: true,
 });
@@ -40,4 +40,4 @@ var pingPongGun = Entities.addEntity({
 function cleanUp() {
     Entities.deleteEntity(pingPongGun);
 }
-Script.scriptEnding.connect(cleanUp);
+Script.scriptEnding.connect(cleanUp);
\ No newline at end of file
diff --git a/examples/toys/ping_pong_gun/pingPongGun.js b/examples/toys/ping_pong_gun/pingPongGun.js
index b3545ce529..298d93a523 100644
--- a/examples/toys/ping_pong_gun/pingPongGun.js
+++ b/examples/toys/ping_pong_gun/pingPongGun.js
@@ -81,15 +81,14 @@
         },
 
         releaseGrab: function() {
-            var _t = this;
+            var _this = this;
 
             if (this.whichHand === this.hand) {
-                _t.whichHand = null;
+                this.whichHand = null;
                 this.canShootTimeout = Script.setTimeout(function() {
-                    _t.canShoot = false;
+                    _this.canShoot = false;
                 }, 250);
             }
-
         },
 
         checkTriggerPressure: function(gunHand) {
@@ -107,6 +106,7 @@
                 this.shootBall(gunProperties);
                 this.canShoot = false;
             }
+
             return;
         },
 
@@ -114,6 +114,7 @@
             var forwardVec = Quat.getFront(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, -90, 0)));
             forwardVec = Vec3.normalize(forwardVec);
             forwardVec = Vec3.multiply(forwardVec, GUN_FORCE);
+
             var properties = {
                 type: 'Sphere',
                 color: BALL_COLOR,
@@ -148,8 +149,10 @@
             var frontOffset = Vec3.multiply(frontVector, GUN_TIP_FWD_OFFSET);
             var upVector = Quat.getRight(properties.rotation);
             var upOffset = Vec3.multiply(upVector, GUN_TIP_UP_OFFSET);
+            
             var gunTipPosition = Vec3.sum(properties.position, frontOffset);
             gunTipPosition = Vec3.sum(gunTipPosition, upOffset);
+
             return gunTipPosition;
         },
 

From 01044e3c056178c28b7ed1f9e8d5d351f18e7764 Mon Sep 17 00:00:00 2001
From: James Pollack <james@highfidelity.io>
Date: Fri, 2 Oct 2015 15:57:46 -0700
Subject: [PATCH 6/7] adjust gun dimensions in toybox master script

---
 unpublishedScripts/masterReset.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/unpublishedScripts/masterReset.js b/unpublishedScripts/masterReset.js
index d6759e2b48..13445ca438 100644
--- a/unpublishedScripts/masterReset.js
+++ b/unpublishedScripts/masterReset.js
@@ -98,7 +98,7 @@ function createAllToys() {
 function deleteAllToys() {
     var entities = Entities.findEntities(MyAvatar.position, 100);
 
-    entities.forEach(function (entity) {
+    entities.forEach(function(entity) {
         //params: customKey, id, defaultValue
         var shouldReset = getEntityCustomData(resetKey, entity, {}).resetMe;
         if (shouldReset === true) {
@@ -468,9 +468,9 @@ function createPingPongBallGun() {
             z: 0
         },
         dimensions: {
-            x: 0.67,
-            y: 0.14,
-            z: 0.09
+            x: 0.08,
+            y: 0.21,
+            z: 0.47
         },
         collisionsWillMove: true,
     });
@@ -831,4 +831,4 @@ function cleanup() {
 if (shouldDeleteOnEndScript) {
 
     Script.scriptEnding.connect(cleanup);
-}
+}
\ No newline at end of file

From 65ae811c9c50a4200d85686f1d0d40f1ec02da76 Mon Sep 17 00:00:00 2001
From: "James B. Pollack" <jamesbradenpollack@gmail.com>
Date: Mon, 5 Oct 2015 11:16:55 -0700
Subject: [PATCH 7/7] make ping pong balls bigger and slower, change out gun
 model and adjust tip calculations, increase volume, add to master reset
 script

---
 .../toys/ping_pong_gun/createPingPongGun.js     |  5 +++--
 examples/toys/ping_pong_gun/pingPongGun.js      | 17 ++++++++---------
 unpublishedScripts/masterReset.js               |  5 +----
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/examples/toys/ping_pong_gun/createPingPongGun.js b/examples/toys/ping_pong_gun/createPingPongGun.js
index 4969a0bc72..cf56d6f790 100644
--- a/examples/toys/ping_pong_gun/createPingPongGun.js
+++ b/examples/toys/ping_pong_gun/createPingPongGun.js
@@ -25,8 +25,9 @@ var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
 var pingPongGun = Entities.addEntity({
     type: "Model",
     modelURL: MODEL_URL,
-    shapeType: 'compound',
-    compoundShapeURL: COLLISION_HULL_URL,
+    shapeType:'box',
+    // shapeType: 'compound',
+    // compoundShapeURL: COLLISION_HULL_URL,
     script: scriptURL,
     position: center,
     dimensions: {
diff --git a/examples/toys/ping_pong_gun/pingPongGun.js b/examples/toys/ping_pong_gun/pingPongGun.js
index 298d93a523..1b5973c8bb 100644
--- a/examples/toys/ping_pong_gun/pingPongGun.js
+++ b/examples/toys/ping_pong_gun/pingPongGun.js
@@ -21,14 +21,14 @@
 
     //if the trigger value goes below this value, reload the gun.
     var RELOAD_THRESHOLD = 0.95;
-    var GUN_TIP_FWD_OFFSET = 0.45;
+    var GUN_TIP_FWD_OFFSET =-0.35;
     var GUN_TIP_UP_OFFSET = 0.040;
-    var GUN_FORCE = 8;
+    var GUN_FORCE = 9;
     var BALL_RESTITUTION = 0.6;
     var BALL_LINEAR_DAMPING = 0.4;
     var BALL_GRAVITY = {
         x: 0,
-        y: -5.8,
+        y: -4.8,
         z: 0
     };
 
@@ -68,7 +68,6 @@
         },
 
         continueNearGrab: function() {
-
             if (this.whichHand === null) {
                 //only set the active hand once -- if we always read the current hand, our 'holding' hand will get overwritten
                 this.setWhichHand();
@@ -111,7 +110,7 @@
         },
 
         shootBall: function(gunProperties) {
-            var forwardVec = Quat.getFront(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, -90, 0)));
+            var forwardVec = Quat.getFront(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, 180, 0)));
             forwardVec = Vec3.normalize(forwardVec);
             forwardVec = Vec3.multiply(forwardVec, GUN_FORCE);
 
@@ -136,7 +135,7 @@
 
         playSoundAtCurrentPosition: function(position) {
             var audioProperties = {
-                volume: 0.1,
+                volume: 0.2,
                 position: position
             };
 
@@ -145,11 +144,11 @@
 
         getGunTipPosition: function(properties) {
             //the tip of the gun is going to be in a different place than the center, so we move in space relative to the model to find that position
-            var frontVector = Quat.getRight(properties.rotation);
+            var frontVector = Quat.getFront(properties.rotation);
             var frontOffset = Vec3.multiply(frontVector, GUN_TIP_FWD_OFFSET);
-            var upVector = Quat.getRight(properties.rotation);
+            var upVector = Quat.getUp(properties.rotation);
             var upOffset = Vec3.multiply(upVector, GUN_TIP_UP_OFFSET);
-            
+
             var gunTipPosition = Vec3.sum(properties.position, frontOffset);
             gunTipPosition = Vec3.sum(gunTipPosition, upOffset);
 
diff --git a/unpublishedScripts/masterReset.js b/unpublishedScripts/masterReset.js
index 13445ca438..a3d4bcc70d 100644
--- a/unpublishedScripts/masterReset.js
+++ b/unpublishedScripts/masterReset.js
@@ -457,8 +457,7 @@ function createPingPongBallGun() {
     var pingPongGun = Entities.addEntity({
         type: "Model",
         modelURL: MODEL_URL,
-        shapeType: 'compound',
-        compoundShapeURL: COLLISION_HULL_URL,
+        shapeType: 'box',
         script: scriptURL,
         position: position,
         rotation: rotation,
@@ -478,8 +477,6 @@ function createPingPongBallGun() {
     setEntityCustomData(resetKey, pingPongGun, {
         resetMe: true
     });
-
-
 }
 
 function createBasketballHoop() {