Commit Graph

77 Commits

Author SHA1 Message Date
RoosterDragon
d0f7511a62 Add TrimExcess to TypeDictionary.
After adding is finished, this can be used to reduce the memory footprint of the dictionary.
2018-03-21 12:08:23 +01: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
5bd5a384b7 Use a BitSet for representing target types.
- Rename Bits<T> to BitSet<T>.
- Implement set based helpers for BitSet<T>.
- When representing TargetTypes of ITargetable in various traits, use a BitSet<TargetableType> instead of HashSet<string> for better performance & reduced memory usage.
- Fix FieldLoader to trim input values when generating a BitSet<T>.
- Require T in BitSet<T> and BitSetAllocator<T> to be a class since it's just a marker value. This allows the JIT to instantiate generic code for these classes once, as they don't benefit from specialized code for T. (Typically JITs will generate shared code for all reference types, and unique code for every value type encountered).
2018-03-21 12:07:44 +01:00
Arular101
21504a774d Add missing copyright notice 2018-01-17 23:07:01 +01:00
Arular101
8a60918841 Update copyright notice year to 2018 2018-01-17 00:47:34 +01:00
RoosterDragon
7760c41bd9 Avoid array resizing in OpenAlAsyncLoadSound.
- Where it is accessible, use the length of the stream to presize the MemoryStream to the correct size.
- Instead of copying out the result via ToArray, grab the underlying buffer via GetBuffer and use that to create the sound source.

This avoids extraneous copying of the array containing the audio.
2017-12-12 00:01:04 +01:00
Paul Chote
46f6263061 Update ScreenMap state in a single pass at the end of the tick. 2017-12-11 19:45:07 +01:00
Paul Chote
9d2935935c Add a debug visualization for screen map rectangles. 2017-12-04 23:10:23 +01:00
Paul Chote
9bdedda43a Make float2 immutable. 2017-10-17 15:46:07 +02:00
RoosterDragon
7ed769421e Providing streaming WavFormat data.
WavFormat.GetPCMInputStream now returns data that is streamed, rather than a MemoryStream.
2017-09-24 11:23:39 +01:00
Matthias Mailänder
1aebf9857c Add support for only rendering effects inside screen bounds 2017-09-17 12:52:04 +01:00
RoosterDragon
9413d9595c Providing streaming AudFormat data.
AudFormat.GetPCMInputStream now returns data that is streamed, rather than a MemoryStream.
2017-07-14 23:02:49 +01:00
RoosterDragon
297f4ad9ed Ensure we set ZipConstants.DefaultCodePage by using a helper method.
We were currently dealing with this terrible global variable in FileSystem/ZipFile.cs previously, but other parts of the code such as DownloadPackageLogic were creating these files too, and may not have executed the static ctors that fixed the encoding yet.
2017-07-05 22:45:15 +01:00
Curtis Shmyr
33e1a6b2dd Fix frame end task race condition in ScrollPanelWidget 2017-01-29 17:49:40 +00:00
Paul Chote
5e7c816257 Add support for font scaling. 2017-01-21 10:59:59 +00:00
Taryn Hill
43317e0f5d Update copyright notice year to 2017 2016-12-31 23:46:13 -06:00
RoosterDragon
2ffea5db54 Change Game.RunTime to a long to prevent overflow. 2016-09-20 19:06:10 +01:00
Paul Chote
3082c61e75 Add depth buffer support to tactical overlays. 2016-08-27 15:43:20 +01:00
Matthias Mailänder
3c7871b352 Add actor name to ease debugging of invalid bounds. 2016-05-15 16:21:32 +02:00
evgeniysergeev
7e7b3f505d SpatiallyPartitioned fixup for d2
BoundsToBinRowsAndCols fixup for negative width or height

Using Math.Min and Math.Max utils instead of '?:'
2016-05-10 22:39:46 +03:00
Paul Chote
a8dda39a72 Introduce float3 type. 2016-04-10 09:41:01 -04:00
RoosterDragon
0306a8de6c Add tests and make minor fixes to PriorityQueue. 2016-03-03 22:31:45 +00:00
Paul Chote
e71225496b Clarify GPL version. 2016-02-21 16:30:48 +00:00
Paul Chote
b396965fd9 Update licence header year. 2016-02-21 16:27:31 +00:00
abcdefg30
085367ced6 Merge pull request #10461 from RoosterDragon/partition-bounds
Calculate better upper bounds in SpatiallyPartitioned.
2016-01-24 21:13:55 +01:00
Oliver Brakmann
8fe90999a5 Merge pull request #10462 from RoosterDragon/partition-no-empty
Prevent items without size from being added to SpatiallyPartitioned.
2016-01-24 20:59:25 +01:00
RoosterDragon
8e89a6a696 Simplify names, remove unused usings, remove redundant casts. 2016-01-17 21:35:36 +00:00
Matthias Mailänder
d578ea4094 Implement MergedStream.Position properly 2016-01-15 18:29:25 +01:00
RoosterDragon
a15d1801e1 Calculate better upper bounds in SpatiallyPartitioned.
SpatiallyPartitioned was calculating larger that necessary bounding regions as this was simple to do and does not impact correctness. By being careful to calculate the upper bounds exactly we can avoid checking more bins than we need to during updates and queries.
2016-01-09 23:44:58 +00:00
RoosterDragon
1bc3a7395f Prevent items without size from being added to SpatiallyPartitioned.
Items with no size act unexpectedly as they can fail to be returned when querying partition bins as they do not intersect along the top or left edges of the bin. We prevent such items being added in the first place to avoid this scenario.

As a side effect - we must now prevent any Immobile items that do not have size from being added to the screen map.
2016-01-09 16:51:13 +00:00
atlimit8
4744f436d3 Move FrozenActor creation to Created in FrozenUnderFog 2015-12-31 00:53:26 -06:00
Matthias Mailänder
c6cc0ecd29 Merge pull request #10323 from RoosterDragon/struct-equatable
Ensure some structs implement IEquatable<T>.
2015-12-30 09:28:09 +01:00
atlimit8
68fd5dfd58 Merge pull request #10272 from RoosterDragon/player-dict
Speed up dictionaries keyed on Player
2015-12-29 19:27:11 -06:00
RoosterDragon
4948f73154 Ensure some structs implement IEquatable<T>. 2015-12-29 15:27:00 +00:00
RoosterDragon
8d2fc24fbe Speed up SpatiallyPartitioned.InBox for searches in a single partition bin.
If a search in a spatial partition is taking place entirely within a single bin, the cost of tracking possible duplicate items with a set can be avoided for a small speedup.
2015-12-28 21:49:58 +00:00
RoosterDragon
3a2139de26 Add PlayerDictionary.
This custom collection allows other classes to implement a Player to value mapping, but also stores the values in an array for faster lookup by the player index in the world. For some code, this improved lookup time is important for performance.
2015-12-23 23:54:04 +00:00
Matthias Mailänder
281cd95be4 Merge pull request #9627 from RoosterDragon/mix-on-filesystem
Avoid redundant copies of mix files in memory
2015-11-01 08:54:24 +01:00
Paul Chote
386f252736 Implement ObservableList collection. 2015-10-17 22:13:22 +01:00
RoosterDragon
210c7e312b Don't keep mix files in memory.
Added SegmentStream class to assist in maintaining views into portions of the FileStream of the overall mix file to avoid having to copy sections into in-memory buffers.
2015-10-13 19:23:56 +01:00
RoosterDragon
7decfc83ea Fix ActionQueue ordering.
This enforces a well defined ordering for ActionQueue to ensure it runs actions in the the order one would expect.
2015-09-20 23:20:51 +01:00
RoosterDragon
54e7c0bf44 Refactor TypeDictionary.
- When removing entries, ensure the dictionary entry is removed is the list is emptied, to prevent incorrect lookups later.
- Prevent NRE when calling GetOrDefault<T> where T is a value type and the default is returned.
- Use a single dictionary for simplicity and improved lookup performance (since there is only one dictionary to check).
- De-duplicate code in Get and GetOrDefault.
2015-07-03 20:54:34 +01:00
Paul Chote
5754de141d Add Remove support to TypeDictionary. 2015-05-15 17:08:30 +01:00
RoosterDragon
109ccbb0b0 Added ConcurrentCache, a thread-safe Cache. 2015-04-25 18:55:45 +01:00
RoosterDragon
09dc1db651 Refactored ScreenMap & improved perf of updates, removals and region lookups.
Reduce code duplication by extracting a common class to deal with spatial partitioning of actors, and use some (cached) delegates to reduce duplication further without affecting performance too much.

Speed up updates and removal of actors by caching their location so we only need to update or remove them from bins they are actually in (typically very few), compared to having to check every bin for removals which is much more work in comparison.

Speed up checking for actors inside a region by checking if items are located entirely within the bin they are located in. If so, we don't need to add them to the hash-set for de-duplication purposes which is fairly expensive.
2015-04-23 21:06:09 +01:00
Benno van den Bogaard
8cf7c46c8f Added audio.bag/audio.idx support used in RA2 2015-03-31 18:13:20 +02:00
David Jiménez
f15f1e41e8 Made int2 struct immutable 2015-03-20 13:54:01 +01:00
David Jiménez
54ae572303 - Introduced Unit Testing capabilities to the PathFinder trait and algorithm.
Introduced also a small Unit test project to prove it.

- Separated caching capabilities from PathFinder class to increase cohesion and maintainability.
Refactored the pathfinding algorithm by extracting methods based on responsibilities like
calculating costs and reordering functions. These changes should provide a in average a small increase in
pathfinding performance and maintainability.

- Optimized the pathfinder algorithm to reuse calculations like the
MovementCost and heuristics.

- Introduced base classes, IPathSearch and IPriorityQueue interfaces,
and restructured code to ease readability and testability

- Renamed the PathFinder related classes to more appropriate names. Made the
traits rely on the interface IPathfinder instead of concrete PathFinder
implementation.

- Massive performance improvements

- Solved error with harvesters' Heuristic

- Updated the heuristic to ease redability and adjustability. D can be
adjusted to offer best paths by decreasing and more performance by
increasing it

- Refactored the CellLayer<CellInfo> creation in its own Singleton class

- Extracted the graph abstraction onto an IGraph interface, making the
Pathfinder agnostic to the definition of world and terrain. This
abstraction can help in the future to be able to cache graphs for similar
classes and their costs, speeding up the pathfinder and being able to feed
the A* algorithm with different types of graphs like Hierarchical graphs
2015-03-03 20:11:11 +01:00
abcdefg30
8ca61aa917 Updated all year numbers 2015-01-09 21:18:05 +01:00
Matthias Mailänder
44cd174a8d StyleCop clean OpenRA.Game 2015-01-03 19:00:48 +01:00
Oliver Brakmann
30e42cdc62 Merge pull request #7247 from Hellhake/stylecop-game
Fix StyleCop warnings in OpenRA.Game
2015-01-02 12:58:04 +01:00