mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 12:53: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;
|
||||
}
|
||||
|
||||
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>();
|
||||
scale *= ref->mBase->mScale;
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace MWClass
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
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 =
|
||||
ptr.get<ESM::NPC>();
|
||||
|
@ -1119,9 +1119,18 @@ namespace MWClass
|
|||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(ref->mBase->mRace);
|
||||
|
||||
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
|
||||
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
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace MWClass
|
|||
/// \param actor Actor that is resposible for the ID being applied to \a ptr.
|
||||
/// \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;
|
||||
///< Inform actor \a ptr that a skill use has succeeded.
|
||||
|
|
|
@ -295,7 +295,7 @@ namespace MWWorld
|
|||
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;
|
||||
///< @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;
|
||||
///< 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))
|
||||
{
|
||||
float scale = ptr.getCellRef().getScale();
|
||||
osg::Vec3f scaleVec (scale,scale,scale);
|
||||
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
|
||||
ptr.getClass().adjustScale(ptr, scale);
|
||||
act->setScale(scale);
|
||||
ptr.getClass().adjustScale(ptr, scaleVec);
|
||||
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
|
||||
{
|
||||
MWWorld::CellStore& mCell;
|
||||
|
@ -103,12 +115,7 @@ namespace
|
|||
{
|
||||
addObject(ptr, /*mPhysics, */mRendering);
|
||||
updateObjectLocalRotation(ptr, /*mPhysics,*/ mRendering);
|
||||
if (ptr.getRefData().getBaseNode())
|
||||
{
|
||||
float scale = ptr.getCellRef().getScale();
|
||||
ptr.getClass().adjustScale(ptr, scale);
|
||||
mRendering.scaleObject(ptr, osg::Vec3f(scale, scale, scale));
|
||||
}
|
||||
updateObjectScale(ptr, /*mPhysics,*/ mRendering);
|
||||
ptr.getClass().adjustPosition (ptr, false);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
|
@ -133,6 +140,11 @@ namespace MWWorld
|
|||
::updateObjectLocalRotation(ptr, /* *mPhysics,*/ mRendering);
|
||||
}
|
||||
|
||||
void Scene::updateObjectScale(const Ptr &ptr)
|
||||
{
|
||||
::updateObjectScale(ptr, /* *mPhysics,*/ mRendering);
|
||||
}
|
||||
|
||||
void Scene::getGridCenter(int &cellX, int &cellY)
|
||||
{
|
||||
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.
|
||||
|
||||
void updateObjectLocalRotation (const Ptr& ptr);
|
||||
void updateObjectScale(const Ptr& ptr);
|
||||
|
||||
bool isCellActive(const CellStore &cell);
|
||||
|
||||
|
|
|
@ -1254,12 +1254,8 @@ namespace MWWorld
|
|||
void World::scaleObject (const Ptr& ptr, float scale)
|
||||
{
|
||||
ptr.getCellRef().setScale(scale);
|
||||
ptr.getClass().adjustScale(ptr,scale);
|
||||
|
||||
if(ptr.getRefData().getBaseNode() == 0)
|
||||
return;
|
||||
mRendering->scaleObject(ptr, osg::Vec3f(scale,scale,scale));
|
||||
//mPhysics->scaleObject(ptr);
|
||||
mWorldScene->updateObjectScale(ptr);
|
||||
}
|
||||
|
||||
void World::rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust)
|
||||
|
@ -1307,9 +1303,7 @@ namespace MWWorld
|
|||
|
||||
ptr.getRefData().setPosition(pos);
|
||||
|
||||
if(ptr.getRefData().getBaseNode() == 0)
|
||||
return;
|
||||
|
||||
if(ptr.getRefData().getBaseNode() != 0)
|
||||
mWorldScene->updateObjectLocalRotation(ptr);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue