public int InsertSegmentBetween(Side side0, Side side1) { // Insert the new segment (it becomes selected) int new_segnum = InsertSegmentSelectedSide(false); // Connect extruded side to side1 JoinSides(segment[new_segnum].side[selected_side], side1); side0.DisableDecals(); side1.DisableDecals(); // Done return(selected_segment); }
//Returns segnum, or -1 public int InsertSegmentSelectedSide(bool regular = false) { if (selected_side > -1 && selected_segment > -1) { Side s = segment[selected_segment].side[selected_side]; if (s.segment.neighbor[selected_side] < 0) { Vector3 side_normal = -s.FindNormal(); Vector3 side_right = s.FindBestEdgeDir(); // s.FindEdgeDir(0); Vector3 side_up = Vector3.Cross(side_normal, side_right).Normalized(); Vector3 side_center = s.FindCenter(); int idx_new = InsertSegmentBasic(s, side_center, side_normal, side_right, side_up, regular, editor.CurrExtrudeLength); segment[idx_new].CopyTexturesAndDecalsFromSegmentAtBack(segment[selected_segment], selected_side); s.DisableDecals(); // Tag the two segments (for refreshing decals) UnTagAllSegments(); segment[idx_new].m_tag = true; s.segment.m_tag = true; // Select the new cube (depending on the option) if (editor.ShouldInsertAdvance) { selected_segment = idx_new; //selected_side = (int)SideOrder.FRONT; } return(idx_new); } else { // Already has a neighbor } } else { // Nothing selected } return(-1); }