mirror of https://github.com/OpenMW/openmw.git
moved light common to its own file
moved esm4light to it's own file7220-lua-add-a-general-purpose-lexical-parser
parent
dc961e3189
commit
486d15b19e
@ -0,0 +1,61 @@
|
||||
#include "light4.hpp"
|
||||
#include "classmodel.hpp"
|
||||
|
||||
#include "../mwphysics/physicssystem.hpp"
|
||||
#include "../mwrender/objects.hpp"
|
||||
#include "../mwrender/renderinginterface.hpp"
|
||||
#include "../mwworld/cellstore.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
#ifndef OPENW_MWCLASS_LIGHT4
|
||||
#define OPENW_MWCLASS_LIGHT4
|
||||
#include "../mwworld/registeredclass.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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
|
@ -0,0 +1,33 @@
|
||||
|
||||
#include "lightcommon.hpp"
|
||||
#include <components/esm3/loadligh.hpp>
|
||||
#include <components/esm4/loadligh.hpp>
|
||||
#include <components/sceneutil/util.hpp>
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
LightCommon::LightCommon(const ESM::Light& light)
|
||||
: mFlicker(light.mData.mFlags & ESM::Light::Flicker)
|
||||
, mFlickerSlow(light.mData.mFlags & ESM::Light::FlickerSlow)
|
||||
, mNegative(light.mData.mFlags & ESM::Light::Negative)
|
||||
, mPulse(light.mData.mFlags & ESM::Light::Pulse)
|
||||
, mPulseSlow(light.mData.mFlags & ESM::Light::PulseSlow)
|
||||
, mOffDefault(light.mData.mFlags & ESM::Light::OffDefault)
|
||||
, mColor(SceneUtil::colourFromRGB(light.mData.mColor))
|
||||
, mRadius(light.mData.mRadius)
|
||||
|
||||
{
|
||||
}
|
||||
LightCommon::LightCommon(const ESM4::Light& light)
|
||||
: mFlicker(light.mData.flags & ESM4::Light::Flicker)
|
||||
, mFlickerSlow(light.mData.flags & ESM4::Light::FlickerSlow)
|
||||
, mNegative(light.mData.flags & ESM::Light::Negative)
|
||||
, mPulse(light.mData.flags & ESM4::Light::Pulse)
|
||||
, mPulseSlow(light.mData.flags & ESM4::Light::PulseSlow)
|
||||
, mOffDefault(light.mData.flags & ESM4::Light::OffDefault)
|
||||
, mColor(SceneUtil::colourFromRGB(light.mData.colour))
|
||||
, mRadius(light.mData.radius)
|
||||
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
|
||||
#ifndef COMPONENTS_SCENEUTIL_LIGHTCOMMON
|
||||
#define COMPONENTS_SCENEUTIL_LIGHTCOMMON
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
|
||||
#include <osg/Vec4>
|
||||
|
||||
namespace ESM4
|
||||
{
|
||||
struct Light;
|
||||
}
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct Light;
|
||||
}
|
||||
|
||||
namespace SceneUtil
|
||||
{
|
||||
struct LightCommon
|
||||
{
|
||||
explicit LightCommon(const ESM::Light& light);
|
||||
explicit LightCommon(const ESM4::Light& light);
|
||||
|
||||
bool mFlicker;
|
||||
bool mFlickerSlow;
|
||||
bool mNegative;
|
||||
bool mPulse;
|
||||
bool mPulseSlow;
|
||||
bool mOffDefault;
|
||||
|
||||
osg::Vec4 mColor;
|
||||
float mRadius;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue