1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-17 14:16:37 +00:00

Get physics fps delta time from physics system

This commit is contained in:
epochwon 2025-07-30 14:51:18 -04:00
parent 57280eaf9d
commit aae21c6f53
6 changed files with 16 additions and 16 deletions

View file

@ -481,6 +481,8 @@ namespace MWBase
virtual float getSunVisibility() const = 0;
virtual float getSunPercentage() const = 0;
virtual float getPhysicsFrameRateDT() const = 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)

View file

@ -287,6 +287,8 @@ namespace MWPhysics
void reportStats(unsigned int frameNumber, osg::Stats& stats) const;
void reportCollision(const btVector3& position, const btVector3& normal);
float mPhysicsDt;
private:
void updateWater();
@ -330,8 +332,6 @@ namespace MWPhysics
osg::ref_ptr<osg::Group> mParentNode;
float mPhysicsDt;
std::size_t mSimulationsCounter = 0;
std::array<std::vector<Simulation>, 2> mSimulations;
std::vector<std::pair<MWWorld::Ptr, osg::Vec3f>> mActorsPositions;

View file

@ -1587,8 +1587,6 @@ namespace MWSound
: SoundOutput(mgr)
, mDevice(nullptr)
, mContext(nullptr)
, mListenerPos(0.0f, 0.0f, 0.0f)
, mListenerVel(0.0f, 0.0f, 0.0f)
, mListenerEnv(Env_Normal)
, mWaterFilter(0)
, mWaterEffect(0)

View file

@ -10,7 +10,6 @@
#include <components/debug/debuglog.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/misc/rng.hpp>
#include <components/misc/strings/conversion.hpp>
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/pathutil.hpp>
@ -43,8 +42,6 @@ namespace MWSound
constexpr float sSfxFadeOutDuration = 1.0f;
constexpr float sSoundCullDistance = 2000.f;
float physicsFramerate = 60.f;
WaterSoundUpdaterSettings makeWaterSoundUpdaterSettings()
{
WaterSoundUpdaterSettings settings;
@ -142,13 +139,6 @@ namespace MWSound
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::stringstream stream;
@ -991,7 +981,9 @@ namespace MWSound
{
sound->setLastPosition(sound->getPosition());
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);
@ -1031,7 +1023,8 @@ namespace MWSound
sound->setLastPosition(sound->getPosition());
MWBase::World* world = MWBase::Environment::get().getWorld();
sound->setPosition(world->getActorHeadTransform(ptr).getTrans());
sound->setVelocity((sound->getPosition() - sound->getLastPosition()) * physicsFramerate);
sound->setVelocity(
(sound->getPosition() - sound->getLastPosition()) / world->getPhysicsFrameRateDT());
}
cull3DSound(sound);

View file

@ -3152,6 +3152,11 @@ namespace MWWorld
return mWeatherManager->getSunPercentage(getTimeStamp().getHour());
}
float World::getPhysicsFrameRateDT() const
{
return mPhysics->mPhysicsDt;
}
bool World::findInteriorPositionInWorldSpace(const MWWorld::CellStore* cell, osg::Vec3f& result)
{
if (cell->isExterior())

View file

@ -576,6 +576,8 @@ namespace MWWorld
float getSunVisibility() const override;
float getSunPercentage() const override;
float getPhysicsFrameRateDT() const 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)