去掉obi,使用自写绳索

This commit is contained in:
2026-02-23 20:51:03 +08:00
parent cb636f862d
commit 91e2309eeb
2011 changed files with 2593 additions and 190578 deletions

View File

@@ -1,25 +0,0 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace Obi
{
public abstract class ObiBlueprintRenderMode
{
protected ObiActorBlueprintEditor editor;
public abstract string name
{
get;
}
public ObiBlueprintRenderMode(ObiActorBlueprintEditor editor)
{
this.editor = editor;
}
public virtual void DrawWithCamera(Camera camera) {}
public virtual void OnSceneRepaint(SceneView sceneView) {}
public virtual void Refresh(){}
public virtual void OnDestroy() { }
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d60f616a126974e6d8be81fbbe459bac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,63 +0,0 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace Obi
{
public class ObiBlueprintRenderModeAerodynamicConstraints : ObiBlueprintRenderMode
{
public override string name
{
get { return "Aerodynamic constraints"; }
}
public ObiMeshBasedActorBlueprintEditor meshBasedEditor
{
get { return editor as ObiMeshBasedActorBlueprintEditor; }
}
public ObiBlueprintRenderModeAerodynamicConstraints(ObiMeshBasedActorBlueprintEditor editor) : base(editor)
{
}
public override void OnSceneRepaint(SceneView sceneView)
{
var meshEditor = editor as ObiMeshBasedActorBlueprintEditor;
if (meshEditor != null)
{
// Get per-particle normals:
Vector3[] normals = meshEditor.sourceMesh.normals;
Vector3[] particleNormals = new Vector3[meshEditor.blueprint.particleCount];
for (int i = 0; i < normals.Length; ++i)
{
int welded = meshEditor.VertexToParticle(i);
particleNormals[welded] = normals[i];
}
using (new Handles.DrawingScope(Color.blue, Matrix4x4.identity))
{
var constraints = editor.blueprint.GetConstraintsByType(Oni.ConstraintType.Aerodynamics) as ObiConstraints<ObiAerodynamicConstraintsBatch>;
if (constraints != null)
{
Vector3[] lines = new Vector3[constraints.GetActiveConstraintCount() * 2];
int lineIndex = 0;
foreach (var batch in constraints.batches)
{
for (int i = 0; i < batch.activeConstraintCount; ++i)
{
int particleIndex = batch.particleIndices[i];
Vector3 position = editor.blueprint.GetParticlePosition(particleIndex);
lines[lineIndex++] = position;
lines[lineIndex++] = position + particleNormals[particleIndex] * 0.025f;
}
}
Handles.DrawLines(lines);
}
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 18881e26e784d47aaa8aa27c93fe0b49
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,44 +0,0 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace Obi
{
public class ObiBlueprintRenderModeBendConstraints : ObiBlueprintRenderMode
{
public override string name
{
get { return "Bend constraints"; }
}
public ObiBlueprintRenderModeBendConstraints(ObiActorBlueprintEditor editor) : base(editor)
{
}
public override void OnSceneRepaint(SceneView sceneView)
{
using (new Handles.DrawingScope(Color.magenta, Matrix4x4.identity))
{
var constraints = editor.blueprint.GetConstraintsByType(Oni.ConstraintType.Bending) as ObiConstraints<ObiBendConstraintsBatch>;
if (constraints != null)
{
Vector3[] lines = new Vector3[constraints.GetActiveConstraintCount() * 2];
int lineIndex = 0;
foreach (var batch in constraints.batches)
{
for (int i = 0; i < batch.activeConstraintCount; ++i)
{
lines[lineIndex++] = editor.blueprint.GetParticlePosition(batch.particleIndices[i * 3]);
lines[lineIndex++] = editor.blueprint.GetParticlePosition(batch.particleIndices[i * 3 + 1]);
}
}
Handles.DrawLines(lines);
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 15e21bc6bea1c4320948413c8d7334bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,44 +0,0 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace Obi
{
public class ObiBlueprintRenderModeDistanceConstraints : ObiBlueprintRenderMode
{
public override string name
{
get { return "Distance constraints"; }
}
public ObiBlueprintRenderModeDistanceConstraints(ObiActorBlueprintEditor editor) : base(editor)
{
}
public override void OnSceneRepaint(SceneView sceneView)
{
using (new Handles.DrawingScope(Color.green, Matrix4x4.identity))
{
var constraints = editor.blueprint.GetConstraintsByType(Oni.ConstraintType.Distance) as ObiConstraints<ObiDistanceConstraintsBatch>;
if (constraints != null)
{
Vector3[] lines = new Vector3[constraints.GetActiveConstraintCount() * 2];
int lineIndex = 0;
foreach (var batch in constraints.batches)
{
for (int i = 0; i < batch.activeConstraintCount; ++i)
{
lines[lineIndex++] = editor.blueprint.GetParticlePosition(batch.particleIndices[i * 2]);
lines[lineIndex++] = editor.blueprint.GetParticlePosition(batch.particleIndices[i * 2 + 1]);
}
}
Handles.DrawLines(lines);
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ac734c05a2b994f148fd43cd5829b1be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,46 +0,0 @@
using UnityEditor;
namespace Obi
{
public class ObiBlueprintRenderModeMesh : ObiBlueprintRenderMode
{
public override string name
{
get { return "Mesh"; }
}
public ObiMeshBasedActorBlueprintEditor meshBasedEditor
{
get { return editor as ObiMeshBasedActorBlueprintEditor; }
}
public ObiBlueprintRenderModeMesh(ObiMeshBasedActorBlueprintEditor editor) : base(editor)
{
}
public override void OnSceneRepaint(SceneView sceneView)
{
if (meshBasedEditor.currentTool is ObiPaintBrushEditorTool)
{
ObiPaintBrushEditorTool paintTool = (ObiPaintBrushEditorTool)meshBasedEditor.currentTool;
float[] weights = new float[ObiActorBlueprintEditor.selectionStatus.Length];
for (int i = 0; i < weights.Length; i++)
{
if (paintTool.selectionMask && !ObiActorBlueprintEditor.selectionStatus[i])
weights[i] = 0;
else
weights[i] = 1;
}
float[] wireframeWeights = new float[paintTool.paintBrush.weights.Length];
for (int i = 0; i < wireframeWeights.Length; i++)
wireframeWeights[i] = paintTool.paintBrush.weights[i];
meshBasedEditor.DrawGradientMesh(weights, wireframeWeights);
}
else
meshBasedEditor.DrawGradientMesh();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: dbcd302f71d6446cd976f736b365c7ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,65 +0,0 @@
using UnityEngine;
using System.Collections;
namespace Obi
{
public class ObiBlueprintRenderModeParticles : ObiBlueprintRenderMode
{
public override string name
{
get { return "Particles"; }
}
private Shader shader;
private Material material;
private ParticleImpostorRendering impostorDrawer;
private MaterialPropertyBlock mpb;
public ObiBlueprintRenderModeParticles(ObiActorBlueprintEditor editor) :base(editor)
{
impostorDrawer = new ParticleImpostorRendering();
impostorDrawer.UpdateMeshes(editor.blueprint);
mpb = new MaterialPropertyBlock();
}
void CreateMaterialIfNeeded()
{
if (shader == null)
{
shader = Shader.Find("Obi/EditorParticles");
if (shader != null)
{
if (!shader.isSupported)
Debug.LogWarning("Particle rendering shader not suported.");
if (material == null || material.shader != shader)
{
GameObject.DestroyImmediate(material);
material = new Material(shader);
material.hideFlags = HideFlags.HideAndDontSave;
}
}
}
}
public override void DrawWithCamera(Camera camera)
{
CreateMaterialIfNeeded();
mpb.SetFloat("_RadiusScale", 1);
mpb.SetColor("_ParticleColor", Color.white);
foreach (Mesh mesh in impostorDrawer.Meshes)
Graphics.DrawMesh(mesh, Matrix4x4.identity, material, 0, camera, 0, mpb);
}
public override void Refresh()
{
impostorDrawer.UpdateMeshes(editor.blueprint, editor.visible, editor.tint);
}
public override void OnDestroy()
{
GameObject.DestroyImmediate(material);
impostorDrawer.ClearMeshes();
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b51ea2becbebe48ba9d77e9d28403f51
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,54 +0,0 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace Obi
{
public class ObiBlueprintRenderModeShapeMatchingConstraints : ObiBlueprintRenderMode
{
public override string name
{
get { return "Shape matching clusters"; }
}
public ObiBlueprintRenderModeShapeMatchingConstraints(ObiActorBlueprintEditor editor) : base(editor)
{
}
public override void OnSceneRepaint(SceneView sceneView)
{
using (new Handles.DrawingScope(Color.cyan, Matrix4x4.identity))
{
var constraints = editor.blueprint.GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints<ObiShapeMatchingConstraintsBatch>;
if (constraints != null)
{
List<Vector3> lines = new List<Vector3>();
foreach (var batch in constraints.batches)
{
for (int i = 0; i < batch.activeConstraintCount; ++i)
{
int first = batch.firstIndex[i];
Vector3 p1 = editor.blueprint.GetParticlePosition(batch.particleIndices[first]);
for (int j = 1; j < batch.numIndices[i]; ++j)
{
int index = first + j;
Vector3 p2 = editor.blueprint.GetParticlePosition(batch.particleIndices[index]);
lines.Add(p1);
lines.Add(p2);
}
}
}
Handles.DrawLines(lines.ToArray());
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e5ff128cfebee45ffb8266eb3e75522e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,43 +0,0 @@
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
namespace Obi
{
public class ObiBlueprintRenderModeTetherConstraints : ObiBlueprintRenderMode
{
public override string name
{
get { return "Tether constraints"; }
}
public ObiBlueprintRenderModeTetherConstraints(ObiActorBlueprintEditor editor) : base(editor)
{
}
public override void OnSceneRepaint(SceneView sceneView)
{
using (new Handles.DrawingScope(Color.yellow, Matrix4x4.identity))
{
var constraints = editor.blueprint.GetConstraintsByType(Oni.ConstraintType.Tether) as ObiConstraints<ObiTetherConstraintsBatch>;
if (constraints != null)
{
Vector3[] lines = new Vector3[constraints.GetActiveConstraintCount() * 2];
int lineIndex = 0;
foreach (var batch in constraints.batches)
{
for (int i = 0; i < batch.activeConstraintCount; ++i)
{
lines[lineIndex++] = editor.blueprint.GetParticlePosition(batch.particleIndices[i * 2]);
lines[lineIndex++] = editor.blueprint.GetParticlePosition(batch.particleIndices[i * 2 + 1]);
}
}
Handles.DrawLines(lines);
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 63054cbedb75c4aa7906bf1c24552085
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: