RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
Auto AnnotationBoosterCalibrate ESCCompile ImpostersCompile MeshesConfig List GeneratorDecal Roads EditorDependency TreeDoc CreatorExport (glTF)Follow The White RabbitForest GeneratorGround Model DebugInput System UtilsInstanced Line Render DemoJBeam StatsLog StreamsMap TilesNode Beam ExportNode StreamPhotomodePrecompile ShadersPrecompile VehiclesProcedural Track (Gymkhana Generator)Rectangle GeneratorRender Components APIResave MaterialsRich PresenceSave Dynamic DataScreenshot Creator (Vehicle Thumbnails)ShowroomSort LinesStep HandlerTerrain GeneratorTest Extension ProxiesTest JSON Files Syntaxutil/vehicleRopeDebug - Rope Physics Debug UIutil/worker - Batch Job Workerutil/wsTest - WebSocket Test Server

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 ReferenceGE Extensionsutil

Rectangle Generator

Generates a planar graph of nodes by recursively subdividing rectangles, used by `procTrack` for gymkhana track generation.

Generates a planar graph of nodes by recursively subdividing rectangles, used by procTrack for gymkhana track generation.


Overview

util_rectangleGen is a helper module (not an extension - it uses require) that takes a set of starting rectangles and parameters, recursively subdivides them, and returns a graph with nodes at rectangle centers and neighbor adjacency information.

Module path: lua/ge/extensions/util/rectangleGen.lua


Exports (M)

FunctionSignatureDescription
getGraph(params) → graph|nilSubdivides starting rectangles and returns a node graph with neighbors.
dist(a,b,x,y) → number2D Euclidean distance helper.

Internals

Graph Structure

graph = {
  nodes = {
    { x, y, neighbours = {{index, dist},...}, name, closestNeighbourDist, force },
    ...
  },
  start = node_or_nil,  -- node with start flag
  finish = node_or_nil  -- node with finish flag
}

Subdivision Algorithm

  1. Copies startingRects (excluding noSplit rects) into a working list.
  2. Iteratively picks the largest rectangle and splits it vertically or horizontally:
    • Direction chosen by params.rectModeParams.vertSplitFunction(width, height).
    • Split position chosen by params.rectModeParams.cutValueFunction(), clamped to respect minXDist/minYDist.
  3. Stops when rectangle count reaches params.rectModeParams.numNodes or no more splits possible.
  4. noSplit rectangles are appended afterwards (fixed nodes with optional start/finish flags).

Neighbor Detection

Two rectangles are neighbors if they share an edge (within floating-point tolerance 0.001):

  • Left/right adjacency: matching X boundary and overlapping Y range.
  • Top/bottom adjacency: matching Y boundary and overlapping X range.

Node Placement

Each rectangle's center becomes a node. The closestNeighbourDist field records the minimum distance to any neighbor, used by procTrack for radius calculations.


How It Works

  1. procTrack.checkParams() calls require('util/rectangleGen').
  2. makeBaseNodePositions() calls getGraph(params).
  3. The returned graph feeds into the Hamiltonian path solver.

Lua Examples

-- Used internally by procTrack, not typically called directly
local rectGen = require('util/rectangleGen')
local graph = rectGen.getGraph(params)
-- graph.nodes contains positioned nodes with neighbor info

Additional Exports

  • M.dist - (undocumented)
  • M.getGraph - (undocumented)

Procedural Track (Gymkhana Generator)

Generates randomized gymkhana / autocross tracks from seed-based procedural parameters.

Render Components API

Reads renderer component JSON files and provides an API to get/set rendering settings (shaders, post-effects, etc.).

On this page

OverviewExports (M)InternalsGraph StructureSubdivision AlgorithmNeighbor DetectionNode PlacementHow It WorksLua ExamplesAdditional Exports