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.
This commit is contained in:
MaxED 2016-04-01 22:23:05 +00:00 committed by spherallic
parent 56dcbfc6cc
commit 1d78786bcf

View file

@ -1228,6 +1228,9 @@ namespace CodeImp.DoomBuilder.Rendering
foreach(KeyValuePair<int, List<Thing>> group in thingsByType) foreach(KeyValuePair<int, List<Thing>> 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 // Find thing information
ThingTypeInfo info = General.Map.Data.GetThingInfo(group.Key); ThingTypeInfo info = General.Map.Data.GetThingInfo(group.Key);
@ -1254,33 +1257,53 @@ namespace CodeImp.DoomBuilder.Rendering
buffercount = 0; buffercount = 0;
totalcount = 0; totalcount = 0;
float spriteWidth, spriteHeight; bool forcespriterendering;
float fixedscaler = (group.Value[0].FixedSize ? 1.0f : 2.0f); float spritewidth, spriteheight, spritescale;
float spriteScale = ((group.Value[0].FixedSize || General.Settings.FixedThingsScale) && (scale > fixedscaler)) ? fixedscaler : scale; 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; float radius = General.Settings.DrawThingsFixedSize ? General.Settings.DefaultThingSize : info.Radius;
if(sprite.Width > sprite.Height) if(sprite.Width > sprite.Height)
{ {
spriteWidth = radius * spriteScale - THING_SPRITE_SHRINK * spriteScale; spritewidth = (radius - THING_SPRITE_SHRINK) * spritescale;
spriteHeight = spriteWidth * ((float)sprite.Height / sprite.Width); spriteheight = spritewidth * ((float)sprite.Height / sprite.Width);
} }
else if(sprite.Width < sprite.Height) else if(sprite.Width < sprite.Height)
{ {
spriteHeight = radius * spriteScale - THING_SPRITE_SHRINK * spriteScale; spriteheight = (radius - THING_SPRITE_SHRINK) * spritescale;
spriteWidth = spriteHeight * ((float)sprite.Width / sprite.Height); spritewidth = spriteheight * ((float)sprite.Width / sprite.Height);
} }
else else
{ {
spriteWidth = radius * spriteScale - THING_SPRITE_SHRINK * spriteScale; spritewidth = (radius - THING_SPRITE_SHRINK) * spritescale;
spriteHeight = spriteWidth; 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) 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; if(t.IsModel && ((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; if(!forcespriterendering && spritesize < MINIMUM_SPRITE_RADIUS)
float scaler = thingsize / radius;
if(Math.Max(spriteWidth, spriteHeight) * scaler < MINIMUM_SPRITE_RADIUS)
{ {
// Hackish way to tell arrow rendering code to draw bigger arrow... // Hackish way to tell arrow rendering code to draw bigger arrow...
Vector3D v = thingsByPosition[t]; Vector3D v = thingsByPosition[t];
@ -1291,7 +1314,7 @@ namespace CodeImp.DoomBuilder.Rendering
continue; 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++; buffercount++;
totalcount++; totalcount++;