Skip to content

Commit

Permalink
Some small fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarmonik committed Feb 18, 2024
1 parent 439ba61 commit d1c1566
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 30 deletions.
40 changes: 25 additions & 15 deletions OVP/D3D9Client/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand All @@ -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<vVessel*> RenderThese;

// Select objects to render with shadow map
Expand All @@ -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);
}
}
}

Expand Down Expand Up @@ -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;
}
}
}

Expand Down
19 changes: 11 additions & 8 deletions OVP/D3D9Client/VVessel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

// ============================================================================================
Expand Down
2 changes: 1 addition & 1 deletion OVP/D3D9Client/VVessel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 0 additions & 6 deletions Src/Orbiter/VCockpit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions Src/Orbiter/Vecmat.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
// Copyright (c) Martin Schweiger
// Licensed under the MIT License

#define OAPI_IMPLEMENTATION

#ifndef __VECMAT_H
#define __VECMAT_H

#include <math.h>
#include <memory.h>
#include <ostream>
#include <OrbiterAPI.h>

// =======================================================================
// Some useful constants
Expand Down Expand Up @@ -167,6 +170,13 @@ class Vector {
};
};


inline VECTOR3 _V(const Vector& v)
{
return { v.x, v.y, v.z };
}


// =======================================================================
// class Matrix

Expand Down

0 comments on commit d1c1566

Please sign in to comment.