From 597f35db3d7fe84fb5cfdf22f1990a84b175ebea Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 10 Apr 2013 09:39:43 -0700 Subject: [PATCH] moved vector math helpers to Utils.cpp/h --- interface/src/Util.cpp | 23 +++++++++++++++++++++++ interface/src/Util.h | 4 ++++ interface/src/main.cpp | 20 -------------------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 03a11e3308..a670f48f9e 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -140,3 +140,26 @@ void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, gl glPopMatrix(); } + +// XXXBHG - These handy operators should probably go somewhere else, I'm surprised they don't +// already exist somewhere in OpenGL. Maybe someone can point me to them if they do exist! +glm::vec3 operator* (float lhs, const glm::vec3& rhs) +{ + glm::vec3 result = rhs; + result.x *= lhs; + result.y *= lhs; + result.z *= lhs; + return result; +} + +// XXXBHG - These handy operators should probably go somewhere else, I'm surprised they don't +// already exist somewhere in OpenGL. Maybe someone can point me to them if they do exist! +glm::vec3 operator* (const glm::vec3& lhs, float rhs) +{ + glm::vec3 result = lhs; + result.x *= rhs; + result.y *= rhs; + result.z *= rhs; + return result; +} + diff --git a/interface/src/Util.h b/interface/src/Util.h index c5a02df5aa..8efe6f549e 100644 --- a/interface/src/Util.h +++ b/interface/src/Util.h @@ -48,4 +48,8 @@ void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, gl double diffclock(timeval *clock1,timeval *clock2); +glm::vec3 operator* (float lhs, const glm::vec3& rhs); +glm::vec3 operator* (const glm::vec3& lhs, float rhs); + + #endif diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 531b0b50f8..00cd8d7bfc 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -511,26 +511,6 @@ void simulateHead(float frametime) } } -// These handy operators should probably go somewhere else, I'm surprised they don't -// already exist somewhere in OpenGL. Maybe someone can point me to them if they do exist! -glm::vec3 operator* (float lhs, const glm::vec3& rhs) -{ - glm::vec3 result = rhs; - result.x *= lhs; - result.y *= lhs; - result.z *= lhs; - return result; -} - -glm::vec3 operator* (const glm::vec3& lhs, float rhs) -{ - glm::vec3 result = lhs; - result.x *= rhs; - result.y *= rhs; - result.z *= rhs; - return result; -} - // XXXBHG - this code is not yet working. This is here to help Jeffery debug getAvatarHeadLookatDirection() // The code will draw a yellow line from the avatar's position to the origin, // It also attempts to draw a cyan line from the avatar to 2 meters in front of the avatar in the direction