Fixed: Randomize Sectors / Vertices, UDMF: vertex handles were not updated.

Fixed: Randomize Sectors, UDMF: vertex height changes were not undone properly after using the mode (I broke it in r2101).
Fixed: Randomize Sectors: floor/ceiling textures can not be used as lower/upper textures when "MixTexturesAndFlats" is disabled. In this case the corresponding option is now changed to "Use default texture".
This commit is contained in:
MaxED 2014-10-29 13:11:35 +00:00
parent 7a3d743650
commit 5e59c38da6
5 changed files with 105 additions and 45 deletions

View file

@ -84,6 +84,7 @@ namespace CodeImp.DoomBuilder.VisualModes
public bool ProcessGeometry { get { return processgeometry; } set { processgeometry = value; } }
public bool ProcessThings { get { return processthings; } set { processthings = value; } }
public VisualBlockMap BlockMap { get { return blockmap; } }
public Dictionary<Vertex, VisualVertexPair> VisualVertices { get { return vertices; } } //mxd
// Rendering
public IRenderer3D Renderer { get { return renderer; } }
@ -108,9 +109,7 @@ namespace CodeImp.DoomBuilder.VisualModes
this.visiblethings = new List<VisualThing>(100);
this.processgeometry = true;
this.processthings = true;
//mxd
if(General.Map.UDMF) this.vertices = new Dictionary<Vertex,VisualVertexPair>();
this.vertices = new Dictionary<Vertex, VisualVertexPair>(); //mxd
//mxd. Synch camera position to cursor position or center of the screen in 2d-mode
if (General.Settings.GZSynchCameras && General.Editing.Mode is ClassicMode) {
@ -845,8 +844,7 @@ namespace CodeImp.DoomBuilder.VisualModes
visibleblocks.Clear();
visiblegeometry.Clear();
visiblethings.Clear();
if(General.Map.UDMF) vertices.Clear(); //mxd
vertices.Clear(); //mxd
// Make new blockmap
FillBlockMap();

View file

@ -13,7 +13,7 @@ namespace CodeImp.DoomBuilder.VisualModes
public VisualVertex[] Vertices { get { return new[] { floorvert, ceilvert }; } }
public VisualVertex FloorVertex { get { return floorvert; } }
public VisualVertex CeilingVertex { get { return ceilvert; } }
public bool Changed { set { floorvert.Changed = true; ceilvert.Changed = true; } }
public bool Changed { set { floorvert.Changed = value; ceilvert.Changed = value; } }
public VisualVertexPair(VisualVertex floorvert, VisualVertex ceilvert) {
if(floorvert.CeilingVertex == ceilvert.CeilingVertex)

View file

@ -12,6 +12,7 @@ namespace CodeImp.DoomBuilder.BuilderEffects
{
private readonly string editingModeName;
private readonly List<VisualSector> visualSectors;
private readonly List<VisualVertexPair> visualVerts;
private readonly TranslationOffsetVertexData[] vertexData;
private readonly List<SectorData> sectorData;
private readonly List<SidedefData> sidedefData;
@ -124,6 +125,12 @@ namespace CodeImp.DoomBuilder.BuilderEffects
}
}
visualVerts = new List<VisualVertexPair>();
foreach (Vertex vert in affectedVerts)
{
if(vm.VisualVertices.ContainsKey(vert)) visualVerts.Add(vm.VisualVertices[vert]);
}
} else if(editingModeName == "SectorsMode") {
ICollection<Sector> list = General.Map.Map.GetSelectedSectors(true);
@ -144,6 +151,10 @@ namespace CodeImp.DoomBuilder.BuilderEffects
return;
}
//create undo
General.Map.UndoRedo.ClearAllRedos();
General.Map.UndoRedo.CreateUndo("Randomize " + sectors.Count + (sectors.Count > 1 ? " sectors" : " sector"));
//update window header
this.Text = "Randomize " + sectors.Count + (sectors.Count > 1 ? " sectors" : " sector");
@ -287,8 +298,20 @@ namespace CodeImp.DoomBuilder.BuilderEffects
//texture pickers
textureLower.Initialize();
textureUpper.Initialize();
textureLower.TextureName = General.Settings.DefaultFloorTexture;
textureUpper.TextureName = General.Settings.DefaultCeilingTexture;
//We can't use floor/ceiling textures when MixTexturesFlats is disabled
if (General.Map.Config.MixTexturesFlats)
{
textureLower.TextureName = General.Settings.DefaultFloorTexture;
textureUpper.TextureName = General.Settings.DefaultCeilingTexture;
}
else
{
textureLower.TextureName = General.Settings.DefaultTexture;
textureUpper.TextureName = General.Settings.DefaultTexture;
cbUpperTexStyle.Items[1] = "Use default texture";
cbLowerTexStyle.Items[1] = "Use default texture";
}
cbUpperTexStyle.SelectedIndex = 0;
cbLowerTexStyle.SelectedIndex = 0;
@ -298,10 +321,6 @@ namespace CodeImp.DoomBuilder.BuilderEffects
updateAngles();
updateFloorHeights();
updateCeilingHeights();
//create undo
General.Map.UndoRedo.ClearAllRedos();
General.Map.UndoRedo.CreateUndo("Randomize " + sectors.Count + (sectors.Count > 1 ? " sectors" : " sector"));
}
private float GetLowestCeiling(Vertex v) {
@ -427,6 +446,11 @@ namespace CodeImp.DoomBuilder.BuilderEffects
foreach(VisualSector vs in visualSectors) vs.UpdateSectorGeometry(true);
foreach(VisualSector vs in visualSectors) vs.UpdateSectorData();
foreach(VisualSector vs in visualSectors) vs.UpdateSectorData();
foreach (VisualVertexPair pair in visualVerts)
{
pair.Changed = true;
pair.Update();
}
}
private void updateTextureSelectors() {
@ -438,22 +462,36 @@ namespace CodeImp.DoomBuilder.BuilderEffects
textureUpper.Enabled = ceilingHeightAmmount.Value > 0 && cbUpperTexStyle.SelectedIndex == 2;
}
private void updateUpperTextures(int index, bool updateGeometry) {
private void updateUpperTextures(int index, bool updateGeometry)
{
if(index == -1) return;
if(index == 0) { //revert
if(index == 0)
{ //revert
foreach(SidedefData sd in sidedefData)
setUpperTexture(sd, sd.HighTexture);
} else if(index == 1) { //use ceiling texture
foreach(SidedefData sd in sidedefData) {
if(sd.Side.Sector != null) {
if(sd.UpdateTextureOnOtherSide && sd.Side.Other.Sector != null)
setUpperTexture(sd, sd.Side.Sector.CeilTexture, sd.Side.Other.Sector.CeilTexture);
else
setUpperTexture(sd, sd.Side.Sector.CeilTexture);
}
else if(index == 1) //use ceiling or default texture
{
if(General.Map.Config.MixTexturesFlats)
{
foreach(SidedefData sd in sidedefData)
{
if(sd.Side.Sector != null)
{
if (sd.UpdateTextureOnOtherSide && sd.Side.Other.Sector != null) setUpperTexture(sd, sd.Side.Sector.CeilTexture, sd.Side.Other.Sector.CeilTexture);
else setUpperTexture(sd, sd.Side.Sector.CeilTexture);
}
}
}
} else if(index == 2) { //use given texture
else
{
foreach(SidedefData sd in sidedefData) setUpperTexture(sd, General.Settings.DefaultTexture);
}
}
else if(index == 2) //use given texture
{
foreach(SidedefData sd in sidedefData)
setUpperTexture(sd, textureUpper.TextureName);
}
@ -462,22 +500,35 @@ namespace CodeImp.DoomBuilder.BuilderEffects
if(updateGeometry && editingModeName == "BaseVisualMode") updateVisualGeometry();
}
private void updateLowerTextures(int index, bool updateGeometry) {
private void updateLowerTextures(int index, bool updateGeometry)
{
if(index == -1) return;
if(index == 0) { //revert
if(index == 0)
{ //revert
foreach(SidedefData sd in sidedefData)
setLowerTexture(sd, sd.LowTexture);
} else if(index == 1) { //use floor texture
foreach(SidedefData sd in sidedefData) {
if(sd.Side.Sector != null) {
if(sd.UpdateTextureOnOtherSide && sd.Side.Other.Sector != null)
setLowerTexture(sd, sd.Side.Sector.FloorTexture, sd.Side.Other.Sector.FloorTexture);
else
setLowerTexture(sd, sd.Side.Sector.FloorTexture);
}
else if(index == 1) //use floor or default texture
{
if(General.Map.Config.MixTexturesFlats)
{
foreach(SidedefData sd in sidedefData)
{
if(sd.Side.Sector != null)
{
if (sd.UpdateTextureOnOtherSide && sd.Side.Other.Sector != null) setLowerTexture(sd, sd.Side.Sector.FloorTexture, sd.Side.Other.Sector.FloorTexture);
else setLowerTexture(sd, sd.Side.Sector.FloorTexture);
}
}
}
} else if(index == 2) { //use given texture
else
{
foreach (SidedefData sd in sidedefData) setLowerTexture(sd, General.Settings.DefaultTexture);
}
}
else if(index == 2) //use given texture
{
foreach(SidedefData sd in sidedefData)
setLowerTexture(sd, textureLower.TextureName);
}

View file

@ -130,6 +130,11 @@ namespace CodeImp.DoomBuilder.BuilderEffects
positionJitterAmmount.Maximum = MaxSafeDistance;
heightJitterAmmount.Maximum = MaxSafeHeightDistance;
//create undo
General.Map.UndoRedo.ClearAllRedos();
General.Map.UndoRedo.CreateUndo("Randomize " + selection.Count + (selection.Count > 1 ? " things" : " thing"));
//update controls
updateOffsetAngles();
updateHeights();
updateRotationAngles();
@ -138,10 +143,6 @@ namespace CodeImp.DoomBuilder.BuilderEffects
updateScaleX();
updateScaleY();
//create undo
General.Map.UndoRedo.ClearAllRedos();
General.Map.UndoRedo.CreateUndo("Randomize " + selection.Count +(selection.Count > 1 ? " things" : " thing"));
//apply settings
cbRelativeScale.Checked = relativeScale;
cbUniformScale.Checked = uniformScale;

View file

@ -13,6 +13,7 @@ namespace CodeImp.DoomBuilder.BuilderEffects
private readonly string editingModeName;
private readonly List<Vertex> selection;
private readonly List<VisualSector> visualSectors;
private readonly List<VisualVertexPair> visualVerts;
private readonly VertexData[] vertexData;
private readonly int MaxSafeDistance;
@ -53,8 +54,15 @@ namespace CodeImp.DoomBuilder.BuilderEffects
}
}
visualVerts = new List<VisualVertexPair>();
foreach(Vertex vert in selection)
{
if(vm.VisualVertices.ContainsKey(vert)) visualVerts.Add(vm.VisualVertices[vert]);
}
//update window header
this.Text = "Randomize " + linesCount + (linesCount > 1 ? " linedefs" : " linedef");
} else if(editingModeName == "LinedefsMode") {
ICollection<Linedef> list = General.Map.Map.GetSelectedLinedefs(true);
int linesCount = 0;
@ -84,6 +92,10 @@ namespace CodeImp.DoomBuilder.BuilderEffects
return;
}
//create undo
General.Map.UndoRedo.ClearAllRedos();
General.Map.UndoRedo.CreateUndo("Randomize " + selection.Count + (selection.Count > 1 ? " vertices" : " vertex"));
Dictionary<Vertex, VertexData> data = new Dictionary<Vertex, VertexData>();
foreach(Vertex v in selection) {
@ -150,10 +162,6 @@ namespace CodeImp.DoomBuilder.BuilderEffects
positionJitterAmmount.Maximum = MaxSafeDistance;
updateAngles();
//create undo
General.Map.UndoRedo.ClearAllRedos();
General.Map.UndoRedo.CreateUndo("Randomize " + selection.Count + (selection.Count > 1 ? " vertices" : " vertex"));
}
//utility
@ -170,11 +178,13 @@ namespace CodeImp.DoomBuilder.BuilderEffects
General.Map.Map.Update();
General.Map.IsChanged = true;
foreach(VisualSector vs in visualSectors)
vs.UpdateSectorGeometry(true);
foreach(VisualSector vs in visualSectors)
vs.UpdateSectorData();
foreach(VisualSector vs in visualSectors) vs.UpdateSectorGeometry(true);
foreach(VisualSector vs in visualSectors) vs.UpdateSectorData();
foreach(VisualVertexPair pair in visualVerts)
{
pair.Changed = true;
pair.Update();
}
} else {
General.Interface.RedrawDisplay();
}