Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CARLA simulator Carla Deformation

From Leeroopedia
Knowledge Sources
Domains Road Network, Rendering
Last Updated 2026-02-15 05:00 GMT

Overview

The Deformation header provides inline functions for computing procedural terrain deformation and bump effects applied to road surfaces.

Description

The carla::geom::deformation namespace contains two inline functions:

  • GetZPosInDeformation(posx, posy) -- computes a smooth sinusoidal height displacement using two superimposed sine waves with different amplitudes (A1=0.6, A2=1.1), frequencies (Kx/Ky modifiers), and phase offsets (F1=1000, F2=-1500). This creates organic-looking terrain undulation across the road surface.
  • GetBumpDeformation(posx, posy) -- computes localized bump deformations with amplitude A3=0.10. It distributes bumps on a grid (17m x 12m spacing) and applies a sine-based falloff within a 2m radius of each bump origin. Positions outside the radius receive no bump offset.

Both functions are deterministic (no random state) and depend only on the (x, y) world position, making them suitable for consistent mesh generation.

Usage

Use these functions during road mesh generation to add procedural height variation to road surfaces, creating a more realistic terrain appearance.

Code Reference

Source Location

  • Repository: CARLA
  • File: LibCarla/source/carla/road/Deformation.h

Signature

namespace carla {
namespace geom {
namespace deformation {

  inline float GetZPosInDeformation(float posx, float posy);
  inline float GetBumpDeformation(float posx, float posy);

} // namespace deformation
} // namespace geom
} // namespace carla

Import

#include "carla/road/Deformation.h"

I/O Contract

Input Type Description
float | X world coordinate
float | Y world coordinate
Output Type Description
float | Vertical displacement to apply to the surface

Usage Examples

float z_deformation = carla::geom::deformation::GetZPosInDeformation(x, y);
float z_bump = carla::geom::deformation::GetBumpDeformation(x, y);
float total_z = base_z + z_deformation + z_bump;

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment