diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7738be1d3b..bc7c3fc104 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1492,6 +1492,8 @@ void Application::idle() { _idleLoopMeasuredJitter = _idleLoopStdev.getStDev(); _idleLoopStdev.reset(); } + + _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData()); // After finishing all of the above work, restart the idle timer, allowing 2ms to process events. idleTimer->start(2); @@ -2809,6 +2811,8 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { "Application::displaySide() ... metavoxels..."); _metavoxels.render(); } + + _buckyBalls.render(); // render particles... _particles.render(); diff --git a/interface/src/Application.h b/interface/src/Application.h index cb1ba2f949..10da600f65 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -32,6 +32,7 @@ #include "Audio.h" #include "BandwidthMeter.h" +#include "BuckyBalls.h" #include "Camera.h" #include "DatagramProcessor.h" #include "Environment.h" @@ -378,6 +379,8 @@ private: bool _justStarted; Stars _stars; + + BuckyBalls _buckyBalls; VoxelSystem _voxels; VoxelTree _clipboard; // if I copy/paste diff --git a/interface/src/BuckyBalls.cpp b/interface/src/BuckyBalls.cpp index fec77d97f3..4c7797d062 100644 --- a/interface/src/BuckyBalls.cpp +++ b/interface/src/BuckyBalls.cpp @@ -54,9 +54,12 @@ BuckyBalls::BuckyBalls() { } } -void BuckyBalls::grab(PalmData& palm, const glm::vec3& fingerTipPosition, glm::quat avatarOrientation, float deltaTime) { +void BuckyBalls::grab(PalmData& palm, float deltaTime) { float penetration; glm::vec3 diff; + FingerData& finger = palm.getFingers()[0]; // Sixense has only one finger + glm::vec3 fingerTipPosition = finger.getTipPosition(); + if (palm.getControllerButtons() & BUTTON_FWD) { if (!_bballIsGrabbed[palm.getSixenseID()]) { // Look for a ball to grab @@ -89,7 +92,13 @@ const float COLLISION_BLEND_RATE = 0.5f; const float ATTRACTION_BLEND_RATE = 0.9f; const float ATTRACTION_VELOCITY_BLEND_RATE = 0.10f; -void BuckyBalls::simulate(float deltaTime) { +void BuckyBalls::simulate(float deltaTime, const HandData* handData) { + // First, update the grab behavior from the hand controllers + for (size_t i = 0; i < handData->getNumPalms(); ++i) { + PalmData palm = handData->getPalms()[i]; + grab(palm, deltaTime); + } + // Look for collisions for (int i = 0; i < NUM_BBALLS; i++) { if (_bballElement[i] != 1) { diff --git a/interface/src/BuckyBalls.h b/interface/src/BuckyBalls.h index 19a589035d..705f85517f 100644 --- a/interface/src/BuckyBalls.h +++ b/interface/src/BuckyBalls.h @@ -26,8 +26,8 @@ const int NUM_BBALLS = 200; class BuckyBalls { public: BuckyBalls(); - void grab(PalmData& palm, const glm::vec3& fingerTipPosition, glm::quat avatarOrientation, float deltaTime); - void simulate(float deltaTime); + void grab(PalmData& palm, float deltaTime); + void simulate(float deltaTime, const HandData* handData); void render();