I’m a queer Creative Programmer, with a side dish of design and consultancy, and a passion for research and artistic applications of technology. I work as a Programmer at Adobe on VR Sculpting app called Modeller. Previously I had a long career in games, and I still love them.
Love living in London.
When I'm not programming, playing games, roleplaying, learning, or reading, you can typically find me skating or streaming on Twitch.
I'm working on a VR game in Godot 4.x and well it has been long since that I admitted I would need to hack open the engine and make changes. I am trying to keep that to a minimum I talk about that about why the last game was shelved in this video. Now as progress on the new game is going well I want to talk about -two things- when you should C++.
Problem: Cut a mesh in VR very fast
It's fast, you can live edit it and well when speed of iteration is king it is hard to beat a domain specific scripting language. Though that is all it is a scripting language. That is not a bad thing and one of my favourite things about GDScript is it doesn't try to overreach. So many game enginges I've worked on get really over complicated when really a bit of YAML or LUA would serve 99% of their needs. So that golden rule for me is, build it in gdscript first whenever possible. So I start out by building a simple slicer using ArrayMesh in GDScript.
VR needs speed and general purpose mesh processing algos are really slow and have a tendency to get linear fast, which means it is hard to avoid frame hitches. 99/100 if your doing realtime mesh processing in a game you haven't spoken to your tech artist enough. Smoke and mirrors baby! Also only solving the problems you to is a huge boost.
So the MVP is we need to...
Another thing is the set of preconditions
Honestly nothing in that list, we good then the question is what should we do in gdscript. Looking at the docs for array mesh and the functions offered by the Render Server I noticed a few things. Any mesh processing or buffer management will be a lot more complex, indirect and hard to optimise in GDScript. This is because many functions are wrapped through layers of indirection which would be hard for compilers to optimised. Now if I wasn't working on a VR game where every drop of perf mattered this wouldn't be a huge issue, but it is for me. Another thing though is...
Writing code which is very robust to processing large chunks of data with minimal wasteage mostly comes down to caring about IO and cache friendly operations. People will often talk about Big O optimisation or some fancy way of making the code "cleaner" but the reality is the compiler needs to scan a bunch of data from one place, make a transformation using a small set of instructions on a tiny worktable (CPU/GPU registers). It has some shelves by the table it can each to, or turn around and reach which can hold a bit more (Cache). But every time the computer needs to walk away from that worktable to fetch something from another room like hard drive or ram, or worse go talk to the neighbour or drive to another city over a network connection things slow waaaaaaaay down.
So often doing more work that involves less moving about is faster than doing less work. Think about this like sorting the puzzle pieces before doing a jigsaw or sorting out the bits of pieces from a model kit, cutting all the sprus while having the cutters in your hand. So sometimes scanning through data and working on it as you come across it, even if it means scanning the data twice or three times is faster. These deep coding problems are when you should be reaching for C++.
Additionally looking at the scripting API for GDScript, rendering server and its multiple backend support for Vulkan and other renderers because I know I'm only on Vulkan I can make things work directly with that. And the calls which are exposed to scripting are often done so in a friendly easy to process way for human devs rather than what is nice for the computer.
I'm still optimising and cleaning up the solution but currently here is the process
Wrap that C++ function in a custom module which is callable from GDScript.
I hope that is useful for some people I'm happy to talk more specifics if people are interested just drop me a line on masto: @kimau@mastodon.gamedev.place or twitter: @EvilKimau
Social Bits and Bobs
Website: Claire Blackshaw
Flammable Penguins: Small Press Publishing
Mastodon: @kimau@mastodon.gamedev.place
Twitter: @EvilKimau
YouTube: YouTube
LinkedIn: Claire Blackshaw
Twitch: Kimau
Github: Kimau
TikTok: @EvilKimau
Tumblr: Forest of Fun
Book list: Good Reads