Skip to content

bugfix(worldbuilder): Fix optimized trees not being shown in object placer preview window#2312

Open
ViTeXFTW wants to merge 3 commits intoTheSuperHackers:mainfrom
ViTeXFTW:bugfix/tree-preview-object-placer
Open

bugfix(worldbuilder): Fix optimized trees not being shown in object placer preview window#2312
ViTeXFTW wants to merge 3 commits intoTheSuperHackers:mainfrom
ViTeXFTW:bugfix/tree-preview-object-placer

Conversation

@ViTeXFTW
Copy link

@ViTeXFTW ViTeXFTW commented Feb 15, 2026

Description
When making Zero Hour the devs created an optimized module (W3DTreeDraw) for drawing trees. They forgot to add the preview handling in WorldBuilder to handle this new draw type, which results in the preview not showing anything when having an object of the W3DTreeDraw module selected.

Root Cause
WorldBuilder attempts to get the module data for getting the model name of the object. However the format of the W3DModelDraw module data and W3DTreeDraw module data are different and there is not an exposed and generic way to get the information without explicitly casting the data to the expected type (W3DModelDrawModuleData or W3DTreeDrawModuleData).

Fix
Added a fallback function call to get the W3DTreeDrawModuleData if the normal W3DModelDraw fails which preserves the original behavior and also enables preview of tree types.

Old:
image

New:
image

TODO

  • Replicate in Generals

@greptile-apps
Copy link

greptile-apps bot commented Feb 15, 2026

Greptile Summary

Adds a fallback in WbView3d::getBestModelName() to handle W3DTreeDraw module data when the primary W3DModelDraw lookup fails. This fixes the WorldBuilder object placer preview not rendering tree objects that use the optimized W3DTreeDraw draw module introduced in Zero Hour.

  • Adds #include "W3DDevice/GameClient/Module/W3DTreeDraw.h" to access W3DTreeDrawModuleData
  • After the existing getAsW3DModelDrawModuleData() check fails, attempts getAsW3DTreeDrawModuleData() and returns m_modelName directly
  • Follows the same virtual dispatch pattern already used in WbView3d::updateTrees() (line 1024) for tree module data access

Confidence Score: 5/5

  • This PR is safe to merge — it's a minimal, well-scoped bugfix that follows existing codebase patterns.
  • The change adds a simple fallback lookup for W3DTreeDrawModuleData using the same virtual dispatch pattern already established in the codebase (e.g., in updateTrees()). The null check is correct, the include is appropriate, and the change preserves existing behavior for all non-tree objects. No new risks introduced.
  • No files require special attention.

Important Files Changed

Filename Overview
GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp Adds W3DTreeDraw.h include and a fallback tree data lookup in getBestModelName() to display tree object previews in WorldBuilder. Clean, minimal change following existing codebase patterns.

Flowchart

flowchart TD
    A["getBestModelName(tt, c)"] --> B{tt != nullptr?}
    B -- No --> G["return TheEmptyString"]
    B -- Yes --> C["Get draw module info\nmdd = mi.getNthData(0)"]
    C --> D{"mdd->getAsW3DModelDrawModuleData()\nreturns non-null?"}
    D -- Yes --> E["return md->getBestModelNameForWB(c)"]
    D -- No --> F{"mdd->getAsW3DTreeDrawModuleData()\nreturns non-null?"}
    F -- Yes --> H["return treeData->m_modelName"]
    F -- No --> G

    style F fill:#2d6,stroke:#1a4,color:#fff
    style H fill:#2d6,stroke:#1a4,color:#fff
Loading

Last reviewed commit: d91a333

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Fix makes sense.

Code style can be polished.

@xezon xezon added Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker WorldBuilder Relates to World Builder labels Feb 15, 2026
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Needs to be replicated in Generals

@xezon xezon changed the title bugfix(worldbuilder): fix optimized trees not being shown in object placer preview window bugfix(worldbuilder): Fix optimized trees not being shown in object placer preview window Feb 16, 2026
@ViTeXFTW
Copy link
Author

Needs to be replicated in Generals

This is not an issue in Generals as it didn't have the optimized treee - only zero hour issue

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

Labels

Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker WorldBuilder Relates to World Builder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worldbuilder: Bug: Optimization made for trees in ZH broke the w3d model preview under ZH worldbuilder

2 participants