1
This commit is contained in:
@@ -15,7 +15,7 @@ public class FindBezier : ModuleFind<DataBezier> {
|
||||
public override bool Find(Vector3 position, out DataBezier bezier) {
|
||||
List<DataPlate> plates = AssetsPlate.Datas;
|
||||
for (int i = 0; i < plates.Count; i++) {
|
||||
Vector3 localPosition = position - plates[i].designPosition;
|
||||
Vector3 localPosition = position - plates[i].dataDesign.position;
|
||||
bezier = Find(plates[i], localPosition);
|
||||
if (bezier != null) { return true; }
|
||||
}
|
||||
@@ -24,14 +24,14 @@ public class FindBezier : ModuleFind<DataBezier> {
|
||||
|
||||
/// <summary> 查询匹配的边 </summary>
|
||||
private DataBezier Find(DataPlate plate, Vector3 localPosition) {
|
||||
for (int i = 0; i < plate.sides.Count; i++) {
|
||||
DataBezier bezier = Find(plate.sides[i], localPosition);
|
||||
for (int i = 0; i < plate.plateSides.Count; i++) {
|
||||
DataBezier bezier = Find(plate.plateSides[i], localPosition);
|
||||
if (bezier != null) { return bezier; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary> 查询匹配的边 </summary>
|
||||
private DataBezier Find(DataSide side, Vector3 localPosition) {
|
||||
private DataBezier Find(DataPlateSide side, Vector3 localPosition) {
|
||||
if (side.bezier == Bezier.一阶) { return null; }
|
||||
float aDis = Vector3.Distance(side.aBezier, localPosition);
|
||||
if (aDis < FindRange) { return new DataBezier() { isA = true, side = side }; }
|
||||
|
||||
@@ -5,17 +5,17 @@ using UnityEngine;
|
||||
/// <summary>
|
||||
/// 查找点
|
||||
/// </summary>
|
||||
public class FindPoint : ModuleFind<DataPoint> {
|
||||
public class FindPoint : ModuleFind<DataPlatePoint> {
|
||||
public readonly float FindRange = 0.01f;
|
||||
/// <summary> 板片资产 </summary>
|
||||
public ModuleAssets<DataPlate> AssetsPlate => ModuleCore.AssetsPlate;
|
||||
|
||||
protected override void Awake() => ModuleCore.FindPoint = this;
|
||||
|
||||
public override bool Find(Vector3 position, out DataPoint point) {
|
||||
public override bool Find(Vector3 position, out DataPlatePoint point) {
|
||||
List<DataPlate> plates = AssetsPlate.Datas;
|
||||
for (int i = 0; i < plates.Count; i++) {
|
||||
Vector3 localPosition = position - plates[i].designPosition;
|
||||
Vector3 localPosition = position - plates[i].dataDesign.position;
|
||||
point = Find(plates[i], localPosition);
|
||||
if (point != null) { return true; }
|
||||
}
|
||||
@@ -23,8 +23,8 @@ public class FindPoint : ModuleFind<DataPoint> {
|
||||
}
|
||||
|
||||
/// <summary> 查询匹配的点 </summary>
|
||||
private DataPoint Find(DataPlate plate, Vector3 localPosition) {
|
||||
List<DataPoint> points = plate.points;
|
||||
private DataPlatePoint Find(DataPlate plate, Vector3 localPosition) {
|
||||
List<DataPlatePoint> points = plate.platePoints;
|
||||
for (int i = 0; i < points.Count; i++) {
|
||||
float distance = Vector3.Distance(points[i].position, localPosition);
|
||||
if (distance > FindRange) { continue; }
|
||||
|
||||
@@ -5,17 +5,17 @@ using UnityEngine;
|
||||
/// <summary>
|
||||
/// 查找边
|
||||
/// </summary>
|
||||
public class FindSide : ModuleFind<DataSide> {
|
||||
public readonly float FindRange = 0.01f;
|
||||
public class FindSide : ModuleFind<DataPlateSide> {
|
||||
public readonly float FindRange = 0.01f;
|
||||
/// <summary> 板片资产 </summary>
|
||||
public ModuleAssets<DataPlate> AssetsPlate => ModuleCore.AssetsPlate;
|
||||
|
||||
protected override void Awake() => ModuleCore.FindSide = this;
|
||||
|
||||
public override bool Find(Vector3 position, out DataSide side) {
|
||||
public override bool Find(Vector3 position, out DataPlateSide side) {
|
||||
List<DataPlate> plates = AssetsPlate.Datas;
|
||||
for (int i = 0; i < plates.Count; i++) {
|
||||
Vector3 localPosition = position - plates[i].designPosition;
|
||||
Vector3 localPosition = position - plates[i].dataDesign.position;
|
||||
side = Find(plates[i], localPosition);
|
||||
if (side != null) { return true; }
|
||||
}
|
||||
@@ -23,20 +23,20 @@ public class FindSide : ModuleFind<DataSide> {
|
||||
}
|
||||
|
||||
/// <summary> 查询匹配的边 </summary>
|
||||
private DataSide Find(DataPlate plate, Vector3 localPosition) {
|
||||
for (int i = 0; i < plate.sides.Count; i++) {
|
||||
DataSide side = Find(plate.sides[i], localPosition);
|
||||
private DataPlateSide Find(DataPlate plate, Vector3 localPosition) {
|
||||
for (int i = 0; i < plate.plateSides.Count; i++) {
|
||||
DataPlateSide side = Find(plate.plateSides[i], localPosition);
|
||||
if (side != null) { return side; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// <summary> 查询匹配的边 </summary>
|
||||
private DataSide Find(DataSide side, Vector3 localPosition) {
|
||||
for (int i = 0; i < side.lines.Length; i++) {
|
||||
Vector3 a = side.lines[i].a;
|
||||
Vector3 b = side.lines[i].b;
|
||||
private DataPlateSide Find(DataPlateSide side, Vector3 localPosition) {
|
||||
DataPlateSideDesign design = side.dataDesign;
|
||||
for (int i = 0; i < design.lines.Length; i++) {
|
||||
Vector3 a = design.lines[i].a;
|
||||
Vector3 b = design.lines[i].b;
|
||||
float distance = ProjectDistance(a, b, localPosition);
|
||||
//Debug.Log($"{a} , {b} , {localPosition}");
|
||||
if (distance < FindRange) { return side; }
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user