samp.directory
← Skrypty i biblioteki

Walter-Correa/GroundAndreas

Ultra-fast memory-mapped heightmap engine for SA-MP and Open.MP.

Plugin★ 3zaktualizowano 9 dni temuOtherC++sampctl
Otwórz na GitHubie

Zainstaluj za pomocą sampctl

sampctl package install Walter-Correa/GroundAndreas

Uruchom to w folderze swojego projektu. sampctl pobiera pakiet i to, od czego zależy.

Wypróbuj w kompilatorze Pawn →

Dodaje jej pliki include, razem z bibliotekami, od których zależy, do kompilatora Pawn w twojej przeglądarce, gotowe do dołączenia w skrypcie.

Zależy od 1 pakietu

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 / MetricMapAndreas (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 Latency1.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 nsO(1) Raw Memory (~2.0 ns) / AMX Native (~50 ns)
Terrain Precision1.0m discrete staircase steps3D mesh verticesContinuous Bilinear Interpolation (1 m grid, 1 cm vertical resolution)
Line-of-Sight Raycast❌ NoYes (Heavy 3D physics)✅ Yes (IsWorldBlockingLine, a few µs)
Surface Normal & Slope❌ NoComplex physics contact✅ Yes ($\vec{N}$ & slope in degrees)
Dynamic Object Alignment❌ NoPossible via raycasts✅ Yes (Pitch & Roll calculation)
Underground Detection❌ NoPossible via raycasts✅ Yes (Point, Player, Vehicle)
Vehicle Dimension Physics❌ NoHeavy 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❌ NoManual mesh removal✅ Yes (Automatic slope reconstruction)
3D Object Surface Stamping❌ NoManual 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) include bool:ignore_interiors = true by 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 trigger ignore_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:

GuideDescription
🚀 Getting StartedStep-by-step installation, memory-mapped virtual architecture, and drop-in migration from MapAndreas.
📐 Elevation & World RaycastingContinuous bilinear interpolation, batch arrays, 2.5D line-of-sight raycasting, and slope normal vectors.
🌊 Underground & Water DetectionSubterranean collision detection (pedestrians & 212 vehicles) and dual-layer water dynamics.
🏗️ Dynamic Terrain & ObjectsTerrain reconstruction on building removal, automatic hook, object surface stamping, and disk baking.
📊 Terrain Analytics & KinematicsSafe spawn discovery, GPWS aircraft impact kinematics under gravity, radar shadow, and zone statistics.
📖 Complete API ReferenceExhaustive technical dictionary covering all 40 natives, parameter types, defaults, and macros.

Quick Start & Installation

1. File Placement

For open.mp (Component)
  1. Copy components/GroundAndreas.dll (Windows) or components/GroundAndreas.so (Linux) to your server's components/ directory (open.mp automatically detects and loads components placed in this directory).
  2. Copy scriptfiles/SAfull.hmap to your server's scriptfiles/ directory.
  3. Copy GroundAndreas.inc to your qawno/include/ or pawno/include/ directory.
For SA-MP 0.3.7 (Plugin)
  1. Copy plugins/GroundAndreas.dll (Windows) or plugins/GroundAndreas.so (Linux) to your server's plugins/ directory.
  2. Copy scriptfiles/SAfull.hmap to your server's scriptfiles/ directory.
  3. Copy GroundAndreas.inc to your pawno/include/ directory.
  4. Add GroundAndreas to server.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 in plugins/), 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_samp and 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_Demo to your filterscripts line in server.cfg (SA-MP) or pawn.legacy_filterscripts in config.json (open.mp).
  • If you wish to recompile from source (FS_GroundAndreas_Demo.pwn), it defaults to pure a_samp. To compile natively against open.mp, define GA_DEMO_USE_OPENMP before 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

  1. 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.
  2. 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}$).
  3. 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.
  4. 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.
  5. 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.
  6. 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: GetPlayerGroundDistance and GetVehicleGroundDistance.
    • Built-in interior awareness (ignore_interiors = true) and automated vehicle interior ALS tracking (GA_SetVehInterior) preventing false subterranean alerts in interiors.
  7. 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.
  8. 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 RemoveBuildingForPlayer in GroundAndreas.inc with 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.

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_BUILDING was renamed to GROUNDANDREAS_NO_REMOVE_BUILD for pawncc $\le 31$ char symbol compliance.
  • Building removal: GroundAndreasRemoveBuilding / RemoveBuildingForPlayer replaces 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). fRadius does not define excavation area; wildcard modelid = -1 and small street props are ignored.

Przeczytaj resztę na GitHubie

colandreascollisionground-zgta-saheightmapmapandreasopen-mpopenmppawnraycastsa-mpsampsamp-pluginsan-andreasterrain

Ta strona jest zbudowana z tego, co GitHub publikuje o repozytorium. samp.directory nie hostuje kodu. Zgłoś problem z tym wpisem

Walter-Correa/GroundAndreas: Plugin SA-MP | samp.directory