MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / onFrameUpdate

Method onFrameUpdate

src/engine/World.cpp:660–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

658}
659
660void WorldInstance::onFrameUpdate(double deltaTime, float updateRangeSquared, const Math::Matrix& cameraWorld)
661{
662 // Tell script engine the frame started
663 m_ClassContents->scriptEngine.onFrameStart();
664
665 // Update physics
666 m_ClassContents->physicsSystem.update(deltaTime);
667
668 // Update sky
669 m_ClassContents->sky.interpolate();
670
671 size_t num = getComponentAllocator().getNumObtainedElements();
672 const auto& ctuple = getComponentDataBundle().m_Data;
673
674 Components::EntityComponent* ents = std::get<Components::EntityComponent*>(ctuple);
675 Components::StaticMeshComponent* sms = std::get<Components::StaticMeshComponent*>(ctuple);
676 Components::LogicComponent* logics = std::get<Components::LogicComponent*>(ctuple);
677 Components::AnimationComponent* anims = std::get<Components::AnimationComponent*>(ctuple);
678 Components::PositionComponent* positions = std::get<Components::PositionComponent*>(ctuple);
679 Components::VisualComponent* visuals = std::get<Components::VisualComponent*>(ctuple);
680
681 //#pragma omp parallel for
682 for (size_t i = 0; i < num; i++)
683 {
684 // Simple distance-check // TODO: Frustum/Occlusion-Culling
685 if (Components::hasComponent<Components::PositionComponent>(ents[i]))
686 {
687 if ((positions[i].m_WorldMatrix.Translation() - cameraWorld.Translation()).lengthSquared() >
688 updateRangeSquared * positions[i].m_DrawDistanceFactor)
689 continue;
690 }
691
692 Components::ComponentMask mask = ents[i].m_ComponentMask;
693 if (Components::hasComponent<Components::LogicComponent>(ents[i]))
694 {
695 if (logics[i].m_pLogicController)
696 {
697 logics[i].m_pLogicController->onUpdate(deltaTime);
698 }
699 }
700
701 if (Components::hasComponent<Components::VisualComponent>(ents[i]))
702 {
703 if (visuals[i].m_pVisualController)
704 {
705 visuals[i].m_pVisualController->onUpdate(deltaTime);
706 }
707 }
708
709 // Update animations, only if there isn't a valid parent registered
710 if (Components::hasComponent<Components::AnimationComponent>(ents[i]) && !anims[i].m_ParentAnimHandler.isValid())
711 {
712 anims[i].getAnimHandler().updateAnimations(deltaTime);
713 }
714 }
715
716 // TODO: Move this somewhere else, where other game-logic is!
717 // TODO: Must be done before the main-camera gets updated, actually

Callers

nothing calls this directly

Calls 15

onFrameStartMethod · 0.80
interpolateMethod · 0.80
lengthSquaredMethod · 0.80
TranslationMethod · 0.80
updateAnimationsMethod · 0.80
getPlayerEntityMethod · 0.80
onUpdateByInputMethod · 0.80
setListenerPositionMethod · 0.80
ForwardMethod · 0.80
UpMethod · 0.80
onFrameEndMethod · 0.80

Tested by

no test coverage detected