PCGEx (PCG Extended Toolkit)

repository·main·Indexed 20 days ago

https://github.com/pcgex/pcgextendedtoolkit

A low-level toolkit extending Unreal Engine's PCG framework with over 200 nodes. It provides structural capabilities for graph theory (Delaunay, Voronoi, MST), pathfinding (A*, Dijkstra), spatial queries, and advanced data manipulation. Built for high-performance extensibility, it features a Processor Pattern for multi-threaded parallelization and a Factory System for pluggable operations.

Tokens
1.1K
Snippets
1
Records
6
Agent score
21%

What's inside PCGEx

  1. What is PCGEx?

    main

    PCGEx (PCG Extended Toolkit) is a low-level, use-case agnostic toolkit designed to extend Unreal Engine's PCG framework. While vanilla PCG focuses on scattering and rule-based placement, PCGEx provides structural tools including:

    • Graph Theory: Building networks from points using Delaunay, Voronoi, MST, and convex hulls.
    • Data Manipulation: Spatial queries, sampling, blending, and polygon booleans.
    • Pathfinding: A* and Dijkstra routing through clusters with pluggable heuristics.
    • Asset Management: Curated collections with weighted distribution and property overrides.
    • Path Manipulation: Tools to smooth, simplify, subdivide, and offset paths/splines.
  2. PCGEx Core Architecture for C++ Developers

    main

    PCGEx is built for high-performance extensibility. It uses a Processor Pattern for per-input processing with automatic multi-threaded parallelization and a Factory System for pluggable operations (filters, blenders, samplers) via a Settings $\rightarrow$ Factory $\rightarrow$ Operation pipeline. All processing runs off the game thread using pre-allocated buffers and thread-safe data facades.

    Core Modules

    • PCGExCore: Data facades, threading primitives, macros, and containers.
    • PCGExGraphs: Graph/cluster structures and node/edge topology.
    • PCGExFilters: Composable filter system and manager orchestration.
    • PCGExBlending: Attribute blending with multiple modes.
    • PCGExCollections: Asset collection management and weighted picking.
    • PCGExFoundations: Polylines, tangents, and geometric primitives.
    • PCGExProperties: Unified property system.
    • PCGExMatching: Pattern matching framework.
    • PCGExHeuristics: Pathfinding heuristic calculations.
    • PCGExNoise3D: Procedural 3D noise.
    • PCGExElements: (Implied) Node implementations.
  3. Learn PCGEx using the Example Project

    main
    The most effective way to understand the toolkit is to use the provided Example Project. It contains hundreds of annotated graphs and complex examples that demonstrate how to implement PCGEx capabilities in real-world scenarios.
  4. Perform 2D Delaunay triangulation with delaunator-cpp

    main

    To perform Delaunay triangulation of 2D points, provide a std::vector<double> containing interleaved x and y coordinates (x0, y0, x1, y1, ...) to the delaunator::Delaunator constructor.

    After triangulation, you can access the results via:

    • d.coords: The original input coordinates.
    • d.triangles: A vector of indices into d.coords. Every three consecutive indices in this vector represent the vertices of a single triangle.
    #include <delaunator.hpp>
    #include <cstdio>
    #include <vector>
    
    int main() {
        /* x0, y0, x1, y1, ... */
        std::vector<double> coords = {-1, 1, 1, 1, 1, -1, -1, -1};
    
        // triangulation happens here
        delaunator::Delaunator d(coords);
    
        for(std::size_t i = 0; i < d.triangles.size(); i+=3) {
            printf(
                "Triangle points: [[%f, %f], [%f, %f], [%f, %f]]\n",
                d.coords[2 * d.triangles[i]],        //tx0
                d.coords[2 * d.triangles[i] + 1],    //ty0
                d.coords[2 * d.triangles[i + 1]],    //tx1
                d.coords[2 * d.triangles[i + 1] + 1],//ty1
                d.coords[2 * d.triangles[i + 2]],    //tx2
                d.coords[2 * d.triangles[i + 2] + 1] //ty2
            );
        }
    }