utopia-rise / godot-kotlin-native Goto Github PK
View Code? Open in Web Editor NEWKotlin bindings for Godot Engine
License: MIT License
Kotlin bindings for Godot Engine
License: MIT License
TODO: split in different subtasks
Has to be done after: #68, #69, #70, #71, #72 !
Implement the entry generator. It should be called by the godot-annotation-processor and receive the lists described here: #71 . With those lists, the entry file should be generated and all the gdns files should be generated. If the gradle plugin sets the automated removal of the generated gdns file to true, it should also remove all obsolete gdns files from the filesystem.
For more information: write @chippmann on Discord.
Hello!
Duplicate(deep = false)
I'm currently missing the duplicate function (with deep_copy functionalities) in the godot.core.Dictionary.
keys and values?
Also I'm not really sure about the implementation of keys and values as they currently seem
much too close to being actual fields in the Dictionary?
Like for example if I have following Dictionary dict:
{
"keys" : ["pear", "banana", "apple"],
"values": ["diamond", "pearl", "amethyst"]
}
I would expect dict.keys to give me a GDArray of ["pear", "banana", "apple"] instead of a GDArray of ["keys", "values"]? Currently this isn't the case and this might confuse adapters coming from GDScript. (I am aware that you can still use dict["keys"] and that will work... but the confusion can be avoided!)
list<String> and array<String> to PoolStringArray
There's a lot of other functionalities missing but having a conversion between list<String> and PoolStringArray (as well as other lists<>/array<> to their respective Godot arrays) would be great to have.
Describe the problem or limitation you are having in your project:
For now, release or debug is hardcoded in gradle build script, we should be able to specify a release target or to have one by default, that is the same for all projects (coroutines project is in RELEASE mode).
Describe how this feature / enhancement will help you overcome this problem or limitation:
User would be able to specify a release target.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide
Describe implementation detail for your proposal (in code), if possible:
-Ptarget=RELEASE/DEBUG
:val target: String by project
this.target.binaries {
sharedLib(listOf(org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.RELEASE))
}
If this enhancement will not be used often, can it be worked around with a few lines of code?:
It depends on build scripts.
Is there a reason why this should be in this project and not individually solved?:
We should be able to publish release
Describe the problem or limitation you are having in your project:
Godot projects can be exported to iOS.
GDNative also supports this target.
For now this project cannot export to iOS.
Describe how this feature / enhancement will help you overcome this problem or limitation:
It will allow me to export kotlin godot's native to iOS.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
Describe the problem or limitation you are having in your project:
When converting script from GDScript to Kotlin, there were a lot of functions I couldn't use out of the box.
Some are straightforward, some need to be locally rewritten, some need to be imported from external Kotlin package.
Describe how this feature / enhancement will help you overcome this problem or limitation:
The idea is to implement the different function of GdScript described here.
https://docs.godotengine.org/en/3.2/classes/[email protected]
Use cases:
Describe implementation detail for your proposal (in code), if possible:
These functions could be implementented in the GD singleton just like the Print function is today.
Implement default value support for coreTypes (except array 's and resources!).
The user would have to write the following:
@RegisterProperty
var nodePath: NodePath = NodePath("")
Implementation hints:
PropertyDefaultValueProvider
and PropertyHintTypeMapper
Variant
property("nameOfProperty", TestingClass::propertyReference, STRING /*This is the püroperty type*/, Variant("defaultValue") /*This is the default value*/, true /**visible in editor/, DISABLED /*RPCMode*/, GODOT_PROPERTY_HINT_GLOBAL_DIR /*hint type*/, "" /*hint string*/)
This would make the initial setup for new users much simpler.
It looks like it's possibly as simply as described here:
https://www.jetbrains.com/help/idea/save-project-as-template-dialog.html
And it could be added to the Jetbrains plugin repo so that users can grab it from within InteliJ it's self.
Version:
Master branch
OS/device including version:
MacOS Catalina 10.15.3
Issue description:
Coroutines sample crashes on macos when starting, with stacktrace:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff70c3d7fa __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff70cfabc1 pthread_kill + 432
2 libsystem_c.dylib 0x00007fff70bc4a1c abort + 120
3 libkotlin.dylib 0x0000000121e46de9 konan::abort() + 9
4 libkotlin.dylib 0x0000000121e4adae TerminateWithUnhandledException + 14
5 libkotlin.dylib 0x0000000121e4acf1 KonanTerminateHandler() + 193
6 libc++abi.dylib 0x00007fff6dc6bdc7 std::__terminate(void (*)()) + 8
7 libc++abi.dylib 0x00007fff6dc6bb6c __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27
8 libc++abi.dylib 0x00007fff6dc5d45d __cxa_throw + 113
9 libkotlin.dylib 0x0000000121e62afc ThrowException + 124
10 libkotlin.dylib 0x0000000121c70f44 kfun:godot.utils.getMB$godot-library(kotlin.String;kotlin.String)ValueType + 1092 (Utils.kt:15)
11 libkotlin.dylib 0x0000000121abf94d kfun:godot.Object.$INITIALIZER$lambda-38#internal + 45 (Object.kt:154)
12 libkotlin.dylib 0x0000000121ac3595 kfun:godot.Object.$$INITIALIZER$lambda-38$FUNCTION_REFERENCE$1438.invoke#internal + 37 (Object.kt:153)
13 libkotlin.dylib 0x0000000121ac364f kfun:godot.Object.$$INITIALIZER$lambda-38$FUNCTION_REFERENCE$1438.$<bridge-UNN>invoke()ValueType#internal + 143 (Object.kt:153)
14 libkotlin.dylib 0x000000012186c129 kfun:kotlin.native.concurrent.FreezeAwareLazyImpl.<get-value>()#GENERIC + 2793 (Lazy.kt:52)
15 libkotlin.dylib 0x0000000121ab958b kfun:godot.Object.<get-toStringMethodBind>#internal + 299 (Object.kt:153)
16 libkotlin.dylib 0x0000000121abceff kfun:godot.Object.toString()kotlin.String + 143 (Object.kt:357)
17 libkotlin.dylib 0x0000000121ce39fe kfun:kotlin.godot.entry.udcBridge9$lambda-8#internal + 2030 (Tools.kt:62)
18 libkotlin.dylib 0x0000000121ce7b1a _knbridge22 + 90 (Entry.kt:109)
19 libkotlin.dylib 0x0000000121e77b47 ___godot_wrapper_call_and_get + 87
20 org.godotengine.godot 0x0000000104428ef6 NativeScriptInstance::_ml_call_reversed(NativeScriptDesc*, StringName const&, Variant const**, int) + 182
21 org.godotengine.godot 0x000000010442aeea NativeScriptInstance::call_multilevel_reversed(StringName const&, Variant const**, int) + 186
22 org.godotengine.godot 0x00000001059cd836 Navigation2D::_notificationv(int, bool) + 102
23 org.godotengine.godot 0x0000000106458d83 Object::notification(int, bool) + 19
24 org.godotengine.godot 0x0000000105549fda Node::_propagate_ready() + 170
25 org.godotengine.godot 0x0000000105549f69 Node::_propagate_ready() + 57
26 org.godotengine.godot 0x0000000105549f69 Node::_propagate_ready() + 57
27 org.godotengine.godot 0x000000010554fa1f Node::_set_tree(SceneTree*) + 95
28 org.godotengine.godot 0x000000010557e948 SceneTree::init() + 40
29 org.godotengine.godot 0x0000000104207604 OS_OSX::run() + 52
30 org.godotengine.godot 0x000000010420a48b main + 811
31 libdyld.dylib 0x00007fff70af67fd start + 1
Steps to reproduce:
Minimal reproduction project:
Coroutines sample project.
Implement default value support for arrays. Only one dimensional array support needs to be implemented!
The user would have to write the following:
@RegisterProperty
var nodePaths = variantArrayOf(NodePath("A"), NodePath("B")) //only VariantArray is allowed!
Implementation hints:
PropertyDefaultValueProvider
and PropertyHintTypeMapper
Variant
variantArrayOf()
property("nameOfProperty", TestingClass::propertyReference, STRING /*This is the püroperty type*/, Variant("defaultValue") /*This is the default value*/, true /**visible in editor/, DISABLED /*RPCMode*/, GODOT_PROPERTY_HINT_GLOBAL_DIR /*hint type*/, "" /*hint string*/)
Describe the problem or limitation you are having in your project:
We currently don't know how Kotlin native wrapper performs.
Describe how this feature / enhancement will help you overcome this problem or limitation:
It will make us able to benchmark the wrapper.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide.
Describe implementation detail for your proposal (in code), if possible:
There are performance test addons for godot. Implementing one in kotlin would to the job.
Like this one: https://github.com/cart/godot3-bunnymark
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Not appropriate.
Is there a reason why this should be in this project and not individually solved?:
Not appropriate.
Version:
0.1.0-3.2
OS/device including version:
OSX 10.15.3
Issue description:
NotImplementedError is thrown when trying to call File's constructor:
kotlin.NotImplementedError: There is no constructor for class File in GD
at 0 libkotlin.dylib 0x00000001264be727 kfun:kotlin.Throwable.<init>(kotlin.String?)kotlin.Throwable + 87 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Throwable.kt:22:37)
at 1 libkotlin.dylib 0x00000001264b89f5 kfun:kotlin.Error.<init>(kotlin.String?)kotlin.Error + 85 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:12:44)
at 2 libkotlin.dylib 0x00000001264b37a5 kfun:kotlin.NotImplementedError.<init>(kotlin.String)kotlin.NotImplementedError + 85 (/Users/teamcity3/buildAgent/work/4d622a065c544371/backend.native/build/stdlib/kotlin/util/Standard.kt:15:90)
at 3 libkotlin.dylib 0x00000001264fa8ae kfun:godot.GodotObject.<init>$godot-library(kotlin.String)godot.GodotObject + 1102 (/Users/piertho/git/kotlin-godot-wrapper/wrapper/godot-library/src/main/kotlin/godot/GodotObject.kt:32:28)
at 4 libkotlin.dylib 0x000000012687c0c5 kfun:godot.Object.<init>$godot-library(kotlin.String)godot.Object + 85 (/Users/piertho/git/kotlin-godot-wrapper/wrapper/godot-library/src/main/kotlin/godot/generated/godot/Object.kt:164:40)
at 5 libkotlin.dylib 0x0000000126901215 kfun:godot.Reference.<init>$godot-library(kotlin.String)godot.Reference + 85 (/Users/piertho/git/kotlin-godot-wrapper/wrapper/godot-library/src/main/kotlin/godot/generated/godot/Reference.kt:29:40)
at 6 libkotlin.dylib 0x000000012673092e kfun:godot.File.<init>()godot.File + 62 (/Users/piertho/git/kotlin-godot-wrapper/wrapper/godot-library/src/main/kotlin/godot/generated/godot/File.kt:177:19)
at 7 libkotlin.dylib 0x0000000126be7406 kfun:godot.samples.games.dodge.Main._ready() + 2774 (/Users/piertho/git/kotlin-godot-wrapper/samples/games/kotlin/src/main/kotlin/godot/samples/games/dodge/Main.kt:39:20)
at 8 libkotlin.dylib 0x0000000126bb3c2b kfun:org.godotengine.kotlin.functionBridge13$lambda-102#internal + 971 (/Users/piertho/git/kotlin-godot-wrapper/samples/games/kotlin/build/godot/entries/org/godotengine/kotlin/Entry.kt:1055:17)
at 9 libkotlin.dylib 0x0000000126bdf7ea _knbridge210 + 90 (/Users/piertho/git/kotlin-godot-wrapper/samples/games/kotlin/build/godot/entries/org/godotengine/kotlin/Entry.kt:1050:10)
at 10 libkotlin.dylib 0x0000000126e92cf7 ___godot_wrapper_call_and_get + 87
at 11 Godot 0x0000000109a53543 _ZN20NativeScriptInstance17_ml_call_reversedEP16NativeScriptDescRK10StringNamePPK7Varianti + 179
at 12 Godot 0x0000000109a55659 _ZN20NativeScriptInstance24call_multilevel_reversedERK10StringNamePPK7Varianti + 185
at 13 Godot 0x000000010bd93bf3 _ZN6Object12notificationEib + 19
at 14 Godot 0x000000010ad9f37b _ZN4Node16_propagate_readyEv + 171
at 15 Godot 0x000000010ada4b04 _ZN4Node18_add_child_nocheckEPS_RK10StringName + 180
at 16 Godot 0x000000010a559812 _ZN11MethodBind1IP4NodeE4callEP6ObjectPPK7VariantiRNS5_9CallErrorE + 322
at 17 Godot 0x000000010bd97155 _ZN6Object4callERK10StringNamePPK7VariantiRNS3_9CallErrorE + 357
at 18 Godot 0x000000010bd89b6a _ZN12MessageQueue14_call_functionEP6ObjectRK10StringNamePK7Variantib + 442
at 19 Godot 0x000000010bd89e50 _ZN12MessageQueue5flushEv + 224
at 20 Godot 0x000000010add4c94 _ZN9SceneTree9iterationEf + 612
at 21 Godot 0x0000000109794e23 _ZN4Main9iterationEv + 531
at 22 Godot 0x0000000109766417 _ZN6OS_OSX3runEv + 391
at 23 Godot 0x000000010976b321 main + 529
at 24 libdyld.dylib 0x00007fff633397fd start + 1
Steps to reproduce:
Create a script which call File constructor.
Minimal reproduction project:
Can be easily done in sample.
Implement kotlin compiler plugins like here:
https://github.com/utopia-rise/godot-kotlin/tree/master/tools/kotlin-compiler-native-plugin
and here:
https://github.com/utopia-rise/godot-kotlin/tree/master/tools/kotlin-compiler-plugin
using the MpApt project.
Describe the problem or limitation you are having in your project:
For the merge purpose, we decided to set api code generation as a gradle task.
Describe how this feature / enhancement will help you overcome this problem or limitation:
Not appropriate
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
See @raniejade repository
Describe implementation detail for your proposal (in code), if possible:
Move code to buildSrc
of project.
Add a task implementation.
Call task from godot-library
gradle.
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Not appropriate.
Is there a reason why this should be in this project and not individually solved?:
Not appropriate.
Describe the problem or limitation you are having in your project:
To make pull requests more consistent, we should provide a pull request template.
Describe how this feature / enhancement will help you overcome this problem or limitation:
It directly related to #11 but can be done separately.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide
Describe implementation detail for your proposal (in code), if possible:
The content of this template needs to be discussed but should definitely contain a brief overview over the changes and why they are done.
If this enhancement will not be used often, can it be worked around with a few lines of code?:
It's not completely necessary but definitely helpful.
Is there a reason why this should be in this project and not individually solved?:
As pull requests are made in this project.
Version:
0.1.0-3.2
OS/device including version:
iOS, every versions
Issue description:
In all samples buildType is not used for ios signing. So it is hard coded in debug and release.
if (project.hasProperty("iosSigningIdentity") && this.target.name == "iosArm64") {
tasks.build {
doLast {
exec {
commandLine = listOf("codesign", "-f", "-s", iosSigningIdentity, "build/bin/iosArm64/debugShared/libkotlin.dylib")
}
exec {
commandLine = listOf("install_name_tool", "-id", "@executable_path/dylibs/ios/libkotlin.dylib", "build/bin/iosArm64/debugShared/libkotlin.dylib")
}
}
}
} else if (project.hasProperty("iosSigningIdentity") && this.target.name == "iosX64") {
tasks.build {
doLast {
exec {
commandLine = listOf("codesign", "-f", "-s", iosSigningIdentity, "build/bin/iosX64/debugShared/libkotlin.dylib")
}
exec {
commandLine = listOf("install_name_tool", "-id", "@executable_path/dylibs/ios/libkotlin.dylib", "build/bin/iosX64/debugShared/libkotlin.dylib")
}
}
}
}
Steps to reproduce:
None.
Minimal reproduction project:
All samples.
Describe the problem or limitation you are having in your project:
Local value modification work-around is somewhat annoying.
Describe how this feature / enhancement will help you overcome this problem or limitation:
By changing the dsl-like interface like position { it.x = 1 }
to using a receiver instead, the code will look like position { x = 1 }
instead. Ie. not require the it
Not sure it this has ever been discussed or if it's a good solution.
Maybe it is possible to circumvent the problem by using delegates, or heck, maybe one doesn't want to circumvent the problem at all.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
Describe implementation detail for your proposal (in code), if possible:
diff --git a/tools/api-classes-generator/src/main/kotlin/Class.kt b/tools/api-classes-generator/src/main/kotlin/Class.kt
index 681cf69..501f204 100644
--- a/tools/api-classes-generator/src/main/kotlin/Class.kt
+++ b/tools/api-classes-generator/src/main/kotlin/Class.kt
@@ -231,7 +231,7 @@ class Class(
ParameterSpec.builder(
"schedule",
LambdaTypeName.get(
- parameters = *arrayOf(parameterTypeName),
+ receiver = parameterTypeName,
returnType = ClassName("kotlin", "Unit")
)
).build()
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Is there a reason why this should be in this project and not individually solved?:
The code is generated by the annotation processor.
Describe the problem or limitation you are having in your project:
We'd like to try inline classes to wrap c pointer into generated class, without overhead.
This needs use of interface for inheritance, internal Objects to store methods and method bindings, and inline classes to store the pointer.
Describe how this feature / enhancement will help you overcome this problem or limitation:
Not appropriate.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide.
Describe implementation detail for your proposal (in code), if possible:
interface Node {
fun getParent(): Node?
}
interface Spatial : Node
internal object SpatialMethods {
}
internal object NodeMethods {
fun getParent(ptr: COpaquePointer): Node? {
TODO("Not yet implemented")
}
}
inline class SpatialImpl(private val ptr: COpaquePointer) : Spatial {
override fun getParent(): Node? {
return NodeMethods.getParent(ptr)
}
}
inline class NodeImpl(private val ptr: COpaquePointer) : Node {
override fun getParent(): Node? = NodeMethods.getParent(ptr)
}
// pseudo constructors
fun Node(): Node = TODO()
fun Spatial(): Spatial = TODO()
fun test() {
val spatial = Spatial()
val node = Node()
}
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Not appropriate;
Is there a reason why this should be in this project and not individually solved?:
It concerns API code generation.
When godot.cleanupGeneratedFiles
is set to true
a clean task should be created to clear up all generated files. For now the only generated files we have are the gdns files (root directory is configured by godot.gdnsDir
). The clean task should be invoke before compilation.
Describe the problem or limitation you are having in your project:
Godot internally use Float and Integer but our current implementation use Double and Long. Kotlin doesn't allows implicit conversion between Double/Float and Long/Integer, you have to manually cast it. It also takes more memory than needed.
As you can see in this example from Rect2, we convert the floats from Godot to Double and cast them back to Float once again when sent to Godot.
Describe how this feature / enhancement will help you overcome this problem or limitation:
We just need to replace the types used in the generation tool and the CoreTypes.
Implement default value support for enum / bit flags.
This includes the following:
The user would have to write the following:
@RegisterProperty
@EnumFlag(MyFlag.ONE, MyFlag.TWO)
lateinit var flags: Set<MyFlag> //fail if not lateinit as default values are passed in annotation
Implementation hints:
PropertyDefaultValueProvider
and PropertyHintTypeMapper
Variant
Set<Enum>
@EnumFlag
annotationproperty("nameOfProperty", TestingClass::propertyReference, STRING /*This is the püroperty type*/, Variant("defaultValue") /*This is the default value*/, true /**visible in editor/, DISABLED /*RPCMode*/, GODOT_PROPERTY_HINT_GLOBAL_DIR /*hint type*/, "" /*hint string*/)
Version:
1.0.0 of the samples
OS/device including version:
Kubuntu 18.04
Kernel 5.3.0-28
Issue description:
set_friction
method -> use physics_materialsset_bounce
method -> use physics_materialscall_deffered
on area_set_shape
as it can't be updated while flushing queriesSteps to reproduce:
Minimal reproduction project:
Describe the problem or limitation you are having in your project:
Currently you solution for casting GodotObjects is very limiting and performance hungry.
We need to find a better way of casting objects.
Describe how this feature / enhancement will help you overcome this problem or limitation:
Currently a user cannot cast a node to a custom class which derives from node as it has no from
function.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide
Describe implementation detail for your proposal (in code), if possible:
None to provide
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Not really.
Is there a reason why this should be in this project and not individually solved?:
Yes the casting is implemented in the core project.
Describe the problem or limitation you are having in your project:
Currently it's very cumbersome and not typesafe to define default values. On top of that, the user in most cases defines a default value in code anyways for properties. And for signals it wpould be easy as well.
Describe how this feature / enhancement will help you overcome this problem or limitation:
The user can use kotlin default value features for registering signals and normal initialisation for properties instead of an usafe string.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
The user would write just this to register a property with a default value:
@RegisterProperty(visibleInEditor = false)
val someProperty = "I'm an awesome String!"
and this for Signals with default values:
@RegisterSignal
fun someSignal(firstArgument: Boolean = false, secondArgument: String = "coolStuff") {}
Describe implementation detail for your proposal (in code), if possible:
We need to find a way to get the values of the properties and parameters inside the entry generation code generation in a typesafe way.
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Yes we could just use the current string version but it's ugly and not typesafe at all
Is there a reason why this should be in this project and not individually solved?:
Entry generation is part of the core project.
Currently it is impossible to add key,value pairs to any godot.core.Dictionary as it is not implemented in the Dictionary.kt
Minimal reproduction project:
var something = Dictionary()
var key = "wakanda"
something[key] = "forever"
Won't work...
TBD
Describe the problem or limitation you are having in your project:
At the moment we have lot's of compiler warnings from the generated api classes like this one:
The corresponding parameter in the supertype 'Popup' is named 'event'. This may cause problems when calling this function with named arguments.
Which comes from: override fun _gui_input(arg0: InputEvent)
But this is mainly an issue of the godot api json as the arguments are named like this there.
A workaround could be to get the argument name from the supertype in the json and not from the definition itself. Or we could open an issue on the gdnative repository directly so they fix the root issue.
Also we still use deprecated code in the godot-library-extensions
regarding coroutines.
Describe how this feature / enhancement will help you overcome this problem or limitation:
We can then concentrate on the real warnings and users may not run into trouble because we generated suspicious code.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
Depends on the solution we take.
Describe implementation detail for your proposal (in code), if possible:
Access the supertypes methods argument names if possible, fallback to provided argument types in json.
If this enhancement will not be used often, can it be worked around with a few lines of code?:
We could suppress the warnings which is not the way to go.
Is there a reason why this should be in this project and not individually solved?:
Our code generates those warnings during compilation.
Describe the problem or limitation you are having in your project:
Currently the api-classes-generator
and the entry-generator
use a errorprone and hard to understand code generation using stringBuilders.
The code would be much cleaner and easier to maintain if we use reflection to generate the api-wrapper and annotations for the entry-classes generation.
Also it would make the project easier to use as a user doesn't have to write config json's anymore.
Describe how this feature / enhancement will help you overcome this problem or limitation:
One no longer needs to configure the errorprone json files and maitanance is much simpler.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide.
Describe implementation detail for your proposal (in code), if possible:
Use the compiler plugin created in issue #13 for the config generation.
Maybe use kotlinPoet for the api classes generation -> done in #14
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Yes with the current system. But it's not user friendly at all.
Is there a reason why this should be in this project and not individually solved?:
Yes as the code generation is the main part of the project.
Version:
all (tested since 1.0.0 tag from forked repo)
OS/device including version:
OSX Catalina 10.15.2, on macbook pro 13" 2017
Issue description:
Everything is working (on all versions of Godot), but only on Windows and Linux. I’m encountering memory issues on OSX Catalina (10.15.2).
In our samples we have 5 games, and the problems we’re facing are only on two:
- Dodge the creep
- Catch Ball
Here are some logs examples:
For Dodge the creep
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff6e1707fa __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff6e22dbc1 pthread_kill + 432
2 libsystem_c.dylib 0x00007fff6e0f7a1c abort + 120
3 libkotlin.dylib 0x0000000123effe29 konan::abort() + 9
4 libkotlin.dylib 0x0000000123effc9a RuntimeAssertFailed(char const*, char const*) + 170
5 libkotlin.dylib 0x0000000123efbf61 (anonymous namespace)::garbageCollect(MemoryState*, bool) + 5857
6 libkotlin.dylib 0x0000000123f1e7a8 ObjHeader* (anonymous namespace)::allocInstance<true>(TypeInfo const*, ObjHeader**) + 360
7 libkotlin.dylib 0x000000012358ea21 kfun:kotlin.lazy(kotlin.Function0<#GENERIC>)Generic + 161 (Lazy.kt:21)
8 libkotlin.dylib 0x0000000123935785 kfun:godot.Object.$INITIALIZER#internal + 4741 (Object.kt:115)
9 libkotlin.dylib 0x0000000123930ae3 kfun:godot.Object.<init>$godot-library(kotlin.String)godot.Object + 99 (Object.kt:164)
10 libkotlin.dylib 0x00000001238dec05 kfun:godot.Node.<init>$godot-library(kotlin.String)godot.Node + 85
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff6e1707fa __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff6e22dbc1 pthread_kill + 432
2 libsystem_c.dylib 0x00007fff6e0f7a1c abort + 120
3 libkotlin.dylib 0x000000011dcf5e29 konan::abort() + 9
4 libkotlin.dylib 0x000000011dcf5c9a RuntimeAssertFailed(char const*, char const*) + 170
5 libkotlin.dylib 0x000000011dcf1f61 (anonymous namespace)::garbageCollect(MemoryState*, bool) + 5857
6 libkotlin.dylib 0x000000011dd147a8 ObjHeader* (anonymous namespace)::allocInstance<true>(TypeInfo const*, ObjHeader**) + 360
7 libkotlin.dylib 0x000000011d9a539f kfun:godot.icalls._icall_Long_String_Object_String_GDArray_Long$godot-library(kotlinx.cinterop.CPointer<godot.gdnative.godot_method_bind>;kotlinx.cinterop.CPointer<out_kotlinx.cinterop.CPointed>;kotlin.String;godot.Object;kotlin.String;godot.core.GDArray;kotlin.Long)ValueType + 655 (Utils.kt:627)
8 libkotlin.dylib 0x000000011d727e5d kfun:godot.Object.connect(kotlin.String;godot.Object;kotlin.String;godot.core.GDArray;kotlin.Long)godot.core.GodotError + 525 (Object.kt:215)
9 libkotlin.dylib 0x000000011d7282ab kfun:godot.Object.connect$default(kotlin.String;godot.Object;kotlin.String;godot.core.GDArray?;kotlin.Long;kotlin.Int)godot.core.GodotError + 843 (Object.kt:208)
10 libkotlin.dylib 0x000000011da8dd16 kfun:godot.samples.games.dodge.Mob._ready() + 934 (Mob.kt:21)
With each time a /Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/cpp/Memory.cpp:1232: runtime assert: A reference to local object is encountered
message in console running Godot.
And for catch ball
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff6e1707fa __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff6e22dbc1 pthread_kill + 432
2 libsystem_c.dylib 0x00007fff6e0f7a1c abort + 120
3 org.godotengine.godot 0x000000010848b2bc handle_crash(int) + 1900
4 libsystem_platform.dylib 0x00007fff6e22242d _sigtramp + 29
5 ??? 0xaaaaaaaaaaaaaaaa 0 + 12297829382473034410
6 com.apple.CoreFoundation 0x00007fff36a9a7e0 _CFRelease + 1089
7 com.apple.IOAccelerator 0x00007fff5ac83f97 IOAccelContextSubmitDataBuffersExt2 + 201
8 libGPUSupportMercury.dylib 0x00007fff574705a0 gpusSubmitDataBuffers + 136
9 com.apple.driver.AppleIntelKBLGraphicsGLDriver 0x00007fff2e806c00 IntelCommandBuffer::getNew(GLDContextRec*) + 48
10 com.apple.driver.AppleIntelKBLGraphicsGLDriver 0x00007fff2e806a10 intelSubmitCommands + 171
11 com.apple.AppKit 0x00007fff345b986b -[NSIOAccelSurface frontBuffer] + 1718
12 com.apple.AppKit 0x00007fff345b8530 -[NSCGLSurface flushRect:] + 966
13 com.apple.AppKit 0x00007fff345b80ec NSCGLSurfaceFlush + 214
14 GLEngine 0x00007fff4123353a glSwap_Exec + 186
15 com.apple.opengl 0x00007fff4121548b CGLFlushDrawable + 59
16 com.apple.AppKit 0x00007fff33f3ea22 -[NSOpenGLContext flushBuffer] + 20
17 org.godotengine.godot 0x000000010a8afdf8 VisualServerRaster::draw(bool, double) + 376
18 org.godotengine.godot 0x00000001084c7017 Main::iteration() + 1031
19 org.godotengine.godot 0x0000000108498417 OS_OSX::run() + 391
20 org.godotengine.godot 0x000000010849d321 main + 529
21 libdyld.dylib 0x00007fff6e0297fd start + 1
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff6e1707fa __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff6e22dbc1 pthread_kill + 432
2 libsystem_c.dylib 0x00007fff6e0f7a1c abort + 120
3 org.godotengine.godot 0x000000010c0fd2bc handle_crash(int) + 1900
4 libsystem_platform.dylib 0x00007fff6e22242d _sigtramp + 29
5 ??? 000000000000000000 0 + 0
6 com.apple.CoreFoundation 0x00007fff36a9a7e0 _CFRelease + 1089
7 com.apple.IOAccelerator 0x00007fff5ac83f97 IOAccelContextSubmitDataBuffersExt2 + 201
8 libGPUSupportMercury.dylib 0x00007fff574705a0 gpusSubmitDataBuffers + 136
9 com.apple.driver.AppleIntelKBLGraphicsGLDriver 0x00007fff2e806c00 IntelCommandBuffer::getNew(GLDContextRec*) + 48
10 com.apple.driver.AppleIntelKBLGraphicsGLDriver 0x00007fff2e806a10 intelSubmitCommands + 171
11 com.apple.driver.AppleIntelKBLGraphicsGLDriver 0x00007fff2e80d3e3 glrWriteBufferData + 1389
12 GLEngine 0x00007fff4125a7d1 glBufferSubData_Exec + 608
13 org.godotengine.godot 0x000000010cad2340 RasterizerSceneGLES3::_setup_lights(RID*, int, Transform const&, CameraMatrix const&, RID) + 4384
14 org.godotengine.godot 0x000000010cae02c9 RasterizerSceneGLES3::render_scene(Transform const&, CameraMatrix const&, bool, RasterizerScene::InstanceBase**, int, RID*, int, RID*, int, RID, RID, RID, RID, int) + 2121
15 org.godotengine.godot 0x000000010e52f906 VisualServerScene::render_camera(RID, RID, Vector2, RID) + 838
16 org.godotengine.godot 0x000000010e54997d VisualServerViewport::_draw_3d(VisualServerViewport::Viewport*, ARVRInterface::Eyes) + 285
17 org.godotengine.godot 0x000000010e549c2f VisualServerViewport::_draw_viewport(VisualServerViewport::Viewport*, ARVRInterface::Eyes) + 447
18 org.godotengine.godot 0x000000010e54ae38 VisualServerViewport::draw_viewports() + 984
19 org.godotengine.godot 0x000000010e521dc3 VisualServerRaster::draw(bool, double) + 323
20 org.godotengine.godot 0x000000010c139017 Main::iteration() + 1031
21 org.godotengine.godot 0x000000010c10a417 OS_OSX::run() + 391
22 org.godotengine.godot 0x000000010c10f321 main + 529
23 libdyld.dylib 0x00007fff6e0297fd start + 1
In this games messages in console are:
/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/cpp/Memory.cpp:1091: runtime assert: Must be positive
/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/cpp/Memory.cpp:2441: runtime assert: Must be newly frozen
Steps to reproduce:
Compile bindings and game on mac os platform, run dodge and catch ball games
Minimal reproduction project:
Sample projects
Describe the problem or limitation you are having in your project:
The Kotlin/Native compiler is very slow at present, resulting in fairly long turnaround for small game code changes using godot-kotlin during development.
Describe how this feature / enhancement will help you overcome this problem or limitation:
For local development, running game logic on the JVM rather than native code would allow for quick re-compile times, as well as some JVM niceties such as live class reloading at runtime and direct debugging+breakpoints into the Kotlin code. The Kotlin/Native implementation in godot-kotlin can then be used in the exported game to remove the dependency on the JRE.
Describe implementation detail for your proposal (in code), if possible:
expect
declarations. Native implementations of these classes will acquire actual
keywords to define them as platform implementations, but otherwise remain unchanged.actual
implementations are created utilizing external
methods to call out to Godot APIs; implementations will be registered by the JNI later.actual
implementations rather than the Kotlin/Native compiler against the existing implementations. The output classes are bundled to a JAR and output into the Godot project path.external
methods don't support pointer types, etc.Is there a reason why this should be in this project and not individually solved?:
Ideally a JVM+JNI implementation will be maintained in parallel to the Kotlin/Native version to ensure seamless transition between fast local development and export.
Describe the problem or limitation you are having in your project:
Godot projects can be exported to Android.
GDNative also supports this target.
For now this project cannot export to Android.
Describe how this feature / enhancement will help you overcome this problem or limitation:
It will allow me to export kotlin godot's native to android.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
Version:
Godot 3.2
*OS/device including version:
Windows 10
Issue description:
If your Kotlin class has a public lateinit var of Vector2, it's "unassigned" value in the Godot editor is 0,0. Giving it any other value will cause it to be assigned in Kotlin, and everything is fine. However, the user may want 0,0 as their value, and in this case, accessing the var in Kotlin will result in an unassigned lateinit var exception being thrown.
Steps to reproduce:
Run the coroutines sample project.
MirrorBall.kt
lateinit var center: Vector2
Minimal reproduction project:
The coroutines sample project.
PropertyTypeHintAnnotation.kt
(already there, needs to be uncommented.PropertyHintTypeMapper.kt
PropertyTypeHintAnnotation.kt
(already there, needs to be uncommented.PropertyHintTypeMapper.kt
Describe the problem or limitation you are having in your project:
Having to use syntax like:
position{
x = 2
}
create a semantic difference between the properties of the Kotlin Script and the properties of the object the script is based on. This difference doesn't exist in Gdscript, so this particulary must disapear.
Describe how this feature / enhancement will help you overcome this problem or limitation:
This feature will allow you to write position.x = 2
without worrying about the local copy.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
/
Describe implementation detail for your proposal (in code), if possible:
The root of the problem is that a godot object doesn't return a pointer when getting a core property but a copy. If we try to update this copy, we have to call the setter either manually with:
it = position //getter called, return a copy and assign it to the variable "it"
it.x = 2 //local copy updated
position = it //setter called, varaible "it" copied into the object.
or with
position{ x = 2}
where the setter is called automatically at the end of the lambda.
Sadly I don't know a way to get the pointer to the original core property.
I want to implement a mechanism calling the setter every time, we write something like:
position.x = 2
.
It can be achieved in the following way:
If this enhancement will not be used often, can it be worked around with a few lines of code?:
/
Is there a reason why this should be in this project and not individually solved?:
It required to change the core wrappers and the api generator.
Describe the problem or limitation you are having in your project:
The used godot headers api json is quite old. It has to be updated to ensure compability with current and future godot versions.
Describe how this feature / enhancement will help you overcome this problem or limitation:
No limitations just yet. But there will be if we don't keep this up to date.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide.
Describe implementation detail for your proposal (in code), if possible:
Pull the latest changes from the master branch of the godot headers api (submodule in this project).
Ensure compability.
If this enhancement will not be used often, can it be worked around with a few lines of code?:
No.
Is there a reason why this should be in this project and not individually solved?:
Yes otherwise this project will not work in the future.
Describe the problem or limitation you are having in your project:
We should define some contribution guidelines to streamline the development process between contributors.
It definitely should include sections about how to branch and write commit messages.
Describe how this feature / enhancement will help you overcome this problem or limitation:
It would make the development more consistent and the commit messages more meaningful. It also would help new contributors to get started more easily.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide
Describe implementation detail for your proposal (in code), if possible:
As a starting point:
@piiertho and I settled down for git flow as on how to manage branches and write commit messages: https://danielkummer.github.io/git-flow-cheatsheet/ (ignore the plugin, it is not needed)
Rest (and maybe also this one) can be discussed further.
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Is there a reason why this should be in this project and not individually solved?:
As it concerns all contributors the guidelines should be in this project.
As many of you know, I'm currently, together with @chippmann and @piiertho , trying to get the Godot SQLite Kotlin plugin ready for release on the Godot Asset Library. I've had a lot of discussions with all Godot-kotlin developers on missing or faulty issues and features that still have to be rectified or added.
Most of these discussions get lost somewhere on Discord and it is a pain to dig them up all the time to remind myself what was said by who and when. I discussed this with @chippmann and we agreed that it might be easier for everyone involved to just open an issue on Github for easier backtracking and discussion.
At the moment there a couple of issues that stop Godot SQLite Kotlin from being released.
Some of them aren't directly connected to Godot Kotlin (this repo) but i added them just for completeness' sake.
fun callback(closure: COpaquePointer?, argc: Int, argv: CPointer<CPointerVar<ByteVar>>?, azColName: CPointer<CPointerVar<ByteVar>>?): Int {
val columnDictionary = Dictionary()
/* Get a reference to the instanced object */
val stableRef = closure?.asStableRef<SQLiteWrapper>()
val obj = stableRef?.get()
val stmt: CPointer<sqlite3_stmt>? = sqlite3_next_stmt(obj?.db, null)
var columnValue: Variant
/* Add result to query_result Array */
obj?.queryResult?.append(Variant(columnDictionary))
/* cleanup! */
stableRef?.dispose()
return 0
}
@RegisterFunction
fun query(queryString : String) : Boolean {
/* Clear the previous query results */
queryResult.clear()
val stableRef = StableRef.create(this)
val voidPointer = stableRef.asCPointer()
/* Execute SQL statement */
memScoped {
val q: CPointerVar<ByteVar> = alloc()
rc = sqlite3_exec(db, queryString, staticCFunction(::callback), voidPointer, q.ptr)
zErrMsg = q.value
}
/* cleanup! */
stableRef.dispose()
}
@RegisterFunction
fun selectRows() : GDArray {
/* Make the queryString here... */
query(queryString)
return queryResult <- JUST RETURNS AN EMPTY GDARRAY HERE!
}
Thus when returning the 'queryResult' it is just an empty GDArray instead of containing the rows that should've been captured by the callback function 'callback'.
I expect this to be a race condition, meaning that the return statement returns an empty GDArray that didn't get filled by the callback, but I'm unsure why this never happens in the C++ Godot SQLite library.
Hopefully opening this issue is ok for all parties involved. It would most definitely help me immensely to retain some oversight on the current situation.
Implement default value support for Resources and custom Resources.
The user would have to write the following:
@RegisterProperty
lateinit var resource: Resource //if not lateinit -> fail, customResources: just have to derive from Resource but are exported as Resource and not as custom type
Implementation hints:
PropertyDefaultValueProvider
and PropertyHintTypeMapper
Variant
property("nameOfProperty", TestingClass::propertyReference, STRING /*This is the püroperty type*/, Variant("defaultValue") /*This is the default value*/, true /**visible in editor/, DISABLED /*RPCMode*/, GODOT_PROPERTY_HINT_GLOBAL_DIR /*hint type*/, "" /*hint string*/)
PropertyTypeHintAnnotation.kt
(already there, needs to be uncommented.PropertyHintTypeMapper.kt
Describe the problem or limitation you are having in your project:
We need to know which methods are missing (like it was the case with set on Dictionary).
Describe how this feature / enhancement will help you overcome this problem or limitation:
It will test kotlin integration on a bigger project than our sample. With this we should be able to see if some basic methods are missing.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide.
Describe implementation detail for your proposal (in code), if possible:
Rewrite GDQuest's platformer implementation in Kotlin.
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Not appropriate.
Is there a reason why this should be in this project and not individually solved?:
Not appropriate. But it can be done in a seperate github, I guess this should be discussed.
Implement all needed registration annotations. This includes:
These annotations should have the following capabilities (arguments):
Hints:
The RPCMode's and the Property Hint's will be implemented as separate annotations rather than as arguments as they are now.
If the necessary RPCMode enum does not exist yet, add an empty enum class and add a TODO in it.
Describe the problem or limitation you are having in your project:
With this a user won't have to write error prone property hint strings like this anymore: 0,100000,1000,or_greater
Describe how this feature / enhancement will help you overcome this problem or limitation:
The usability of the registration system would be much improved when using property hint strings
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
We could define annotations like @HintRange(start = 0, end = 1000, step = 2)
which would provide typesafety
Describe implementation detail for your proposal (in code), if possible:
None to provide atm.
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Yes. We could still force the user to use type strings. But it's errorprone.
Is there a reason why this should be in this project and not individually solved?:
Annotations and the entry generating process are both part of the core project.
The version used should be similar to the gradle plugin. This can be achieved by embedding the project.version in a properties file bundled together with the artifact jar.The plugin read the version during runtime.
Implement a annotation processor like here: https://github.com/utopia-rise/godot-kotlin/tree/master/tools/godot-annotation-processor
The annotation processor should listen to the annotation's defined here: #68 , #70 , #69.
It should gather the descriptor classes in these lists:
It should gather those informations using the mpApt project: https://github.com/Foso/MpApt
But should NOT pass any MpApt specific informations to the godot-entry-generator so it does not need any dependency to MpApt!
Describe the problem or limitation you are having in your project:
Currently it is not possible to use yield on android, and it is the only platform concerned by this issue.
Describe how this feature / enhancement will help you overcome this problem or limitation:
It would make people able to use yield if they are targeting android, which is not possible for now.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide.
Describe implementation detail for your proposal (in code), if possible:
Have no idea on how to do that with only native, see issue on kotlinx.coroutines repo
If this enhancement will not be used often, can it be worked around with a few lines of code?:
No.
Is there a reason why this should be in this project and not individually solved?:
This is concerning godot-library-extension build itself.
Describe the problem or limitation you are having in your project:
Currently, godot's api kotlin code is generated using error prone StringBuilder.
It would be easier to maintain if we use a generation code api.
Describe how this feature / enhancement will help you overcome this problem or limitation:
Kotlin Poet is an api that provide easy to use code generation tools.
It is well maintained and our code would be much cleaner and easy to maintain.
Show a mock up screenshots/video or a flow diagram explaining how your proposal will work:
None to provide.
Describe implementation detail for your proposal (in code), if possible:
Replace string builders in generation methods of POJO in api-classes-generator
If this enhancement will not be used often, can it be worked around with a few lines of code?:
Not appropriate.
Is there a reason why this should be in this project and not individually solved?:
It concerns stability of the project.
This would eliminate another maintenance step, and it would simplify the Godot Editor plugin I'm working on as it currently doesn't work out of the box because these need to be entered manually.
Implement all needed propertyHint annotations. Like for example:
These annotations should have their arguments optional and in the correct type. For example:
Hints:
A hint on what should and could be implemented: http://docs.godotengine.org/en/latest/getting_started/scripting/gdscript/gdscript_exports.html#doc-gdscript-exports
All enums defined in RPCMode should also exist as annotations:
The annotation do not have parameters.
Implement default value support for primitiveTypes (expect array which are considered primitive in this case as well).
This includes the following:
The user would have to write the following:
@RegisterProperty
var int = 100
@RegisterProperty
var long = 100L
@RegisterProperty
var float = 1.0f
@RegisterProperty
var double = 2.0
@RegisterProperty
var str = "hello"
@RegisterProperty
var bool = true
@RegisterProperty
var enum = TestEnum.ENUM1
Implementation hints:
PropertyDefaultValueProvider
and PropertyHintTypeMapper
Variant
property("nameOfProperty", TestingClass::propertyReference, STRING /*This is the püroperty type*/, Variant("defaultValue") /*This is the default value*/, true /**visible in editor/, DISABLED /*RPCMode*/, GODOT_PROPERTY_HINT_GLOBAL_DIR /*hint type*/, "" /*hint string*/)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.