mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into compressed_packets
Conflicts: interface/src/Menu.cpp interface/src/Menu.h
This commit is contained in:
commit
0e501f4439
8 changed files with 331 additions and 37 deletions
257
interface/resources/shaders/point_size.vert.using-table
Normal file
257
interface/resources/shaders/point_size.vert.using-table
Normal file
|
@ -0,0 +1,257 @@
|
|||
#version 120
|
||||
|
||||
attribute float voxelSizeIn;
|
||||
varying float voxelSize;
|
||||
|
||||
uniform float viewportWidth;
|
||||
uniform float viewportHeight;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
// Bit codes for faces
|
||||
const int RIGHT = 1;
|
||||
const int LEFT = 2;
|
||||
const int BOTTOM = 4;
|
||||
const int TOP = 8;
|
||||
const int NEAR = 16;
|
||||
const int FAR = 32;
|
||||
|
||||
// index locations for the coordinates of the two vertices
|
||||
const int X_ONE = 0;
|
||||
const int Y_ONE = 1;
|
||||
const int Z_ONE = 2;
|
||||
const int X_TWO = 3;
|
||||
const int Y_TWO = 4;
|
||||
const int Z_TWO = 5;
|
||||
|
||||
const int MAX_POSSIBLE_COMBINATIONS = 43;
|
||||
const int COORD_PER_VERTEX = 3;
|
||||
const int TWO_DISTANT_VERTICES = 2;
|
||||
const int COORD_PER_LOOKUP = COORD_PER_VERTEX * TWO_DISTANT_VERTICES;
|
||||
const int TOTAL_LOOKUP_COORDS = MAX_POSSIBLE_COMBINATIONS * COORD_PER_LOOKUP;
|
||||
const int HALF_LOOKUP_COORDS = MAX_POSSIBLE_COMBINATIONS * COORD_PER_VERTEX;
|
||||
|
||||
|
||||
// If we know the position of the camera relative to the voxel, we can apriori know the vertices that make the visible hull
|
||||
// polygon. This also tells us which two vertices are known to make the longest possible distance between any pair of these
|
||||
// vertices for the projected polygon. This is a lookup table based on this knowledge.
|
||||
|
||||
// try switching these to indexes, and then using a switch statement...
|
||||
const float coordLookup[TOTAL_LOOKUP_COORDS] = float[TOTAL_LOOKUP_COORDS]
|
||||
(
|
||||
0,0,0, 1,1,1, // 0 - inside - n/a
|
||||
0,0,0, 0,1,1, // 1 - right face, BOTTOM_RIGHT_NEAR to TOP_RIGHT_FAR
|
||||
1,0,0, 1,1,1, // 2 - left fact BOTTOM_LEFT_NEAR to TOP_LEFT_FAR
|
||||
0,0,0, 0,0,0, // n/a
|
||||
0,0,0, 1,0,1, // 4 - bottom face, BOTTOM_RIGHT_NEAR to BOTTOM_LEFT_FAR
|
||||
1,0,0, 0,1,1, // 5 - bottom, right - BOTTOM_RIGHT_NEAR to TOP_LEFT_FAR
|
||||
0,0,0, 1,1,1, // 6 - bottom, left - BOTTOM_RIGHT_NEAR to TOP_LEFT_FAR
|
||||
0,0,0, 0,0,0, // n/a
|
||||
0,1,0, 1,1,1, // 8 - top - TOP_RIGHT_NEAR to TOP_LEFT_FAR
|
||||
0,0,0, 1,1,1, // 9 - top, right - BOTTOM_RIGHT_NEAR to TOP_LEFT_FAR
|
||||
1,0,0, 0,1,1, //10 - top, left - BOTTOM_LEFT_NEAR to TOP_RIGHT_FAR
|
||||
0,0,0, 0,0,0, // n/a
|
||||
0,0,0, 0,0,0, // n/a
|
||||
0,0,0, 0,0,0, // n/a
|
||||
0,0,0, 0,0,0, // n/a
|
||||
0,0,0, 0,0,0, // n/a
|
||||
0,0,0, 1,1,1 , // 16 - front TODO
|
||||
0,0,0, 1,1,1 , // 17 front, right - TODO
|
||||
0,0,0, 1,1,1 , // 18 - front, left- TODO
|
||||
0,0,0, 0,0,0 , // n/a
|
||||
0,0,0, 1,1,1 , // 20 - front,bottom - TODO
|
||||
0,0,0, 1,1,1 , // 21 - front,bottom,right - TODO
|
||||
0,0,0, 1,1,1 , // 22 - front,bottom,left - TODO
|
||||
0,0,0, 0,0,0 , // n/a
|
||||
0,0,0, 1,1,1 , // 24 - front, top -TODO
|
||||
0,0,0, 1,1,1 , // 25 - front, top, right - TODO
|
||||
0,0,0, 1,1,1 , // 26 - front, top, left - TODO
|
||||
0,0,0, 0,0,0 , // n/a
|
||||
0,0,0, 0,0,0 , // n/a
|
||||
0,0,0, 0,0,0 , // n/a
|
||||
0,0,0, 0,0,0 , // n/a
|
||||
0,0,0, 0,0,0 , // n/a
|
||||
0,0,0, 1,1,1 , // 32 - far - TODO
|
||||
0,0,0, 1,1,1 , // 33 - back, right - TODO
|
||||
0,0,0, 1,1,1 , // 34 - back, left - TODO
|
||||
0,0,0, 0,0,0 , // n/a
|
||||
0,0,0, 1,1,1 , // 36 - back, bottom - TODO
|
||||
0,0,0, 1,1,1 , // 37 - back, bottom, right -TODO
|
||||
0,0,0, 1,1,1 , // 38 - back, bottom, left - TODO
|
||||
0,0,0, 0,0,0 , // n/a
|
||||
0,0,0, 1,1,1 , // 40 - back, top - TODO
|
||||
0,0,0, 1,1,1 , // 41 - back, top, right - TODO
|
||||
0,0,0, 1,1,1 // 42- back, top, left - TODO
|
||||
);
|
||||
|
||||
/**
|
||||
const int COLORS_PER_LOOKUP = 3;
|
||||
const int TOTAL_LOOKUP_COLORS = MAX_POSSIBLE_COMBINATIONS * COLORS_PER_LOOKUP;
|
||||
|
||||
const float debugColorLookup[TOTAL_LOOKUP_COLORS] = float[TOTAL_LOOKUP_COLORS]
|
||||
(
|
||||
1,1,0, // n/a
|
||||
0,0,1, // 1 - right face, BOTTOM_RIGHT_NEAR to TOP_RIGHT_FAR
|
||||
0,0,1, // 2 - left fact BOTTOM_LEFT_NEAR to TOP_LEFT_FAR
|
||||
1,0,0, // n/a
|
||||
1,0,1, // 4 - bottom face, BOTTOM_RIGHT_NEAR to BOTTOM_LEFT_FAR
|
||||
1,0,1, // 5 - bottom, right - BOTTOM_RIGHT_NEAR to TOP_LEFT_FAR
|
||||
1,0,1, // 6 - bottom, left - BOTTOM_RIGHT_NEAR to TOP_LEFT_FAR
|
||||
1,0,0, // n/a
|
||||
0,1,1, // 8 - top - TOP_RIGHT_NEAR to TOP_LEFT_FAR
|
||||
0,1,1, // 9 - top, right - BOTTOM_RIGHT_NEAR to TOP_LEFT_FAR
|
||||
0,1,1, //10 - top, left - BOTTOM_LEFT_NEAR to TOP_RIGHT_FAR
|
||||
1,0,0, // n/a
|
||||
1,0,0, // n/a
|
||||
1,0,0, // n/a
|
||||
1,0,0, // n/a
|
||||
1,0,0, // n/a
|
||||
0,0,1, //16 - front or near - TODO
|
||||
0,0,1, // 17 - front, right - TODO
|
||||
0,0,1, // 18 - front, left - TODO
|
||||
1,0,0 , // n/a
|
||||
1,0,1, // 20 - front,bottom - TODO
|
||||
1,0,1, // 21 - front,bottom,right - TODO
|
||||
1,0,1, // 22 - front,bottom,left - TODO
|
||||
1,0,0 , // n/a
|
||||
0,1,1, // 24 - front, top - TODO
|
||||
0,1,1, // 25 - front, top, right - TODO
|
||||
0,1,1, // 26 - front, top, left - TODO
|
||||
1,0,0 , // n/a
|
||||
1,0,0 , // n/a
|
||||
1,0,0 , // n/a
|
||||
1,0,0 , // n/a
|
||||
1,0,0 , // n/a
|
||||
0,0,1, // 32 - back - TODO
|
||||
0,0,1, // 33 - back, right - TODO
|
||||
0,0,1, // 34 - back, left - TODO
|
||||
1,0,0, // n/a
|
||||
1,0,1, // 36 - back, bottom - TODO
|
||||
1,0,1, // 37 - back, bottom, right - TODO
|
||||
1,0,1, // 38 - back, bottom, left - TODO
|
||||
1,0,0 , // n/a
|
||||
0,1,1, // 40 - back, top - TODO
|
||||
0,1,1, // 41 - back, top, right - TODO
|
||||
0,1,1 // 42 - back, top, left - TODO
|
||||
);
|
||||
|
||||
**/
|
||||
|
||||
void main(void) {
|
||||
vec4 debugColor = vec4(0,0,0,1);
|
||||
|
||||
float voxelScreenWidth = 0;
|
||||
float voxelScreenHeight = 0;
|
||||
|
||||
|
||||
// Note: the gl_Vertex in this case are in "world coordinates" meaning they've already been scaled to TREE_SCALE
|
||||
// this is also true for voxelSizeIn.
|
||||
vec4 bottomNearRight = gl_Vertex;
|
||||
vec4 topFarLeft = (gl_Vertex + vec4(voxelSizeIn, voxelSizeIn, voxelSizeIn, 0.0));
|
||||
|
||||
int lookUp = 0;
|
||||
int lookUpBase = 0;
|
||||
|
||||
// In order to use our lookup table above, we need to encode the 6-bit code to classify camera relative to the 6 defining
|
||||
// planes of the voxel. Based on camera position relative to the bottomNearRight corner and the topFarLeft corner, we can
|
||||
// calculate which hull and therefore which two vertices are furthest apart liniarly once projected
|
||||
if (cameraPosition.x < bottomNearRight.x) {
|
||||
lookUp += RIGHT;
|
||||
}
|
||||
if (cameraPosition.x > topFarLeft.x) {
|
||||
lookUp += LEFT;
|
||||
}
|
||||
if (cameraPosition.y < bottomNearRight.y) {
|
||||
lookUp += BOTTOM;
|
||||
}
|
||||
if (cameraPosition.y > topFarLeft.y) {
|
||||
lookUp += TOP;
|
||||
}
|
||||
if (cameraPosition.z < bottomNearRight.z) {
|
||||
lookUp += NEAR;
|
||||
}
|
||||
if (cameraPosition.z > topFarLeft.z) {
|
||||
lookUp += FAR;
|
||||
}
|
||||
|
||||
//if (cameraPositionZ > gl_Vertex.z) {
|
||||
// debugColor = vec4(0,1,0,1);
|
||||
//}
|
||||
|
||||
const bool useLookup = false;
|
||||
if (true) {
|
||||
lookUpBase = lookUp * COORD_PER_LOOKUP;
|
||||
vec4 cornerAdjustOne = vec4(coordLookup[lookUpBase + 0],
|
||||
coordLookup[lookUpBase + 1],
|
||||
coordLookup[lookUpBase + 2], 0) * voxelSizeIn;
|
||||
|
||||
|
||||
float xTwo = coordLookup[lookUpBase + 3];
|
||||
float yTwo = coordLookup[lookUpBase + 4];
|
||||
float zTwo = coordLookup[lookUpBase + 5];
|
||||
|
||||
vec4 cornerAdjustTwo = vec4(xTwo, yTwo, zTwo, 0) * voxelSizeIn;
|
||||
|
||||
/**
|
||||
vec4 cornerAdjustOne = vec4(0,0,0,0) * voxelSizeIn;
|
||||
vec4 cornerAdjustTwo = vec4(1,1,1,0) * voxelSizeIn;
|
||||
**/
|
||||
|
||||
vec4 cornerOne = gl_Vertex + cornerAdjustOne;
|
||||
vec4 cornerTwo = gl_Vertex + cornerAdjustTwo;
|
||||
|
||||
vec4 cornerOneMVP = gl_ModelViewProjectionMatrix * cornerOne;
|
||||
vec4 cornerTwoMVP = gl_ModelViewProjectionMatrix * cornerTwo;
|
||||
|
||||
vec2 cornerOneScreen = vec2(cornerOneMVP.x / cornerOneMVP.w, cornerOneMVP.y / cornerOneMVP.w);
|
||||
if (cornerOneMVP.w < 0) {
|
||||
cornerOneScreen.x = -cornerOneScreen.x;
|
||||
cornerOneScreen.y = -cornerOneScreen.y;
|
||||
}
|
||||
|
||||
vec2 cornerTwoScreen = vec2(cornerTwoMVP.x / cornerTwoMVP.w, cornerTwoMVP.y / cornerTwoMVP.w);
|
||||
if (cornerTwoMVP.w < 0) {
|
||||
cornerTwoScreen.x = -cornerTwoScreen.x;
|
||||
cornerTwoScreen.y = -cornerTwoScreen.y;
|
||||
}
|
||||
voxelScreenWidth = abs(cornerOneScreen.x - cornerTwoScreen.x) * viewportWidth / 2.0;
|
||||
voxelScreenHeight = abs(cornerOneScreen.y - cornerTwoScreen.y) * viewportHeight / 2.0;
|
||||
} //else
|
||||
|
||||
if (false) {
|
||||
vec4 corner = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
vec4 farCornerVertex = gl_Vertex;
|
||||
farCornerVertex += vec4(voxelSizeIn, voxelSizeIn, voxelSizeIn, 0.0);
|
||||
vec4 farCorner = gl_ModelViewProjectionMatrix * farCornerVertex;
|
||||
|
||||
// math! If the w result is negative then the point is behind the viewer
|
||||
vec2 cornerOnScreen = vec2(corner.x / corner.w, corner.y / corner.w);
|
||||
if (corner.w < 0) {
|
||||
cornerOnScreen.x = -cornerOnScreen.x;
|
||||
cornerOnScreen.y = -cornerOnScreen.y;
|
||||
}
|
||||
|
||||
vec2 farCornerOnScreen = vec2(farCorner.x / farCorner.w, farCorner.y / farCorner.w);
|
||||
if (farCorner.w < 0) {
|
||||
farCornerOnScreen.x = -farCornerOnScreen.x;
|
||||
farCornerOnScreen.y = -farCornerOnScreen.y;
|
||||
}
|
||||
|
||||
voxelScreenWidth = abs(farCornerOnScreen.x - cornerOnScreen.x) * viewportWidth / 2.0;
|
||||
voxelScreenHeight = abs(farCornerOnScreen.y - cornerOnScreen.y) * viewportHeight / 2.0;
|
||||
}
|
||||
|
||||
float voxelScreenLength = sqrt(voxelScreenHeight * voxelScreenHeight + voxelScreenWidth * voxelScreenWidth);
|
||||
|
||||
vec4 centerVertex = gl_Vertex;
|
||||
float halfSizeIn = voxelSizeIn / 2;
|
||||
centerVertex += vec4(halfSizeIn, halfSizeIn, halfSizeIn, 0.0);
|
||||
vec4 center = gl_ModelViewProjectionMatrix * centerVertex;
|
||||
|
||||
gl_Position = center;
|
||||
gl_PointSize = voxelScreenLength;
|
||||
|
||||
//int debugColorBase = lookUp * COLORS_PER_LOOKUP;
|
||||
//debugColor = vec4(debugColorLookup[debugColorBase], debugColorLookup[debugColorBase + 1], debugColorLookup[debugColorBase + 2], 1);
|
||||
|
||||
gl_FrontColor = debugColor; // gl_Color; // set the color..
|
||||
}
|
|
@ -27,12 +27,8 @@
|
|||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
// Uncomment the following definition to test audio device latency by copying output to input
|
||||
//#define TEST_AUDIO_LOOPBACK
|
||||
//#define SHOW_AUDIO_DEBUG
|
||||
|
||||
#define VISUALIZE_ECHO_CANCELLATION
|
||||
|
||||
static const int PHASE_DELAY_AT_90 = 20;
|
||||
static const float AMPLITUDE_RATIO_AT_90 = 0.5;
|
||||
static const int MIN_FLANGE_EFFECT_THRESHOLD = 600;
|
||||
|
@ -84,11 +80,17 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
|
|||
memset(outputLeft, 0, PACKET_LENGTH_BYTES_PER_CHANNEL);
|
||||
memset(outputRight, 0, PACKET_LENGTH_BYTES_PER_CHANNEL);
|
||||
|
||||
// If Mute button is pressed, clear the input buffer
|
||||
// If Mute button is pressed, clear the input buffer
|
||||
if (_muted) {
|
||||
memset(inputLeft, 0, PACKET_LENGTH_BYTES_PER_CHANNEL);
|
||||
}
|
||||
|
||||
// If local loopback enabled, copy input to output
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::EchoLocalAudio)) {
|
||||
memcpy(outputLeft, inputLeft, PACKET_LENGTH_BYTES_PER_CHANNEL);
|
||||
memcpy(outputRight, inputLeft, PACKET_LENGTH_BYTES_PER_CHANNEL);
|
||||
}
|
||||
|
||||
// Add Procedural effects to input samples
|
||||
addProceduralSounds(inputLeft, outputLeft, outputRight, BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
||||
|
||||
|
@ -120,7 +122,7 @@ inline void Audio::performIO(int16_t* inputLeft, int16_t* outputLeft, int16_t* o
|
|||
// + 12 for 3 floats for position + float for bearing + 1 attenuation byte
|
||||
unsigned char dataPacket[MAX_PACKET_SIZE];
|
||||
|
||||
PACKET_TYPE packetType = Menu::getInstance()->isOptionChecked(MenuOption::EchoAudio)
|
||||
PACKET_TYPE packetType = Menu::getInstance()->isOptionChecked(MenuOption::EchoServerAudio)
|
||||
? PACKET_TYPE_MICROPHONE_AUDIO_WITH_ECHO
|
||||
: PACKET_TYPE_MICROPHONE_AUDIO_NO_ECHO;
|
||||
|
||||
|
@ -360,7 +362,8 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples) :
|
|||
_collisionSoundDuration(0.0f),
|
||||
_proceduralEffectSample(0),
|
||||
_heartbeatMagnitude(0.0f),
|
||||
_muted(false)
|
||||
_muted(false),
|
||||
_localEcho(false)
|
||||
{
|
||||
outputPortAudioError(Pa_Initialize());
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
// in which case 'true' is returned - otherwise the return value is 'false'.
|
||||
// The results of the analysis are written to the log.
|
||||
bool eventuallyAnalyzePing();
|
||||
|
||||
private:
|
||||
|
||||
PaStream* _stream;
|
||||
|
@ -109,6 +110,7 @@ private:
|
|||
float _heartbeatMagnitude;
|
||||
|
||||
bool _muted;
|
||||
bool _localEcho;
|
||||
GLuint _micTextureId;
|
||||
GLuint _muteTextureId;
|
||||
QRect _iconBounds;
|
||||
|
|
|
@ -36,11 +36,18 @@
|
|||
Menu* Menu::_instance = NULL;
|
||||
|
||||
Menu* Menu::getInstance() {
|
||||
static QMutex menuInstanceMutex;
|
||||
|
||||
// lock the menu instance mutex to make sure we don't race and create two menus and crash
|
||||
menuInstanceMutex.lock();
|
||||
|
||||
if (!_instance) {
|
||||
qDebug("First call to Menu::getInstance() - initing menu.\n");
|
||||
|
||||
_instance = new Menu();
|
||||
}
|
||||
|
||||
menuInstanceMutex.unlock();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
@ -477,8 +484,10 @@ Menu::Menu() :
|
|||
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::CoverageMapV2, Qt::SHIFT | Qt::CTRL | Qt::Key_P);
|
||||
|
||||
QMenu* audioDebugMenu = developerMenu->addMenu("Audio Debugging Tools");
|
||||
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::EchoAudio);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::EchoServerAudio);
|
||||
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::EchoLocalAudio);
|
||||
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::ExtraDebugging);
|
||||
addActionToQMenuAndActionHash(developerMenu, MenuOption::PasteToVoxel,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_V,
|
||||
|
|
|
@ -169,9 +169,10 @@ namespace MenuOption {
|
|||
const QString DisplayLeapHands = "Display Leap Hands";
|
||||
const QString DontRenderVoxels = "Don't call _voxels.render()";
|
||||
const QString DontCallOpenGLForVoxels = "Don't call glDrawRangeElementsEXT() for Voxels";
|
||||
const QString EchoAudio = "Echo Audio";
|
||||
const QString EnableOcclusionCulling = "Enable Occlusion Culling";
|
||||
const QString EnableVoxelPacketCompression = "Enable Voxel Packet Compression";
|
||||
const QString EchoServerAudio = "Echo Server Audio";
|
||||
const QString EchoLocalAudio = "Echo Local Audio";
|
||||
const QString ExportVoxels = "Export Voxels";
|
||||
const QString ExtraDebugging = "Extra Debugging";
|
||||
const QString DontFadeOnVoxelServerChanges = "Don't Fade In/Out on Voxel Server Changes";
|
||||
|
|
|
@ -381,15 +381,18 @@ void MyAvatar::updateFromGyrosAndOrWebcam(bool turnWithHead) {
|
|||
if (faceshift->isActive()) {
|
||||
estimatedPosition = faceshift->getHeadTranslation();
|
||||
estimatedRotation = safeEulerAngles(faceshift->getHeadRotation());
|
||||
// Rotate the body if the head is turned quickly
|
||||
// Rotate the body if the head is turned beyond the screen
|
||||
if (turnWithHead) {
|
||||
glm::vec3 headAngularVelocity = faceshift->getHeadAngularVelocity();
|
||||
const float FACESHIFT_YAW_TURN_SENSITIVITY = 0.25f;
|
||||
const float FACESHIFT_MIN_YAW_TURN = 10.f;
|
||||
const float FACESHIFT_MAX_YAW_TURN = 30.f;
|
||||
const float FACESHIFT_YAW_TURN_SENSITIVITY = 0.5f;
|
||||
const float FACESHIFT_MIN_YAW_TURN = 15.f;
|
||||
const float FACESHIFT_MAX_YAW_TURN = 50.f;
|
||||
if ( (fabs(estimatedRotation.y) > FACESHIFT_MIN_YAW_TURN) &&
|
||||
(fabs(estimatedRotation.y) < FACESHIFT_MAX_YAW_TURN) ) {
|
||||
_bodyYawDelta += estimatedRotation.y * FACESHIFT_YAW_TURN_SENSITIVITY;
|
||||
if (estimatedRotation.y > 0.f) {
|
||||
_bodyYawDelta += (estimatedRotation.y - FACESHIFT_MIN_YAW_TURN) * FACESHIFT_YAW_TURN_SENSITIVITY;
|
||||
} else {
|
||||
_bodyYawDelta += (estimatedRotation.y + FACESHIFT_MIN_YAW_TURN) * FACESHIFT_YAW_TURN_SENSITIVITY;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (gyros->isActive()) {
|
||||
|
@ -459,22 +462,33 @@ void MyAvatar::updateFromGyrosAndOrWebcam(bool turnWithHead) {
|
|||
if (!Menu::getInstance()->isOptionChecked(MenuOption::MoveWithLean)) {
|
||||
return;
|
||||
}
|
||||
const float ANGULAR_DRIVE_SCALE = 0.1f;
|
||||
const float ANGULAR_DEAD_ZONE = 0.3f;
|
||||
setDriveKeys(FWD, glm::clamp(-_head.getLeanForward() * ANGULAR_DRIVE_SCALE - ANGULAR_DEAD_ZONE, 0.0f, 1.0f));
|
||||
setDriveKeys(BACK, glm::clamp(_head.getLeanForward() * ANGULAR_DRIVE_SCALE - ANGULAR_DEAD_ZONE, 0.0f, 1.0f));
|
||||
setDriveKeys(LEFT, glm::clamp(_head.getLeanSideways() * ANGULAR_DRIVE_SCALE - ANGULAR_DEAD_ZONE, 0.0f, 1.0f));
|
||||
setDriveKeys(RIGHT, glm::clamp(-_head.getLeanSideways() * ANGULAR_DRIVE_SCALE - ANGULAR_DEAD_ZONE, 0.0f, 1.0f));
|
||||
|
||||
// only consider going up if we're not going in any of the four horizontal directions
|
||||
if (_driveKeys[FWD] == 0.0f && _driveKeys[BACK] == 0.0f && _driveKeys[LEFT] == 0.0f && _driveKeys[RIGHT] == 0.0f) {
|
||||
const float LINEAR_DRIVE_SCALE = 5.0f;
|
||||
const float LINEAR_DEAD_ZONE = 0.95f;
|
||||
float torsoDelta = glm::length(relativePosition) - TORSO_LENGTH;
|
||||
setDriveKeys(UP, glm::clamp(torsoDelta * LINEAR_DRIVE_SCALE - LINEAR_DEAD_ZONE, 0.0f, 1.0f));
|
||||
|
||||
} else {
|
||||
setDriveKeys(UP, 0.0f);
|
||||
// Move with Lean by applying thrust proportional to leaning
|
||||
glm::quat orientation = _head.getCameraOrientation();
|
||||
glm::vec3 front = orientation * IDENTITY_FRONT;
|
||||
glm::vec3 right = orientation * IDENTITY_RIGHT;
|
||||
float leanForward = _head.getLeanForward();
|
||||
float leanSideways = _head.getLeanSideways();
|
||||
|
||||
// Degrees of 'dead zone' when leaning, and amount of acceleration to apply to lean angle
|
||||
const float LEAN_FWD_DEAD_ZONE = 15.f;
|
||||
const float LEAN_SIDEWAYS_DEAD_ZONE = 10.f;
|
||||
const float LEAN_FWD_THRUST_SCALE = 4.f;
|
||||
const float LEAN_SIDEWAYS_THRUST_SCALE = 3.f;
|
||||
|
||||
if (fabs(leanForward) > LEAN_FWD_DEAD_ZONE) {
|
||||
if (leanForward > 0.f) {
|
||||
addThrust(front * -(leanForward - LEAN_FWD_DEAD_ZONE) * LEAN_FWD_THRUST_SCALE);
|
||||
} else {
|
||||
addThrust(front * -(leanForward + LEAN_FWD_DEAD_ZONE) * LEAN_FWD_THRUST_SCALE);
|
||||
}
|
||||
}
|
||||
if (fabs(leanSideways) > LEAN_SIDEWAYS_DEAD_ZONE) {
|
||||
if (leanSideways > 0.f) {
|
||||
addThrust(right * -(leanSideways - LEAN_SIDEWAYS_DEAD_ZONE) * LEAN_SIDEWAYS_THRUST_SCALE);
|
||||
} else {
|
||||
addThrust(right * -(leanSideways + LEAN_SIDEWAYS_DEAD_ZONE) * LEAN_SIDEWAYS_THRUST_SCALE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,12 +58,20 @@ void SixenseManager::update() {
|
|||
avatar->setDriveKeys(DOWN, data.trigger);
|
||||
}
|
||||
|
||||
// set palm position and normal based on Hydra position/orientation
|
||||
// Set palm position and normal based on Hydra position/orientation
|
||||
PalmData palm(&hand);
|
||||
palm.setActive(true);
|
||||
glm::vec3 position(-data.pos[0], data.pos[1], -data.pos[2]);
|
||||
glm::vec3 position(data.pos[0], data.pos[1], data.pos[2]);
|
||||
|
||||
// Adjust for distance between acquisition 'orb' and the user's torso
|
||||
// (distance to the right of body center, distance below torso, distance behind torso)
|
||||
const glm::vec3 SPHERE_TO_TORSO(-250.f, -300.f, -300.f);
|
||||
position = SPHERE_TO_TORSO + position;
|
||||
palm.setRawPosition(position);
|
||||
glm::quat rotation(data.rot_quat[3], -data.rot_quat[0], data.rot_quat[1], -data.rot_quat[2]);
|
||||
|
||||
// Rotate about controller
|
||||
rotation = glm::angleAxis(180.0f, 0.f, 1.f, 0.f) * rotation;
|
||||
const glm::vec3 PALM_VECTOR(0.0f, -1.0f, 0.0f);
|
||||
palm.setRawNormal(rotation * PALM_VECTOR);
|
||||
|
||||
|
|
|
@ -113,20 +113,20 @@ PerformanceWarning::~PerformanceWarning() {
|
|||
if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) {
|
||||
if (elapsedmsec > 1000) {
|
||||
double elapsedsec = (end - _start) / 1000000.0;
|
||||
qDebug("%s took %lf seconds %s\n", _message, elapsedsec, (_alwaysDisplay ? "" : "WARNING!") );
|
||||
qDebug("%s took %.2lf seconds %s\n", _message, elapsedsec, (_alwaysDisplay ? "" : "WARNING!") );
|
||||
} else {
|
||||
if (_suppressShortTimings) {
|
||||
if (elapsedmsec > 10) {
|
||||
qDebug("%s took %lf milliseconds %s\n", _message, elapsedmsec,
|
||||
qDebug("%s took %.1lf milliseconds %s\n", _message, elapsedmsec,
|
||||
(_alwaysDisplay || (elapsedmsec < 10) ? "" : "WARNING!"));
|
||||
}
|
||||
} else {
|
||||
qDebug("%s took %lf milliseconds %s\n", _message, elapsedmsec,
|
||||
qDebug("%s took %.2lf milliseconds %s\n", _message, elapsedmsec,
|
||||
(_alwaysDisplay || (elapsedmsec < 10) ? "" : "WARNING!"));
|
||||
}
|
||||
}
|
||||
} else if (_alwaysDisplay) {
|
||||
qDebug("%s took %lf milliseconds\n", _message, elapsedmsec);
|
||||
qDebug("%s took %.2lf milliseconds\n", _message, elapsedmsec);
|
||||
}
|
||||
// if the caller gave us a pointer to store the running total, track it now.
|
||||
if (_runningTotal) {
|
||||
|
|
Loading…
Reference in a new issue