Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Features/InteriorSun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ void InteriorSun::DrawSettings()
}
if (ImGui::SliderFloat("Interior Shadow Distance", &settings.InteriorShadowDistance, 1000.0f, 8000.0f)) {
*gInteriorShadowDistance = settings.InteriorShadowDistance;
SetShadowDistance(globals::game::tes && globals::game::tes->interiorCell);
auto tes = RE::TES::GetSingleton();
SetShadowDistance(tes && tes->interiorCell);
}
if (auto _tt = Util::HoverTooltipWrapper()) {
ImGui::Text(
Expand Down Expand Up @@ -72,7 +73,7 @@ void InteriorSun::PostPostLoad()

void InteriorSun::EarlyPrepass()
{
isInteriorWithSun = IsInteriorWithSun(globals::game::tes->interiorCell);
isInteriorWithSun = IsInteriorWithSun(RE::TES::GetSingleton()->interiorCell);
}

inline bool InteriorSun::IsInteriorWithSun(const RE::TESObjectCELL* cell)
Expand Down Expand Up @@ -102,7 +103,7 @@ RE::TESWorldSpace* InteriorSun::disableInteriorSun = [] {
void InteriorSun::DirShadowLightCulling::thunk(RE::BSShadowDirectionalLight* dirLight, RE::BSTArray<RE::BSTArray<RE::NiPointer<RE::NiAVObject>>>& jobArrays, RE::BSTArray<RE::NiPointer<RE::NiAVObject>>& nodes)
{
auto& singleton = globals::features::interiorSun;
const auto cell = globals::game::tes->interiorCell;
const auto cell = RE::TES::GetSingleton()->interiorCell;
auto* passedJobArrays = &jobArrays;

if (cell && singleton.isInteriorWithSun) {
Expand Down
6 changes: 3 additions & 3 deletions src/Features/TerrainShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void TerrainShadows::DrawSettings()
if (ImGui::CollapsingHeader("Debug")) {
std::string curr_worldspace = "N/A";
std::string curr_worldspace_name = "N/A";
auto tes = globals::game::tes;
auto tes = RE::TES::GetSingleton();
if (tes) {
auto worldspace = tes->GetRuntimeData2().worldSpace;
if (worldspace) {
Expand Down Expand Up @@ -171,7 +171,7 @@ void TerrainShadows::CompileComputeShaders()

bool TerrainShadows::IsHeightMapReady()
{
if (auto tes = globals::game::tes)
if (auto tes = RE::TES::GetSingleton())
if (auto worldspace = tes->GetRuntimeData2().worldSpace)
return cachedHeightmap && cachedHeightmap->worldspace == worldspace->GetFormEditorID();
return false;
Expand All @@ -197,7 +197,7 @@ TerrainShadows::PerFrame TerrainShadows::GetCommonBufferData()

void TerrainShadows::LoadHeightmap()
{
auto tes = globals::game::tes;
auto tes = RE::TES::GetSingleton();
if (!tes)
return;
auto worldspace = tes->GetRuntimeData2().worldSpace;
Expand Down
2 changes: 1 addition & 1 deletion src/Features/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void VR::DataLoaded()

void VR::EarlyPrepass()
{
*gDepthBufferCulling = globals::game::tes->interiorCell ? settings.EnableDepthBufferCullingInterior : settings.EnableDepthBufferCullingExterior;
*gDepthBufferCulling = RE::TES::GetSingleton()->interiorCell ? settings.EnableDepthBufferCullingInterior : settings.EnableDepthBufferCullingExterior;
}

//=============================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/Features/VolumetricLighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void VolumetricLighting::EarlyPrepass()
vlData.screenYMin1 = height - 1;
vlDataCB->Update(vlData);

const auto interiorCell = globals::game::tes->interiorCell;
const auto interiorCell = RE::TES::GetSingleton()->interiorCell;
const bool currentlyInInterior = interiorCell != nullptr;

if (initialised && currentlyInInterior == inInterior)
Expand Down
4 changes: 0 additions & 4 deletions src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ namespace globals
RE::BSGraphics::State* graphicsState = nullptr;
RE::BSGraphics::Renderer* renderer = nullptr;
RE::BSShaderManager::State* smState = nullptr;
RE::TES* tes = nullptr;
bool isVR = false;
RE::MemoryManager* memoryManager = nullptr;
RE::INISettingCollection* iniSettingCollection = nullptr;
RE::INIPrefSettingCollection* iniPrefSettingCollection = nullptr;
RE::GameSettingCollection* gameSettingCollection = nullptr;
Expand Down Expand Up @@ -150,7 +148,6 @@ namespace globals
renderer = RE::BSGraphics::Renderer::GetSingleton();
smState = &RE::BSShaderManager::State::GetSingleton();
isVR = REL::Module::IsVR();
memoryManager = RE::MemoryManager::GetSingleton();
iniSettingCollection = RE::INISettingCollection::GetSingleton();
iniPrefSettingCollection = RE::INIPrefSettingCollection::GetSingleton();
gameSettingCollection = RE::GameSettingCollection::GetSingleton();
Expand Down Expand Up @@ -186,7 +183,6 @@ namespace globals
void OnDataLoaded()
{
using namespace game;
tes = RE::TES::GetSingleton();
sky = RE::Sky::GetSingleton();
utilityShader = RE::BSUtilityShader::GetSingleton();

Expand Down
2 changes: 0 additions & 2 deletions src/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ namespace globals
extern RE::BSGraphics::State* graphicsState;
extern RE::BSGraphics::Renderer* renderer;
extern RE::BSShaderManager::State* smState;
extern RE::TES* tes;
extern bool isVR;
extern RE::MemoryManager* memoryManager;
extern RE::INISettingCollection* iniSettingCollection;
extern RE::INIPrefSettingCollection* iniPrefSettingCollection;
extern RE::GameSettingCollection* gameSettingCollection;
Expand Down
8 changes: 5 additions & 3 deletions src/TruePBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,10 +1109,12 @@ bool TruePBR::TESObjectLAND_SetupMaterial(RE::TESObjectLAND* land)
return false;
}

auto memoryManager = RE::MemoryManager::GetSingleton();

if (land->loadedData != nullptr && land->loadedData->mesh[0] != nullptr) {
land->data.flags.set(static_cast<RE::OBJ_LAND::Flag>(8));
for (uint32_t quadIndex = 0; quadIndex < 4; ++quadIndex) {
auto shaderProperty = static_cast<RE::BSLightingShaderProperty*>(globals::game::memoryManager->Allocate(REL::Module::IsVR() ? 0x178 : sizeof(RE::BSLightingShaderProperty), 0, false));
auto shaderProperty = static_cast<RE::BSLightingShaderProperty*>(memoryManager->Allocate(REL::Module::IsVR() ? 0x178 : sizeof(RE::BSLightingShaderProperty), 0, false));
shaderProperty->Ctor();

{
Expand Down Expand Up @@ -1148,7 +1150,7 @@ bool TruePBR::TESObjectLAND_SetupMaterial(RE::TESObjectLAND* land)
}

bool noLODLandBlend = false;
auto tes = globals::game::tes;
auto tes = RE::TES::GetSingleton();
auto worldSpace = tes->GetRuntimeData2().worldSpace;
if (worldSpace != nullptr) {
if (auto terrainManager = worldSpace->GetTerrainManager()) {
Expand Down Expand Up @@ -1249,7 +1251,7 @@ struct BSTempEffectGeometryDecal_Initialize
auto* singleton = globals::truePBR;

if (decal->decal != nullptr && singleton->IsPBRTextureSet(decal->texSet)) {
auto shaderProperty = static_cast<RE::BSLightingShaderProperty*>(globals::game::memoryManager->Allocate(sizeof(RE::BSLightingShaderProperty), 0, false));
auto shaderProperty = static_cast<RE::BSLightingShaderProperty*>(RE::MemoryManager::GetSingleton()->Allocate(sizeof(RE::BSLightingShaderProperty), 0, false));
shaderProperty->Ctor();

{
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Util
float4 TryGetWaterData(float offsetX, float offsetY)
{
if (globals::game::shadowState) {
if (auto tes = globals::game::tes) {
if (auto tes = RE::TES::GetSingleton()) {
auto position = GetEyePosition(0);
position.x += offsetX;
position.y += offsetY;
Expand Down Expand Up @@ -302,7 +302,7 @@ namespace Util

bool IsInterior()
{
auto tes = globals::game::tes;
auto tes = RE::TES::GetSingleton();
if (tes && !tes->interiorCell) {
if (auto worldSpace = tes->GetRuntimeData2().worldSpace) {
if (!worldSpace->flags.all(RE::TESWorldSpace::Flag::kNoSky)) {
Expand Down