From 1d78786bcf58a9f53e8dbb785b35252ec0a721f7 Mon Sep 17 00:00:00 2001 From: MaxED Date: Fri, 1 Apr 2016 22:23:05 +0000 Subject: [PATCH] Fixed, Classic modes: thing sprite should always be rendered when it's size is affected by "Fixed Things Scale" option or FixedSize setting. MAPINFO parser: removed a misleading warning. --- Source/Core/Rendering/Renderer2D.cs | 51 +++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs index 54e7aa5..036b50f 100644 --- a/Source/Core/Rendering/Renderer2D.cs +++ b/Source/Core/Rendering/Renderer2D.cs @@ -1228,6 +1228,9 @@ namespace CodeImp.DoomBuilder.Rendering foreach(KeyValuePair> group in thingsByType) { + // Skip when all things of this type will be rendered as models + if(group.Value[0].IsModel && (General.Settings.GZDrawModelsMode == ModelRenderMode.ALL)) continue; + // Find thing information ThingTypeInfo info = General.Map.Data.GetThingInfo(group.Key); @@ -1254,33 +1257,53 @@ namespace CodeImp.DoomBuilder.Rendering buffercount = 0; totalcount = 0; - float spriteWidth, spriteHeight; - float fixedscaler = (group.Value[0].FixedSize ? 1.0f : 2.0f); - float spriteScale = ((group.Value[0].FixedSize || General.Settings.FixedThingsScale) && (scale > fixedscaler)) ? fixedscaler : scale; + bool forcespriterendering; + float spritewidth, spriteheight, spritescale; + float fixedscaler = (group.Value[0].FixedSize ? 1.0f : 2.0f); // Make sure thing size stays at 2x scale when FixedThingsScale is enabled + // Apply FixedSize setting? + if((group.Value[0].FixedSize || General.Settings.FixedThingsScale) && (scale > fixedscaler)) + { + spritescale = fixedscaler; + forcespriterendering = true; // Always render sprite when thing size is affected by FixedSize or FixedThingsScale settings + } + else + { + spritescale = scale; + forcespriterendering = false; + } + + // Calculate scaled sprite size float radius = General.Settings.DrawThingsFixedSize ? General.Settings.DefaultThingSize : info.Radius; if(sprite.Width > sprite.Height) { - spriteWidth = radius * spriteScale - THING_SPRITE_SHRINK * spriteScale; - spriteHeight = spriteWidth * ((float)sprite.Height / sprite.Width); + spritewidth = (radius - THING_SPRITE_SHRINK) * spritescale; + spriteheight = spritewidth * ((float)sprite.Height / sprite.Width); } else if(sprite.Width < sprite.Height) { - spriteHeight = radius * spriteScale - THING_SPRITE_SHRINK * spriteScale; - spriteWidth = spriteHeight * ((float)sprite.Width / sprite.Height); + spriteheight = (radius - THING_SPRITE_SHRINK) * spritescale; + spritewidth = spriteheight * ((float)sprite.Width / sprite.Height); } else { - spriteWidth = radius * spriteScale - THING_SPRITE_SHRINK * spriteScale; - spriteHeight = spriteWidth; + spritewidth = (radius - THING_SPRITE_SHRINK) * spritescale; + spriteheight = spritewidth; } + // Apply radius and height Thing Argument overrides? + if(!group.Value[0].FixedSize) + { + float sizeoverridescaler = group.Value[0].Size / info.Radius; + spritewidth *= sizeoverridescaler; + spriteheight *= sizeoverridescaler; + } + float spritesize = Math.Max(spritewidth, spriteheight); + foreach(Thing t in group.Value) { - if(t.IsModel && (General.Settings.GZDrawModelsMode == ModelRenderMode.ALL || (General.Settings.GZDrawModelsMode == ModelRenderMode.SELECTION && t.Selected) || (General.Settings.GZDrawModelsMode == ModelRenderMode.ACTIVE_THINGS_FILTER && alpha == 1.0f))) continue; - float thingsize = General.Settings.DrawThingsFixedSize ? General.Settings.DefaultThingSize : t.Size; - float scaler = thingsize / radius; - if(Math.Max(spriteWidth, spriteHeight) * scaler < MINIMUM_SPRITE_RADIUS) + if(t.IsModel && ((General.Settings.GZDrawModelsMode == ModelRenderMode.SELECTION && t.Selected) || (General.Settings.GZDrawModelsMode == ModelRenderMode.ACTIVE_THINGS_FILTER && alpha == 1.0f))) continue; + if(!forcespriterendering && spritesize < MINIMUM_SPRITE_RADIUS) { // Hackish way to tell arrow rendering code to draw bigger arrow... Vector3D v = thingsByPosition[t]; @@ -1291,7 +1314,7 @@ namespace CodeImp.DoomBuilder.Rendering continue; } - CreateThingSpriteVerts(thingsByPosition[t], spriteWidth * scaler, spriteHeight * scaler, ref verts, buffercount * 6, t.Selected ? selectionColor : 0xFFFFFF); + CreateThingSpriteVerts(thingsByPosition[t], spritewidth, spriteheight, ref verts, buffercount * 6, (t.Selected ? selectionColor : 0xFFFFFF)); buffercount++; totalcount++;