Merge pull request #728 from bruvzg/double_pr_build
commit
d00e46966d
|
@ -15,6 +15,13 @@ jobs:
|
|||
artifact-name: godot-cpp-linux-glibc2.27-x86_64-release
|
||||
artifact-path: bin/libgodot-cpp.linux.release.64.a
|
||||
|
||||
- name: 🐧 Linux (GCC, Double Precision)
|
||||
os: ubuntu-18.04
|
||||
platform: linux
|
||||
artifact-name: godot-cpp-linux-glibc2.27-x86_64-double-release
|
||||
artifact-path: bin/libgodot-cpp.linux.release.64.a
|
||||
flags: float=64
|
||||
|
||||
- name: 🏁 Windows (x86_64, MSVC)
|
||||
os: windows-2019
|
||||
platform: windows
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# godot-cpp cmake arguments
|
||||
# GODOT_HEADERS_DIR: This is where the gdnative include folder is (godot_source/modules/gdnative/include)
|
||||
# GODOT_CUSTOM_API_FILE: This is if you have another path for the godot_api.json
|
||||
# FLOAT_TYPE Floating-point precision (32, 64)
|
||||
#
|
||||
# Android cmake arguments
|
||||
# CMAKE_TOOLCHAIN_FILE: The path to the android cmake toolchain ($ANDROID_NDK/build/cmake/android.toolchain.cmake)
|
||||
|
@ -60,6 +61,16 @@ set(CMAKE_CXX_STANDARD 17)
|
|||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(FLOAT_TYPE_FLAG "float" CACHE STRING "")
|
||||
if(FLOAT_TYPE EQUAL 64)
|
||||
set(FLOAT_TYPE_FLAG "double" CACHE STRING "")
|
||||
endif(FLOAT_TYPE EQUAL 64)
|
||||
|
||||
set(BITS 32)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(BITS 64)
|
||||
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
|
||||
# Input from user for godot headers and the api file
|
||||
set(GODOT_HEADERS_DIR "godot-headers" CACHE STRING "")
|
||||
set(GODOT_CUSTOM_API_FILE "godot-headers/extension_api.json" CACHE STRING "")
|
||||
|
@ -139,7 +150,7 @@ execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator;
|
|||
)
|
||||
|
||||
add_custom_command(OUTPUT ${GENERATED_FILES_LIST}
|
||||
COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_CUSTOM_API_FILE}\", \"${GENERATE_BINDING_PARAMETERS}\", \"${CMAKE_CURRENT_BINARY_DIR}\")"
|
||||
COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_CUSTOM_API_FILE}\", \"${GENERATE_BINDING_PARAMETERS}\", \"${BITS}\", \"${FLOAT_TYPE_FLAG}\", \"${CMAKE_CURRENT_BINARY_DIR}\")"
|
||||
VERBATIM
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
MAIN_DEPENDENCY ${GODOT_CUSTOM_API_FILE}
|
||||
|
@ -185,11 +196,6 @@ set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LI
|
|||
|
||||
# Create the correct name (godot.os.build_type.system_bits)
|
||||
|
||||
set(BITS 32)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(BITS 64)
|
||||
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
|
||||
string(TOLOWER "${CMAKE_SYSTEM_NAME}" SYSTEM_NAME)
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@ opts.Add(
|
|||
opts.Add(BoolVariable("generate_template_get_node", "Generate a template version of the Node class's get_node.", True))
|
||||
|
||||
opts.Add(BoolVariable("build_library", "Build the godot-cpp library.", True))
|
||||
opts.Add(EnumVariable("float", "Floating-point precision", "32", ("32", "64")))
|
||||
|
||||
opts.Update(env)
|
||||
Help(opts.GenerateHelpText(env))
|
||||
|
@ -171,6 +172,9 @@ else:
|
|||
if env["target"] == "debug":
|
||||
env.Append(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_METHODS_ENABLED"])
|
||||
|
||||
if env["float"] == "64":
|
||||
env.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"])
|
||||
|
||||
if env["platform"] == "linux" or env["platform"] == "freebsd":
|
||||
if env["use_llvm"]:
|
||||
env["CXX"] = "clang++"
|
||||
|
|
|
@ -64,11 +64,17 @@ def scons_emit_files(target, source, env):
|
|||
|
||||
|
||||
def scons_generate_bindings(target, source, env):
|
||||
generate_bindings(str(source[0]), env["generate_template_get_node"], target[0].abspath)
|
||||
generate_bindings(
|
||||
str(source[0]),
|
||||
env["generate_template_get_node"],
|
||||
env["bits"],
|
||||
"double" if (env["float"] == "64") else "float",
|
||||
target[0].abspath,
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
def generate_bindings(api_filepath, use_template_get_node, output_dir="."):
|
||||
def generate_bindings(api_filepath, use_template_get_node, bits="64", double="float", output_dir="."):
|
||||
api = None
|
||||
|
||||
target_dir = Path(output_dir) / "gen"
|
||||
|
@ -79,9 +85,11 @@ def generate_bindings(api_filepath, use_template_get_node, output_dir="."):
|
|||
shutil.rmtree(target_dir, ignore_errors=True)
|
||||
target_dir.mkdir(parents=True)
|
||||
|
||||
print("Built-in type config: " + double + "_" + bits)
|
||||
|
||||
generate_global_constants(api, target_dir)
|
||||
generate_global_constant_binds(api, target_dir)
|
||||
generate_builtin_bindings(api, target_dir, "float_64")
|
||||
generate_builtin_bindings(api, target_dir, double + "_" + bits)
|
||||
generate_engine_classes_bindings(api, target_dir, use_template_get_node)
|
||||
generate_utility_functions(api, target_dir)
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
|
||||
inline Color blend(const Color &p_over) const {
|
||||
Color res;
|
||||
float sa = (real_t)1.0 - p_over.a;
|
||||
float sa = 1.0 - p_over.a;
|
||||
res.a = a * sa + p_over.a;
|
||||
if (res.a == 0) {
|
||||
return Color(0, 0, 0, 0);
|
||||
|
@ -173,16 +173,16 @@ public:
|
|||
|
||||
inline Color srgb_to_linear() const {
|
||||
return Color(
|
||||
r < (real_t)0.04045 ? r * (real_t)(1.0 / 12.92) : Math::pow((r + (real_t)0.055) * (real_t)(1.0 / (1.0 + 0.055)), (real_t)2.4),
|
||||
g < (real_t)0.04045 ? g * (real_t)(1.0 / 12.92) : Math::pow((g + (real_t)0.055) * (real_t)(1.0 / (1.0 + 0.055)), (real_t)2.4),
|
||||
b < (real_t)0.04045 ? b * (real_t)(1.0 / 12.92) : Math::pow((b + (real_t)0.055) * (real_t)(1.0 / (1.0 + 0.055)), (real_t)2.4),
|
||||
r < 0.04045 ? r * (1.0 / 12.92) : Math::pow((r + 0.055f) * (1.0 / (1.0 + 0.055)), 2.4),
|
||||
g < 0.04045 ? g * (1.0 / 12.92) : Math::pow((g + 0.055f) * (1.0 / (1.0 + 0.055)), 2.4),
|
||||
b < 0.04045 ? b * (1.0 / 12.92) : Math::pow((b + 0.055f) * (1.0 / (1.0 + 0.055)), 2.4),
|
||||
a);
|
||||
}
|
||||
inline Color linear_to_srgb() const {
|
||||
return Color(
|
||||
r < (real_t)0.0031308 ? (real_t)12.92 * r : (real_t)(1.0 + 0.055) * Math::pow(r, (real_t)(1.0 / 2.4)) - (real_t)0.055,
|
||||
g < (real_t)0.0031308 ? (real_t)12.92 * g : (real_t)(1.0 + 0.055) * Math::pow(g, (real_t)(1.0 / 2.4)) - (real_t)0.055,
|
||||
b < (real_t)0.0031308 ? (real_t)12.92 * b : (real_t)(1.0 + 0.055) * Math::pow(b, (real_t)(1.0 / 2.4)) - (real_t)0.055, a);
|
||||
r < 0.0031308f ? 12.92f * r : (1.0f + 0.055f) * Math::pow(r, 1.0f / 2.4f) - 0.055f,
|
||||
g < 0.0031308f ? 12.92f * g : (1.0f + 0.055f) * Math::pow(g, 1.0f / 2.4f) - 0.055f,
|
||||
b < 0.0031308f ? 12.92f * b : (1.0f + 0.055f) * Math::pow(b, 1.0f / 2.4f) - 0.055f, a);
|
||||
}
|
||||
|
||||
static Color hex(uint32_t p_hex);
|
||||
|
@ -204,14 +204,14 @@ public:
|
|||
operator String() const;
|
||||
|
||||
// For the binder.
|
||||
inline void set_r8(int32_t r8) { r = (Math::clamp(r8, 0, 255) / (real_t)255.0); }
|
||||
inline int32_t get_r8() const { return int32_t(Math::clamp(r * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
|
||||
inline void set_g8(int32_t g8) { g = (Math::clamp(g8, 0, 255) / (real_t)255.0); }
|
||||
inline int32_t get_g8() const { return int32_t(Math::clamp(g * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
|
||||
inline void set_b8(int32_t b8) { b = (Math::clamp(b8, 0, 255) / (real_t)255.0); }
|
||||
inline int32_t get_b8() const { return int32_t(Math::clamp(b * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
|
||||
inline void set_a8(int32_t a8) { a = (Math::clamp(a8, 0, 255) / (real_t)255.0); }
|
||||
inline int32_t get_a8() const { return int32_t(Math::clamp(a * (real_t)255.0, (real_t)0.0, (real_t)255.0)); }
|
||||
inline void set_r8(int32_t r8) { r = (Math::clamp(r8, 0, 255) / 255.0); }
|
||||
inline int32_t get_r8() const { return int32_t(Math::clamp(r * 255.0, 0.0, 255.0)); }
|
||||
inline void set_g8(int32_t g8) { g = (Math::clamp(g8, 0, 255) / 255.0); }
|
||||
inline int32_t get_g8() const { return int32_t(Math::clamp(g * 255.0, 0.0, 255.0)); }
|
||||
inline void set_b8(int32_t b8) { b = (Math::clamp(b8, 0, 255) / 255.0); }
|
||||
inline int32_t get_b8() const { return int32_t(Math::clamp(b * 255.0, 0.0, 255.0)); }
|
||||
inline void set_a8(int32_t a8) { a = (Math::clamp(a8, 0, 255) / 255.0); }
|
||||
inline int32_t get_a8() const { return int32_t(Math::clamp(a * 255.0, 0.0, 255.0)); }
|
||||
|
||||
inline void set_h(float p_h) { set_hsv(p_h, get_s(), get_v()); }
|
||||
inline void set_s(float p_s) { set_hsv(get_h(), p_s, get_v()); }
|
||||
|
|
Loading…
Reference in New Issue