mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Allow using more than 65535 vertices in CubeSphere and IcoSphere
This commit is contained in:
parent
304f3f359e
commit
44f1791b98
@ -7,13 +7,6 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
{
|
||||
public static Mesh Build(int resolution, Texture2D heightMap, float minHeight, float maxHeight, Vector3 stretch)
|
||||
{
|
||||
// It breaks if resolution is greater than 100 I don't know why
|
||||
if (resolution > 100)
|
||||
{
|
||||
Logger.LogWarning($"Can't make CubeSphere's with resolution higher than 100 for some reason");
|
||||
resolution = 100;
|
||||
}
|
||||
|
||||
Mesh mesh = new Mesh();
|
||||
mesh.name = "CubeSphere";
|
||||
|
||||
@ -109,6 +102,12 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
}
|
||||
}
|
||||
|
||||
// Higher than this and we have to use a different indexFormat
|
||||
if (vertices.Length > 65535)
|
||||
{
|
||||
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
|
||||
}
|
||||
|
||||
mesh.vertices = vertices;
|
||||
mesh.normals = normals;
|
||||
mesh.uv = uvs;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
@ -60,8 +60,7 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
{
|
||||
Mesh mesh = new Mesh();
|
||||
|
||||
if (vertices.Count <= subdivisions)
|
||||
RefineFaces(subdivisions);
|
||||
if (vertices.Count <= subdivisions) RefineFaces(subdivisions);
|
||||
|
||||
var verticesToCopy = vertices[subdivisions];
|
||||
|
||||
@ -89,6 +88,12 @@ namespace NewHorizons.Builder.Body.Geometry
|
||||
uvs[i] = new Vector2(x, y);
|
||||
}
|
||||
|
||||
// Higher than this and we have to use a different indexFormat
|
||||
if (newVertices.Length > 65535)
|
||||
{
|
||||
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
|
||||
}
|
||||
|
||||
mesh.vertices = newVertices;
|
||||
mesh.triangles = triangles[subdivisions];
|
||||
mesh.normals = normals;
|
||||
|
||||
@ -5,14 +5,13 @@ using OWML.Common;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using Object = UnityEngine.Object;
|
||||
namespace NewHorizons.Builder.Body
|
||||
{
|
||||
public static class HeightMapBuilder
|
||||
{
|
||||
public static Shader PlanetShader;
|
||||
|
||||
public static void Make(GameObject planetGO, Sector sector, HeightMapModule module, IModBehaviour mod, int resolution = 51)
|
||||
public static void Make(GameObject planetGO, Sector sector, HeightMapModule module, IModBehaviour mod, int resolution)
|
||||
{
|
||||
var deleteHeightmapFlag = false;
|
||||
|
||||
|
||||
@ -387,7 +387,7 @@ namespace NewHorizons.Handlers
|
||||
|
||||
if (body.Config.HeightMap != null)
|
||||
{
|
||||
HeightMapBuilder.Make(go, sector, body.Config.HeightMap, body.Mod);
|
||||
HeightMapBuilder.Make(go, sector, body.Config.HeightMap, body.Mod, 51);
|
||||
}
|
||||
|
||||
if (body.Config.ProcGen != null)
|
||||
|
||||
@ -96,7 +96,7 @@ namespace NewHorizons.Handlers
|
||||
heightMap.textureMap = body.Config.Atmosphere.clouds.texturePath;
|
||||
}
|
||||
|
||||
HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod);
|
||||
HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod, 30);
|
||||
|
||||
GameObject pivot = GameObject.Instantiate(SearchUtilities.Find("Scene/Background/PlanetPivot"), SearchUtilities.Find("Scene/Background").transform);
|
||||
pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user