refactor(sphere): Zero initialize SphereClass by default and add IsEmpty function#2855
refactor(sphere): Zero initialize SphereClass by default and add IsEmpty function#2855stephanmeesters wants to merge 3 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WWMath/sphere.h | Core change: default constructor now zero-initializes Center and Radius; IsEmpty() added and used in Add_Sphere/Add_Spheres; verbose EA comment blocks removed. Logic is sound. |
| Core/Libraries/Source/WWVegas/WW3D2/collect.cpp | Replaces explicit SphereClass(Vector3(0,0,0),0) with SphereClass() — behaviour identical given the new default constructor. |
| Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp | Trivial call-site cleanup: SphereClass(Vector3(0,0,0),0) → SphereClass(). |
| Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp | Inline temporary SphereClass() replaces named zero-initialized variable; no behaviour change. |
| Core/Tools/W3DView/ViewerScene.cpp | SphereClass accumulator switches to default constructor; functionally identical. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp | Removes an unused SphereClass variable and Get_Obj_Space_Bounding_Sphere call whose result was never read — clean dead code removal. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp | Three unused SphereClass variables (never read after construction) removed in Render_Dazzle. |
| Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp | Removes declared-but-unused SphereClass bsphere variable in renderShadows. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp | Mirror of Generals boxrobj.cpp: same unused SphereClass variable removed. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp | Mirror of Generals dazzle.cpp: three unused SphereClass variables removed. |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp | Mirror of Generals W3DVolumetricShadow.cpp: unused bsphere variable removed. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[SphereClass default ctor\nbefore: uninitialized] -->|PR change| B[SphereClass default ctor\nCenter=0,0,0 Radius=0]
B --> C[IsEmpty: Radius <= 0.0]
C -->|used in| D[Add_Sphere\nold: s.Radius == 0.0f\nnew: s.IsEmpty]
C -->|used in| E[Add_Spheres\nold: s0.Radius == 0.0f\nnew: s0.IsEmpty]
F[Call-site cleanup] --> G[collect.cpp\ndynamesh.cpp\nsortingrenderer.cpp\nViewerScene.cpp\nuse SphereClass instead of\nSphereClass Vector3 0 0 0 0]
H[Dead code removal] --> I[boxrobj.cpp x2\ndazzle.cpp x2\nW3DVolumetricShadow.cpp x2\nunused SphereClass variables\nremoved]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[SphereClass default ctor\nbefore: uninitialized] -->|PR change| B[SphereClass default ctor\nCenter=0,0,0 Radius=0]
B --> C[IsEmpty: Radius <= 0.0]
C -->|used in| D[Add_Sphere\nold: s.Radius == 0.0f\nnew: s.IsEmpty]
C -->|used in| E[Add_Spheres\nold: s0.Radius == 0.0f\nnew: s0.IsEmpty]
F[Call-site cleanup] --> G[collect.cpp\ndynamesh.cpp\nsortingrenderer.cpp\nViewerScene.cpp\nuse SphereClass instead of\nSphereClass Vector3 0 0 0 0]
H[Dead code removal] --> I[boxrobj.cpp x2\ndazzle.cpp x2\nW3DVolumetricShadow.cpp x2\nunused SphereClass variables\nremoved]
Reviews (2): Last reviewed commit: "Remove unused instances of SphereClass" | Re-trigger Greptile
Caball009
left a comment
There was a problem hiding this comment.
While looking at instances of SphereClass I noticed a couple of places where they're unused:
GeneralsGameCode/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp
Lines 514 to 516 in 838f9d0
I realize it's slightly outside the scope of this PR, but perhaps these can be removed as well.
SphereClassto zero-init its members.IsEmptyfunctionSphereClass