Class VisibleSort

All Implemented Interfaces:
Serializable, Cloneable, Iterable<RenderState<?,?>>, Collection<RenderState<?,?>>, List<RenderState<?,?>>, RandomAccess, SequencedCollection<RenderState<?,?>>

public class VisibleSort extends SortMethod
The following sort method was generated by GitHub Copilot Chat (IntelliJ plugin) on 03-01-2026 with the following prompt:

This is SortMethod and there is PureListener and GTri following the JDoc in Sortmethod make a class which will effeicntly sort the triangles such that only visible triangles will be rendered. keep in mind it has to strictly adhere to Sortmethod JDoc and also dont use back face culling as i'll implement that myself.

VisibleSort is a SortMethod that keeps only triangles which are visible according to a software Z-buffer pass performed with ZDepthIdBuffer.

Behaviour requirements from SortMethod.javadoc: - When a triangle is added via add(Object) it sorts the list according to its algorithm. - clear() re-adds non-dirty triangles from the registered listeners. This implementation does NOT perform back-face culling (left for caller).
Author:
Lehlogonolo Poole
See Also:
  • Field Details

  • Constructor Details

    • VisibleSort

      public VisibleSort()
  • Method Details

    • add

      public boolean add(RenderState<?,?> gTri)
      Specified by:
      add in interface Collection<RenderState<?,?>>
      Specified by:
      add in interface List<RenderState<?,?>>
      Overrides:
      add in class SortMethod
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<RenderState<?,?>>
      Specified by:
      clear in interface List<RenderState<?,?>>
      Overrides:
      clear in class ArrayList<RenderState<?,?>>
    • sort

      public void sort()
      Specified by:
      sort in class SortMethod
    • updateVisibilityAndSort

      private void updateVisibilityAndSort()
      Performs a Z-buffer rasterisation of all registered triangles and keeps only those which appear on the final buffer (i.e. are visible). The remaining visible triangles are sorted by depth (farthest first) to be suitable for painter-style rendering if desired.