// This is called to update UV dragging protected virtual void UpdateDragUV() { float u_ray = 1.0f; // Calculate intersection position this.Level.plane.GetIntersection(General.Map.VisualCamera.Position, General.Map.VisualCamera.Target, ref u_ray); Vector3D intersect = General.Map.VisualCamera.Position + (General.Map.VisualCamera.Target - General.Map.VisualCamera.Position) * u_ray; // Calculate offsets Vector3D dragdelta = intersect - dragorigin; float offsetx = dragdelta.x; float offsety = dragdelta.y; bool lockX = General.Interface.CtrlState && !General.Interface.ShiftState; bool lockY = !General.Interface.CtrlState && General.Interface.ShiftState; if (lockX || lockY) { float camAngle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY); if (camAngle > 315 || camAngle < 46) { if (lockX) { offsetx = 0; } if (lockY) { offsety = 0; } } else if (camAngle > 225) { if (lockX) { offsety = 0; } if (lockY) { offsetx = 0; } } else if (camAngle > 135) { if (lockX) { offsetx = 0; } if (lockY) { offsety = 0; } } else { if (lockX) { offsety = 0; } if (lockY) { offsetx = 0; } } } //mxd. Modify offsets based on surface and camera angles float angle; if (GeometryType == VisualGeometryType.CEILING) { angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationceiling", 0f)); } else { angle = Angle2D.DegToRad(level.sector.Fields.GetValue("rotationfloor", 0f)); } Vector2D v = new Vector2D(offsetx, offsety).GetRotated(angle); offsetx = (int)Math.Round(v.x); offsety = (int)Math.Round(v.y); // Calculate deltas int deltax, deltay; if (General.Interface.CtrlState && General.Interface.ShiftState) { //mxd. Clamp to grid size? int newoffsetx = startoffsetx - (int)Math.Round(offsetx); int newoffsety = startoffsety + (int)Math.Round(offsety); deltax = prevoffsetx - newoffsetx; deltay = prevoffsety - newoffsety; if (Math.Abs(deltax) >= General.Map.Grid.GridSize) { deltax = General.Map.Grid.GridSize * Math.Sign(deltax); prevoffsetx = newoffsetx; } else { deltax = 0; } if (Math.Abs(deltay) >= General.Map.Grid.GridSize) { deltay = General.Map.Grid.GridSize * Math.Sign(deltay); prevoffsety = newoffsety; } else { deltay = 0; } } else { int newoffsetx = startoffsetx - (int)Math.Round(offsetx); int newoffsety = startoffsety + (int)Math.Round(offsety); deltax = prevoffsetx - newoffsetx; deltay = prevoffsety - newoffsety; prevoffsetx = newoffsetx; prevoffsety = newoffsety; } //mxd. Apply offset? if (deltax != 0 || deltay != 0) { mode.ApplyFlatOffsetChange(deltax, deltay); } mode.ShowTargetInfo(); }