diff --git a/source/gdefines.h b/source/gdefines.h index 136993cfdc10b24826512b7a8a0c7ab292d2d4da..3fd01e5e20eb8840193ace30eb94eb18986a1849 100644 --- a/source/gdefines.h +++ b/source/gdefines.h @@ -156,6 +156,31 @@ struct IBaseObject #define XMETHODCALLTYPE __stdcall +typedef struct _XGUID +{ + _XGUID() + { + } + _XGUID(unsigned long l, unsigned short w1, unsigned short w2, + unsigned char b1, unsigned char b2, unsigned char b3, unsigned char b4, + unsigned char b5, unsigned char b6, unsigned char b7, unsigned char b8): + Data1(l), Data2(w1), Data3(w2), Data40(b1), Data41(b2), Data43(b3), Data44(b4), + Data45(b5), Data46(b6), Data47(b7) + { + } + unsigned long Data1 = 0; + unsigned short Data2 = 0; + unsigned short Data3 = 0; + unsigned char Data40 = 0; + unsigned char Data41 = 0; + unsigned char Data42 = 0; + unsigned char Data43 = 0; + unsigned char Data44 = 0; + unsigned char Data45 = 0; + unsigned char Data46 = 0; + unsigned char Data47 = 0; +} XGUID; + class IXUnknown { protected: @@ -182,6 +207,11 @@ public: { return(0); } + + /*virtual void XMETHODCALLTYPE getInternalData(const XGUID *pGUID, void **ppOut) + { + *ppOut = NULL; + }*/ }; #if 0 @@ -222,31 +252,6 @@ public: virtual bool XMETHODCALLTYPE isEnd() = 0; }; -typedef struct _XGUID -{ - _XGUID() - { - } - _XGUID(unsigned long l, unsigned short w1, unsigned short w2, - unsigned char b1, unsigned char b2, unsigned char b3, unsigned char b4, - unsigned char b5, unsigned char b6, unsigned char b7, unsigned char b8): - Data1(l), Data2(w1), Data3(w2), Data40(b1), Data41(b2), Data43(b3), Data44(b4), - Data45(b5), Data46(b6), Data47(b7) - { - } - unsigned long Data1 = 0; - unsigned short Data2 = 0; - unsigned short Data3 = 0; - unsigned char Data40 = 0; - unsigned char Data41 = 0; - unsigned char Data42 = 0; - unsigned char Data43 = 0; - unsigned char Data44 = 0; - unsigned char Data45 = 0; - unsigned char Data46 = 0; - unsigned char Data47 = 0; -} XGUID; - #define DEFINE_XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ XGUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) diff --git a/source/light/IXLight.h b/source/light/IXLight.h index b2995edd84fb368f7256a67cf28634ba424ea9d8..ebf3fec7b5a0b1f2c6cce111e68b578fd6a2fde7 100644 --- a/source/light/IXLight.h +++ b/source/light/IXLight.h @@ -68,19 +68,6 @@ public: virtual bool isShadowDynamic() = 0; virtual void setShadowDynamic(bool isDynamic) = 0; - //@TODO: Remove this method - virtual void drawShape(IGXDevice *pDevice) = 0; - //@TODO: Remove this method - virtual IGXConstantBuffer* getConstants(IGXDevice *pDevice) = 0; - //@TODO: Remove this method - virtual LIGHT_RENDER_TYPE getRenderType() = 0; - //@TODO: Remove this method - virtual bool isDirty(LIGHT_RENDER_TYPE type) = 0; - //@TODO: Remove this method - virtual void markClean(LIGHT_RENDER_TYPE type) = 0; - //@TODO: Remove this method - virtual void testDirty() = 0; - virtual IXLightSpot *asSpot() = 0; virtual IXLightSun *asSun() = 0; virtual IXLightPoint *asPoint() = 0; diff --git a/source/light/LightSystem.cpp b/source/light/LightSystem.cpp index 4d568100ff014a25913554988c2f1eee29bc7f56..519ca34ff02d19491bbdc66dba744ba5211cb3f1 100644 --- a/source/light/LightSystem.cpp +++ b/source/light/LightSystem.cpp @@ -455,9 +455,9 @@ void XMETHODCALLTYPE CLightSystem::renderGI(IGXTexture2D *pLightTotal, IGXTextur IGXDepthStencilSurface *pOldDSSurface = pCtx->getDepthStencilSurface(); UINT uCounts[LIGHT_TYPE__COUNT] = {0}; - for(int i = 0, l = getCount(); i < l; ++i) + for(int i = 0, l = m_aLights.size(); i < l; ++i) { - ++uCounts[getLight(i)->getType()]; + ++uCounts[m_aLights[i]->getType()]; } m_pShadowCache->setLightsCount(uCounts[LIGHT_TYPE_POINT], uCounts[LIGHT_TYPE_SPOT], uCounts[LIGHT_TYPE_SUN] != 0); m_pShadowCache->setRSMLightsCount(uCounts[LIGHT_TYPE_POINT], uCounts[LIGHT_TYPE_SPOT], uCounts[LIGHT_TYPE_SUN] != 0); @@ -527,10 +527,10 @@ void XMETHODCALLTYPE CLightSystem::renderGI(IGXTexture2D *pLightTotal, IGXTextur */ // Определим список лампочек, которые будут участвовать в текущем кадре - IXLight *pLight; - for(int i = 0, l = getCount(); i < l; ++i) + CXLight *pLight; + for(int i = 0, l = m_aLights.size(); i < l; ++i) { - pLight = getLight(i); + pLight = m_aLights[i]; //если свет виден фрустуму камеры (это надо было заранее просчитать) и если свет включен if(pLight->isEnabled() && pLight->getRenderType() != LRT_NONE) diff --git a/source/light/ShadowCache.cpp b/source/light/ShadowCache.cpp index b65f5a153c41c42f040e71822c9fed632a897ebe..c4aa6d71b745845f4e544f91bfa89a179d1569be 100644 --- a/source/light/ShadowCache.cpp +++ b/source/light/ShadowCache.cpp @@ -223,13 +223,13 @@ void CShadowCache::nextFrame() m_reflectiveShadowCubeMaps.updateLastUsed(); } -void CShadowCache::addLight(IXLight *pLight) +void CShadowCache::addLight(CXLight *pLight) { pLight->testDirty(); m_aFrameLights.push_back(pLight); } -void CShadowCache::addRSMLight(IXLight *pLight) +void CShadowCache::addRSMLight(CXLight *pLight) { pLight->testDirty(); m_aFrameRSMLights.push_back(pLight); @@ -477,13 +477,13 @@ UINT CShadowCache::processNextRSMBunch() return(m_aReadyReflectiveMaps.size()); } -IXLight* CShadowCache::getLight(ID id) +CXLight* CShadowCache::getLight(ID id) { assert(ID_VALID(id) && m_aReadyMaps.size() > (UINT)id); return(m_aReadyMaps[id].pLight); } -IXLight* CShadowCache::getRSMLight(ID id) +CXLight* CShadowCache::getRSMLight(ID id) { assert(ID_VALID(id) && m_aReadyReflectiveMaps.size() > (UINT)id); return(m_aReadyReflectiveMaps[id].pLight); diff --git a/source/light/ShadowCache.h b/source/light/ShadowCache.h index e25bb24f5b4f81fc1bb29bb7c9fa4bf68c79c442..757b73c4e9fea9dd42e6e2ab941e3125f67f3b0b 100644 --- a/source/light/ShadowCache.h +++ b/source/light/ShadowCache.h @@ -3,11 +3,12 @@ #include <gdefines.h> -#include <light/IXLight.h> #include <mtrl/IXMaterialSystem.h> #include <common/array.h> #include "shadow.h" +#include "light.h" + enum SHADOW_TYPE { SHADOW_TYPE_PSSM, @@ -34,13 +35,13 @@ public: void setObserverCamera(ICamera *pCamera); //! Добавляет источник к текущему проходу, В случае отсутствия свободных слотов, возвращает false - void addLight(IXLight *pLight); - void addRSMLight(IXLight *pLight); + void addLight(CXLight *pLight); + void addRSMLight(CXLight *pLight); UINT processNextBunch(); UINT processNextRSMBunch(); - IXLight *getLight(ID id); - IXLight *getRSMLight(ID id); + CXLight *getLight(ID id); + CXLight *getRSMLight(ID id); IBaseShadowMap *getShadow(ID id); IBaseReflectiveShadowMap *getRSMShadow(ID id); @@ -54,8 +55,8 @@ protected: IGXRasterizerState *m_pRasterizerConservative = NULL; UINT m_uCurrentFrame = 0; - Array<IXLight*> m_aFrameLights; - Array<IXLight*> m_aFrameRSMLights; + Array<CXLight*> m_aFrameLights; + Array<CXLight*> m_aFrameRSMLights; bool m_isFirstBunch = true; bool m_isFirstRSMBunch = true; @@ -64,7 +65,7 @@ protected: CShadowMap map; bool isDirty = false; bool shouldProcess = false; - IXLight *pLight = NULL; + CXLight *pLight = NULL; UINT uLastUsed = UINT_MAX; }; @@ -73,7 +74,7 @@ protected: CShadowCubeMap map; bool isDirty = false; bool shouldProcess = false; - IXLight *pLight = NULL; + CXLight *pLight = NULL; UINT uLastUsed = UINT_MAX; }; @@ -82,7 +83,7 @@ protected: CShadowPSSM map; bool isDirty = false; bool shouldProcess = false; - IXLight *pLight = NULL; + CXLight *pLight = NULL; SX_ALIGNED_OP_MEM2(); }; @@ -92,7 +93,7 @@ protected: CReflectiveShadowMap map; bool isDirty = false; bool shouldProcess = false; - IXLight *pLight = NULL; + CXLight *pLight = NULL; UINT uLastUsed = UINT_MAX; }; @@ -101,7 +102,7 @@ protected: CReflectiveShadowCubeMap map; bool isDirty = false; bool shouldProcess = false; - IXLight *pLight = NULL; + CXLight *pLight = NULL; UINT uLastUsed = UINT_MAX; }; @@ -110,7 +111,7 @@ protected: CReflectiveShadowSun map; bool isDirty = false; bool shouldProcess = false; - IXLight *pLight = NULL; + CXLight *pLight = NULL; SX_ALIGNED_OP_MEM2(); }; @@ -123,10 +124,10 @@ protected: Array<T> m_aMaps; Array<T*> m_aMapsQueue; LIGHT_RENDER_TYPE m_renderType; - Array<IXLight*> &m_aFrameLights; + Array<CXLight*> &m_aFrameLights; Array<R> &m_aReadyMaps; public: - Cache(Array<IXLight*> &aFrameLights, Array<R> &aReadyMaps, IXRenderPipeline *pRenderPipeline, LIGHT_RENDER_TYPE renderType): + Cache(Array<CXLight*> &aFrameLights, Array<R> &aReadyMaps, IXRenderPipeline *pRenderPipeline, LIGHT_RENDER_TYPE renderType): m_aFrameLights(aFrameLights), m_aReadyMaps(aReadyMaps), m_pRenderPipeline(pRenderPipeline), @@ -240,7 +241,7 @@ protected: struct ReadyShadows { IBaseShadowMap *pShadowMap; - IXLight *pLight; + CXLight *pLight; }; Array<ReadyShadows> m_aReadyMaps; @@ -248,7 +249,7 @@ protected: struct ReadyReflectiveShadows { IBaseReflectiveShadowMap *pShadowMap; - IXLight *pLight; + CXLight *pLight; }; Array<ReadyReflectiveShadows> m_aReadyReflectiveMaps; diff --git a/source/light/light.h b/source/light/light.h index b8081993fb479011744b2c70300651acff026eed..1d93c8de116a3d9e85aa796441ce54e0eee0a157 100644 --- a/source/light/light.h +++ b/source/light/light.h @@ -53,12 +53,12 @@ public: virtual void updateVisibility(ICamera *pMainCamera, const float3 &vLPVmin, const float3 &vLPVmax); IXRenderableVisibility *getVisibility() override; - LIGHT_RENDER_TYPE getRenderType() override + LIGHT_RENDER_TYPE getRenderType() { return(m_renderType); } - void testDirty() override + void testDirty() { if(m_pMutationObserver->wasTriggered()) { @@ -66,11 +66,11 @@ public: m_dirty = LRT_ALL; } } - bool isDirty(LIGHT_RENDER_TYPE type) override + bool isDirty(LIGHT_RENDER_TYPE type) { - return(m_dirty & type); + return((m_dirty & type) != 0); } - void markClean(LIGHT_RENDER_TYPE type) override + void markClean(LIGHT_RENDER_TYPE type) { m_dirty &= ~type; } diff --git a/source/light/shadow.cpp b/source/light/shadow.cpp index 0634c4d18c1e247e9e00cca690c1d5aa6c0f9b26..e15b175b7c05f0fee1de189cd3a02630870e89cb 100644 --- a/source/light/shadow.cpp +++ b/source/light/shadow.cpp @@ -108,7 +108,7 @@ void CShadowMap::init(IGXDevice *pContext, UINT uSize) m_pCameraShaderDataVS = m_pDevice->createConstantBuffer(sizeof(m_cameraShaderData.vs)); } -void CShadowMap::setLight(IXLight *pLight) +void CShadowMap::setLight(CXLight *pLight) { m_pLight = pLight; } @@ -123,7 +123,7 @@ void CShadowMap::process(IXRenderPipeline *pRenderPipeline) IGXContext *pCtx = m_pDevice->getThreadContext(); - IXLightSpot *pSpotLight = m_pLight->asSpot(); + CXLightSpot *pSpotLight = (CXLightSpot*)m_pLight; //! @todo remove double with Light::updateFrustum() float3 vPos = pSpotLight->getPosition(); @@ -366,7 +366,7 @@ void CReflectiveShadowMap::init(IGXDevice *pContext, UINT uSize) m_pCameraShaderDataVS = m_pDevice->createConstantBuffer(sizeof(m_cameraShaderData.vs)); } -void CReflectiveShadowMap::setLight(IXLight *pLight) +void CReflectiveShadowMap::setLight(CXLight *pLight) { m_pLight = pLight; } @@ -381,7 +381,7 @@ void CReflectiveShadowMap::process(IXRenderPipeline *pRenderPipeline) IGXContext *pCtx = m_pDevice->getThreadContext(); - IXLightSpot *pSpotLight = m_pLight->asSpot(); + CXLightSpot *pSpotLight = (CXLightSpot*)m_pLight; //! @todo remove double with Light::updateFrustum() float3 vPos = pSpotLight->getPosition(); @@ -551,7 +551,7 @@ void CShadowPSSM::init(IGXDevice *pContext, UINT uSize) m_pCameraShaderDataVS = m_pDevice->createConstantBuffer(sizeof(m_cameraShaderData.vs)); } -void CShadowPSSM::setLight(IXLight *pLight) +void CShadowPSSM::setLight(CXLight *pLight) { m_pLight = pLight; } @@ -566,7 +566,7 @@ void CShadowPSSM::process(IXRenderPipeline *pRenderPipeline) IGXContext *pCtx = m_pDevice->getThreadContext(); - IXLightSun *pSunLight = m_pLight->asSun(); + CXLightSun *pSunLight = (CXLightSun*)m_pLight; //! @todo remove double with Light::updateFrustum() @@ -619,7 +619,7 @@ void CShadowPSSM::updateFrustums() { assert(m_pCamera); - IXLightSun *pSunLight = m_pLight->asSun(); + CXLightSun *pSunLight = (CXLightSun*)m_pLight; float3 vLightDir = pSunLight->getDirection() * LIGHTS_DIR_BASE; float3 vUpDir = pSunLight->getDirection() * float3(1.0f, 0.0f, 0.0f); @@ -876,7 +876,7 @@ void CReflectiveShadowSun::init(IGXDevice *pContext, UINT uSize) m_pCameraShaderDataVS = m_pDevice->createConstantBuffer(sizeof(m_cameraShaderData.vs)); } -void CReflectiveShadowSun::setLight(IXLight *pLight) +void CReflectiveShadowSun::setLight(CXLight *pLight) { m_pLight = pLight; } @@ -891,7 +891,7 @@ void CReflectiveShadowSun::process(IXRenderPipeline *pRenderPipeline) IGXContext *pCtx = m_pDevice->getThreadContext(); - IXLightSun *pSunLight = m_pLight->asSun(); + CXLightSun *pSunLight = (CXLightSun*)m_pLight; //! @todo remove double with Light::updateFrustum() @@ -955,7 +955,7 @@ void CReflectiveShadowSun::updateFrustum() { assert(m_pCamera); - IXLightSun *pSunLight = m_pLight->asSun(); + CXLightSun *pSunLight = (CXLightSun*)m_pLight; float3 vLightDir = pSunLight->getDirection() * LIGHTS_DIR_BASE; float3 vUpDir = pSunLight->getDirection() * float3(1.0f, 0.0f, 0.0f); @@ -1123,7 +1123,7 @@ void CShadowCubeMap::init(IGXDevice *pDevice, UINT uSize) m_pCameraShaderDataVS = m_pDevice->createConstantBuffer(sizeof(m_cameraShaderData.vs)); } -void CShadowCubeMap::setLight(IXLight *pLight) +void CShadowCubeMap::setLight(CXLight *pLight) { m_pLight = pLight; } @@ -1138,7 +1138,7 @@ void CShadowCubeMap::process(IXRenderPipeline *pRenderPipeline) IGXContext *pCtx = m_pDevice->getThreadContext(); - IXLightPoint *pPointLight = m_pLight->asPoint(); + CXLightPoint *pPointLight = (CXLightPoint*)m_pLight; float3 vPos = pPointLight->getPosition(); @@ -1358,7 +1358,7 @@ void CReflectiveShadowCubeMap::init(IGXDevice *pDevice, UINT uSize) m_pCameraShaderDataVS = m_pDevice->createConstantBuffer(sizeof(m_cameraShaderData.vs)); } -void CReflectiveShadowCubeMap::setLight(IXLight *pLight) +void CReflectiveShadowCubeMap::setLight(CXLight *pLight) { m_pLight = pLight; } @@ -1373,7 +1373,7 @@ void CReflectiveShadowCubeMap::process(IXRenderPipeline *pRenderPipeline) IGXContext *pCtx = m_pDevice->getThreadContext(); - IXLightPoint *pPointLight = m_pLight->asPoint(); + CXLightPoint *pPointLight = (CXLightPoint*)m_pLight; float3 vPos = pPointLight->getPosition(); diff --git a/source/light/shadow.h b/source/light/shadow.h index 4f8cd5ebff64a36bb914f5affb02821eae7de50e..8c6411b2cf207fbfe8f5bba5f2bfcf4795be7d07 100644 --- a/source/light/shadow.h +++ b/source/light/shadow.h @@ -14,6 +14,7 @@ See the license in LICENSE #include <graphix/graphix.h> #include <gcore/sxgcore.h> #include <light/IXLight.h> +#include "light.h" #define RSM_POINT_SIZE 32 #define RSM_SPOT_SIZE 32 @@ -49,7 +50,7 @@ public: void init(IGXDevice *pContext, UINT uSize); - void setLight(IXLight *pLight); + void setLight(CXLight *pLight); void process(IXRenderPipeline *pRenderPipeline); void genShadow(IGXTexture2D *pGBufferDepth, IGXTexture2D *pGBufferNormals) override; @@ -77,7 +78,7 @@ private: float m_fSize; - IXLight *m_pLight = NULL; + CXLight *m_pLight = NULL; float4x4 m_mView; float4x4 m_mProj; @@ -120,7 +121,7 @@ public: void init(IGXDevice *pContext, UINT uSize); - void setLight(IXLight *pLight); + void setLight(CXLight *pLight); void process(IXRenderPipeline *pRenderPipeline); void genLPV(bool isDebug = false) override; @@ -150,7 +151,7 @@ private: float m_fSize; - IXLight *m_pLight = NULL; + CXLight *m_pLight = NULL; float4x4 m_mView; float4x4 m_mProj; @@ -195,7 +196,7 @@ public: void init(IGXDevice *pContext, UINT uSize); void setObserverCamera(ICamera *pCamera); - void setLight(IXLight *pLight); + void setLight(CXLight *pLight); void process(IXRenderPipeline *pRenderPipeline); void genShadow(IGXTexture2D *pGBufferDepth, IGXTexture2D *pGBufferNormals) override; @@ -230,7 +231,7 @@ private: float m_fSize; - IXLight *m_pLight = NULL; + CXLight *m_pLight = NULL; struct { @@ -276,7 +277,7 @@ public: void init(IGXDevice *pContext, UINT uSize); void setObserverCamera(ICamera *pCamera); - void setLight(IXLight *pLight); + void setLight(CXLight *pLight); void process(IXRenderPipeline *pRenderPipeline); void genLPV(bool isDebug = false) override; protected: @@ -308,7 +309,7 @@ private: float m_fSize; - IXLight *m_pLight = NULL; + CXLight *m_pLight = NULL; struct { @@ -348,7 +349,7 @@ public: void init(IGXDevice *pDevice, UINT uSize); - void setLight(IXLight *pLight); + void setLight(CXLight *pLight); void process(IXRenderPipeline *pRenderPipeline); void genShadow(IGXTexture2D *pGBufferDepth, IGXTexture2D *pGBufferNormals) override; @@ -374,7 +375,7 @@ private: float m_fSize; - IXLight *m_pLight = NULL; + CXLight *m_pLight = NULL; float4x4 m_mView[6]; float4x4 m_mProj; @@ -435,7 +436,7 @@ public: void init(IGXDevice *pDevice, UINT uSize); - void setLight(IXLight *pLight); + void setLight(CXLight *pLight); void process(IXRenderPipeline *pRenderPipeline); void genLPV(bool isDebug = false) override; @@ -465,7 +466,7 @@ private: float m_fSize; - IXLight *m_pLight = NULL; + CXLight *m_pLight = NULL; float4x4 m_mView[6]; float4x4 m_mProj;