Skip to content

Commit

Permalink
Merge branch 'nilightcolorcontroller' into 'master'
Browse files Browse the repository at this point in the history
Give NiLightColorController its own struct

See merge request OpenMW/openmw!4472
  • Loading branch information
psi29a committed Dec 2, 2024
2 parents 23a46a1 + a923e31 commit c454675
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
22 changes: 21 additions & 1 deletion components/nif/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,32 @@ namespace Nif
mCollider.post(nif);
}

void NiLightColorController::read(NIFStream* nif)
{
NiPoint3InterpController::read(nif);

if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
mMode = static_cast<Mode>(nif->get<uint16_t>());
else
mMode = static_cast<Mode>((mFlags >> 4) & 1);

if (nif->getVersion() <= NIFStream::generateVersion(10, 1, 0, 103))
mData.read(nif);
}

void NiLightColorController::post(Reader& nif)
{
NiPoint3InterpController::post(nif);

mData.post(nif);
}

void NiMaterialColorController::read(NIFStream* nif)
{
NiPoint3InterpController::read(nif);

if (nif->getVersion() >= NIFStream::generateVersion(10, 1, 0, 0))
mTargetColor = static_cast<TargetColor>(nif->get<uint16_t>() & 3);
mTargetColor = static_cast<TargetColor>(nif->get<uint16_t>());
else
mTargetColor = static_cast<TargetColor>((mFlags >> 4) & 3);

Expand Down
15 changes: 15 additions & 0 deletions components/nif/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ namespace Nif
};
using NiBSPArrayController = NiParticleSystemController;

struct NiLightColorController : public NiPoint3InterpController
{
enum class Mode
{
DiffuseSpecular = 0,
Ambient = 1,
};

NiPosDataPtr mData;
Mode mMode = Mode::DiffuseSpecular;

void read(NIFStream* nif) override;
void post(Reader& nif) override;
};

struct NiMaterialColorController : public NiPoint3InterpController
{
enum class TargetColor
Expand Down
3 changes: 1 addition & 2 deletions components/nif/niffile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ namespace Nif
{ "NiGeomMorpherController", &construct<NiGeomMorpherController, RC_NiGeomMorpherController> },
{ "NiKeyframeController", &construct<NiKeyframeController, RC_NiKeyframeController> },
{ "NiLookAtController", &construct<NiLookAtController, RC_NiLookAtController> },
// FIXME: NiLightColorController should have its own struct
{ "NiLightColorController", &construct<NiMaterialColorController, RC_NiLightColorController> },
{ "NiLightColorController", &construct<NiLightColorController, RC_NiLightColorController> },
{ "NiMaterialColorController", &construct<NiMaterialColorController, RC_NiMaterialColorController> },
{ "NiPathController", &construct<NiPathController, RC_NiPathController> },
{ "NiRollController", &construct<NiRollController, RC_NiRollController> },
Expand Down

0 comments on commit c454675

Please sign in to comment.