@ work on (G)ZDoom Editing plugin

This commit is contained in:
codeimp 2010-09-14 19:50:16 +00:00
parent f59094e2bc
commit 21c4ad0dcc
6 changed files with 87 additions and 25 deletions

View file

@ -61,6 +61,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
new public BaseVisualSector Sector { get { return (BaseVisualSector)base.Sector; } }
public bool Changed { get { return changed; } set { changed = value; } }
public SectorLevel Level { get { return level; } }
#endregion
@ -298,7 +299,11 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
ChangeHeight(amount);
// Rebuild sector
Sector.UpdateSectorGeometry(true);
if(mode.VisualSectorExists(level.sector))
{
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
vs.UpdateSectorGeometry(true);
}
}
// Sector brightness change

View file

@ -762,11 +762,16 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Go for all sectors to update
foreach(Sector s in General.Map.Map.Sectors)
{
if(s.Marked && VisualSectorExists(s))
if(s.Marked)
{
BaseVisualSector vs = (BaseVisualSector)GetVisualSector(s);
vs.Floor.Setup();
vs.Ceiling.Setup();
SectorData sd = GetSectorData(s);
sd.Reset();
if(VisualSectorExists(s))
{
BaseVisualSector vs = (BaseVisualSector)GetVisualSector(s);
vs.UpdateSectorGeometry(false);
}
}
}
@ -797,6 +802,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Make new blockmap
if(sectorsmarked || General.Map.UndoRedo.PopulationChanged)
FillBlockMap();
UpdateChangedObjects();
// Visibility culling (this re-creates the needed resources)
DoCulling();
@ -930,7 +937,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
{
if(i is BaseVisualGeometrySector)
{
Sector s = (i as BaseVisualGeometrySector).Sector.Sector;
Sector s = (i as BaseVisualGeometrySector).Level.sector;
if(!added.ContainsKey(s))
{
sectors.Add(s);
@ -942,7 +949,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Add highlight?
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySector))
{
Sector s = (target.picked as BaseVisualGeometrySector).Sector.Sector;
Sector s = (target.picked as BaseVisualGeometrySector).Level.sector;
if(!added.ContainsKey(s))
sectors.Add(s);
}

View file

@ -98,9 +98,13 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
{
if(Thing.Sector != null)
{
SectorData sd = mode.GetSectorData(Thing.Sector);
SectorLevel level = sd.GetLevelAbove(new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + Thing.Sector.FloorHeight));
// Use sector brightness for color shading
byte brightness = (byte)General.Clamp(Thing.Sector.Brightness, 0, 255);
sectorcolor = new PixelColor(255, brightness, brightness, brightness);
PixelColor areabrightness = PixelColor.FromInt(mode.CalculateBrightness(level.brightnessbelow));
PixelColor areacolor = PixelColor.Modulate(level.colorbelow, areabrightness);
sectorcolor = areacolor.WithAlpha(255);
}
// Check if the texture is loaded
@ -169,27 +173,39 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
else if(info.Hangs)
{
// Hang from ceiling
if(Thing.Sector != null) pos.z = Thing.Sector.CeilHeight - info.Height;
if(Thing.Sector != null)
{
SectorData sd = mode.GetSectorData(Thing.Sector);
pos.z = sd.Ceiling.plane.GetZ(Thing.Position) - info.Height;
}
if(Thing.Position.z > 0) pos.z -= Thing.Position.z;
// Check if below floor
if((Thing.Sector != null) && (pos.z < Thing.Sector.FloorHeight))
{
// Put thing on the floor
pos.z = Thing.Sector.FloorHeight;
SectorData sd = mode.GetSectorData(Thing.Sector);
pos.z = sd.Floor.plane.GetZ(Thing.Position);
}
}
else
{
// Stand on floor
if(Thing.Sector != null) pos.z = Thing.Sector.FloorHeight;
if(Thing.Sector != null)
{
SectorData sd = mode.GetSectorData(Thing.Sector);
pos.z = sd.Floor.plane.GetZ(Thing.Position);
}
if(Thing.Position.z > 0) pos.z += Thing.Position.z;
// Check if above ceiling
if((Thing.Sector != null) && ((pos.z + info.Height) > Thing.Sector.CeilHeight))
{
// Put thing against ceiling
pos.z = Thing.Sector.CeilHeight - info.Height;
SectorData sd = mode.GetSectorData(Thing.Sector);
pos.z = sd.Ceiling.plane.GetZ(Thing.Position) - info.Height;
}
}

View file

@ -175,9 +175,18 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// This changes the height
protected override void ChangeHeight(int amount)
{
mode.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, this.Sector.Sector.FixedIndex);
this.Sector.Sector.CeilHeight += amount;
mode.SetActionResult("Changed ceiling height to " + Sector.Sector.CeilHeight + ".");
if(level.sector == Sector.Sector)
{
mode.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, level.sector.FixedIndex);
level.sector.CeilHeight += amount;
mode.SetActionResult("Changed ceiling height to " + level.sector.CeilHeight + ".");
}
else
{
mode.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, level.sector.FixedIndex);
level.sector.FloorHeight += amount;
mode.SetActionResult("Changed floor height to " + level.sector.FloorHeight + ".");
}
}
// This performs a fast test in object picking
@ -218,15 +227,23 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Return texture name
public override string GetTextureName()
{
return this.Sector.Sector.CeilTexture;
return level.sector.CeilTexture;
}
// This changes the texture
protected override void SetTexture(string texturename)
{
this.Sector.Sector.SetCeilTexture(texturename);
level.sector.SetCeilTexture(texturename);
General.Map.Data.UpdateUsedTextures();
this.Setup();
if(level.sector == this.Sector.Sector)
{
this.Setup();
}
else if(mode.VisualSectorExists(level.sector))
{
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
vs.UpdateSectorGeometry(false);
}
}
#endregion

View file

@ -162,9 +162,18 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// This changes the height
protected override void ChangeHeight(int amount)
{
mode.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, this.Sector.Sector.FixedIndex);
this.Sector.Sector.FloorHeight += amount;
mode.SetActionResult("Changed floor height to " + Sector.Sector.FloorHeight + ".");
if(level.sector == Sector.Sector)
{
mode.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, level.sector.FixedIndex);
level.sector.FloorHeight += amount;
mode.SetActionResult("Changed floor height to " + level.sector.FloorHeight + ".");
}
else
{
mode.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, level.sector.FixedIndex);
level.sector.CeilHeight += amount;
mode.SetActionResult("Changed ceiling height to " + level.sector.CeilHeight + ".");
}
}
// This performs a fast test in object picking
@ -205,15 +214,23 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Return texture name
public override string GetTextureName()
{
return this.Sector.Sector.FloorTexture;
return level.sector.FloorTexture;
}
// This changes the texture
protected override void SetTexture(string texturename)
{
this.Sector.Sector.SetFloorTexture(texturename);
level.sector.SetFloorTexture(texturename);
General.Map.Data.UpdateUsedTextures();
this.Setup();
if(level.sector == this.Sector.Sector)
{
this.Setup();
}
else if(mode.VisualSectorExists(level.sector))
{
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
vs.UpdateSectorGeometry(false);
}
}
#endregion

Binary file not shown.