mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-20 10:53:19 +00:00
Improve camera sector search somewhat
This commit is contained in:
parent
459742c840
commit
061fa30a45
1 changed files with 49 additions and 39 deletions
|
@ -592,45 +592,55 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
|
|
||||||
if(processgeometry)
|
if(processgeometry)
|
||||||
{
|
{
|
||||||
// Find camera sector
|
// Find camera sector
|
||||||
Linedef nld = MapSet.NearestLinedef(visiblelines, campos2d);
|
Sector camsector = blockmap.GetSectorAt(campos2d);
|
||||||
if(nld != null)
|
if (camsector != null)
|
||||||
{
|
{
|
||||||
General.Map.VisualCamera.Sector = GetCameraSectorFromLinedef(nld);
|
General.Map.VisualCamera.Sector = camsector;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Exceptional case: no lines found in any nearby blocks!
|
// To do: fix this code. It is retarded. Walking over all visible lines is extremely expensive.
|
||||||
// This could happen in the middle of an extremely large sector and in this case
|
|
||||||
// the above code will not have found any sectors/sidedefs for rendering.
|
Linedef nld = MapSet.NearestLinedef(visiblelines, campos2d);
|
||||||
// Here we handle this special case with brute-force. Let's find the sector
|
if (nld != null)
|
||||||
// the camera is in by searching the entire map and render that sector only.
|
{
|
||||||
nld = General.Map.Map.NearestLinedef(campos2d);
|
General.Map.VisualCamera.Sector = GetCameraSectorFromLinedef(nld);
|
||||||
if(nld != null)
|
}
|
||||||
{
|
else
|
||||||
General.Map.VisualCamera.Sector = GetCameraSectorFromLinedef(nld);
|
{
|
||||||
if(General.Map.VisualCamera.Sector != null)
|
// Exceptional case: no lines found in any nearby blocks!
|
||||||
{
|
// This could happen in the middle of an extremely large sector and in this case
|
||||||
foreach(Sidedef sd in General.Map.VisualCamera.Sector.Sidedefs)
|
// the above code will not have found any sectors/sidedefs for rendering.
|
||||||
{
|
// Here we handle this special case with brute-force. Let's find the sector
|
||||||
float side = sd.Line.SideOfLine(campos2d);
|
// the camera is in by searching the entire map and render that sector only.
|
||||||
if(((side < 0) && sd.IsFront) ||
|
nld = General.Map.Map.NearestLinedef(campos2d);
|
||||||
((side > 0) && !sd.IsFront))
|
if (nld != null)
|
||||||
ProcessSidedefCulling(sd);
|
{
|
||||||
}
|
General.Map.VisualCamera.Sector = GetCameraSectorFromLinedef(nld);
|
||||||
}
|
if (General.Map.VisualCamera.Sector != null)
|
||||||
else
|
{
|
||||||
{
|
foreach (Sidedef sd in General.Map.VisualCamera.Sector.Sidedefs)
|
||||||
// Too far away from the map to see anything
|
{
|
||||||
General.Map.VisualCamera.Sector = null;
|
float side = sd.Line.SideOfLine(campos2d);
|
||||||
}
|
if (((side < 0) && sd.IsFront) ||
|
||||||
}
|
((side > 0) && !sd.IsFront))
|
||||||
else
|
ProcessSidedefCulling(sd);
|
||||||
{
|
}
|
||||||
// Map is empty
|
}
|
||||||
General.Map.VisualCamera.Sector = null;
|
else
|
||||||
}
|
{
|
||||||
}
|
// Too far away from the map to see anything
|
||||||
|
General.Map.VisualCamera.Sector = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Map is empty
|
||||||
|
General.Map.VisualCamera.Sector = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue