Debug render

This module provides functionality for rendering debug primitives. It includes data structures for representing debug primitives, as well as functions for drawing them.

To use this module, include the following line in your project file:

require engine.render.debug_render // or require engine.core

Type aliases

bitfield DebugDrawFlags
Fields:
  • ZTest (0x1) - Enable z-test, so debug lines will be occluded by opaque geometry

  • HideInGame (0x2) - Hide debug lines game view. They’re always visible in scene view

Functions

draw_line(begin: float3; end: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug line.

Arguments:
  • begin : float3 - the starting point of the debug line

  • end : float3 - the ending point of the debug line

  • color : float4 - the color of the debug line

  • frames : int - the number of frames to render the debug line

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_line(float3(0), float3(1, 0, 0), float4(1, 0, 0, 1)) // Draws a red line from (0, 0, 0) to (1, 0, 0)
draw_line(nodeId: NodeId; begin: float3; end: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug line.

Arguments:
  • nodeId : NodeId - the id of the node against which the debug line transformation matrix is calculated

  • begin : float3 - the starting point of the debug line

  • end : float3 - the ending point of the debug line

  • color : float4 - the color of the debug line

  • frames : int - the number of frames to render the debug line

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_line(nodeId, float3(0), float3(1, 0, 0), float4(1, 0, 0, 1)) // Draws a red line from (0, 0, 0) to (1, 0, 0) aligned with the transformation matrix of the node
draw_ray(ray: Ray; length: float = 1000f; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug ray.

Arguments:
  • ray : Ray - the ray to draw

  • length : float - the length of the debug ray

  • color : float4 - the color of the debug ray

  • frames : int - the number of frames to render the debug ray

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_ray(float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray from (0, 0, 0) in the direction of (1, 0, 0) with length 2
draw_ray(nodeId: NodeId; ray: Ray; length: float = 1000f; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug ray.

Arguments:
  • nodeId : NodeId - the id of the node against which the debug ray transformation matrix is calculated

  • ray : Ray - the ray to draw

  • length : float - the length of the debug ray

  • color : float4 - the color of the debug ray

  • frames : int - the number of frames to render the debug ray

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_ray(nodeId, float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray from (0, 0, 0) in the direction of (1, 0, 0) with length 2 aligned with the transformation matrix of the node
draw_ray(origin: float3; direction: float3; length: float = 1000f; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug ray.

Arguments:
  • origin : float3 - the origin of the debug ray

  • direction : float3 - the direction of the debug ray

  • length : float - the length of the debug ray

  • color : float4 - the color of the debug ray

  • frames : int - the number of frames to render the debug ray

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_ray(float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray from (0, 0, 0) in the direction of (1, 0, 0) with length 2
draw_ray(nodeId: NodeId; origin: float3; direction: float3; length: float = 1000f; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug ray.

Arguments:
  • nodeId : NodeId - the id of the node against which the debug ray transformation matrix is calculated

  • origin : float3 - the origin of the debug ray

  • direction : float3 - the direction of the debug ray

  • length : float - the length of the debug ray

  • color : float4 - the color of the debug ray

  • frames : int - the number of frames to render the debug ray

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_ray(nodeId, float3(0), float3(1, 0, 0), 2., float4(1, 0, 0, 1)) // Draws a red ray from (0, 0, 0) in the direction of (1, 0, 0) with length 2 aligned with the transformation matrix of the node
draw_sphere(center: float3; radius: float; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug sphere.

Arguments:
  • center : float3 - the center position of the debug sphere

  • radius : float - the radius of the debug sphere

  • color : float4 - the color of the debug sphere

  • frames : int - the number of frames to render the debug sphere

  • segments : int - the number of segments to render the debug sphere

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_sphere(float3(0), 1., float4(1, 0, 0, 1)) // Draws a red sphere at (0, 0, 0) with radius 1
draw_sphere(nodeId: NodeId; center: float3; radius: float; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug sphere.

Arguments:
  • nodeId : NodeId - the id of the node against which the debug sphere transformation matrix is calculated

  • center : float3 - the center position of the debug sphere

  • radius : float - the radius of the debug sphere

  • color : float4 - the color of the debug sphere

  • frames : int - the number of frames to render the debug sphere

  • segments : int - the number of segments to render the debug sphere

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_sphere(nodeId, float3(0), 1., float4(1, 0, 0, 1)) // Draws a red sphere at (0, 0, 0) with radius 1 aligned with the transformation matrix of the node
draw_sphere(sphere: BSphere3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug sphere.

Arguments:
  • sphere : BSphere3D - the bounding sphere to draw

  • color : float4 - the color of the debug sphere

  • frames : int - the number of frames to render the debug sphere

  • segments : int - the number of segments to render the debug sphere

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_sphere(BSphere3D(float3(0), 1.), float4(1, 0, 0, 1)) // Draws a red sphere at (0, 0, 0) with radius 1
draw_sphere(nodeId: NodeId; sphere: BSphere3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; segments: int = 16; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug sphere.

Arguments:
  • nodeId : NodeId - the id of the node against which the debug sphere transformation matrix is calculated

  • sphere : BSphere3D - the bounding sphere to draw

  • color : float4 - the color of the debug sphere

  • frames : int - the number of frames to render the debug sphere

  • segments : int - the number of segments to render the debug sphere

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_sphere(nodeId, BSphere3D(float3(0), 1.), float4(1, 0, 0, 1)) // Draws a red sphere at (0, 0, 0) with radius 1 aligned with the transformation matrix of the node
draw_box(min: float3; max: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug box.

Arguments:
  • min : float3 - the minimum point of the debug box

  • max : float3 - the maximum point of the debug box

  • color : float4 - the color of the debug box

  • frames : int - the number of frames to render the debug box

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_box(float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1)
draw_box(nodeId: NodeId; min: float3; max: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug box.

Arguments:
  • nodeId : NodeId - the id of the node against which the debug box transformation matrix is calculated

  • min : float3 - the minimum point of the debug box

  • max : float3 - the maximum point of the debug box

  • color : float4 - the color of the debug box

  • frames : int - the number of frames to render the debug box

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_box(nodeId, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1) aligned with the transformation matrix of the node
draw_box(box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug box.

Arguments:
  • box : BBox3D - the bounding box to draw

  • color : float4 - the color of the debug box

  • frames : int - the number of frames to render the debug box

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_box(BBox3D(float3(0), float3(1))) // Draws a red box from (0, 0, 0) to (1, 1, 1)
draw_box(nodeId: NodeId; box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug box.

Arguments:
  • nodeId : NodeId - the id of the node against which the debug box transformation matrix is calculated

  • box : BBox3D - the bounding box to draw

  • color : float4 - the color of the debug box

  • frames : int - the number of frames to render the debug box

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_box(nodeId, BBox3D(float3(0), float3(1))) // Draws a red box from (0, 0, 0) to (1, 1, 1) aligned with the transformation matrix of the node
draw_box(tm: float3x4; min: float3; max: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug box aligned with the given transformation matrix.

Arguments:
  • tm : float3x4 - the transformation matrix of the debug box

  • min : float3 - the minimum point of the debug box

  • max : float3 - the maximum point of the debug box

  • color : float4 - the color of the debug box

  • frames : int - the number of frames to render the debug box

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_box(nodeId.worldTransform, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node
draw_box(nodeId: NodeId; tm: float3x4; min: float3; max: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug box aligned with the given transformation matrix.

Arguments:
  • nodeId : NodeId - the id of the node against which the debug box transformation matrix is calculated

  • tm : float3x4 - the transformation matrix of the debug box

  • min : float3 - the minimum point of the debug box

  • max : float3 - the maximum point of the debug box

  • color : float4 - the color of the debug box

  • frames : int - the number of frames to render the debug box

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_box(node1, node2.worldTransform, float3(0), float3(1), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node2 and aligned with the transformation matrix of the node1 (the matrices are multiplied)
draw_box(tm: float3x4; box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug box aligned with the given transformation matrix.

Arguments:
  • tm : float3x4 - the transformation matrix of the debug box

  • box : BBox3D - the bounding box to draw

  • color : float4 - the color of the debug box

  • frames : int - the number of frames to render the debug box

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_box(nodeId.worldTransform, BBox3D(float3(0), float3(1)), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node
draw_box(nodeId: NodeId; tm: float3x4; box: BBox3D; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 1; flags: DebugDrawFlags = bitfield(0x0))

Draws a debug box aligned with the given transformation matrix.

Arguments:
  • nodeId : NodeId - the id of the node against which the debug box transformation matrix is calculated

  • tm : float3x4 - the transformation matrix of the debug box

  • box : BBox3D - the bounding box to draw

  • color : float4 - the color of the debug box

  • frames : int - the number of frames to render the debug box

  • flags : DebugDrawFlags - debug rendering flags, see DebugDrawFlags description

Usage example:

draw_box(node1, node2.worldTransform, BBox3D(float3(0), float3(1)), float4(1, 0, 0, 1)) // Draws a red box from (0, 0, 0) to (1, 1, 1) with the transformation matrix of the node2 and aligned with the transformation matrix of the node1 (the matrices are multiplied)
draw_text(text: string; position: float3; color: float4 = float4(1f, 1f, 1f, 1f); frames: int = 10; font_size: float = 16f)

Draws a debug text.

Arguments:
  • text : string - the text to draw

  • position : float3 - the position of the debug text

  • color : float4 - the color of the debug text

  • frames : int - the number of frames to render the debug text

  • font_size : float - the font size of the debug text

Usage example:

draw_text("Hello, World!", float3(0), float4(1, 0, 0, 1)) // Draws "Hello, World!" in red at (0, 0, 0)