Package limn.render3d
Class DebugDraw
java.lang.Object
limn.render3d.DebugDraw
Immediate-mode debug geometry: world-space lines (AABBs, oriented boxes,
axes, grids, rays) batched on the CPU and flushed into a
RenderPass
once per frame. Purely a vertex buffer builder: no GL, so it works headless
and in tests; the backend draws the batch after the scene's meshes.
Two buckets: depth-tested lines are occluded by scene geometry like any
mesh; overlay ("X-ray") lines draw on top regardless of depth. Select with
depthTest(boolean); primitives go to the current bucket.
GC discipline: vertices accumulate into reused, doubling float[]s;
steady-state emission allocates nothing. The core primitives take floats;
Vec3/Vec4 conveniences exist for call sites where clarity
beats the last allocation. Typical per-frame use inside a
Viewport3D.Renderer:
debug.grid(10, 20, gray);
debug.axes(nodeWorld, 0.5f);
debug.depthTest(false).aabb(worldBounds, red);
debug.flush(pass); // submits both buckets and resets for the next frame
Lines are 1 px (core profile clamps glLineWidth; the viewport's
MSAA target antialiases them). Colors are STRAIGHT (non-premultiplied) and are
alpha-blended over whatever the pass has already drawn, so a faded guide really
does read as faded.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFloats per vertex: x, y, z, r, g, b, a. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe 12 edges of an axis-aligned box.The basis of an affinetransformdrawn from its origin: X red, Y green, Z blue, eachsizelong (in the transform's own scale).voidclear()Drops all emitted vertices (buckets stay allocated for reuse).depthTest(boolean on) Selects the bucket for subsequent primitives (default: depth-tested).voidflush(RenderPass pass) Submits both buckets to the pass and resets for the next frame.A square grid on the XZ plane at y=0, centered at the origin:divisions×divisionscells spanning ±halfExtent.line(float x0, float y0, float z0, float x1, float y1, float z1, float r, float g, float b, float a) A world-space line segment, the primitive everything else builds on.Queues a world-space line for this frame; cleared after it is drawn.The 12 edges ofboxtransformed by an affinetransform, an oriented box (a mesh's local bounds under its world matrix), unlikeaabb(box.transformedBy(m), …)which draws the axis-aligned hull the culler uses.A ray drawnlengthlong from its origin.intvertexCount(boolean depthTestedBucket)
-
Field Details
-
FLOATS_PER_VERTEX
public static final int FLOATS_PER_VERTEXFloats per vertex: x, y, z, r, g, b, a.- See Also:
-
-
Constructor Details
-
DebugDraw
public DebugDraw()
-
-
Method Details
-
depthTest
Selects the bucket for subsequent primitives (default: depth-tested). -
line
public DebugDraw line(float x0, float y0, float z0, float x1, float y1, float z1, float r, float g, float b, float a) A world-space line segment, the primitive everything else builds on. -
line
Queues a world-space line for this frame; cleared after it is drawn. -
aabb
The 12 edges of an axis-aligned box. Empty boxes draw nothing. -
obb
The 12 edges ofboxtransformed by an affinetransform, an oriented box (a mesh's local bounds under its world matrix), unlikeaabb(box.transformedBy(m), …)which draws the axis-aligned hull the culler uses. Empty boxes draw nothing. -
axes
The basis of an affinetransformdrawn from its origin: X red, Y green, Z blue, eachsizelong (in the transform's own scale). -
grid
A square grid on the XZ plane at y=0, centered at the origin:divisions×divisionscells spanning ±halfExtent. -
ray
A ray drawnlengthlong from its origin. -
flush
Submits both buckets to the pass and resets for the next frame. The arrays are handed to the backend by reference and consumed before this pass's render call returns; call once, at the end of frame emission. -
clear
public void clear()Drops all emitted vertices (buckets stay allocated for reuse). -
vertexCount
public int vertexCount(boolean depthTestedBucket) - Returns:
- vertices currently held in the given bucket (for tests/HUDs)
-