unify(ww3d2): Merge SortingRenderer and move to Core#2772
unify(ww3d2): Merge SortingRenderer and move to Core#2772stephanmeesters wants to merge 2 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp | Moved from GeneralsMD and refactored: TempIndexStruct now carries z, specialized Sort with median-of-three, fast particle path, memcpy-based vertex copy, and _EnableTriangleDraw wrapping around Flush_Sorting_Pool — the else branch that calls Draw_Triangles directly is still unguarded (pre-existing comment). |
| Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.h | Moved from GeneralsMD to Core unchanged; public interface is identical to both Generals and GeneralsMD versions. |
| Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt | Uncomments sortingrenderer.cpp and sortingrenderer.h so Core now builds both files. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt | Comments out sortingrenderer entries so Generals no longer builds its own copy. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt | Comments out sortingrenderer entries so GeneralsMD no longer builds its own copy. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["SortingRendererClass::Flush()"] --> B["while sorted_list not empty"]
B --> C{"sorting buffer\ntype?"}
C -- "SORTING / DYNAMIC_SORTING" --> D["Insert_To_Sorting_Pool(state)"]
C -- "other" --> E["DX8Wrapper::Draw_Triangles (unguarded)"]
D --> F["overlapping_nodes[]\noverlapping counts updated"]
B -- "list empty" --> G["Save old _EnableTriangleDraw\nSet _EnableTriangleDraw"]
G --> H["Flush_Sorting_Pool()"]
H --> I["Get_Temp_Index_Array()\nmemcpy vertices to dynamic VB"]
I --> J{"identity-like\nworld-view?"}
J -- "yes (fast path)" --> K["tis.z = raw vertex z avg"]
J -- "no" --> L["tis.z = full matrix transform avg"]
K --> M["Sort(tis, tis + count)\nmedian-of-three quicksort"]
L --> M
M --> N["Fill dynamic IB\nApply_Render_State per group\nDraw_Triangles"]
N --> O["Release refs / clean list"]
O --> P["Restore old _EnableTriangleDraw"]
H --> P
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp:135
**`if` body on same line as condition**
The body of this `if` is on the same line as the condition. Per the codebase convention, statement bodies should go on the next line to allow precise debugger breakpoint placement. Prefer:
```
if (right < left)
break;
```
Reviews (3): Last reviewed commit: "unify(ww3d2): Move SortingRenderer to Co..." | Re-trigger Greptile
xezon
left a comment
There was a problem hiding this comment.
The bot has a complain about something. Commit titles need pull ids.
This is fine, |
|
Fair point — if it's a debug tool scoped to the sorting renderer's pooled path, that behavior is correct by design. I'll withdraw that concern. |
a660cf2 to
f898980
Compare
Merge by rebase
Added to Generals
A refactor that moves separate arrays to a struct, as well as performance and memory improvements.
In detail:
zdepth intoTempIndexStruct— removed separatepolygon_z_array,node_id_array,polygon_index_arrayand their allocators;z, node ID, and triangle indices now live together in one struct<,<=,>,>=,==) toTempIndexStructkeyed onzQuickSort/InsertionSort/Sort<T,K>) with a specialized sort onTempIndexStruct*using median-of-three partitioning and sorting smaller subarray firstmemcpyinstead of per-vertex loop with matrix transformz_isnan/_finite) on computed triangle z-depth with debug assertFlush_Sorting_Poolwith_Enable_Triangle_Drawto respect the enable/disable stateShortVectorIStructconstructors (default and parameterized)Sorting renderer is involved with rendering particles in the right order, so I did this test with a bunch of particles (alpha and additive), they looked the same before and after so I think we're good: