Merge branch 'MontyTRC89:develop' into develop

This commit is contained in:
davidmarr 2024-11-24 13:15:38 +01:00 committed by GitHub
commit 5e87ac32e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 23 additions and 29 deletions

View file

@ -20,6 +20,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
* Fixed vehicle transfer not happening for levels which were not previously visited.
* Fixed audio tracks placed in subfolders not restoring after loading savegame.
* Fixed initial position and lack of fade-in for looped audio track on level start.
* Fixed shatter debris spawning on incorrect position for the first frame.
* Fixed scripted input events not registering on the same game frame.
* Fixed incorrect object camera position.
* Fixed incorrect camera movement near walls after leaving look mode.

View file

@ -183,6 +183,9 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num, short roomNumbe
fragment->numBounces = 0;
fragment->color = isStatic ? mesh->color : item->color;
fragment->lightMode = fragmentsMesh->lightMode;
fragment->UpdateTransform();
fragment->StoreInterpolationData();
}
}
}
@ -259,9 +262,7 @@ void UpdateDebris()
deb.numBounces++;
}
auto translation = Matrix::CreateTranslation(deb.worldPosition.x, deb.worldPosition.y, deb.worldPosition.z);
auto rotation = Matrix::CreateFromQuaternion(deb.rotation);
deb.Transform = rotation * translation;
deb.UpdateTransform();
}
}
}

View file

@ -73,6 +73,13 @@ struct DebrisFragment
Matrix PrevTransform = Matrix::Identity;
void UpdateTransform()
{
auto translation = Matrix::CreateTranslation(worldPosition.x, worldPosition.y, worldPosition.z);
auto rot = Matrix::CreateFromQuaternion(rotation);
Transform = rot * translation;
}
void StoreInterpolationData()
{
PrevTransform = Transform;

View file

@ -8,33 +8,21 @@
namespace TEN::Math::Random
{
static auto Generator = std::mt19937();
static std::mt19937 Engine;
int GenerateInt(int min, int max)
int GenerateInt(int low, int high)
{
if (min >= max)
{
TENLog("Attempted to generate integer with minimum value greater than maximum value.", LogLevel::Warning);
return min;
return (Engine() / (Engine.max() / (high - low + 1) + 1) + low);
}
return (((Generator() / (Generator.max()) / (max - min + 1)) + 1) + min);
float GenerateFloat(float low, float high)
{
return ((high - low) * Engine() / Engine.max() + low);
}
float GenerateFloat(float min, float max)
short GenerateAngle(short low, short high)
{
if (min >= max)
{
TENLog("Attempted to generate float with minimum value greater than maximum value.", LogLevel::Warning);
return min;
}
return ((((max - min) * Generator()) / Generator.max()) + min);
}
short GenerateAngle(short min, short max)
{
return (short)GenerateInt(min, min);
return (short)GenerateInt(low, high);
}
Vector2 GenerateDirection2D()

View file

@ -6,9 +6,9 @@ namespace TEN::Math::Random
{
// Value generation
int GenerateInt(int min = 0, int max = SHRT_MAX);
float GenerateFloat(float min = 0.0f, float max = 1.0f);
short GenerateAngle(short min = SHRT_MIN, short max = SHRT_MAX);
int GenerateInt(int low = 0, int high = SHRT_MAX);
float GenerateFloat(float low = 0.0f, float high = 1.0f);
short GenerateAngle(short low = SHRT_MIN, short high = SHRT_MAX);
// 2D geometric generation

View file

@ -1088,10 +1088,7 @@ int GetShatterSound(int shatterID)
if (fxID != NO_VALUE && fxID < NUM_SFX)
return fxID;
if (shatterID < 3)
return SFX_TR5_SMASH_WOOD;
else
return SFX_TR4_SMASH_ROCK;
}
void PlaySoundSources()