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

Duplication problem #1

Closed
JekSun97 opened this issue Jul 10, 2024 · 4 comments · Fixed by #15
Closed

Duplication problem #1

JekSun97 opened this issue Jul 10, 2024 · 4 comments · Fixed by #15
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@JekSun97
Copy link
Owner

I noticed a problem when duplicating a Tree3D node using Ctrl+D: if we change any leaf or branch value, we see that the old mesh of the duplicate node remains and it looks like one tree is overlaid on top of another.

This multi-level tree disappears after the project is restarted.

I don't know how to solve this problem yet, if anyone has any ideas, I'd be glad for your help.

@JekSun97 JekSun97 added bug Something isn't working help wanted Extra attention is needed labels Jul 10, 2024
@mrjustaguy
Copy link

From a cursory glance at the code, I see you are using Surface tool, and I don't see any surface_clear which might resolve the issue - https://docs.godotengine.org/en/stable/tutorials/3d/procedural_geometry/immediatemesh.html#using-immediatemesh

@JekSun97
Copy link
Owner Author

@mrjustaguy This is unlikely to solve the problem, especially since SurfceTool also has a "clear" method

@RonYanDaik
Copy link

What happens is that editor copies all child nodes (trunk and leash nodes are just invisible to editor) but you create nodes on constructor again.
I think what you need to do:

  1. When creating mesh instance assign owner to make nodes visible (copy from parent nodes)
  2. Expose those member nodes to editor
  3. Move creation into _ready instead in constructor and check if member variables are valid

Also you need to expose MeshInstances3D to editor because user might want and need to use them. (For example when he well be creating custom culling system, or he might want to save mesh to disk because mesh instance allows that end etc.)

Also I don't think you need parent as node3d. Might be better to inherit it from MeshInstance3d and to not create one more node.

@JekSun97
Copy link
Owner Author

@RonYanDaik I have made the MeshInstance3D available to the editor using

void Tree3D::_ready() {
trunk_inst->set_owner(get_owner());
twig_inst->set_owner(get_owner());
}

and when we open the demo the MeshInstance3D are available to the editor, but when we create a new tree in the editor they are not available to the editor until we reload the project.

Also memnew in _ready() causes a crash, I tried to do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants