mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 05:48:39 +02:00
Physics test ‘buckyballs’ moved to application.cpp
This commit is contained in:
parent
a9849c131f
commit
246bb1fd2d
4 changed files with 20 additions and 4 deletions
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue