From d1c156639e3796481353d7e949c3f6a66d7fea3f Mon Sep 17 00:00:00 2001 From: jarmonik Date: Sun, 18 Feb 2024 13:26:08 +0200 Subject: [PATCH] Some small fixes. --- OVP/D3D9Client/Scene.cpp | 40 ++++++++++++++++++++++++-------------- OVP/D3D9Client/VVessel.cpp | 19 ++++++++++-------- OVP/D3D9Client/VVessel.h | 2 +- Src/Orbiter/VCockpit.h | 6 ------ Src/Orbiter/Vecmat.h | 10 ++++++++++ 5 files changed, 47 insertions(+), 30 deletions(-) diff --git a/OVP/D3D9Client/Scene.cpp b/OVP/D3D9Client/Scene.cpp index 6b678e944..f92904986 100644 --- a/OVP/D3D9Client/Scene.cpp +++ b/OVP/D3D9Client/Scene.cpp @@ -1830,8 +1830,11 @@ void Scene::clbkRenderMainScene() if (Config->ShadowMapMode >= 1) { // Get shadowing params for vFocus - SMapInput smi = vFocus->GetSMapRenderData(vVessel::SMI::Visual); - pExtShdMap = RenderObjectsInShadow(&smi, RenderList, pSketch); + SMapInput smi; + if (vFocus->GetSMapRenderData(vVessel::SMI::Visual, 0, &smi)) { + pExtShdMap = RenderObjectsInShadow(&smi, RenderList, pSketch); + } + else pExtShdMap = nullptr; } @@ -1841,7 +1844,9 @@ void Scene::clbkRenderMainScene() { // Don't render more shadows if debug controls are open to keep pExtShdMap valid - SMapInput smf = vFocus->GetSMapRenderData(vVessel::SMI::Visual); + SMapInput smf; + vFocus->GetSMapRenderData(vVessel::SMI::Visual, 0, &smf); + list RenderThese; // Select objects to render with shadow map @@ -1854,8 +1859,10 @@ void Scene::clbkRenderMainScene() while (RenderThese.size()) { - SMapInput smi = RenderThese.front()->GetSMapRenderData(vVessel::SMI::Visual); - RenderObjectsInShadow(&smi, RenderThese, pSketch); + SMapInput smi; + if (RenderThese.front()->GetSMapRenderData(vVessel::SMI::Visual, 0, &smi)) { + RenderObjectsInShadow(&smi, RenderThese, pSketch); + } } } @@ -2848,19 +2855,22 @@ bool Scene::RenderVCProbes(vVessel* vV) vV->GetInterface()->Local2Global(ec->lPos._V(), gp); ResetOrigin(gp); - SMapInput smi = vV->GetSMapRenderData(vVessel::SMI::VC); - Casters.clear(); + SMapInput smi; - if (ec->bRendered) { - vV->RenderInteriorENVMap(pDevice, ec, smSS); - } - else { - if (RenderShadowMap(&smi, smSS, Casters, true) < 0) { - LogErr("Failed to render shadow map for stage-set"); + if (vV->GetSMapRenderData(vVessel::SMI::VC, 0, &smi)) + { + if (ec->bRendered) { + vV->RenderInteriorENVMap(pDevice, ec, smSS); } else { - vV->RenderInteriorENVMap(pDevice, ec, smSS); - return false; + Casters.clear(); + if (RenderShadowMap(&smi, smSS, Casters, true) < 0) { + LogErr("Failed to render shadow map for stage-set"); + } + else { + vV->RenderInteriorENVMap(pDevice, ec, smSS); + return false; + } } } diff --git a/OVP/D3D9Client/VVessel.cpp b/OVP/D3D9Client/VVessel.cpp index 693e45a8a..95c6db73d 100644 --- a/OVP/D3D9Client/VVessel.cpp +++ b/OVP/D3D9Client/VVessel.cpp @@ -596,22 +596,25 @@ void vVessel::UpdateAnimations (int mshidx) // ============================================================================================ // -SMapInput vVessel::GetSMapRenderData(SMI type, int idx) +bool vVessel::GetSMapRenderData(SMI type, int idx, SMapInput *sm) { - SMapInput sm; D3DXVECTOR3 cpos; float rad; + D3DXVECTOR3 cpos; float rad; if (type == SMI::Visual) { - sm = { GetBoundingSpherePosDX(), FVECTOR3(-sundir), GetBoundingSphereRadius() }; + *sm = { GetBoundingSpherePosDX(), FVECTOR3(-sundir), GetBoundingSphereRadius() }; + return true; } if (type == SMI::VC) { - GetVCPos(&cpos, NULL, &rad); - sm = { cpos, FVECTOR3(-sundir), rad }; + bool bRet = GetVCPos(&cpos, NULL, &rad); + *sm = { cpos, FVECTOR3(-sundir), rad }; + return bRet; } if (type == SMI::Mesh) { - GetMeshPosition(idx, &cpos, nullptr, &rad); - sm = { cpos, FVECTOR3(-sundir), rad }; + bool bRet = GetMeshPosition(idx, &cpos, nullptr, &rad); + *sm = { cpos, FVECTOR3(-sundir), rad }; + return bRet; } - return sm; + return false; } // ============================================================================================ diff --git a/OVP/D3D9Client/VVessel.h b/OVP/D3D9Client/VVessel.h index 331993149..6177e2e1e 100644 --- a/OVP/D3D9Client/VVessel.h +++ b/OVP/D3D9Client/VVessel.h @@ -97,7 +97,7 @@ class vVessel: public vObject { bool IntersectShadowVolume(const SMapInput* shd); bool IntersectShadowTarget(const SMapInput* shd); void GetMinMaxLightDist(const SMapInput* shd, float* mind, float* maxd); - SMapInput GetSMapRenderData(SMI type, int idx = 0); + bool GetSMapRenderData(SMI type, int idx, SMapInput* sm); void ReloadTextures(); diff --git a/Src/Orbiter/VCockpit.h b/Src/Orbiter/VCockpit.h index f244702d2..561a4a2b1 100644 --- a/Src/Orbiter/VCockpit.h +++ b/Src/Orbiter/VCockpit.h @@ -80,12 +80,6 @@ class VirtualCockpit { private: - inline VECTOR3 _V(const Vector& v) - { - VECTOR3 vec = { v.x, v.y, v.z }; - return vec; - } - inline int AreaIndex (int aid) const { for (int i = 0; i < narea; i++) if (area[i]->id == aid) return i; diff --git a/Src/Orbiter/Vecmat.h b/Src/Orbiter/Vecmat.h index cf1179f53..74446cfea 100644 --- a/Src/Orbiter/Vecmat.h +++ b/Src/Orbiter/Vecmat.h @@ -1,12 +1,15 @@ // Copyright (c) Martin Schweiger // Licensed under the MIT License +#define OAPI_IMPLEMENTATION + #ifndef __VECMAT_H #define __VECMAT_H #include #include #include +#include // ======================================================================= // Some useful constants @@ -167,6 +170,13 @@ class Vector { }; }; + +inline VECTOR3 _V(const Vector& v) +{ + return { v.x, v.y, v.z }; +} + + // ======================================================================= // class Matrix