public void UpdateCursor(MeshMaking.MeshHitTarget meshHitTarget, MouseState mouseState) { this.mouseState = mouseState; hideCursor = meshHitTarget == null; if (!hideCursor) { PlaceCursor(meshHitTarget); } UpdateCursorVisuals(); }
private void PlaceCursor(MeshMaking.MeshHitTarget meshHitTarget) { int oldTargetsCount = targets != null ? targets.Length : 0; targetCenter = meshHitTarget.Center; targets = meshHitTarget.FaceVerts; lineRenderer.positionCount = targets.Length; // If new points are added, set their start position to the last position of the targets set if (oldTargetsCount < targets.Length && oldTargetsCount != 0) { Vector3 lastOldTarget = lineRenderer.GetPosition(oldTargetsCount - 1); for (int i = oldTargetsCount; i < targets.Length; i++) { lineRenderer.SetPosition(i, lastOldTarget); } } }
private IReadOnlyList <MeshHitTarget> CreateHittable(List <MeshBuilderTriangle> meshBuidlerTriangles) { MeshHitTarget[] ret = new MeshHitTarget[meshBuidlerTriangles.Count]; Dictionary <MeshBuilderTriangle, int> indexTable = new Dictionary <MeshBuilderTriangle, int>(); for (int i = 0; i < meshBuidlerTriangles.Count; i++) { indexTable.Add(meshBuidlerTriangles[i], i); } foreach (IGrouping <VoxelCell, MeshBuilderTriangle> item in meshBuidlerTriangles.GroupBy(item => item.SourceCell)) { foreach (var subItem in item.GroupBy(subItem => subItem.TargetCell)) { MeshBuilderTriangle firstValue = subItem.First(); MeshHitTarget hitTarget = new MeshHitTarget(firstValue.TargetCell, firstValue.SourceCell, subItem); foreach (MeshBuilderTriangle bedrock in subItem) { int index = indexTable[bedrock]; ret[index] = hitTarget; } } } return(ret.ToList().AsReadOnly()); }