mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-22 00:23:51 +00:00
Scale NPCs by their Weight property (Fixes #814)
This commit is contained in:
parent
1c0e3a6488
commit
9f12e53956
10 changed files with 42 additions and 25 deletions
|
@ -893,7 +893,7 @@ namespace MWClass
|
||||||
return ref->mBase->mAiData.mFight;
|
return ref->mBase->mAiData.mFight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::adjustScale(const MWWorld::Ptr &ptr, float &scale) const
|
void Creature::adjustScale(const MWWorld::Ptr &ptr, osg::Vec3f &scale) const
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
||||||
scale *= ref->mBase->mScale;
|
scale *= ref->mBase->mScale;
|
||||||
|
|
|
@ -157,7 +157,7 @@ namespace MWClass
|
||||||
|
|
||||||
virtual int getBaseFightRating(const MWWorld::Ptr &ptr) const;
|
virtual int getBaseFightRating(const MWWorld::Ptr &ptr) const;
|
||||||
|
|
||||||
virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const;
|
virtual void adjustScale(const MWWorld::Ptr& ptr, osg::Vec3f& scale) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1110,7 +1110,7 @@ namespace MWClass
|
||||||
+ shield;
|
+ shield;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Npc::adjustScale(const MWWorld::Ptr &ptr, float &scale) const
|
void Npc::adjustScale(const MWWorld::Ptr &ptr, osg::Vec3f&scale) const
|
||||||
{
|
{
|
||||||
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||||
ptr.get<ESM::NPC>();
|
ptr.get<ESM::NPC>();
|
||||||
|
@ -1119,9 +1119,18 @@ namespace MWClass
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(ref->mBase->mRace);
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(ref->mBase->mRace);
|
||||||
|
|
||||||
if (ref->mBase->isMale())
|
if (ref->mBase->isMale())
|
||||||
scale *= race->mData.mHeight.mMale;
|
{
|
||||||
|
scale.x() *= race->mData.mWeight.mMale;
|
||||||
|
scale.y() *= race->mData.mWeight.mMale;
|
||||||
|
scale.z() *= race->mData.mHeight.mMale;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
scale *= race->mData.mHeight.mFemale;
|
{
|
||||||
|
scale.x() *= race->mData.mWeight.mFemale;
|
||||||
|
scale.y() *= race->mData.mWeight.mFemale;
|
||||||
|
scale.z() *= race->mData.mHeight.mFemale;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Npc::getServices(const MWWorld::Ptr &actor) const
|
int Npc::getServices(const MWWorld::Ptr &actor) const
|
||||||
|
|
|
@ -129,7 +129,7 @@ namespace MWClass
|
||||||
/// \param actor Actor that is resposible for the ID being applied to \a ptr.
|
/// \param actor Actor that is resposible for the ID being applied to \a ptr.
|
||||||
/// \return Any effect?
|
/// \return Any effect?
|
||||||
|
|
||||||
virtual void adjustScale (const MWWorld::Ptr &ptr, float &scale) const;
|
virtual void adjustScale (const MWWorld::Ptr &ptr, osg::Vec3f &scale) const;
|
||||||
|
|
||||||
virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor=1.f) const;
|
virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor=1.f) const;
|
||||||
///< Inform actor \a ptr that a skill use has succeeded.
|
///< Inform actor \a ptr that a skill use has succeeded.
|
||||||
|
|
|
@ -295,7 +295,7 @@ namespace MWWorld
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Class::adjustScale(const MWWorld::Ptr& ptr,float& scale) const
|
void Class::adjustScale(const MWWorld::Ptr& ptr, osg::Vec3f& scale) const
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,7 @@ namespace MWWorld
|
||||||
virtual int getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
|
virtual int getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
|
||||||
///< @return the number of enchantment points available for possible enchanting
|
///< @return the number of enchantment points available for possible enchanting
|
||||||
|
|
||||||
virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const;
|
virtual void adjustScale(const MWWorld::Ptr& ptr, osg::Vec3f& scale) const;
|
||||||
|
|
||||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||||
///< Determine whether or not \a item can be sold to an npc with the given \a npcServices
|
///< Determine whether or not \a item can be sold to an npc with the given \a npcServices
|
||||||
|
|
|
@ -769,10 +769,11 @@ namespace MWWorld
|
||||||
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
|
||||||
{
|
{
|
||||||
float scale = ptr.getCellRef().getScale();
|
float scale = ptr.getCellRef().getScale();
|
||||||
|
osg::Vec3f scaleVec (scale,scale,scale);
|
||||||
if (!ptr.getClass().isNpc())
|
if (!ptr.getClass().isNpc())
|
||||||
// NOTE: Ignoring Npc::adjustScale (race height) on purpose. This is a bug in MW and must be replicated for compatibility reasons
|
// NOTE: Ignoring Npc::adjustScale (race height) on purpose. This is a bug in MW and must be replicated for compatibility reasons
|
||||||
ptr.getClass().adjustScale(ptr, scale);
|
ptr.getClass().adjustScale(ptr, scaleVec);
|
||||||
act->setScale(scale);
|
act->setScale(scaleVec.x());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,18 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateObjectScale(const MWWorld::Ptr& ptr, /*MWWorld::PhysicsSystem& physics,*/
|
||||||
|
MWRender::RenderingManager& rendering)
|
||||||
|
{
|
||||||
|
if (ptr.getRefData().getBaseNode() != NULL)
|
||||||
|
{
|
||||||
|
float scale = ptr.getCellRef().getScale();
|
||||||
|
osg::Vec3f scaleVec (scale, scale, scale);
|
||||||
|
ptr.getClass().adjustScale(ptr, scaleVec);
|
||||||
|
rendering.scaleObject(ptr, scaleVec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct InsertFunctor
|
struct InsertFunctor
|
||||||
{
|
{
|
||||||
MWWorld::CellStore& mCell;
|
MWWorld::CellStore& mCell;
|
||||||
|
@ -103,12 +115,7 @@ namespace
|
||||||
{
|
{
|
||||||
addObject(ptr, /*mPhysics, */mRendering);
|
addObject(ptr, /*mPhysics, */mRendering);
|
||||||
updateObjectLocalRotation(ptr, /*mPhysics,*/ mRendering);
|
updateObjectLocalRotation(ptr, /*mPhysics,*/ mRendering);
|
||||||
if (ptr.getRefData().getBaseNode())
|
updateObjectScale(ptr, /*mPhysics,*/ mRendering);
|
||||||
{
|
|
||||||
float scale = ptr.getCellRef().getScale();
|
|
||||||
ptr.getClass().adjustScale(ptr, scale);
|
|
||||||
mRendering.scaleObject(ptr, osg::Vec3f(scale, scale, scale));
|
|
||||||
}
|
|
||||||
ptr.getClass().adjustPosition (ptr, false);
|
ptr.getClass().adjustPosition (ptr, false);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
|
@ -133,6 +140,11 @@ namespace MWWorld
|
||||||
::updateObjectLocalRotation(ptr, /* *mPhysics,*/ mRendering);
|
::updateObjectLocalRotation(ptr, /* *mPhysics,*/ mRendering);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scene::updateObjectScale(const Ptr &ptr)
|
||||||
|
{
|
||||||
|
::updateObjectScale(ptr, /* *mPhysics,*/ mRendering);
|
||||||
|
}
|
||||||
|
|
||||||
void Scene::getGridCenter(int &cellX, int &cellY)
|
void Scene::getGridCenter(int &cellX, int &cellY)
|
||||||
{
|
{
|
||||||
int maxX = std::numeric_limits<int>::min();
|
int maxX = std::numeric_limits<int>::min();
|
||||||
|
|
|
@ -116,6 +116,7 @@ namespace MWWorld
|
||||||
///< Remove an object from the scene, but not from the world model.
|
///< Remove an object from the scene, but not from the world model.
|
||||||
|
|
||||||
void updateObjectLocalRotation (const Ptr& ptr);
|
void updateObjectLocalRotation (const Ptr& ptr);
|
||||||
|
void updateObjectScale(const Ptr& ptr);
|
||||||
|
|
||||||
bool isCellActive(const CellStore &cell);
|
bool isCellActive(const CellStore &cell);
|
||||||
|
|
||||||
|
|
|
@ -1254,12 +1254,8 @@ namespace MWWorld
|
||||||
void World::scaleObject (const Ptr& ptr, float scale)
|
void World::scaleObject (const Ptr& ptr, float scale)
|
||||||
{
|
{
|
||||||
ptr.getCellRef().setScale(scale);
|
ptr.getCellRef().setScale(scale);
|
||||||
ptr.getClass().adjustScale(ptr,scale);
|
|
||||||
|
|
||||||
if(ptr.getRefData().getBaseNode() == 0)
|
mWorldScene->updateObjectScale(ptr);
|
||||||
return;
|
|
||||||
mRendering->scaleObject(ptr, osg::Vec3f(scale,scale,scale));
|
|
||||||
//mPhysics->scaleObject(ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust)
|
void World::rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust)
|
||||||
|
@ -1307,9 +1303,7 @@ namespace MWWorld
|
||||||
|
|
||||||
ptr.getRefData().setPosition(pos);
|
ptr.getRefData().setPosition(pos);
|
||||||
|
|
||||||
if(ptr.getRefData().getBaseNode() == 0)
|
if(ptr.getRefData().getBaseNode() != 0)
|
||||||
return;
|
|
||||||
|
|
||||||
mWorldScene->updateObjectLocalRotation(ptr);
|
mWorldScene->updateObjectLocalRotation(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue