Ignore hidden channels when framing cameras
This commit is contained in:
parent
e451719520
commit
912e5aac79
3 changed files with 12 additions and 5 deletions
|
|
@ -69,7 +69,9 @@ namespace GameCult.Eve.UnityScene
|
|||
}
|
||||
cameraComponent.cullingMask = cullingMask;
|
||||
}
|
||||
var bounds = CalculateVisualBounds(player);
|
||||
var bounds = CalculateVisualBounds(
|
||||
player,
|
||||
cameraComponent != null ? cameraComponent.cullingMask : -1);
|
||||
var target = bounds?.center ?? player.position;
|
||||
var radius = bounds?.extents.magnitude ?? 0f;
|
||||
var verticalFov = cameraComponent != null ? cameraComponent.fieldOfView : 60f;
|
||||
|
|
@ -89,13 +91,14 @@ namespace GameCult.Eve.UnityScene
|
|||
return true;
|
||||
}
|
||||
|
||||
private static Bounds? CalculateVisualBounds(Transform player)
|
||||
private static Bounds? CalculateVisualBounds(Transform player, int cullingMask)
|
||||
{
|
||||
var renderers = player.GetComponentsInChildren<Renderer>(includeInactive: false);
|
||||
Bounds? bounds = null;
|
||||
foreach (var visual in renderers)
|
||||
{
|
||||
if (visual == null || !visual.enabled)
|
||||
if (visual == null || !visual.enabled ||
|
||||
(cullingMask & (1 << visual.gameObject.layer)) == 0)
|
||||
continue;
|
||||
if (bounds.HasValue)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -948,11 +948,15 @@ namespace GameCult.Eve.UnityScene.Tests
|
|||
var largeVisual = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
largeVisual.transform.SetParent(player.transform, false);
|
||||
largeVisual.transform.localScale = Vector3.one * 100f;
|
||||
largeVisual.layer = 14;
|
||||
|
||||
Assert.That(rig.ApplyRig(0f), Is.True);
|
||||
Assert.That(camera.cullingMask & (1 << 14), Is.Zero);
|
||||
Assert.That(cameraObject.transform.position.y, Is.GreaterThan(0f));
|
||||
Assert.That(Vector3.Distance(cameraObject.transform.position, largeVisual.transform.position), Is.GreaterThan(100f));
|
||||
Assert.That(
|
||||
Vector3.Distance(cameraObject.transform.position, player.transform.position),
|
||||
Is.LessThan(50f),
|
||||
"An excluded map glyph changed pilot-camera framing.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "org.gamecult.eve.unity-scene",
|
||||
"displayName": "Eve Unity Scene Lowering",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"unity": "2021.3",
|
||||
"description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.",
|
||||
"dependencies": {
|
||||
|
|
|
|||
Reference in a new issue