Debug Rastering - ZackWilde27/Z3dPy GitHub Wiki

DebugRaster() will visualize rays, lights, hitboxes, and dots for debugging.

Setup

Rays, Lights, and Dots have a render queue, just like things, and must be added to their lists before they will be drawn.

z3dpy.rays.append(myRay)

z3dpy.lights.append(myLight)

# Dots is just a list of locations to draw dots
myDot = [2, 5, 8]
z3dpy.dots.append(myDot)

Drawing

Debug triangles have an id of -1, so drawing them differently can be done in 2 ways:

for tri in z3dpy.DebugRaster():
    if z3dpy.TriGetId(tri) == -1:
        # Drawing debug things with a red outline
        z3dpy.PgDrawTriOutl(tri, [255, 0, 0], screen, pygame)
    else:
        # Everything else
        z3dpy.PgDrawTriFL(tri, screen, pygame)

Or if you already have a shader setup going, add a case for -1

for tri in z3dpy.DebugRaster():
   match z3dpy.TriGetId(tri):
       case -1:
           z3dpy.PgDrawTriOutl(tri, [255, 0, 0], screen, pygame)
       case 0:
           # Flat Lit
           z3dpy.PgDrawTriFL(tri, screen, pygame)
       case 1:
           # Simple Z Shading
           z3dpy.PgDrawTriF(tri, z3dpy.TriGetNormal(tri)[2], screen, pygame)
       #...

DebugRaster() has a few optional parameters, including a train to draw, wether or not to clear the rays list after drawing, etc.

# DebugRaster(*train, *sortingMethod, *bReverse, *clearRays)
for tri in z3dpy.DebugRaster(myTrain, z3dpy.triSortAverage, True, False)