common/vector_math: Move Vec[x] types into the Common namespace
These types are within the common library, so they should be using the Common namespace.
This commit is contained in:
parent
a1574aabd5
commit
1b855efd5e
6 changed files with 38 additions and 38 deletions
|
@ -32,12 +32,12 @@ public:
|
|||
}
|
||||
|
||||
void BeginTilt(int x, int y) {
|
||||
mouse_origin = Math::MakeVec(x, y);
|
||||
mouse_origin = Common::MakeVec(x, y);
|
||||
is_tilting = true;
|
||||
}
|
||||
|
||||
void Tilt(int x, int y) {
|
||||
auto mouse_move = Math::MakeVec(x, y) - mouse_origin;
|
||||
auto mouse_move = Common::MakeVec(x, y) - mouse_origin;
|
||||
if (is_tilting) {
|
||||
std::lock_guard<std::mutex> guard(tilt_mutex);
|
||||
if (mouse_move.x == 0 && mouse_move.y == 0) {
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
is_tilting = false;
|
||||
}
|
||||
|
||||
std::tuple<Math::Vec3<float>, Math::Vec3<float>> GetStatus() {
|
||||
std::tuple<Common::Vec3<float>, Common::Vec3<float>> GetStatus() {
|
||||
std::lock_guard<std::mutex> guard(status_mutex);
|
||||
return status;
|
||||
}
|
||||
|
@ -66,17 +66,17 @@ private:
|
|||
const std::chrono::steady_clock::duration update_duration;
|
||||
const float sensitivity;
|
||||
|
||||
Math::Vec2<int> mouse_origin;
|
||||
Common::Vec2<int> mouse_origin;
|
||||
|
||||
std::mutex tilt_mutex;
|
||||
Math::Vec2<float> tilt_direction;
|
||||
Common::Vec2<float> tilt_direction;
|
||||
float tilt_angle = 0;
|
||||
|
||||
bool is_tilting = false;
|
||||
|
||||
Common::Event shutdown_event;
|
||||
|
||||
std::tuple<Math::Vec3<float>, Math::Vec3<float>> status;
|
||||
std::tuple<Common::Vec3<float>, Common::Vec3<float>> status;
|
||||
std::mutex status_mutex;
|
||||
|
||||
// Note: always keep the thread declaration at the end so that other objects are initialized
|
||||
|
@ -85,7 +85,7 @@ private:
|
|||
|
||||
void MotionEmuThread() {
|
||||
auto update_time = std::chrono::steady_clock::now();
|
||||
Common::Quaternion<float> q = Common::MakeQuaternion(Math::Vec3<float>(), 0);
|
||||
Common::Quaternion<float> q = Common::MakeQuaternion(Common::Vec3<float>(), 0);
|
||||
Common::Quaternion<float> old_q;
|
||||
|
||||
while (!shutdown_event.WaitUntil(update_time)) {
|
||||
|
@ -96,14 +96,14 @@ private:
|
|||
std::lock_guard<std::mutex> guard(tilt_mutex);
|
||||
|
||||
// Find the quaternion describing current 3DS tilting
|
||||
q = Common::MakeQuaternion(Math::MakeVec(-tilt_direction.y, 0.0f, tilt_direction.x),
|
||||
tilt_angle);
|
||||
q = Common::MakeQuaternion(
|
||||
Common::MakeVec(-tilt_direction.y, 0.0f, tilt_direction.x), tilt_angle);
|
||||
}
|
||||
|
||||
auto inv_q = q.Inverse();
|
||||
|
||||
// Set the gravity vector in world space
|
||||
auto gravity = Math::MakeVec(0.0f, -1.0f, 0.0f);
|
||||
auto gravity = Common::MakeVec(0.0f, -1.0f, 0.0f);
|
||||
|
||||
// Find the angular rate vector in world space
|
||||
auto angular_rate = ((q - old_q) * inv_q).xyz * 2;
|
||||
|
@ -131,7 +131,7 @@ public:
|
|||
device = std::make_shared<MotionEmuDevice>(update_millisecond, sensitivity);
|
||||
}
|
||||
|
||||
std::tuple<Math::Vec3<float>, Math::Vec3<float>> GetStatus() const override {
|
||||
std::tuple<Common::Vec3<float>, Common::Vec3<float>> GetStatus() const override {
|
||||
return device->GetStatus();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue