refactor(sphere): Zero initialize SphereClass by default and add Is_Valid function#2855
refactor(sphere): Zero initialize SphereClass by default and add Is_Valid function#2855stephanmeesters wants to merge 3 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WWMath/sphere.h | Default constructor now zero-initialises Center and Radius; adds Is_Valid() (Radius > 0.0); updates Add_Sphere and Add_Spheres to use the new predicate. Minor: Is_Valid uses double literal 0.0 instead of 0.0f. |
| Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp | If/else branches reorganised to test Is_Valid() first; semantics unchanged (Radius > 0 → sorted list, else → unsorted list). Inline SphereClass variable replaced with temporary. |
| Core/Libraries/Source/WWVegas/WW3D2/collect.cpp | SphereClass(Vector3(0,0,0),0) replaced with SphereClass(); semantically identical now that the default constructor zero-initialises members. |
| Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp | Explicit zero-init constructor call replaced with SphereClass(); no behavioural change. |
| Core/Tools/W3DView/ViewerScene.cpp | Explicit SphereClass(Vector3(0,0,0), 0.0f) replaced with SphereClass(); no behavioural change. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp | Removed unused SphereClass local variable and its Get_Obj_Space_Bounding_Sphere call; result was never consumed. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp | Removed three unused SphereClass local variables that were constructed but never read. |
| Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp | Removed unused SphereClass bsphere local variable; was declared but never used. |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp | Mirror of Generals/; removed unused SphereClass bsphere declaration in renderShadows. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp | Mirror of Generals/boxrobj.cpp; removed unused SphereClass variable and Get_Obj_Space_Bounding_Sphere call. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp | Mirror of Generals/dazzle.cpp; removed three unused SphereClass local variables. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Insert_Triangles(bounding_sphere, ...)"] --> B{"bounding_sphere.Is_Valid()\n(Radius > 0.0f)"}
B -- Yes --> C["Transform center via world×view matrix"]
C --> D["Insert_To_Sorted_List(state)"]
B -- No --> E["state->transformed_center = (0,0,0)"]
E --> F["unsorted_list.push_back(state)"]
G["Add_Spheres(s0, s1)"] --> H{"s0.Is_Valid()"}
H -- Yes --> I["result = s0\nresult.Add_Sphere(s1)\nreturn result"]
H -- No --> J["return s1"]
K["SphereClass::Add_Sphere(s)"] --> L{"!s.Is_Valid()"}
L -- Yes --> M["return (no-op)"]
L -- No --> N["Compute enclosing sphere"]
%%{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["Insert_Triangles(bounding_sphere, ...)"] --> B{"bounding_sphere.Is_Valid()\n(Radius > 0.0f)"}
B -- Yes --> C["Transform center via world×view matrix"]
C --> D["Insert_To_Sorted_List(state)"]
B -- No --> E["state->transformed_center = (0,0,0)"]
E --> F["unsorted_list.push_back(state)"]
G["Add_Spheres(s0, s1)"] --> H{"s0.Is_Valid()"}
H -- Yes --> I["result = s0\nresult.Add_Sphere(s1)\nreturn result"]
H -- No --> J["return s1"]
K["SphereClass::Add_Sphere(s)"] --> L{"!s.Is_Valid()"}
L -- Yes --> M["return (no-op)"]
L -- No --> N["Compute enclosing sphere"]
Reviews (3): Last reviewed commit: "Rename IsEmpty to Is_Valid and flip logi..." | 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.
Caball009
left a comment
There was a problem hiding this comment.
I don't really have an opinion on the removal of the EA / Westwood comments, but the code changes look fine to me.
4f6ec5c to
09e0333
Compare
|
|
||
| inline bool SphereClass::Is_Valid() const | ||
| { | ||
| return Radius > 0.0; |
SphereClassto zero-init its members.Is_ValidfunctionRemoves verbose EA comments (2nd commit)SphereClass