1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-02 22:11:10 +00:00
Commit Graph

8 Commits

Author SHA1 Message Date
danhale-git
54ff33c552
Benchmark d2math (#595)
* Vector and tests reviewed.

* Tests and benchmarks for d2math.math.

Also docs/comments.
2020-07-17 18:50:07 -04:00
danhale-git
dcb0c087b9
Vector benchmark (#594)
* Reflect and ReflectSurface benchmark.

* Rotate, NinetyAnti and NinetyClock benchmark.

* Equals, EqualsApprox, CompareApprox and IsZero benchmark.

* Benchmarks for everything else.

Also removing dead functions and commented out code and correcting typos.
2020-07-16 14:13:01 -04:00
danhale-git
921d44a70c
mapEntity.Step() benchmark and improvements. (#593)
* Initial test and benchmark for mapEntity.Step().

* Removed `&& !m.hasPath()` from mapEntity.atTarget

* Direction is now updated when the path node changes mid-step and target is updated when path is set.

* Test improvements.

* Deleted old benchmark function and tidying.

* d2math.Abs added.

* Abs benchmark and optimisation.

* Negate and Distance benchmark.

* Length and SetLength benchmark.

* Lerp and Dot benchmark.

* Cross and Normalize benchmark.

* Angle and SignedAngle benchmark.

* Trivial change to Vector.Abs()
2020-07-16 12:06:08 -04:00
danhale-git
894c60f77a
Map entity rework - vectors in mapEntity (#579)
* Fixed NaN on normalize 0 vector.

* Tentative implementation in getStepLength.

* mapEntity.TileX/Y removed.

* Fixed Position and Target not being initialised in createMapEntity.

* mapEntity.Position is no longer embedded.

* mapEntity.LocationX/Y no longer used outside map_entity.go.

* mapEntity.subCellX/Y removed.

* mapEntity.LocationX/Y removed.

* mapEntity.OffsetX/Y and TargetX/Y removed.

* Direction method added to Vector, returns 0-64 direction.

* Moved Vector.Direction() to Position.DirectionTo and refactored.

* Renamed RenderOffset from SubCell and tested IsZero.

* d2math.WrapInt added for use with directions.

* Tidied up position and tests.

* Refactored d2common.AdjustWithRemainder into d2mapEntity.

* Tidying up d2mapEntity.

* Final cleanup.

* Lint warnings.

* Spelling correction.
2020-07-13 09:06:50 -04:00
danhale-git
fa0814e0b1
Position supports current coordinate types. (#576) 2020-07-11 18:11:26 -04:00
danhale-git
029cb62972
Vector float64 (#565)
* Fixed nil pointer in Copy()

* Position added

Added Floor() and String() methods to Vector.

Also added Position which declares an embedded Vector2 and returns various forms of it.

* d2vector.Vector2 renamed to d2vector.BigFloat

* vector.go renamed to big_float.go

* Float64 stub and more renaming

* Vector value getters

* Separate vector types with initial methods.

* Divide and lint warnings.

* Distance and Length.

* Scale, Abs and Negate.

* CompareFloat64Fuzzy delta direction reversed.

* Refactor vector_test.go.

* Renamed Approx methods.

* Distance and Length.

* Distance and Length.

* Removed BigFloat and Vector, renamed Float64 to Vector, simplified tests.

* Angle, SignedAngle and other small functions.

* Receiver rename.

* SingedAngle and test fixed

* Rotate.

* SetLength.

* Cross.

* NinetyAnti and NinetyClock.

* Lerp and Clamp.

* Reflect and ReflectSurface.

* Cardinal convenience functions.

* Comments.

* Panic on NaN and Inf in Position.

* Lint warnings and comments.
2020-07-09 08:30:55 -04:00
danhale-git
07d90e9681
Position struct for managing world coordinates (#540)
* Fixed nil pointer in Copy()

* Position added

Added Floor() and String() methods to Vector.

Also added Position which declares an embedded Vector2 and returns various forms of it.

* Position tests improved
2020-07-04 19:25:53 -04:00
danhale-git
853ad7ae64
Cardinal vectors (#539)
* Comments and newlines in vector.go

* Added cardinal direction functions.

* Moved vector.go into d2vector.
2020-07-04 08:02:47 -04:00