From 6cfc75a1a21239981d284dbff34653846c0403d2 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 4 Jul 2013 20:43:49 +0200 Subject: [PATCH] Correctly synchronize some more animation in snowballs, re #43 --HG-- branch : multipass-stereo --- code/snowballs2/client/src/animation.cpp | 8 ++++---- code/snowballs2/client/src/entities.cpp | 10 +++++----- code/snowballs2/client/src/entities.h | 2 +- code/snowballs2/client/src/snowballs_client.cpp | 13 ++++++------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/code/snowballs2/client/src/animation.cpp b/code/snowballs2/client/src/animation.cpp index ab873ffbc..dd2296e25 100644 --- a/code/snowballs2/client/src/animation.cpp +++ b/code/snowballs2/client/src/animation.cpp @@ -97,7 +97,7 @@ Anim AnimIdArray[][2] = void computeAnimation (CEntity &entity, EAnim anim) { // Get the current time - double currentTime = double (CTime::getLocalTime ())/1000.0f; + double currentTime = AnimationTime; // nlinfo ("%d playing animation", anim); // nlinfo ("%d playing animation %s ct%f st%f et%f", anim, AnimIdArray[anim][0].Name, currentTime, AnimIdArray[anim][0].Animation->getBeginTime (), AnimIdArray[anim][0].Animation->getEndTime ()); @@ -153,7 +153,7 @@ void playAnimation (CEntity &entity, EAnim anim, bool force) // nlinfo ("playAnimation() %d", anim); // Get the current time - CAnimationTime currentTime = CAnimationTime(CTime::getLocalTime ())/1000.0f; + CAnimationTime currentTime = AnimationTime; // Can't do animation without skeleton if (entity.Skeleton.empty()) @@ -224,7 +224,7 @@ void initAnimation() void updateAnimation() { // Get the current time - CAnimationTime currentTime = CAnimationTime(CTime::getLocalTime ())/1000.0f; + CAnimationTime currentTime = AnimationTime; for (EIT eit = Entities.begin (); eit != Entities.end (); eit++) { @@ -270,7 +270,7 @@ void updateAnimation() } // compute new animation position depending of the current time - PlayListManager->animate (double(CTime::getLocalTime ())/1000.0f); + PlayListManager->animate (AnimationTime); } void releaseAnimation() diff --git a/code/snowballs2/client/src/entities.cpp b/code/snowballs2/client/src/entities.cpp index af879958c..2972aebf1 100644 --- a/code/snowballs2/client/src/entities.cpp +++ b/code/snowballs2/client/src/entities.cpp @@ -105,7 +105,7 @@ bool _TestCLS = false; void CEntity::setState (TState state) { State = state; - StateStartTime = CTime::getLocalTime (); + StateStartTime = LocalTime; } @@ -376,7 +376,7 @@ void deleteAllEntities() void stateAppear (CEntity &entity) { // after 1 second, show the instance - if (CTime::getLocalTime () > entity.StateStartTime + 1000) + if (LocalTime > entity.StateStartTime + 1.0) { if (entity.Instance.getVisibility () != UTransform::Show) entity.Instance.show (); @@ -384,7 +384,7 @@ void stateAppear (CEntity &entity) // after 5 seconds, delete the particle system (if any) // and pass the entity into the Normal state - if (CTime::getLocalTime () > entity.StateStartTime + 3000) + if (LocalTime > entity.StateStartTime + 3.0) { if (!entity.Particule.empty()) { @@ -403,7 +403,7 @@ void stateAppear (CEntity &entity) void stateDisappear (CEntity &entity) { // after 1 second, remove the mesh and all collision stuff - if (CTime::getLocalTime () > entity.StateStartTime + 1000) + if (LocalTime > entity.StateStartTime + 1.0) { if (entity.Instance.getVisibility () != UTransform::Hide) { @@ -419,7 +419,7 @@ void stateDisappear (CEntity &entity) } // after 5 seconds, remove the particle system and the entity entry - if (CTime::getLocalTime () > entity.StateStartTime + 3000) + if (LocalTime > entity.StateStartTime + 3.0) { deleteEntity (entity); } diff --git a/code/snowballs2/client/src/entities.h b/code/snowballs2/client/src/entities.h index 0ad7819ee..e85ffc569 100644 --- a/code/snowballs2/client/src/entities.h +++ b/code/snowballs2/client/src/entities.h @@ -108,7 +108,7 @@ public: // The state of this entity TState State; // The date of the beginning of this state - NLMISC::TTime StateStartTime; + NLMISC::TLocalTime StateStartTime; // The type enum of the entity enum TType { Self, Other, Snowball }; diff --git a/code/snowballs2/client/src/snowballs_client.cpp b/code/snowballs2/client/src/snowballs_client.cpp index ea0bc2648..6c3630a8b 100644 --- a/code/snowballs2/client/src/snowballs_client.cpp +++ b/code/snowballs2/client/src/snowballs_client.cpp @@ -691,14 +691,14 @@ void loopIngame() CGameTime::updateTime(); CGameTime::advanceTime(1.0); - // 03. Update Input (keyboard controls, etc) + // 03. Update Incoming (network, receive messages) + updateNetwork(); + + // 04. Update Input (keyboard controls, etc) Driver->EventServer.pump(); // Pump user input messages MouseListener->update(); MouseListener->updateCamera(); - // 04. Update Incoming (network, receive messages) - updateNetwork(); - // 05. Update Weather (sky, snow, wind, fog, sun) animateSky(LocalTimeDelta); @@ -706,7 +706,7 @@ void loopIngame() updateLandscape(); // Update the landscape // ... Update Animations (TEST) - // ... + updateAnimation(); // 07. Update Entities (collisions and actions) // - Move Other Entities (move//, animations, etc) @@ -783,7 +783,7 @@ void loopIngame() Scene->render(); // Render // 05. Render Effects (flare) - if (!StereoDisplay) updateLensFlare(); // Render the lens flare (left eye stretched with stereo...) + if (!StereoHMD) updateLensFlare(); // Render the lens flare (left eye stretched with stereo...) } if (!StereoDisplay || StereoDisplay->wantInterface3D()) @@ -817,7 +817,6 @@ void loopIngame() updateRadar(); // Update the radar updateGraph(); // Update the radar if (ShowCommands) updateCommands(); // Update the commands panel - updateAnimation(); renderEntitiesNames(); // Render the name on top of the other players updateInterface(); // Update interface renderInformation();