using System;
using HTraceWSGI.Scripts.Data.Private;
using HTraceWSGI.Scripts.Extensions;
using HTraceWSGI.Scripts.Globals;
using UnityEngine;
namespace HTraceWSGI.Scripts.Data.Public
{
[Serializable]
public class VoxelizationSettings
{
public VoxelizationSettings()
{
UpdateData();
}
internal void UpdateData()
{
ExactData.UpdateData(this);
}
[SerializeField]
internal VoxelizationExactData ExactData = new VoxelizationExactData();
//Voxelization ------------------------------------------------------------------------------------------------
///
/// Exclude objects (on a per-layer basis) from voxelization and has the highest priority over all other layer masks.
///
/// More information
public LayerMask VoxelizationMask = ~0;
///
/// This mode defines how voxel data will be updated.
///
/// More information
public VoxelizationUpdateMode VoxelizationUpdateMode = VoxelizationUpdateMode.Constant;
[SerializeField]
private int _updatePeriod = 1;
///
/// Update Period
///
/// [1;4]
/// More information
[HExtensions.HRangeAttribute(1, 4)]
public int UpdatePeriod
{
get { return _updatePeriod; }
set
{
if (value == _updatePeriod)
return;
_updatePeriod = HExtensions.Clamp(value, typeof(VoxelizationSettings), nameof(VoxelizationSettings.UpdatePeriod));
}
}
///
/// Anchor object for the voxelization bound. Voxelization will occur around this object and will follow it when it moves.
///
/// More information
public Transform AttachTo;
[SerializeField]
private int _lodMax = 0;
///
/// Maximum LOD level
///
/// [0;10]
/// More information
[HExtensions.HRangeAttribute(0, HConstants.MAX_LOD_LEVEL)]
public int LODMax
{
get { return _lodMax; }
set
{
if (value == _lodMax)
return;
_lodMax = HExtensions.Clamp(value, typeof(VoxelizationSettings), nameof(VoxelizationSettings.LODMax));
}
}
///
///
///
public LayerMask InstancedTerrains = 0;
//Update Options ------------------------------------------------------------------------------------------------
public LayerMask CulledObjectsMask = 0;
[SerializeField] private int _expandCullFov = 0;
///
/// Expand Cull Fov
///
/// [0;20]
[HExtensions.HRangeAttribute(0, 20)]
public int ExpandCullFov
{
get { return _expandCullFov; }
set
{
if (value == _expandCullFov)
return;
_expandCullFov = HExtensions.Clamp(value, typeof(VoxelizationSettings), nameof(VoxelizationSettings.ExpandCullFov));
}
}
[SerializeField]
private float _expandCullRadius = 1f;
///
/// Expand Cull Radius
///
/// [0.0;3.0]
[HExtensions.HRangeAttribute(0.0f, 3.0f)]
public float ExpandCullRadius
{
get { return _expandCullRadius; }
set
{
if (Mathf.Abs(value - _expandCullRadius) < Mathf.Epsilon)
return;
_expandCullRadius = HExtensions.Clamp(value, typeof(VoxelizationSettings), nameof(VoxelizationSettings.ExpandCullRadius));
}
}
public LayerMask DynamicObjectsMask = 0;
//Voxels parameters ------------------------------------------------------------------------------------------------
[SerializeField]
private float _voxelDensity = 0.64f;
///
/// Controls the resolution of the voxel volume (3D Texture). Lower values reduce the volume resolution, while higher values provide finer detail. The Voxel Density is limited by
/// the Voxel Bounds parameter to ensure voxel sizes remain between 4 and 8 centimeters.
///
/// [0.0;1.0]
/// More information
[HExtensions.HRangeAttribute(0.0f, 1.0f)]
public float VoxelDensity
{
get { return _voxelDensity; }
set
{
if (Mathf.Abs(value - _voxelDensity) < Mathf.Epsilon)
return;
_voxelDensity = HExtensions.Clamp(value, typeof(VoxelizationSettings), nameof(VoxelizationSettings.VoxelDensity));
//ExactData.UpdateData(this);
}
}
[SerializeField] private int _voxelBounds = 35;
///
/// Controls the maximum size (in meters) that the voxelization bound can cover.
///
/// [1;80]
/// More information
[HExtensions.HRangeAttribute(5, HConfig.MAX_VOXEL_BOUNDS)]
public int VoxelBounds
{
get { return _voxelBounds; }
set
{
if (value == _voxelBounds)
return;
_voxelBounds = HExtensions.Clamp(value, typeof(VoxelizationSettings), nameof(VoxelizationSettings.VoxelBounds));
//ExactData.UpdateData(this);
}
}
[SerializeField]
private bool _overrideBoundsHeightEnable = false;
///
/// Enable Bounds height override.
///
/// [1;80]
/// More information
public bool OverrideBoundsHeightEnable
{
get { return _overrideBoundsHeightEnable; }
set { _overrideBoundsHeightEnable = value; }
}
[SerializeField]
private int _overrideBoundsHeight = 10;
///
/// The maximum height of the voxelization bound.
/// This parameter is particularly useful for "flat" levels with low verticality, where the scene extends along the X and Z axes but has minimal content along the Y axis
/// (e.g., indoor scenes where the distance to walls is typically greater than the distance to the floor or ceiling).
///
/// [1;200]
/// More information
[HExtensions.HRangeAttribute(1, 200)]
public int OverrideBoundsHeight
{
get { return _overrideBoundsHeight; }
set
{
if (value == _overrideBoundsHeight)
return;
_overrideBoundsHeight = HExtensions.Clamp(value, typeof(VoxelizationSettings), nameof(VoxelizationSettings.OverrideBoundsHeight));
//ExactData.UpdateData(this);
}
}
///
/// Shift Center of voxelization bound
///
/// More information
public float CenterShift = 0f;
///
/// Enable Ground level for voxelization.
///
/// More information
public bool GroundLevelEnable = false;
///
/// Ensures that the voxelization bounds will always remain above this specified level.
/// This option is useful when you know the base level of your scene and there is no need to voxelize anything below it.
///
/// More information
public float GroundLevel = 0f;
}
}