MCPcopy Index your code
hub / github.com/PerroEngine/Perro

github.com/PerroEngine/Perro @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
12,710 symbols 44,982 edges 652 files 285 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Perro Engine

Perro Logo

Perro is an experimental, open-source game engine written in Rust. With a focus on performance and simplicity without sacrificing either.

Philosophy

  • Simple To Learn: start with scenes, nodes, and Rust scripts without large registration steps or boilerplate.
  • Flexible To Use: removes a lot of borrow checker issues by having direct apis and scoped closures for when we need mutable access, seperating state from the script behavior means we will never have a runtime borrow fail.
  • Fast In Release: nodes and scripts are laid out for efficient node and state access, all resources are statically baked in release for efficient and quick retrieval

Design Goals

  • Full Game-Making Scope: 2D, 3D, and UI all matter. Perro aims to support both 2D and 3D performantly, with high frame rates and a workflow that stays simple.
  • Simple Start: get first scene and script running quickly, with minimal setup and no script-registration boilerplate.
  • Compiler-Managed Workflow: let Perro sync scripts, generate glue code, and prepare supported assets so project setup stays small.
  • Split Model: scripts are just Rust files (lifecycle + methods); they store #[State] structs which each instance gets a copy of.
  • Safe Mutation: access through NodeID closures and engine-managed storage avoids borrow-contention edge cases in normal gameplay code (no "try_get_mut" fails).
  • Fast Access: flat ID lookups keep common node/script operations efficient, with room to cache IDs for hot paths.
  • Quick Iteration: project scripts build and reload in usually less than 1 second after initial compilation.

For more details, see the full documentation: perroengine.com/docs.

Local reference:

Dev Checks

  • cargo check --workspace --all-targets
  • cargo test --workspace
  • cargo clippy --workspace --all-targets -- -D warnings -F clippy::all

Major Features

  • Behavior Scripts + Per-Node State: a script is function entry points (lifecycle hooks + methods), not a mutable behavior object. When a node binds that script, runtime uses that node’s ctx.id to run behavior and resolve that node’s own #[State] via with_state!/with_state_mut!.
  • Object-Centric Scene Model: parent/child relationships, concrete node types, and traditional game-object structure stay front and center.
  • Compiler-Backed Asset Flow: dev stays flexible with plain files, while build/export bakes supported assets into fast static lookup paths and packs the rest.
  • Powerful UI System: UI is built as a real engine system with relative sizing, clamping, and layouts designed to scale from simple menus to larger game interfaces.
  • Flat ID-Based Runtime Access: node and script data are addressed by NodeID, enabling constant-time lookups for common operations and efficient cross-system interaction.
  • Predictable Failure Modes: most runtime misses come from real-world state changes (deleted node, missing tag/name match, unbound script), not from borrow contention between unrelated systems. (NoT "try_get_mut" runtime errors)
  • Powerful Query Layer: if you prefer query-style access, filter by type, base type, tag, name, and subtree to gather NodeIDs, then operate directly through script/node APIs. See Query System.

Contributions

Perro is, of course, open source, and contributions are always appreciated: issue reports, new features, system optimizations, and other improvements. Everyone is welcome to join the project.

Support Perro

Donations help fund full-time development, faster features, and better tooling. If you want to support the project:


License

Perro is licensed under the Apache 2.0 License. See LICENSE for details.


Extension points exported contracts — how you extend this code

ScriptLifecycle (Interface)
Optional lifecycle hooks implemented by scripts. Generated script glue sets [`ScriptFlags`] for non-empty lifecycle met [8 …
perro_source/script_stack/perro_scripting/src/script_trait.rs
DeriveVariant (Interface)
Typed conversion contract used by script state and method parameter conversion. Implement this trait for custom structs [64 …
perro_source/core/perro_variant/src/variant.rs
IntoNodeTag (Interface)
Converts a single tag into stored node tag data. [7 implementers]
perro_source/api_modules/perro_runtime_api/src/sub_apis/node.rs
ReadSeek (Interface)
Trait alias for Read + Seek [1 implementers]
perro_source/io_stack/perro_io/src/asset_io.rs
ScriptTypeDef (Interface)
(no doc) [2 implementers]
perro_editor/res/scripts/ui/editor_inspector_values.rs
GraphicsBackend (Interface)
(no doc) [1 implementers]
perro_source/render_stack/perro_graphics/src/backend.rs
ScriptBehavior (Interface)
Behavior object shared by all instances of one script definition. `ScriptBehavior` is intentionally separate from per-n [8 …
perro_source/script_stack/perro_scripting/src/script_trait.rs
VariantSchema (Interface)
Optional compile-time introspection metadata for Variant-derived types. By default types expose no fields (`&[]`). `#[d [20 …
perro_source/core/perro_variant/src/variant.rs

Core symbols most depended-on inside this repo

max
called by 1672
perro_source/core/perro_ui/src/layout.rs
len
called by 1165
perro_source/runtime_project/perro_runtime/src/cns/node_arena.rs
get
called by 1050
perro_source/runtime_project/perro_runtime/src/cns/node_arena.rs
as_ref
called by 1019
perro_source/runtime_project/perro_scene/src/scene.rs
iter
called by 987
perro_source/runtime_project/perro_runtime/src/cns/node_arena.rs
insert
called by 935
perro_source/runtime_project/perro_runtime/src/cns/node_arena.rs
clone
called by 904
perro_source/core/perro_nodes/src/nodes/node_2d/visual/sprite_2d.rs
expect
called by 826
perro_source/runtime_project/perro_scene/src/parser.rs

Shape

Function 6,667
Method 4,448
Class 1,171
Enum 348
Interface 76

Languages

Rust99%
TypeScript1%

Modules by API surface

perro_editor/res/scripts/ui/editor_ui.rs233 symbols
perro_editor/res/scripts/ui/editor_inspector_values.rs211 symbols
perro_source/api_modules/perro_steamworks/src/disabled.rs210 symbols
perro_source/core/perro_structs/src/structs/matrix/mod.rs207 symbols
perro_source/api_modules/perro_runtime_api/src/sub_apis/node.rs182 symbols
perro_source/api_modules/perro_runtime_api/tests/unit/lib_tests.rs140 symbols
perro_source/runtime_project/perro_runtime/src/runtime/render/ui/tests.rs135 symbols
perro_source/runtime_project/perro_scene/src/node_fields.rs120 symbols
perro_source/core/perro_variant/src/variant.rs119 symbols
perro_source/render_stack/perro_graphics/src/ui/painter.rs112 symbols
perro_source/devtools/perro_cli/src/doctor.rs109 symbols
perro_source/core/perro_csv/src/lib.rs108 symbols

For agents

$ claude mcp add Perro \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact