private void ChaikinSplit(Rail OldPath, ref Rail NewPath, int Index)//lol { KeyFrame NewNode = NewPath.frames[Index].DeepCopy(); int NewNodeIndex = NewPath.frames.Length; NewPath.InsertFrame(NewNode, NewPath.frames.Length);//Add node at the end to not change the indicies KeyFrame MiddleKeyFrame = OldPath.frames[Index]; KeyFrame FirstKeyframe = OldPath.frames[MiddleKeyFrame.connections[0]]; KeyFrame LastKeyFrame = OldPath.frames[MiddleKeyFrame.connections[1]]; NewPath.frames[Index].x = (short)(0.25 * FirstKeyframe.x + 0.75 * MiddleKeyFrame.x); NewPath.frames[Index].y = (short)(0.25 * FirstKeyframe.y + 0.75 * MiddleKeyFrame.y); NewPath.frames[Index].z = (short)(0.25 * FirstKeyframe.z + 0.75 * MiddleKeyFrame.z); NewPath.frames[NewNodeIndex].x = (short)(0.25 * LastKeyFrame.x + 0.75 * MiddleKeyFrame.x); NewPath.frames[NewNodeIndex].y = (short)(0.25 * LastKeyFrame.y + 0.75 * MiddleKeyFrame.y); NewPath.frames[NewNodeIndex].z = (short)(0.25 * LastKeyFrame.z + 0.75 * MiddleKeyFrame.z); NewPath.frames[Index].connections[1] = (short)NewNodeIndex; NewPath.frames[NewNodeIndex].connections[0] = (short)Index; int ConnectToMiddleIndexOfIndex = -1; for (int i = 0; i < LastKeyFrame.connections.Length; i++) { if (LastKeyFrame.connections[i] == (short)Index) { ConnectToMiddleIndexOfIndex = i; } } if (ConnectToMiddleIndexOfIndex != -1) { NewPath.frames[MiddleKeyFrame.connections[1]].connections[ConnectToMiddleIndexOfIndex] = (short)NewNodeIndex; } }