-
Notifications
You must be signed in to change notification settings - Fork 141
performance(Drawable): Adjusts Turret Positioning, Recoil and Muzzle for Model Draw to Update Only when Necessary #2046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…Update when Necessary
Skyaero42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any indication on the performance gain?
This may need extensive testing for mismatching.
| //------------------------------------------------------------------------------------------------- | ||
| void W3DModelDraw::setNeedUpdateTurretPositioning(Bool set) | ||
| { | ||
| m_needUpdateTurretPosition = set; // A simple function with the dangers of an atomic bomb, misuse and it'll cause desync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment not necessary.
| if( xfer->getXferMode() == XFER_LOAD && m_subObjectVec.empty() == FALSE ) | ||
| updateSubObjects(); | ||
|
|
||
| #if !RETAIL_COMPATIBLE_CRC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this require a xfer version change?
I am not sure, but the devs does mention it being not a major problem. Line handleClientRecoil function are majority just For Loop Checks, each time checks with for loops based on how many Maximum Weapons are in game, (In this case, 3), and checks for each Weapon Slot whether there are any recoil to handle. If it does, it handles the Model Bone Recoil and handles their Muzzle from showing. Every Barrel Bone present will require checks. handleClientTurretPositioning however, is O(n) based. It calls for all Turrets for each Weapon Slot to update Every Frame regardless if there are any changes. For each turret in the runtime it calls for AIUpdateInterface to get their Turret Pitch and Angle, then Transforms the Matrix up to 2 Times (One for Angle, One for Pitch). This is called every frame. The changes just add a go/stop variable at the beginning of both functions, (m_doHandleRecoil, and m_needUpdateTurretPosition) to inform W3DModelDraw to allow the calling of the respective functions. |
|
I think this can be simplified by removing the changes to xfer and instead forcing a recompute right after you load the savegame, like this (do test it): diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
@@ void Object::loadPostProcess()
if( m_xferContainedByID != INVALID_ID )
m_containedBy = TheGameLogic->findObjectByID(m_xferContainedByID);
else
m_containedBy = NULL;
+
+ setNeedUpdateTurretPositioning(TRUE);diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/
Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
@@ void W3DModelDraw::loadPostProcess( void )
// extend base class
DrawModule::loadPostProcess();
+
+ m_needUpdateTurretPosition = TRUE;
+ m_doHandleRecoil = TRUE;This may change the CRC right after loading a savegame but I don't see how that would be a problem |
This change seems logical, tested on my end from loading a retail compatible save and it seems fine. I'll adjust and update my commit. |
Modifies the GameLogic to tell handleClientTurretPositioning() and handleClientRecoil() function in W3DModelDraw to only update when Necessary.