Skip to content

Commit bb7459e

Browse files
authored
Merge pull request #10 from gam0022/raymarching-quad-mesh
RaymarchingQuadMeshCreator
2 parents e9214c3 + 1f191e9 commit bb7459e

File tree

8 files changed

+472
-99
lines changed

8 files changed

+472
-99
lines changed

.idea/.idea.unity-demoscene/.idea/contentModel.xml

Lines changed: 145 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
public static class RaymarchingQuadMeshCreator
5+
{
6+
static readonly string outputPath = "Assets/Demoscene/Resources/Meshes/RaymarchingQuad.mesh";
7+
private const int expandBounds = 10000;
8+
9+
[MenuItem("Tools/CreateRaymarchingQuadMesh")]
10+
static void CreateRaymarchingQuadMesh()
11+
{
12+
var mesh = new Mesh
13+
{
14+
vertices = new[]
15+
{
16+
new Vector3(1f, 1f, 0f),
17+
new Vector3(-1f, 1f, 0f),
18+
new Vector3(-1f, -1f, 0f),
19+
new Vector3(1f, -1f, 0f),
20+
},
21+
triangles = new[] {0, 1, 2, 2, 3, 0}
22+
};
23+
mesh.RecalculateNormals();
24+
mesh.RecalculateBounds();
25+
26+
var bounds = mesh.bounds;
27+
bounds.Expand(expandBounds);
28+
mesh.bounds = bounds;
29+
30+
var oldAsset = AssetDatabase.LoadAssetAtPath<Mesh>(outputPath);
31+
if (oldAsset)
32+
{
33+
// Update Asset
34+
EditorUtility.CopySerialized(mesh, oldAsset);
35+
AssetDatabase.SaveAssets();
36+
}
37+
else
38+
{
39+
// Create Asset
40+
AssetDatabase.CreateAsset(mesh, outputPath);
41+
AssetDatabase.Refresh();
42+
}
43+
}
44+
}

Assets/Demoscene/Editor/RaymarchingQuadMeshCreator.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)