# infinideastudio/neworld architecture

> Architecture diagram of the GitHub repository infinideastudio/neworld, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/infinideastudio/neworld
- Repository: https://github.com/infinideastudio/neworld

## Overview

##### Project Type and Purpose
- NEWorld is a 3D sandbox game inspired by Minecraft. Its purpose is to provide a highly optimized, cross-platform game built with a custom C++ engine.
- The README and file structure indicate the game incorporates several components: rendering (using OpenGL), audio, a custom GUI (integrating Noesis GUI), physics/collision (likely handled via BVH structures), and world/universe simulation.

##### File Structure
- Assets Folder: This directory holds all visual and audio resources – textures, shaders, fonts, and GUIs. It’s key to distinguish that there is a clear separation between GUI assets (e.g., InGame.xaml, MainMenu.xaml and related theme files) and game assets (textures for blocks, items, players).
- NEWorld.Base: Contains core common libraries, including console logging, math (e.g., Vector2, Vector3, Vector4), and system modules such as file management and the message bus. This is your foundational layer.
- NEWorld.Game: Houses most of the game’s logic including the Audio system, GUI management, rendering (both OpenGL specific code and world/renderer modules), and game settings. This directory is the heart of the application.
- NEWorld.Game/Universe: Focuses on the simulation aspect – entity management, world data (chunk management, terrain generation using noise algorithms), and BVHs (bounding volume hierarchies) for spatial queries.
- External Libraries: The External directory contains libraries like bvh, stb, and tsl, which provide essential utilities (such as spatial hierarchy building, advanced hashing, and texture packing support), indicating that many performance-critical parts have been re-invented or custom built.
- NoesisGUI: This integration directory shows that Noesis GUI is used for the user interface. It includes CMake support and helper scripts.
- CMakeLists.txt and related configuration files help in building the game across platforms.

##### Guiding Architecture
a. Main Components:
- Rendering Subsystem: Include detailed nodes for Shader Management (shader files in Assets/Shaders), Renderer core (NEWorld.Game/Renderer) with subdivisions for GL-specific operations and World rendering (ChunkRenderer, ShadowMaps, etc.).
- Audio System: Represent the Audio module (NEWorld.Game/Audio and AudioSystem files) responsible for sound processing.
- Game Logic and Universe: This component covers simulation aspects like Entities, World (universe and chunk management), Terrain Generation, and the dispatch mechanism for game events.
- GUI Layer: Separate the GUI into two parts – one from the NEWorld.Game/GUI directory for in-game menus and inventory, and another for the Noesis GUI integration (linked to the NoesisGUI directory and XAML files under Assets/GUI).
- Core Base: Represent NEWorld.Base as the core utilities that underpin logging, math, file system, and the messaging bus which supports inter-component communication.
- External Libraries: Illustrate external dependencies (BVH algorithms, stb, and tsl) that assist in optimized performance.
- Assets Repository: Illustrate the Asset management’s role (textures, fonts, shaders) and its directional connection to both the renderer and GUI components.

b. Relationships and Interactions:
- From Assets → Renderer: Assets like shaders and textures feed into the rendering pipeline.
- From Core Base (e.g., MessageBus) → Game Logic and Universe: The messaging system propagates game events and commands.
- Between GUI components and Game Logic: User input via GUI overlays influences game state.
- External libraries impact multiple layers: For instance, BVH support improves simulation performance in the Universe subsystem.
- Dependency between the custom engine layers (NEWorld.Base, NEWorld.Game, and Universe) and the third-party systems like Noesis GUI and OpenGL.

c. Important Architectural Patterns:
- Modularity: The division into Base, Game, and Universe suggests a layered architecture where low-level utilities are separated from high-level game logic.
- Separation of Concerns: Distinct folders for renderer, audio, GUI, and world simulation imply a clean separation between presentation, engine, and simulation layers.
- Performance Optimizations: The sophisticated use of BVH (in External/bvh) and custom algorithms indicates a performance-centric design.

d. Technologies and Frameworks:
- C++20 is used throughout, with modern language features.
- OpenGL 4.5 along with glew and glfw for graphics.
- OpenAL (via openal-soft) for audio.
- LevelDB (mentioned in README) might be used for some persistent data management.
- Noesis GUI for the user interface.
- External libraries for BVH, texture packing, and high performance data structures.

## Diagram (Mermaid)

```mermaid
flowchart TD
    NP["NEWorld Project"]:::project
    Base["Core Utilities (NEWorld.Base)"]:::base
    Universe["Game Logic & Universe Simulation (NEWorld.Game/Universe)"]:::universe
    Renderer["Rendering Subsystem (NEWorld.Game/Renderer)"]:::renderer
    Audio["Audio System (NEWorld.Game/Audio)"]:::audio
    GUI["GUI Layer (NEWorld.Game/GUI)"]:::gui
    Noesis["Noesis GUI Integration (NoesisGUI)"]:::noesis
    Assets["Assets Repository (Assets)"]:::assets
    External["External Libraries (External)"]:::external

    %% Main vertical flow
    NP -->|"starts"| Base
    Base -->|"drives via MessageBus"| Universe
    Universe -->|"provides scene data"| Renderer
    Renderer -->|"renders visuals"| Audio
    Audio -->|"updates state"| GUI
    GUI -->|"integrates"| Noesis

    %% Branch connections
    Assets ---|"supplies assets (textures, shaders, fonts, GUI themes)"| Renderer
    Assets ---|"supplies GUI assets"| GUI

    External ---|"provides performance libraries (BVH, stb, tsl)"| Universe

    %% Click Events
    click NP "https://github.com/infinideastudio/neworld/tree/0.5.0/NEWorld_Project"
    click Base "https://github.com/infinideastudio/neworld/blob/0.5.0/NEWorld.Base"
    click Universe "https://github.com/infinideastudio/neworld/tree/0.5.0/NEWorld.Game/Universe"
    click Renderer "https://github.com/infinideastudio/neworld/tree/0.5.0/NEWorld.Game/Renderer"
    click Audio "https://github.com/infinideastudio/neworld/tree/0.5.0/NEWorld.Game/Audio"
    click GUI "https://github.com/infinideastudio/neworld/tree/0.5.0/NEWorld.Game/GUI"
    click Noesis "https://github.com/infinideastudio/neworld/tree/0.5.0/NoesisGUI"
    click Assets "https://github.com/infinideastudio/neworld/tree/0.5.0/Assets"
    click External "https://github.com/infinideastudio/neworld/tree/0.5.0/External"

    %% Styles
    classDef project fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef base fill:#66ccff,stroke:#333,stroke-width:2px;
    classDef universe fill:#cc99ff,stroke:#333,stroke-width:2px;
    classDef renderer fill:#99ff99,stroke:#333,stroke-width:2px;
    classDef audio fill:#ff9999,stroke:#333,stroke-width:2px;
    classDef gui fill:#99ccff,stroke:#333,stroke-width:2px;
    classDef noesis fill:#ffcc99,stroke:#333,stroke-width:2px;
    classDef assets fill:#d3a4ff,stroke:#333,stroke-width:2px;
    classDef external fill:#ffa500,stroke:#333,stroke-width:2px;
```
