protected virtual DMesh3 compute_blend_analytic() { bool profile = true; LocalProfiler p = null; if (profile) { p = new LocalProfiler(); p.Start("bvtree"); } compute_cache_lazy_sdfs(); if (is_invalidated()) { return(null); } if (profile) { p.Stop("bvtree"); p.Start("mc"); } List <BoundedImplicitFunction3d> inputs = new List <BoundedImplicitFunction3d>(); foreach (CachingMeshSDF sdf in cached_lazy_sdfs) { var skel_field = new DistanceFieldToSkeletalField() { DistanceField = new CachingMeshSDFImplicit(sdf), FalloffDistance = blend_falloff }; inputs.Add(skel_field); } SkeletalRicciNaryBlend3d blend = new SkeletalRicciNaryBlend3d() { Children = inputs, BlendPower = this.blend_power, FieldShift = -DistanceFieldToSkeletalField.ZeroIsocontour }; AxisAlignedBox3d use_bounds = source_bounds; source_bounds.Expand(blend_falloff); MarchingCubesPro c = lazy_mc; c.Implicit = blend; //c.IsoValue = DistanceFieldToSkeletalField.ZeroIsocontour; c.Bounds = use_bounds; c.CubeSize = mesh_cell_size; c.Bounds.Expand(3 * c.CubeSize); c.RootMode = MarchingCubesPro.RootfindingModes.LerpSteps; c.RootModeSteps = 3; //c.ParallelCompute = false; c.CancelF = is_invalidated; c.GenerateContinuation(input_mesh_seeds()); if (is_invalidated()) { return(null); } if (profile) { p.Stop("mc"); p.Start("reduce"); } c.Mesh.ReverseOrientation(); Reducer r = new Reducer(c.Mesh); r.FastCollapsePass(c.CubeSize / 2, 3, true); if (is_invalidated()) { return(null); } if (min_component_volume > 0) { MeshEditor.RemoveSmallComponents(c.Mesh, min_component_volume, min_component_volume); } if (is_invalidated()) { return(null); } if (profile) { p.Stop("reduce"); #if G3_USING_UNITY UnityEngine.Debug.Log("ANALYTIC BLEND TIME: " + p.AllTimes()); #endif } return(c.Mesh); }
protected virtual DMesh3 compute_blend_bounded() { bool profile = true; LocalProfiler p = null; if (profile) { p = new LocalProfiler(); p.Start("sdf"); } cache_input_sdfs_bounded(); if (is_invalidated()) { return(null); } if (profile) { p.Stop("sdf"); p.Start("mc"); } List <BoundedImplicitFunction3d> inputs = new List <BoundedImplicitFunction3d>(); foreach (var sdf in cached_bounded_sdfs) { var dist_field = new DenseGridTrilinearImplicit(sdf); var skel_field = new DistanceFieldToSkeletalField() { DistanceField = dist_field, FalloffDistance = blend_falloff }; inputs.Add(skel_field); } SkeletalRicciNaryBlend3d blend = new SkeletalRicciNaryBlend3d() { Children = inputs, BlendPower = this.blend_power }; MarchingCubesPro c = new MarchingCubesPro(); c.Implicit = blend; c.IsoValue = DistanceFieldToSkeletalField.ZeroIsocontour; c.Bounds = blend.Bounds(); c.CubeSize = mesh_cell_size; c.Bounds.Expand(3 * c.CubeSize); c.RootMode = MarchingCubesPro.RootfindingModes.LerpSteps; c.RootModeSteps = 3; c.CancelF = is_invalidated; //c.Generate(); c.GenerateContinuation(input_mesh_seeds()); if (is_invalidated()) { return(null); } if (profile) { p.Stop("mc"); p.Start("reduce"); } c.Mesh.ReverseOrientation(); Reducer r = new Reducer(c.Mesh); r.FastCollapsePass(c.CubeSize / 2, 3, true); if (is_invalidated()) { return(null); } if (min_component_volume > 0) { MeshEditor.RemoveSmallComponents(c.Mesh, min_component_volume, min_component_volume); } if (is_invalidated()) { return(null); } if (profile) { p.Stop("reduce"); #if G3_USING_UNITY UnityEngine.Debug.Log("BLEND TIME: " + p.AllTimes()); #endif } return(c.Mesh); }