mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-05 16:34:30 +00:00
Get physics fps delta time from physics system
This commit is contained in:
parent
57280eaf9d
commit
aae21c6f53
6 changed files with 16 additions and 16 deletions
|
|
@ -481,6 +481,8 @@ namespace MWBase
|
||||||
virtual float getSunVisibility() const = 0;
|
virtual float getSunVisibility() const = 0;
|
||||||
virtual float getSunPercentage() const = 0;
|
virtual float getSunPercentage() const = 0;
|
||||||
|
|
||||||
|
virtual float getPhysicsFrameRateDT() const = 0;
|
||||||
|
|
||||||
virtual bool findInteriorPositionInWorldSpace(const MWWorld::CellStore* cell, osg::Vec3f& result) = 0;
|
virtual bool findInteriorPositionInWorldSpace(const MWWorld::CellStore* cell, osg::Vec3f& result) = 0;
|
||||||
|
|
||||||
/// Teleports \a ptr to the closest reference of \a id (e.g. DivineMarker, PrisonMarker, TempleMarker)
|
/// Teleports \a ptr to the closest reference of \a id (e.g. DivineMarker, PrisonMarker, TempleMarker)
|
||||||
|
|
|
||||||
|
|
@ -287,6 +287,8 @@ namespace MWPhysics
|
||||||
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
|
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
|
||||||
void reportCollision(const btVector3& position, const btVector3& normal);
|
void reportCollision(const btVector3& position, const btVector3& normal);
|
||||||
|
|
||||||
|
float mPhysicsDt;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateWater();
|
void updateWater();
|
||||||
|
|
||||||
|
|
@ -330,8 +332,6 @@ namespace MWPhysics
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> mParentNode;
|
osg::ref_ptr<osg::Group> mParentNode;
|
||||||
|
|
||||||
float mPhysicsDt;
|
|
||||||
|
|
||||||
std::size_t mSimulationsCounter = 0;
|
std::size_t mSimulationsCounter = 0;
|
||||||
std::array<std::vector<Simulation>, 2> mSimulations;
|
std::array<std::vector<Simulation>, 2> mSimulations;
|
||||||
std::vector<std::pair<MWWorld::Ptr, osg::Vec3f>> mActorsPositions;
|
std::vector<std::pair<MWWorld::Ptr, osg::Vec3f>> mActorsPositions;
|
||||||
|
|
|
||||||
|
|
@ -1587,8 +1587,6 @@ namespace MWSound
|
||||||
: SoundOutput(mgr)
|
: SoundOutput(mgr)
|
||||||
, mDevice(nullptr)
|
, mDevice(nullptr)
|
||||||
, mContext(nullptr)
|
, mContext(nullptr)
|
||||||
, mListenerPos(0.0f, 0.0f, 0.0f)
|
|
||||||
, mListenerVel(0.0f, 0.0f, 0.0f)
|
|
||||||
, mListenerEnv(Env_Normal)
|
, mListenerEnv(Env_Normal)
|
||||||
, mWaterFilter(0)
|
, mWaterFilter(0)
|
||||||
, mWaterEffect(0)
|
, mWaterEffect(0)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/misc/resourcehelpers.hpp>
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
#include <components/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
#include <components/misc/strings/conversion.hpp>
|
|
||||||
#include <components/settings/values.hpp>
|
#include <components/settings/values.hpp>
|
||||||
#include <components/vfs/manager.hpp>
|
#include <components/vfs/manager.hpp>
|
||||||
#include <components/vfs/pathutil.hpp>
|
#include <components/vfs/pathutil.hpp>
|
||||||
|
|
@ -43,8 +42,6 @@ namespace MWSound
|
||||||
constexpr float sSfxFadeOutDuration = 1.0f;
|
constexpr float sSfxFadeOutDuration = 1.0f;
|
||||||
constexpr float sSoundCullDistance = 2000.f;
|
constexpr float sSoundCullDistance = 2000.f;
|
||||||
|
|
||||||
float physicsFramerate = 60.f;
|
|
||||||
|
|
||||||
WaterSoundUpdaterSettings makeWaterSoundUpdaterSettings()
|
WaterSoundUpdaterSettings makeWaterSoundUpdaterSettings()
|
||||||
{
|
{
|
||||||
WaterSoundUpdaterSettings settings;
|
WaterSoundUpdaterSettings settings;
|
||||||
|
|
@ -142,13 +139,6 @@ namespace MWSound
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const char* env = getenv("OPENMW_PHYSICS_FPS"))
|
|
||||||
{
|
|
||||||
if (const auto physFramerate = Misc::StringUtils::toNumeric<float>(env);
|
|
||||||
physFramerate.has_value() && *physFramerate > 0)
|
|
||||||
physicsFramerate = *physFramerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> names = mOutput->enumerate();
|
std::vector<std::string> names = mOutput->enumerate();
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
|
|
||||||
|
|
@ -991,7 +981,9 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
sound->setLastPosition(sound->getPosition());
|
sound->setLastPosition(sound->getPosition());
|
||||||
sound->setPosition(ptr.getRefData().getPosition().asVec3());
|
sound->setPosition(ptr.getRefData().getPosition().asVec3());
|
||||||
sound->setVelocity((sound->getPosition() - sound->getLastPosition()) * physicsFramerate);
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||||
|
sound->setVelocity(
|
||||||
|
(sound->getPosition() - sound->getLastPosition()) / world->getPhysicsFrameRateDT());
|
||||||
}
|
}
|
||||||
|
|
||||||
cull3DSound(sound);
|
cull3DSound(sound);
|
||||||
|
|
@ -1031,7 +1023,8 @@ namespace MWSound
|
||||||
sound->setLastPosition(sound->getPosition());
|
sound->setLastPosition(sound->getPosition());
|
||||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||||
sound->setPosition(world->getActorHeadTransform(ptr).getTrans());
|
sound->setPosition(world->getActorHeadTransform(ptr).getTrans());
|
||||||
sound->setVelocity((sound->getPosition() - sound->getLastPosition()) * physicsFramerate);
|
sound->setVelocity(
|
||||||
|
(sound->getPosition() - sound->getLastPosition()) / world->getPhysicsFrameRateDT());
|
||||||
}
|
}
|
||||||
|
|
||||||
cull3DSound(sound);
|
cull3DSound(sound);
|
||||||
|
|
|
||||||
|
|
@ -3152,6 +3152,11 @@ namespace MWWorld
|
||||||
return mWeatherManager->getSunPercentage(getTimeStamp().getHour());
|
return mWeatherManager->getSunPercentage(getTimeStamp().getHour());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float World::getPhysicsFrameRateDT() const
|
||||||
|
{
|
||||||
|
return mPhysics->mPhysicsDt;
|
||||||
|
}
|
||||||
|
|
||||||
bool World::findInteriorPositionInWorldSpace(const MWWorld::CellStore* cell, osg::Vec3f& result)
|
bool World::findInteriorPositionInWorldSpace(const MWWorld::CellStore* cell, osg::Vec3f& result)
|
||||||
{
|
{
|
||||||
if (cell->isExterior())
|
if (cell->isExterior())
|
||||||
|
|
|
||||||
|
|
@ -576,6 +576,8 @@ namespace MWWorld
|
||||||
float getSunVisibility() const override;
|
float getSunVisibility() const override;
|
||||||
float getSunPercentage() const override;
|
float getSunPercentage() const override;
|
||||||
|
|
||||||
|
float getPhysicsFrameRateDT() const override;
|
||||||
|
|
||||||
bool findInteriorPositionInWorldSpace(const MWWorld::CellStore* cell, osg::Vec3f& result) override;
|
bool findInteriorPositionInWorldSpace(const MWWorld::CellStore* cell, osg::Vec3f& result) override;
|
||||||
|
|
||||||
/// Teleports \a ptr to the closest reference of \a id (e.g. DivineMarker, PrisonMarker, TempleMarker)
|
/// Teleports \a ptr to the closest reference of \a id (e.g. DivineMarker, PrisonMarker, TempleMarker)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue