Skip to content
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

Occassional Invalid set index 'low_poly' #8

Closed
TheDuckCow opened this issue Oct 19, 2022 · 2 comments · Fixed by #16 or #19
Closed

Occassional Invalid set index 'low_poly' #8

TheDuckCow opened this issue Oct 19, 2022 · 2 comments · Fixed by #16 or #19
Assignees
Labels
bug Something isn't working
Milestone

Comments

@TheDuckCow
Copy link
Owner

Sometimes while moving RoadPoints, there is a bad state where geometry doesn't update, and we get errors like:

res://addons/road-generator/road_network.gd:142 - Invalid set index 'low_poly' (on base: 'null instance') with value of type 'bool'.

My hunch is this is something to do with how the scene-tree initializes, but that would need further verification. When I faced this in the demo project and I opened a new scene and created a network from scratch (using spatials), I did not run into this issue.

Also unsure if related, but occasionally get the error:

res://addons/road-generator/plugin.gd:33 - Attempt to call function 'hide_gizmo' in base 'null instance' on a null instance.

Which again points towards a reference / initialization error, or at least an issue with the plugin's ability to correctly pick up the current state when being triggered to make a change.

@TheDuckCow TheDuckCow added the bug Something isn't working label Oct 19, 2022
@TheDuckCow TheDuckCow added this to the v0.2.0 milestone Oct 19, 2022
@TheDuckCow TheDuckCow self-assigned this Oct 27, 2022
@TheDuckCow
Copy link
Owner Author

Reframing this task to be more about addressing startup issues, such as warnings and errors on open.

On further exploration, it seems to be happening due to a variety of reasons:

  • Warnings on open:
    • At surface value, the warnings are of no concern because they point out valid, impossible auto-texture scenarios. The question is more about the frequency and number of times they are called.
    • Can be eliminated by commenting out all calls to on_transform in the RoadPoint class.
    • On further reading, seems to be due to setget necessarily being called (possibly twice) on scene load. See https://github.com/godotengine/godot/issues/17436 for more details).
    • Thus, scene startup has the risk of being very slow if these set-get functions each lead to generation geometry.
    • The fix here in progress: wait until the network node is ready, since all children are added to the scene first before the parent-most node. Then do one generation at the parent level.
  • Errors on open
    • Can be traced to references of transform (basically anywhere in road_segment where global_transform is called).
    • However, this may be more root-caused by the above warnings actually. Ideally we do one single generation once all children are ready.
    • This really does, however, necessitate that users of the road network make both the roadpoints and segments be children of the network itself, and not place elsewhere.

While working on resolving the warnings, I may have actually eliminated the issue referenced here: #3

Once I added flags of:

if not is_instance_valid(network):
    return  # might not be initialized yet

to the RoadPoint class, it seemed to resolve point number 3.

@TheDuckCow TheDuckCow linked a pull request Oct 28, 2022 that will close this issue
@TheDuckCow
Copy link
Owner Author

Fixed with the above changes.

@TheDuckCow TheDuckCow linked a pull request Nov 5, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant