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

SkinnedMeshRenderer support immediate initialization of rootBone and bones #1672

Merged
merged 13 commits into from
Aug 4, 2023

Conversation

GuoLei1990
Copy link
Member

@GuoLei1990 GuoLei1990 commented Jul 28, 2023

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Feat:

  • Remove glTF lazy initialization issue, we can get rootBone at anytime
  • SkinnedMeshRenderer support custom bones
  • Remove hack logic of Initialize bone data

@GuoLei1990 GuoLei1990 added the enhancement New feature or request label Jul 28, 2023
@GuoLei1990 GuoLei1990 added this to the 1.1 milestone Jul 28, 2023
@GuoLei1990 GuoLei1990 self-assigned this Jul 28, 2023
@GuoLei1990 GuoLei1990 added the bug Something isn't working label Jul 31, 2023
* dev/1.1: (43 commits)
  fix: skin mesh error (galacean#1675)
  fix: test error (galacean#1674)
  test: fix github test (galacean#1669)
  test: fix ci not work (galacean#1670)
  glTF support basisu (galacean#1662)
  fix: `EventDispatcher` static pool bug
  fix: eventdispatcher bug (galacean#1671)
  fix: animation event bug (galacean#1666)
  Fix parse glTF texture wrap & filterMode bug (galacean#1659)
  Fix text wrap bug (galacean#1644)
  chore: use strict error msg and type (galacean#1647)
  Fix text error for set text to "" and set enableWrapping to true (galacean#1634)
  "v1.0.0-beta.17"
  Process GLTFBufferParser and GLTFTextureParser pipelines in parallel (galacean#1638)
  Fix animation clip loader, clip change promise to assetPromise, controller json parse (galacean#1506)
  fix: the layer is not cloned when the node is cloned (galacean#1636)
  Fix glTF texture mipmap bug (galacean#1637)
  "v1.0.0-beta.16"
  Adjust main light to directional lights first (galacean#1635)
  Fix  `AmbientLight` can't destroy bug (galacean#1633)
  ...
@@ -173,10 +182,10 @@ export class SkinnedMeshRenderer extends MeshRenderer {
const blendShapeManager = mesh._blendShapeManager;
blendShapeManager._updateShaderData(shaderData, this);

const skin = this._skin;
if (skin) {
const bones = this.bones;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this._bones

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* @internal
*/
private _getEntityByHierarchyPath(rootEntity: Entity, inversePath: number[]): Entity {
let sprite = rootEntity;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sprite ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 351 to 362
private _skin: Skin;

/**
* @deprecated
* Skin Object.
*/
get skin(): Skin {
return this._skin;
}

set skin(value: Skin) {
this._skin = value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should set renderer's bones and rootBond if you want adapter deprecated method

Comment on lines 325 to 338
private _getEntityHierarchyPath(rootEntity: Entity, searchEntity: Entity, inversePath: number[]): boolean {
inversePath.length = 0;
let entity = searchEntity;
while (entity !== rootEntity) {
const parent = entity.parent;
if (parent) {
inversePath.push(entity.siblingIndex);
} else {
return false;
}
entity = parent;
}
return true;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private _getEntityHierarchyPath(rootEntity: Entity, searchEntity: Entity, inversePath: number[]): boolean {
    inversePath.length = 0;
    while (searchEntity !== rootEntity) {
        if (!searchEntity.parent) {
            return false;
        }
        inversePath.push(searchEntity.siblingIndex);
        searchEntity = searchEntity.parent;
    }
    return true;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -244,8 +253,25 @@ export class SkinnedMeshRenderer extends MeshRenderer {
/**
* @internal
*/
override _cloneTo(target: SkinnedMeshRenderer): void {
super._cloneTo(target);
override _cloneTo(target: SkinnedMeshRenderer, srcRoot: Entity, targetRoot: Entity): void {
Copy link
Member

@zhuxudong zhuxudong Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge error, if(this._jointEntities) -> if(this._bones)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 10 to 11
public joints: string[];
public skeleton: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

joints and skeleton are not used now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep readonly

skin.skeleton = entities[skeleton].name;
const rootBone = entities[skeleton];
skin.rootBone = rootBone;
skin.skeleton = rootBone.name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

} else {
const rootBone = this._findSkeletonRootBone(joints, entities);
if (rootBone) {
skin.rootBone = rootBone;
skin.skeleton = rootBone.name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

@@ -420,5 +420,12 @@ describe("glTF Loader test", function () {
const renderer = entities[1].getComponent(SkinnedMeshRenderer);
expect(renderer).to.exist;
expect(renderer.blendShapeWeights).to.deep.include([1, 1]);
// expect(renderer.rootBone).to.equal();
// expect(renderer.bones).to.equal();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

glTFResource.destroy();
expect(glTFResource.materials).to.be.null;
expect(glTFResource.textures).to.be.null;
expect(glTFResource.entities).to.be.null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge error, delete it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@GuoLei1990 GuoLei1990 changed the title SkinnedMeshRenderer support immediate initialization SkinnedMeshRenderer support immediate initialization(rootBone, bones) Aug 4, 2023
@GuoLei1990 GuoLei1990 changed the title SkinnedMeshRenderer support immediate initialization(rootBone, bones) SkinnedMeshRenderer support immediate initialization of rootBone and bones Aug 4, 2023
@GuoLei1990 GuoLei1990 merged commit 10f3b23 into galacean:dev/1.1 Aug 4, 2023
4 of 5 checks passed
GuoLei1990 added a commit to GuoLei1990/galacean-engine that referenced this pull request Aug 4, 2023
* dev/1.1:
  `SkinnedMeshRenderer` support immediate initialization of `rootBone` and `bones` (galacean#1672)
  Support camera depth texture (galacean#1658)
zhuxudong added a commit to zhuxudong/engine that referenced this pull request Aug 17, 2023
* dev/1.1: (66 commits)
  build: fix pnpm lock file
  build: fix pnpm-lock file
  build: fix pnpm-lock file
  build: fix build error
  `ResourceManager` support `findResourcesByType` (galacean#1700)
  fix: memory leak of Transform (galacean#1701)
  fix: file name error
  "v1.1.0-alpha.1"
  test(RenderTarget): fix `getColorTexture` error
  Fix ktx2 loader can't throw error (galacean#1699)
  Enhance type for `LoadItem` & `Entity.getComponent` (galacean#1696)
  types: opt getComponent return type
  types: fix lint
  Fix ci test (galacean#1677)
  Shader Lab support `RenderState` (galacean#1664)
  feat: enhance type for `LoadItem` & `Entity.getComponent`
  fix: variable error (galacean#1693)
  `SkinnedMeshRenderer` support immediate initialization of `rootBone` and `bones` (galacean#1672)
  Support camera depth texture (galacean#1658)
  "v1.0.0-beta.18"
  ...

# Conflicts:
#	packages/loader/src/gltf/parser/GLTFSceneParser.ts
#	packages/loader/src/gltf/parser/GLTFSkinParser.ts
#	tests/src/loader/GLTFLoader.test.ts
@GuoLei1990 GuoLei1990 deleted the PR/fix-skin-lazy branch September 18, 2023 14:01
@GuoLei1990 GuoLei1990 linked an issue Oct 7, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

glTF rendering exception cause by duplicated bone names
2 participants