melonJS icon indicating copy to clipboard operation
melonJS copied to clipboard

Inconsistent position vector type between me.Renderable and base shape objects

Open obiot opened this issue 9 years ago • 2 comments

Object pos type :

  • me.Ellipse : me.Vector2d
  • me.Polygon : me.Vector2d
  • me.Line : me.Vector2d
  • me.Rect : me.Vector2d
  • me.Renderable : me.ObscervableVector3d

Inheritance Chain :

  • me.Ellipse
  • me.Line <- me.Polygon
  • me.Renderable <- me.Rect <- me.Polygon

When attempting to clean the me.Renderable implementation, and removing the unnecessary bounds objets, this caused a lots of problems, because of the type mismatch.

Also, it might not be fully used (e.g. in the collision detection), and there will be still a mismatch as Renderables use a me.ObscervableVector3d object type, but all shapes should at least uses a me.Vector3d type for the position object.

Anyway clean way maybe to mutate a me.Vector3d object to a me.ObscervableVector3d one (using Object.assign?)

obiot avatar Sep 21 '16 03:09 obiot

see also #709 , this should then be extended to all shapes constructor. (can come as a second step though)

obiot avatar Sep 21 '16 03:09 obiot

another solution to this, that we discussed in the past as well, would be to reimplement me.Rect as a pure "box" object, that would then only be used for bounding box, and would be the base class for renderable (since ultimately, we also want to replace the child bounds, and use the renderable bounds as bounding box).

which would then give the following : Object pos type :

me.Ellipse : me.Vector2d me.Polygon :me.Vector2d me.Line : me.Vector2d me.Rect : me.ObscervableVector3d me.Renderable : me.ObscervableVector3d Inheritance Chain :

me.Ellipse me.Line <- me.Polygon me.Renderable <- me.Rect

obiot avatar Sep 27 '16 11:09 obiot