Git Product home page Git Product logo

godot-nim's Introduction

Godot-Nim v4.1

It enable us to work godot-4.x with Nim.

Based on godot-cpp 4.1 stable

How to use

  • See test/ to get an overview of the binding interface.
  • There is a nim implementation of Dodge the Creeps! at demo/.

Known Issues

Caused in this library

  • Initial loading of the extension fails

    Initialization of the extension fails the first time. Reloading solves the problem.

Caused in Engine

  • AudioStreamPlayer causes a leak in the resources used by this node. We have seen this happen in the demo project.

Features

This project is in the early stages of development and some features are not yet operational.

🟢Available

Godot (Editor/GDScript) Side

See GodotSideTester and tester.gd

  • Add defined Extension-Class Node into scene
  • Instantiate Extension-Class
  • Call Extension-Class method
  • Use Extension-Class property
  • Receive/Emit Extension-Class signal

Nim (GDExtension) Side

See NimSideTester

  • Define Extension-Class
  • Define Simple Extension-Class method
  • Define Extension-Class property
  • Define/Emit Extension-Class signal
  • Instantiate Engine-Class
  • Call Engine-Class method (E.g. Node.get_node)
  • Override virtual hooks of Engine-Class (E.g. _ready, _process)
  • Call Variants' method

🟡Never tested yet

  • Async Dispatch

⚫In progress

  • Upgrade to v4.2
  • Define utility functions (E.g. print)
  • Register user-defined methods
    • Register and call simple method
      • access to self instance
      • access to other arguments
      • return value
    • Support varargs
    • Support static
    • Support virtual
    • Support default-value
  • Auto-react to typical notifications
  • Define constants
    • Define Variant constants
    • Define Class constants

🟣Planned

  • Using Parallelism
  • Library hot reloading
  • GDScript integration
    • Static conversion from GDScript to Nim (c2nim-like converter)
    • GDScript Embedding

🔴Still can't

  • C++ backend
    • Module development

...And so on.

Note

Bridge between Nim's ref and Godot's Refcounted

To handle godot's RefCounted, we have defined our own GD_ref type that wraps Nim's ref type. It calls reference/unreference at the appropriate time (copy, destruction, etc.).

Various ways to fetch Godot's object

Singleton

let obj1: Engine = Engine.singleton
let obj2: Engine = /Engine

Get Node

# getNode(Node, NodePath): Node
let obj1: Control = node.getNode("Control") as Control
# `/`(Node, NodePath): Node = getNode(Node, NodePath)
let obj2: Control = node/"Control" as Control
# `/`(Node, typedesc[SomeNode]): SomeNode = getNode(Node, $SomeNode) as SomeNode
let obj3: Control = node/Control

Vector Swizzling

Godot-nim supports GL-like swizzling operator .*.

To use swizzling, please switch -d:nimPreviewDotLikeOps

let v: Vector3 = [0f, 1, 2]
var v_sub = v.*zxz
assert v_sub == [2f, 0, 2]
v_sub.*xy = [3f, 4]
assert v_sub == [3f, 4, 2]
assert not compiles(v_sub.*xz = [5f, 6])

There are four types of accessors: x, y, z, and w.

Immutable values can be obtained in any combination.

let v2 = v.*zxy
let v3 = v.*xxxxxxxxx

Mutable values can only be retrieved by contiguous accessors (i.e., subsets).

v.*xy = [10f, 11]
v.*yz = [12f, 13]
v.*xyz = [14f, 15, 16]

Though if the original value is immutable, sub-vector will be too.

assert not compiles([1, 2, 3].*xy = [10, 11])

Single accessor represents mutable scalar.

let s: float32 = v.*x
v.*x = 20

Development

engine classes and engine variants are generated by generator/.

Environment

Tested

  • Arch Linux
  • Ubuntu 20.04.6 LTS on Windows 11 Subsystem

godot-nim's People

Contributors

panno8m avatar

Stargazers

 avatar Jemoo Chan avatar  avatar Wilton Lazary avatar Ark avatar Miguel Rodríguez avatar moddo avatar 深淵の鴿子 avatar RIKA! avatar Nicol  avatar Jacey Janczak avatar Kimmy avatar Joakim Grahn avatar Vsevolod Tsiliurik avatar PUFF1N avatar Vladimir Berezenko avatar Christopher Arndt avatar Klavdij Voncina avatar  avatar  avatar Leon Lysak avatar Komet Fox avatar  avatar  avatar  avatar  avatar Mathy Fey avatar Nikolaus Schlemm avatar astrolemonade avatar Benjamin Stanley avatar  avatar  avatar jg avatar Andrés Peláez avatar Akito avatar Cristian Camilo Ruiz avatar ringabout avatar Wasin Chintapanyakul avatar  avatar  avatar  avatar  avatar Antonis Geralis avatar Toma400 avatar Dragos avatar Solitude avatar Yu Vitaqua fer Chronos avatar Guerro323 avatar Dustin Neumann avatar David Krause avatar  avatar TdS avatar Satsuki Akiba avatar  avatar  avatar  avatar  avatar Nick Seong avatar adam avatar xix xeaon avatar Stehsaer Liu avatar Arik Rahman avatar griffith1deady avatar  avatar Jonathan Arreguit avatar Constantine Molchanov avatar Scott Wadden avatar Александр Старочкин avatar  avatar

Watchers

Kimmy avatar Dmitry avatar Wasin Chintapanyakul avatar Guerro323 avatar Solitude avatar  avatar  avatar  avatar TdS avatar Jacey Janczak avatar

godot-nim's Issues

How to contribute

Hi there.

I would love to see this project become stable. And I would also be willing to help in my spare time, talking a few hours a week.

I don't really have an understanding of how gdextension works though and I'm kinda struggling to get over the hurdle of getting into it.

If you have simple but labor intensive tasks (possibly "Define utility functions"), I would be happy to help with sufficient instructions.

Unstable Nim version 1.9.3

In godot.nimble it specifies the Nim version to be.

requires "nim >= 1.9.3"

That is a problem because that is an unstable version of Nim that can only be reproduced by building Nim yourself at a specific commit in the repo.

It would be great if you could either upgrade your code to be compatible with Nim 2.0.0 or make it compatible with 1.6.x.

Thank you for you work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.