engine icon indicating copy to clipboard operation
engine copied to clipboard

Cloning entity with render component and mesh with skin does not clone the skin instance

Open mvaligursky opened this issue 3 years ago • 2 comments

  • it seems in some cases the skin instance never gets cloned and the skinning no longer works
  • looking at the code, it seems:
  1. when rootBone is set, it clones skin instance
  2. if not set, skin instance should be cloned when the cloned entity is added to the scene / enabled in it.

But it seems in some cases this might not take place.

mvaligursky avatar Aug 22 '22 14:08 mvaligursky

This may be related to a bug that we just wanted to report. We are creating our own meshes and destroying them a lot and we noticed that the SkinInstanceCache is not freeing the skin instances that were created by it. We looked at the _cloneSkinInstances of the renderComponent and saw that the condition of the if seems to be wrong. The Mesh class doesn't have a property skinInstance, but the condition is looking for one. We think this is a typo and was meant to be !meshInstance.skinInstance. https://github.com/playcanvas/engine/blob/4500ad0d68c9d867cd756861917574e0533489f9/src/framework/components/render/component.js#L816-L830

If this is not related or doesn't help with this issue, I will open a separate issue and try to add some reproduction steps.

MoserAlex avatar Aug 22 '22 15:08 MoserAlex

I think you're right on the typo there, and some repro would be awesome, that's always the hardest part.

mvaligursky avatar Aug 22 '22 15:08 mvaligursky

@MoserAlex - thanks for the investigation, I created a fix you suggested - as that was an obvious typo there. I could not verified if this fixes the original issue as well, so I'll leave the issue opened for now.

mvaligursky avatar Sep 23 '22 13:09 mvaligursky

Closing, till I can find a repro, or at least a confirmation.

mvaligursky avatar Nov 15 '22 11:11 mvaligursky