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

add self flag #1258

Merged
merged 1 commit into from
Sep 29, 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
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ private async static Task<SkinnedMeshRenderer> CreateHeadlessMeshAsync(SkinnedMe

bool m_done;

async Task SetupRendererAsync(GameObject go, Transform FirstPersonBone, RendererFirstPersonFlags x,
async Task SetupSelfRendererAsync(GameObject go, Transform FirstPersonBone, RendererFirstPersonFlags x,
(int FirstPersonOnly, int ThirdPersonOnly) layer, IAwaitCaller awaitCaller = null)
{
var runtime = go.GetComponent<UniGLTF.RuntimeGltfInstance>();

switch (x.FirstPersonFlag)
{
case UniGLTF.Extensions.VRMC_vrm.FirstPersonType.auto:
Expand Down Expand Up @@ -127,19 +126,17 @@ async Task SetupRendererAsync(GameObject go, Transform FirstPersonBone, Renderer
}

/// <summary>
/// Setup first person
///
/// * SetupLayers
/// * Each renderer is set according to the first person flag. If the flag is `auto`, headless mesh creation will be performed. It's a heavy process.
/// * If visible is false, the created headless mesh will be hidden.
///
/// Each renderer is set according to the first person flag.
/// If the flag is `auto`, headless mesh creation will be performed.
/// Creating a headless mesh(Renderer) is a heavy process and can be done in threads.
/// </summary>
/// <param name="go"></param>
/// <param name="firstPersonOnlyLayer"></param>
/// <param name="thirdPersonOnlyLayer"></param>
/// <param name="awaitCaller"></param>
/// <param name="go">The target model root</param>
/// <param name="isSelf">The target model is the VR user himself</param>
/// <param name="firstPersonOnlyLayer">layer VRMFirstPersonOnly or 9</param>
/// <param name="thirdPersonOnlyLayer">layer VRMThirdPersonOnly ir 10</param>
/// <param name="awaitCaller">Headless mesh creation task scheduler. By default, creation is immediate</param>
/// <returns></returns>
public async Task SetupAsync(GameObject go, int? firstPersonOnlyLayer = default, int? thirdPersonOnlyLayer = default, IAwaitCaller awaitCaller = default)
public async Task SetupAsync(GameObject go, bool isSelf = true, int? firstPersonOnlyLayer = default, int? thirdPersonOnlyLayer = default, IAwaitCaller awaitCaller = default)
{
if (awaitCaller == null)
{
Expand All @@ -159,7 +156,30 @@ public async Task SetupAsync(GameObject go, int? firstPersonOnlyLayer = default,
var FirstPersonBone = go.GetComponent<Animator>().GetBoneTransform(HumanBodyBones.Head);
foreach (var x in Renderers)
{
await SetupRendererAsync(go, FirstPersonBone, x, layer, awaitCaller);
if (isSelf)
{
await SetupSelfRendererAsync(go, FirstPersonBone, x, layer, awaitCaller);
}
else
{
switch (x.FirstPersonFlag)
Copy link
Contributor

Choose a reason for hiding this comment

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

モデルが非ユーザのモデルの場合、モデル分割などの処理は入らない。

唯一、ユーザが FirstPersonOnly を明示的に設定したレンダラのみが無効化される。

{
case UniGLTF.Extensions.VRMC_vrm.FirstPersonType.firstPersonOnly:
if (x.GetRenderer(go.transform) is Renderer r)
{
// invisible
r.enabled = false;
}
break;

case UniGLTF.Extensions.VRMC_vrm.FirstPersonType.auto:
// => Same as Both
case UniGLTF.Extensions.VRMC_vrm.FirstPersonType.both:
case UniGLTF.Extensions.VRMC_vrm.FirstPersonType.thirdPersonOnly:
// do nothing
break;
}
}
}
}
}
Expand Down