Skip to content

Commit

Permalink
Merge branch 'exorcisingtoddfrommyoblivioncopy' into 'master'
Browse files Browse the repository at this point in the history
Support ESM4::Light with no spotlight data again

See merge request OpenMW/openmw!4465
  • Loading branch information
psi29a committed Nov 25, 2024
2 parents b555c98 + ec564b1 commit 690de3c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
34 changes: 20 additions & 14 deletions components/esm4/loadligh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ void ESM4::Light::load(ESM4::Reader& reader)
break;
case ESM::fourCC("DATA"):
{
if (subHdr.dataSize != 32 && subHdr.dataSize != 48 && subHdr.dataSize != 64)
// 24: older TES4 records (found in GOG release)
// 32: newer TES4 records, FO3/FNV
// 48: TES5
// 64: FO4/FO76
if (subHdr.dataSize != 24 && subHdr.dataSize != 32 && subHdr.dataSize != 48 && subHdr.dataSize != 64)
{
reader.skipSubRecordData();
break;
Expand All @@ -57,21 +61,23 @@ void ESM4::Light::load(ESM4::Reader& reader)
reader.get(mData.radius);
reader.get(mData.colour);
reader.get(mData.flags);
reader.get(mData.falloff);
reader.get(mData.FOV);
// TES5, FO4
if (subHdr.dataSize >= 48)
if (subHdr.dataSize >= 32)
{
reader.get(mData.nearClip);
reader.get(mData.frequency);
reader.get(mData.intensityAmplitude);
reader.get(mData.movementAmplitude);
if (subHdr.dataSize == 64)
reader.get(mData.falloff);
reader.get(mData.FOV);
if (subHdr.dataSize >= 48)
{
reader.get(mData.constant);
reader.get(mData.scalar);
reader.get(mData.exponent);
reader.get(mData.godRaysNearClip);
reader.get(mData.nearClip);
reader.get(mData.frequency);
reader.get(mData.intensityAmplitude);
reader.get(mData.movementAmplitude);
if (subHdr.dataSize == 64)
{
reader.get(mData.constant);
reader.get(mData.scalar);
reader.get(mData.exponent);
reader.get(mData.godRaysNearClip);
}
}
}
reader.get(mData.value);
Expand Down
28 changes: 14 additions & 14 deletions components/esm4/loadligh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ namespace ESM4

struct Data
{
std::int32_t time;
std::uint32_t radius;
std::uint32_t colour; // RGBA
std::int32_t time = 0;
std::uint32_t radius = 0;
std::uint32_t colour = 0; // RGBA
// flags:
// 0x00000001 = Dynamic
// 0x00000002 = Can be Carried
Expand All @@ -70,19 +70,19 @@ namespace ESM4
// 0x00000100 = Pulse Slow
// 0x00000200 = Spot Light
// 0x00000400 = Spot Shadow
std::int32_t flags;
std::int32_t flags = 0;
float falloff = 1.f;
float FOV = 90; // FIXME: FOV in degrees or radians?
float nearClip; // TES5+
float frequency; // TES5+
float intensityAmplitude; // TES5+
float movementAmplitude; // TES5+
float constant; // FO4
float scalar; // FO4
float exponent; // FO4
float godRaysNearClip; // FO4
std::uint32_t value; // gold
float weight;
float nearClip = 0.f; // TES5+
float frequency = 0.f; // TES5+
float intensityAmplitude = 0.f; // TES5+
float movementAmplitude = 0.f; // TES5+
float constant = 0.f; // FO4
float scalar = 0.f; // FO4
float exponent = 0.f; // FO4
float godRaysNearClip = 0.f; // FO4
std::uint32_t value = 0; // gold
float weight = 0.f;
};

ESM::FormId mId; // from the header
Expand Down

0 comments on commit 690de3c

Please sign in to comment.