Commit Graph

982 Commits

Author SHA1 Message Date
Andre Mohren
3f81df9c52 Fixed backwards animation playback. 2018-08-04 20:58:02 +02:00
reaperrr
b2a069f8ab Add FillTriangle support 2018-07-28 21:35:42 +02:00
Paul Chote
1ac13de4b2 Remove byte order marks from C# files. 2018-07-01 11:08:32 +02:00
Paul Chote
8c0f4fde81 Fix newlines in C# files. 2018-07-01 11:08:32 +02:00
RoosterDragon
bb536ee4fc Run graphics rendering on a dedicated thread.
The main game thread can offload some of the CPU cost to the rendering thread, freeing up its time to run more logic and render ticks.
2018-06-22 18:40:16 +01:00
Paul Chote
9ff177359b Split IGraphicsContext from IPlatformWindow. 2018-06-13 18:45:21 +01:00
Paul Chote
ab14a86d39 Rename Renderer.Device to Renderer.Window. 2018-06-13 18:45:21 +01:00
Paul Chote
28c8089bc7 Rename IGraphicsDevice to IPlatformWindow. 2018-06-13 18:45:21 +01:00
Paul Chote
8461a82577 Remove requirement for depth sprites to share color sheet. 2018-06-04 23:33:57 +02:00
Paul Chote
bfcbe8c004 Improve batching by binding up to 8 simultaneous textures. 2018-06-04 23:33:57 +02:00
Paul Chote
131496ebf8 Merge RGBA sprite rendering into SpriteRenderer.
Renderer.RgbaSpriteRenderer is kept as a thin
wrapper to maintain compatibility with consumer
code.
2018-06-04 23:33:57 +02:00
Paul Chote
ba38878933 Add TextureChannel.RGBA for RBGA sprites. 2018-06-04 23:33:57 +02:00
Paul Chote
c307b3e291 Encode channel attributes in a more sensible way. 2018-06-04 23:33:57 +02:00
Paul Chote
6c338eb06c Revert "Run graphics rendering on a dedicated thread."
This reverts commit b9be52c5428d4a3862d62fe3a2c01663bd3692c3.
2018-06-04 23:04:35 +02:00
RoosterDragon
b96e062a0d Run graphics rendering on a dedicated thread.
The main game thread can offload some of the CPU cost to the rendering thread, freeing up its time to run more logic and render ticks.
2018-05-29 23:05:39 +01:00
RoosterDragon
8ec90525e3 Change Shader.Render to Shader.PrepareRender.
Instead of running the shader operation as an action, just run it after the shader is prepared.
2018-05-29 23:05:39 +01:00
RoosterDragon
95ac1aa5b2 Avoid redundant property sets in WorldRenderer.Draw. 2018-05-29 23:05:39 +01:00
RoosterDragon
296c732525 Avoid redundant implicit float3 conversions. 2018-05-29 23:05:39 +01:00
Paul Chote
a329711011 Render lines using SpriteRenderer without breaking the batch. 2018-05-23 23:28:22 +02:00
Paul Chote
bf4b91741a Ignore unused frames when loading Sequences into Sheets. 2018-05-02 09:59:03 +02:00
Paul Chote
d9fd0f272c Add support on-demand sprite frame loading.
Passing the getUsedFrames argument will cause frames to be buffered
locally (and not added to the SheetBuilder) until they are explicitly
requested. This allows unused frames in sprite files to be skipped
instead of wasting space in GPU memory.
2018-05-02 09:59:03 +02:00
Paul Chote
952f41b4e4 Add --dump-sequence-sheets Utility command.
This can be used to debug and optimize the texture
data that is uploaded to VRAM.
2018-04-30 02:05:43 +02:00
RoosterDragon
7bc5bd5791 Force buffered sheets to commit data to a texture on buffer release.
Previously ReleaseBuffer did not immediately null out the buffer, instead the releaseBufferOnCommit flag allows it to be nulled when the texture is next access and the pending changes from the buffer are committed to it. Now the texture is committed immediately, thus the buffer is null once ReleaseBuffer returns.

Once loaded, we force a GC to reclaim temporary memory used during loading. Previously the buffer would not be null as it was pending commit to the texture and thus could not be reclaimed. As soon as we rendered the first frame, the buffer is nulled but we are now in a low GC state - and the buffer will not be reclaimed until the next gen 2 GC which may be dozens of minutes away.

This change ensures the buffer is null in time for the post-load GC, and thus can be reclaimed before we start rendering.
2018-04-29 18:11:48 +02:00
RoosterDragon
f6471d411e Reuse set when rendering actors in the world to avoid allocations. 2018-03-22 23:32:03 -03:00
RoosterDragon
e17ede34ef Add Int32Matrix4x4 struct.
This allows matrices to be represented as a value type, and additionally allows avoiding array allocations when calculating rotations.
2018-03-21 12:07:53 +01:00
RoosterDragon
f2e270ce06 Return IRenderable[] rather than IEnumerable<IRenderable> for animations.
Since some callers now know they have an array, then can enumerate it more efficiently and without allocating an enumerator.
2018-03-17 17:51:16 +01:00
Arular101
8a60918841 Update copyright notice year to 2018 2018-01-17 00:47:34 +01:00
RoosterDragon
e42e766bb6 Prevent incorrect usage of ModelRenderer.
Force BeginFrame/EndFrame to be called correctly, and prevent calls to RenderAsync when outside of a frame.
2017-12-23 22:58:17 +01:00
reaperrr
fbc18dfb18 Use HashSet instead of IEnumerable to pass actors to renderable lists 2017-12-23 17:56:11 +00:00
reaperrr
04fb0f209d Spatially partition some actor overlays 2017-12-23 17:56:11 +00:00
reaperrr
6ef95405bf Split overlay renderable generation to separate list
To make the code a bit more readable and consistent with normal renderables.
2017-12-23 17:56:11 +00:00
RoosterDragon
a9d1d374b8 Remove draw line 2D helper method.
Callers can provide 3D points easily, and this avoids the need to allocate and slow down enumeration via the points.Select(p => new float3(p, 0)) wrapper.
2017-12-17 01:51:51 +01:00
Paul Chote
6f5d035e79 Introduce IMouseBounds and split/rework mouse rectangles.
The render bounds for an actor now include the area covered
by bibs, shadows, and any other widgets. In many cases this
area is much larger than we really want to consider for
tooltips and mouse selection.

An optional Margin is added to Selectable to support cases
like infantry, where we want the mouse area of the actor
to be larger than the drawn selection box.
2017-12-11 19:45:07 +01:00
Paul Chote
29255c8e01 Add IModel.AggregateBounds and ModelAnimation.ScreenBounds.
The bounds define the smallest Rectangle that covers all
rotations of all frames within a model sequence.
2017-12-11 19:45:07 +01:00
Paul Chote
506b677527 Add ModelAnimation.IsVisible property. 2017-12-11 19:45:07 +01:00
Paul Chote
041431d966 Add ISpriteSequence.Bounds and Animation(WithOffset).ScreenBounds.
The bounds define the smallest Rectangle that covers all frames within a sequence.
2017-12-11 19:45:07 +01:00
RoosterDragon
c75a866f0d Lazily allocate sheet builder in ModelRenderer.
Avoid allocating the sheet builder each frame until it is needed. For mods that do not need to render models, this avoids allocating a large buffer and backing sheet as it will never render to the sheet. For mods that do render models, but don't need any this frame, this avoids allocating a new SheetBuilder that will not be used.
2017-12-11 01:44:21 +01:00
Paul Chote
9d2935935c Add a debug visualization for screen map rectangles. 2017-12-04 23:10:23 +01:00
reaperrr
6711af63eb Move SelectionBarsRenderable to Mods.Common 2017-11-21 01:00:09 +02:00
reaperrr
be290cfabd Split Actor.Bounds into RenderBounds and SelectableBounds
Additionally, internally renamed VisualBounds to SelectionOverlayBounds to avoid confusion with RenderBounds.

This step was necessary to prevent actors with selectable area smaller than their graphics to be removed too early from ScreenMap even though part of the graphics should still be visible.
RA cruisers were a prime example, but to a lesser extent several other actors were affected as well.

This separation also serves as preparation to determine the final RenderBounds from multiple source bounds later, to fix the remaining ScreenMap issues (building 'bibs', aircraft shadows).
2017-11-21 01:00:09 +02:00
RoosterDragon
a71a5cc71d Reduce the size of the sheets created for fonts.
- A 512x512 sheet is about half full after precaching and some usage, but uses 16x less memory than the default 2048x2048 sheet. This saving occurs twice as we maintain a managed buffer for this sheet.
- Only precache smaller fonts, as the larger fonts are less used and take up more space than is worthwhile.
- Only precache in white, as red is largely unused.
2017-11-19 12:40:04 +00:00
Andrii Yukhymchak
636a9a74a1 Font Crash gracious fallback 2017-11-01 18:50:15 +01:00
Paul Chote
69b4b541d2 Fix mutable use of float2 in SpriteFont. 2017-10-17 15:46:07 +02:00
Matthias Mailänder
1aebf9857c Add support for only rendering effects inside screen bounds 2017-09-17 12:52:04 +01:00
rob-v
d4e9e0e069 Add Visualization chat commands 2017-07-23 15:08:24 +02:00
rob-v
1b3422db2d Fix flickering tooltip 2017-06-24 11:52:27 +01:00
Paul Chote
2683b2507e Fix remaining voxel references in Game. 2017-06-14 18:56:06 +02:00
Paul Chote
34810756c2 Move Voxel code to Mods.Cnc. 2017-06-14 18:56:06 +02:00
Paul Chote
dc4c3fd546 Rename VoxelRenderer to ModelRenderer. 2017-06-14 18:56:06 +02:00
Paul Chote
4f42778d26 Rename VoxelAnimation to ModelAnimation. 2017-06-14 18:56:06 +02:00