Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plWaveSet7 UB. #977

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,18 +1304,6 @@ void plWaveSet7::IInitState()

void plWaveSet7::IInitWaveConsts()
{
// See header for what fS, fK and fD actually mean.
WaveK waveKs[] = {
// fS fK fD
{ 1.f, 5.f, 0.f },
{ 1.f, 10.f, 2.f },
{ -1.f, 20.f, -9.f },
{ 1.f, 30.f, 16.f }
};
int i;
for( i = 0; i < kNumTexWaves; i++ )
fWaveKs[i] = waveKs[i];

TexWaveWindDep windDeps[] = {
// WindSpeed, Height, Specular
{ 0.f, 0.01f, 1.f },
Expand All @@ -1326,7 +1314,7 @@ void plWaveSet7::IInitWaveConsts()
{ 25.f, 0.1f, 0.3f }
};

for( i = 0; i < kNumWindDep; i++ )
for (size_t i = 0; i < kNumWindDep; i++)
fWindDeps[i] = windDeps[i];

ISetupTextureWaves();
Expand Down
16 changes: 0 additions & 16 deletions Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,6 @@ class plWaveSet7 : public plWaveSetBase

GraphState fGraphState[kGraphShorePasses];

class WaveK
{
public:
// fK is the number of times the sine wave repeats across the texture. Must be an integer
// fS/fK is the base X component of the direction of the wave, with Y = 1.f - X. Note that X^2 + Y^2 != 1.
// fD allows the wave to get more off the Y direction
// So the X component will be Int(fS + fD*dispersion) / fK, because it must be an integer ratio to
// preserve tiling. Also, (fS + fD) must be <= fK (for the Y normalization).
// See the notes.
float fS;
float fK;
float fD;
};

WaveK fWaveKs[kNumTexWaves];

class TexWaveDesc
{
public:
Expand Down