Correctly synchronize some more animation in snowballs, re #43

This commit is contained in:
kaetemi 2013-07-04 20:43:49 +02:00
parent 4b2ea661cc
commit 4402fbe1c2
4 changed files with 16 additions and 17 deletions

View file

@ -97,7 +97,7 @@ Anim AnimIdArray[][2] =
void computeAnimation (CEntity &entity, EAnim anim) void computeAnimation (CEntity &entity, EAnim anim)
{ {
// Get the current time // Get the current time
double currentTime = double (CTime::getLocalTime ())/1000.0f; double currentTime = AnimationTime;
// nlinfo ("%d playing animation", anim); // 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 ()); // 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); // nlinfo ("playAnimation() %d", anim);
// Get the current time // Get the current time
CAnimationTime currentTime = CAnimationTime(CTime::getLocalTime ())/1000.0f; CAnimationTime currentTime = AnimationTime;
// Can't do animation without skeleton // Can't do animation without skeleton
if (entity.Skeleton.empty()) if (entity.Skeleton.empty())
@ -224,7 +224,7 @@ void initAnimation()
void updateAnimation() void updateAnimation()
{ {
// Get the current time // Get the current time
CAnimationTime currentTime = CAnimationTime(CTime::getLocalTime ())/1000.0f; CAnimationTime currentTime = AnimationTime;
for (EIT eit = Entities.begin (); eit != Entities.end (); eit++) for (EIT eit = Entities.begin (); eit != Entities.end (); eit++)
{ {
@ -270,7 +270,7 @@ void updateAnimation()
} }
// compute new animation position depending of the current time // compute new animation position depending of the current time
PlayListManager->animate (double(CTime::getLocalTime ())/1000.0f); PlayListManager->animate (AnimationTime);
} }
void releaseAnimation() void releaseAnimation()

View file

@ -105,7 +105,7 @@ bool _TestCLS = false;
void CEntity::setState (TState state) void CEntity::setState (TState state)
{ {
State = state; State = state;
StateStartTime = CTime::getLocalTime (); StateStartTime = LocalTime;
} }
@ -376,7 +376,7 @@ void deleteAllEntities()
void stateAppear (CEntity &entity) void stateAppear (CEntity &entity)
{ {
// after 1 second, show the instance // after 1 second, show the instance
if (CTime::getLocalTime () > entity.StateStartTime + 1000) if (LocalTime > entity.StateStartTime + 1.0)
{ {
if (entity.Instance.getVisibility () != UTransform::Show) if (entity.Instance.getVisibility () != UTransform::Show)
entity.Instance.show (); entity.Instance.show ();
@ -384,7 +384,7 @@ void stateAppear (CEntity &entity)
// after 5 seconds, delete the particle system (if any) // after 5 seconds, delete the particle system (if any)
// and pass the entity into the Normal state // and pass the entity into the Normal state
if (CTime::getLocalTime () > entity.StateStartTime + 3000) if (LocalTime > entity.StateStartTime + 3.0)
{ {
if (!entity.Particule.empty()) if (!entity.Particule.empty())
{ {
@ -403,7 +403,7 @@ void stateAppear (CEntity &entity)
void stateDisappear (CEntity &entity) void stateDisappear (CEntity &entity)
{ {
// after 1 second, remove the mesh and all collision stuff // 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) 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 // 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); deleteEntity (entity);
} }

View file

@ -108,7 +108,7 @@ public:
// The state of this entity // The state of this entity
TState State; TState State;
// The date of the beginning of this state // The date of the beginning of this state
NLMISC::TTime StateStartTime; NLMISC::TLocalTime StateStartTime;
// The type enum of the entity // The type enum of the entity
enum TType { Self, Other, Snowball }; enum TType { Self, Other, Snowball };

View file

@ -691,14 +691,14 @@ void loopIngame()
CGameTime::updateTime(); CGameTime::updateTime();
CGameTime::advanceTime(1.0); 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 Driver->EventServer.pump(); // Pump user input messages
MouseListener->update(); MouseListener->update();
MouseListener->updateCamera(); MouseListener->updateCamera();
// 04. Update Incoming (network, receive messages)
updateNetwork();
// 05. Update Weather (sky, snow, wind, fog, sun) // 05. Update Weather (sky, snow, wind, fog, sun)
animateSky(LocalTimeDelta); animateSky(LocalTimeDelta);
@ -706,7 +706,7 @@ void loopIngame()
updateLandscape(); // Update the landscape updateLandscape(); // Update the landscape
// ... Update Animations (TEST) // ... Update Animations (TEST)
// ... updateAnimation();
// 07. Update Entities (collisions and actions) // 07. Update Entities (collisions and actions)
// - Move Other Entities (move//, animations, etc) // - Move Other Entities (move//, animations, etc)
@ -783,7 +783,7 @@ void loopIngame()
Scene->render(); // Render Scene->render(); // Render
// 05. Render Effects (flare) // 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()) if (!StereoDisplay || StereoDisplay->wantInterface3D())
@ -817,7 +817,6 @@ void loopIngame()
updateRadar(); // Update the radar updateRadar(); // Update the radar
updateGraph(); // Update the radar updateGraph(); // Update the radar
if (ShowCommands) updateCommands(); // Update the commands panel if (ShowCommands) updateCommands(); // Update the commands panel
updateAnimation();
renderEntitiesNames(); // Render the name on top of the other players renderEntitiesNames(); // Render the name on top of the other players
updateInterface(); // Update interface updateInterface(); // Update interface
renderInformation(); renderInformation();