Classic modes: thing sprites are now rendered in classic modes.

Classic modes: models no longer disappear when the thing the model is attached to is no longer visible.
This commit is contained in:
MaxED 2013-11-27 12:45:28 +00:00
parent ac6e7f07e7
commit f482aebfb0
10 changed files with 431 additions and 153 deletions

View file

@ -11,6 +11,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorPicker", "Source\Plugi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagExplorer", "Source\Plugins\TagExplorer\TagExplorer.csproj", "{BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommentsPanel", "Source\Plugins\CommentsPanel\CommentsPanel.csproj", "{58BD8A5B-1B48-435D-8473-A92F27D06C49}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CopyPasteSectorProperties", "Source\Plugins\CopyPasteSectorProps\CopyPasteSectorProperties.csproj", "{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodesViewer", "Source\Plugins\NodesViewer\NodesViewer.csproj", "{9F244231-6A0C-42A6-87C5-ED9620DEE096}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StairSectorBuilder", "Source\Plugins\StairSectorBuilder\StairSectorBuilder.csproj", "{3F365121-906B-409D-BB1E-37E0A78056C2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Statistics", "Source\Plugins\Statistics\Statistics.csproj", "{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagRange", "Source\Plugins\TagRange\TagRange.csproj", "{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisplaneExplorer", "Source\Plugins\VisplaneExplorer\VisplaneExplorer.csproj", "{CF670175-7099-4090-A330-EE25C7230139}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -83,6 +97,90 @@ Global
{BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Win32.ActiveCfg = Release|x86
{BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|x86.ActiveCfg = Release|x86
{BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|x86.Build.0 = Release|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Debug|Any CPU.ActiveCfg = Debug|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Debug|Mixed Platforms.Build.0 = Debug|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Debug|Win32.ActiveCfg = Debug|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Debug|x86.ActiveCfg = Debug|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Debug|x86.Build.0 = Debug|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Release|Any CPU.ActiveCfg = Release|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Release|Mixed Platforms.ActiveCfg = Release|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Release|Mixed Platforms.Build.0 = Release|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Release|Win32.ActiveCfg = Release|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Release|x86.ActiveCfg = Release|x86
{58BD8A5B-1B48-435D-8473-A92F27D06C49}.Release|x86.Build.0 = Release|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Debug|Any CPU.ActiveCfg = Debug|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Debug|Mixed Platforms.Build.0 = Debug|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Debug|Win32.ActiveCfg = Debug|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Debug|x86.ActiveCfg = Debug|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Debug|x86.Build.0 = Debug|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Release|Any CPU.ActiveCfg = Release|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Release|Mixed Platforms.ActiveCfg = Release|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Release|Mixed Platforms.Build.0 = Release|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Release|Win32.ActiveCfg = Release|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Release|x86.ActiveCfg = Release|x86
{A5F93B70-18D9-4F3C-9B72-BC8B5B13998E}.Release|x86.Build.0 = Release|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Debug|Any CPU.ActiveCfg = Debug|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Debug|Mixed Platforms.Build.0 = Debug|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Debug|Win32.ActiveCfg = Debug|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Debug|x86.ActiveCfg = Debug|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Debug|x86.Build.0 = Debug|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Release|Any CPU.ActiveCfg = Release|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Release|Mixed Platforms.ActiveCfg = Release|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Release|Mixed Platforms.Build.0 = Release|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Release|Win32.ActiveCfg = Release|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Release|x86.ActiveCfg = Release|x86
{9F244231-6A0C-42A6-87C5-ED9620DEE096}.Release|x86.Build.0 = Release|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Debug|Any CPU.ActiveCfg = Debug|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Debug|Mixed Platforms.Build.0 = Debug|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Debug|Win32.ActiveCfg = Debug|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Debug|x86.ActiveCfg = Debug|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Debug|x86.Build.0 = Debug|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Release|Any CPU.ActiveCfg = Release|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Release|Mixed Platforms.ActiveCfg = Release|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Release|Mixed Platforms.Build.0 = Release|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Release|Win32.ActiveCfg = Release|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Release|x86.ActiveCfg = Release|x86
{3F365121-906B-409D-BB1E-37E0A78056C2}.Release|x86.Build.0 = Release|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|Any CPU.ActiveCfg = Debug|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|Mixed Platforms.Build.0 = Debug|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|Win32.ActiveCfg = Debug|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|x86.ActiveCfg = Debug|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Debug|x86.Build.0 = Debug|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|Any CPU.ActiveCfg = Release|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|Mixed Platforms.ActiveCfg = Release|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|Mixed Platforms.Build.0 = Release|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|Win32.ActiveCfg = Release|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|x86.ActiveCfg = Release|x86
{FBC0A503-9152-4BE2-9B5C-128FFD0B0D3F}.Release|x86.Build.0 = Release|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Debug|Any CPU.ActiveCfg = Debug|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Debug|Mixed Platforms.Build.0 = Debug|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Debug|Win32.ActiveCfg = Debug|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Debug|x86.ActiveCfg = Debug|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Debug|x86.Build.0 = Debug|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Release|Any CPU.ActiveCfg = Release|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Release|Mixed Platforms.ActiveCfg = Release|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Release|Mixed Platforms.Build.0 = Release|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Release|Win32.ActiveCfg = Release|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Release|x86.ActiveCfg = Release|x86
{F49EFF6D-51CB-4E49-8223-AAE653C5B62F}.Release|x86.Build.0 = Release|x86
{CF670175-7099-4090-A330-EE25C7230139}.Debug|Any CPU.ActiveCfg = Debug|x86
{CF670175-7099-4090-A330-EE25C7230139}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{CF670175-7099-4090-A330-EE25C7230139}.Debug|Mixed Platforms.Build.0 = Debug|x86
{CF670175-7099-4090-A330-EE25C7230139}.Debug|Win32.ActiveCfg = Debug|x86
{CF670175-7099-4090-A330-EE25C7230139}.Debug|x86.ActiveCfg = Debug|x86
{CF670175-7099-4090-A330-EE25C7230139}.Debug|x86.Build.0 = Debug|x86
{CF670175-7099-4090-A330-EE25C7230139}.Release|Any CPU.ActiveCfg = Release|x86
{CF670175-7099-4090-A330-EE25C7230139}.Release|Mixed Platforms.ActiveCfg = Release|x86
{CF670175-7099-4090-A330-EE25C7230139}.Release|Mixed Platforms.Build.0 = Release|x86
{CF670175-7099-4090-A330-EE25C7230139}.Release|Win32.ActiveCfg = Release|x86
{CF670175-7099-4090-A330-EE25C7230139}.Release|x86.ActiveCfg = Release|x86
{CF670175-7099-4090-A330-EE25C7230139}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -1095,8 +1095,6 @@
<DependentUpon>ThingsFiltersForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Resources\Font.png" />
<EmbeddedResource Include="Resources\Thing2D_3.png" />
<EmbeddedResource Include="Resources\Thing2D_2.png" />
<EmbeddedResource Include="Resources\White.png" />
<EmbeddedResource Include="Resources\Font.cfg" />
<EmbeddedResource Include="Windows\VertexEditForm.resx">

View file

@ -64,7 +64,7 @@ namespace CodeImp.DoomBuilder.Map
private float size;
private PixelColor color;
private bool fixedsize;
private float iconoffset; // Arrow or dot coordinate offset on the texture
private bool directional; //mxd. If true, we need to render an arrow
#endregion
@ -80,12 +80,12 @@ namespace CodeImp.DoomBuilder.Map
public int Action { get { return action; } set { BeforePropsChange(); action = value; } }
public int[] Args { get { return args; } }
public float Size { get { return size; } }
public float IconOffset { get { return iconoffset; } }
public PixelColor Color { get { return color; } }
public bool FixedSize { get { return fixedsize; } }
public int Tag { get { return tag; } set { BeforePropsChange(); tag = value; if((tag < General.Map.FormatInterface.MinTag) || (tag > General.Map.FormatInterface.MaxTag)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } }
public Sector Sector { get { return sector; } }
public bool IsModel { get { return isModel; } } //mxd
public bool IsDirectional { get { return directional; } } //mxd
#endregion
@ -206,7 +206,7 @@ namespace CodeImp.DoomBuilder.Map
t.args = (int[])args.Clone();
t.size = size;
t.color = color;
t.iconoffset = iconoffset;
t.directional = directional;
t.fixedsize = fixedsize;
base.CopyPropertiesTo(t);
@ -222,8 +222,6 @@ namespace CodeImp.DoomBuilder.Map
// This determines which sector the thing is in and links it
public void DetermineSector(VisualBlockMap blockmap)
{
//Linedef nl;
// Find nearest sectors using the blockmap
List<Sector> possiblesectors = blockmap.GetBlock(blockmap.GetBlockCoordinates(pos)).Sectors;
@ -452,7 +450,8 @@ namespace CodeImp.DoomBuilder.Map
}
// Apply icon offset (arrow or dot)
if(ti.Arrow) iconoffset = 0f; else iconoffset = 0.25f;
//if(ti.Arrow) iconoffset = 0f; else iconoffset = 0.25f;
directional = ti.Arrow; //mxd
}
#endregion

View file

@ -28,6 +28,7 @@ using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
using CodeImp.DoomBuilder.GZBuilder.Geometry; //mxd
using CodeImp.DoomBuilder.Config; //mxd
#endregion
@ -47,17 +48,16 @@ namespace CodeImp.DoomBuilder.Rendering
private const float THING_ARROW_SIZE = 1.5f;
private const float THING_ARROW_SHRINK = 2f;
private const float THING_CIRCLE_SIZE = 1f;
private const float THING_CIRCLE_SHRINK = 0f;
private const float THING_SPRITE_SHRINK = 2f;
private const int THING_BUFFER_SIZE = 100;
private const float MINIMUM_THING_RADIUS = 1.5f; //mxd
private const float MINIMUM_SPRITE_RADIUS = 5.5f; //mxd
private const string FONT_NAME = "Verdana";
private const int FONT_WIDTH = 0;
private const int FONT_HEIGHT = 0;
private const int THING_SHINY = 1;
private const int THING_SQUARE = 2;
private const int NUM_THING_TEXTURES = 4;
private const int NUM_THING_TEXTURES = 2;
internal const int NUM_VIEW_MODES = 4;
#endregion
@ -126,9 +126,6 @@ namespace CodeImp.DoomBuilder.Rendering
// Presentation
private Presentation present;
//mxd
private Dictionary<int, Dictionary<Vector2D, Thing>> thingsWithModel; //model index, list of thing positions in screen space, thing
#endregion
@ -942,116 +939,128 @@ namespace CodeImp.DoomBuilder.Rendering
// This makes vertices for a thing
// Returns false when not on the screen
private bool CreateThingVerts(Thing t, ref FlatVertex[] verts, int offset, PixelColor c)
private bool CreateThingBoxVerts(Thing t, ref FlatVertex[] verts, Dictionary<Thing, Vector2D> thingsByPosition, int offset, PixelColor c)
{
if(t.Size * scale < MINIMUM_THING_RADIUS) return false; //mxd. Don't render tiny little things
float circlesize;
float arrowsize;
// Determine size
float circlesize = (t.FixedSize && (scale > 1.0f) ? t.Size * THING_CIRCLE_SIZE : t.Size * scale * THING_CIRCLE_SIZE);
// Transform to screen coordinates
Vector2D screenpos = ((Vector2D)t.Position).GetTransformed(translatex, translatey, scale, -scale);
// Determine sizes
if(t.FixedSize && (scale > 1.0f))
{
circlesize = (t.Size - THING_CIRCLE_SHRINK) * THING_CIRCLE_SIZE;
arrowsize = (t.Size - THING_ARROW_SHRINK) * THING_ARROW_SIZE;
}
else
{
circlesize = (t.Size - THING_CIRCLE_SHRINK) * scale * THING_CIRCLE_SIZE;
arrowsize = (t.Size - THING_ARROW_SHRINK) * scale * THING_ARROW_SIZE;
}
// Check if the thing is actually on screen
if(((screenpos.x + circlesize) > 0.0f) && ((screenpos.x - circlesize) < windowsize.Width) &&
((screenpos.y + circlesize) > 0.0f) && ((screenpos.y - circlesize) < windowsize.Height))
{
//mxd. Collect things with models for rendering
if(t.IsModel && General.Settings.GZDrawModels && (!General.Settings.GZDrawSelectedModelsOnly || t.Selected)) {
if(!thingsWithModel.ContainsKey(t.Type)) {
thingsWithModel.Add(t.Type, new Dictionary<Vector2D, Thing>());
}
if (((screenpos.x + circlesize) <= 0.0f) || ((screenpos.x - circlesize) >= windowsize.Width) ||
((screenpos.y + circlesize) <= 0.0f) || ((screenpos.y - circlesize) >= windowsize.Height))
return false;
if(thingsWithModel[t.Type].ContainsKey(screenpos)) {
thingsWithModel[t.Type][screenpos] = t;
} else {
thingsWithModel[t.Type].Add(screenpos, t);
}
}
// Get integral color
int color = c.ToInt();
// Get integral color
int color = c.ToInt();
// Setup fixed rect for circle
verts[offset].x = screenpos.x - circlesize;
verts[offset].y = screenpos.y - circlesize;
verts[offset].c = color;
verts[offset].u = 1f / 512f;
verts[offset].v = 1f / 128f;
offset++;
verts[offset].x = screenpos.x + circlesize;
verts[offset].y = screenpos.y - circlesize;
verts[offset].c = color;
verts[offset].u = 0.25f - 1f / 512f;
verts[offset].v = 1f / 128f;
offset++;
verts[offset].x = screenpos.x - circlesize;
verts[offset].y = screenpos.y + circlesize;
verts[offset].c = color;
verts[offset].u = 1f / 512f;
verts[offset].v = 1f - 1f / 128f;
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset].x = screenpos.x + circlesize;
verts[offset].y = screenpos.y + circlesize;
verts[offset].c = color;
verts[offset].u = 0.25f - 1f / 512f;
verts[offset].v = 1f - 1f / 128f;
offset++;
// Setup fixed rect for circle
verts[offset].x = screenpos.x - circlesize;
verts[offset].y = screenpos.y - circlesize;
verts[offset].c = color;
verts[offset].u = 0f;
verts[offset].v = 0f;
offset++;
verts[offset].x = screenpos.x + circlesize;
verts[offset].y = screenpos.y - circlesize;
verts[offset].c = color;
verts[offset].u = 0.5f;
verts[offset].v = 0f;
offset++;
verts[offset].x = screenpos.x - circlesize;
verts[offset].y = screenpos.y + circlesize;
verts[offset].c = color;
verts[offset].u = 0f;
verts[offset].v = 1f;
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset].x = screenpos.x + circlesize;
verts[offset].y = screenpos.y + circlesize;
verts[offset].c = color;
verts[offset].u = 0.5f;
verts[offset].v = 1f;
float sinarrowsize = (float)Math.Sin(t.Angle + Angle2D.PI * 0.25f) * arrowsize;
float cosarrowsize = (float)Math.Cos(t.Angle + Angle2D.PI * 0.25f) * arrowsize;
// Setup rotated rect for arrow
verts[offset].x = screenpos.x + sinarrowsize;
verts[offset].y = screenpos.y + cosarrowsize;
verts[offset].c = -1;
verts[offset].u = 0.50f + t.IconOffset;
verts[offset].v = 0f;
offset++;
verts[offset].x = screenpos.x - cosarrowsize;
verts[offset].y = screenpos.y + sinarrowsize;
verts[offset].c = -1;
verts[offset].u = 0.75f + t.IconOffset;
verts[offset].v = 0f;
offset++;
verts[offset].x = screenpos.x + cosarrowsize;
verts[offset].y = screenpos.y - sinarrowsize;
verts[offset].c = -1;
verts[offset].u = 0.50f + t.IconOffset;
verts[offset].v = 1f;
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset].x = screenpos.x - sinarrowsize;
verts[offset].y = screenpos.y - cosarrowsize;
verts[offset].c = -1;
verts[offset].u = 0.75f + t.IconOffset;
verts[offset].v = 1f;
// Done
return true;
}
//mxd. Add to list
thingsByPosition.Add(t, screenpos);
// Not on screen
return false;
// Done
return true;
}
//mxd
private void CreateThingArrowVerts(Thing t, ref FlatVertex[] verts, Vector2D screenpos, int offset) {
// Determine size
float arrowsize = (t.FixedSize && (scale > 1.0f) ? (t.Size - THING_ARROW_SHRINK) * THING_ARROW_SIZE : (t.Size - THING_ARROW_SHRINK) * scale * THING_ARROW_SIZE);
// Setup rotated rect for arrow
float sinarrowsize = (float)Math.Sin(t.Angle + Angle2D.PI * 0.25f) * arrowsize;
float cosarrowsize = (float)Math.Cos(t.Angle + Angle2D.PI * 0.25f) * arrowsize;
verts[offset].x = screenpos.x + sinarrowsize;
verts[offset].y = screenpos.y + cosarrowsize;
verts[offset].c = -1;
verts[offset].u = 0.50f;
verts[offset].v = 0f;
offset++;
verts[offset].x = screenpos.x - cosarrowsize;
verts[offset].y = screenpos.y + sinarrowsize;
verts[offset].c = -1;
verts[offset].u = 1f;
verts[offset].v = 0f;
offset++;
verts[offset].x = screenpos.x + cosarrowsize;
verts[offset].y = screenpos.y - sinarrowsize;
verts[offset].c = -1;
verts[offset].u = 0.50f;
verts[offset].v = 1f;
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset].x = screenpos.x - sinarrowsize;
verts[offset].y = screenpos.y - cosarrowsize;
verts[offset].c = -1;
verts[offset].u = 1f;
verts[offset].v = 1f;
}
//mxd
private void CreateThingSpriteVerts(Vector2D screenpos, float width, float height, ref FlatVertex[] verts, int offset, int color) {
// Setup fixed rect for circle
verts[offset].x = screenpos.x - width;
verts[offset].y = screenpos.y - height;
verts[offset].c = color;
verts[offset].u = 0;
verts[offset].v = 0;
offset++;
verts[offset].x = screenpos.x + width;
verts[offset].y = screenpos.y - height;
verts[offset].c = color;
verts[offset].u = 1;
verts[offset].v = 0;
offset++;
verts[offset].x = screenpos.x - width;
verts[offset].y = screenpos.y + height;
verts[offset].c = color;
verts[offset].u = 0;
verts[offset].v = 1;
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset] = verts[offset - 2];
offset++;
verts[offset].x = screenpos.x + width;
verts[offset].y = screenpos.y + height;
verts[offset].c = color;
verts[offset].u = 1;
verts[offset].v = 1;
}
// This draws a set of things
@ -1079,8 +1088,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.Device.SetStreamSource(0, thingsvertices, 0, FlatVertex.Stride);
// Determine things texture to use
if(General.Settings.QualityDisplay) thingtextureindex |= THING_SHINY;
if(General.Settings.SquareThings) thingtextureindex |= THING_SQUARE;
if(General.Settings.SquareThings) thingtextureindex = 1;
graphics.Device.SetTexture(0, thingtexture[thingtextureindex].Texture);
graphics.Shaders.Things2D.Texture1 = thingtexture[thingtextureindex].Texture;
SetWorldTransformation(false);
@ -1092,20 +1100,33 @@ namespace CodeImp.DoomBuilder.Rendering
// Determine next lock size
int locksize = (things.Count > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : things.Count;
FlatVertex[] verts = new FlatVertex[THING_BUFFER_SIZE * 12];
FlatVertex[] verts = new FlatVertex[THING_BUFFER_SIZE * 6];
//mxd
thingsWithModel = new Dictionary<int, Dictionary<Vector2D, Thing>>();
Dictionary<int, List<Thing>> thingsByType = new Dictionary<int, List<Thing>>();
Dictionary<int, List<Thing>> modelsByType = new Dictionary<int, List<Thing>>();
Dictionary<Thing, Vector2D> thingsByPosition = new Dictionary<Thing, Vector2D>();
// Go for all things
int buffercount = 0;
int totalcount = 0;
foreach(Thing t in things)
{
//collect models
if (t.IsModel) {
if(!modelsByType.ContainsKey(t.Type)) modelsByType.Add(t.Type, new List<Thing>());
modelsByType[t.Type].Add(t);
}
// Create vertices
tc = fixedcolor ? c : DetermineThingColor(t);
if(CreateThingVerts(t, ref verts, buffercount * 12, tc))
if(CreateThingBoxVerts(t, ref verts, thingsByPosition, buffercount * 6, tc)) {
buffercount++;
//mxd
if(!thingsByType.ContainsKey(t.Type)) thingsByType.Add(t.Type, new List<Thing>());
thingsByType[t.Type].Add(t);
}
totalcount++;
@ -1113,13 +1134,13 @@ namespace CodeImp.DoomBuilder.Rendering
if(buffercount == locksize)
{
// Write to buffer
stream = thingsvertices.Lock(0, locksize * 12 * FlatVertex.Stride, LockFlags.Discard);
stream.WriteRange(verts, 0, buffercount * 12);
stream = thingsvertices.Lock(0, locksize * 6 * FlatVertex.Stride, LockFlags.Discard);
stream.WriteRange(verts, 0, buffercount * 6);
thingsvertices.Unlock();
stream.Dispose();
// Draw!
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 4);
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 2);
buffercount = 0;
// Determine next lock size
@ -1128,38 +1149,183 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Write to buffer
stream = thingsvertices.Lock(0, locksize * 12 * FlatVertex.Stride, LockFlags.Discard);
if(buffercount > 0) stream.WriteRange(verts, 0, buffercount * 12);
stream = thingsvertices.Lock(0, locksize * 6 * FlatVertex.Stride, LockFlags.Discard);
if(buffercount > 0) stream.WriteRange(verts, 0, buffercount * 6);
thingsvertices.Unlock();
stream.Dispose();
// Draw what's still remaining
if(buffercount > 0)
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 4);
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 2);
// Done
graphics.Shaders.Things2D.EndPass();
//mxd. Render sprites
int color = new PixelColor(255, 255, 255, 255).ToInt();
int selectionColor = General.Colors.Selection.ToInt();
graphics.Shaders.Things2D.BeginPass(1);
float spriteShrink = General.Settings.SquareThings ? THING_SPRITE_SHRINK : THING_SPRITE_SHRINK * 2;
foreach(KeyValuePair<int, List<Thing>> group in thingsByType){
// Find thing information
ThingTypeInfo info = General.Map.Data.GetThingInfo(group.Key);
// Find sprite texture
if(info.Sprite.Length == 0) continue;
ImageData sprite = General.Map.Data.GetSpriteImage(info.Sprite);
if(sprite == null) continue;
if(!sprite.IsImageLoaded) sprite.LoadImage();
if(sprite.Texture == null) sprite.CreateTexture();
graphics.Device.SetTexture(0, sprite.Texture);
graphics.Shaders.Things2D.Texture1 = sprite.Texture;
// Determine next lock size
locksize = (group.Value.Count > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : group.Value.Count;
verts = new FlatVertex[THING_BUFFER_SIZE * 6];
// Go for all things
buffercount = 0;
totalcount = 0;
float spriteWidth, spriteHeight;
float spriteScale = (group.Value[0].FixedSize && (scale > 1.0f)) ? 1.0f : scale;
if(sprite.Width > sprite.Height) {
spriteWidth = info.Radius * spriteScale - spriteShrink * spriteScale;
spriteHeight = spriteWidth * ((float)sprite.Height / sprite.Width);
if(spriteWidth < MINIMUM_SPRITE_RADIUS) continue; //don't render tiny little sprites
} else if(sprite.Width < sprite.Height) {
spriteHeight = info.Radius * spriteScale - spriteShrink * spriteScale;
spriteWidth = spriteHeight * ((float)sprite.Width / sprite.Height);
if(spriteHeight < MINIMUM_SPRITE_RADIUS) continue; //don't render tiny little sprites
} else {
spriteWidth = info.Radius * spriteScale - spriteShrink * spriteScale;
spriteHeight = spriteWidth;
if(spriteWidth < MINIMUM_SPRITE_RADIUS) continue; //don't render tiny little sprites
}
foreach(Thing t in group.Value) {
if(t.IsModel) continue;
CreateThingSpriteVerts(thingsByPosition[t], spriteWidth, spriteHeight, ref verts, buffercount * 6, t.Selected ? selectionColor : color);
buffercount++;
totalcount++;
// Buffer filled?
if(buffercount == locksize) {
// Write to buffer
stream = thingsvertices.Lock(0, locksize * 6 * FlatVertex.Stride, LockFlags.Discard);
stream.WriteRange(verts, 0, buffercount * 6);
thingsvertices.Unlock();
stream.Dispose();
// Draw!
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 2);
buffercount = 0;
// Determine next lock size
locksize = ((things.Count - totalcount) > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : (things.Count - totalcount);
}
}
// Write to buffer
stream = thingsvertices.Lock(0, locksize * 6 * FlatVertex.Stride, LockFlags.Discard);
if(buffercount > 0) stream.WriteRange(verts, 0, buffercount * 6);
thingsvertices.Unlock();
stream.Dispose();
// Draw what's still remaining
if(buffercount > 0)
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 2);
}
// Done
graphics.Shaders.Things2D.EndPass();
//mxd. Render thing arrows
graphics.Device.SetTexture(0, thingtexture[thingtextureindex].Texture);
graphics.Shaders.Things2D.Texture1 = thingtexture[thingtextureindex].Texture;
graphics.Shaders.Things2D.BeginPass(0);
// Go for all things
buffercount = 0;
totalcount = 0;
foreach (KeyValuePair<Thing, Vector2D> group in thingsByPosition) {
if(!group.Key.IsDirectional) continue;
CreateThingArrowVerts(group.Key, ref verts, group.Value, buffercount * 6);
buffercount++;
totalcount++;
// Buffer filled?
if(buffercount == locksize) {
// Write to buffer
stream = thingsvertices.Lock(0, locksize * 6 * FlatVertex.Stride, LockFlags.Discard);
stream.WriteRange(verts, 0, buffercount * 6);
thingsvertices.Unlock();
stream.Dispose();
// Draw!
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 2);
buffercount = 0;
// Determine next lock size
locksize = ((things.Count - totalcount) > THING_BUFFER_SIZE) ? THING_BUFFER_SIZE : (things.Count - totalcount);
}
}
// Write to buffer
stream = thingsvertices.Lock(0, locksize * 6 * FlatVertex.Stride, LockFlags.Discard);
if(buffercount > 0) stream.WriteRange(verts, 0, buffercount * 6);
thingsvertices.Unlock();
stream.Dispose();
// Draw what's still remaining
if(buffercount > 0)
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, buffercount * 2);
//Done with this pass
graphics.Shaders.Things2D.EndPass();
//mxd. Render models
if (thingsWithModel.Count > 0) {
if (General.Settings.GZDrawModels) {
// Set renderstates for rendering
graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, false);
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
graphics.Device.SetRenderState(RenderState.FillMode, FillMode.Wireframe);
graphics.Shaders.Things2D.BeginPass(1);
graphics.Shaders.Things2D.BeginPass(2);
Color4 cSel = General.Colors.Selection.ToColorValue();
Color4 cWire = General.Colors.ModelWireframe.ToColorValue();
ModelData mde;
foreach(KeyValuePair<int, Dictionary<Vector2D, Thing>> group in thingsWithModel) {
foreach(KeyValuePair<int, List<Thing>> group in modelsByType) {
mde = General.Map.Data.ModeldefEntries[group.Key];
foreach(KeyValuePair<Vector2D, Thing> thingData in group.Value) {
graphics.Shaders.Things2D.FillColor = thingData.Value.Selected ? cSel : cWire;
float maxX = Math.Max(Math.Abs(mde.Model.BoundingBox[4].X), Math.Abs(mde.Model.BoundingBox[1].X));
float maxY = Math.Max(Math.Abs(mde.Model.BoundingBox[4].Y), Math.Abs(mde.Model.BoundingBox[1].Y));
float maxSize = Math.Max(maxX, maxY);
foreach(Thing t in group.Value) {
if(General.Settings.GZDrawSelectedModelsOnly && !t.Selected) continue;
Vector2D screenpos = ((Vector2D)t.Position).GetTransformed(translatex, translatey, scale, -scale);
float modelScale = scale * t.Scale;
//should we render this model?
if(((screenpos.x + maxSize * modelScale) <= 0.0f) || ((screenpos.x - maxSize * modelScale) >= windowsize.Width) ||
((screenpos.y + maxSize * modelScale) <= 0.0f) || ((screenpos.y - maxSize * modelScale) >= windowsize.Height))
continue;
graphics.Shaders.Things2D.FillColor = t.Selected ? cSel : cWire;
for(int i = 0; i < mde.Model.Meshes.Count; i++) {
graphics.Shaders.Things2D.SetTransformSettings(thingData.Key, thingData.Value.Angle, scale * thingData.Value.Scale);
graphics.Shaders.Things2D.SetTransformSettings(screenpos, t.Angle, modelScale);
graphics.Shaders.Things2D.ApplySettings();
// Draw
@ -1168,8 +1334,8 @@ namespace CodeImp.DoomBuilder.Rendering
}
}
//Done with this pass
graphics.Shaders.Things2D.EndPass();
graphics.Device.SetRenderState(RenderState.FillMode, FillMode.Solid);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

View file

@ -46,6 +46,18 @@ sampler2D texture1samp = sampler_state
MipMapLodBias = -0.9f;
};
//mxd. Texture sampler settings for sprite rendering
sampler2D texture1sprite = sampler_state
{
Texture = <texture1>;
MagFilter = Point;
MinFilter = Point;
MipFilter = Point;
AddressU = Clamp;
AddressV = Clamp;
MipMapLodBias = 0.0f;
};
// Transformation
PixelData vs_transform(VertexData vd)
{
@ -56,24 +68,23 @@ PixelData vs_transform(VertexData vd)
return pd;
}
// Pixel shader for colored circle
float4 ps_circle(PixelData pd) : COLOR
//mxd. Pixel shader for sprite drawing
float4 ps_sprite(PixelData pd) : COLOR
{
// Texture pixel color
float4 c = tex2D(texture1samp, pd.uv);
// Use shinyness?
if(pd.uv.x < 0.4f)
{
float4 s = tex2D(texture1samp, pd.uv + float2(0.25f, 0.0f));
c = float4(lerp(c.rgb * pd.color.rgb, s.rgb, s.a), c.a);
}
c.a = c.a * pd.color.a * rendersettings.w;
return c;
// Take this pixel's color
float4 c = tex2D(texture1sprite, pd.uv);
return float4(c.rgb, c.a * rendersettings.w) * pd.color;
}
//mxd: pretty darn simple pixel shader for wireframe rendering :)
//mxd. Pixel shader for thing box and arrow drawing
float4 ps_thing(PixelData pd) : COLOR
{
// Take this pixel's color
float4 c = tex2D(texture1samp, pd.uv);
return float4(c.rgb, c.a * rendersettings.w) * pd.color;
}
//mxd. Pretty darn simple pixel shader for wireframe rendering :)
float4 ps_fill(PixelData pd) : COLOR {
return fillColor;
}
@ -81,13 +92,20 @@ float4 ps_fill(PixelData pd) : COLOR {
// Technique for shader model 2.0
technique SM20
{
pass p0
pass p0 //mxd
{
VertexShader = compile vs_2_0 vs_transform();
PixelShader = compile ps_2_0 ps_circle();
PixelShader = compile ps_2_0 ps_thing();
}
//mxd
pass p1
pass p1 //mxd
{
VertexShader = compile vs_2_0 vs_transform();
PixelShader = compile ps_2_0 ps_sprite();
}
pass p2 //mxd
{
VertexShader = compile vs_2_0 vs_transform();
PixelShader = compile ps_2_0 ps_fill();

View file

@ -18,11 +18,10 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.GZBuilder.Tools;
using System.Drawing;
#endregion