De-janked code by removing magic numbers

This commit is contained in:
barnold1953 2014-06-17 17:14:26 -07:00
parent 9f66eeb37f
commit fa32ad5b11
2 changed files with 16 additions and 18 deletions

View file

@ -190,7 +190,7 @@ void ApplicationOverlay::getClickLocation(int &x, int &y) const {
const float yRange = MAGNIFY_WIDTH * MAGNIFY_MULT / 2.0f; const float yRange = MAGNIFY_WIDTH * MAGNIFY_MULT / 2.0f;
//Loop through all magnification windows //Loop through all magnification windows
for (int i = 0; i < 3; i++) { for (int i = 0; i < NUMBER_OF_MAGNIFIERS; i++) {
if (_magActive[i]) { if (_magActive[i]) {
dx = x - _magX[i]; dx = x - _magX[i];
dy = y - _magY[i]; dy = y - _magY[i];
@ -212,7 +212,6 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
return; return;
} }
Application* application = Application::getInstance(); Application* application = Application::getInstance();
MyAvatar* myAvatar = application->getAvatar(); MyAvatar* myAvatar = application->getAvatar();
@ -251,7 +250,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
glAlphaFunc(GL_GREATER, 0.01f); glAlphaFunc(GL_GREATER, 0.01f);
//Update and draw the magnifiers //Update and draw the magnifiers
for (int i = 0; i < 3; i++) { for (int i = 0; i < NUMBER_OF_MAGNIFIERS; i++) {
if (_magActive[i]) { if (_magActive[i]) {
_magSizeMult[i] += MAG_SPEED; _magSizeMult[i] += MAG_SPEED;
@ -336,11 +335,11 @@ void ApplicationOverlay::renderControllerPointers() {
MyAvatar* myAvatar = application->getAvatar(); MyAvatar* myAvatar = application->getAvatar();
//Static variables used for storing controller state //Static variables used for storing controller state
static quint64 pressedTime[3] = { 0ULL, 0ULL, 0ULL }; static quint64 pressedTime[NUMBER_OF_MAGNIFIERS] = { 0ULL, 0ULL, 0ULL };
static bool isPressed[3] = { false, false, false }; static bool isPressed[NUMBER_OF_MAGNIFIERS] = { false, false, false };
static bool stateWhenPressed[3] = { false, false, false }; static bool stateWhenPressed[NUMBER_OF_MAGNIFIERS] = { false, false, false };
static bool triggerPressed[3] = { false, false, false }; static bool triggerPressed[NUMBER_OF_MAGNIFIERS] = { false, false, false };
static bool bumperPressed[3] = { false, false, false }; static bool bumperPressed[NUMBER_OF_MAGNIFIERS] = { false, false, false };
const HandData* handData = Application::getInstance()->getAvatar()->getHandData(); const HandData* handData = Application::getInstance()->getAvatar()->getHandData();
@ -472,7 +471,7 @@ void ApplicationOverlay::renderControllerPointersOculus() {
glBindTexture(GL_TEXTURE_2D, _crosshairTexture); glBindTexture(GL_TEXTURE_2D, _crosshairTexture);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
for (int i = 0; i < 3; i++) { for (int i = 0; i < NUMBER_OF_MAGNIFIERS; i++) {
//Dont render the reticle if its inactive //Dont render the reticle if its inactive
if (!_reticleActive[i]) { if (!_reticleActive[i]) {

View file

@ -43,8 +43,6 @@ private:
glm::vec2 uv; glm::vec2 uv;
}; };
enum MousePointerDevice { MOUSE, LEFT_CONTROLLER, RIGHT_CONTROLLER };
typedef QPair<GLuint, GLuint> VerticesIndices; typedef QPair<GLuint, GLuint> VerticesIndices;
void renderPointers(); void renderPointers();
@ -59,13 +57,14 @@ private:
float _trailingAudioLoudness; float _trailingAudioLoudness;
float _textureFov; float _textureFov;
// 0 = Mouse, 1 = Left Controller, 2 = Right Controller // 0 = Mouse, 1 = Left Controller, 2 = Right Controller
bool _reticleActive[3]; enum MagnifyDevices { MOUSE, LEFT_CONTROLLER, RIGHT_CONTROLLER, NUMBER_OF_MAGNIFIERS = RIGHT_CONTROLLER + 1 };
int _mouseX[3]; bool _reticleActive[NUMBER_OF_MAGNIFIERS];
int _mouseY[3]; int _mouseX[NUMBER_OF_MAGNIFIERS];
bool _magActive[3]; int _mouseY[NUMBER_OF_MAGNIFIERS];
int _magX[3]; bool _magActive[NUMBER_OF_MAGNIFIERS];
int _magY[3]; int _magX[NUMBER_OF_MAGNIFIERS];
float _magSizeMult[3]; int _magY[NUMBER_OF_MAGNIFIERS];
float _magSizeMult[NUMBER_OF_MAGNIFIERS];
float _alpha; float _alpha;
bool _active; bool _active;