1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-28 22:09:42 +00:00

Merge branch openmw:master into mwdialogue-bindings

This commit is contained in:
trav 2024-04-28 10:34:21 +00:00
commit c6807465f6
11 changed files with 78 additions and 78 deletions

View file

@ -275,10 +275,13 @@ namespace
if (mAdvanceSimulation) if (mAdvanceSimulation)
{ {
MWWorld::Ptr standingOn; MWWorld::Ptr standingOn;
auto* ptrHolder if (frameData.mStandingOn != nullptr)
= static_cast<MWPhysics::PtrHolder*>(scheduler->getUserPointer(frameData.mStandingOn)); {
if (ptrHolder) auto* const ptrHolder
standingOn = ptrHolder->getPtr(); = static_cast<MWPhysics::PtrHolder*>(scheduler->getUserPointer(frameData.mStandingOn));
if (ptrHolder != nullptr)
standingOn = ptrHolder->getPtr();
}
actor->setStandingOnPtr(standingOn); actor->setStandingOnPtr(standingOn);
// the "on ground" state of an actor might have been updated by a traceDown, don't overwrite the // the "on ground" state of an actor might have been updated by a traceDown, don't overwrite the
// change // change
@ -650,15 +653,15 @@ namespace MWPhysics
void PhysicsTaskScheduler::addCollisionObject( void PhysicsTaskScheduler::addCollisionObject(
btCollisionObject* collisionObject, int collisionFilterGroup, int collisionFilterMask) btCollisionObject* collisionObject, int collisionFilterGroup, int collisionFilterMask)
{ {
mCollisionObjects.insert(collisionObject);
MaybeExclusiveLock lock(mCollisionWorldMutex, mLockingPolicy); MaybeExclusiveLock lock(mCollisionWorldMutex, mLockingPolicy);
mCollisionObjects.insert(collisionObject);
mCollisionWorld->addCollisionObject(collisionObject, collisionFilterGroup, collisionFilterMask); mCollisionWorld->addCollisionObject(collisionObject, collisionFilterGroup, collisionFilterMask);
} }
void PhysicsTaskScheduler::removeCollisionObject(btCollisionObject* collisionObject) void PhysicsTaskScheduler::removeCollisionObject(btCollisionObject* collisionObject)
{ {
mCollisionObjects.erase(collisionObject);
MaybeExclusiveLock lock(mCollisionWorldMutex, mLockingPolicy); MaybeExclusiveLock lock(mCollisionWorldMutex, mLockingPolicy);
mCollisionObjects.erase(collisionObject);
mCollisionWorld->removeCollisionObject(collisionObject); mCollisionWorld->removeCollisionObject(collisionObject);
} }

View file

@ -113,19 +113,29 @@ namespace Bsa
input.read(reinterpret_cast<char*>(header), 16); input.read(reinterpret_cast<char*>(header), 16);
input.read(reinterpret_cast<char*>(&fileTableOffset), 8); input.read(reinterpret_cast<char*>(&fileTableOffset), 8);
if (header[0] == 0x00415342) /*"BSA\x00"*/ if (header[0] != ESM::fourCC("BTDX"))
fail("Unrecognized compressed BSA format"); fail("Unrecognized BA2 signature");
mVersion = header[1]; mVersion = header[1];
if (mVersion != 0x01 /*FO4*/ && mVersion != 0x02 /*Starfield*/) switch (static_cast<BA2Version>(mVersion))
fail("Unrecognized compressed BSA version"); {
case BA2Version::Fallout4:
case BA2Version::Fallout4NextGen_v7:
case BA2Version::Fallout4NextGen_v8:
break;
case BA2Version::StarfieldDDS:
uint64_t dummy;
input.read(reinterpret_cast<char*>(&dummy), 8);
uint32_t compressionMethod;
input.read(reinterpret_cast<char*>(&compressionMethod), 4);
if (compressionMethod == 3)
fail("Unsupported LZ4-compressed DDS BA2");
break;
default:
fail("Unrecognized DDS BA2 version");
}
type = header[2]; type = header[2];
fileCount = header[3]; fileCount = header[3];
if (mVersion == 0x02)
{
uint64_t dummy;
input.read(reinterpret_cast<char*>(&dummy), 8);
}
} }
if (type == ESM::fourCC("DX10")) if (type == ESM::fourCC("DX10"))

View file

@ -8,6 +8,15 @@ namespace Bsa
{ {
uint32_t generateHash(const std::string& name); uint32_t generateHash(const std::string& name);
uint32_t generateExtensionHash(std::string_view extension); uint32_t generateExtensionHash(std::string_view extension);
enum class BA2Version : std::uint32_t
{
Fallout4 = 1,
StarfieldGeneral = 2,
StarfieldDDS = 3,
Fallout4NextGen_v7 = 7,
Fallout4NextGen_v8 = 8,
};
} }
#endif #endif

View file

@ -107,19 +107,25 @@ namespace Bsa
input.read(reinterpret_cast<char*>(header), 16); input.read(reinterpret_cast<char*>(header), 16);
input.read(reinterpret_cast<char*>(&fileTableOffset), 8); input.read(reinterpret_cast<char*>(&fileTableOffset), 8);
if (header[0] == 0x00415342) /*"BSA\x00"*/ if (header[0] != ESM::fourCC("BTDX"))
fail("Unrecognized compressed BSA format"); fail("Unrecognized BA2 signature");
mVersion = header[1]; mVersion = header[1];
if (mVersion != 0x01 /*FO4*/ && mVersion != 0x02 /*Starfield*/) switch (static_cast<BA2Version>(mVersion))
fail("Unrecognized compressed BSA version"); {
case BA2Version::Fallout4:
case BA2Version::Fallout4NextGen_v7:
case BA2Version::Fallout4NextGen_v8:
break;
case BA2Version::StarfieldGeneral:
uint64_t dummy;
input.read(reinterpret_cast<char*>(&dummy), 8);
break;
default:
fail("Unrecognized general BA2 version");
}
type = header[2]; type = header[2];
fileCount = header[3]; fileCount = header[3];
if (mVersion == 0x02)
{
uint64_t dummy;
input.read(reinterpret_cast<char*>(&dummy), 8);
}
} }
if (type == ESM::fourCC("GNRL")) if (type == ESM::fourCC("GNRL"))

View file

@ -340,18 +340,18 @@ BsaVersion Bsa::BSAFile::detectVersion(const std::filesystem::path& filePath)
return BsaVersion::Uncompressed; return BsaVersion::Uncompressed;
} }
if (head[0] == static_cast<uint32_t>(BsaVersion::Compressed) || head[0] == ESM::fourCC("BTDX")) if (head[0] == static_cast<uint32_t>(BsaVersion::Compressed))
{ {
if (head[1] == static_cast<uint32_t>(0x01))
{
if (head[2] == ESM::fourCC("GNRL"))
return BsaVersion::BA2GNRL;
if (head[2] == ESM::fourCC("DX10"))
return BsaVersion::BA2DX10;
return BsaVersion::Unknown;
}
return BsaVersion::Compressed; return BsaVersion::Compressed;
} }
if (head[0] == ESM::fourCC("BTDX"))
{
if (head[2] == ESM::fourCC("GNRL"))
return BsaVersion::BA2GNRL;
if (head[2] == ESM::fourCC("DX10"))
return BsaVersion::BA2DX10;
}
return BsaVersion::Unknown; return BsaVersion::Unknown;
} }

View file

@ -325,7 +325,7 @@ namespace Nif
{ {
nif->read(mSubsurfaceRolloff); nif->read(mSubsurfaceRolloff);
nif->read(mRimlightPower); nif->read(mRimlightPower);
if (nif->getBethVersion() == 130 && mRimlightPower == std::numeric_limits<float>::max()) if (mRimlightPower == std::numeric_limits<float>::max())
nif->read(mBacklightPower); nif->read(mBacklightPower);
} }

View file

@ -74,10 +74,7 @@ namespace SceneUtil
else else
mShadowTechnique->disableFrontFaceCulling(); mShadowTechnique->disableFrontFaceCulling();
if (settings.mAllowShadowMapOverlap) mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::CASCADED);
mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::CASCADED);
else
mShadowSettings->setMultipleShadowMapHint(osgShadow::ShadowSettings::PARALLEL_SPLIT);
if (settings.mEnableDebugHud) if (settings.mEnableDebugHud)
mShadowTechnique->enableDebugHUD(); mShadowTechnique->enableDebugHUD();
@ -161,8 +158,6 @@ namespace SceneUtil
definesWithShadows["shadow_texture_unit_list"] = definesWithShadows["shadow_texture_unit_list"].substr( definesWithShadows["shadow_texture_unit_list"] = definesWithShadows["shadow_texture_unit_list"].substr(
0, definesWithShadows["shadow_texture_unit_list"].length() - 1); 0, definesWithShadows["shadow_texture_unit_list"].length() - 1);
definesWithShadows["shadowMapsOverlap"] = settings.mAllowShadowMapOverlap ? "1" : "0";
definesWithShadows["useShadowDebugOverlay"] = settings.mEnableDebugOverlay ? "1" : "0"; definesWithShadows["useShadowDebugOverlay"] = settings.mEnableDebugOverlay ? "1" : "0";
// switch this to reading settings if it's ever exposed to the user // switch this to reading settings if it's ever exposed to the user
@ -186,8 +181,6 @@ namespace SceneUtil
definesWithoutShadows["shadow_texture_unit_list"] = ""; definesWithoutShadows["shadow_texture_unit_list"] = "";
definesWithoutShadows["shadowMapsOverlap"] = "0";
definesWithoutShadows["useShadowDebugOverlay"] = "0"; definesWithoutShadows["useShadowDebugOverlay"] = "0";
definesWithoutShadows["perspectiveShadowMaps"] = "0"; definesWithoutShadows["perspectiveShadowMaps"] = "0";

View file

@ -23,7 +23,6 @@ namespace Settings
makeClampSanitizerInt(1, 8) }; makeClampSanitizerInt(1, 8) };
SettingValue<float> mMaximumShadowMapDistance{ mIndex, "Shadows", "maximum shadow map distance" }; SettingValue<float> mMaximumShadowMapDistance{ mIndex, "Shadows", "maximum shadow map distance" };
SettingValue<float> mShadowFadeStart{ mIndex, "Shadows", "shadow fade start", makeClampSanitizerFloat(0, 1) }; SettingValue<float> mShadowFadeStart{ mIndex, "Shadows", "shadow fade start", makeClampSanitizerFloat(0, 1) };
SettingValue<bool> mAllowShadowMapOverlap{ mIndex, "Shadows", "allow shadow map overlap" };
SettingValue<float> mSplitPointUniformLogarithmicRatio{ mIndex, "Shadows", SettingValue<float> mSplitPointUniformLogarithmicRatio{ mIndex, "Shadows",
"split point uniform logarithmic ratio", makeClampSanitizerFloat(0, 1) }; "split point uniform logarithmic ratio", makeClampSanitizerFloat(0, 1) };
SettingValue<float> mSplitPointBias{ mIndex, "Shadows", "split point bias" }; SettingValue<float> mSplitPointBias{ mIndex, "Shadows", "split point bias" };

View file

@ -55,17 +55,6 @@ This setting has no effect if the maximum shadow map distance is non-positive (i
This setting can be controlled in the Settings tab of the launcher. This setting can be controlled in the Settings tab of the launcher.
allow shadow map overlap
------------------------
:Type: boolean
:Range: True/False
:Default: True
If true, allow shadow maps to overlap.
Counter-intuitively, will produce much better results when the light is behind the camera.
When enabled, OpenMW uses Cascaded Shadow Maps and when disabled, it uses Parallel Split Shadow Maps.
enable debug hud enable debug hud
---------------- ----------------

View file

@ -1016,9 +1016,6 @@ maximum shadow map distance = 8192
# Fraction of the maximum distance at which shadows begin to gradually fade away. # Fraction of the maximum distance at which shadows begin to gradually fade away.
shadow fade start = 0.9 shadow fade start = 0.9
# If true, allow shadow maps to overlap. Counter-intuitively, will produce better results when the light is behind the camera. When enabled, OpenMW uses Cascaded Shadow Maps and when disabled, it uses Parallel Split Shadow Maps.
allow shadow map overlap = true
# Indirectly controls where to split the shadow map(s). Values closer to 1.0 bring more detail closer to the camera (potentially excessively so), and values closer to 0.0 spread it more evenly across the whole viewing distance. 0.5 is recommended for most viewing distances by the original Parallel Split Shadow Maps paper, but this does not take into account use of a Light Space Perspective transformation, so other values may be preferable. If some of the terms used here go over your head, you might not want to change this, especially not without reading the associated papers first. When "allow shadow map overlap" is combined with a higher-than-default viewing distance, values closer to 1.0 will prevent nearby shadows losing a lot of quality. # Indirectly controls where to split the shadow map(s). Values closer to 1.0 bring more detail closer to the camera (potentially excessively so), and values closer to 0.0 spread it more evenly across the whole viewing distance. 0.5 is recommended for most viewing distances by the original Parallel Split Shadow Maps paper, but this does not take into account use of a Light Space Perspective transformation, so other values may be preferable. If some of the terms used here go over your head, you might not want to change this, especially not without reading the associated papers first. When "allow shadow map overlap" is combined with a higher-than-default viewing distance, values closer to 1.0 will prevent nearby shadows losing a lot of quality.
split point uniform logarithmic ratio = 0.5 split point uniform logarithmic ratio = 0.5

View file

@ -22,31 +22,25 @@ float unshadowedLightRatio(float distance)
if (fade == 1.0) if (fade == 1.0)
return shadowing; return shadowing;
#endif #endif
#if @shadowMapsOverlap bool doneShadows = false;
bool doneShadows = false; @foreach shadow_texture_unit_index @shadow_texture_unit_list
@foreach shadow_texture_unit_index @shadow_texture_unit_list if (!doneShadows)
if (!doneShadows) {
vec3 shadowXYZ = shadowSpaceCoords@shadow_texture_unit_index.xyz / shadowSpaceCoords@shadow_texture_unit_index.w;
#if @perspectiveShadowMaps
vec3 shadowRegionXYZ = shadowRegionCoords@shadow_texture_unit_index.xyz / shadowRegionCoords@shadow_texture_unit_index.w;
#endif
if (all(lessThan(shadowXYZ.xy, vec2(1.0, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.0, 0.0))))
{ {
vec3 shadowXYZ = shadowSpaceCoords@shadow_texture_unit_index.xyz / shadowSpaceCoords@shadow_texture_unit_index.w; shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing);
#if @perspectiveShadowMaps
vec3 shadowRegionXYZ = shadowRegionCoords@shadow_texture_unit_index.xyz / shadowRegionCoords@shadow_texture_unit_index.w;
#endif
if (all(lessThan(shadowXYZ.xy, vec2(1.0, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.0, 0.0))))
{
shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing);
doneShadows = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0))); doneShadows = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0)));
#if @perspectiveShadowMaps #if @perspectiveShadowMaps
doneShadows = doneShadows && all(lessThan(shadowRegionXYZ, vec3(1.0, 1.0, 1.0))) && all(greaterThan(shadowRegionXYZ.xy, vec2(-1.0, -1.0))); doneShadows = doneShadows && all(lessThan(shadowRegionXYZ, vec3(1.0, 1.0, 1.0))) && all(greaterThan(shadowRegionXYZ.xy, vec2(-1.0, -1.0)));
#endif #endif
}
} }
@endforeach }
#else @endforeach
@foreach shadow_texture_unit_index @shadow_texture_unit_list
shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing);
@endforeach
#endif
#if @limitShadowMapDistance #if @limitShadowMapDistance
shadowing = mix(shadowing, 1.0, fade); shadowing = mix(shadowing, 1.0, fade);
#endif #endif