Skip to content

refactor(baseheightmap): Extract scorch rendering from BaseHeightMap into new W3DScorch - #3017

Open
stephanmeesters wants to merge 1 commit into
TheSuperHackers:mainfrom
stephanmeesters:refactor/scorches
Open

refactor(baseheightmap): Extract scorch rendering from BaseHeightMap into new W3DScorch#3017
stephanmeesters wants to merge 1 commit into
TheSuperHackers:mainfrom
stephanmeesters:refactor/scorches

Conversation

@stephanmeesters

Copy link
Copy Markdown
  • Extracts the scorch rendering code into its own class W3DScorch
  • Usages of the macro DO_SCORCH have mostly been removed
  • Disabling DO_SCORCH before didn't compile but this has been fixed. Scorches are now disabled using W3DScorchDummy when using DO_SCORCH=0
  • W3DScorchDummy could be used in headless mode (not part of this PR)

N.B. some code was in DO_SCORCH that didn't actually belong inside the macro, for example Real m_curImpassableSlope;

@stephanmeesters stephanmeesters added the Refactor Edits the code with insignificant behavior changes, is never user facing label Jul 27, 2026
@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR extracts terrain-scorch ownership and rendering from BaseHeightMap into W3DScorch.

  • Adds W3DScorch and its no-op W3DScorchDummy implementation.
  • Delegates scorch allocation, invalidation, storage, and drawing from BaseHeightMap.
  • Updates flat and regular height-map render paths to use the delegated renderer.
  • Registers the new source and header in the GameEngineDevice target.

Confidence Score: 4/5

The PR appears safe to merge, with only the previously reported unreachable disabled-scorch branch remaining.

The rendering refactor preserves the active scorch path, while the no-op implementation remains inaccessible because the feature macro is still hardcoded on.

Files Needing Attention: Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h; Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp

Important Files Changed

Filename Overview
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DScorch.cpp Implements the extracted scorch lifecycle, geometry generation, and draw submission.
Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DScorch.h Defines the real and no-op scorch-rendering implementations.
Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp Replaces embedded scorch state and behavior with delegation to the new renderer.
Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h Removes embedded scorch data and exposes the delegated draw entry point.
Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp Routes flat-terrain scorch drawing through BaseHeightMap.
Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp Routes regular-terrain scorch drawing through BaseHeightMap.
Core/GameEngineDevice/CMakeLists.txt Adds the extracted scorch implementation to the device-library sources.

Sequence Diagram

sequenceDiagram
    participant Terrain as HeightMap Render
    participant Base as BaseHeightMap
    participant Scorch as W3DScorch
    participant Map as WorldHeightMap
    participant DX8 as DX8Wrapper
    Terrain->>Base: drawScorches()
    Base->>Scorch: drawScorches(map)
    Scorch->>Map: read terrain heights and flip state
    Scorch->>Scorch: rebuild vertex/index buffers when invalidated
    Scorch->>DX8: bind buffers, shader, and texture
    Scorch->>DX8: Draw_Triangles()
Loading

Reviews (2): Last reviewed commit: "refactor(baseheightmap): Extract scorch ..." | Re-trigger Greptile

Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DScorch.cpp
Comment thread Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. I do not see error.

{
public:
void allocateScorchBuffers() override {}
void freeBuffers() override {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you removed "Scorch" from function name but not from the others. I suggest keep consistent either way.

{
return;
}
if (!map)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe test this outside of this function and pass WorldHeightMap as reference?

m_shroud = nullptr;
#if ENABLE_CONFIGURABLE_SHROUD
if (TheGlobalData->m_shroudOn)
m_shroud = NEW W3DShroud;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else
m_shroud = nullptr;

Int m_scorchesInBuffer; ///< how many are in the buffers. If less than numScorches, we need to update
};

class W3DScorchDummy : public W3DScorch

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make a proper interface, then the dummy does not need to carry all the members of W3DScorch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants