Commit Graph

173 Commits

Author SHA1 Message Date
Paul Chote
a495a2f528 Split IFinalizedRenderable from Renderable to remove mutable structs. 2015-02-09 23:23:37 +00:00
RoosterDragon
82bea961ba Checked LINQ queries and collections for inefficiencies.
- Made Array.IndexOf available via extension method.
- Made ToHashSet extension method.
- Change collections queried often via Contains into sets.
- Avoid Count() extension if Count or Length property exist.
- Made Count() > 0 checks and variations calls to Any() instead.
- Don't call ToList/ToArray if there is no benefit to materializing the sequence.
- If the sequence does benefit from materialization, follow this general pattern:
  - Collection queried often via Contains use ToHashSet to speed up lookups.
  - Short lived variables use ToList. This is because ToArray requires an extra copy to output the final size.
  - Collections persisted into fields or for a long time use ToArray to minimize memory overhead.
2015-01-29 19:20:11 +00:00
RoosterDragon
930d9cbea3 Cache or inline some delegates to avoid repeated allocations. 2015-01-14 22:57:41 +00:00
Paul Chote
3ea70e891d Merge pull request #7291 from RoosterDragon/dynamic-palette-sizing
Implement dynamic hardware palette sizing.
2015-01-13 17:41:15 +13:00
abcdefg30
8ca61aa917 Updated all year numbers 2015-01-09 21:18:05 +01:00
Matthias Mailänder
89b2f4d5d3 Merge pull request #7217 from Mailaender/chrome-init-cleanup
Cleaned up the ingame widget initialization
2015-01-08 07:40:36 +01:00
RoosterDragon
53f06ba093 Implement dynamic hardware palette sizing.
The HardwarePalette will now grow its palette buffer and texture in power-of-2 increments. This avoids it having to allocate memory for a full 256x256 texture up front. In practice the default mods use 22 or 23 palettes so a 32x256 texture is used. This means both the buffer and texture save neatly on memory. Additionally, HardwarePalette.ApplyModifiers sees a nice speedup as it has to transfer a much smaller amount of memory from the buffer to the texture.

To facilitate this change, the MaxPalettes constant is no more. Instead the PaletteReference deals with the calculation of the index and this is passed into the appropriate methods.
2015-01-07 22:41:51 +00:00
RoosterDragon
69c409c20d Speed up depth sorting of renderables.
The OrderBy overload that takes an int generating key selector is faster than the one that requires a custom comparer. We extract a function from the ScreenZPosition function that determines the Z position of a WPos with an offset, but does not account for the tileset height. For the ordering function this is fine as only the relative magnitude of the comparison keys matter, so we don't need to spend time adjusting for the tileset height, as that won't affect the sort.
2015-01-07 18:22:38 +00:00
Matthias Mailänder
9d2f33d42c add a World type 2015-01-04 17:57:38 +01:00
Matthias Mailänder
bc3acfeee7 StyleCop clean OpenRA.Game 2015-01-04 15:38:54 +01:00
Hellhake
5a97a4b63b Fix StyleCop warnings in OpenRA.Game 2015-01-02 12:11:01 +01:00
RoosterDragon
9cbac2d5e1 Clean up style of files affected by the last commit. 2014-12-22 17:34:02 +00:00
RoosterDragon
f0f02dff5c Dispose of graphics resources deterministically.
Textures, FrameBuffers and VertexBuffers allocated by the Sdl2 Renderer were only being released via finalizers. This could lead to OpenGL out of memory errors since resources may not be cleaned up in a timely manner. To avoid this, IDisposable has been implemented and transitively applied to classes that use these resources.

As a side-effect some static state is no longer static, particularly in Renderer, in order to facilitate this change and just for nicer design in general.

Also dispose some bitmaps.
2014-12-22 17:34:01 +00:00
Paul Chote
0884722c4b Change IOrderGenerator.RenderAfterWorld to return Renderables. 2014-07-25 21:14:39 +12:00
Paul Chote
da6ecbf92e Change IPostRenderSelection and IPlaceBuildingDecoration to return renderables. 2014-07-25 21:14:39 +12:00
Paul Chote
1beff77c6a Split selectable rendering into *Renderables. 2014-07-25 21:14:39 +12:00
Paul Chote
c4bcf0af46 Introduce RangeCircleRenderable. 2014-07-25 21:14:39 +12:00
RoosterDragon
7030d8b2b6 Changed HardwarePalette.ApplyModifiers to be more efficient.
- Add separate ImmutablePalette and MutablePalette classes since the distinction is extremely important to HardwarePalette.
- Keep a cache of palettes in HardwarePalette to avoid reallocation them every time ApplyModifiers is called.
- Palettes that are not allowed to be modified are copied to the buffer once when added, rather than every time ApplyModifiers is called.
- The AdjustPalette method now takes a read-only dictionary to prevent the dictionary being messed with.
- Added a constant for the palette size to remove its usage as a magic number in several areas.
- The ColorPreviewManagerWidget is annoying in that it needs to actually permanently update a palette after it has been added. To allow this, HardwarePalette now allows a palette to be replaced after initialization. The WorldRenderer therefore now also updates the PaletteReference it created earlier with the new palette to prevent stale data being used elsewhere.
2014-06-28 01:11:48 +01:00
RoosterDragon
909c5c7037 Some minor cleanup in TraitDictionary and affected callsites. 2014-06-17 22:10:41 +01:00
ScottNZ
dbffce81a6 Remove unused usings 2014-06-15 22:16:40 +12:00
RoosterDragon
b733465f33 General uncontroversial cleanup:
- Made private methods static where possible (runtime can elide checking the object for null).
- Declared attribute classes as sealed (allows reflection on attributes to complete faster).
- Moved some static cctor's into field initializers (static cctor's are slower than static field initializers).
- Made classes static if they contained only static methods (can't create instances of useless objects).
- Use inferable Exts.Lazy and not new Lazy<T>().
- Added required STAThread attribute to CrashDialog.
- Removed unused parameters in private methods.
- Added Serializable attribute to exceptions.
- Added parameter name in calls to ArgumentNullException.
- Use of as operator instead of is + cast.
- Changed (x as Foo).Bar anti-pattern into ((Foo)x).Bar. Results in sensible cast exceptions on error rather than null dereferences.
- Removed unused method in NullShader.
2014-05-23 15:50:54 +01:00
Paul Chote
fdd4437c52 Re-enable shellmaps. 2014-05-02 22:08:41 +12:00
Paul Chote
4935266945 Merge FileFormats dll into Game and reorganise namespaces. 2014-04-17 01:20:47 +12:00
Paul Chote
1b2a90c00c Migrate to System.Lazy. 2014-04-09 20:20:41 +12:00
Matthias Mailänder
67cd0645a4 update to .NET 4.0 2014-04-09 20:20:26 +12:00
Oliver Brakmann
4d71e37ab0 Disable shellmaps temporarily 2014-04-03 17:24:01 +02:00
Paul Chote
4f7f0b7a55 Don't draw combat debug for actors outside the world. 2014-03-21 10:03:54 +13:00
Paul Chote
0143e8bfb8 Support rectangular tiles. 2013-12-29 14:16:20 +13:00
Paul Chote
1a31368953 Convert range circle rendering to world coords. 2013-12-26 17:23:12 +13:00
Paul Chote
4e814a8c2e Move ShroudRenderer into a trait. 2013-12-11 19:22:55 +13:00
Curtis Shmyr
d30f60809b Added 2 settings for unit health bars: always show unit health, and team health bar colors 2013-11-24 12:12:52 -07:00
Paul Chote
94554d7678 Support nested scissor rectangles. 2013-10-25 08:31:34 +13:00
Paul Chote
84bb78060f Don't zoom UI lines when pixel doubling. 2013-10-15 11:19:16 +13:00
Paul Chote
44dd801f16 Extract shared constants in Draw*Bar and DrawSelectionBox. 2013-10-15 10:45:51 +13:00
Paul Chote
483120ea20 Extract DrawTargetMarker to WorldRenderer. 2013-10-15 10:45:51 +13:00
Paul Chote
839419635d Improve contrasted range circle rendering. 2013-10-15 10:45:51 +13:00
Paul Chote
919181e04d Clean up viewport internals. 2013-10-05 21:01:22 +13:00
Paul Chote
936bf98496 Move Viewport inside WorldRenderer. 2013-10-05 21:01:22 +13:00
Paul Chote
0b560bfc6e Move more viewport lookups to WorldRenderer. 2013-10-05 21:01:21 +13:00
Paul Chote
f575c20d38 Route viewport centering via WorldRenderer. 2013-10-05 21:01:21 +13:00
Paul Chote
5f0bb4b6c2 Fix some style nits in WorldRenderer. 2013-09-29 21:15:46 +13:00
Paul Chote
2e0e4b0bc5 Add WorldRenderer.Position for screen -> world conversion. 2013-09-27 15:41:32 +12:00
Paul Chote
4df9fc1acc Render minefield targeting using PBOG-style overlay. 2013-09-27 15:41:32 +12:00
Paul Chote
0dc50c65f5 Remove unnecessary int2 -> PPos -> int2 conversions. 2013-09-27 15:41:32 +12:00
Paul Chote
ad44610e5a Replace dynamic Actor.Bounds with the (unchanging) relative rect. 2013-09-27 15:39:57 +12:00
Paul Chote
dfd51c0caa Introduce ScreenMap trait for caching screen-coord queries. 2013-09-27 15:36:25 +12:00
Paul Chote
b6a033eef5 Remove obsolete IRenderAsTerrain.
This removes the technical limitation preventing
FrozenUnderFog on bridges.
2013-08-15 18:12:49 +12:00
Paul Chote
387ac04d9f Split tileset artwork loading out of TileSet.
This simplifies terrain loading and allows for
non-square tiles in game.

The editor still relies on the old code for now.
2013-08-14 23:08:17 +12:00
Paul Chote
0a9d920eb6 Allow world and (render-) player actors to render. 2013-08-11 22:23:52 +12:00
Paul Chote
4754cbb768 Replace IOrderGenerator.RenderBeforeWorld with world-sorted .Render.
Range circles have been moved to RenderAfterWorld for now.
2013-08-11 00:25:54 +12:00