Skip to content

performance(Drawable): Rework for IterateDrawablesInRegion Functions for both GameClient and W3DView to be more Efficient#2044

Open
IamInnocent3X wants to merge 1 commit intoTheSuperHackers:mainfrom
IamInnocent3X:EffectiveIterateDrawablesInRegion
Open

performance(Drawable): Rework for IterateDrawablesInRegion Functions for both GameClient and W3DView to be more Efficient#2044
IamInnocent3X wants to merge 1 commit intoTheSuperHackers:mainfrom
IamInnocent3X:EffectiveIterateDrawablesInRegion

Conversation

@IamInnocent3X
Copy link
Copy Markdown

@IamInnocent3X IamInnocent3X commented Jan 1, 2026

To use the features, RETAIL_COMPATIBLE_DRAWUPDATE must be set to 0. The feature is Retail Xfer Compatible, but might require checking. RETAIL_COMPATIBLE_DRAWUPDATE can be removed once the check is done.

  • GameClient: Informs whenever a New Drawable has been registered or a Drawable has Moved. If the Drawable is within the Screen Region, it will be registered onto a Drawable List. The List is reset everytime the Camera Moves or a Stealthed Object has been Detected, or a Unit has Transitioned a Disguise. Resetting means it will reiterate the Drawable List from the first and registers Drawables that fits within the Screen onto the List.

Above directly addresses the Issue - #1502

  • W3DView: Used for Selecting. Edited Function converts the Selection Region onto a Radius and gets its Center, then uses Partition Manager to find List of Drawables within the Region. Has a configured minimum Iterate Radius of 200.0f units as a Requirement to Select Airborne Units when selecting with a small region.

@IamInnocent3X IamInnocent3X changed the title performance(Drawables): Edited IterateDrawablesInRegion Functions for both GameClient and W3DView to be more Efficient performance(Drawables): Rework for IterateDrawablesInRegion Functions for both GameClient and W3DView to be more Efficient Jan 1, 2026
@IamInnocent3X IamInnocent3X changed the title performance(Drawables): Rework for IterateDrawablesInRegion Functions for both GameClient and W3DView to be more Efficient performance(Drawable): Rework for IterateDrawablesInRegion Functions for both GameClient and W3DView to be more Efficient Jan 1, 2026
Copy link
Copy Markdown

@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.

I glanced over it and I see it does add quite a bit of complexity and GameClient is now at the mercy of other systems properly registering and unregistering drawables. The first question here is, does the Game (and WorldBuilder?) still work normal? The second question is, how big are the performance gains here? If you can, please provide frame ms time comparison.

Code needs cleaning. No commented and compiled out code should be left.

normalizedRegion.lo.x = (INT_TO_REAL(screenRegion->lo.x - m_originX) / INT_TO_REAL(getWidth())) * 2.0f - 1.0f;
normalizedRegion.lo.y = -((INT_TO_REAL(screenRegion->hi.y - m_originY) / INT_TO_REAL(getHeight())) * 2.0f - 1.0f);
normalizedRegion.hi.x = (INT_TO_REAL(screenRegion->hi.x - m_originX) / INT_TO_REAL(getWidth())) * 2.0f - 1.0f;
normalizedRegion.hi.y = -((INT_TO_REAL(screenRegion->lo.y - m_originY) / INT_TO_REAL(getHeight())) * 2.0f - 1.0f);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Better keep the (Real) cast.

@xezon xezon added Major Severity: Minor < Major < Critical < Blocker Performance Is a performance concern Gen Relates to Generals ZH Relates to Zero Hour labels Jan 11, 2026
@IamInnocent3X
Copy link
Copy Markdown
Author

IamInnocent3X commented Jan 12, 2026

The code is tested playing against multiple AIs in Skirmish on both Vanilla and Contra Mod with both Saving and Loading, so it should be fine in game.

I haven't tested on WorldBuilder, but it should not have any issues. Moving the camera or Adjusting the Positions should account whether an object is within the screen region for iteration.

I will have to check for the performance gains, but I do notice it being a bit lag-free during the testing sessions.

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

Labels

Gen Relates to Generals Major Severity: Minor < Major < Critical < Blocker Performance Is a performance concern ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants