小修
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap
|
||||
{
|
||||
[System.Serializable]
|
||||
public class DTMConstellation_BM : EnvironmentObject_BM
|
||||
{
|
||||
// Constellation Settings
|
||||
public int maxParticles = 10;
|
||||
public int maxLineCount = 12;
|
||||
public Vector3 spreadSize = new Vector3(20f, 20f, 20f);
|
||||
public int maxConnectionsPerStar = 3;
|
||||
|
||||
// Visual Settings
|
||||
public float maxConnectionDistance = 20f;
|
||||
public float activeStarSize = 1f;
|
||||
public float lineWidth = 0.1f;
|
||||
|
||||
// Particle Motion Settings
|
||||
public Vector3 orbitalVelocity = Vector3.one * 0.1f;
|
||||
public float angularVelocity = 60f;
|
||||
|
||||
// 颜色由 ColorSubmodule_BM 统一管理,此处不存储
|
||||
|
||||
public DTMConstellation_BM()
|
||||
{
|
||||
}
|
||||
|
||||
public DTMConstellation_BM(
|
||||
string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
||||
string themeBundleName, string objectName, bool isStatic,
|
||||
int maxParticles, int maxLineCount,
|
||||
Vector3 spreadSize, int maxConnectionsPerStar,
|
||||
float maxConnectionDistance, float activeStarSize, float lineWidth,
|
||||
Vector3 orbitalVelocity, float angularVelocity)
|
||||
: base(elementName, elementGuid, tags, attachedElement, themeBundleName, objectName, isStatic)
|
||||
{
|
||||
this.maxParticles = maxParticles;
|
||||
this.maxLineCount = maxLineCount;
|
||||
this.spreadSize = spreadSize;
|
||||
this.maxConnectionsPerStar = maxConnectionsPerStar;
|
||||
|
||||
this.maxConnectionDistance = maxConnectionDistance;
|
||||
this.activeStarSize = activeStarSize;
|
||||
this.lineWidth = lineWidth;
|
||||
|
||||
this.orbitalVelocity = orbitalVelocity;
|
||||
this.angularVelocity = angularVelocity;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = DTMConstellation.GenerateElement(
|
||||
elementName, elementGuid, tags, false,
|
||||
themeBundleName, objectName, GetElement(attachedElementGuid), isStatic,
|
||||
maxParticles, maxLineCount,
|
||||
spreadSize, maxConnectionsPerStar,
|
||||
maxConnectionDistance, activeStarSize, lineWidth,
|
||||
orbitalVelocity, angularVelocity);
|
||||
}
|
||||
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
return DTMConstellation.GenerateElement(
|
||||
elementName, Guid.NewGuid(), tags, true,
|
||||
themeBundleName, objectName, parent, isStatic,
|
||||
maxParticles, maxLineCount,
|
||||
spreadSize, maxConnectionsPerStar,
|
||||
maxConnectionDistance, activeStarSize, lineWidth,
|
||||
orbitalVelocity, angularVelocity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5cb7116edc0bcd84a996accd3a1b0ea3
|
||||
@@ -0,0 +1,74 @@
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
{
|
||||
public partial class DTMConstellation
|
||||
{
|
||||
#region [Editor] Inspection & Save
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new DTMConstellation_BM(
|
||||
elementName, elementGuid, tags,
|
||||
parentElement.matchedBM as GameElement_BM,
|
||||
themeBundleName, objectName, isStatic,
|
||||
maxParticles, maxLineCount,
|
||||
spreadSize, maxConnectionsPerStar,
|
||||
maxConnectionDistance, activeStarSize, lineWidth,
|
||||
orbitalVelocity, angularVelocity);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
// base.SetUpInspector() 会自动生成 ColorSubmodule 的 UI(BaseColor + EmissionColor)
|
||||
base.SetUpInspector();
|
||||
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
|
||||
// ── 星座核心参数 ──────────────────────────────────────────────
|
||||
var mainContainer = inspector.GenerateContainer("DTMConstellation");
|
||||
var mainSettings = mainContainer.GenerateSubcontainer(3);
|
||||
|
||||
inspector.GenerateInputField(this, mainSettings, "Max Particles", nameof(maxParticles));
|
||||
inspector.GenerateInputField(this, mainSettings, "Max Line Count", nameof(maxLineCount));
|
||||
inspector.GenerateInputField(this, mainSettings, "Max Connections Per Star", nameof(maxConnectionsPerStar));
|
||||
inspector.GenerateInputField(this, mainSettings, "Max Connection Distance", nameof(maxConnectionDistance));
|
||||
|
||||
// ── 散布体积 ──────────────────────────────────────────────────
|
||||
var spreadContainer = inspector.GenerateContainer("Spread Volume");
|
||||
var spreadSettings = spreadContainer.GenerateSubcontainer(1);
|
||||
inspector.GenerateVector3InputField(this, spreadSettings, "Spread Size", nameof(spreadSize));
|
||||
|
||||
// ── 视觉参数 ─────────────────────────────────────────────────
|
||||
var visualContainer = inspector.GenerateContainer("Visual");
|
||||
var visualSettings = visualContainer.GenerateSubcontainer(3);
|
||||
inspector.GenerateInputField(this, visualSettings, "Active Star Size", nameof(activeStarSize));
|
||||
inspector.GenerateInputField(this, visualSettings, "Line Width", nameof(lineWidth));
|
||||
|
||||
// ── 粒子运动 ─────────────────────────────────────────────────
|
||||
var motionContainer = inspector.GenerateContainer("Particle Motion");
|
||||
var motionSettings = motionContainer.GenerateSubcontainer(1);
|
||||
inspector.GenerateVector3InputField(this, motionSettings, "Orbital Velocity", nameof(orbitalVelocity));
|
||||
inspector.GenerateInputField(this, motionSettings, "Angular Velocity", nameof(angularVelocity));
|
||||
|
||||
// ── 刷新操作按钮 ──────────────────────────────────────────────
|
||||
var actionContainer = inspector.GenerateContainer("Constellation Actions");
|
||||
var actionSettings = actionContainer.GenerateSubcontainer(2);
|
||||
|
||||
inspector.GenerateButton(this, actionSettings, "Refresh This", () =>
|
||||
{
|
||||
GenerateSingleConstellation();
|
||||
});
|
||||
|
||||
inspector.GenerateButton(this, actionSettings, "Refresh All", () =>
|
||||
{
|
||||
var allConstellations = FindObjectsByType<DTMConstellation>(FindObjectsSortMode.None);
|
||||
foreach (var c in allConstellations)
|
||||
c.GenerateSingleConstellation();
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e98444d2c711354e91cae0fae56210d
|
||||
@@ -34,11 +34,15 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
inspector.GenerateInputField(this, subcontainer, "Base Speed", nameof(baseSpeed)).AddListenerFunction(UpdateMaterialProperties);
|
||||
|
||||
inspector.GenerateToggle(this, subcontainer, "Enable Outer Border", nameof(enableOuterBorder)).AddListenerFunction(UpdateMaterialProperties);
|
||||
inspector.GenerateBaseColorPicker(this, subcontainer, "Outer Border Color", nameof(outerBorderColor)).AddListenerFunction(UpdateMaterialProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Outer Border Width", nameof(outerBorderWidth)).AddListenerFunction(UpdateMaterialProperties);
|
||||
|
||||
var colorContainer = container.GenerateSubcontainer(1, 280f);
|
||||
inspector.GenerateBaseColorPicker(this, colorContainer, "Outer Border Color", nameof(outerBorderColor)).AddListenerFunction(UpdateMaterialProperties);
|
||||
|
||||
var subcontainer2 = container.GenerateSubcontainer(3);
|
||||
inspector.GenerateInputField(this, subcontainer2, "Outer Border Width", nameof(outerBorderWidth)).AddListenerFunction(UpdateMaterialProperties);
|
||||
|
||||
inspector.GenerateInputField(this, subcontainer, "Fade Far", nameof(fadeFar)).AddListenerFunction(UpdateMaterialProperties);
|
||||
inspector.GenerateInputField(this, subcontainer, "Fade Near", nameof(fadeNear)).AddListenerFunction(UpdateMaterialProperties);
|
||||
inspector.GenerateInputField(this, subcontainer2, "Fade Far", nameof(fadeFar)).AddListenerFunction(UpdateMaterialProperties);
|
||||
inspector.GenerateInputField(this, subcontainer2, "Fade Near", nameof(fadeNear)).AddListenerFunction(UpdateMaterialProperties);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -0,0 +1,408 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using Unity.Burst;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
{
|
||||
public partial class DTMConstellation : EnvironmentObject
|
||||
{
|
||||
[Header("Core References")]
|
||||
[Tooltip("拖入用于生成节点的粒子系统")]
|
||||
public ParticleSystem starParticleSystem;
|
||||
|
||||
[Tooltip("拖入用于渲染连线的 MeshFilter")]
|
||||
public MeshFilter lineMeshFilter;
|
||||
|
||||
[SerializeField]
|
||||
private Camera mainCam;
|
||||
|
||||
[Header("Constellation Settings (星座设置)")]
|
||||
[Tooltip("这个星座包含的星星总数")]
|
||||
public int maxParticles = 10;
|
||||
|
||||
[Tooltip("整个星座允许产生的最大连线数量")]
|
||||
public int maxLineCount = 12;
|
||||
|
||||
// 【修改】:使用 Vector3 代替单轴 Radius,控制长方体生成体积
|
||||
[Tooltip("星座的散布体积 (长宽高)")]
|
||||
public Vector3 spreadSize = new Vector3(20f, 20f, 20f);
|
||||
|
||||
[Tooltip("单颗星星的最大连线数 (建议设置在 2 到 4 之间)")]
|
||||
public int maxConnectionsPerStar = 3;
|
||||
|
||||
[Header("Visual Settings (视觉设置)")]
|
||||
public float maxConnectionDistance = 20f;
|
||||
public float activeStarSize = 1f;
|
||||
public float lineWidth = 0.1f;
|
||||
|
||||
[Header("Particle Motion Settings (粒子运动设置)")]
|
||||
[Tooltip("星系整体的轨道旋转速度 (Velocity over Lifetime -> Orbital)")]
|
||||
public Vector3 orbitalVelocity = Vector3.one * 0.1f;
|
||||
[Tooltip("星星自身的旋转角速度 (Rotation over Lifetime -> Angular Velocity)")]
|
||||
public float angularVelocity = 60f;
|
||||
|
||||
// 【新增】:连线 Mesh 的渲染器,用于同步 EmissionColor 到材质
|
||||
public Renderer lineRenderer;
|
||||
|
||||
public override bool haveBaseColor => true;
|
||||
public override bool haveEmissionColor => true;
|
||||
|
||||
private ParticleSystem.Particle[] particles;
|
||||
private Mesh lineMesh;
|
||||
private bool hasInitializedSpawning = false;
|
||||
|
||||
public static DTMConstellation GenerateElement(
|
||||
string elementName, Guid id, List<string> tags,
|
||||
bool isFirstGenerated, string themeBundleName, string objectName,
|
||||
GameElement parentElement, bool isStatic,
|
||||
int maxParticles, int maxLineCount,
|
||||
Vector3 spreadSize, int maxConnectionsPerStar,
|
||||
float maxConnectionDistance, float activeStarSize, float lineWidth,
|
||||
Vector3 orbitalVelocity, float angularVelocity)
|
||||
{
|
||||
DTMConstellation constellation = EnvironmentObject.GenerateElement(
|
||||
elementName, id, tags, isFirstGenerated,
|
||||
themeBundleName, objectName, parentElement, isStatic)
|
||||
.GetComponent<DTMConstellation>();
|
||||
|
||||
constellation.maxParticles = maxParticles;
|
||||
constellation.maxLineCount = maxLineCount;
|
||||
constellation.spreadSize = spreadSize;
|
||||
constellation.maxConnectionsPerStar = maxConnectionsPerStar;
|
||||
constellation.maxConnectionDistance = maxConnectionDistance;
|
||||
constellation.activeStarSize = activeStarSize;
|
||||
constellation.lineWidth = lineWidth;
|
||||
constellation.orbitalVelocity = orbitalVelocity;
|
||||
constellation.angularVelocity = angularVelocity;
|
||||
|
||||
return constellation;
|
||||
}
|
||||
|
||||
public override void FirstSetUpObject(bool isFirstGenerated)
|
||||
{
|
||||
// 粒子数组和 Mesh 在此初始化(Prefab 实例化后立即运行)
|
||||
mainCam = EditorManager.instance.cameraManager.gameCamera.cam ?? Camera.main;
|
||||
particles = new ParticleSystem.Particle[maxParticles];
|
||||
|
||||
lineMesh = new Mesh();
|
||||
lineMesh.name = "Constellation_Lines_Mesh";
|
||||
lineMesh.MarkDynamic();
|
||||
|
||||
if (lineMeshFilter != null) lineMeshFilter.sharedMesh = lineMesh;
|
||||
|
||||
var psRenderer = starParticleSystem?.GetComponent<ParticleSystemRenderer>();
|
||||
if (psRenderer != null) psRenderer.enabled = true;
|
||||
|
||||
if (starParticleSystem != null)
|
||||
{
|
||||
var emission = starParticleSystem.emission;
|
||||
emission.enabled = false;
|
||||
}
|
||||
|
||||
// 实例化连线材质,确保 EmissionColor 修改不污染共享资源
|
||||
if (lineRenderer != null)
|
||||
lineRenderer.InitializeShader();
|
||||
}
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
base.AfterInitialize();
|
||||
ApplyColorSubmodule();
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
ApplyColorSubmodule();
|
||||
}
|
||||
|
||||
public override void OnDirtyRefresh(Dictionary<string, bool> flags)
|
||||
{
|
||||
ApplyColorSubmodule();
|
||||
}
|
||||
|
||||
/// <summary>将 colorSubmodule 的当前颜色同步到粒子和线条材质</summary>
|
||||
private void ApplyColorSubmodule()
|
||||
{
|
||||
if (colorSubmodule == null) return;
|
||||
|
||||
// BaseColor → 粒子 startColor(重新发射时使用,或逐帧设置已存粒子)
|
||||
if (particles != null)
|
||||
{
|
||||
int aliveCount = starParticleSystem != null
|
||||
? starParticleSystem.GetParticles(particles)
|
||||
: 0;
|
||||
Color32 c32 = colorSubmodule.currentBaseColor;
|
||||
for (int i = 0; i < aliveCount; i++)
|
||||
particles[i].startColor = c32;
|
||||
if (aliveCount > 0 && starParticleSystem != null)
|
||||
starParticleSystem.SetParticles(particles, aliveCount);
|
||||
}
|
||||
|
||||
// EmissionColor → 连线材质
|
||||
if (lineRenderer != null && lineRenderer.material != null)
|
||||
{
|
||||
starParticleSystem.GetComponent<ParticleSystemRenderer>().material.SetColor("_EmissionColor", colorSubmodule.GetCurrentEmissionColor());
|
||||
lineRenderer.material.SetColor("_EmissionColor", colorSubmodule.GetCurrentEmissionColor());
|
||||
Debug.Log($"Applied EmissionColor {colorSubmodule.GetCurrentEmissionColor()} to line material of {objectName}");
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!hasInitializedSpawning)
|
||||
{
|
||||
GenerateSingleConstellation();
|
||||
hasInitializedSpawning = true;
|
||||
}
|
||||
}
|
||||
|
||||
[Button("Refresh Constellation")]
|
||||
public void GenerateSingleConstellation()
|
||||
{
|
||||
starParticleSystem.Stop();
|
||||
starParticleSystem.Clear();
|
||||
|
||||
// --- 【新增】:通过代码接管并设置 Velocity over Lifetime 模块 ---
|
||||
// 注意:如果轨道旋转不为零,则强制开启该模块
|
||||
var vol = starParticleSystem.velocityOverLifetime;
|
||||
if (orbitalVelocity != Vector3.zero)
|
||||
{
|
||||
vol.enabled = true;
|
||||
vol.orbitalX = new ParticleSystem.MinMaxCurve(orbitalVelocity.x);
|
||||
vol.orbitalY = new ParticleSystem.MinMaxCurve(orbitalVelocity.y);
|
||||
vol.orbitalZ = new ParticleSystem.MinMaxCurve(orbitalVelocity.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
vol.enabled = false;
|
||||
}
|
||||
|
||||
// --- 【新增】:通过代码接管并设置 Rotation over Lifetime 模块 ---
|
||||
var rol = starParticleSystem.rotationOverLifetime;
|
||||
if (angularVelocity != 0f)
|
||||
{
|
||||
rol.enabled = true;
|
||||
// 对于普通的 Billboard 粒子,Z 轴旋转就是屏幕空间上的二维自转
|
||||
rol.z = new ParticleSystem.MinMaxCurve(angularVelocity * Mathf.Deg2Rad); // 转换为弧度
|
||||
}
|
||||
else
|
||||
{
|
||||
rol.enabled = false;
|
||||
}
|
||||
|
||||
ParticleSystem.EmitParams emitParams = new ParticleSystem.EmitParams();
|
||||
|
||||
for (int i = 0; i < maxParticles; i++)
|
||||
{
|
||||
float x = Random.Range(-spreadSize.x * 0.5f, spreadSize.x * 0.5f);
|
||||
float y = Random.Range(-spreadSize.y * 0.5f, spreadSize.y * 0.5f);
|
||||
float z = Random.Range(-spreadSize.z * 0.5f, spreadSize.z * 0.5f);
|
||||
emitParams.position = new Vector3(x, y, z);
|
||||
|
||||
// startColor 使用 colorSubmodule 的当前 BaseColor(单色)
|
||||
emitParams.startColor = colorSubmodule != null
|
||||
? (Color32)colorSubmodule.currentBaseColor
|
||||
: new Color32(0, 255, 255, 255);
|
||||
|
||||
// 为了让自身旋转可见,可以在生成时赋予一个随机的初始旋转角度
|
||||
emitParams.rotation3D = new Vector3(0, 0, Random.Range(0f, 360f));
|
||||
|
||||
starParticleSystem.Emit(emitParams, 1);
|
||||
}
|
||||
|
||||
starParticleSystem.Play();
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (starParticleSystem == null || lineMeshFilter == null) return;
|
||||
|
||||
int aliveCount = starParticleSystem.GetParticles(particles);
|
||||
if (aliveCount < 2)
|
||||
{
|
||||
lineMesh.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
int processCount = Mathf.Min(aliveCount, maxParticles);
|
||||
|
||||
NativeArray<Vector3> positions = new NativeArray<Vector3>(processCount, Allocator.TempJob);
|
||||
NativeArray<Color32> starColors = new NativeArray<Color32>(processCount, Allocator.TempJob);
|
||||
NativeArray<int> connectionCounts = new NativeArray<int>(processCount, Allocator.TempJob);
|
||||
NativeArray<bool> adjacencyMatrix = new NativeArray<bool>(processCount * processCount, Allocator.TempJob);
|
||||
|
||||
for (int i = 0; i < processCount; i++)
|
||||
{
|
||||
positions[i] = particles[i].position;
|
||||
starColors[i] = particles[i].GetCurrentColor(starParticleSystem);
|
||||
}
|
||||
|
||||
NativeList<Vector3> lineVertices = new NativeList<Vector3>(maxLineCount * 4, Allocator.TempJob);
|
||||
NativeList<Color32> lineColors = new NativeList<Color32>(maxLineCount * 4, Allocator.TempJob);
|
||||
NativeList<int> lineIndices = new NativeList<int>(maxLineCount * 6, Allocator.TempJob);
|
||||
|
||||
ConstellationJob job = new ConstellationJob
|
||||
{
|
||||
positions = positions,
|
||||
colors = starColors,
|
||||
sqrMaxDistance = maxConnectionDistance * maxConnectionDistance,
|
||||
lineWidth = lineWidth,
|
||||
maxLineCount = maxLineCount,
|
||||
maxConnectionsPerStar = maxConnectionsPerStar,
|
||||
cameraForward = mainCam.transform.forward,
|
||||
lineVertices = lineVertices,
|
||||
lineColors = lineColors,
|
||||
lineIndices = lineIndices,
|
||||
connectionCounts = connectionCounts,
|
||||
adjacencyMatrix = adjacencyMatrix
|
||||
};
|
||||
|
||||
JobHandle handle = job.Schedule();
|
||||
handle.Complete();
|
||||
|
||||
for (int i = 0; i < processCount; i++)
|
||||
{
|
||||
particles[i].startSize = connectionCounts[i] > 0 ? activeStarSize : 0f;
|
||||
}
|
||||
|
||||
starParticleSystem.SetParticles(particles, aliveCount);
|
||||
|
||||
lineMesh.Clear();
|
||||
lineMesh.SetVertices(lineVertices.AsArray());
|
||||
lineMesh.SetColors(lineColors.AsArray());
|
||||
lineMesh.SetIndices(lineIndices.AsArray(), MeshTopology.Triangles, 0);
|
||||
lineMesh.RecalculateBounds();
|
||||
|
||||
positions.Dispose();
|
||||
starColors.Dispose();
|
||||
lineVertices.Dispose();
|
||||
lineColors.Dispose();
|
||||
lineIndices.Dispose();
|
||||
connectionCounts.Dispose();
|
||||
adjacencyMatrix.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
[BurstCompile(CompileSynchronously = true)]
|
||||
public struct ConstellationJob : IJob
|
||||
{
|
||||
public NativeArray<Vector3> positions;
|
||||
public NativeArray<Color32> colors;
|
||||
public float sqrMaxDistance;
|
||||
public float lineWidth;
|
||||
public int maxLineCount;
|
||||
public int maxConnectionsPerStar;
|
||||
public Vector3 cameraForward;
|
||||
|
||||
public NativeList<Vector3> lineVertices;
|
||||
public NativeList<Color32> lineColors;
|
||||
public NativeList<int> lineIndices;
|
||||
public NativeArray<int> connectionCounts;
|
||||
public NativeArray<bool> adjacencyMatrix;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
int count = positions.Length;
|
||||
int currentLineCount = 0;
|
||||
int vertexOffset = 0;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (currentLineCount >= maxLineCount) break;
|
||||
if (connectionCounts[i] >= maxConnectionsPerStar) continue;
|
||||
|
||||
for (int j = i + 1; j < count; j++)
|
||||
{
|
||||
if (currentLineCount >= maxLineCount) break;
|
||||
if (connectionCounts[j] >= maxConnectionsPerStar) continue;
|
||||
|
||||
if (connectionCounts[i] == 0 || connectionCounts[j] == 0)
|
||||
{
|
||||
float distSq = (positions[i] - positions[j]).sqrMagnitude;
|
||||
if (distSq < sqrMaxDistance)
|
||||
{
|
||||
AddLine(i, j, ref vertexOffset, count);
|
||||
currentLineCount++;
|
||||
|
||||
if (connectionCounts[i] >= maxConnectionsPerStar)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (currentLineCount >= maxLineCount) break;
|
||||
if (connectionCounts[i] >= maxConnectionsPerStar) continue;
|
||||
|
||||
for (int j = i + 1; j < count; j++)
|
||||
{
|
||||
if (currentLineCount >= maxLineCount) break;
|
||||
if (connectionCounts[j] >= maxConnectionsPerStar) continue;
|
||||
|
||||
if (adjacencyMatrix[i * count + j]) continue;
|
||||
|
||||
float distSq = (positions[i] - positions[j]).sqrMagnitude;
|
||||
if (distSq < sqrMaxDistance)
|
||||
{
|
||||
AddLine(i, j, ref vertexOffset, count);
|
||||
currentLineCount++;
|
||||
|
||||
if (connectionCounts[i] >= maxConnectionsPerStar)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddLine(int i, int j, ref int vertexOffset, int count)
|
||||
{
|
||||
Vector3 posA = positions[i];
|
||||
Vector3 posB = positions[j];
|
||||
|
||||
Vector3 direction = posB - posA;
|
||||
float dirLength = direction.magnitude;
|
||||
if (dirLength < 0.0001f) return;
|
||||
direction /= dirLength;
|
||||
|
||||
Vector3 perpDir = Vector3.Cross(direction, cameraForward);
|
||||
if (perpDir.sqrMagnitude < 0.00001f) return;
|
||||
|
||||
Vector3 perp = perpDir.normalized * (lineWidth * 0.5f);
|
||||
|
||||
lineVertices.Add(posA + perp);
|
||||
lineVertices.Add(posA - perp);
|
||||
lineVertices.Add(posB - perp);
|
||||
lineVertices.Add(posB + perp);
|
||||
|
||||
lineColors.Add(colors[i]);
|
||||
lineColors.Add(colors[i]);
|
||||
lineColors.Add(colors[j]);
|
||||
lineColors.Add(colors[j]);
|
||||
|
||||
lineIndices.Add(vertexOffset + 0);
|
||||
lineIndices.Add(vertexOffset + 1);
|
||||
lineIndices.Add(vertexOffset + 2);
|
||||
lineIndices.Add(vertexOffset + 0);
|
||||
lineIndices.Add(vertexOffset + 2);
|
||||
lineIndices.Add(vertexOffset + 3);
|
||||
|
||||
vertexOffset += 4;
|
||||
|
||||
connectionCounts[i]++;
|
||||
connectionCounts[j]++;
|
||||
adjacencyMatrix[i * count + j] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ba3055fc57abcb41811796e6a0ed3aa
|
||||
@@ -72,6 +72,8 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
dtmTrail.widthCurve = widthCurve ?? DefaultWidthCurve();
|
||||
dtmTrail.trailAlphaGradient = trailGradient ?? DefaultTrailGradient();
|
||||
|
||||
if(isFirstGenerated) dtmTrail.AfterInitialize();
|
||||
|
||||
return dtmTrail;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,12 @@ namespace Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse
|
||||
effect.Recover();
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 posOffset = new Vector2(transformSubmodule.currentPosition.x, transformSubmodule.currentPosition.y);
|
||||
hold.trackPositioner.motion.offset = posOffset;
|
||||
meshGenerator.offset = posOffset;
|
||||
headPoint.motion.offset = posOffset;
|
||||
tailPoint.motion.offset = posOffset;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user