Files
Dec2017-Script-Dump/ProBuilderCore-Unity5/pb_BezierPoint.cs
T
2026-06-04 11:42:34 +02:00

120 lines
4.0 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine;
namespace ProBuilder2.Common
{
// Token: 0x02000048 RID: 72
[Serializable]
public struct pb_BezierPoint
{
// Token: 0x0600022A RID: 554 RVA: 0x0001DB57 File Offset: 0x0001BF57
public pb_BezierPoint(Vector3 position, Vector3 tangentIn, Vector3 tangentOut, Quaternion rotation)
{
this.position = position;
this.tangentIn = tangentIn;
this.tangentOut = tangentOut;
this.rotation = rotation;
}
// Token: 0x0600022B RID: 555 RVA: 0x0001DB78 File Offset: 0x0001BF78
public void EnforceTangentMode(pb_BezierTangentDirection master, pb_BezierTangentMode mode)
{
if (mode == pb_BezierTangentMode.Aligned)
{
if (master == pb_BezierTangentDirection.In)
{
this.tangentOut = this.position + (this.tangentOut - this.position).normalized * (this.tangentIn - this.position).magnitude;
}
else
{
this.tangentIn = this.position + (this.tangentIn - this.position).normalized * (this.tangentOut - this.position).magnitude;
}
}
else if (mode == pb_BezierTangentMode.Mirrored)
{
if (master == pb_BezierTangentDirection.In)
{
this.tangentOut = this.position - (this.tangentIn - this.position);
}
else
{
this.tangentIn = this.position - (this.tangentOut - this.position);
}
}
}
// Token: 0x0600022C RID: 556 RVA: 0x0001DC84 File Offset: 0x0001C084
public void SetPosition(Vector3 position)
{
Vector3 vector = position - this.position;
this.position = position;
this.tangentIn += vector;
this.tangentOut += vector;
}
// Token: 0x0600022D RID: 557 RVA: 0x0001DCC9 File Offset: 0x0001C0C9
public void SetTangentIn(Vector3 tangent, pb_BezierTangentMode mode)
{
this.tangentIn = tangent;
this.EnforceTangentMode(pb_BezierTangentDirection.In, mode);
}
// Token: 0x0600022E RID: 558 RVA: 0x0001DCDA File Offset: 0x0001C0DA
public void SetTangentOut(Vector3 tangent, pb_BezierTangentMode mode)
{
this.tangentOut = tangent;
this.EnforceTangentMode(pb_BezierTangentDirection.Out, mode);
}
// Token: 0x0600022F RID: 559 RVA: 0x0001DCEC File Offset: 0x0001C0EC
public static Vector3 QuadraticPosition(pb_BezierPoint a, pb_BezierPoint b, float t)
{
float num = (1f - t) * (1f - t) * a.position.x + 2f * (1f - t) * t * a.tangentOut.x + t * t * b.position.x;
float num2 = (1f - t) * (1f - t) * a.position.y + 2f * (1f - t) * t * a.tangentOut.y + t * t * b.position.y;
float num3 = (1f - t) * (1f - t) * a.position.z + 2f * (1f - t) * t * a.tangentOut.z + t * t * b.position.z;
return new Vector3(num, num2, num3);
}
// Token: 0x06000230 RID: 560 RVA: 0x0001DDE4 File Offset: 0x0001C1E4
public static Vector3 CubicPosition(pb_BezierPoint a, pb_BezierPoint b, float t)
{
t = Mathf.Clamp01(t);
float num = 1f - t;
return num * num * num * a.position + 3f * num * num * t * a.tangentOut + 3f * num * t * t * b.tangentIn + t * t * t * b.position;
}
// Token: 0x06000231 RID: 561 RVA: 0x0001DE60 File Offset: 0x0001C260
public static Vector3 GetLookDirection(IList<pb_BezierPoint> points, int index, int previous, int next)
{
if (previous < 0)
{
return (points[index].position - pb_BezierPoint.QuadraticPosition(points[index], points[next], 0.1f)).normalized;
}
if (next < 0)
{
return (pb_BezierPoint.QuadraticPosition(points[index], points[previous], 0.1f) - points[index].position).normalized;
}
if (next > -1 && previous > -1)
{
Vector3 normalized = (pb_BezierPoint.QuadraticPosition(points[index], points[previous], 0.1f) - points[index].position).normalized;
Vector3 normalized2 = (pb_BezierPoint.QuadraticPosition(points[index], points[next], 0.1f) - points[index].position).normalized;
return ((normalized + normalized2) * 0.5f).normalized;
}
return Vector3.forward;
}
// Token: 0x040001A4 RID: 420
public Vector3 position;
// Token: 0x040001A5 RID: 421
public Vector3 tangentIn;
// Token: 0x040001A6 RID: 422
public Vector3 tangentOut;
// Token: 0x040001A7 RID: 423
public Quaternion rotation;
}
}