diff --git a/src/Client/GUI/Scene.h b/src/Client/GUI/Scene.h index 8f9e642..7674536 100644 --- a/src/Client/GUI/Scene.h +++ b/src/Client/GUI/Scene.h @@ -128,6 +128,7 @@ private: core::vector2df xyCharMovement; // stores sin() and cos() values for current MyCharacter orientation, so that they need to be calculated only if the character turns around bool mouse_pressed_left; bool mouse_pressed_right; + float old_char_o; }; diff --git a/src/Client/GUI/SceneWorld.cpp b/src/Client/GUI/SceneWorld.cpp index 6398adf..1c5a32d 100644 --- a/src/Client/GUI/SceneWorld.cpp +++ b/src/Client/GUI/SceneWorld.cpp @@ -33,6 +33,7 @@ SceneWorld::SceneWorld(PseuGUI *g) : Scene(g) mychar = wsession->GetMyChar(); ASSERT(mychar); _CalcXYMoveVect(mychar->GetO()); + old_char_o = mychar->GetO(); ILightSceneNode* light = smgr->addLightSceneNode(0, core::vector3df(0,0,0), SColorf(255, 255, 255, 255), 1000.0f); SLight ldata = light->getLightData(); @@ -367,11 +368,16 @@ void SceneWorld::OnUpdate(s32 timediff) } device->getCursorControl()->setPosition(mouse_pos); - // TODO: implement charater turning on right-click-mouse-move. - // the code below doesnt work at all actually, no idea why. seems like camera interferes with mychar pos or so.. + // rotate character if right mpouse button pressed. if(mouse_pressed_right) { - mychar->GetPositionPtr()->o = IRR_TO_O(DEG_TO_RAD(camera->getHeading())); + mychar->GetPositionPtr()->o = PI*3/2 - DEG_TO_RAD(camera->getHeading()); + // send update to server only if we turned by some amount and not always when we turn + if(!equals(old_char_o, mychar->GetO(), MOVE_TURN_UPDATE_DIFF)) + { + old_char_o = mychar->GetO(); + movemgr->MoveSetFacing(); + } } } } diff --git a/src/Client/World/MovementMgr.h b/src/Client/World/MovementMgr.h index 4971809..f4bb49a 100644 --- a/src/Client/World/MovementMgr.h +++ b/src/Client/World/MovementMgr.h @@ -5,6 +5,7 @@ #include "UpdateData.h" #define MOVE_HEARTBEAT_DELAY 500 +#define MOVE_TURN_UPDATE_DIFF 0.15f // not sure about original/real value, but this seems good // -- // -- MovementFlags and MovementInfo can be found in UpdateData.h