stride3d / stride3d/stride

[Core] EntityCloner Clone() should not clone references outsides of his tree

Open
#832 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-Low work-estimate-M
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: Github

Version: https://github.com/stride3d/stride/commit/c65c5c831755952296de0fb8f9389048c520ef58

Platform(s): Windows, not tested on other platforms

Describe the bug
Cloned entities fail to present transform instances.
References whose 'origin' are sitting outside of the hierarchy are also cloned, ex: cloning an entity also clones its parents.
I didn't expect that behavior, I don't think other users would either.

To Reproduce
Download this attached repro project, build and run the solution.
CloneAsChild.cs is cloning the 'ufo' at startup and moves the clone and the original around, as you can see you only have one ufo and one single ring instead of two ufos. The ufo is composed of two parts, the sphere is an instance and the ring is a model, the model does show up but the instance doesn't.

Expected behavior
It just works !
If a component being duplicated/if an entity is referenced and sits outside of the root's hierarchy, include it as a reference instead of cloning it.

Screenshots
N/A

Log and callstacks
N/A

Additional context
Instancing is pr #741

Could you take a look at this @tebjan ? Thanks again for that PR btw, it's fantastic !
Unrelated, see description.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with CloneAsChild.cs in the attached repro project and trace the EntityCloner Clone() call, then compare the behavior with the instancing context from PR #741. Run the repro to confirm the cloned UFO and ring behavior. Done means references whose origins are outside the cloned hierarchy remain references instead of being cloned, while the expected instance and model appear in the clone.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.