I'm trying to compile Godot to use doubles for vectors and math functions internally and found I can do this by setting the preprocessor macro REAL_T_IS_DOUBLE but I don't know how to set this using the scons build environment.

All I've been able to find so far is this snippet of code from stackoverflow that will add the macro to the environment variables:

env = Environment()
env.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"])

Looking through the SConstruct file in the root folder of the source code seems to confirm that this will work as it is used to set other macros to control the build process. However, I can't find any mechanism in there to set user defined macros.

I figure I could just edit the file directly but this seems like a hack. What's the recommended way to set preprocessor macros when compiling Godot?

Well, I'm sure you've looked at the docs already, so you probably know as much as I do. The custom.py section may be what you're looking for.

However, as I recall, the Environment() function is built on your current shell environment. Have you tried just adding it to your shell? In bash, that would be

export CPPDEFINES="REAL_T_IS_DOUBLE"

added to whichever script you start the build from.

Godot 3.x doesn't have working support for compiling using double-precision floats. There is a define, but if I'm not mistaken, it will not compile successfully if enabled (or it won't have any visible effect).

Godot 4.0.alpha supports compiling using double-precision floats, but single-precision remains the default. Support for doubles also remains partial so far, as vertex positions are still 32-bit on the GPU. Sending vertex positions as 64-bit is too slow, so another approach needs to be figured out. This can be tested by building Godot's master branch with float=64.

7 months later