public static void Subdivide(ProbeReferenceVolume.Volume cellVolume, ProbeReferenceVolume refVol, List <ProbeReferenceVolume.Volume> influencerVolumes, ref Vector3[] positions, ref List <ProbeBrickIndex.Brick> bricks) { // TODO move out var indicatorVolumes = new List <ProbeReferenceVolume.Volume>(); foreach (ProbeVolume pv in UnityEngine.Object.FindObjectsOfType <ProbeVolume>()) { if (!pv.enabled) { continue; } indicatorVolumes.Add(new ProbeReferenceVolume.Volume(Matrix4x4.TRS(pv.transform.position, pv.transform.rotation, pv.GetExtents()), pv.parameters.maxSubdivisionMultiplier, pv.parameters.minSubdivisionMultiplier)); } ProbeReferenceVolume.SubdivisionDel subdivDel = (RefTrans refTrans, int subdivisionLevel, List <Brick> inBricks, List <Flags> outFlags) => { SubdivisionAlgorithm(cellVolume, indicatorVolumes, influencerVolumes, refTrans, inBricks, subdivisionLevel, outFlags); }; bricks = new List <ProbeBrickIndex.Brick>(); // get a list of bricks for this volume int numProbes; refVol.CreateBricks(new List <ProbeReferenceVolume.Volume>() { cellVolume }, influencerVolumes, subdivDel, bricks, out numProbes); positions = new Vector3[numProbes]; refVol.ConvertBricks(bricks, positions); }
public static void Subdivide(Vector3Int cellPosGridSpace, ProbeReferenceVolume refVol, float cellSize, Vector3 translation, Quaternion rotation, List <Volume> influencerVolumes, ref Vector3[] positions, ref List <ProbeBrickIndex.Brick> bricks) { //TODO: This per-cell volume is calculated 2 times during probe placement. We should calculate it once and reuse it. Volume cellVolume = new Volume(); cellVolume.corner = new Vector3(cellPosGridSpace.x * cellSize, cellPosGridSpace.y * cellSize, cellPosGridSpace.z * cellSize); cellVolume.X = new Vector3(cellSize, 0, 0); cellVolume.Y = new Vector3(0, cellSize, 0); cellVolume.Z = new Vector3(0, 0, cellSize); cellVolume.Transform(Matrix4x4.TRS(translation, rotation, Vector3.one)); // TODO move out var indicatorVolumes = new List <ProbeReferenceVolume.Volume>(); foreach (ProbeVolume pv in UnityEngine.Object.FindObjectsOfType <ProbeVolume>()) { if (!pv.enabled) { continue; } indicatorVolumes.Add(new ProbeReferenceVolume.Volume(Matrix4x4.TRS(pv.transform.position, pv.transform.rotation, pv.GetExtents()))); } ProbeReferenceVolume.SubdivisionDel subdivDel = (RefTrans refTrans, List <Brick> inBricks, List <Flags> outFlags) => { SubdivisionAlgorithm(cellVolume, indicatorVolumes, influencerVolumes, refTrans, inBricks, outFlags); }; bricks = new List <ProbeBrickIndex.Brick>(); // get a list of bricks for this volume int numProbes; refVol.CreateBricks(new List <Volume>() { cellVolume }, subdivDel, bricks, out numProbes); positions = new Vector3[numProbes]; refVol.ConvertBricks(bricks, positions); }