Excalibur icon indicating copy to clipboard operation
Excalibur copied to clipboard

Consistency: Adding optional destination/output arguments to all applicable Vector functions

Open Autsider666 opened this issue 6 months ago • 8 comments

Context

I ran into a great presentation about increasing Vector math performance that advises to add output arguments to functions to prevent the creation of unneeded objects.

Proposal

EX.Vector already has some functions (scale, add, sub, rotate and clone) that have an optional dest argument, so I'm suggesting to consistently add an optional destargument to the following functions:

  • min
  • max
  • normalize
  • cross
  • perpendicular

Optional

  • Add an extra argument for the fallback anchor used in rotate
  • Use destination or output instead of the abbreviated dest currently used.
  • Update the documentation to inform developers of the potential performance gains from using this argument when using Vector. (Even more optional: Add code examples to show the differences)

Autsider666 avatar Apr 29 '25 08:04 Autsider666