Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Deamon87 committed Jul 6, 2024
1 parent 5b843e4 commit 85b62d6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
12 changes: 8 additions & 4 deletions src/database/CSqliteDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ SQLite::Column CSqliteDB::StatementFieldHolder::getField(const HashedString fiel


const std::string getMapListSQL =
"select m.ID, m.Directory, m.MapName_lang, m.WdtFileDataID, m.MapType, m.TimeOfDayOverride, m.Flags_0 from Map m where m.WdtFileDataID > 0";
"select m.ID, m.Directory, m.MapName_lang, m.WdtFileDataID, m.MapType, m.TimeOfDayOverride, m.Flags_0, m.Flags_1, m.Flags_2 from Map m where m.WdtFileDataID > 0";

const std::string getMapListSQL_classic =
"select m.ID, m.Directory, m.MapName_lang, m.MapType, m.TimeOfDayOverride, m.Flags_0 from Map m";
"select m.ID, m.Directory, m.MapName_lang, m.MapType, m.TimeOfDayOverride, m.Flags_0, m.Flags_1, m.Flags_2 from Map m";

const std::string getMapByIDSQL =
"select m.ID, m.Directory, m.MapName_lang, m.WdtFileDataID, m.MapType, m.TimeOfDayOverride, m.Flags_0 from Map m where m.ID = ?";
"select m.ID, m.Directory, m.MapName_lang, m.WdtFileDataID, m.MapType, m.TimeOfDayOverride, m.Flags_0, m.Flags_1, m.Flags_2 from Map m where m.ID = ?";

const std::string getMapByIDSQL_classic =
"select m.ID, m.Directory, m.MapName_lang, m.MapType, m.TimeOfDayOverride, m.Flags_0 from Map m where m.ID = ?";
"select m.ID, m.Directory, m.MapName_lang, m.MapType, m.TimeOfDayOverride, m.Flags_0, m.Flags_1, m.Flags_2 from Map m where m.ID = ?";

const std::string getWmoAreaAreaNameSQL = R"===(
select wat.AreaName_lang as wmoAreaName, at.AreaName_lang as areaName, at.ID as ID, at.ParentAreaID as ParentAreaID, at.Ambient_multiplier as Ambient_multiplier from WMOAreaTable wat
Expand Down Expand Up @@ -182,6 +182,8 @@ void CSqliteDB::getMapArray(std::vector<MapRecord> &mapRecords) {
mapRecord.MapType = getMapList.getField("MapType").getInt();
mapRecord.overrideTime = getMapList.getField("TimeOfDayOverride").getInt();
mapRecord.flags0 = getMapList.getField("Flags_0").getInt();
mapRecord.flags1 = getMapList.getField("Flags_1").getInt();
mapRecord.flags2 = getMapList.getField("Flags_2").getInt();
}
}
Expand All @@ -205,6 +207,8 @@ bool CSqliteDB::getMapById(int mapId, MapRecord &mapRecord) {
mapRecord.MapType = getMapByIdStatement.getField("MapType").getInt();
mapRecord.overrideTime = getMapByIdStatement.getField("TimeOfDayOverride").getInt();
mapRecord.flags0 = getMapByIdStatement.getField("Flags_0").getInt();
mapRecord.flags1 = getMapByIdStatement.getField("Flags_1").getInt();
mapRecord.flags2 = getMapByIdStatement.getField("Flags_2").getInt();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ DayNightLightHolder::DayNightLightHolder(const HApiContainer &api, int mapId) :

MapRecord mapRecord;
api->databaseHandler->getMapById(mapId, mapRecord);
m_mapFlag2_0x2 = (mapRecord.flags2 & 0x2) > 0;
m_useWeightedBlend = (mapRecord.flags0 & 0x4) > 0;
m_mapHasFlag_0x200000 = (mapRecord.flags0 & 0x200000) > 0;
m_mapHasFlag_0x10000 = (mapRecord.flags0 & 0x10000) > 0;
Expand Down Expand Up @@ -56,6 +57,19 @@ void DayNightLightHolder::loadZoneLights() {
}
}


static inline mathfu::vec4 mix(const mathfu::vec4 &a, const mathfu::vec4 &b, float alpha) {
return (b - a) * alpha + a;
}
static inline mathfu::vec3 mix(const mathfu::vec3 &a, const mathfu::vec3 &b, float alpha) {
return (b - a) * alpha + a;
}
static inline float mix(const float &a, const float &b, float alpha) {
return (b - a) * alpha + a;
}



void DayNightLightHolder::updateLightAndSkyboxData(const HMapRenderPlan &mapRenderPlan,
MathHelper::FrustumCullingData &frustumData,
StateForConditions &stateForConditions,
Expand Down Expand Up @@ -347,17 +361,6 @@ void DayNightLightHolder::updateLightAndSkyboxData(const HMapRenderPlan &mapRend
}
}


static inline mathfu::vec4 mix(const mathfu::vec4 &a, const mathfu::vec4 &b, float alpha) {
return (b - a) * alpha + a;
}
static inline mathfu::vec3 mix(const mathfu::vec3 &a, const mathfu::vec3 &b, float alpha) {
return (b - a) * alpha + a;
}
static inline float mix(const float &a, const float &b, float alpha) {
return (b - a) * alpha + a;
}

template <int T>
inline float getFloatFromInt(int value) {
if constexpr (T == 0) {
Expand Down Expand Up @@ -653,7 +656,7 @@ void DayNightLightHolder::getLightResultsFromDB(mathfu::vec3 &cameraVec3, const
fogResult.FogStartOffset = mixMembers<1>(lightParamData, &LightTimedData::FogStartOffset, blendTimeCoeff);

if (fogResult.FogHeightCoefficients.LengthSquared() <= 0.00000011920929f ){
//TODO:
fogResult.FogHeightCoefficients = mathfu::vec4(0,0,1,0);
}

if (
Expand All @@ -666,7 +669,7 @@ void DayNightLightHolder::getLightResultsFromDB(mathfu::vec3 &cameraVec3, const
}

fogResult.FogDensity = fmaxf(fogResult.FogDensity, 0.89999998f);
if ( m_useWeightedBlend )
if ( m_mapFlag2_0x2 )
{
fogResult.FogDensity = 1.0f;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DayNightLightHolder {
StateForConditions *stateForConditions);

private:
bool m_mapFlag2_0x2 = false;
bool m_useWeightedBlend = false;
bool m_mapHasFlag_0x200000 = false;
bool m_mapHasFlag_0x10000 = false;
Expand Down
2 changes: 2 additions & 0 deletions wowViewerLib/src/include/database/dbStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct MapRecord {
int MapType;
int overrideTime;
uint32_t flags0;
uint32_t flags1;
uint32_t flags2;
};

struct LightResult {
Expand Down
2 changes: 1 addition & 1 deletion wowViewerLib/src/renderer/mapScene/MapSceneRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void MapSceneRenderer::updateSceneWideChunk(const std::shared_ptr<IBufferChunkVe
1000.0f
);
fogData.sunPercentage = mathfu::vec4(
fogResult.SunFogAngle * fogResult.SunFogStrength,
fogResult.SunAngleBlend * fogResult.SunFogStrength,
0, 1.0, 1.0);
fogData.sunDirection_and_fogZScalar = mathfu::vec4(
fdd->exteriorDirectColorDir, //TODO: for fog this is calculated from SUN position
Expand Down

0 comments on commit 85b62d6

Please sign in to comment.