Sprinkle some const-ref

pull/3097/head
jvoisin 3 years ago
parent 7400050b38
commit 7a015d24c6

@ -289,14 +289,14 @@ namespace MWBase
virtual MWWorld::Ptr moveObject(const MWWorld::Ptr &ptr, MWWorld::CellStore* newCell, const osg::Vec3f& position, bool movePhysics=true) = 0;
///< @return an updated Ptr
virtual MWWorld::Ptr moveObjectBy(const MWWorld::Ptr &ptr, osg::Vec3f vec, bool moveToActive, bool ignoreCollisions) = 0;
virtual MWWorld::Ptr moveObjectBy(const MWWorld::Ptr &ptr, const osg::Vec3f& vec, bool moveToActive, bool ignoreCollisions) = 0;
///< @return an updated Ptr
virtual void scaleObject (const MWWorld::Ptr& ptr, float scale) = 0;
virtual void rotateObject(const MWWorld::Ptr& ptr, const osg::Vec3f& rot, RotationFlags flags = RotationFlag_inverseOrder) = 0;
virtual MWWorld::Ptr placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos) = 0;
virtual MWWorld::Ptr placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, const ESM::Position& pos) = 0;
///< Place an object. Makes a copy of the Ptr.
virtual MWWorld::Ptr safePlaceObject (const MWWorld::ConstPtr& ptr, const MWWorld::ConstPtr& referenceObject, MWWorld::CellStore* referenceCell, int direction, float distance) = 0;
@ -624,7 +624,7 @@ namespace MWBase
virtual void setPlayerTraveling(bool traveling) = 0;
virtual bool isPlayerTraveling() const = 0;
virtual void rotateWorldObject (const MWWorld::Ptr& ptr, osg::Quat rotate) = 0;
virtual void rotateWorldObject (const MWWorld::Ptr& ptr, const osg::Quat& rotate) = 0;
/// Return terrain height at \a worldPos position.
virtual float getTerrainHeightAt(const osg::Vec3f& worldPos) const = 0;

@ -108,7 +108,7 @@ struct TypesetBookImpl : TypesetBook
virtual ~TypesetBookImpl () {}
Range addContent (BookTypesetter::Utf8Span text)
Range addContent (const BookTypesetter::Utf8Span &text)
{
Contents::iterator i = mContents.insert (mContents.end (), Content (text.first, text.second));

@ -86,7 +86,7 @@ size_t ContainerItemModel::getItemCount()
return mItems.size();
}
ItemModel::ModelIndex ContainerItemModel::getIndex (ItemStack item)
ItemModel::ModelIndex ContainerItemModel::getIndex (const ItemStack& item)
{
size_t i = 0;
for (ItemStack& itemStack : mItems)

@ -28,7 +28,7 @@ namespace MWGui
bool onTakeItem(const MWWorld::Ptr &item, int count) override;
ItemStack getItem (ModelIndex index) override;
ModelIndex getIndex (ItemStack item) override;
ModelIndex getIndex (const ItemStack &item) override;
size_t getItemCount() override;
MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool allowAutoEquip = true) override;

@ -53,7 +53,7 @@ namespace MWGui
}
void removeItem (const ItemStack& item, size_t count) override { throw std::runtime_error("removeItem not implemented"); }
ModelIndex getIndex (ItemStack item) override { throw std::runtime_error("getIndex not implemented"); }
ModelIndex getIndex (const ItemStack &item) override { throw std::runtime_error("getIndex not implemented"); }
void update() override {}
size_t getItemCount() override { return 0; }
ItemStack getItem (ModelIndex index) override { throw std::runtime_error("getItem not implemented"); }

@ -34,7 +34,7 @@ size_t InventoryItemModel::getItemCount()
return mItems.size();
}
ItemModel::ModelIndex InventoryItemModel::getIndex (ItemStack item)
ItemModel::ModelIndex InventoryItemModel::getIndex (const ItemStack& item)
{
size_t i = 0;
for (ItemStack& itemStack : mItems)

@ -12,7 +12,7 @@ namespace MWGui
InventoryItemModel (const MWWorld::Ptr& actor);
ItemStack getItem (ModelIndex index) override;
ModelIndex getIndex (ItemStack item) override;
ModelIndex getIndex (const ItemStack &item) override;
size_t getItemCount() override;
bool onTakeItem(const MWWorld::Ptr &item, int count) override;

@ -129,7 +129,7 @@ namespace MWGui
return -1;
}
ItemModel::ModelIndex ProxyItemModel::getIndex (ItemStack item)
ItemModel::ModelIndex ProxyItemModel::getIndex (const ItemStack& item)
{
return mSourceModel->getIndex(item);
}

@ -55,7 +55,7 @@ namespace MWGui
virtual size_t getItemCount() = 0;
/// Returns an invalid index if the item was not found
virtual ModelIndex getIndex (ItemStack item) = 0;
virtual ModelIndex getIndex (const ItemStack &item) = 0;
/// Rebuild the item model, this will invalidate existing model indices
virtual void update() = 0;
@ -98,7 +98,7 @@ namespace MWGui
MWWorld::Ptr copyItem (const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
void removeItem (const ItemStack& item, size_t count) override;
ModelIndex getIndex (ItemStack item) override;
ModelIndex getIndex (const ItemStack &item) override;
/// @note Takes ownership of the passed pointer.
void setSourceModel(ItemModel* sourceModel);

@ -44,7 +44,7 @@ namespace MWGui
mSelect->getHeight());
}
void TravelWindow::addDestination(const std::string& name, ESM::Position pos, bool interior)
void TravelWindow::addDestination(const std::string& name, const ESM::Position &pos, bool interior)
{
int price;

@ -31,7 +31,7 @@ namespace MWGui
void onCancelButtonClicked(MyGUI::Widget* _sender);
void onTravelButtonClick(MyGUI::Widget* _sender);
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
void addDestination(const std::string& name, ESM::Position pos, bool interior);
void addDestination(const std::string& name, const ESM::Position& pos, bool interior);
void clearDestinations();
int mCurrentY;

@ -84,7 +84,7 @@ PartHolderPtr ActorAnimation::attachMesh(const std::string& model, const std::st
return PartHolderPtr(new PartHolder(instance));
}
std::string ActorAnimation::getShieldMesh(MWWorld::ConstPtr shield) const
std::string ActorAnimation::getShieldMesh(const MWWorld::ConstPtr& shield) const
{
std::string mesh = shield.getClass().getModel(shield);
const ESM::Armor *armor = shield.get<ESM::Armor>()->mBase;

@ -45,7 +45,7 @@ class ActorAnimation : public Animation, public MWWorld::ContainerStoreListener
virtual void updateHolsteredWeapon(bool showHolsteredWeapons);
virtual void updateHolsteredShield(bool showCarriedLeft);
virtual void updateQuiver();
virtual std::string getShieldMesh(MWWorld::ConstPtr shield) const;
virtual std::string getShieldMesh(const MWWorld::ConstPtr& shield) const;
virtual std::string getHolsteredWeaponBoneName(const MWWorld::ConstPtr& weapon);
virtual PartHolderPtr attachMesh(const std::string& model, const std::string& bonename, bool enchantedGlow, osg::Vec4f* glowColor);
virtual PartHolderPtr attachMesh(const std::string& model, const std::string& bonename)

@ -1839,7 +1839,7 @@ namespace MWRender
mRootController = addRotateController("bip01");
}
RotateController* Animation::addRotateController(std::string bone)
RotateController* Animation::addRotateController(const std::string &bone)
{
auto iter = getNodeMap().find(bone);
if (iter == getNodeMap().end())

@ -271,7 +271,7 @@ protected:
float mLegsYawRadians;
float mBodyPitchRadians;
RotateController* addRotateController(std::string bone);
RotateController* addRotateController(const std::string& bone);
bool mHasMagicEffects;

@ -551,7 +551,7 @@ void NpcAnimation::updateNpcBase()
mWeaponAnimationTime->updateStartTime();
}
std::string NpcAnimation::getShieldMesh(MWWorld::ConstPtr shield) const
std::string NpcAnimation::getShieldMesh(const MWWorld::ConstPtr& shield) const
{
std::string mesh = shield.getClass().getModel(shield);
const ESM::Armor *armor = shield.get<ESM::Armor>()->mBase;

@ -106,7 +106,7 @@ private:
protected:
void addControllers() override;
bool isArrowAttached() const override;
std::string getShieldMesh(MWWorld::ConstPtr shield) const override;
std::string getShieldMesh(const MWWorld::ConstPtr& shield) const override;
public:
/**

@ -328,7 +328,7 @@ namespace MWRender
mRootNode->removeChild(camera);
}
void ScreenshotManager::makeCubemapScreenshot(osg::Image *image, int w, int h, osg::Matrixd cameraTransform)
void ScreenshotManager::makeCubemapScreenshot(osg::Image *image, int w, int h, const osg::Matrixd& cameraTransform)
{
osg::ref_ptr<osg::Camera> rttCamera (new osg::Camera);
float nearClip = Settings::Manager::getFloat("near clip", "Camera");

@ -37,7 +37,7 @@ namespace MWRender
void traversalsAndWait(unsigned int frame);
void renderCameraToImage(osg::Camera *camera, osg::Image *image, int w, int h);
void makeCubemapScreenshot(osg::Image* image, int w, int h, osg::Matrixd cameraTransform=osg::Matrixd());
void makeCubemapScreenshot(osg::Image* image, int w, int h, const osg::Matrixd &cameraTransform=osg::Matrixd());
};
}

@ -60,7 +60,7 @@ WeaponAnimation::~WeaponAnimation()
}
void WeaponAnimation::attachArrow(MWWorld::Ptr actor)
void WeaponAnimation::attachArrow(const MWWorld::Ptr& actor)
{
const MWWorld::InventoryStore& inv = actor.getClass().getInventoryStore(actor);
MWWorld::ConstContainerStoreIterator weaponSlot = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);

@ -34,7 +34,7 @@ namespace MWRender
virtual ~WeaponAnimation();
/// @note If no weapon (or an invalid weapon) is equipped, this function is a no-op.
void attachArrow(MWWorld::Ptr actor);
void attachArrow(const MWWorld::Ptr &actor);
void detachArrow(MWWorld::Ptr actor);

@ -29,7 +29,7 @@ namespace MWWorld
{
std::vector<MWWorld::Ptr> mObjects;
bool operator() (MWWorld::Ptr ptr)
bool operator() (const MWWorld::Ptr& ptr)
{
mObjects.push_back (ptr);
return true;

@ -86,7 +86,7 @@ namespace
return rot;
}
void setNodeRotation(const MWWorld::Ptr& ptr, MWRender::RenderingManager& rendering, osg::Quat rotation)
void setNodeRotation(const MWWorld::Ptr& ptr, MWRender::RenderingManager& rendering, const osg::Quat &rotation)
{
if (ptr.getRefData().getBaseNode())
rendering.rotateObject(ptr, rotation);

@ -1256,7 +1256,7 @@ namespace MWWorld
return moveObject(ptr, cell, position, movePhysics);
}
MWWorld::Ptr World::moveObjectBy(const Ptr& ptr, osg::Vec3f vec, bool moveToActive, bool ignoreCollisions)
MWWorld::Ptr World::moveObjectBy(const Ptr& ptr, const osg::Vec3f& vec, bool moveToActive, bool ignoreCollisions)
{
auto* actor = mPhysics->getActor(ptr);
osg::Vec3f newpos = ptr.getRefData().getPosition().asVec3() + vec;
@ -1410,7 +1410,7 @@ namespace MWWorld
}
}
void World::rotateWorldObject (const Ptr& ptr, osg::Quat rotate)
void World::rotateWorldObject (const Ptr& ptr, const osg::Quat& rotate)
{
if(ptr.getRefData().getBaseNode() != nullptr)
{
@ -1425,7 +1425,7 @@ namespace MWWorld
}
}
MWWorld::Ptr World::placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos)
MWWorld::Ptr World::placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, const ESM::Position& pos)
{
return copyObjectToCell(ptr,cell,pos,ptr.getRefData().getCount(),false);
}

@ -224,7 +224,7 @@ namespace MWWorld
void setWaterHeight(const float height) override;
void rotateWorldObject (const MWWorld::Ptr& ptr, osg::Quat rotate) override;
void rotateWorldObject (const MWWorld::Ptr& ptr, const osg::Quat& rotate) override;
bool toggleWater() override;
bool toggleWorld() override;
@ -376,7 +376,7 @@ namespace MWWorld
MWWorld::Ptr moveObject (const Ptr& ptr, CellStore* newCell, const osg::Vec3f& position, bool movePhysics=true) override;
///< @return an updated Ptr
MWWorld::Ptr moveObjectBy(const Ptr& ptr, osg::Vec3f vec, bool moveToActive, bool ignoreCollisions) override;
MWWorld::Ptr moveObjectBy(const Ptr& ptr, const osg::Vec3f& vec, bool moveToActive, bool ignoreCollisions) override;
///< @return an updated Ptr
void scaleObject (const Ptr& ptr, float scale) override;
@ -387,7 +387,7 @@ namespace MWWorld
/// \param adjust indicates rotation should be set or adjusted
void rotateObject (const Ptr& ptr, const osg::Vec3f& rot, MWBase::RotationFlags flags = MWBase::RotationFlag_inverseOrder) override;
MWWorld::Ptr placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos) override;
MWWorld::Ptr placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, const ESM::Position& pos) override;
///< Place an object. Makes a copy of the Ptr.
MWWorld::Ptr safePlaceObject (const MWWorld::ConstPtr& ptr, const MWWorld::ConstPtr& referenceObject, MWWorld::CellStore* referenceCell, int direction, float distance) override;

@ -56,7 +56,7 @@ namespace Shader
bool hasUniform(const std::string& name) { return mUniforms.count(name); }
bool hasMode(osg::StateAttribute::GLMode mode) { return mModes.count(mode); }
bool hasAttribute(osg::StateAttribute::TypeMemberPair typeMemberPair) { return mAttributes.count(typeMemberPair); }
bool hasAttribute(const osg::StateAttribute::TypeMemberPair &typeMemberPair) { return mAttributes.count(typeMemberPair); }
bool hasAttribute(osg::StateAttribute::Type type, unsigned int member) { return hasAttribute(osg::StateAttribute::TypeMemberPair(type, member)); }
const std::set<osg::StateAttribute::TypeMemberPair>& getAttributes() { return mAttributes; }

@ -18,7 +18,7 @@ namespace Gui
}
}
void SharedStateButton::shareStateWith(ButtonGroup shared)
void SharedStateButton::shareStateWith(const ButtonGroup &shared)
{
mSharedWith = shared;
}

@ -34,7 +34,7 @@ namespace Gui
bool _setState(const std::string &_value);
public:
void shareStateWith(ButtonGroup shared);
void shareStateWith(const ButtonGroup &shared);
/// @note The ButtonGroup connection will be destroyed when any widget in the group gets destroyed.
static void createButtonGroup(ButtonGroup group);

Loading…
Cancel
Save