Skip to content

Commit

Permalink
Merge pull request #10 from ColdIce1605/reduce-reliance-on-win-apis
Browse files Browse the repository at this point in the history
replace sinf and cosf
  • Loading branch information
Eirenliel committed Dec 28, 2021
2 parents 21a5857 + 5e0c536 commit b41fe85
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ControllerDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void SlimeVRDriver::ControllerDevice::Update()
linalg::vec<float, 4> hmd_rotation{ (float)hmd_pose.qRotation.x, (float)hmd_pose.qRotation.y, (float)hmd_pose.qRotation.z, (float)hmd_pose.qRotation.w };

// Do shaking animation if haptic vibration was requested
float controller_y = -0.2f + 0.01f * std::sinf(8 * 3.1415f * vibrate_anim_state_);
float controller_y = -0.2f + 0.01f * std::sin(8 * 3.1415f * vibrate_anim_state_);

// Left hand controller on the left, right hand controller on the right, any other handedness sticks to the middle
float controller_x = this->handedness_ == Handedness::LEFT ? -0.2f : (this->handedness_ == Handedness::RIGHT ? 0.2f : 0.f);
Expand Down
4 changes: 2 additions & 2 deletions src/HMDDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void SlimeVRDriver::HMDDevice::Update()
this->rot_x_ = std::fmax(this->rot_x_, -3.14159f/2);
this->rot_x_ = std::fmin(this->rot_x_, 3.14159f/2);

linalg::vec<float, 4> y_quat{ 0, std::sinf(this->rot_y_ / 2), 0, std::cosf(this->rot_y_ / 2) };
linalg::vec<float, 4> y_quat{ 0, std::sin(this->rot_y_ / 2), 0, std::cos(this->rot_y_ / 2) };

linalg::vec<float, 4> x_quat{ std::sinf(this->rot_x_ / 2), 0, 0, std::cosf(this->rot_x_ / 2) };
linalg::vec<float, 4> x_quat{ std::sin(this->rot_x_ / 2), 0, 0, std::cos(this->rot_x_ / 2) };

linalg::vec<float, 4> pose_rot = linalg::qmul(y_quat, x_quat);

Expand Down
5 changes: 2 additions & 3 deletions src/TrackingReferenceDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "TrackingReferenceDevice.hpp"
#include <Windows.h>

SlimeVRDriver::TrackingReferenceDevice::TrackingReferenceDevice(std::string serial):
serial_(serial)
Expand All @@ -25,9 +24,9 @@ void SlimeVRDriver::TrackingReferenceDevice::Update()

linalg::vec<float, 3> device_position{ 0.f, 1.f, 1.f };

linalg::vec<float, 4> y_quat{ 0, std::sinf(this->random_angle_rad_ / 2), 0, std::cosf(this->random_angle_rad_ / 2) }; // Point inwards (z- is forward)
linalg::vec<float, 4> y_quat{ 0, std::sin(this->random_angle_rad_ / 2), 0, std::cos(this->random_angle_rad_ / 2) }; // Point inwards (z- is forward)

linalg::vec<float, 4> x_look_down{ std::sinf((-3.1415f/4) / 2), 0, 0, std::cosf((-3.1415f / 4) / 2) }; // Tilt downwards to look at the centre
linalg::vec<float, 4> x_look_down{ std::sin((-3.1415f/4) / 2), 0, 0, std::cos((-3.1415f / 4) / 2) }; // Tilt downwards to look at the centre

linalg::vec<float, 4> device_rotation = linalg::qmul(y_quat, x_look_down);

Expand Down

0 comments on commit b41fe85

Please sign in to comment.