Browse Source

Minor refactoring and cleaning on IK component's code.

Yao Wei Tjong 姚伟忠 8 years ago
parent
commit
8c9122ce25

+ 5 - 8
Source/Samples/45_InverseKinematics/InverseKinematics.cpp

@@ -38,7 +38,6 @@
 #include <Urho3D/Physics/CollisionShape.h>
 #include <Urho3D/Physics/RigidBody.h>
 #include <Urho3D/Resource/ResourceCache.h>
-#include <Urho3D/Scene/Scene.h>
 #include <Urho3D/UI/Font.h>
 #include <Urho3D/UI/Text.h>
 #include <Urho3D/UI/UI.h>
@@ -138,7 +137,7 @@ void InverseKinematics::CreateScene()
     // possible to the effectors for optimal performance. Since in this case
     // we're solving the legs only, we can place the solver at the spine.
     Node* spine = jackNode_->GetChild("Bip01_Spine", true);
-    solver_ = jackNode_->CreateComponent<IKSolver>();
+    solver_ = spine->CreateComponent<IKSolver>();
 
     // Disable auto-solving, which means we need to call Solve() manually
     solver_->EnableAutoSolve(false);
@@ -190,7 +189,7 @@ void InverseKinematics::SetupViewport()
     renderer->SetViewport(0, viewport);
 }
 
-void InverseKinematics::UpdateCameraAndFloor(float timeStep)
+void InverseKinematics::UpdateCameraAndFloor(float /*timeStep*/)
 {
     // Do not move if the UI has a focused element (the console)
     if (GetSubsystem<UI>()->GetFocusElement())
@@ -198,8 +197,6 @@ void InverseKinematics::UpdateCameraAndFloor(float timeStep)
 
     Input* input = GetSubsystem<Input>();
 
-    // Movement speed as world units per second
-    const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;
 
@@ -248,7 +245,7 @@ void InverseKinematics::SubscribeToEvents()
     SubscribeToEvent(E_SCENEDRAWABLEUPDATEFINISHED, URHO3D_HANDLER(InverseKinematics, HandleSceneDrawableUpdateFinished));
 }
 
-void InverseKinematics::HandleUpdate(StringHash eventType, VariantMap& eventData)
+void InverseKinematics::HandleUpdate(StringHash /*eventType*/, VariantMap& eventData)
 {
     using namespace Update;
 
@@ -259,13 +256,13 @@ void InverseKinematics::HandleUpdate(StringHash eventType, VariantMap& eventData
     UpdateCameraAndFloor(timeStep);
 }
 
-void InverseKinematics::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
+void InverseKinematics::HandlePostRenderUpdate(StringHash /*eventType*/, VariantMap& eventData)
 {
     if (drawDebug_)
         solver_->DrawDebugGeometry(false);
 }
 
-void InverseKinematics::HandleSceneDrawableUpdateFinished(StringHash eventType, VariantMap& eventData)
+void InverseKinematics::HandleSceneDrawableUpdateFinished(StringHash /*eventType*/, VariantMap& eventData)
 {
     PhysicsWorld* phyWorld = scene_->GetComponent<PhysicsWorld>();
     Vector3 leftFootPosition = leftFoot_->GetWorldPosition();

+ 3 - 3
Source/Urho3D/Core/Context.cpp

@@ -26,17 +26,17 @@
 #include "../Core/EventProfiler.h"
 #include "../IO/Log.h"
 
-#include "../DebugNew.h"
-
 #ifndef MINI_URHO
 #include <SDL/SDL.h>
 #endif
 
 #ifdef URHO3D_IK
-#include <ik/memory.h>
 #include <ik/log.h>
+#include <ik/memory.h>
 #endif
 
+#include "../DebugNew.h"
+
 namespace Urho3D
 {
 

+ 4 - 5
Source/Urho3D/IK/IK.cpp

@@ -20,11 +20,10 @@
 // THE SOFTWARE.
 //
 
-#include "IK.h"
-#include "IKConstraint.h"
-#include "IKEffector.h"
-#include "IKSolver.h"
-
+#include "../IK/IK.h"
+#include "../IK/IKConstraint.h"
+#include "../IK/IKEffector.h"
+#include "../IK/IKSolver.h"
 
 namespace Urho3D
 {

+ 2 - 1
Source/Urho3D/IK/IKConstraint.cpp

@@ -20,11 +20,12 @@
 // THE SOFTWARE.
 //
 
+#include "../Core/Context.h"
 #include "../IK/IK.h"
 #include "../IK/IKConstraint.h"
-#include "../Core/Context.h"
 #include "../Scene/Node.h"
 #include "../Scene/SceneEvents.h"
+
 #include <ik/node.h>
 
 namespace Urho3D

+ 3 - 2
Source/Urho3D/IK/IKConverters.h

@@ -22,10 +22,11 @@
 
 #pragma once
 
-#include "../Math/Vector3.h"
 #include "../Math/Quaternion.h"
-#include <ik/vec3.h>
+#include "../Math/Vector3.h"
+
 #include <ik/quat.h>
+#include <ik/vec3.h>
 
 namespace Urho3D {
 

+ 5 - 7
Source/Urho3D/IK/IKEffector.cpp

@@ -20,17 +20,15 @@
 // THE SOFTWARE.
 //
 
-#include "../IK/IKEffector.h"
-#include "../IK/IKSolver.h"
-#include "../IK/IKConverters.h"
-#include "../IK/IKEvents.h"
 #include "../Core/Context.h"
 #include "../Graphics/DebugRenderer.h"
-#include "../Scene/Node.h"
-#include "../Scene/Scene.h"
+#include "../IK/IKConverters.h"
+#include "../IK/IKEffector.h"
+#include "../IK/IKEvents.h"
+#include "../IK/IKSolver.h"
 #include "../Scene/SceneEvents.h"
+
 #include <ik/effector.h>
-#include <ik/log.h>
 
 namespace Urho3D
 {

+ 0 - 1
Source/Urho3D/IK/IKEvents.h

@@ -24,7 +24,6 @@
 
 #include "../Core/Object.h"
 
-
 namespace Urho3D
 {
 

+ 4 - 7
Source/Urho3D/IK/IKSolver.cpp

@@ -28,18 +28,15 @@
 
 #include "../Core/Context.h"
 #include "../Core/Profiler.h"
-#include "../IO/Log.h"
-#include "../Scene/Node.h"
-#include "../Scene/Scene.h"
-#include "../Scene/SceneEvents.h"
 #include "../Graphics/Animation.h"
 #include "../Graphics/AnimationState.h"
 #include "../Graphics/DebugRenderer.h"
+#include "../IO/Log.h"
+#include "../Scene/SceneEvents.h"
 
-#include <ik/solver.h>
-#include <ik/node.h>
 #include <ik/effector.h>
-#include <ik/log.h>
+#include <ik/node.h>
+#include <ik/solver.h>
 
 namespace Urho3D
 {

+ 0 - 2
bin/Data/LuaScripts/45_InverseKinematics.lua

@@ -145,8 +145,6 @@ function UpdateCameraAndFloor(timeStep)
         return
     end
 
-    -- Movement speed as world units per second
-    local MOVE_SPEED = 20.0
     -- Mouse sensitivity as degrees per pixel
     local MOUSE_SENSITIVITY = 0.1
 

+ 0 - 2
bin/Data/Scripts/45_InverseKinematics.as

@@ -150,8 +150,6 @@ void UpdateCameraAndFloor(float timeStep)
     if (ui.focusElement !is null)
         return;
 
-    // Movement speed as world units per second
-    const float MOVE_SPEED = 20.0f;
     // Mouse sensitivity as degrees per pixel
     const float MOUSE_SENSITIVITY = 0.1f;