public void ClearSelection() { selectedobjects = new List <IVisualEventReceiver>(); foreach (KeyValuePair <Sector, VisualSector> vs in allsectors) { BaseVisualSector bvs = (BaseVisualSector)vs.Value; if (bvs.Floor != null) { bvs.Floor.Selected = false; } if (bvs.Ceiling != null) { bvs.Ceiling.Selected = false; } foreach (Sidedef sd in vs.Key.Sidedefs) { List <VisualGeometry> sidedefgeos = bvs.GetSidedefGeometry(sd); foreach (VisualGeometry sdg in sidedefgeos) { sdg.Selected = false; } } } foreach (KeyValuePair <Thing, VisualThing> vt in allthings) { BaseVisualThing bvt = (BaseVisualThing)vt.Value; bvt.Selected = false; } }
// This updates the VisualSectors and VisualThings that have their Changed property set private void UpdateChangedObjects() { foreach (KeyValuePair <Sector, VisualSector> vs in allsectors) { if (vs.Value != null) { BaseVisualSector bvs = (BaseVisualSector)vs.Value; if (bvs.Changed) { bvs.Rebuild(); } } } foreach (KeyValuePair <Thing, VisualThing> vt in allthings) { if (vt.Value != null) { BaseVisualThing bvt = (BaseVisualThing)vt.Value; if (bvt.Changed) { bvt.Rebuild(); } } } }
// Thisvirtuals the secotr and neightbours if needed public void UpdateSectorGeometry(bool includeneighbours) { // Rebuild sector this.Changed = true; // Go for all things in this sector foreach (Thing t in General.Map.Map.Things) { if (t.Sector == this.Sector) { if (mode.VisualThingExists(t)) { // Update thing BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing); vt.Changed = true; } } } if (includeneighbours) { // Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted foreach (Sidedef sd in this.Sector.Sidedefs) { if (sd.Other != null) { if (mode.VisualSectorExists(sd.Other.Sector)) { BaseVisualSector bvs = (BaseVisualSector)mode.GetVisualSector(sd.Other.Sector); bvs.Changed = true; } } } } }
// This makes a list of the selected object private void RebuildSelectedObjectsList() { // Make list of selected objects selectedobjects = new List <IVisualEventReceiver>(); foreach (KeyValuePair <Sector, VisualSector> vs in allsectors) { if (vs.Value != null) { BaseVisualSector bvs = (BaseVisualSector)vs.Value; if ((bvs.Floor != null) && bvs.Floor.Selected) { selectedobjects.Add(bvs.Floor); } if ((bvs.Ceiling != null) && bvs.Ceiling.Selected) { selectedobjects.Add(bvs.Ceiling); } foreach (Sidedef sd in vs.Key.Sidedefs) { List <VisualGeometry> sidedefgeos = bvs.GetSidedefGeometry(sd); foreach (VisualGeometry sdg in sidedefgeos) { if (sdg.Selected) { selectedobjects.Add((sdg as IVisualEventReceiver)); } } } } } foreach (KeyValuePair <Thing, VisualThing> vt in allthings) { if (vt.Value != null) { BaseVisualThing bvt = (BaseVisualThing)vt.Value; if (bvt.Selected) { selectedobjects.Add(bvt); } } } }
// Sector brightness change public virtual void OnChangeTargetBrightness(bool up) { if (!Sector.Changed) { // Change brightness mode.CreateUndo("Change sector brightness", UndoGroup.SectorBrightnessChange, Sector.Sector.FixedIndex); if (up) { Sector.Sector.Brightness = General.Map.Config.BrightnessLevels.GetNextHigher(Sector.Sector.Brightness); } else { Sector.Sector.Brightness = General.Map.Config.BrightnessLevels.GetNextLower(Sector.Sector.Brightness); } mode.SetActionResult("Changed sector brightness to " + Sector.Sector.Brightness + "."); Sector.Sector.UpdateCache(); // Rebuild sector Sector.Changed = true; // Go for all things in this sector foreach (Thing t in General.Map.Map.Things) { if (t.Sector == Sector.Sector) { if (mode.VisualThingExists(t)) { // Update thing BaseVisualThing vt = (mode.GetVisualThing(t) as BaseVisualThing); vt.Changed = true; } } } } }
//mxd. call this to update sector and things in it when Sector.Fields are changed override public void UpdateSectorData() { //update sector data SectorData data = GetSectorData(); data.UpdateForced(); //update sector Rebuild(); //update things in this sector foreach (Thing t in General.Map.Map.Things) { if (t.Sector == this.Sector) { if (mode.VisualThingExists(t)) { // Update thing BaseVisualThing vt = (BaseVisualThing)mode.GetVisualThing(t); vt.Rebuild(); } } } }
// This updates this virtual the sector and neightbours if needed override public void UpdateSectorGeometry(bool includeneighbours) { if (isupdating) { return; } isupdating = true; changed = true; // Not sure what from this part we need, so commented out for now SectorData data = mode.GetSectorDataEx(this.Sector); //mxd if (data != null) //mxd { data.Reset(false); // Update sectors that rely on this sector foreach (KeyValuePair <Sector, bool> s in data.UpdateAlso) { SectorData other = mode.GetSectorDataEx(s.Key); if (other != null) { other.Reset(s.Value); } } } // Go for all things in this sector foreach (Thing t in General.Map.Map.Things) { if (t.Sector == this.Sector) { if (mode.VisualThingExists(t)) { // Update thing BaseVisualThing vt = (BaseVisualThing)mode.GetVisualThing(t); vt.Changed = true; } } } if (includeneighbours) { // Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted foreach (Sidedef sd in this.Sector.Sidedefs) { if (sd.Other != null) { if (mode.VisualSectorExists(sd.Other.Sector)) { SectorData other = mode.GetSectorDataEx(sd.Other.Sector); if (other != null) { other.Reset(other.UpdateAlso.Count > 0 ? true : false); // biwa. Make sure to reset the update status of dependend sectors. This fixes #250, where 3D floors where not updated when the control sector was sloped using line action 181 } else { BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(sd.Other.Sector); vs.Changed = true; } } } } } Sector.UpdateFogColor(); //mxd isupdating = false; }
// This creates a visual thing protected override VisualThing CreateVisualThing(Thing t) { BaseVisualThing vt = new BaseVisualThing(this, t); return(vt.Setup() ? vt : null); }
// This makes sure we are updated with the source linedef information public override void Update() { if (l.Front == null || l.Back == null) { return; //mxd } // Find the vertex furthest from the line Vertex foundv = null; double founddist = -1.0f; foreach (Sidedef sd in data.Sector.Sidedefs) { Vertex v = sd.IsFront ? sd.Line.Start : sd.Line.End; double d = l.DistanceToSq(v.Position, false); if (d > founddist) { foundv = v; founddist = d; } } if (foundv == null) { return; //mxd } bool updatesides = false; // Align floor with back of line if ((l.Args[0] == 1) && (l.Front.Sector == data.Sector)) { Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Back.Sector.FloorHeight); Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Back.Sector.FloorHeight); Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.FloorHeight); data.Floor.plane = (l.SideOfLine(v3) < 0.0f ? new Plane(v1, v2, v3, true) : new Plane(v2, v1, v3, true)); //mxd. Update only when actually changed if (storedfloor != data.Floor.plane) { storedfloor = data.Floor.plane; updatesides = true; } } // Align floor with front of line else if ((l.Args[0] == 2) && (l.Back.Sector == data.Sector)) { Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Front.Sector.FloorHeight); Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Front.Sector.FloorHeight); Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.FloorHeight); data.Floor.plane = (l.SideOfLine(v3) < 0.0f ? new Plane(v1, v2, v3, true) : new Plane(v2, v1, v3, true)); //mxd. Update only when actually changed if (storedfloor != data.Floor.plane) { storedfloor = data.Floor.plane; updatesides = true; } } // Align ceiling with back of line if ((l.Args[1] == 1) && (l.Front.Sector == data.Sector)) { Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Back.Sector.CeilHeight); Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Back.Sector.CeilHeight); Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.CeilHeight); data.Ceiling.plane = (l.SideOfLine(v3) > 0.0f ? new Plane(v1, v2, v3, false) : new Plane(v2, v1, v3, false)); //mxd. Update only when actually changed if (storedceiling != data.Ceiling.plane) { storedceiling = data.Ceiling.plane; updatesides = true; } } // Align ceiling with front of line else if ((l.Args[1] == 2) && (l.Back.Sector == data.Sector)) { Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Front.Sector.CeilHeight); Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Front.Sector.CeilHeight); Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.CeilHeight); data.Ceiling.plane = (l.SideOfLine(v3) > 0.0f ? new Plane(v1, v2, v3, false) : new Plane(v2, v1, v3, false)); //mxd. Update only when actually changed if (storedceiling != data.Ceiling.plane) { storedceiling = data.Ceiling.plane; updatesides = true; } } //mxd. Update outer sidedef geometry if (updatesides) { UpdateSectorSides(data.Sector); // Update sectors with PlaneCopySlope Effect... List <SectorData> toupdate = new List <SectorData>(); foreach (Sector s in data.UpdateAlso.Keys) { SectorData osd = data.Mode.GetSectorDataEx(s); if (osd == null) { continue; } foreach (SectorEffect e in osd.Effects) { if (e is EffectPlaneCopySlope) { toupdate.Add(osd); break; } } } // Do it in 2 steps, because SectorData.Reset() may change SectorData.UpdateAlso collection... foreach (SectorData sd in toupdate) { // Update PlaneCopySlope Effect... sd.Reset(false); // Update outer sides... UpdateSectorSides(sd.Sector); } // Update all things in the sector foreach (Thing t in General.Map.Map.Things) { if (t.Sector == data.Sector) { if (data.Mode.VisualThingExists(t)) { // Update thing BaseVisualThing vt = (BaseVisualThing)data.Mode.GetVisualThing(t); vt.Changed = true; } } } } }