-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPBGE: Initialize components during first update.
Previously, components were initialized independently of the component update. This operation was made in the conversion and in the object replication, but some issues were noticed: in case of libloading the component must be run in an unmerged scene but they have to acces to the new scene. The workaround was to bind the final scene before initialize the python component, but this solution is unstable. To avoid this problematic case, the components could be initialized at the begining of theirs first update. As we ensure that the update is independent of the lib loading and the object creation. To realize this solution, the conversion from blender struct PythonComponent to KX_PythonComponent previously made in KX_GameObject::InitComponents() is now moves in the converter function: BL_ConvertComponentsObject. This function converts all the components, put them in a list and set the list to the game object thanks to KX_GameObject::SetComponents(…). This conversion is made only for objects converted and doesn't manage the duplicated object. These duplicated objects must use a new python component with the same python proxy subclassing. To do so the function GetReplica() in KX_PythonComponent is overrided. This function is used when the game object component list is replicated, in the same time each component remap their game object owner. The initialization is made in KX_PythonComponent::Start when the member m_init is checked to false in Update(). But the components have to know which blender component they are using and which game object is owning them. To answer this problem the new setter SetBlenderPythonComponent is called in the same time of SetGameObject when the components are converted. The initialization is now independent of libloading but not about object duplication. To avoid issues iterating on the list of objects which can be modified, a second list is made in KX_Scene::LogicUpdateFrame containing all the objects using a component at the begining of the frame update. Added object will be update in the next frame as before. Reported by Maujoe in #335.
- Loading branch information
1 parent
20be643
commit 814afdf
Showing
6 changed files
with
204 additions
and
174 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.