comparison engine/core/view/camera.cpp @ 181:56ac89189bc4

fixed time handling in fife: - the time scaling method was unreliable when changing the time factors (jumping in the moment of the change) - replaced much calls to SDL_GetTicks with TimerManager::instance()->getTime() - some other time related cleanup
author spq@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 31 Jan 2009 04:15:43 +0000
parents 29309cd5e240
children 09f40db3f10c
comparison
equal deleted inserted replaced
180:66bd7f8c541e 181:56ac89189bc4
482 } 482 }
483 //if ((!map->isChanged()) && (!m_iswarped) && (cammove == ScreenPoint(0,0,0))) { 483 //if ((!map->isChanged()) && (!m_iswarped) && (cammove == ScreenPoint(0,0,0))) {
484 // return; 484 // return;
485 //} 485 //}
486 486
487 const unsigned long curtime = TimeManager::instance()->getTime();
488
489 // update each layer 487 // update each layer
490 m_renderbackend->pushClipArea(getViewPort()); 488 m_renderbackend->pushClipArea(getViewPort());
491 489
492 m_layer_to_instances.clear(); 490 m_layer_to_instances.clear();
493 491
532 Image* image = NULL; 530 Image* image = NULL;
533 Action* action = instance->getCurrentAction(); 531 Action* action = instance->getCurrentAction();
534 if (action) { 532 if (action) {
535 FL_DBG(_log, "Instance has action"); 533 FL_DBG(_log, "Instance has action");
536 int animation_id = action->getVisual<ActionVisual>()->getAnimationIndexByAngle(angle); 534 int animation_id = action->getVisual<ActionVisual>()->getAnimationIndexByAngle(angle);
537
538 Animation& animation = m_apool->getAnimation(animation_id); 535 Animation& animation = m_apool->getAnimation(animation_id);
539 int animtime = scaleTime(instance->getTotalTimeMultiplier(), instance->getActionRuntime()) % animation.getDuration(); 536 unsigned int animtime = instance->getActionRuntime() % animation.getDuration();
540 image = animation.getFrameByTimestamp(animtime); 537 image = animation.getFrameByTimestamp(animtime);
541 } else { 538 } else {
542 FL_DBG(_log, "No action"); 539 FL_DBG(_log, "No action");
543 int imageid = vc.getStaticImageIndexByAngle(angle, instance); 540 int imageid = vc.getStaticImageIndexByAngle(angle, instance);
544 FL_DBG(_log, LMsg("Instance does not have action, using static image with id ") << imageid); 541 FL_DBG(_log, LMsg("Instance does not have action, using static image with id ") << imageid);
548 // there was no static image for instance, trying default action 545 // there was no static image for instance, trying default action
549 action = instance->getObject()->getDefaultAction(); 546 action = instance->getObject()->getDefaultAction();
550 if (action) { 547 if (action) {
551 int animation_id = action->getVisual<ActionVisual>()->getAnimationIndexByAngle(angle); 548 int animation_id = action->getVisual<ActionVisual>()->getAnimationIndexByAngle(angle);
552 Animation& animation = m_apool->getAnimation(animation_id); 549 Animation& animation = m_apool->getAnimation(animation_id);
553 int animtime = scaleTime(instance->getTotalTimeMultiplier(), curtime) % animation.getDuration(); 550 unsigned int animtime = instance->getRuntime() % animation.getDuration();
554 image = animation.getFrameByTimestamp(animtime); 551 image = animation.getFrameByTimestamp(animtime);
555 } 552 }
556 } 553 }
557 } 554 }
558 if (image) { 555 if (image) {