mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-12 21:31:43 +00:00
Merge pull request #788 from Laupetin/fix/iw4-physpreset-clamping
fix: iw4 physpreset clamping
This commit is contained in:
@@ -206,6 +206,7 @@ namespace IW5
|
|||||||
float mass;
|
float mass;
|
||||||
float bounce;
|
float bounce;
|
||||||
float friction;
|
float friction;
|
||||||
|
int isFrictionInfinity;
|
||||||
float bulletForceScale;
|
float bulletForceScale;
|
||||||
float explosiveForceScale;
|
float explosiveForceScale;
|
||||||
const char* sndAliasPrefix;
|
const char* sndAliasPrefix;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace IW5
|
|||||||
{"mass", offsetof(PhysPresetInfo, mass), CSPFT_FLOAT },
|
{"mass", offsetof(PhysPresetInfo, mass), CSPFT_FLOAT },
|
||||||
{"bounce", offsetof(PhysPresetInfo, bounce), CSPFT_FLOAT },
|
{"bounce", offsetof(PhysPresetInfo, bounce), CSPFT_FLOAT },
|
||||||
{"friction", offsetof(PhysPresetInfo, friction), CSPFT_FLOAT },
|
{"friction", offsetof(PhysPresetInfo, friction), CSPFT_FLOAT },
|
||||||
|
{"isFrictionInfinity", offsetof(PhysPresetInfo, isFrictionInfinity), CSPFT_QBOOLEAN},
|
||||||
{"bulletForceScale", offsetof(PhysPresetInfo, bulletForceScale), CSPFT_FLOAT },
|
{"bulletForceScale", offsetof(PhysPresetInfo, bulletForceScale), CSPFT_FLOAT },
|
||||||
{"explosiveForceScale", offsetof(PhysPresetInfo, explosiveForceScale), CSPFT_FLOAT },
|
{"explosiveForceScale", offsetof(PhysPresetInfo, explosiveForceScale), CSPFT_FLOAT },
|
||||||
{"sndAliasPrefix", offsetof(PhysPresetInfo, sndAliasPrefix), CSPFT_STRING },
|
{"sndAliasPrefix", offsetof(PhysPresetInfo, sndAliasPrefix), CSPFT_STRING },
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ namespace
|
|||||||
|
|
||||||
void CopyFromPhysPresetInfo(const PhysPresetInfo& physPresetInfo, PhysPreset& physPreset)
|
void CopyFromPhysPresetInfo(const PhysPresetInfo& physPresetInfo, PhysPreset& physPreset)
|
||||||
{
|
{
|
||||||
physPreset.mass = std::clamp(physPresetInfo.mass, 1.0f, 2000.0f) * 0.001f;
|
physPreset.mass = physPresetInfo.mass;
|
||||||
physPreset.bounce = physPresetInfo.bounce;
|
physPreset.bounce = physPresetInfo.bounce;
|
||||||
|
|
||||||
if (physPresetInfo.isFrictionInfinity != 0)
|
if (physPresetInfo.isFrictionInfinity != 0)
|
||||||
physPreset.friction = std::numeric_limits<float>::infinity();
|
physPreset.friction = std::numeric_limits<float>::max();
|
||||||
else
|
else
|
||||||
physPreset.friction = physPresetInfo.friction;
|
physPreset.friction = physPresetInfo.friction;
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,12 @@ namespace
|
|||||||
{
|
{
|
||||||
physPreset.mass = physPresetInfo.mass;
|
physPreset.mass = physPresetInfo.mass;
|
||||||
physPreset.bounce = physPresetInfo.bounce;
|
physPreset.bounce = physPresetInfo.bounce;
|
||||||
|
|
||||||
|
if (physPresetInfo.isFrictionInfinity != 0)
|
||||||
|
physPreset.friction = std::numeric_limits<float>::max();
|
||||||
|
else
|
||||||
physPreset.friction = physPresetInfo.friction;
|
physPreset.friction = physPresetInfo.friction;
|
||||||
|
|
||||||
physPreset.bulletForceScale = physPresetInfo.bulletForceScale;
|
physPreset.bulletForceScale = physPresetInfo.bulletForceScale;
|
||||||
physPreset.explosiveForceScale = physPresetInfo.explosiveForceScale;
|
physPreset.explosiveForceScale = physPresetInfo.explosiveForceScale;
|
||||||
physPreset.sndAliasPrefix = physPresetInfo.sndAliasPrefix;
|
physPreset.sndAliasPrefix = physPresetInfo.sndAliasPrefix;
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ namespace
|
|||||||
|
|
||||||
void CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo)
|
void CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo)
|
||||||
{
|
{
|
||||||
physPresetInfo->mass = std::clamp(physPreset->mass * 1000.0f, 1.0f, 2000.0f);
|
physPresetInfo->mass = physPreset->mass;
|
||||||
physPresetInfo->bounce = physPreset->bounce;
|
physPresetInfo->bounce = physPreset->bounce;
|
||||||
|
|
||||||
if (std::isinf(physPreset->friction))
|
if (physPreset->friction >= std::numeric_limits<float>::max())
|
||||||
{
|
{
|
||||||
physPresetInfo->isFrictionInfinity = 1;
|
physPresetInfo->isFrictionInfinity = 1;
|
||||||
physPresetInfo->friction = 0;
|
physPresetInfo->friction = 0;
|
||||||
|
|||||||
@@ -47,7 +47,18 @@ namespace
|
|||||||
{
|
{
|
||||||
physPresetInfo->mass = physPreset->mass;
|
physPresetInfo->mass = physPreset->mass;
|
||||||
physPresetInfo->bounce = physPreset->bounce;
|
physPresetInfo->bounce = physPreset->bounce;
|
||||||
|
|
||||||
|
if (physPreset->friction >= std::numeric_limits<float>::max())
|
||||||
|
{
|
||||||
|
physPresetInfo->isFrictionInfinity = 1;
|
||||||
|
physPresetInfo->friction = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
physPresetInfo->isFrictionInfinity = 0;
|
||||||
physPresetInfo->friction = physPreset->friction;
|
physPresetInfo->friction = physPreset->friction;
|
||||||
|
}
|
||||||
|
|
||||||
physPresetInfo->bulletForceScale = physPreset->bulletForceScale;
|
physPresetInfo->bulletForceScale = physPreset->bulletForceScale;
|
||||||
physPresetInfo->explosiveForceScale = physPreset->explosiveForceScale;
|
physPresetInfo->explosiveForceScale = physPreset->explosiveForceScale;
|
||||||
physPresetInfo->sndAliasPrefix = physPreset->sndAliasPrefix;
|
physPresetInfo->sndAliasPrefix = physPreset->sndAliasPrefix;
|
||||||
|
|||||||
Reference in New Issue
Block a user