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

Skip mesh export when MeshExportInfo.CanExport is false #1117

Merged
merged 1 commit into from
Jul 28, 2021

Conversation

ichi-23
Copy link
Contributor

@ichi-23 ichi-23 commented Jul 27, 2021

MeshExportInfo.CanExport が false である場合、その mesh の export をスキップする

なぜそうしたいか

  • MeshExportList.GetInfo で集めた MeshExportInfo の中には「Export 可能ではない Mesh の情報」(Mesh が null であったり、Mesh の vertexCount が 0 だったりするもの)が存在しうる
  • しかし、mesh の Export 処理で Export 可能ではない Mesh の MeshExportInfo が渡された場合のハンドリングが抜けている
    • mesh の export 処理で呼ばれる MeshExporter_DividedVertexBuffer.Export ならびに MeshExporter_SharedVertexBuffer.Export は Mesh が null ではない、Mesh の vertexCount が 0 ではないこと前提の処理となっており、そうでない MeshExportInfo が渡された場合 Exception が発生する
    • Mesh が export 可能であるか否かは事前に判別可能( MeshExportInfo.CanExport を見ればよい)であるため、CanExport が false の場合対象の mesh の export をスキップしたい

@@ -247,6 +247,11 @@ public virtual void Export(GltfExportSettings meshExportSettings, ITextureSerial
MeshBlendShapeIndexMap = new Dictionary<Mesh, Dictionary<int, int>>();
foreach (var unityMesh in uniqueUnityMeshes)
{
if (!unityMesh.CanExport)
{
continue;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

continue する前に何かログに出力したほうがいいかもしれない

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

{
continue;
}

var (gltfMesh, blendShapeIndexMap) = meshExportSettings.DivideVertexBuffer
? MeshExporter_DividedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_settings.InverseAxis.Create(), meshExportSettings)
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 の vertexCount が 0 の場合、ArgumentOutOfRangeException が発生する
  • mesh が null の場合、NullReferenceException が発生する

{
continue;
}

var (gltfMesh, blendShapeIndexMap) = meshExportSettings.DivideVertexBuffer
? MeshExporter_DividedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_settings.InverseAxis.Create(), meshExportSettings)
: MeshExporter_SharedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_settings.InverseAxis.Create(), meshExportSettings)
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 の vertexCount が 0 の場合処理が正常に終了するが、空の Mesh が Export されることになる
  • mesh が null の場合、NullReferenceException が発生する

@ousttrue ousttrue merged commit 7067e52 into vrm-c:master Jul 28, 2021
@ousttrue ousttrue added this to the v0.80 milestone Aug 6, 2021
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.

2 participants