This commit is contained in:
davidmarr 2024-11-24 13:20:32 +01:00
commit 4195bc042a
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 vehicle transfer not happening for levels which were not previously visited.
* Fixed audio tracks placed in subfolders not restoring after loading savegame. * 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 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 scripted input events not registering on the same game frame.
* Fixed incorrect object camera position. * Fixed incorrect object camera position.
* Fixed incorrect camera movement near walls after leaving look mode. * 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->numBounces = 0;
fragment->color = isStatic ? mesh->color : item->color; fragment->color = isStatic ? mesh->color : item->color;
fragment->lightMode = fragmentsMesh->lightMode; fragment->lightMode = fragmentsMesh->lightMode;
fragment->UpdateTransform();
fragment->StoreInterpolationData();
} }
} }
} }
@ -259,9 +262,7 @@ void UpdateDebris()
deb.numBounces++; deb.numBounces++;
} }
auto translation = Matrix::CreateTranslation(deb.worldPosition.x, deb.worldPosition.y, deb.worldPosition.z); deb.UpdateTransform();
auto rotation = Matrix::CreateFromQuaternion(deb.rotation);
deb.Transform = rotation * translation;
} }
} }
} }

View file

@ -73,6 +73,13 @@ struct DebrisFragment
Matrix PrevTransform = Matrix::Identity; 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() void StoreInterpolationData()
{ {
PrevTransform = Transform; PrevTransform = Transform;

View file

@ -8,33 +8,21 @@
namespace TEN::Math::Random 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) return (Engine() / (Engine.max() / (high - low + 1) + 1) + low);
{
TENLog("Attempted to generate integer with minimum value greater than maximum value.", LogLevel::Warning);
return min;
} }
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) return (short)GenerateInt(low, high);
{
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);
} }
Vector2 GenerateDirection2D() Vector2 GenerateDirection2D()

View file

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

View file

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