mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-20 15:40:32 +00:00
Load light models in the engine. Doesn't emit light
This commit is contained in:
parent
4f001d8736
commit
a71a86e64a
@ -49,5 +49,6 @@ namespace MWClass
|
||||
BodyPart::registerSelf();
|
||||
|
||||
ESM4Static::registerSelf();
|
||||
ESM4Light::registerSelf();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <components/esm3/loadligh.hpp>
|
||||
#include <components/esm3/loadnpc.hpp>
|
||||
#include <components/esm3/objectstate.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
@ -242,4 +243,53 @@ namespace MWClass
|
||||
{
|
||||
return ptr.get<ESM::Light>()->mBase->mSound;
|
||||
}
|
||||
|
||||
ESM4Light::ESM4Light()
|
||||
: MWWorld::RegisteredClass<ESM4Light>(ESM4::Light::sRecordId)
|
||||
{
|
||||
}
|
||||
|
||||
void ESM4Light ::insertObjectRendering(
|
||||
const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM4::Light>* ref = ptr.get<ESM4::Light>();
|
||||
|
||||
// Insert even if model is empty, so that the light is added
|
||||
renderingInterface.getObjects().insertModel(ptr, model, !(ref->mBase->mData.flags & ESM4::Light::OffDefault));
|
||||
}
|
||||
|
||||
void ESM4Light::insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
insertObjectPhysics(ptr, model, rotation, physics);
|
||||
}
|
||||
|
||||
void ESM4Light::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const
|
||||
{
|
||||
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
|
||||
}
|
||||
|
||||
std::string ESM4Light::getModel(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return getClassModel<ESM4::Light>(ptr);
|
||||
}
|
||||
|
||||
std::string_view ESM4Light ::getName(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ESM4Light::hasToolTip(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MWWorld::Ptr ESM4Light::copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM4::Light>* ref = ptr.get<ESM4::Light>();
|
||||
|
||||
return MWWorld::Ptr(cell.insert(ref), &cell);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -78,6 +78,33 @@ namespace MWClass
|
||||
|
||||
const ESM::RefId& getSound(const MWWorld::ConstPtr& ptr) const override;
|
||||
};
|
||||
|
||||
class ESM4Light : public MWWorld::RegisteredClass<ESM4Light>
|
||||
{
|
||||
friend MWWorld::RegisteredClass<ESM4Light>;
|
||||
|
||||
ESM4Light();
|
||||
|
||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr& ptr, MWWorld::CellStore& cell) const override;
|
||||
|
||||
public:
|
||||
void insertObjectRendering(const MWWorld::Ptr& ptr, const std::string& model,
|
||||
MWRender::RenderingInterface& renderingInterface) const override;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
void insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const override;
|
||||
void insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation,
|
||||
MWPhysics::PhysicsSystem& physics) const override;
|
||||
|
||||
std::string_view getName(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< \return name or ID; can return an empty string.
|
||||
|
||||
bool hasToolTip(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< @return true if this object has a tooltip when focused (default implementation: true)
|
||||
|
||||
std::string getModel(const MWWorld::ConstPtr& ptr) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <components/esm3/readerscache.hpp>
|
||||
#include <components/esm4/loadrefr.hpp>
|
||||
#include <components/esm4/loadstat.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/misc/tuplehelpers.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
@ -59,6 +59,7 @@ namespace ESM4
|
||||
struct Cell;
|
||||
struct Reference;
|
||||
struct Static;
|
||||
struct Light;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
@ -73,7 +74,7 @@ namespace MWWorld
|
||||
CellRefList<ESM::Lockpick>, CellRefList<ESM::Miscellaneous>, CellRefList<ESM::NPC>, CellRefList<ESM::Probe>,
|
||||
CellRefList<ESM::Repair>, CellRefList<ESM::Static>, CellRefList<ESM::Weapon>, CellRefList<ESM::BodyPart>,
|
||||
|
||||
CellRefList<ESM4::Static>>;
|
||||
CellRefList<ESM4::Static>, CellRefList<ESM4::Light>>;
|
||||
|
||||
/// \brief Mutable state of a cell
|
||||
class CellStore
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <components/esm4/common.hpp>
|
||||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/esm4/loadrefr.hpp>
|
||||
#include <components/esm4/loadstat.hpp>
|
||||
#include <components/esm4/reader.hpp>
|
||||
@ -279,6 +280,7 @@ namespace MWWorld
|
||||
case ESM::REC_WEAP:
|
||||
case ESM::REC_BODY:
|
||||
case ESM::REC_STAT4:
|
||||
case ESM::REC_LIGH4:
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ namespace ESM4
|
||||
struct Static;
|
||||
struct Cell;
|
||||
struct Reference;
|
||||
struct Light;
|
||||
}
|
||||
|
||||
namespace ESM
|
||||
@ -105,7 +106,7 @@ namespace MWWorld
|
||||
// Special entry which is hardcoded and not loaded from an ESM
|
||||
Store<ESM::Attribute>,
|
||||
|
||||
Store<ESM4::Static>, Store<ESM4::Cell>, Store<ESM4::Reference>>;
|
||||
Store<ESM4::Static>, Store<ESM4::Cell>, Store<ESM4::Reference>, Store<ESM4::Light>>;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/esm3/esmwriter.hpp>
|
||||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/esm4/loadrefr.hpp>
|
||||
#include <components/esm4/loadstat.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
@ -1250,5 +1251,6 @@ template class MWWorld::TypedDynamicStore<ESM::Static>;
|
||||
template class MWWorld::TypedDynamicStore<ESM::Weapon>;
|
||||
|
||||
template class MWWorld::TypedDynamicStore<ESM4::Static>;
|
||||
template class MWWorld::TypedDynamicStore<ESM4::Light>;
|
||||
template class MWWorld::TypedDynamicStore<ESM4::Reference>;
|
||||
template class MWWorld::TypedDynamicStore<ESM4::Cell>;
|
||||
|
@ -33,8 +33,9 @@
|
||||
|
||||
void ESM4::Light::load(ESM4::Reader& reader)
|
||||
{
|
||||
mFormId = reader.hdr().record.id;
|
||||
reader.adjustFormId(mFormId);
|
||||
FormId formId = reader.hdr().record.id;
|
||||
reader.adjustFormId(formId);
|
||||
mId = ESM::RefId::formIdRefId(formId);
|
||||
mFlags = reader.hdr().record.flags;
|
||||
std::uint32_t esmVer = reader.esmVersion();
|
||||
bool isFONV = esmVer == ESM::VER_132 || esmVer == ESM::VER_133 || esmVer == ESM::VER_134;
|
||||
|
@ -32,6 +32,9 @@
|
||||
|
||||
#include "formid.hpp"
|
||||
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
namespace ESM4
|
||||
{
|
||||
class Reader;
|
||||
@ -39,6 +42,20 @@ namespace ESM4
|
||||
|
||||
struct Light
|
||||
{
|
||||
enum Flag
|
||||
{
|
||||
Dynamic = 0x01,
|
||||
Carryable = 0x02,
|
||||
Negative = 0x04,
|
||||
Flicker = 0x08,
|
||||
OffDefault = 0x020,
|
||||
FlickerSlow = 0x040,
|
||||
Pulse = 0x080,
|
||||
PulseSlow = 0x100,
|
||||
SpotLight = 0x200,
|
||||
SpotShadow = 0x400,
|
||||
};
|
||||
|
||||
struct Data
|
||||
{
|
||||
std::uint32_t time; // FO/FONV only
|
||||
@ -67,7 +84,7 @@ namespace ESM4
|
||||
float weight;
|
||||
};
|
||||
|
||||
FormId mFormId; // from the header
|
||||
ESM::RefId mId; // from the header
|
||||
std::uint32_t mFlags; // from the header, see enum type RecordFlag for details
|
||||
|
||||
std::string mEditorId;
|
||||
@ -87,6 +104,8 @@ namespace ESM4
|
||||
void load(ESM4::Reader& reader);
|
||||
// void save(ESM4::Writer& writer) const;
|
||||
|
||||
static constexpr ESM::RecNameInts sRecordId = ESM::REC_LIGH4;
|
||||
|
||||
// void blank();
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user