dkavolis / Ferram-Aerospace-Research

Aerodynamics model for Kerbal Space Program
Other
80 stars 32 forks source link

[VehicleAerodynamics] Dictionary<Part, PartTransformInfo> _partWorldToLocalMatrixDict> thown away #14

Closed GER-Space closed 5 years ago

GER-Space commented 5 years ago

The dictionary is cleared for each time its accesed, also converting a part to a key value for a dictionanry is very slow. part.persistentId would be faster to use. (its unique as long the part exists)

dkavolis commented 5 years ago

Thanks for this, I'll also check other dicts for similar behavior.

dkavolis commented 5 years ago

I don't think this is actually a problem for optimisation. The dictionary is only used for voxelization which:

  1. Is only done on part and vessel hierarchy changes
  2. Voxelization usually takes O(10^2) ms to complete so saving fraction of a millisecond is negligible
  3. The hash code is the object reference from RuntimeHelpers.GetHashCode(Object)