From 57cb0193f7f065196cb55b6c30611f002d8abe6c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Molteni Date: Wed, 13 Nov 2024 08:28:49 -0300 Subject: [PATCH] Increase limit for disabling object --- .../Utils/SceneCircumscribedPlanesCalculator.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/asset-bundle-converter/Assets/AssetBundleConverter/LODsConverter/Utils/SceneCircumscribedPlanesCalculator.cs b/asset-bundle-converter/Assets/AssetBundleConverter/LODsConverter/Utils/SceneCircumscribedPlanesCalculator.cs index 82b2f164..17bbe56b 100644 --- a/asset-bundle-converter/Assets/AssetBundleConverter/LODsConverter/Utils/SceneCircumscribedPlanesCalculator.cs +++ b/asset-bundle-converter/Assets/AssetBundleConverter/LODsConverter/Utils/SceneCircumscribedPlanesCalculator.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Cysharp.Threading.Tasks; +using System.Collections.Generic; using UnityEngine; namespace AssetBundleConverter.LODsConverter.Utils @@ -10,6 +7,7 @@ public class SceneCircumscribedPlanesCalculator { private const float PARCEL_SIZE = 16.0f; private const float EXTEND_AMOUNT = 0.05f; + private const float EXTEND_AMOUNT_FOR_DISABLE = 0.5f; private const float MAX_HEIGHT = 200f; private static ParcelCorners CalculateCorners(Vector2Int parcelPosition) @@ -55,21 +53,22 @@ public ParcelCorners(Vector3 minXZ, Vector3 minXmaxZ, Vector3 maxXZ, Vector3 max } } - private static Bounds CalculateSceneBoundingBox(Vector4 scenePlane, int parcelCount) + private static Bounds CalculateSceneBoundingBox(Vector4 scenePlane) { Vector3 center = new Vector3((scenePlane[0] + scenePlane[1]) / 2, 0, (scenePlane[2] + scenePlane[3]) / 2); //NOTE: I was getting inconsistencies on LOD_1 because weird merging was done underground. //SO, by setting MAX_HEIGHT * 2, the height wont be larger than MAX_HEIGHT going up, //And we'll go until MAX_HEIGHT underground - Vector3 size = new Vector3(scenePlane[1] - scenePlane[0] + EXTEND_AMOUNT, MAX_HEIGHT * 2, scenePlane[3] - scenePlane[2] + EXTEND_AMOUNT); + var size = new Vector3(scenePlane[1] - scenePlane[0] + EXTEND_AMOUNT_FOR_DISABLE, MAX_HEIGHT * 2, + scenePlane[3] - scenePlane[2] + EXTEND_AMOUNT_FOR_DISABLE); return new Bounds(center, size); } public static void DisableObjectsOutsideBounds(Parcel parcel, GameObject parent) { parent.transform.position = GetPositionByParcelPosition(parcel.GetDecodedBaseParcel()); - Bounds sceneBoundingBox = CalculateSceneBoundingBox(CalculateScenePlane(parcel.GetDecodedParcels()), parcel.GetDecodedParcels().Count); + var sceneBoundingBox = CalculateSceneBoundingBox(CalculateScenePlane(parcel.GetDecodedParcels())); foreach (var renderer in parent.GetComponentsInChildren()) { Bounds meshBounds = renderer.sharedMesh.bounds; meshBounds.center = renderer.transform.TransformPoint(meshBounds.center);