Page MenuHomeWildfire Games

Improve splash damage falloff calculation to account somewhat for obstruction size
ClosedPublic

Authored by wraitii on Aug 17 2020, 12:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Sep 21, 3:41 PM
Unknown Object (File)
Wed, Sep 18, 1:57 AM
Unknown Object (File)
Sat, Sep 14, 2:27 AM
Unknown Object (File)
Tue, Sep 10, 1:34 PM
Unknown Object (File)
Aug 24 2024, 7:56 AM
Unknown Object (File)
Aug 24 2024, 7:56 AM
Unknown Object (File)
Aug 24 2024, 7:56 AM
Unknown Object (File)
Aug 24 2024, 7:55 AM
Subscribers
None

Details

Summary

As noted in D2759, splash calculates falloff based on centre-to-point distance, which is somewhat incorrect -> it ought to use nearest-edge-to-point distance.

This:

  • cleans up GetUnitSize for just GetSize (unrelated in this iteration of the patch but I noticed it while working on this)
  • Uses DistanceToPoint to calculate an exact distance for falloff
  • Makes sure the damage multiplier cannot be below 0.

The change to DistanceToPoint might be controversial - it's certainly slower, but for buildings it's required.

Test Plan

Check that the new maths is correct and agree that this new behaviour is preferable.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
temp
Lint
Lint Passed
SeverityLocationCodeMessage
Warningbinaries/data/mods/public/simulation/components/Trader.js:84ESLintBear (semi)ESLintBear (semi)
Warningbinaries/data/mods/public/simulation/components/Trader.js:84JSHintBearJSHintBear
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:207ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:208ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:209ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:303ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:304ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:305ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:306ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:307ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:308ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:536ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:537ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:642ESLintBear (quote-props)ESLintBear (quote-props)
Warningbinaries/data/mods/public/simulation/components/tests/test_Damage.js:643ESLintBear (quote-props)ESLintBear (quote-props)
Unit
No Test Coverage
Build Status
Buildable 12906
Build 25343: Vulcan BuildJenkins
Build 25342: Vulcan Build (macOS)Jenkins
Build 25341: Vulcan Build (Windows)Jenkins
Build 25340: arc lint + arc unit

Event Timeline

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:154:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.
builderr-release-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:154:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1358/display/redirect

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:154:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.
builderr-release-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:154:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1359/display/redirect

Good use of those range functions imo.

Some small stuffs, otherwise good to go:

./source/simulation2/components/tests/test_ObstructionManager.h has a GetUnitRadius reference. Straightforward nuke

binaries/data/mods/public/simulation/components/Trader.js
301

could add spaces while at it

binaries/data/mods/public/simulation/components/tests/test_Builder.js
80

can nuke a .0 while at it

binaries/data/mods/public/simulation/components/tests/test_Damage.js
207

Make the linter happy, by quoting the object keys

209

weird that the linter doesn't complain about trailing comma's

303

Please some linter

binaries/data/mods/public/simulation/helpers/Attacking.js
310

I believe this reason not to be accurate. The reason it can become negative is the rangemanager returning to many to far away entities (due to square/circular shape mismatch)

This revision is now accepted and ready to land.Aug 25 2020, 1:55 PM
binaries/data/mods/public/simulation/helpers/Attacking.js
310

Mh, that's kind of what I meant here. I'll clarify.

@bb's comments + Rebased.

Will commit once lights are green.

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:155:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.
builderr-release-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:155:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1446/display/redirect