DPSF by Daniel Schroeder

<PackageReference Include="DPSF" Version="2.5.0" />

.NET API 168,448 bytes

 DPSFDefaultSprite3DBillboardParticleSystem<Particle, Vertex>

public abstract class DPSFDefaultSprite3DBillboardParticleSystem<Particle, Vertex> : DPSFDefaultSpriteParticleSystem<Particle, Vertex> where Particle : DPSFParticle where Vertex : struct, IDPSFParticleVertex
The Default Sprite 3D Billboard Particle System class. This class just inherits from the Default Sprite Particle System class and overrides the DrawSprite() function to draw the sprites as Billboards in 3D space.
public Vector3 CameraPosition { get; set; }

Get / Set the Position of the Camera.

NOTE: 3D Billboard Sprite particles always face the camera by using the View Matrix, so this only needs to be Set (updated) every frame if you plan on sorting these particles relative to one another by their distance from the camera, in order to give proper depth perception of the particles.


protected void UpdateParticleDistanceFromCameraSquared(DefaultSprite3DBillboardParticle cParticle, float fElapsedTimeInSeconds)

Updates the Particle's DistanceFromCameraSquared property to reflect how far this Particle is from the Camera.

protected void UpdateParticleSystemToSortParticlesByDistanceFromCamera(float fElapsedTimeInSeconds)

Sorts the particles to draw particles furthest from the camera first, in order to achieve proper depth perspective.

NOTE: This operation is very expensive and should only be used when you are drawing particles with both opaque and semi-transparent portions, and not using additive blending.

Merge Sort is the sorting algorithm used, as it tends to be best for linked lists. TODO - WHILE MERGE SORT SHOULD BE USED, DUE TO TIME CONSTRAINTS A (PROBABLY) SLOWER METHOD (QUICK-SORT) IS BEING USED INSTEAD. THIS FUNCTION NEEDS TO BE UPDATED TO USE MERGE SORT STILL. THE LINKED LIST MERGE SORT ALGORITHM CAN BE FOUND AT http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html