Skip to content

feat: dedupe math files #1104

@dragoncoder047

Description

@dragoncoder047

Is your feature request related to a problem? Please describe.

  • the testShapeXXX collision functions all use instanceof which is slow, if we make the shape classes use a type tag enum and then use dispatch tables, it will be much faster.
  • all of the testLineXXX functions use the exact same algorithms as the raycasting code, since raycasting is basically testing for intersection with the ray
  • all of the testPointXXX functions are the same as containment so we could just move them to the method implementations of the contains() methods and then have testPointShape just call shape.contains(point.pt)
  • clipLineToCircle and clipLineToRect are once again basically just raycasting from both ends of the line, and using the resultant points
  • we could get rid of clipLineToCircle and clipLineToRect and make a generalized clipLineToShape helper that just does that (raycasts from both directions of the line and uses the hit points), that way we could clip lines to polygons and ellipses too

Any more information?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions