RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Debug DrawingGPU Mesh StructsImGui FFIMath Structs (FFI)FFI C DefinitionsPID ControllersCSV LibraryDelay LineDequeDevelopment UtilitiesEvent ReferenceExtension SystemSignal FiltersGraph PathfindingUI BridgeInput Filter Constants2D Bilinear InterpolationIntrospectionJBeam Pretty PrinterJSON AST ParserSJSON ParserJSON Debug ParserJSON Pretty PrinterK-D Tree (2D Boxes)K-D Tree (3D)K-D Tree (3D)Lua SerializerC++/Lua BindingLua CoreLua ProfilerMath LibraryParticlesQuadtreeSettingsTCP ServerTimer SchedulerUtility Library

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API Referencecommon

Debug Drawing

Module defined in `lua/common/cdefDebugDraw.lua`. Defines FFI C definitions for debug drawing primitives (spheres, cylinders, lines, text, triangles) used by the engine's debug visualization system.

Module defined in lua/common/cdefDebugDraw.lua. Defines FFI C definitions for debug drawing primitives (spheres, cylinders, lines, text, triangles) used by the engine's debug visualization system.


Exports

This module has no Lua exports (no M table or return value). It registers C function definitions via ffi.cdef when FFI is available.

FFI C Functions

BNG_DBG_DRAW_Sphere(x, y, z, radius, packedCol, useZ)

Draws a debug sphere at the given position.

  • Parameters:
    • x - float - X position
    • y - float - Y position
    • z - float - Z position
    • radius - float - Sphere radius
    • packedCol - unsigned int - Packed RGBA color
    • useZ - bool - Whether to use Z-buffer

BNG_DBG_DRAW_Cylinder(x1, y1, z1, x2, y2, z2, radius, packedCol, useZ)

Draws a debug cylinder between two points.

BNG_DBG_DRAW_Line(x1, y1, z1, x2, y2, z2, packedCol, useZ)

Draws a debug line between two points.

BNG_DBG_DRAW_Text(x1, y1, z1, text, packedCol)

Draws debug text at a 3D position.

BNG_DBG_DRAW_TextAdvanced(x1, y1, z1, text, packedCol, useAdvancedText, twod, bgColorPacked, shadow, useZ)

Draws advanced debug text with background color and shadow options.

BNG_DBG_DRAW_SquarePrism(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, packedCol, useZ)

Draws a square prism shape.

BNG_DBG_DRAW_TriSolid(x1, y1, z1, x2, y2, z2, x3, y3, z3, packedCol, useZ)

Draws a solid triangle.

BNG_DBG_DRAW_LineInstance_MinArg(x1, y1, z1, x2, y2, z2, w, packedCol)

Draws a line instance with minimal arguments.

BNG_DBG_DRAW_LineInstance_MinArgBatch(data, lineCount, w1, packedCol)

Batch draws multiple line instances from a float array.

BNG_DBG_DRAW_TriSolidBatch(data, triCount, packedCol, useZ)

Batch draws multiple solid triangles from a float array.

FFI Types

Vector3

  • Type: FFI struct {float x, y, z}
  • Description: 3D vector used by debug draw functions

Internal Notes

  • Only registers definitions when ffi global is available
  • These are C++ engine functions exposed to Lua via LuaJIT FFI
  • Colors are packed as unsigned integers (use color() from utils to create them)

See Also

  • cdefGpuMesh Reference - Related reference
  • cdefImgui Reference - Related reference
  • cdefMath Reference - Related reference
  • Common Libraries Overview - Guide

Tech Vehicle Utilities

Module defined in `lua/vehicle/tech/techVehicleUtils.lua`. Provides low-level physical analysis of the vehicle structure.

GPU Mesh Structs

Module defined in `lua/common/cdefGpuMesh.lua`. Defines FFI C struct for GPU mesh primitive data. Most structs are commented out as reference only.

On this page

ExportsFFI C FunctionsBNG_DBG_DRAW_Sphere(x, y, z, radius, packedCol, useZ)BNG_DBG_DRAW_Cylinder(x1, y1, z1, x2, y2, z2, radius, packedCol, useZ)BNG_DBG_DRAW_Line(x1, y1, z1, x2, y2, z2, packedCol, useZ)BNG_DBG_DRAW_Text(x1, y1, z1, text, packedCol)BNG_DBG_DRAW_TextAdvanced(x1, y1, z1, text, packedCol, useAdvancedText, twod, bgColorPacked, shadow, useZ)BNG_DBG_DRAW_SquarePrism(x1, y1, z1, x2, y2, z2, x3, y3, x4, y4, packedCol, useZ)BNG_DBG_DRAW_TriSolid(x1, y1, z1, x2, y2, z2, x3, y3, z3, packedCol, useZ)BNG_DBG_DRAW_LineInstance_MinArg(x1, y1, z1, x2, y2, z2, w, packedCol)BNG_DBG_DRAW_LineInstance_MinArgBatch(data, lineCount, w1, packedCol)BNG_DBG_DRAW_TriSolidBatch(data, triCount, packedCol, useZ)FFI TypesVector3Internal NotesSee Also