Check whether model is empty before trying to insert object

pull/3226/head
elsid 3 years ago committed by jvoisin
parent 964f288c13
commit 6e0d660dd5

@ -45,8 +45,7 @@ namespace MWClass
void Activator::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const
{
if(!model.empty())
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
}
std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const

@ -24,12 +24,9 @@ namespace MWClass
void Actor::insertObject(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const
{
if (!model.empty())
{
physics.addActor(ptr, model);
if (getCreatureStats(ptr).isDead() && getCreatureStats(ptr).isDeathAnimationFinished())
MWBase::Environment::get().getWorld()->enableActorCollision(ptr, false);
}
physics.addActor(ptr, model);
if (getCreatureStats(ptr).isDead() && getCreatureStats(ptr).isDeathAnimationFinished())
MWBase::Environment::get().getWorld()->enableActorCollision(ptr, false);
}
bool Actor::useAnim() const

@ -111,8 +111,7 @@ namespace MWClass
void Container::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const
{
if(!model.empty())
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
}
std::string Container::getModel(const MWWorld::ConstPtr &ptr) const

@ -72,8 +72,7 @@ namespace MWClass
void Door::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const
{
if(!model.empty())
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_Door);
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_Door);
}
bool Door::isDoor() const

@ -50,7 +50,7 @@ namespace MWClass
void Light::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const
{
// TODO: add option somewhere to enable collision for placeable objects
if (!model.empty() && (ptr.get<ESM::Light>()->mBase->mData.mFlags & ESM::Light::Carry) == 0)
if ((ptr.get<ESM::Light>()->mBase->mData.mFlags & ESM::Light::Carry) == 0)
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
}

@ -30,8 +30,7 @@ namespace MWClass
void Static::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string& model, const osg::Quat& rotation, MWPhysics::PhysicsSystem& physics) const
{
if(!model.empty())
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
physics.addObject(ptr, model, rotation, MWPhysics::CollisionType_World);
}
std::string Static::getModel(const MWWorld::ConstPtr &ptr) const

@ -125,7 +125,8 @@ namespace
// Restore effect particles
MWBase::Environment::get().getWorld()->applyLoopingParticles(ptr);
ptr.getClass().insertObject (ptr, model, rotation, physics);
if (!model.empty())
ptr.getClass().insertObject(ptr, model, rotation, physics);
MWBase::Environment::get().getLuaManager()->objectAddedToScene(ptr);
}
@ -584,10 +585,14 @@ namespace MWWorld
if(ptr.mRef->mData.mPhysicsPostponed)
{
ptr.mRef->mData.mPhysicsPostponed = false;
if(ptr.mRef->mData.isEnabled() && ptr.mRef->mData.getCount() > 0) {
if (ptr.mRef->mData.isEnabled() && ptr.mRef->mData.getCount() > 0)
{
std::string model = getModel(ptr, MWBase::Environment::get().getResourceSystem()->getVFS());
const auto rotation = makeNodeRotation(ptr, RotationOrder::direct);
ptr.getClass().insertObjectPhysics(ptr, model, rotation, *mPhysics);
if (!model.empty())
{
const auto rotation = makeNodeRotation(ptr, RotationOrder::direct);
ptr.getClass().insertObjectPhysics(ptr, model, rotation, *mPhysics);
}
}
}
return true;

Loading…
Cancel
Save