`CTimeCycle` (#1078)

This commit is contained in:
Pirulax 2025-06-01 20:27:58 +02:00 committed by GitHub
parent cb7301b575
commit 1b34baea7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 355 additions and 251 deletions

View File

@ -733,6 +733,7 @@ void InjectHooksMain() {
CGangWars::InjectHooks();
CPlayerPedData::InjectHooks();
CTimeCycle::InjectHooks();
CColourSet::InjectHooks();
CSkidmarks::InjectHooks();
CMovingThings::InjectHooks();
CRoadBlocks::InjectHooks();

View File

@ -86,6 +86,9 @@ constexpr inline auto find_value(auto&& mapping, auto&& needle) {
NOTSA_UNREACHABLE("Needle not in the mapping!");
}
/*!
* @brief Find the index of the first occurrence of a value in a range, returning a default index if not found.
*/
template<rng::input_range R>
ptrdiff_t indexof(R&& r, const rng::range_value_t<R>& v, ptrdiff_t defaultIdx = -1) {
const auto it = rng::find(r, v);

View File

@ -49,6 +49,7 @@ public:
static uint8 GetGameWeekDay() { return CurrentDay; } // NOTSA, maybe
static float GetMinutesToday() { return float(ms_nGameClockMinutes) + 60.0f * (float)ms_nGameClockHours + (float)ms_nGameClockSeconds / 60.0f; } // 0x55F470
static float GetHoursToday() { return (float)(CClock::GetGameClockMinutes()) / 60.0f + (float)(CClock::GetGameClockSeconds()) / 3600.0f + (float)(CClock::GetGameClockHours()); } // notsa
static bool ClockHoursInRange(uint8 start, uint8 end) { return ms_nGameClockHours > start && ms_nGameClockHours < end; }
};

View File

@ -90,3 +90,18 @@ void CBox::StretchToPoint(const CVector& pt) {
m_vecMax[i] = std::max(m_vecMax[i], pt[i]);
}
}
CVector CBox::GetShortestVectorDistToPt(const CVector& pt) const {
const auto CalculateAxis = [&](int32 i) {
return std::max({
m_vecMin[i] - pt[i],
pt[i] - m_vecMax[i],
0.0f
});
};
return {
CalculateAxis(0),
CalculateAxis(1),
CalculateAxis(2)
};
}

View File

@ -42,6 +42,13 @@ public:
*/
void DrawWireFrame(CRGBA color, const CMatrix& transform = CMatrix::Unity()) const;
/*!
* @notsa
* @brief Find the shortest vector from the box to the point.
* @brief It's magnitude is `0` if `pt` is inside the box.
*/
CVector GetShortestVectorDistToPt(const CVector& pt) const;
public:
static void InjectHooks();
};

View File

@ -11,7 +11,7 @@ void CColourSet::InjectHooks() {
}
// 0x55F4B0
CColourSet::CColourSet(int32 weatherId, int32 timeId) {
CColourSet::CColourSet(int32 timeId, int32 weatherId) {
m_fAmbientRed = (float)CTimeCycle::m_nAmbientRed[timeId][weatherId];
m_fAmbientGreen = (float)CTimeCycle::m_nAmbientGreen[timeId][weatherId];
m_fAmbientBlue = (float)CTimeCycle::m_nAmbientBlue[timeId][weatherId];

View File

@ -6,6 +6,8 @@
*/
#pragma once
#include "common.h"
class CColourSet {
public:
float m_fAmbientRed;
@ -77,13 +79,13 @@ public:
public:
static void InjectHooks();
CColourSet* Constructor(int32 weatherId, int32 timeId) {
this->CColourSet::CColourSet(weatherId, timeId);
CColourSet* Constructor(int32 timeId, int32 weatherId) {
this->CColourSet::CColourSet(timeId, weatherId);
return this;
}
CColourSet() = default;
CColourSet(int32 weatherId, int32 timeId);
CColourSet(int32 timeId, int32 weatherId);
void Interpolate(CColourSet* a, CColourSet* b, float fa, float fb, bool bIgnoreSky);
// helpers
@ -114,5 +116,4 @@ public:
};
}
};
VALIDATE_SIZE(CColourSet, 0xAC);

View File

@ -298,19 +298,24 @@ void CShadows::PrintDebugPoly(CVector* a, CVector* b, CVector* c) {
}
// 0x7076C0
void CShadows::CalcPedShadowValues(CVector sunPosn, float& displacementX, float& displacementY, float& frontX, float& frontY, float& sideX, float& sideY) {
void CShadows::CalcPedShadowValues(
CVector sunPosn,
float& frontX, float& frontY,
float& sideX, float& sideY,
float& displacementX, float& displacementY
) {
const auto sunDist = sunPosn.Magnitude2D();
const auto recip = 1.0f / sunDist;
const auto mult = (sunDist + 1.0f) * recip;
frontX = -sunPosn.x * mult / 2.0f;
frontY = -sunPosn.y * mult / 2.0f;
displacementX = -sunPosn.x * mult / 2.0f;
displacementY = -sunPosn.y * mult / 2.0f;
sideX = -sunPosn.y * recip / 2.0f;
sideY = +sunPosn.x * recip / 2.0f;
frontX = -sunPosn.y * recip / 2.0f;
frontY = +sunPosn.x * recip / 2.0f;
sideX = -sunPosn.x / 2.0f;
sideY = -sunPosn.y / 2.0f;
displacementX = -sunPosn.x / 2.0f;
displacementY = -sunPosn.y / 2.0f;
}
// 0x707850

View File

@ -197,7 +197,12 @@ public:
static void RemoveOilInArea(float x1, float x2, float y1, float y2);
static void GunShotSetsOilOnFire(const CVector& shotOrigin, const CVector& shotTarget);
static void PrintDebugPoly(CVector* a, CVector* b, CVector* c);
static void CalcPedShadowValues(CVector sunPosn, float& displacementX, float& displacementY, float& frontX, float& frontY, float& sideX, float& sideY);
static void CalcPedShadowValues(
CVector sunPosn,
float& frontX, float& frontY,
float& sideX, float& sideY,
float& displacementX, float& displacementY
);
static void AffectColourWithLighting(eShadowType shadowType,
uint8 dayNightIntensity,
uint8 red, uint8 green, uint8 blue,

View File

@ -4,8 +4,6 @@
#include "PostEffects.h"
#include "Shadows.h"
static uint8 gTimecycleHours[] = { 5, 6, 7, 12, 19, 20, 22, 24 }; // 0x8CDECD
static uint8 gTimecycleStartHours[] = { 30, 30, 30, 50, 60, 60, 50, 35 }; // 0x8CDED8
int &TunnelWeather = *(int*)0x8CDEE0; // 9 = WEATHER_FOGGY_SF, unchanged
void CTimeCycle::InjectHooks() {
@ -19,9 +17,9 @@ void CTimeCycle::InjectHooks() {
RH_ScopedInstall(StartExtraColour, 0x55FEC0);
RH_ScopedInstall(StopExtraColour, 0x55FF20);
RH_ScopedInstall(AddOne, 0x55FF40);
RH_ScopedInstall(CalcColoursForPoint, 0x5603D0, { .reversed = false });
RH_ScopedInstall(CalcColoursForPoint, 0x5603D0);
RH_ScopedInstall(FindFarClipForCoors, 0x5616E0);
RH_ScopedInstall(FindTimeCycleBox, 0x55FFD0, { .reversed = false });
RH_ScopedInstall(FindTimeCycleBox, 0x55FFD0);
RH_ScopedInstall(SetConstantParametersForPostFX, 0x560210);
RH_ScopedInstall(GetAmbientRed, 0x560330);
RH_ScopedInstall(GetAmbientGreen, 0x560340);
@ -71,7 +69,7 @@ void CTimeCycle::Initialise() {
char* line;
for (auto w = 0; w < NUM_WEATHERS; w++) {
for (auto h = 0; h < NUM_HOURS; h++) {
while (line = CFileLoader::LoadLine(file), line) {
while (line = CFileLoader::LoadLine(file)) {
if (line[0] != '/' && line[0] != '\0') {
break;
}
@ -211,166 +209,201 @@ void CTimeCycle::StopExtraColour(bool bNoExtraColorInterior) {
// 0x55FF40
void CTimeCycle::AddOne(CBox& box, int16 farClip, int32 m_ExtraColor, float strength, float falloff, float lodDistMult) {
m_aBoxes[m_NumBoxes].m_Box = box;
m_aBoxes[m_NumBoxes].m_FarClip = farClip;
m_aBoxes[m_NumBoxes].m_ExtraColor = m_ExtraColor;
m_aBoxes[m_NumBoxes].m_Strength = strength / 100.0f;
m_aBoxes[m_NumBoxes].m_Falloff = falloff;
m_aBoxes[m_NumBoxes].m_LodDistMult = (uint8)(std::min(lodDistMult, 4.0f) * 32.0f);
m_aBoxes[m_NumBoxes].Box = box;
m_aBoxes[m_NumBoxes].FarClip = farClip;
m_aBoxes[m_NumBoxes].ExtraColor = m_ExtraColor;
m_aBoxes[m_NumBoxes].Strength = strength / 100.0f;
m_aBoxes[m_NumBoxes].Falloff = falloff;
m_aBoxes[m_NumBoxes].LodDistMult = (uint8)(std::min(lodDistMult, 4.0f) * 32.0f);
m_NumBoxes++;
}
// 0x5603D0
void CTimeCycle::CalcColoursForPoint(CVector point, CColourSet* set) {
return plugin::Call<0x5603D0, CVector, CColourSet*>(point, set);
constexpr auto TimeSamples = std::to_array({ 0, 5, 6, 7, 12, 19, 20, 22, 24 }); // 0x8CDECC
constexpr auto GreyValuesDuringDay = std::to_array({ 30, 30, 30, 50, 60, 60, 50, 35 }); // 0x8CDED8
// untested
CTimeCycleBox *lodBox, *farBox1, *farBox2, *weatherBox;
float lodBoxInterp, farBox1Interp, farBox2Interp, weatherBoxInterp;
FindTimeCycleBox(point, &lodBox, &lodBoxInterp, true, false, nullptr);
FindTimeCycleBox(point, &farBox1, &farBox1Interp, false, true, nullptr);
CTimeCycleBox *lodBoxA, *farBoxA, *farBoxB, *weatherBox;
float lodBoxA_T, farBoxA_T, farBoxB_T, weatherBox_T;
if (farBox1) {
FindTimeCycleBox(point, &farBox2, &farBox2Interp, false, true, farBox1);
if (farBox2 && farBox2->m_Box.GetWidth() > farBox1->m_Box.GetWidth()) {
std::swap(farBox1, farBox2);
std::swap(farBox1Interp, farBox2Interp);
// Find LOD box
FindTimeCycleBox(point, &lodBoxA, &lodBoxA_T, true, false, nullptr);
// Find far boxes
FindTimeCycleBox(point, &farBoxA, &farBoxA_T, false, true, nullptr);
if (farBoxA) {
FindTimeCycleBox(point, &farBoxB, &farBoxB_T, false, true, farBoxA);
if (farBoxB && farBoxB->Box.GetWidth() > farBoxA->Box.GetWidth()) {
std::swap(farBoxA, farBoxB);
std::swap(farBoxA_T, farBoxB_T);
}
} else {
farBox2 = nullptr;
}
FindTimeCycleBox(point, &weatherBox, &weatherBoxInterp, false, false, nullptr);
float time = (float)CClock::GetGameClockMinutes() / 60.0f + (float)CClock::GetGameClockSeconds() / 3600.0f + (float)CClock::GetGameClockHours();
time = std::min(time, 24.0f); // 23.999f ?
int curHourSel, nextHourSel;
for (curHourSel = 0; time >= (float)gTimecycleHours[curHourSel + 1]; curHourSel++) {
;
farBoxB = nullptr;
}
nextHourSel = (curHourSel + 1) % NUM_HOURS;
auto curHour = gTimecycleHours[curHourSel];
auto nextHour = gTimecycleHours[curHourSel + 1];
// Find current weather box
FindTimeCycleBox(point, &weatherBox, &weatherBox_T, false, false, nullptr);
float timeInterp = (time - (float)curHour) / (float)(nextHour - curHour);
float invTimeInterp = 1.0f - timeInterp;
float weatherInterp = CWeather::InterpolationValue;
float invWeatherInterp = 1.0f - weatherInterp;
// 0x560502 - Clamped hours
const auto hours = std::min(23.999f, CClock::GetHoursToday());
int boxHour, boxWeather;
// 0x560528 - Find sample index for current hour
int32 currSampleIdx{};
while (hours >= (float)(TimeSamples[currSampleIdx + 1])) {
currSampleIdx++;
}
const auto nextSampleIdx = (currSampleIdx + 1) % NUM_HOURS;
const float timeT = invLerp((float)(TimeSamples[currSampleIdx]), (float)(TimeSamples[currSampleIdx + 1]), hours);
const float invTimeT = 1.0f - timeT;
const float t = CWeather::InterpolationValue;
// 0x5605D5
eWeatherType boxWeather{ WEATHER_UNDEFINED };
int32 boxHour;
if (weatherBox) {
boxHour = weatherBox->m_ExtraColor % 8;
boxWeather = (weatherBox->m_ExtraColor / NUM_HOURS) + 21;
boxHour = weatherBox->ExtraColor % 8;
boxWeather = weatherBox->ExtraColor >= 8
? WEATHER_EXTRACOLOURS_2
: WEATHER_EXTRACOLOURS_1;
}
CColourSet currentOld(curHourSel, CWeather::OldWeatherType);
CColourSet nextOld(nextHourSel, CWeather::OldWeatherType);
CColourSet currentNew(curHourSel, CWeather::NewWeatherType);
CColourSet nextNew(nextHourSel, CWeather::NewWeatherType);
auto& camPos = TheCamera.GetPosition();
const auto& camPos = TheCamera.GetPosition();
float f = std::clamp((camPos.z - 20.0f) / 200.0f, 0.0f, 1.0f);
if (CWeather::OldWeatherType == WEATHER_EXTRASUNNY_SMOG_LA) {
CColourSet set1(curHourSel, WEATHER_EXTRASUNNY_LA);
currentOld.Interpolate(&currentOld, &set1, 1.0f - f, f, false);
CColourSet set2(nextHourSel, WEATHER_EXTRASUNNY_LA);
nextOld.Interpolate(&nextOld, &set2, 1.0f - f, f, false);
} else if (CWeather::OldWeatherType == WEATHER_SUNNY_SMOG_LA) {
CColourSet set1(curHourSel, WEATHER_SUNNY_LA);
currentOld.Interpolate(&currentOld, &set1, 1.0f - f, f, false);
CColourSet set2(nextHourSel, WEATHER_SUNNY_LA);
nextOld.Interpolate(&nextOld, &set2, 1.0f - f, f, false);
}
if (CWeather::NewWeatherType == WEATHER_EXTRASUNNY_SMOG_LA) {
CColourSet set1(curHourSel, WEATHER_EXTRASUNNY_LA);
currentNew.Interpolate(&currentNew, &set1, 1.0f - f, f, false);
CColourSet set2(nextHourSel, WEATHER_EXTRASUNNY_LA);
nextNew.Interpolate(&nextNew, &set2, 1.0f - f, f, false);
} else if (CWeather::NewWeatherType == WEATHER_SUNNY_SMOG_LA) {
CColourSet set1(curHourSel, WEATHER_SUNNY_LA);
currentNew.Interpolate(&currentNew, &set1, 1.0f - f, f, false);
CColourSet set2(nextHourSel, WEATHER_SUNNY_LA);
nextNew.Interpolate(&nextNew, &set2, 1.0f - f, f, false);
{ // 0x5606B7
CColourSet currentOld(currSampleIdx, CWeather::OldWeatherType);
CColourSet nextOld(nextSampleIdx, CWeather::OldWeatherType);
CColourSet currentNew(currSampleIdx, CWeather::NewWeatherType);
CColourSet nextNew(nextSampleIdx, CWeather::NewWeatherType);
if (CWeather::OldWeatherType == WEATHER_EXTRASUNNY_SMOG_LA) {
CColourSet set1(currSampleIdx, WEATHER_EXTRASUNNY_LA);
currentOld.Interpolate(&currentOld, &set1, 1.0f - f, f, false);
CColourSet set2(nextSampleIdx, WEATHER_EXTRASUNNY_LA);
nextOld.Interpolate(&nextOld, &set2, 1.0f - f, f, false);
} else if (CWeather::OldWeatherType == WEATHER_SUNNY_SMOG_LA) {
CColourSet set1(currSampleIdx, WEATHER_SUNNY_LA);
currentOld.Interpolate(&currentOld, &set1, 1.0f - f, f, false);
CColourSet set2(nextSampleIdx, WEATHER_SUNNY_LA);
nextOld.Interpolate(&nextOld, &set2, 1.0f - f, f, false);
}
if (CWeather::NewWeatherType == WEATHER_EXTRASUNNY_SMOG_LA) {
CColourSet set1(currSampleIdx, WEATHER_EXTRASUNNY_LA);
currentNew.Interpolate(&currentNew, &set1, 1.0f - f, f, false);
CColourSet set2(nextSampleIdx, WEATHER_EXTRASUNNY_LA);
nextNew.Interpolate(&nextNew, &set2, 1.0f - f, f, false);
} else if (CWeather::NewWeatherType == WEATHER_SUNNY_SMOG_LA) {
CColourSet set1(currSampleIdx, WEATHER_SUNNY_LA);
currentNew.Interpolate(&currentNew, &set1, 1.0f - f, f, false);
CColourSet set2(nextSampleIdx, WEATHER_SUNNY_LA);
nextNew.Interpolate(&nextNew, &set2, 1.0f - f, f, false);
}
{ // 0x560877
CColourSet a{}, b{};
a.Interpolate(&currentOld, &nextOld, invTimeT, timeT, false);
b.Interpolate(&currentNew, &nextNew, invTimeT, timeT, false);
set->Interpolate(&a, &b, 1.f - t, t, false);
}
}
CColourSet oldInterp{}, newInterp{};
oldInterp.Interpolate(&currentOld, &nextOld, invTimeInterp, timeInterp, false);
newInterp.Interpolate(&currentNew, &nextNew, invTimeInterp, timeInterp, false);
set->Interpolate(&oldInterp, &newInterp, invWeatherInterp, weatherInterp, false);
// 0x5608E0 - Calculate sky colors
{
const float lightMult = (1.0f / CCoronas::LightsMult + 3.0f) * 0.25f;
float lightMult = (1.0f / CCoronas::LightsMult + 3.0f) * 0.25f;
set->m_nSkyTopRed = std::min(uint16(float(set->m_nSkyTopRed) * lightMult), uint16(255));
set->m_nSkyTopGreen = std::min(uint16(float(set->m_nSkyTopGreen) * lightMult), uint16(255));
set->m_nSkyTopBlue = std::min(uint16(float(set->m_nSkyTopBlue) * lightMult), uint16(255));
set->m_nSkyBottomRed = std::min(uint16(float(set->m_nSkyBottomRed) * lightMult), uint16(255));
set->m_nSkyBottomGreen = std::min(uint16(float(set->m_nSkyBottomGreen) * lightMult), uint16(255));
set->m_nSkyBottomBlue = std::min(uint16(float(set->m_nSkyBottomBlue) * lightMult), uint16(255));
set->m_nSkyTopRed = std::min<uint16>((uint16)((float)(set->m_nSkyTopRed) * lightMult), 255);
set->m_nSkyTopGreen = std::min<uint16>((uint16)((float)(set->m_nSkyTopGreen) * lightMult), 255);
set->m_nSkyTopBlue = std::min<uint16>((uint16)((float)(set->m_nSkyTopBlue) * lightMult), 255);
set->m_nSkyBottomRed = std::min<uint16>((uint16)((float)(set->m_nSkyBottomRed) * lightMult), 255);
set->m_nSkyBottomGreen = std::min<uint16>((uint16)((float)(set->m_nSkyBottomGreen) * lightMult), 255);
set->m_nSkyBottomBlue = std::min<uint16>((uint16)((float)(set->m_nSkyBottomBlue) * lightMult), 255);
}
if (m_FogReduction) {
set->m_fFarClip = set->m_fFarClip > float(m_FogReduction) * 10.15625f ? set->m_fFarClip : float(m_FogReduction) * 10.15625f;
}
// 0x560A59
m_CurrentStoredValue = (m_CurrentStoredValue + 1) & 15;
CVector* vec = &m_VectorToSun[m_CurrentStoredValue];
float sunAngle = CClock::GetMinutesToday() * PI / 720.0f;
vec->x = +0.7f + std::sin(sunAngle);
vec->y = -0.7f;
vec->z = +0.2f - std::cos(sunAngle);
vec->Normalise();
// 0x560A67
const float sunAngle = CClock::GetMinutesToday() * PI / 720.0f;
m_VectorToSun[m_CurrentStoredValue] = CVector{
+0.7f + std::sin(sunAngle),
-0.7f,
+0.2f - std::cos(sunAngle),
}.Normalized();
// 0x560AAE
if (weatherBox && weatherBox->m_ExtraColor >= 0) {
float boxf = weatherBoxInterp * weatherBox->m_Strength;
if (weatherBox && weatherBox->ExtraColor >= 0) {
float boxf = weatherBox_T * weatherBox->Strength;
float invboxf = 1.0f - boxf;
set->m_nSkyTopRed = uint16((float)set->m_nSkyTopRed * invboxf + (float)m_nSkyTopRed[boxHour][boxWeather] * boxf);
set->m_nSkyTopGreen = uint16((float)set->m_nSkyTopGreen * invboxf + (float)m_nSkyTopGreen[boxHour][boxWeather] * boxf);
set->m_nSkyTopBlue = uint16((float)set->m_nSkyTopBlue * invboxf + (float)m_nSkyTopBlue[boxHour][boxWeather] * boxf);
set->m_nSkyTopRed = (uint16)(lerp<float>(set->m_nSkyTopRed, m_nSkyTopRed[boxHour][boxWeather], boxf));
set->m_nSkyTopGreen = (uint16)(lerp<float>(set->m_nSkyTopGreen, m_nSkyTopGreen[boxHour][boxWeather], boxf));
set->m_nSkyTopBlue = (uint16)(lerp<float>(set->m_nSkyTopBlue, m_nSkyTopBlue[boxHour][boxWeather], boxf));
set->m_nSkyBottomRed = uint16((float)set->m_nSkyBottomRed * invboxf + (float)m_nSkyBottomRed[boxHour][boxWeather] * boxf);
set->m_nSkyBottomGreen = uint16((float)set->m_nSkyBottomGreen * invboxf + (float)m_nSkyBottomGreen[boxHour][boxWeather] * boxf);
set->m_nSkyBottomBlue = uint16((float)set->m_nSkyBottomBlue * invboxf + (float)m_nSkyBottomBlue[boxHour][boxWeather] * boxf);
set->m_fWaterRed *= invboxf + (float)m_fWaterRed[boxHour][boxWeather] * boxf;
set->m_fWaterGreen *= invboxf + (float)m_fWaterGreen[boxHour][boxWeather] * boxf;
set->m_fWaterBlue *= invboxf + (float)m_fWaterBlue[boxHour][boxWeather] * boxf;
set->m_fWaterAlpha *= invboxf + (float)m_fWaterAlpha[boxHour][boxWeather] * boxf;
set->m_fAmbientRed *= invboxf + (float)m_nAmbientRed[boxHour][boxWeather] * boxf;
set->m_fAmbientGreen *= invboxf + (float)m_nAmbientGreen[boxHour][boxWeather] * boxf;
set->m_fAmbientBlue *= invboxf + (float)m_nAmbientBlue[boxHour][boxWeather] * boxf;
set->m_fAmbientRed_Obj *= invboxf + (float)m_nAmbientRed_Obj[boxHour][boxWeather] * boxf;
set->m_fAmbientGreen_Obj *= invboxf + (float)m_nAmbientGreen_Obj[boxHour][boxWeather] * boxf;
set->m_fAmbientBlue_Obj *= invboxf + (float)m_nAmbientBlue_Obj[boxHour][boxWeather] * boxf;
if ((float)m_fFarClip[boxHour][boxWeather] < set->m_fFarClip) {
set->m_fFarClip = set->m_fFarClip * invboxf + (float)m_fFarClip[boxHour][boxWeather] * boxf;
if (m_nSkyBottomRed[boxHour][boxWeather] != 255) { // 0x560B6A
set->m_nSkyBottomRed = (uint16)(lerp<float>(set->m_nSkyBottomRed, m_nSkyBottomRed[boxHour][boxWeather], boxf));
set->m_nSkyBottomGreen = (uint16)(lerp<float>(set->m_nSkyBottomGreen, m_nSkyBottomGreen[boxHour][boxWeather], boxf));
set->m_nSkyBottomBlue = (uint16)(lerp<float>(set->m_nSkyBottomBlue, m_nSkyBottomBlue[boxHour][boxWeather], boxf));
}
if (m_fWaterRed[boxHour][boxWeather] != 255) { // 0x560BED
set->m_fWaterRed = lerp<float>(set->m_fWaterRed, m_fWaterRed[boxHour][boxWeather], boxf);
set->m_fWaterGreen = lerp<float>(set->m_fWaterGreen, m_fWaterGreen[boxHour][boxWeather], boxf);
set->m_fWaterBlue = lerp<float>(set->m_fWaterBlue, m_fWaterBlue[boxHour][boxWeather], boxf);
set->m_fWaterAlpha = lerp<float>(set->m_fWaterAlpha, m_fWaterAlpha[boxHour][boxWeather], boxf);
}
if (m_nAmbientRed[boxHour][boxWeather] != 255) { // 0x560C5E
set->m_fAmbientRed = lerp<float>(set->m_fAmbientRed, m_nAmbientRed[boxHour][boxWeather], boxf);
set->m_fAmbientGreen = lerp<float>(set->m_fAmbientGreen, m_nAmbientGreen[boxHour][boxWeather], boxf);
set->m_fAmbientBlue = lerp<float>(set->m_fAmbientBlue, m_nAmbientBlue[boxHour][boxWeather], boxf);
}
if (m_nAmbientRed_Obj[boxHour][boxWeather] != 255) { // 0x560CB2
set->m_fAmbientRed_Obj = lerp<float>(set->m_fAmbientRed_Obj, m_nAmbientRed_Obj[boxHour][boxWeather], boxf);
set->m_fAmbientGreen_Obj = lerp<float>(set->m_fAmbientGreen_Obj, m_nAmbientGreen_Obj[boxHour][boxWeather], boxf);
set->m_fAmbientBlue_Obj = lerp<float>(set->m_fAmbientBlue_Obj, m_nAmbientBlue_Obj[boxHour][boxWeather], boxf);
}
if (m_fFarClip[boxHour][boxWeather] != 255) { // 0x560D08
if ((float)m_fFarClip[boxHour][boxWeather] < set->m_fFarClip) {
set->m_fFarClip = set->m_fFarClip * invboxf + (float)m_fFarClip[boxHour][boxWeather] * boxf;
}
}
if (m_fFogStart[boxHour][boxWeather] != 255) { // 0x560D3E
set->m_fFogStart = lerp(set->m_fFogStart, (float)m_fFogStart[boxHour][boxWeather], boxf);
}
if (m_fPostFx1Red[boxHour][boxWeather] != 255) { // 0x560D63
set->m_fPostFx1Red = lerp(set->m_fPostFx1Red, (float)(m_fPostFx1Red[boxHour][boxWeather]), boxf);
set->m_fPostFx1Green = lerp(set->m_fPostFx1Green, (float)(m_fPostFx1Green[boxHour][boxWeather]), boxf);
set->m_fPostFx1Blue = lerp(set->m_fPostFx1Blue, (float)(m_fPostFx1Blue[boxHour][boxWeather]), boxf);
set->m_fPostFx1Alpha = lerp(set->m_fPostFx1Alpha, (float)(m_fPostFx1Alpha[boxHour][boxWeather]), boxf);
}
if (m_fPostFx2Red[boxHour][boxWeather] != 255) { // 0x560DE0
set->m_fPostFx2Red = lerp(set->m_fPostFx2Red, (float)(m_fPostFx2Red[boxHour][boxWeather]), boxf);
set->m_fPostFx2Green = lerp(set->m_fPostFx2Green, (float)(m_fPostFx2Green[boxHour][boxWeather]), boxf);
set->m_fPostFx2Blue = lerp(set->m_fPostFx2Blue, (float)(m_fPostFx2Blue[boxHour][boxWeather]), boxf);
set->m_fPostFx2Alpha = lerp(set->m_fPostFx2Alpha, (float)(m_fPostFx2Alpha[boxHour][boxWeather]), boxf);
}
set->m_fFogStart *= invboxf + (float)m_fFogStart[boxHour][boxWeather] * boxf;
set->m_fPostFx1Red *= invboxf + (float)m_fPostFx1Red[boxHour][boxWeather] * boxf;
set->m_fPostFx1Green *= invboxf + (float)m_fPostFx1Green[boxHour][boxWeather] * boxf;
set->m_fPostFx1Blue *= invboxf + (float)m_fPostFx1Blue[boxHour][boxWeather] * boxf;
set->m_fPostFx1Alpha *= invboxf + (float)m_fPostFx1Alpha[boxHour][boxWeather] * boxf;
set->m_fPostFx2Red *= invboxf + (float)m_fPostFx2Red[boxHour][boxWeather] * boxf;
set->m_fPostFx2Green *= invboxf + (float)m_fPostFx2Green[boxHour][boxWeather] * boxf;
set->m_fPostFx2Blue *= invboxf + (float)m_fPostFx2Blue[boxHour][boxWeather] * boxf;
set->m_fPostFx2Alpha *= invboxf + (float)m_fPostFx2Alpha[boxHour][boxWeather] * boxf;
}
if (lodBox) {
set->m_fLodDistMult *= (1.0f - lodBoxInterp) + (float)lodBox->m_LodDistMult / 32.0f * lodBoxInterp;
if (lodBoxA) {
set->m_fLodDistMult *= (1.0f - lodBoxA_T) + (float)lodBoxA->LodDistMult / 32.0f * lodBoxA_T;
}
if (farBox1 && (float)farBox1->m_FarClip < set->m_fFarClip) {
set->m_fFarClip = set->m_fFarClip * (1.0f - farBox1Interp) + (float)farBox1->m_FarClip * farBox1Interp;
if (farBoxA && (float)farBoxA->FarClip < set->m_fFarClip) {
set->m_fFarClip = set->m_fFarClip * (1.0f - farBoxA_T) + (float)farBoxA->FarClip * farBoxA_T;
}
if (farBox2 && (float)farBox2->m_FarClip < set->m_fFarClip) {
set->m_fFarClip = set->m_fFarClip * (1.0f - farBox2Interp) + (float)farBox2->m_FarClip * farBox2Interp;
if (farBoxB && (float)farBoxB->FarClip < set->m_fFarClip) {
set->m_fFarClip = set->m_fFarClip * (1.0f - farBoxB_T) + (float)farBoxB->FarClip * farBoxB_T;
}
float inc = CTimer::GetTimeStep() / 120.0f;
@ -389,10 +422,10 @@ void CTimeCycle::CalcColoursForPoint(CVector point, CColourSet* set) {
}
if (CWeather::UnderWaterness > 0.0f) {
CColourSet current(curHourSel, 20);
CColourSet next(nextHourSel, 20);
CColourSet current(currSampleIdx, 20);
CColourSet next(nextSampleIdx, 20);
CColourSet tmp{};
tmp.Interpolate(&current, &next, invTimeInterp, timeInterp, false);
tmp.Interpolate(&current, &next, invTimeT, timeT, false);
set->Interpolate(set, &tmp, 1.0f - CWeather::UnderWaterness, CWeather::UnderWaterness, false);
}
@ -412,22 +445,17 @@ void CTimeCycle::CalcColoursForPoint(CVector point, CColourSet* set) {
// 0x5612AA
CShadows::CalcPedShadowValues(
m_VectorToSun[m_CurrentStoredValue],
m_fShadowDisplacementX[m_CurrentStoredValue], m_fShadowDisplacementY[m_CurrentStoredValue],
m_fShadowFrontX[m_CurrentStoredValue], m_fShadowFrontY[m_CurrentStoredValue],
m_fShadowSideX[m_CurrentStoredValue], m_fShadowSideY[m_CurrentStoredValue]
m_fShadowSideX[m_CurrentStoredValue], m_fShadowSideY[m_CurrentStoredValue],
m_fShadowDisplacementX[m_CurrentStoredValue], m_fShadowDisplacementY[m_CurrentStoredValue]
);
if (TheCamera.m_mCameraMatrix.GetForward().z < -0.9f
|| !CWeather::bScriptsForceRain
&& (CCullZones::PlayerNoRain() || CCullZones::CamNoRain() || CCutsceneMgr::ms_running)
if ( TheCamera.m_mCameraMatrix.GetForward().z < -0.9f
|| !CWeather::bScriptsForceRain && (CCullZones::PlayerNoRain() || CCullZones::CamNoRain() || CCutsceneMgr::ms_running)
) {
m_FogReduction++;
if (m_FogReduction > 64)
m_FogReduction = 64;
m_FogReduction = std::min(m_FogReduction + 1, 64);
} else {
m_FogReduction--;
if (m_FogReduction < 0)
m_FogReduction = 0;
m_FogReduction = std::max(m_FogReduction - 1, 0);
}
if (camPos.z > 200.0f) {
@ -441,7 +469,7 @@ void CTimeCycle::CalcColoursForPoint(CVector point, CColourSet* set) {
}
}
float horizon = (float)gTimecycleStartHours[curHourSel] * invTimeInterp + (float)gTimecycleStartHours[nextHourSel] * timeInterp;
float horizon = (float)GreyValuesDuringDay[currSampleIdx] * invTimeT + (float)GreyValuesDuringDay[nextSampleIdx] * timeT;
m_BelowHorizonGrey.red = uint8((float)m_CurrentColours.m_nSkyBottomRed * CWeather::UnderWaterness + horizon * (1.0f - CWeather::UnderWaterness));
m_BelowHorizonGrey.green = uint8((float)m_CurrentColours.m_nSkyBottomGreen * CWeather::UnderWaterness + horizon * (1.0f - CWeather::UnderWaterness));
m_BelowHorizonGrey.blue = uint8((float)m_CurrentColours.m_nSkyBottomBlue * CWeather::UnderWaterness + horizon * (1.0f - CWeather::UnderWaterness));
@ -529,14 +557,49 @@ float CTimeCycle::FindFarClipForCoors(CVector cameraPos) {
}
// 0x55FFD0
void CTimeCycle::FindTimeCycleBox(CVector pos, CTimeCycleBox** outBox, float* interpolation, bool bCheckLod, bool bCheckFar, CTimeCycleBox* exclude) {
return plugin::Call<0x55FFD0, CVector, CTimeCycleBox**, float*, bool, bool, CTimeCycleBox*>(pos, outBox, interpolation, bCheckLod, bCheckFar, exclude);
*outBox = nullptr;
void CTimeCycle::FindTimeCycleBox(
CVector pos,
CTimeCycleBox** curr,
float* interpolation,
bool isLOD,
bool isFarClip,
CTimeCycleBox* ignored
) {
*curr = nullptr;
*interpolation = 0.0f;
for (auto& box : std::span{ m_aBoxes, m_NumBoxes }) {
for (auto& v : std::span{ m_aBoxes, m_NumBoxes }) {
if (isLOD && v.LodDistMult == 32.f) { // 0x560013
continue;
}
if (isFarClip && !v.FarClip) { // 0x560038
continue;
}
if (ignored == &v) {
continue;
}
// Check if the point is at least within the `FallOff`
const auto CheckPointWithin = [&](int32 i, float tolerance) {
return v.Box.m_vecMin[i] - tolerance > pos[i] || v.Box.m_vecMax[i] + tolerance < pos[i];
};
if (CheckPointWithin(0, v.Falloff) || CheckPointWithin(1, v.Falloff) || CheckPointWithin(2, v.Falloff / 3.f)) {
continue;
}
// Calculate the distance to the box and interpolation
const auto vdist = v.Box.GetShortestVectorDistToPt(pos); // 0x5600EC
const auto dist = CVector{ vdist.x, vdist.y, vdist.z * 3.f }.Magnitude(); // 0x560188
if (dist > 0.f) { // Point not inside the box, but within `FallOff`
const auto t = 1.f - dist / v.Falloff;
if (t > *interpolation) {
*curr = &v;
*interpolation = t;
}
} else { // Point inside the box
*curr = &v;
*interpolation = 1.f;
}
}
}

View File

@ -8,12 +8,12 @@ class CBox;
class CTimeCycleBox {
public:
CBox m_Box;
int16 m_FarClip;
uint8 m_LodDistMult;
int32 m_ExtraColor;
float m_Strength;
float m_Falloff;
CBox Box;
int16 FarClip;
uint8 LodDistMult;
int32 ExtraColor;
float Strength;
float Falloff;
};
VALIDATE_SIZE(CTimeCycleBox, 0x28);
@ -23,6 +23,7 @@ class CTimeCycle {
public:
static constexpr auto NUM_HOURS = 8;
static inline CVector& m_vecDirnLightToSun = *(CVector*)0xB7CB14;
static inline RwRGBA& m_BelowHorizonGrey = *(RwRGBA*)0xB7CB10;
static inline CVector (&m_VectorToSun)[16] = *(CVector(*)[16])0xB7CA50;
@ -33,78 +34,73 @@ public:
static inline uint32& m_bExtraColourOn = *(uint32*)0xB7C484;
static inline CColourSet& m_CurrentColours = *(CColourSet*)0xB7C4A0;
static inline float& m_fCurrentRGB1Red = *(float*)0xB7C518;
static inline float& m_fCurrentRGB1Green = *(float*)0xB7C51C;
static inline float& m_fCurrentRGB1Blue = *(float*)0xB7C520;
template<typename T>
using Colors = notsa::mdarray<T, NUM_HOURS, NUM_WEATHERS>;
static inline float& m_fCurrentRGB2Red = *(float*)0xB7C528;
static inline float& m_fCurrentRGB2Green = *(float*)0xB7C52C;
static inline float& m_fCurrentRGB2Blue = *(float*)0xB7C530;
static inline auto& m_nAmbientRed = StaticRef<Colors<uint8>>(0xB7C3C8);
static inline auto& m_nAmbientGreen = StaticRef<Colors<uint8>>(0xB7C310);
static inline auto& m_nAmbientBlue = StaticRef<Colors<uint8>>(0xB7C258);
static inline uint8 (&m_nAmbientRed)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7C3C8;
static inline uint8 (&m_nAmbientGreen)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7C310;
static inline uint8 (&m_nAmbientBlue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7C258;
static inline auto& m_nAmbientRed_Obj = StaticRef<Colors<uint8>>(0xB7C1A0);
static inline auto& m_nAmbientGreen_Obj = StaticRef<Colors<uint8>>(0xB7C0E8);
static inline auto& m_nAmbientBlue_Obj = StaticRef<Colors<uint8>>(0xB7C030);
static inline uint8 (&m_nAmbientRed_Obj)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7C1A0;
static inline uint8 (&m_nAmbientGreen_Obj)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7C0E8;
static inline uint8 (&m_nAmbientBlue_Obj)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7C030;
static inline auto& m_nSkyTopRed = StaticRef<Colors<uint8>>(0xB7BF78);
static inline auto& m_nSkyTopGreen = StaticRef<Colors<uint8>>(0xB7BEC0);
static inline auto& m_nSkyTopBlue = StaticRef<Colors<uint8>>(0xB7BE08);
static inline uint8 (&m_nSkyTopRed)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7BF78;
static inline uint8 (&m_nSkyTopGreen)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7BEC0;
static inline uint8 (&m_nSkyTopBlue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7BE08;
static inline auto& m_nSkyBottomRed = StaticRef<Colors<uint8>>(0xB7BD50);
static inline auto& m_nSkyBottomGreen = StaticRef<Colors<uint8>>(0xB7BC98);
static inline auto& m_nSkyBottomBlue = StaticRef<Colors<uint8>>(0xB7BBE0);
static inline uint8 (&m_nSkyBottomRed)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7BD50;
static inline uint8 (&m_nSkyBottomGreen)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7BC98;
static inline uint8 (&m_nSkyBottomBlue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7BBE0;
static inline auto& m_fSunSize = StaticRef<Colors<uint8>>(0xB7B6D8);
static inline uint8 (&m_fSunSize)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B6D8;
static inline auto& m_nSunCoronaRed = StaticRef<Colors<uint8>>(0xB7B900);
static inline auto& m_nSunCoronaGreen = StaticRef<Colors<uint8>>(0xB7B848);
static inline auto& m_nSunCoronaBlue = StaticRef<Colors<uint8>>(0xB7B790);
static inline uint8 (&m_nSunCoronaRed)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B900;
static inline uint8 (&m_nSunCoronaGreen)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B848;
static inline uint8 (&m_nSunCoronaBlue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B790;
static inline auto& m_nSunCoreRed = StaticRef<Colors<uint8>>(0xB7BB28);
static inline auto& m_nSunCoreGreen = StaticRef<Colors<uint8>>(0xB7BA70);
static inline auto& m_nSunCoreBlue = StaticRef<Colors<uint8>>(0xB7B9B8);
static inline uint8 (&m_nSunCoreRed)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7BB28;
static inline uint8 (&m_nSunCoreGreen)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7BA70;
static inline uint8 (&m_nSunCoreBlue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B9B8;
static inline auto& m_fFarClip = StaticRef<Colors<uint16>>(0xB7B1D0);
static inline auto& m_fFogStart = StaticRef<Colors<uint16>>(0xB7B060);
static inline auto& m_fLightsOnGroundBrightness = StaticRef<Colors<uint8>>(0xB7AFA8);
static inline uint16 (&m_fFarClip)[NUM_HOURS][NUM_WEATHERS] = *(uint16(*)[NUM_HOURS][NUM_WEATHERS])0xB7B1D0;
static inline uint16 (&m_fFogStart)[NUM_HOURS][NUM_WEATHERS] = *(uint16(*)[NUM_HOURS][NUM_WEATHERS])0xB7B060;
static inline uint8 (&m_fLightsOnGroundBrightness)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7AFA8;
static inline auto& m_nShadowStrength = StaticRef<Colors<uint8>>(0xB7B4B0);
static inline auto& m_nLightShadowStrength = StaticRef<Colors<uint8>>(0xB7B3F8);
static inline auto& m_nPoleShadowStrength = StaticRef<Colors<uint8>>(0xB7B340);
static inline uint8 (&m_nShadowStrength)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B4B0;
static inline uint8 (&m_nLightShadowStrength)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B3F8;
static inline uint8 (&m_nPoleShadowStrength)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B340;
static inline auto& m_fSpriteSize = StaticRef<Colors<uint8>>(0xB7B620);
static inline auto& m_fSpriteBrightness = StaticRef<Colors<uint8>>(0xB7B568);
static inline uint8 (&m_fSpriteSize)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B620;
static inline uint8 (&m_fSpriteBrightness)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7B568;
static inline auto& m_nLowCloudsRed = StaticRef<Colors<uint8>>(0xB7AEF0);
static inline auto& m_nLowCloudsGreen = StaticRef<Colors<uint8>>(0xB7AE38);
static inline auto& m_nLowCloudsBlue = StaticRef<Colors<uint8>>(0xB7AD80);
static inline uint8 (&m_nLowCloudsRed)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7AEF0;
static inline uint8 (&m_nLowCloudsGreen)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7AE38;
static inline uint8 (&m_nLowCloudsBlue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7AD80;
static inline auto& m_nFluffyCloudsBottomRed = StaticRef<Colors<uint8>>(0xB7ACC8);
static inline auto& m_nFluffyCloudsBottomGreen = StaticRef<Colors<uint8>>(0xB7AC10);
static inline auto& m_nFluffyCloudsBottomBlue = StaticRef<Colors<uint8>>(0xB7AB58);
static inline uint8 (&m_nFluffyCloudsBottomRed)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7ACC8;
static inline uint8 (&m_nFluffyCloudsBottomGreen)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7AC10;
static inline uint8 (&m_nFluffyCloudsBottomBlue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7AB58;
static inline auto& m_fWaterRed = StaticRef<Colors<uint8>>(0xB7AAA0);
static inline auto& m_fWaterGreen = StaticRef<Colors<uint8>>(0xB7A9E8);
static inline auto& m_fWaterBlue = StaticRef<Colors<uint8>>(0xB7A930);
static inline auto& m_fWaterAlpha = StaticRef<Colors<uint8>>(0xB7A878);
static inline uint8 (&m_fWaterRed)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7AAA0;
static inline uint8 (&m_fWaterGreen)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A9E8;
static inline uint8 (&m_fWaterBlue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A930;
static inline uint8 (&m_fWaterAlpha)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A878;
static inline auto& m_fPostFx1Red = StaticRef<Colors<uint8>>(0xB7A7C0);
static inline auto& m_fPostFx1Green = StaticRef<Colors<uint8>>(0xB7A708);
static inline auto& m_fPostFx1Blue = StaticRef<Colors<uint8>>(0xB7A650);
static inline auto& m_fPostFx1Alpha = StaticRef<Colors<uint8>>(0xB7A598);
static inline uint8 (&m_fPostFx1Red)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A7C0;
static inline uint8 (&m_fPostFx1Green)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A708;
static inline uint8 (&m_fPostFx1Blue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A650;
static inline uint8 (&m_fPostFx1Alpha)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A598;
static inline auto& m_fPostFx2Red = StaticRef<Colors<uint8>>(0xB7A4E0);
static inline auto& m_fPostFx2Green = StaticRef<Colors<uint8>>(0xB7A428);
static inline auto& m_fPostFx2Blue = StaticRef<Colors<uint8>>(0xB7A370);
static inline auto& m_fPostFx2Alpha = StaticRef<Colors<uint8>>(0xB7A2B8);
static inline uint8 (&m_fPostFx2Red)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A4E0;
static inline uint8 (&m_fPostFx2Green)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A428;
static inline uint8 (&m_fPostFx2Blue)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A370;
static inline uint8 (&m_fPostFx2Alpha)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A2B8;
static inline uint8 (&m_fCloudAlpha)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A200;
static inline uint8 (&m_nHighLightMinIntensity)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A148;
static inline uint8 (&m_nWaterFogAlpha)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB7A090;
static inline uint8 (&m_nDirectionalMult)[NUM_HOURS][NUM_WEATHERS] = *(uint8(*)[NUM_HOURS][NUM_WEATHERS])0xB79FD8;
static inline auto& m_fCloudAlpha = StaticRef<Colors<uint8>>(0xB7A200);
static inline auto& m_nHighLightMinIntensity = StaticRef<Colors<uint8>>(0xB7A148);
static inline auto& m_nWaterFogAlpha = StaticRef<Colors<uint8>>(0xB7A090);
static inline auto& m_nDirectionalMult = StaticRef<Colors<uint8>>(0xB79FD8);
static inline int32& m_CurrentStoredValue = *(int32*)0xB79FD0;
@ -142,7 +138,14 @@ public:
static void AddOne(CBox& box, int16 farClip, int32 extraColor, float strength, float falloff, float lodDistMult);
static void CalcColoursForPoint(CVector point, CColourSet* set);
static float FindFarClipForCoors(CVector cameraPos);
static void FindTimeCycleBox(CVector pos, CTimeCycleBox** outBox, float* interpolation, bool bCheckLod, bool bCheckFar, CTimeCycleBox* exclude);
static void FindTimeCycleBox(
CVector pos,
CTimeCycleBox** out,
float* currentBox,
bool isLOD,
bool isFarClip,
CTimeCycleBox* alreadyFoundBox
);
static void SetConstantParametersForPostFX();
static float GetAmbientRed() { return gfLaRiotsLightMult * m_CurrentColours.m_fAmbientRed; } // 0x560330
@ -163,8 +166,8 @@ public: // NOTSA
static auto GetPostFxColors() { return std::make_pair(m_CurrentColours.GetPostFx1(), m_CurrentColours.GetPostFx2()); }
static float SumOfCurrentRGB1() { return m_fCurrentRGB1Blue + m_fCurrentRGB1Green + m_fCurrentRGB1Red; }
static float SumOfCurrentRGB2() { return m_fCurrentRGB2Blue + m_fCurrentRGB2Green + m_fCurrentRGB2Red; }
static float SumOfCurrentRGB1() { return m_CurrentColours.m_fPostFx1Blue + m_CurrentColours.m_fPostFx1Green + m_CurrentColours.m_fPostFx1Red; }
static float SumOfCurrentRGB2() { return m_CurrentColours.m_fPostFx2Blue + m_CurrentColours.m_fPostFx2Green + m_CurrentColours.m_fPostFx2Red; }
static auto GetBoxes() { return std::span{ m_aBoxes, m_NumBoxes}; }
static bool ShouldIgnoreSky() {

View File

@ -75,16 +75,16 @@ void TimeCycleDebugModule::RenderWindow() {
}
ImGui::NewLine();
if (ImGui::ColorEdit3("Current RGB 1", (float*)&m_CurrentRGB1)) {
CTimeCycle::m_fCurrentRGB1Red = m_CurrentRGB1.r * 255.0f;
CTimeCycle::m_fCurrentRGB1Green = m_CurrentRGB1.g * 255.0f;
CTimeCycle::m_fCurrentRGB1Blue = m_CurrentRGB1.b * 255.0f;
if (ImGui::ColorEdit3("Post Fx 1", (float*)&m_PostFx1)) {
CTimeCycle::m_CurrentColours.m_fPostFx1Red = m_PostFx1.r * 255.0f;
CTimeCycle::m_CurrentColours.m_fPostFx1Green = m_PostFx1.g * 255.0f;
CTimeCycle::m_CurrentColours.m_fPostFx1Blue = m_PostFx1.b * 255.0f;
}
if (ImGui::ColorEdit3("Current RGB 2", (float*)&m_CurrentRGB2)) {
CTimeCycle::m_fCurrentRGB2Red = m_CurrentRGB2.r * 255.0f;
CTimeCycle::m_fCurrentRGB2Green = m_CurrentRGB2.r * 255.0f;
CTimeCycle::m_fCurrentRGB2Blue = m_CurrentRGB2.r * 255.0f;
if (ImGui::ColorEdit3("Post Fx 2", (float*)&m_PostFx2)) {
CTimeCycle::m_CurrentColours.m_fPostFx2Red = m_PostFx2.r * 255.0f;
CTimeCycle::m_CurrentColours.m_fPostFx2Green = m_PostFx2.g * 255.0f;
CTimeCycle::m_CurrentColours.m_fPostFx2Blue = m_PostFx2.b * 255.0f;
}
ImGui::NewLine();
@ -267,25 +267,25 @@ void TimeCycleDebugModule::RenderBoxesGUI() {
for (auto& box : CTimeCycle::GetBoxes()) {
ImGui::PushID(&box);
const auto& boxCenter = box.m_Box.GetCenter();
const auto& boxCenter = box.Box.GetCenter();
ImGui::TableNextColumn();
ImGui::Text("%s", CTheZones::FindSmallestZoneForPosition(boxCenter, false)->GetTranslatedName());
ImGui::TableNextColumn();
ImGui::Text("%d", box.m_FarClip);
ImGui::Text("%d", box.FarClip);
ImGui::TableNextColumn();
ImGui::Text("%d", box.m_LodDistMult);
ImGui::Text("%d", box.LodDistMult);
ImGui::TableNextColumn();
ImGui::Text("%d", box.m_ExtraColor);
ImGui::Text("%d", box.ExtraColor);
ImGui::TableNextColumn();
ImGui::Text("%f", box.m_Strength);
ImGui::Text("%f", box.Strength);
ImGui::TableNextColumn();
ImGui::Text("%f", box.m_Falloff);
ImGui::Text("%f", box.Falloff);
ImGui::TableNextColumn();
if (bool selected = false; ImGui::Selectable("Teleport", &selected, ImGuiSelectableFlags_SpanAllColumns)) {
@ -305,7 +305,7 @@ void TimeCycleDebugModule::Render3D() {
}
for (auto& box : CTimeCycle::GetBoxes()) {
box.m_Box.DrawWireFrame({ 255, 0, 0, 255 }, CMatrix::Unity());
box.Box.DrawWireFrame({ 255, 0, 0, 255 }, CMatrix::Unity());
}
}
@ -317,13 +317,13 @@ void TimeCycleDebugModule::SyncFromGame() {
m_Hours = CClock::ms_nGameClockHours;
m_Minutes = CClock::ms_nGameClockMinutes;
m_CurrentRGB1.r = ColorF32(CTimeCycle::m_fCurrentRGB1Red);
m_CurrentRGB1.g = ColorF32(CTimeCycle::m_fCurrentRGB1Green);
m_CurrentRGB1.b = ColorF32(CTimeCycle::m_fCurrentRGB1Blue);
m_PostFx1.r = ColorF32(CTimeCycle::m_CurrentColours.m_fPostFx1Red);
m_PostFx1.g = ColorF32(CTimeCycle::m_CurrentColours.m_fPostFx1Green);
m_PostFx1.b = ColorF32(CTimeCycle::m_CurrentColours.m_fPostFx1Blue);
m_CurrentRGB2.r = ColorF32(CTimeCycle::m_fCurrentRGB2Red);
m_CurrentRGB2.g = ColorF32(CTimeCycle::m_fCurrentRGB2Green);
m_CurrentRGB2.b = ColorF32(CTimeCycle::m_fCurrentRGB2Blue);
m_PostFx2.r = ColorF32(CTimeCycle::m_CurrentColours.m_fPostFx2Red);
m_PostFx2.g = ColorF32(CTimeCycle::m_CurrentColours.m_fPostFx2Green);
m_PostFx2.b = ColorF32(CTimeCycle::m_CurrentColours.m_fPostFx2Blue);
m_AmbRGB.r = ColorF32(CTimeCycle::m_nAmbientRed[m_TimeId][m_WeatherId]);
m_AmbRGB.g = ColorF32(CTimeCycle::m_nAmbientGreen[m_TimeId][m_WeatherId]);

View File

@ -28,8 +28,8 @@ private:
int m_NewWeatherType{};
int m_Hours{};
int m_Minutes{};
Color3 m_CurrentRGB1{};
Color3 m_CurrentRGB2{};
Color3 m_PostFx1{};
Color3 m_PostFx2{};
Color3 m_AmbRGB{};
Color3 m_AmbObjRGB{};
Color3 m_SkyTopRGB{};