mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 18:09:39 +00:00
Merge pull request #2343 from Capostrophic/vfx
Tweak object VFX scaling (bug #4989)
This commit is contained in:
commit
df94bfbf29
4 changed files with 15 additions and 31 deletions
|
@ -76,6 +76,7 @@
|
||||||
Bug #4979: AiTravel maximum range depends on "actors processing range" setting
|
Bug #4979: AiTravel maximum range depends on "actors processing range" setting
|
||||||
Bug #4980: Drowning mechanics is applied for actors indifferently from distance to player
|
Bug #4980: Drowning mechanics is applied for actors indifferently from distance to player
|
||||||
Bug #4984: "Friendly hits" feature should be used only for player's followers
|
Bug #4984: "Friendly hits" feature should be used only for player's followers
|
||||||
|
Bug #4989: Object dimension-dependent VFX scaling behavior is inconsistent
|
||||||
Bug #4990: Dead bodies prevent you from hitting
|
Bug #4990: Dead bodies prevent you from hitting
|
||||||
Feature #1774: Handle AvoidNode
|
Feature #1774: Handle AvoidNode
|
||||||
Feature #2229: Improve pathfinding AI
|
Feature #2229: Improve pathfinding AI
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
#include <components/misc/constants.hpp>
|
||||||
#include <components/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
@ -1085,41 +1086,18 @@ namespace MWMechanics
|
||||||
|
|
||||||
std::string texture = effect->mParticle;
|
std::string texture = effect->mParticle;
|
||||||
|
|
||||||
float scale = 1.0f;
|
|
||||||
osg::Vec3f pos (mCaster.getRefData().getPosition().asVec3());
|
osg::Vec3f pos (mCaster.getRefData().getPosition().asVec3());
|
||||||
|
|
||||||
if (animation && mCaster.getClass().isNpc())
|
|
||||||
{
|
|
||||||
// For NPC we should take race height as scaling factor
|
|
||||||
const ESM::NPC *npc = mCaster.get<ESM::NPC>()->mBase;
|
|
||||||
const MWWorld::ESMStore &esmStore =
|
|
||||||
MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
const ESM::Race *race =
|
|
||||||
esmStore.get<ESM::Race>().find(npc->mRace);
|
|
||||||
|
|
||||||
scale = npc->isMale() ? race->mData.mHeight.mMale : race->mData.mHeight.mFemale;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getHalfExtents(mCaster);
|
|
||||||
|
|
||||||
// TODO: take a size of particle or NPC with height and weight = 1.0 as scale = 1.0
|
|
||||||
float scaleX = halfExtents.x() * 2 / 60.f;
|
|
||||||
float scaleY = halfExtents.y() * 2 / 60.f;
|
|
||||||
float scaleZ = halfExtents.z() * 2 / 120.f;
|
|
||||||
|
|
||||||
scale = std::max({ scaleX, scaleY, scaleZ });
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the caster has no animation, add the effect directly to the effectManager
|
|
||||||
if (animation)
|
if (animation)
|
||||||
{
|
{
|
||||||
animation->addEffect("meshes\\" + castStatic->mModel, effect->mIndex, false, "", texture, scale);
|
animation->addEffect("meshes\\" + castStatic->mModel, effect->mIndex, false, "", texture);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We should set scale for effect manager manually
|
// If the caster has no animation, add the effect directly to the effectManager
|
||||||
|
// We should scale it manually
|
||||||
|
osg::Vec3f bounds (MWBase::Environment::get().getWorld()->getHalfExtents(mCaster) * 2.f / Constants::UnitsPerFoot);
|
||||||
|
float scale = std::max({ bounds.x()/3.f, bounds.y()/3.f, bounds.z()/6.f });
|
||||||
float meshScale = !mCaster.getClass().isActor() ? mCaster.getCellRef().getScale() : 1.0f;
|
float meshScale = !mCaster.getClass().isActor() ? mCaster.getCellRef().getScale() : 1.0f;
|
||||||
MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + castStatic->mModel, effect->mParticle, pos, scale * meshScale);
|
MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + castStatic->mModel, effect->mParticle, pos, scale * meshScale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1631,7 +1631,7 @@ namespace MWRender
|
||||||
SceneUtil::addLight(parent, esmLight, Mask_ParticleSystem, Mask_Lighting, exterior);
|
SceneUtil::addLight(parent, esmLight, Mask_ParticleSystem, Mask_Lighting, exterior);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, const std::string& texture, float scale)
|
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, const std::string& texture)
|
||||||
{
|
{
|
||||||
if (!mObjectRoot.get())
|
if (!mObjectRoot.get())
|
||||||
return;
|
return;
|
||||||
|
@ -1663,7 +1663,12 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::PositionAttitudeTransform> trans = new osg::PositionAttitudeTransform;
|
osg::ref_ptr<osg::PositionAttitudeTransform> trans = new osg::PositionAttitudeTransform;
|
||||||
trans->setScale(osg::Vec3f(scale, scale, scale));
|
if (!mPtr.getClass().isNpc())
|
||||||
|
{
|
||||||
|
osg::Vec3f bounds (MWBase::Environment::get().getWorld()->getHalfExtents(mPtr) * 2.f / Constants::UnitsPerFoot);
|
||||||
|
float scale = std::max({ bounds.x()/3.f, bounds.y()/3.f, bounds.z()/6.f });
|
||||||
|
trans->setScale(osg::Vec3f(scale, scale, scale));
|
||||||
|
}
|
||||||
parentNode->addChild(trans);
|
parentNode->addChild(trans);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> node = mResourceSystem->getSceneManager()->getInstance(model, trans);
|
osg::ref_ptr<osg::Node> node = mResourceSystem->getSceneManager()->getInstance(model, trans);
|
||||||
|
|
|
@ -365,7 +365,7 @@ public:
|
||||||
* @param texture override the texture specified in the model's materials - if empty, do not override
|
* @param texture override the texture specified in the model's materials - if empty, do not override
|
||||||
* @note Will not add an effect twice.
|
* @note Will not add an effect twice.
|
||||||
*/
|
*/
|
||||||
void addEffect (const std::string& model, int effectId, bool loop = false, const std::string& bonename = "", const std::string& texture = "", float scale = 1.0f);
|
void addEffect (const std::string& model, int effectId, bool loop = false, const std::string& bonename = "", const std::string& texture = "");
|
||||||
void removeEffect (int effectId);
|
void removeEffect (int effectId);
|
||||||
void removeEffects ();
|
void removeEffects ();
|
||||||
void getLoopingEffects (std::vector<int>& out) const;
|
void getLoopingEffects (std::vector<int>& out) const;
|
||||||
|
|
Loading…
Reference in a new issue