initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,72 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Splines;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace UnityEditor.Splines
|
||||
{
|
||||
struct BezierBuilder
|
||||
{
|
||||
readonly List<BezierKnot> m_ResultKnots;
|
||||
readonly bool m_Closed;
|
||||
|
||||
int knotCount => m_ResultKnots.Count;
|
||||
public int segmentCount => m_Closed ? m_ResultKnots.Count : m_ResultKnots.Count - 1;
|
||||
|
||||
public BezierBuilder(List<BezierKnot> result, bool closed, int targetKnotCount)
|
||||
{
|
||||
m_ResultKnots = result;
|
||||
for (int i = 0; i < targetKnotCount; ++i)
|
||||
{
|
||||
var knot = new BezierKnot();
|
||||
knot.Rotation = quaternion.identity;
|
||||
|
||||
m_ResultKnots.Add(knot);
|
||||
}
|
||||
|
||||
m_Closed = closed;
|
||||
}
|
||||
|
||||
public void SetKnot(int index, float3 position, float3 tangentIn, float3 tangentOut, quaternion rotation)
|
||||
{
|
||||
var current = m_ResultKnots[index];
|
||||
|
||||
current.Position = position;
|
||||
current.TangentIn = tangentIn;
|
||||
current.TangentOut = tangentOut;
|
||||
current.Rotation = rotation;
|
||||
|
||||
m_ResultKnots[index] = current;
|
||||
}
|
||||
|
||||
void GetSegmentEndIndex(int index, out int endIndex)
|
||||
{
|
||||
endIndex = m_Closed ? (index + 1) % knotCount : index + 1;
|
||||
}
|
||||
|
||||
public void SetSegment(int index, float3 posA, float3 tangentOutA, quaternion rotationA, float3 posB, float3 tangentInB, quaternion rotationB)
|
||||
{
|
||||
GetSegmentEndIndex(index, out int nextIndex);
|
||||
var current = m_ResultKnots[index];
|
||||
current.Position = posA;
|
||||
current.Rotation = rotationA;
|
||||
current.TangentOut = tangentOutA;
|
||||
|
||||
var next = m_ResultKnots[nextIndex];
|
||||
next.Position = posB;
|
||||
next.Rotation = rotationB;
|
||||
next.TangentIn = tangentInB;
|
||||
|
||||
if (!m_Closed)
|
||||
{
|
||||
if (index == 0)
|
||||
current.TangentIn = -current.TangentOut;
|
||||
else if (nextIndex == knotCount - 1)
|
||||
next.TangentOut = -next.TangentIn;
|
||||
}
|
||||
|
||||
m_ResultKnots[index] = current;
|
||||
m_ResultKnots[nextIndex] = next;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6c652dfb0c532cd4991ca0f23b93b51f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue