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

[Mesh統合] glb/vrm-0/vrm-1 の Mesh統合 Utility を整理 #2187

Merged

Conversation

ousttrue
Copy link
Contributor

@ousttrue ousttrue commented Dec 6, 2023

共通機能を glb 版の runtime 動作に実装した。
重複していた部分などを整理。

runtime prefab
glb 基本機能 asset/prefabへの書き出し
vrm0 必須の正規化 Vrm0FirstPerson BlendShapeClip asset/prefabへの書き出し
vrm1 オプションの正規化 Vrm1FirstPerson Expression asset/prefabへの書き出し

freeze(bake) => 統合 => 分割

統合対象を
ブラックリストで除外するのを、
ホワイトリストで列挙する様に変えた。

using UnityEditor;
using UnityEditorInternal;
using UnityEngine;

namespace UniVRM10
namespace UniGLTF.MeshUtility
Copy link
Contributor Author

Choose a reason for hiding this comment

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

共通機能。UniGLTF に移動

// Meshの焼きこみ
var newMesh = BoneNormalizer.NormalizeHierarchyFreezeMesh(go, true);
// 焼いたMeshで置き換える
BoneNormalizer.Replace(go, newMesh, true, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mesh を焼くのと、焼いた Mesh を Renderer に挿すを分けた。
挿すときに Transform.rotation / scale のクリアをする。

/// <summary>
/// Meshを統合し、統合後のMeshのBlendShapeの変化をVRMのBlendShapeClipに反映する
/// </summary>
public class VrmBlendShapeUpdater
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mesh統合でずれるBlendShape参照を追随させる


namespace UniGLTF.MeshUtility
{
public class MeshAttachInfo
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mesh を焼いたときに Renderer を置き換えるのをやめたので、
置き換え情報を蓄える。

@ousttrue ousttrue requested a review from Santarh December 6, 2023 09:36
Santarh
Santarh previously approved these changes Dec 6, 2023
Copy link
Contributor

@Santarh Santarh left a comment

Choose a reason for hiding this comment

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

LGTM。
書いたところは 🍰

Comment on lines 37 to 45
public void WriteAndReload(string assetPath)
{
AssetDatabase.CreateAsset(IntegratedRenderer.sharedMesh, assetPath);
var unityPath = UnityPath.FromUnityPath(assetPath);
unityPath.ImportAsset();
var mesh = unityPath.LoadAsset<Mesh>();
// replace reloaded
IntegratedRenderer.sharedMesh = mesh;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

これ、処理は public な状態を読み書きしているので、関数自体は Editor の asmdef に押しやれそうな気はします。
(プリプロセッサなくしたい)

}
else
{
#if VRM_DEVELOP
Copy link
Contributor

Choose a reason for hiding this comment

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

プリプロセッサ外したとしてもコンパイルエラーになるコードではないので

if (Symbols.VRM_DEVELOP)

としてほしいかも

{
var childAssetPath = $"{assetFolder}/{result.Integrated.IntegratedRenderer.gameObject.name}{ASSET_SUFFIX}";
Debug.LogFormat("CreateAsset: {0}", childAssetPath);
AssetDatabase.CreateAsset(result.Integrated.IntegratedRenderer.sharedMesh, childAssetPath);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

AssetDatabase.CreateAsset を後続の result.Integrated.Reload から移動

Copy link
Contributor

@Santarh Santarh left a comment

Choose a reason for hiding this comment

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

LGTM

@ousttrue ousttrue merged commit 07311ec into vrm-c:master Dec 7, 2023
1 check failed
@ousttrue ousttrue deleted the fix/integrate_glb_vrm0_vrm1_meshutility branch January 24, 2024 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants