Walter-Correa/GroundAndreas
Ultra-fast memory-mapped heightmap engine for SA-MP and Open.MP.
Install with sampctl
sampctl package install Walter-Correa/GroundAndreas
Run this in your project folder. sampctl downloads the package and what it depends on.
Adds its include files, with the libraries it depends on, to the Pawn compiler in your browser, ready to include in a script.
Depends on 1 package
- sampctl/samp-stdlibnot in this directory
README.md
GroundAndreas
GroundAndreas is an ultra-fast, modern, memory-mapped heightmap engine, 2.5D world line-of-sight raycasting, and high-precision underground/water detection plugin and native component engineered specifically for San Andreas Multiplayer (SA-MP) and open.mp.
It delivers continuous bilinear interpolation over a 1 m grid with 1 cm vertical resolution, fast 2.5D world raycasting, surface normal vectors, dynamic object slope alignment, physical underground collision analysis (covering pedestrians and all 212 vehicle models), dual-layer ocean and inland water dynamics, dynamic building removal terrain reconstruction, and 3D object slope stamping-all with instantaneous boot times (< 1ms) and near-zero CPU overhead.
[!NOTE] This project serves as the modern, high-performance successor to legacy solutions like MapAndreas and heavy 3D physics engines like ColAndreas. Rebuilt from the ground up, it introduces operating system memory-mapped virtual address paging (
MapViewOfFile/mmap), continuous bilinear surface interpolation, and analytical topographic kinematics, covering many common ColAndreas raycasting use cases without its 350+ MB memory footprint or startup lag.
Comparison: MapAndreas vs. ColAndreas vs. GroundAndreas (Approximate estimates, not formally benchmarked)
| Feature / Metric | MapAndreas (Legacy) | ColAndreas (Bullet Physics) | GroundAndreas (Modern) |
|---|---|---|---|
| Physical RAM Usage | ~72 MB (Fixed static buffer) | 350 MB - 500+ MB | ~10 - 20 MB (Kernel demand paging) |
| Server Boot Latency | 1.0 - 3.0s (fread disk lag) | 3.0 - 8.0s (3D BVH tree load) | 0.001s (Instantaneous virtual map) |
| Z-Query Speed | ~2.0 ns (Raw buffer) | ~500 - 2,000 ns | O(1) Raw Memory (~2.0 ns) / AMX Native (~50 ns) |
| Terrain Precision | 1.0m discrete staircase steps | 3D mesh vertices | Continuous Bilinear Interpolation (1 m grid, 1 cm vertical resolution) |
| Line-of-Sight Raycast | ❌ No | Yes (Heavy 3D physics) | ✅ Yes (IsWorldBlockingLine, a few µs) |
| Surface Normal & Slope | ❌ No | Complex physics contact | ✅ Yes ($\vec{N}$ & slope in degrees) |
| Dynamic Object Alignment | ❌ No | Possible via raycasts | ✅ Yes (Pitch & Roll calculation) |
| Underground Detection | ❌ No | Possible via raycasts | ✅ Yes (Point, Player, Vehicle) |
| Vehicle Dimension Physics | ❌ No | Heavy mesh bounding | ✅ Yes (Built-in 212 SA Model Heights) |
| Comprehensive Water System | ❌ No (No water volumes) | Material configuration | ✅ Yes (Ocean + 44 Inland Bodies + Weather) |
| Dynamic Building Removal | ❌ No | Manual mesh removal | ✅ Yes (Automatic slope reconstruction) |
| 3D Object Surface Stamping | ❌ No | Manual mesh insertion | ✅ Yes (Euler rotated ramps/slabs) |
| Batch Array Processing | ❌ No | ❌ No | ✅ Yes (GetGroundZPosBatch) |
| open.mp Native Component | ❌ No | ❌ No | ✅ Yes (Direct components/ loading) |
[!NOTE] 2.5D Heightmap Architecture & Technical Notes
- Highest Solid Surface: The terrain is modeled as a 6000x6000 grid of 16-bit unsigned elevation values (0.01m resolution, range 0.0m to 655.35m). Each cell records the single highest solid collision surface.
- Bridges, Tunnels & Overhangs: Subterranean locations, multi-level highways, under-bridge spans, and covered interiors return the upper roof/deck elevation as ground Z.
- Interior Awareness: Detection natives (
IsPlayerUnderGround,IsVehicleUnderGround,IsPlayerOnGround,IsVehicleOnGround,GetPlayerGroundDistance,GetVehicleGroundDistance) includebool:ignore_interiors = trueby default. When an entity is located in an interior (> 0), heightmap checks are safely bypassed to prevent false subterranean flags. Note: Virtual worlds (VW) used outdoors in roleplay servers do not triggerignore_interiors.- Underwater Floor: Because heightmap values are unsigned
uint16, negative sea floor elevations (< 0.0m) are not representable. Water queries utilize the dedicated 3D water polygon database.
Documentation Hub
Comprehensive, modular technical guides and references are available in the docs/ directory:
| Guide | Description |
|---|---|
| 🚀 Getting Started | Step-by-step installation, memory-mapped virtual architecture, and drop-in migration from MapAndreas. |
| 📐 Elevation & World Raycasting | Continuous bilinear interpolation, batch arrays, 2.5D line-of-sight raycasting, and slope normal vectors. |
| 🌊 Underground & Water Detection | Subterranean collision detection (pedestrians & 212 vehicles) and dual-layer water dynamics. |
| 🏗️ Dynamic Terrain & Objects | Terrain reconstruction on building removal, automatic hook, object surface stamping, and disk baking. |
| 📊 Terrain Analytics & Kinematics | Safe spawn discovery, GPWS aircraft impact kinematics under gravity, radar shadow, and zone statistics. |
| 📖 Complete API Reference | Exhaustive technical dictionary covering all 40 natives, parameter types, defaults, and macros. |
Quick Start & Installation
1. File Placement
For open.mp (Component)
- Copy
components/GroundAndreas.dll(Windows) orcomponents/GroundAndreas.so(Linux) to your server'scomponents/directory (open.mp automatically detects and loads components placed in this directory). - Copy
scriptfiles/SAfull.hmapto your server'sscriptfiles/directory. - Copy
GroundAndreas.incto yourqawno/include/orpawno/include/directory.
For SA-MP 0.3.7 (Plugin)
- Copy
plugins/GroundAndreas.dll(Windows) orplugins/GroundAndreas.so(Linux) to your server'splugins/directory. - Copy
scriptfiles/SAfull.hmapto your server'sscriptfiles/directory. - Copy
GroundAndreas.incto yourpawno/include/directory. - Add
GroundAndreastoserver.cfg:# Windows plugins GroundAndreas # Linux plugins GroundAndreas.so
[!NOTE] On open.mp, use either the component (recommended, placed in
components/) or the legacy plugin (placed inplugins/), not both.
Via sampctl
sampctl package install Walter-Correa/GroundAndreas
Interactive Demonstration Filterscript (FS_GroundAndreas_Demo)
The release package includes a precompiled, plug-and-play demonstration filterscript (filterscripts/FS_GroundAndreas_Demo.amx):
- Comes precompiled with
a_sampand runs out-of-the-box on both SA-MP 0.3.7 and open.mp without requiring any extra plugins (such as Pawn.CMD). - To use it, add
FS_GroundAndreas_Demoto yourfilterscriptsline inserver.cfg(SA-MP) orpawn.legacy_filterscriptsinconfig.json(open.mp). - If you wish to recompile from source (
FS_GroundAndreas_Demo.pwn), it defaults to purea_samp. To compile natively against open.mp, defineGA_DEMO_USE_OPENMPbefore including.
2. Include in Your Script
#include <open.mp> // or <a_samp>
#include <GroundAndreas>
3. Basic Example
Query continuous ground elevation, verify line-of-sight clearance, and align an object flush to a slope in just a few lines:
#include <a_samp>
#include <GroundAndreas>
// Command to spawn a road barrier flush against any terrain slope
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/barrier", true))
{
new Float:x, Float:y, Float:z, Float:facing;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, facing);
// 1. Calculate ground height with continuous bilinear interpolation
new Float:groundZ;
GetGroundZPos(x, y, groundZ);
// 2. Compute exact Pitch (RX) and Roll (RY) to sit flush on the slope
new Float:rx, Float:ry;
GetGroundObjectRotation(x, y, facing, rx, ry);
// 3. Create object flush with the sloped road
CreateObject(1427, x, y, groundZ, rx, ry, facing);
SendClientMessage(playerid, 0x2ECC71FF, "Police barrier deployed flush with terrain slope!");
return 1;
}
return 0;
}
// Anti-cheat verification on weapon shots
// NOTE: Due to 2.5D heightmap architecture, shooters standing beneath bridges, awnings,
// or overpasses will start "beneath" the deck geometry. Log suspicious shots rather than
// blindly rejecting them to avoid false-positive rejections for legitimate players.
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if (hittype == BULLET_HIT_TYPE_PLAYER)
{
new Float:pX, Float:pY, Float:pZ, Float:tX, Float:tY, Float:tZ;
GetPlayerCameraPos(playerid, pX, pY, pZ);
GetPlayerPos(hitid, tX, tY, tZ);
new Float:hitX, Float:hitY, Float:hitZ;
// Verify if a mountain or building occludes the bullet line of sight (a few microseconds)
if (IsWorldBlockingLine(pX, pY, pZ, tX, tY, tZ + 0.5, hitX, hitY, hitZ))
{
printf("[Anti-Cheat] Suspicious shot by player %d: terrain obstruction detected at (%.1f, %.1f, %.1f)", playerid, hitX, hitY, hitZ);
// Log for administrative review (do not outright reject due to 2.5D bridges/overhangs)
}
}
return 1;
}
Key Technical Highlights
Kernel Memory-Mapped I/O (
MapViewOfFile/mmap)- The entire 72 MB heightmap (
SAfull.hmap) is mapped directly into virtual address space. - Booting takes under 1 millisecond without blocking the server main thread.
- Operating system demand paging loads only active sectors into RAM, maintaining a working set of ~10 to 20 MB.
- Copy-on-Write (COW) ensures runtime modifications never alter the clean on-disk file.
- The entire 72 MB heightmap (
Continuous Bilinear Interpolation
- Eliminates the jagged 1-meter staircases of legacy heightmaps.
- Computes continuous bilinear interpolation over a 1 m grid with 1 cm vertical resolution across hills, mountain passes, and ramps ($Z(u, v) = (1 - u)(1 - v) Z_{00} + u(1 - v) Z_{10} + (1 - u) v Z_{01} + u v Z_{11}$).
2.5D World Line-of-Sight Raycasting (
IsWorldBlockingLine)- Traces 3D rays across the world with ~2 cm binary search refinement running in a few microseconds for typical distances (≈ 0.5 m sampling, cost proportional to length).
- Covers many common ColAndreas use cases (anti-cheat sniper verification, line of sight, radar occlusion) without the heavy 350+ MB memory footprint.
Surface Normal Vector & Slope Calculation (
GetGroundNormal)- Computes normalized 3D surface vectors $\vec{N} = (n_x, n_y, n_z)$ and terrain angle in degrees ($0^\circ$ flat to $90^\circ$ cliff).
- Ideal for vehicle traction physics, fall damage multipliers, and anti-hillclimb sliding logic.
Dynamic Object Alignment & 3D Vector Spanning
- Automatically calculates Pitch ($RX$) and Roll ($RY$) angles from surface normals (
GetGroundObjectRotation) for road barriers, tents, and cones to sit flush on inclined terrain. - Spans arbitrary 3D vectors between any two ground coordinates (
GetGroundTwoPointRotation) with exact Euler pitch and yaw angles to align road barriers, bridge decks, and ramps. - Samples contoured multi-node elevations along line segments (
GetGroundLinePoints) for curbs, guard rails, and fences.
- Automatically calculates Pitch ($RX$) and Roll ($RY$) angles from surface normals (
Precision Underground Detection Engine
- Detects whether points, players, or vehicles are beneath terrain or inside underground spaces.
- Factors in pedestrian foot contact offsets ($Z_{\text{feet}} = Z - 1.0\text{m}$) and an internal database with a per-model wheel/base offset table (212 models).
- Returns float clearances directly:
GetPlayerGroundDistanceandGetVehicleGroundDistance. - Built-in interior awareness (
ignore_interiors = true) and automated vehicle interior ALS tracking (GA_SetVehInterior) preventing false subterranean alerts in interiors.
Advanced Water Dynamics Subsystem
- Strictly distinguishes surface contact (
InWater- swimming, wading, floating) from full submersion (UnderWater- diving, sunken vehicles). - Features dynamic ocean wave swell factoring in GTA SA weather IDs (0.15m calm, 0.50m rain/storm/fog/overcast (4, 7, 8, 12, 14–16), 0.80m weather 19 (sandstorm)).
- Built-in 3D volumes and floor levels for 44 inland water bodies (reservoirs, casino pools, fountains, lakes, interior pools) to avoid false positives in tunnels or basements beneath water.
- Strictly distinguishes surface contact (
Dynamic Terrain Modification & Object Surface Stamping
- Reconstructs natural ground elevation when GTA buildings are removed (
GroundAndreasRemoveBuilding) using rooftop plateau detection (BFS flood fill + Andrew's Monotone Chain convex hull) and surrounding street lower envelope regression (iterative least-squares plane fitting). - Small props (thin poles, street lights, benches, fences) and wildcard model ID -1 are safely ignored; carved area caching prevents duplicate LOD or component removals from degrading neighboring terrain.
- Transparently hooks
RemoveBuildingForPlayerinGroundAndreas.incwith deduplication caching. - Stamps dynamic mapped objects (
ApplyObjectToGroundAndreas) onto the heightmap with 3D Euler rotations ($RX, RY, RZ$) and inclined plane math (helipads, roads, ramps, bridges). - In-memory patch baking to disk (
SaveGroundAndreasPatches,LoadGroundAndreasPatches) for instantaneous startup loading.
- Reconstructs natural ground elevation when GTA buildings are removed (
Building from Source
Windows (Visual Studio 2022)
Run the automated build script:
build_msvc.bat
Output binaries and archives will be placed in dist/GroundAndreas-Windows.zip.
Linux (Ubuntu / Debian i686)
sudo apt-get update && sudo apt-get install -y gcc-multilib g++-multilib cmake zip
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32"
cmake --build build --config Release
Output binaries: build/GroundAndreas.so (plugin) and build/components/GroundAndreas.so (open.mp component).
Version history
Show the version history
1.1.0 - 09/11/2026
[!WARNING] Breaking Changes & Upgrading Notes from 1.0.0:
GetPlayerGroundDistance: Now measures elevation from the player's physical feet ($Z_{\text{feet}} = Z - 1.0\text{m}$) rather than the ped root center-of-mass, resulting in clearance values $\approx 1.0\text{m}$ lower.IsPlayerUnderWater: Submergence threshold lowered to ped root $+ 0.90\text{m}$ (physical head height) instead of $+ 1.45\text{m}$.- Macro rename:
GROUNDANDREAS_NO_REMOVE_BUILDINGwas renamed toGROUNDANDREAS_NO_REMOVE_BUILDfor pawncc $\le 31$ char symbol compliance.- Building removal:
GroundAndreasRemoveBuilding/RemoveBuildingForPlayerreplaces the legacy bounding-circle method with Rooftop Plateau Detection (BFS flood fill + Andrew's Monotone Chain convex hull) and surrounding street lower envelope regression (iterative least-squares plane fitting).fRadiusdoes not define excavation area; wildcardmodelid = -1and small street props are ignored.
colandreascollisionground-zgta-saheightmapmapandreasopen-mpopenmppawnraycastsa-mpsampsamp-pluginsan-andreasterrain
This page is built from what GitHub publishes about the repository. samp.directory does not host the code. Report a problem with this listing