-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Python Components start method issues with getSceneList() & createConstraint() #335
Comments
This is because the objects present in a scene are created before the scene is first added.
|
Precision: I marked it as a bug because it makes my blender crash at ge start. |
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.
@panzergame : The crash is fixed for me. I have this error in the console in Maujoe test file: Blender Game Engine Started but I don't know if this is a bug or only due to a wrong usage of start method. |
@youle31 : Iirc it's because |
I notice that the start method of the python components has some issus in upbge.
When I call bge.logic.getSceneList() in the start method it return an empty list.
The same happends with bge.constraints.createConstraint(..) that return None.
In the update method everything works right.
Here is a file:
components_start_bug.zip
When I use agoose77's Addon (https://blenderartists.org/forum/showthread.php?393763-Python-Components-Addon) I have no issues with the start method.
I know nothing about the bge code but I think it could be a timing problem in the Initialization state or something like that.
The text was updated successfully, but these errors were encountered: