mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 06:02:11 +00:00
Applied SoundPropagationMode patch by Boris.
This commit is contained in:
parent
f30c1ba0c6
commit
aa7bfd77c3
2 changed files with 30 additions and 18 deletions
|
@ -57,27 +57,15 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
foreach (Sidedef sd in sector.Sidedefs)
|
||||
{
|
||||
bool blocksound = sd.Line.IsFlagSet(General.Map.UDMF ? "blocksound" : "64");
|
||||
bool blockheight = false;
|
||||
Sector oppositesector;
|
||||
|
||||
if (blocksound) blockinglines.Add(sd.Line);
|
||||
|
||||
// If the line is one sided, the sound can travel nowhere, so try the next one
|
||||
if (sd.Line.Back == null || blocksound) continue;
|
||||
|
||||
// Get the sector on the other side of the line we're checking right now
|
||||
if (sd.Line.Front.Sector == sector)
|
||||
oppositesector = sd.Line.Back.Sector;
|
||||
else
|
||||
oppositesector = sd.Line.Front.Sector;
|
||||
Sector oppositesector = sd.Other.Sector;
|
||||
|
||||
// Check if the sound will be blocked because of sector floor and ceiling heights
|
||||
// (like closed doors, raised lifts etc.)
|
||||
if (sector.CeilHeight <= oppositesector.FloorHeight || sector.FloorHeight >= oppositesector.CeilHeight
|
||||
|| oppositesector.CeilHeight <= oppositesector.FloorHeight || sector.CeilHeight <= sector.FloorHeight)
|
||||
{
|
||||
blockheight = true;
|
||||
}
|
||||
bool blockheight = IsSoundBlockedByHeight(sd.Line);
|
||||
|
||||
// Try next line if sound will not pass through the current one. The last check makes
|
||||
// sure that the next line is tried if the current line is blocking sound, and the current
|
||||
|
@ -97,8 +85,11 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
|
||||
foreach (Linedef ld in blockinglines)
|
||||
{
|
||||
// Lines that don't have a back side, or where the sound is blocked due to
|
||||
// the sector heights on each side can be skipped
|
||||
if (ld.Back == null || IsSoundBlockedByHeight(ld)) continue;
|
||||
if (!sectors.Contains(ld.Front.Sector)) adjacentsectors.Add(ld.Front.Sector);
|
||||
if (ld.Back != null && !sectors.Contains(ld.Back.Sector)) adjacentsectors.Add(ld.Back.Sector);
|
||||
if (!sectors.Contains(ld.Back.Sector)) adjacentsectors.Add(ld.Back.Sector);
|
||||
}
|
||||
|
||||
List<FlatVertex> vertices = new List<FlatVertex>();
|
||||
|
@ -118,6 +109,19 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
}
|
||||
}
|
||||
|
||||
private static bool IsSoundBlockedByHeight(Linedef ld)
|
||||
{
|
||||
if(ld.Back == null) return false;
|
||||
|
||||
Sector s1 = ld.Front.Sector;
|
||||
Sector s2 = ld.Back.Sector;
|
||||
|
||||
// Check if the sound will be blocked because of sector floor and ceiling heights
|
||||
// (like closed doors, raised lifts etc.)
|
||||
return (s1.CeilHeight <= s2.FloorHeight || s1.FloorHeight >= s2.CeilHeight ||
|
||||
s2.CeilHeight <= s2.FloorHeight || s1.CeilHeight <= s1.FloorHeight);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,6 +119,13 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
private void UpdateSoundPropagation()
|
||||
{
|
||||
huntingThings.Clear();
|
||||
|
||||
BuilderPlug.Me.BlockingLinedefs.Clear();
|
||||
|
||||
foreach (Linedef ld in General.Map.Map.Linedefs)
|
||||
if (ld.IsFlagSet(General.Map.UDMF ? "blocksound" : "64"))
|
||||
BuilderPlug.Me.BlockingLinedefs.Add(ld);
|
||||
|
||||
if (highlighted == null || highlighted.IsDisposed) return;
|
||||
|
||||
if (!sector2domain.ContainsKey(highlighted))
|
||||
|
@ -126,7 +133,6 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
SoundPropagationDomain spd = new SoundPropagationDomain(highlighted);
|
||||
foreach (Sector s in spd.Sectors) sector2domain[s] = spd;
|
||||
propagationdomains.Add(spd);
|
||||
BuilderPlug.Me.BlockingLinedefs.AddRange(spd.BlockingLines);
|
||||
}
|
||||
|
||||
foreach (Sector adjacent in sector2domain[highlighted].AdjacentSectors)
|
||||
|
@ -135,11 +141,10 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
{
|
||||
SoundPropagationDomain aspd = new SoundPropagationDomain(adjacent);
|
||||
foreach (Sector s in aspd.Sectors) sector2domain[s] = aspd;
|
||||
BuilderPlug.Me.BlockingLinedefs.AddRange(aspd.BlockingLines);
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Create the list of sectors, which will be affected by nose made in highlighted sector
|
||||
//mxd. Create the list of sectors, which will be affected by noise made in highlighted sector
|
||||
SoundPropagationDomain curdomain = sector2domain[highlighted];
|
||||
Dictionary<int, Sector> noisysectors = new Dictionary<int, Sector>(curdomain.Sectors.Count);
|
||||
foreach(Sector s in curdomain.Sectors)
|
||||
|
@ -209,6 +214,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
|
|||
|
||||
// Convert geometry selection to sectors only
|
||||
General.Map.Map.ConvertSelection(SelectionType.Sectors);
|
||||
|
||||
UpdateSoundPropagation();
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
|
|
Loading…
Reference in a new issue