From 4c453ec4e927b50d78c2c5404988250674b9683d Mon Sep 17 00:00:00 2001 From: D-AIRY <admin@ds-servers.com> Date: Fri, 5 Jun 2020 20:56:01 +0300 Subject: [PATCH] Observer changed event --- source/xEngine/Engine.cpp | 8 +++++++- source/xEngine/Engine.h | 2 ++ source/xcommon/XEvents.h | 10 ++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/source/xEngine/Engine.cpp b/source/xEngine/Engine.cpp index 3203de187..f9f5e6f8c 100644 --- a/source/xEngine/Engine.cpp +++ b/source/xEngine/Engine.cpp @@ -123,6 +123,7 @@ CEngine::CEngine(int argc, char **argv, const char *szName) INIT_OUTPUT_STREAM(m_pCore); LibReport(REPORT_MSG_LEVEL_NOTICE, "LIB core initialized\n"); + m_pObserverChangedEventChannel = m_pCore->getEventChannel<XEventObserverChanged>(EVENT_OBSERVER_CHANGED_GUID); Core_0RegisterCVarString("engine_version", SKYXENGINE_VERSION, "Текущая версия движка", FCVAR_READONLY); @@ -382,9 +383,14 @@ bool CEngine::runFrame() if(pRenderContext) { - SRender_SetCamera(m_pCallback->getCameraForFrame()); + ICamera *pCamera = m_pCallback->getCameraForFrame(); + SRender_SetCamera(pCamera); SRender_UpdateView(); + XEventObserverChanged ev; + ev.pCamera = pCamera; + m_pObserverChangedEventChannel->broadcastEvent(&ev); + IXRenderPipeline *pRenderPipeline; m_pCore->getRenderPipeline(&pRenderPipeline); diff --git a/source/xEngine/Engine.h b/source/xEngine/Engine.h index 1333bed86..e86557770 100644 --- a/source/xEngine/Engine.h +++ b/source/xEngine/Engine.h @@ -55,6 +55,8 @@ protected: IXUI *m_pXUI = NULL; + IEventChannel<XEventObserverChanged> *m_pObserverChangedEventChannel = NULL; + #ifdef USE_BREAKPAD google_breakpad::ExceptionHandler *m_pBreakpadHandler = NULL; #endif diff --git a/source/xcommon/XEvents.h b/source/xcommon/XEvents.h index a3fbfc39d..0d33ec29a 100644 --- a/source/xcommon/XEvents.h +++ b/source/xcommon/XEvents.h @@ -222,4 +222,14 @@ struct XEventCvarChanged const void *pCvar; }; + +// {5CEC2355-1F1E-4A1D-8E69-5B92850B62D2} +#define EVENT_OBSERVER_CHANGED_GUID DEFINE_XGUID(0x5cec2355, 0x1f1e, 0x4a1d, 0x8e, 0x69, 0x5b, 0x92, 0x85, 0xb, 0x62, 0xd2) + +class ICamera; +struct XEventObserverChanged +{ + ICamera *pCamera; +}; + #endif -- GitLab