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

Fix typo (VRMFirstPerson) #735

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ static FirstPersonFlag GetFirstPersonFlag(VRMImporterContext context, Renderer r
/// <summary>
/// ヘッドレスモデルを作成した場合に返す
/// </summary>
Mesh CreateHeadlessModel(Renderer _renderer, Transform EraseRoot, SetVisiblityFunc setVisiblity)
Mesh CreateHeadlessModel(Renderer _renderer, Transform EraseRoot, SetVisibilityFunc setVisibility)
{
{
var renderer = _renderer as SkinnedMeshRenderer;
if (renderer != null)
{
return CreateHeadlessModelForSkinnedMeshRenderer(renderer, EraseRoot, setVisiblity);
return CreateHeadlessModelForSkinnedMeshRenderer(renderer, EraseRoot, setVisibility);
}
}

Expand All @@ -143,7 +143,7 @@ Mesh CreateHeadlessModel(Renderer _renderer, Transform EraseRoot, SetVisiblityFu
var renderer = _renderer as MeshRenderer;
if (renderer != null)
{
CreateHeadlessModelForMeshRenderer(renderer, EraseRoot, setVisiblity);
CreateHeadlessModelForMeshRenderer(renderer, EraseRoot, setVisibility);
return null;
}
}
Expand All @@ -164,12 +164,12 @@ public static void SetupLayers()
}
}

private static void CreateHeadlessModelForMeshRenderer(MeshRenderer renderer, Transform eraseRoot, SetVisiblityFunc setVisiblity)
private static void CreateHeadlessModelForMeshRenderer(MeshRenderer renderer, Transform eraseRoot, SetVisibilityFunc setVisibility)
{
if (renderer.transform.Ancestors().Any(x => x == eraseRoot))
{
// 祖先に削除ボーンが居る
setVisiblity(renderer, false, true);
setVisibility(renderer, false, true);
}
else
{
Expand All @@ -186,7 +186,7 @@ private static void CreateHeadlessModelForMeshRenderer(MeshRenderer renderer, Tr
/// * 全部削除対象の場合
///
/// </summary>
private static Mesh CreateHeadlessModelForSkinnedMeshRenderer(SkinnedMeshRenderer renderer, Transform eraseRoot, SetVisiblityFunc setVisiblity)
private static Mesh CreateHeadlessModelForSkinnedMeshRenderer(SkinnedMeshRenderer renderer, Transform eraseRoot, SetVisibilityFunc setVisibility)
{
var bones = renderer.bones;

Expand All @@ -211,7 +211,7 @@ private static Mesh CreateHeadlessModelForSkinnedMeshRenderer(SkinnedMeshRendere
}

// 元のメッシュを三人称に変更(自分からは見えない)
setVisiblity(renderer, false, true);
setVisibility(renderer, false, true);

// 削除対象のボーンに対するウェイトを保持する三角形を除外して、一人称用のモデルを複製する
var headlessMesh = MeshUtility.BoneMeshEraser.CreateErasedMesh(renderer.sharedMesh, eraseBones);
Expand Down Expand Up @@ -248,6 +248,9 @@ private static Mesh CreateHeadlessModelForSkinnedMeshRenderer(SkinnedMeshRendere
/// <param name="renderer">Target renderer. Player avatar or other</param>
/// <param name="firstPerson">visibility in HMD camera</param>
/// <param name="thirdPerson">other camera visibility</param>
public delegate void SetVisibilityFunc(Renderer renderer, bool firstPerson, bool thirdPerson);

[Obsolete("Use SetVisibilityFunc")]
public delegate void SetVisiblityFunc(Renderer renderer, bool firstPerson, bool thirdPerson);

/// <summary>
Expand All @@ -257,7 +260,7 @@ private static Mesh CreateHeadlessModelForSkinnedMeshRenderer(SkinnedMeshRendere
/// <param name="renderer"></param>
/// <param name="firstPerson"></param>
/// <param name="thirdPerson"></param>
public static void SetVisiblity(Renderer renderer, bool firstPerson, bool thirdPerson)
public static void SetVisibility(Renderer renderer, bool firstPerson, bool thirdPerson)
{
SetupLayers();

Expand All @@ -283,17 +286,21 @@ public static void SetVisiblity(Renderer renderer, bool firstPerson, bool thirdP
}
}

[Obsolete("Use SetVisibility")]
public static void SetVisiblity(Renderer renderer, bool firstPerson, bool thirdPerson) =>
SetVisibility(renderer, firstPerson, thirdPerson);

public void Setup()
{
// same as v0.63.2
Setup(true, SetVisiblity);
Setup(true, SetVisibility);
}

/// <summary>
/// from v0.64.0
/// </summary>
/// <param name="isSelf"></param>
public void Setup(bool isSelf, SetVisiblityFunc setVisiblity)
public void Setup(bool isSelf, SetVisibilityFunc setVisibility)
{
if (m_done) return;
m_done = true;
Expand All @@ -307,7 +314,7 @@ public void Setup(bool isSelf, SetVisiblityFunc setVisiblity)
{
case FirstPersonFlag.Auto:
{
var headlessMesh = CreateHeadlessModel(x.Renderer, FirstPersonBone, setVisiblity);
var headlessMesh = CreateHeadlessModel(x.Renderer, FirstPersonBone, setVisibility);
if (headlessMesh != null)
{
m_headlessMeshes.Add(headlessMesh);
Expand All @@ -316,15 +323,15 @@ public void Setup(bool isSelf, SetVisiblityFunc setVisiblity)
break;

case FirstPersonFlag.FirstPersonOnly:
setVisiblity(x.Renderer, true, false);
setVisibility(x.Renderer, true, false);
break;

case FirstPersonFlag.ThirdPersonOnly:
setVisiblity(x.Renderer, false, true);
setVisibility(x.Renderer, false, true);
break;

case FirstPersonFlag.Both:
setVisiblity(x.Renderer, true, true);
setVisibility(x.Renderer, true, true);
break;
}
}
Expand All @@ -337,14 +344,14 @@ public void Setup(bool isSelf, SetVisiblityFunc setVisiblity)
switch (x.FirstPersonFlag)
{
case FirstPersonFlag.FirstPersonOnly:
setVisiblity(x.Renderer, false, false);
setVisibility(x.Renderer, false, false);
break;

case FirstPersonFlag.Auto:
// => Same as Both
case FirstPersonFlag.Both:
case FirstPersonFlag.ThirdPersonOnly:
setVisiblity(x.Renderer, true, true);
setVisibility(x.Renderer, true, true);
break;
}
}
Expand Down