Skip to content

Commit

Permalink
Fixed memory management bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
hayden-donnelly committed May 12, 2023
1 parent 296ce7a commit 96fa23f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ private void GenerateMaskedBrushHeightmap()
modelOutputHeight,
upSampleFactor,
true,
WorkerFactory.Type.ComputePrecompiled
workerType
);
brushMaskTensor = barraUpSampler.Execute(brushMaskTensor);
Tensor upSampledBrushMaskTensor = barraUpSampler.Execute(brushMaskTensor);
// Consider smoothing upsample brush mask, otherwise it makes heightmap jagged.

/*
Expand All @@ -136,17 +136,17 @@ private void GenerateMaskedBrushHeightmap()

for(int i = 0; i < brushHeightmapColors.Length; i++)
{
Color brushMaskColor = new Color(brushMaskTensor[i], 0, 0, 1);
Color brushMaskColor = new Color(upSampledBrushMaskTensor[i], 0, 0, 1);
brushHeightmapMaskedColors[i] = brushHeightmapColors[i] * brushMaskColor.r;
}

brushMaskTensor.Dispose();
upSampledBrushMaskTensor.Dispose();
barraUpSampler.Dispose();

brushHeightmapMasked = new Texture2D(brushHeightmap.width, brushHeightmap.height);
brushHeightmapMasked.SetPixels(brushHeightmapMaskedColors);
brushHeightmapMasked.Apply();
Debug.Log(brushHeightmapMasked.width);
}

public override void OnInspectorGUI(Terrain terrain, IOnInspectorGUI editContext)
Expand Down

0 comments on commit 96fa23f

Please sign in to comment.