mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 12:50:52 +00:00
Fixed a bug in Line2D.GetIntersection(), introduced in r1854 (SHOULD... OPTIMIZE... MORE... CAREFULLY!!!11).
A couple of minor optimizations in Renderer3D.
This commit is contained in:
parent
4e93bc71d3
commit
940a5f6183
4 changed files with 33 additions and 27 deletions
|
@ -125,16 +125,14 @@ namespace CodeImp.DoomBuilder.Geometry
|
||||||
u_ray = ((v2.x - v1.x) * (v1.y - y3) - (v2.y - v1.y) * (v1.x - x3)) / div;
|
u_ray = ((v2.x - v1.x) * (v1.y - y3) - (v2.y - v1.y) * (v1.x - x3)) / div;
|
||||||
|
|
||||||
// Return if intersecting
|
// Return if intersecting
|
||||||
if (u_ray <= 0.0f || u_ray >= 1.0f || u_line <= 0.0f || u_line >= 1.0f) return false; //mxd
|
if (u_ray < 0.0f || u_ray > 1.0f || u_line < 0.0f || u_line > 1.0f) return false; //mxd
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
// Unable to detect intersection
|
||||||
// Unable to detect intersection
|
u_line = float.NaN;
|
||||||
u_line = float.NaN;
|
u_ray = float.NaN;
|
||||||
u_ray = float.NaN;
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This tests on which side of the line the given coordinates are
|
// This tests on which side of the line the given coordinates are
|
||||||
|
@ -209,7 +207,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
||||||
{
|
{
|
||||||
// Calculate and return the angle
|
// Calculate and return the angle
|
||||||
Vector2D d = GetDelta();
|
Vector2D d = GetDelta();
|
||||||
return -(float)Math.Atan2(-d.y, d.x) + Angle2D.PIHALF;//mxd // (float)Math.PI * 0.5f;
|
return -(float)Math.Atan2(-d.y, d.x) + Angle2D.PIHALF;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2D GetDelta() { return v2 - v1; }
|
public Vector2D GetDelta() { return v2 - v1; }
|
||||||
|
|
|
@ -130,8 +130,8 @@ namespace CodeImp.DoomBuilder.Geometry
|
||||||
FindInnerLines(p, alllines);
|
FindInnerLines(p, alllines);
|
||||||
return alllines;
|
return alllines;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This finds the inner lines of the sector and adds them to the sector polygon
|
// This finds the inner lines of the sector and adds them to the sector polygon
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace CodeImp.DoomBuilder.IO
|
||||||
|
|
||||||
// This draws the picture to the given pixel color data
|
// This draws the picture to the given pixel color data
|
||||||
// Throws exception on failure
|
// Throws exception on failure
|
||||||
public unsafe void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
|
public void DrawToPixelData(Stream stream, PixelColor* target, int targetwidth, int targetheight, int x, int y)
|
||||||
{
|
{
|
||||||
Bitmap bmp;
|
Bitmap bmp;
|
||||||
BitmapData bmpdata;
|
BitmapData bmpdata;
|
||||||
|
|
|
@ -484,7 +484,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
//mxd. LINKS
|
//mxd. LINKS
|
||||||
if (General.Settings.GZShowEventLines) {
|
if (General.Settings.GZShowEventLines) {
|
||||||
//mxd. gather links
|
//mxd. gather links
|
||||||
List<Line3D> lines = GZBuilder.Data.LinksCollector.GetThingLinks(thingsbydistance);
|
List<Line3D> lines = LinksCollector.GetThingLinks(thingsbydistance);
|
||||||
if(lines.Count > 0) {
|
if(lines.Count > 0) {
|
||||||
List<Line3D> normalLines = new List<Line3D>();
|
List<Line3D> normalLines = new List<Line3D>();
|
||||||
List<Line3D> activatorLines = new List<Line3D>();
|
List<Line3D> activatorLines = new List<Line3D>();
|
||||||
|
@ -510,7 +510,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
RenderSinglePass((int)RenderPass.Additive);
|
RenderSinglePass((int)RenderPass.Additive);
|
||||||
|
|
||||||
//mxd. LIGHT PASS
|
//mxd. LIGHT PASS
|
||||||
if (General.Settings.GZDrawLights && !fullbrightness && thingsWithLight.Count > 0 && litGeometry.Count > 0) {
|
if( !(!General.Settings.GZDrawLights || fullbrightness || thingsWithLight.Count == 0 || litGeometry.Count == 0) ) {
|
||||||
RenderLights(litGeometry, thingsWithLight);
|
RenderLights(litGeometry, thingsWithLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,12 +537,20 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
lightOffsets = new int[3];
|
lightOffsets = new int[3];
|
||||||
foreach (VisualThing t in thingsWithLight) {
|
foreach (VisualThing t in thingsWithLight) {
|
||||||
//add light to apropriate array.
|
//add light to apropriate array.
|
||||||
if (t.LightRenderStyle == DynamicLightRenderStyle.NORMAL || t.LightRenderStyle == DynamicLightRenderStyle.VAVOOM)
|
switch(t.LightRenderStyle) {
|
||||||
lightOffsets[0]++;
|
case DynamicLightRenderStyle.NORMAL:
|
||||||
else if (t.LightRenderStyle == DynamicLightRenderStyle.ADDITIVE)
|
case DynamicLightRenderStyle.VAVOOM:
|
||||||
lightOffsets[1]++;
|
lightOffsets[0]++;
|
||||||
else
|
break;
|
||||||
lightOffsets[2]++;
|
|
||||||
|
case DynamicLightRenderStyle.ADDITIVE:
|
||||||
|
lightOffsets[1]++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
lightOffsets[2]++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,11 +785,11 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
int wantedshaderpass = (((g == highlighted) && showhighlight) || (g.Selected && showselection)) ? highshaderpass : shaderpass;
|
int wantedshaderpass = (((g == highlighted) && showhighlight) || (g.Selected && showselection)) ? highshaderpass : shaderpass;
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
if (General.Settings.GZDrawFog && !fullbrightness && sector.Sector.Brightness < 248)
|
if( !(!General.Settings.GZDrawFog || fullbrightness || sector.Sector.Brightness > 247) )
|
||||||
wantedshaderpass += 8;
|
wantedshaderpass += 8;
|
||||||
|
|
||||||
//mxd. Seems that lines rendered with RenderPass.Alpha or RenderPass.Additive aren't affected by dynamic lights in GZDoom
|
//mxd. Seems that lines rendered with RenderPass.Alpha or RenderPass.Additive aren't affected by dynamic lights in GZDoom
|
||||||
if (g.RenderPass != RenderPass.Alpha && g.RenderPass != RenderPass.Additive && General.Settings.GZDrawLights && !fullbrightness && thingsWithLight.Count > 0) {
|
if ( !(g.RenderPass == RenderPass.Alpha || g.RenderPass == RenderPass.Additive || !General.Settings.GZDrawLights || fullbrightness || thingsWithLight.Count == 0) ) {
|
||||||
if (curtexture.Texture != null) {
|
if (curtexture.Texture != null) {
|
||||||
if (!litGeometry.ContainsKey(curtexture.Texture))
|
if (!litGeometry.ContainsKey(curtexture.Texture))
|
||||||
litGeometry[curtexture.Texture] = new List<VisualGeometry>();
|
litGeometry[curtexture.Texture] = new List<VisualGeometry>();
|
||||||
|
@ -834,15 +842,15 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
// Render things collected
|
// Render things collected
|
||||||
foreach(KeyValuePair<ImageData, List<VisualThing>> group in thingspass)
|
foreach(KeyValuePair<ImageData, List<VisualThing>> group in thingspass)
|
||||||
{
|
{
|
||||||
ImageData curtexture;
|
|
||||||
|
|
||||||
if(!(group.Key is UnknownImage))
|
if(!(group.Key is UnknownImage))
|
||||||
{
|
{
|
||||||
|
ImageData curtexture;
|
||||||
|
|
||||||
// What texture to use?
|
// What texture to use?
|
||||||
if((group.Key != null) && group.Key.IsImageLoaded && !group.Key.IsDisposed)
|
if((group.Key == null) || !group.Key.IsImageLoaded || group.Key.IsDisposed)
|
||||||
curtexture = group.Key;
|
|
||||||
else
|
|
||||||
curtexture = General.Map.Data.Hourglass3D;
|
curtexture = General.Map.Data.Hourglass3D;
|
||||||
|
else
|
||||||
|
curtexture = group.Key;
|
||||||
|
|
||||||
// Create Direct3D texture if still needed
|
// Create Direct3D texture if still needed
|
||||||
if((curtexture.Texture == null) || curtexture.Texture.Disposed)
|
if((curtexture.Texture == null) || curtexture.Texture.Disposed)
|
||||||
|
|
Loading…
Reference in a new issue