Record Class VfxLayer

java.lang.Object
java.lang.Record
net.ixdarklord.coolcatcanvas.api.client.vfx.VfxLayer
Record Components:
order - where the layer is drawn: lower first
sorted - whether its painted-over shapes are drawn back to front across materials

public record VfxLayer(int order, boolean sorted) extends Record
Where in a frame's world effects a shape is drawn, given to VfxFrame.draw(VfxMaterial, VfxLayer). World effects write no depth of their own, so what's drawn later covers what's drawn earlier wherever they overlap, nearer or not. Layers say what that order is:
  • Layers are drawn from the lowest order() to the highest, so a higher layer always covers a lower one.
  • Within a layer, everything painted over the scene (VfxBlend.ALPHA, VfxBlend.LUMINOUS) is drawn first and everything added to it (VfxBlend.ADDITIVE) last; additive shapes look the same in any order.
  • In a plain layer, the painted-over shapes are drawn material by material, each material where it was first drawn in the frame and its shapes in the order they were drawn. That's cheap, and right when one material's shapes never need to cover another's.
  • In a sorted layer, the painted-over shapes of every material are drawn back to front, the farthest from the camera first: shapes of different textures cover each other as their distance says. It costs a sort of the layer's shapes each frame (by each one's middle), and a draw call wherever the material changes along the way.
Particles and the shapes of WorldVfx are drawn in DEFAULT.
VfxLayer HANDS = VfxLayer.sorted(10);   // the hands and arms of a creature, which reach in front of each other
frame.draw(HAND, HANDS).quad(...);
frame.draw(ARM, HANDS).quad(...);
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final VfxLayer
    Layer 0, not sorted: where shapes go without a layer.
  • Constructor Summary

    Constructors
    Constructor
    Description
    VfxLayer(int order, boolean sorted)
    Creates an instance of a VfxLayer record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    static VfxLayer
    of(int order)
    A plain layer: drawn material by material in first-use order.
    int
    Returns the value of the order record component.
    boolean
    Returns the value of the sorted record component.
    static VfxLayer
    sorted(int order)
    A sorted layer: its painted-over shapes, of every material, drawn from the farthest to the nearest.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT

      public static final VfxLayer DEFAULT
      Layer 0, not sorted: where shapes go without a layer.
  • Constructor Details

    • VfxLayer

      public VfxLayer(int order, boolean sorted)
      Creates an instance of a VfxLayer record class.
      Parameters:
      order - the value for the order record component
      sorted - the value for the sorted record component
  • Method Details

    • of

      public static VfxLayer of(int order)
      A plain layer: drawn material by material in first-use order.
    • sorted

      public static VfxLayer sorted(int order)
      A sorted layer: its painted-over shapes, of every material, drawn from the farthest to the nearest.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • order

      public int order()
      Returns the value of the order record component.
      Returns:
      the value of the order record component
    • sorted

      public boolean sorted()
      Returns the value of the sorted record component.
      Returns:
      the value of the sorted record component