Repository navigation
fix(camera): handle camera object replacement - #14
Merged
Merged
Conversation
The game can swap the active camera's underlying object without changing its type (e.g. switching trucks in the interior view). Track the live object in `GameCameraManager` and re-activate the camera when it changes so writes target the new object. Store default state per object and forget it when the object is replaced.
Owner
|
Thanks for finding this, merging! |
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SPF keeps the address of the game's camera object and only re-reads it when the camera type changes. When the game replaces the object without changing the type (e.g. switching trucks in the interior view), SPF kept writing to the old, freed object:
ACCESS_VIOLATIONinspf-framework.dll).Changes
GameCameraManager::Update()asks the game for the active camera's live object every frame. If it changed, the camera is re-activated on the new object (oneInfolog line).ActivateCamera(), which also refreshes the verified-camera cache so cameras reading it (Free camera) get the same object.IGameCamera::ForgetDefaults().m_defaultsSaved, hiding the one inIGameCamera:HasSavedDefaults()always returned false andStoreDefaultState()ran every frame. The duplicates are removed.Every camera's
OnDeactivate()only clears its pointer, so deactivating a camera whose object is already freed is safe.Testing