From 75494a501a48fe6af5f769c9861070776503e1e0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 12 May 2020 16:58:27 -0400 Subject: [PATCH] CFluidPlaneCPU: Early exit in CTurbulence constructor Allows unindenting code. --- Runtime/World/CFluidPlaneCPU.cpp | 42 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/Runtime/World/CFluidPlaneCPU.cpp b/Runtime/World/CFluidPlaneCPU.cpp index 2f872c65d..7a6fb50bf 100644 --- a/Runtime/World/CFluidPlaneCPU.cpp +++ b/Runtime/World/CFluidPlaneCPU.cpp @@ -25,27 +25,29 @@ CFluidPlaneCPU::CTurbulence::CTurbulence(float speed, float distance, float freq , x1c_amplitudeMin(amplitudeMin) , x2c_ooTurbSpeed(1.f / x0_speed) , x30_ooTurbDistance(1.f / x4_distance) { - if (x18_amplitudeMax != 0.f || x1c_amplitudeMin != 0.f) { - x24_tableCount = kTableSize; - x28_heightSelPitch = x24_tableCount; - x20_table.reset(new float[x24_tableCount]); - const float anglePitch = 2.f * M_PIF / x28_heightSelPitch; - const float freqConstant = 0.5f * (x8_freqMax + xc_freqMin); - const float freqLinear = 0.5f * (x8_freqMax - xc_freqMin); - const float phaseConstant = 0.5f * (x10_phaseMax + x14_phaseMin); - const float phaseLinear = 0.5f * (x10_phaseMax - x14_phaseMin); - const float amplitudeConstant = 0.5f * (x18_amplitudeMax + x1c_amplitudeMin); - const float amplitudeLinear = 0.5f * (x18_amplitudeMax - x1c_amplitudeMin); - - float curAng = 0.f; - for (size_t i = 0; i < x24_tableCount; ++i, curAng += anglePitch) { - const float angCos = std::cos(curAng); - x20_table[i] = (amplitudeLinear * angCos + amplitudeConstant) * - std::sin((freqLinear * angCos + freqConstant) * curAng + (phaseLinear * angCos + phaseConstant)); - } - - x34_hasTurbulence = true; + if (x18_amplitudeMax == 0.f && x1c_amplitudeMin == 0.f) { + return; } + + x24_tableCount = kTableSize; + x28_heightSelPitch = x24_tableCount; + x20_table.reset(new float[x24_tableCount]); + const float anglePitch = 2.f * M_PIF / x28_heightSelPitch; + const float freqConstant = 0.5f * (x8_freqMax + xc_freqMin); + const float freqLinear = 0.5f * (x8_freqMax - xc_freqMin); + const float phaseConstant = 0.5f * (x10_phaseMax + x14_phaseMin); + const float phaseLinear = 0.5f * (x10_phaseMax - x14_phaseMin); + const float amplitudeConstant = 0.5f * (x18_amplitudeMax + x1c_amplitudeMin); + const float amplitudeLinear = 0.5f * (x18_amplitudeMax - x1c_amplitudeMin); + + float curAng = 0.f; + for (size_t i = 0; i < x24_tableCount; ++i, curAng += anglePitch) { + const float angCos = std::cos(curAng); + x20_table[i] = (amplitudeLinear * angCos + amplitudeConstant) * + std::sin((freqLinear * angCos + freqConstant) * curAng + (phaseLinear * angCos + phaseConstant)); + } + + x34_hasTurbulence = true; } CFluidPlaneCPU::CFluidPlaneCPU(CAssetId texPattern1, CAssetId texPattern2, CAssetId texColor, CAssetId bumpMap,