From d3f7349692fa9c1329b8fca5d92f385cc4a8fde5 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Fri, 20 Feb 2009 22:17:26 +0000 Subject: [PATCH] pow is total overkill for x*x, introduce pow2 inline function to fix it. fix a warning. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2323 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/MathUtil.h | 3 +++ Source/Core/Core/Src/PluginManager.cpp | 2 +- Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Core/Common/Src/MathUtil.h b/Source/Core/Common/Src/MathUtil.h index a841a6dc6b..6edaffb2ca 100644 --- a/Source/Core/Common/Src/MathUtil.h +++ b/Source/Core/Common/Src/MathUtil.h @@ -27,6 +27,9 @@ uses round towards zero. */ +inline float pow2f(float x) {return x * x;} +inline double pow2(double x) {return x * x;} + void SaveSSEState(); void LoadSSEState(); void LoadDefaultSSEState(); diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp index 7970023193..aef91f512d 100644 --- a/Source/Core/Core/Src/PluginManager.cpp +++ b/Source/Core/Core/Src/PluginManager.cpp @@ -257,7 +257,7 @@ CPluginInfo::CPluginInfo(const char *_rFilename) If the user has done that he will instead get the "Can't open %s, it's missing" message. */ void CPluginManager::GetPluginInfo(CPluginInfo *&info, std::string Filename) { - for (int i = 0; i < m_PluginInfos.size(); i++) + for (int i = 0; i < (int)m_PluginInfos.size(); i++) { if (m_PluginInfos.at(i).GetFilename() == Filename) { diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp index 41cc66a95f..92220e4f6a 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuDynamics.cpp @@ -26,6 +26,7 @@ #include "../../../Core/InputCommon/Src/XInput.h" #include "Common.h" // Common +#include "MathUtil.h" #include "StringUtil.h" // for ArrayToString() #include "IniFile.h" #include "pluginspecs_wiimote.h" @@ -133,10 +134,10 @@ void PitchDegreeToAccelerometer(float _Roll, float _Pitch, u8 &_x, u8 &_y, u8 &_ /* I got these from reversing the calculation in PitchAccelerometerToDegree() in a math program I don't know if we can derive these from some kind of matrix or something */ float x_num = 2 * tanf(0.5f * _Roll) * z; - float x_den = powf(tanf(0.5f * _Roll), 2) - 1; + float x_den = pow2f(tanf(0.5f * _Roll)) - 1; x = - (x_num / x_den); float y_num = 2 * tanf(0.5f * _Pitch) * z; - float y_den = powf(tanf(0.5f * _Pitch), 2) - 1; + float y_den = pow2f(tanf(0.5f * _Pitch)) - 1; y = - (y_num / y_den); // ========================= }