Implement proper actor/component lifecycle #9

Closed
opened 2022-02-22 00:06:48 +00:00 by keith · 3 comments
Owner

Currently, the lifecycle described in Scene-Actor-Component model is not actually properly implemented. Specifically, (resume) and (activate) are not called as described during initialization.

To implement this lifecycle, actors should not be properly added to their scenes (via [scene (add-actor)]) immediately after they are created. Instead, a new function should be called to properly initialize them, after all their components and children have been attached.

Currently, the lifecycle described in [Scene-Actor-Component model](https://bytes.keithhacks.cyou/keith/wh-engine/wiki/Scene-Actor-Component-model#lifecycle) is not actually properly implemented. Specifically, `(resume)` and `(activate)` are not called as described during initialization. To implement this lifecycle, actors should *not* be properly added to their scenes (via `[scene (add-actor)]`) immediately after they are created. Instead, a new function should be called to properly initialize them, after all their components and children have been attached.
keith added the
missing
label 2022-02-22 00:06:48 +00:00
keith self-assigned this 2022-02-22 00:16:48 +00:00
Author
Owner

The (attach-actor-to-world) functionality can probably be done in [scene (add-actor)] instead?

Also, (parent-activated) and (parent-deactivated) should be rolled into the standard (activate)/(deactivate) methods, with some parameter to specify whether it's being called manually or due to a parent changing activation state.

The `(attach-actor-to-world)` functionality can probably be done in `[scene (add-actor)]` instead? Also, `(parent-activated)` and `(parent-deactivated)` should be rolled into the standard `(activate)`/`(deactivate)` methods, with some parameter to specify whether it's being called manually or due to a parent changing activation state.
Author
Owner

Actually, (attach-actor-to-world) can't really be moved into [scene (add-actor)] because that would also be called when moving an already-initialized actor between scenes.

Actually, `(attach-actor-to-world)` can't really be moved into `[scene (add-actor)]` because that would also be called when moving an already-initialized actor between scenes.
Author
Owner

Okay so there's an unpredictable bug where (weak-pointer-value child-ptr) will return nil in #[actor (apply-to-tree)]. This happens when garbage collection occurs after the actors have been created in memory, but before (initialize-actors-in) has completed. During this time, the child actors are only referenced by a weak-pointer in their parent, so they are garbage collected. Not entirely sure how to fix this.

Okay so there's an unpredictable bug where `(weak-pointer-value child-ptr)` will return `nil` in `#[actor (apply-to-tree)]`. This happens when garbage collection occurs after the actors have been created in memory, but before `(initialize-actors-in)` has completed. During this time, the child actors are only referenced by a weak-pointer in their parent, so they are garbage collected. Not entirely sure how to fix this.
keith closed this issue 2022-02-22 19:03:01 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: keith/wh-engine#9
No description provided.