mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-01 05:48:37 +03:00
Compare commits
134 Commits
godot-3.2.
...
3.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b340cb483 | ||
|
|
4212e9e38b | ||
|
|
745d7a2d1a | ||
|
|
ef26a3b42d | ||
|
|
76d6ad5d8d | ||
|
|
316b91c5f5 | ||
|
|
97c181a246 | ||
|
|
62714899ff | ||
|
|
02333f8dae | ||
|
|
867374da40 | ||
|
|
7a193d3857 | ||
|
|
dac7dc2a35 | ||
|
|
a930046796 | ||
|
|
db93fbb5f7 | ||
|
|
15e173d159 | ||
|
|
43fae056d0 | ||
|
|
bf0d95369d | ||
|
|
e7ebeccd25 | ||
|
|
3e1f8f3d89 | ||
|
|
2b9843d573 | ||
|
|
9e5341a5c1 | ||
|
|
7bff71a9f5 | ||
|
|
ac572d5f84 | ||
|
|
c7b81a15f6 | ||
|
|
95258f61f4 | ||
|
|
f9f6767722 | ||
|
|
9451c184b1 | ||
|
|
ca7cd22326 | ||
|
|
7d00a6e05b | ||
|
|
3427c97f24 | ||
|
|
7a3ad31dc4 | ||
|
|
2eedcb0131 | ||
|
|
f230e51e98 | ||
|
|
63df6debdf | ||
|
|
09249530bd | ||
|
|
c1f632a146 | ||
|
|
4efceefe13 | ||
|
|
a93f7f9e73 | ||
|
|
b31e690a91 | ||
|
|
a0f2ab1f31 | ||
|
|
68ce78179f | ||
|
|
c12e9a3195 | ||
|
|
1070a29d77 | ||
|
|
8366761930 | ||
|
|
de89011ca4 | ||
|
|
a1337a2dd7 | ||
|
|
99e9dd1d93 | ||
|
|
68372606b5 | ||
|
|
bfdf55afd9 | ||
|
|
b8658d3733 | ||
|
|
83ef64079b | ||
|
|
74cee6e6b7 | ||
|
|
4e8508ad53 | ||
|
|
407710b622 | ||
|
|
907d35126e | ||
|
|
228014bec8 | ||
|
|
3de367920f | ||
|
|
055f3141f8 | ||
|
|
7a693df988 | ||
|
|
0fba89df67 | ||
|
|
c109d4e5dc | ||
|
|
654836a135 | ||
|
|
402e33a7dc | ||
|
|
e96e49e63b | ||
|
|
d9477fd0aa | ||
|
|
6e013e415d | ||
|
|
4b6ab10c5d | ||
|
|
1bb06e8507 | ||
|
|
54c2d23572 | ||
|
|
466f2cdebf | ||
|
|
6e1af3bedb | ||
|
|
8efe619e3a | ||
|
|
6b31e67dd3 | ||
|
|
bba8393af7 | ||
|
|
cf5428e103 | ||
|
|
abab0715a0 | ||
|
|
b56df8f6da | ||
|
|
2f534ddd88 | ||
|
|
024ffef50f | ||
|
|
95ff72706d | ||
|
|
1db7630d01 | ||
|
|
e08ecdc28c | ||
|
|
784103f676 | ||
|
|
98124aafe8 | ||
|
|
5b8bcb7164 | ||
|
|
e5279d3d0f | ||
|
|
26d4df4e17 | ||
|
|
dbf3a13d0f | ||
|
|
fda7ddd158 | ||
|
|
7a1890345b | ||
|
|
59959b1a5b | ||
|
|
67e2c6145c | ||
|
|
b44b98a94c | ||
|
|
cd05371ce8 | ||
|
|
492285f681 | ||
|
|
6e662223aa | ||
|
|
bdc5674ace | ||
|
|
689b5fb98b | ||
|
|
c296e9210b | ||
|
|
8ef2e4f139 | ||
|
|
5128858b1e | ||
|
|
dfee6f0ca4 | ||
|
|
f298d36c86 | ||
|
|
3fe276c02f | ||
|
|
c629200b93 | ||
|
|
476a870d6c | ||
|
|
eb8ae9dd51 | ||
|
|
d68e629a7c | ||
|
|
87e97cb85e | ||
|
|
1637975a0b | ||
|
|
2ccc5e08f2 | ||
|
|
f579039a0a | ||
|
|
a3f1175f1c | ||
|
|
d7c55b1ab2 | ||
|
|
6e4a13beec | ||
|
|
f6899e190f | ||
|
|
0c8dd096c4 | ||
|
|
55c0a2ea03 | ||
|
|
cee79bb7a6 | ||
|
|
87f7e061a0 | ||
|
|
6c56bfdc8f | ||
|
|
a65a340329 | ||
|
|
ba526df7bd | ||
|
|
52f786b923 | ||
|
|
aa2792528e | ||
|
|
cba90d6301 | ||
|
|
77d41fa179 | ||
|
|
39a0567e81 | ||
|
|
45fef69aca | ||
|
|
5f24388b04 | ||
|
|
f669380811 | ||
|
|
2989a385d7 | ||
|
|
73f1f90bf7 | ||
|
|
2007e6f81e |
@@ -13,9 +13,9 @@ AlignAfterOpenBracket: DontAlign
|
||||
AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
# AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
# AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
# AllowShortIfStatementsOnASingleLine: false
|
||||
# AllowShortLoopsOnASingleLine: false
|
||||
# AlwaysBreakAfterDefinitionReturnType: None
|
||||
# AlwaysBreakAfterReturnType: None
|
||||
@@ -76,7 +76,7 @@ IndentWidth: 4
|
||||
# IndentWrappedFunctionNames: false
|
||||
# JavaScriptQuotes: Leave
|
||||
# JavaScriptWrapImports: true
|
||||
# KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
# MacroBlockBegin: ''
|
||||
# MacroBlockEnd: ''
|
||||
# MaxEmptyLinesToKeep: 1
|
||||
@@ -112,10 +112,11 @@ UseTab: Always
|
||||
---
|
||||
### C++ specific config ###
|
||||
Language: Cpp
|
||||
Standard: Cpp03
|
||||
Standard: Cpp11
|
||||
---
|
||||
### ObjC specific config ###
|
||||
Language: ObjC
|
||||
Standard: Cpp11
|
||||
ObjCBlockIndentWidth: 4
|
||||
# ObjCSpaceAfterProperty: false
|
||||
# ObjCSpaceBeforeProtocolList: true
|
||||
@@ -123,4 +124,5 @@ ObjCBlockIndentWidth: 4
|
||||
### Java specific config ###
|
||||
Language: Java
|
||||
# BreakAfterJavaFieldAnnotations: false
|
||||
JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax']
|
||||
...
|
||||
|
||||
218
.github/workflows/ci.yml
vendored
218
.github/workflows/ci.yml
vendored
@@ -2,159 +2,129 @@ name: Continuous integration
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
name: Build (Linux, GCC)
|
||||
runs-on: ubuntu-16.04
|
||||
build:
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: 🐧 Linux (GCC)
|
||||
os: ubuntu-20.04
|
||||
platform: linux
|
||||
artifact-name: godot-cpp-linux-glibc2.31-x86_64-release
|
||||
artifact-path: bin/libgodot-cpp.linux.release.64.a
|
||||
godot_zip: Godot_v3.5-stable_linux_server.64.zip
|
||||
executable: Godot_v3.5-stable_linux_server.64
|
||||
|
||||
- name: 🏁 Windows (x86_64, MSVC)
|
||||
os: windows-2022
|
||||
platform: windows
|
||||
artifact-name: godot-cpp-windows-msvc2019-x86_64-release
|
||||
artifact-path: bin/libgodot-cpp.windows.release.64.lib
|
||||
|
||||
- name: 🏁 Windows (x86_64, MinGW)
|
||||
os: windows-2022
|
||||
platform: windows
|
||||
artifact-name: godot-cpp-linux-mingw-x86_64-release
|
||||
artifact-path: bin/libgodot-cpp.windows.release.64.a
|
||||
flags: use_mingw=yes
|
||||
|
||||
- name: 🍎 macOS (universal)
|
||||
os: macos-13
|
||||
platform: osx
|
||||
artifact-name: godot-cpp-macos-universal-release
|
||||
artifact-path: bin/libgodot-cpp.osx.release.64.a
|
||||
flags: macos_arch=universal
|
||||
godot_zip: Godot_v3.5-stable_osx.universal.zip
|
||||
executable: Godot.app/Contents/MacOS/Godot
|
||||
|
||||
- name: 🤖 Android (arm64)
|
||||
os: ubuntu-20.04
|
||||
platform: android
|
||||
artifact-name: godot-cpp-android-arm64-release
|
||||
artifact-path: bin/libgodot-cpp.android.release.arm64v8.a
|
||||
flags: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME android_arch=arm64v8
|
||||
|
||||
- name: 🍏 iOS (arm64)
|
||||
os: macos-13
|
||||
platform: ios
|
||||
artifact-name: godot-cpp-ios-arm64-release
|
||||
artifact-path: bin/libgodot-cpp.ios.release.arm64.a
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Set up Python (for SCons)
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.9.1'
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Linux dependencies
|
||||
if: ${{ matrix.platform == 'linux' }}
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -qqq build-essential pkg-config
|
||||
|
||||
- name: Install scons
|
||||
run: |
|
||||
python -m pip install scons
|
||||
curl -LO https://downloads.tuxfamily.org/godotengine/3.2.3/Godot_v3.2.3-stable_linux_server.64.zip
|
||||
unzip Godot_v3.2.3-stable_linux_server.64.zip
|
||||
|
||||
- name: Build godot-cpp
|
||||
run: |
|
||||
scons target=release generate_bindings=yes -j $(nproc)
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2.2.1
|
||||
- name: Windows dependency (MinGW)
|
||||
if: ${{ matrix.platform == 'windows' }}
|
||||
uses: egor-tensin/setup-mingw@v2
|
||||
with:
|
||||
name: godot-cpp-linux-glibc2.23-x86_64-release
|
||||
path: bin/libgodot-cpp.linux.release.64.a
|
||||
if-no-files-found: error
|
||||
version: 12.2.0
|
||||
|
||||
- name: Build test GDNative library
|
||||
- name: Build godot-cpp (debug)
|
||||
run: |
|
||||
scons target=release platform=linux bits=64 -j $(nproc) -C test
|
||||
scons platform=${{ matrix.platform }} target=debug generate_bindings=yes ${{ matrix.flags }}
|
||||
|
||||
- name: Build test without rebuilding godot-cpp (debug)
|
||||
run: |
|
||||
cd test
|
||||
scons platform=${{ matrix.platform }} target=debug ${{ matrix.flags }} build_library=no
|
||||
|
||||
- name: Build test and godot-cpp (release)
|
||||
run: |
|
||||
cd test
|
||||
scons platform=${{ matrix.platform }} target=release ${{ matrix.flags }}
|
||||
|
||||
- name: Run test GDNative library
|
||||
if: ${{ matrix.platform == 'linux' || matrix.platform == 'osx' }}
|
||||
run: |
|
||||
./Godot_v3.2.3-stable_linux_server.64 --path test -s script.gd
|
||||
|
||||
windows-msvc:
|
||||
name: Build (Windows, MSVC)
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Set up Python (for SCons)
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9.1'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install scons
|
||||
|
||||
- name: Build godot-cpp
|
||||
run: |
|
||||
scons target=release generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS
|
||||
curl -LO https://downloads.tuxfamily.org/godotengine/3.5/${{ matrix.godot_zip }}
|
||||
unzip ${{ matrix.godot_zip }}
|
||||
./${{ matrix.executable }} --path test -s script.gd
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2.2.1
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: godot-cpp-windows-msvc2019-x86_64-release
|
||||
path: bin/libgodot-cpp.windows.release.64.lib
|
||||
name: ${{ matrix.artifact-name }}
|
||||
path: ${{ matrix.artifact-path }}
|
||||
if-no-files-found: error
|
||||
|
||||
windows-mingw:
|
||||
name: Build (Windows, MinGW)
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Set up Python (for SCons)
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9.1'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install scons
|
||||
|
||||
- name: Build godot-cpp
|
||||
# Install GCC from Scoop as the default supplied GCC doesn't work ("Error 1").
|
||||
run: |
|
||||
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
||||
scoop install gcc
|
||||
g++ --version
|
||||
gcc --version
|
||||
scons target=release generate_bindings=yes use_mingw=yes -j $env:NUMBER_OF_PROCESSORS
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2.2.1
|
||||
with:
|
||||
name: godot-cpp-linux-mingw-x86_64-release
|
||||
path: bin/libgodot-cpp.windows.release.64.a
|
||||
if-no-files-found: error
|
||||
|
||||
macos:
|
||||
name: Build (macOS, Clang)
|
||||
runs-on: macos-10.15
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Set up Python (for SCons)
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.9.1'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install scons
|
||||
curl -LO https://downloads.tuxfamily.org/godotengine/3.2.3/Godot_v3.2.3-stable_osx.64.zip
|
||||
unzip Godot_v3.2.3-stable_osx.64.zip
|
||||
|
||||
- name: Build godot-cpp
|
||||
run: |
|
||||
scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu)
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2.2.1
|
||||
with:
|
||||
name: godot-cpp-macos-x86_64-release
|
||||
path: bin/libgodot-cpp.osx.release.64.a
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Build test GDNative library
|
||||
run: |
|
||||
scons target=release platform=osx bits=64 -j $(sysctl -n hw.logicalcpu) -C test
|
||||
|
||||
- name: Run test GDNative library
|
||||
run: |
|
||||
./Godot.app/Contents/MacOS/Godot --path test -s script.gd
|
||||
|
||||
static-checks:
|
||||
name: Static Checks (clang-format)
|
||||
runs-on: ubuntu-16.04
|
||||
name: 📊 Static Checks (clang-format)
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Make apt sources.list use the default Ubuntu repositories
|
||||
run: |
|
||||
sudo rm -f /etc/apt/sources.list.d/*
|
||||
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
|
||||
sudo apt-get update
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get install clang-format-8
|
||||
sudo apt-get install -qq dos2unix recode clang-format-11
|
||||
sudo update-alternatives --remove-all clang-format
|
||||
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
|
||||
|
||||
- name: Style checks via clang-format
|
||||
run: |
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,11 +1,14 @@
|
||||
# Misc
|
||||
gen/*
|
||||
logs/*
|
||||
*.log
|
||||
|
||||
# Binaries
|
||||
*.o
|
||||
*.os
|
||||
*.so
|
||||
*.obj
|
||||
*.bc
|
||||
*.pyc
|
||||
*.dblite
|
||||
*.pdb
|
||||
|
||||
@@ -1,44 +1,46 @@
|
||||
# cmake arguments
|
||||
# CMAKE_BUILD_TYPE: Compilation target (Debug or Release defaults to Debug)
|
||||
#
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
# Android cmake arguments
|
||||
# CMAKE_TOOLCHAIN_FILE: The path to the android cmake toolchain ($ANDROID_NDK/build/cmake/android.toolchain.cmake)
|
||||
# ANDROID_NDK: The path to the android ndk root folder
|
||||
# ANDROID_TOOLCHAIN_NAME: The android toolchain (arm-linux-androideabi-4.9 or aarch64-linux-android-4.9 or x86-4.9 or x86_64-4.9)
|
||||
# ANDROID_PLATFORM: The android platform version (android-23)
|
||||
# More info here: https://godot.readthedocs.io/en/latest/development/compiling/compiling_for_android.html
|
||||
#
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
#
|
||||
# Builds a debug version:
|
||||
# cmake .
|
||||
# cmake --build .
|
||||
#
|
||||
#
|
||||
# Builds a release version with clang
|
||||
# CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" .
|
||||
# cmake --build .
|
||||
#
|
||||
#
|
||||
# Builds an android armeabi-v7a debug version:
|
||||
# cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake -DANDROID_NDK=$ANDROID_NDK \
|
||||
# -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DANDROID_PLATFORM=android-23 -DCMAKE_BUILD_TYPE=Debug .
|
||||
# cmake --build .
|
||||
#
|
||||
#
|
||||
# Protip
|
||||
# Generate the buildfiles in a sub directory to not clutter the root directory with build files:
|
||||
# mkdir build && cd build && cmake -G "Unix Makefiles" .. && cmake --build .
|
||||
#
|
||||
#
|
||||
# Todo
|
||||
# Test build for Windows, Mac and mingw.
|
||||
|
||||
project(godot-cpp)
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
option(GENERATE_TEMPLATE_GET_NODE "Generate a template version of the Node class's get_node." ON)
|
||||
|
||||
# Change the output directory to the bin directory
|
||||
set(BUILD_PATH ${CMAKE_SOURCE_DIR}/bin)
|
||||
set(BUILD_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_PATH}")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BUILD_PATH}")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BUILD_PATH}")
|
||||
@@ -50,7 +52,7 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${BUILD_PATH}")
|
||||
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${BUILD_PATH}")
|
||||
|
||||
# Default build type is Debug in the SConstruct
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "")
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif()
|
||||
|
||||
@@ -65,6 +67,13 @@ set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if(NOT DEFINED BITS)
|
||||
set(BITS 32)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(BITS 64)
|
||||
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
endif()
|
||||
|
||||
# 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/api.json" CACHE STRING "")
|
||||
@@ -95,21 +104,17 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
# string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
#endif()
|
||||
|
||||
else()
|
||||
|
||||
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
# using Clang
|
||||
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
# using GCC and maybe MinGW?
|
||||
|
||||
else() # GCC/Clang
|
||||
set(GODOT_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,-R,'$$ORIGIN'")
|
||||
|
||||
# Hmm.. maybe to strikt?
|
||||
set(GODOT_COMPILE_FLAGS "-fPIC -g -Wwrite-strings")
|
||||
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set(GODOT_COMPILE_FLAGS "-fPIC")
|
||||
endif()
|
||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -g -Wwrite-strings")
|
||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wchar-subscripts -Wcomment -Wdisabled-optimization")
|
||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wformat -Wformat=2 -Wformat-security -Wformat-y2k")
|
||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wimport -Winit-self -Winline -Winvalid-pch -Werror")
|
||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wlong-long -Wmissing-braces -Wmissing-format-attribute")
|
||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wmissing-braces -Wmissing-format-attribute")
|
||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpointer-arith")
|
||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wredundant-decls -Wreturn-type -Wsequence-point")
|
||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wswitch -Wswitch-enum -Wtrigraphs")
|
||||
@@ -131,24 +136,53 @@ else()
|
||||
endif()
|
||||
|
||||
# Generate source from the bindings file
|
||||
find_package(Python3 3.4 REQUIRED) # pathlib should be present
|
||||
if(GENERATE_TEMPLATE_GET_NODE)
|
||||
set(GENERATE_BINDING_PARAMETERS "True")
|
||||
else()
|
||||
set(GENERATE_BINDING_PARAMETERS "False")
|
||||
endif()
|
||||
|
||||
message(STATUS "Generating Bindings")
|
||||
execute_process(COMMAND "python" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_CUSTOM_API_FILE}\")"
|
||||
execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.print_file_list(\"${GODOT_CUSTOM_API_FILE}\", \"${CMAKE_CURRENT_BINARY_DIR}\", headers=True)"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE GENERATION_RESULT
|
||||
OUTPUT_VARIABLE GENERATION_OUTPUT)
|
||||
message(STATUS ${GENERATION_RESULT} ${GENERATION_OUTPUT})
|
||||
RESULT_VARIABLE HEADERS_FILE_LIST_RESULT
|
||||
OUTPUT_VARIABLE HEADERS_FILE_LIST
|
||||
)
|
||||
set(HEADERS_FILE_LIST ${HEADERS_FILE_LIST})
|
||||
|
||||
execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.print_file_list(\"${GODOT_CUSTOM_API_FILE}\", \"${CMAKE_CURRENT_BINARY_DIR}\", sources=True)"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
RESULT_VARIABLE SOURCES_FILE_LIST_RESULT
|
||||
OUTPUT_VARIABLE SOURCES_FILE_LIST
|
||||
)
|
||||
set(SOURCES_FILE_LIST ${SOURCES_FILE_LIST})
|
||||
|
||||
add_custom_command(OUTPUT ${HEADERS_FILE_LIST} ${SOURCES_FILE_LIST}
|
||||
COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_CUSTOM_API_FILE}\", \"${GENERATE_BINDING_PARAMETERS}\", \"${CMAKE_CURRENT_BINARY_DIR}\")"
|
||||
VERBATIM
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
MAIN_DEPENDENCY ${GODOT_CUSTOM_API_FILE}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/binding_generator.py
|
||||
COMMENT Generating Bindings
|
||||
)
|
||||
|
||||
# Get Sources
|
||||
file(GLOB_RECURSE SOURCES src/*.c**)
|
||||
file(GLOB_RECURSE HEADERS include/*.h**)
|
||||
|
||||
# Define our godot-cpp library
|
||||
add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS})
|
||||
add_library(${PROJECT_NAME}
|
||||
${SOURCES}
|
||||
${SOURCES_FILE_LIST}
|
||||
${HEADERS}
|
||||
${HEADERS_FILE_LIST}
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
include
|
||||
include/core
|
||||
include/gen
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/gen/
|
||||
)
|
||||
|
||||
# Put godot headers as SYSTEM PUBLIC to exclude warnings from irrelevant headers
|
||||
@@ -163,13 +197,8 @@ 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)
|
||||
string(TOLOWER "${CMAKE_SYSTEM_NAME}" SYSTEM_NAME)
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
|
||||
|
||||
if(ANDROID)
|
||||
# Added the android abi after system name
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# MIT License
|
||||
|
||||
Copyright (c) 2017-2020 GodotNativeTools
|
||||
Copyright (c) 2017-2022 Godot Engine contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
2
Makefile
2
Makefile
@@ -3,7 +3,7 @@ HEADERS = godot-headers
|
||||
TARGET = debug
|
||||
USE_CLANG = no
|
||||
|
||||
BASE = scons use_llvm=$(USE_CLANG) generate_bindings=$(GENERATE_BINDINGS) target=$(TARGET) headers=$(HEADERS) -j4
|
||||
BASE = scons use_llvm=$(USE_CLANG) generate_bindings=$(GENERATE_BINDINGS) target=$(TARGET) headers=$(HEADERS)
|
||||
LINUX = $(BASE) platform=linux
|
||||
WINDOWS = $(BASE) platform=windows
|
||||
OSX = $(BASE) platform=osx
|
||||
|
||||
51
README.md
51
README.md
@@ -1,27 +1,41 @@
|
||||
# godot-cpp
|
||||
|
||||
**C++ bindings for the Godot script API.**
|
||||
|
||||
The instructions below feature the new NativeScript 1.1 class structure and will only work for modules created for Godot 3.1 and later. Use the following branches for older implementations:
|
||||
|
||||
Version | Branch
|
||||
--- | ---
|
||||
**Godot 3.0 Nativescript 1.0** | [3.0](https://github.com/godotengine/godot-cpp/tree/3.0)
|
||||
**Godot 3.1 Nativescript 1.0** | [nativescript-1.0](https://github.com/godotengine/godot-cpp/tree/nativescript-1.0)
|
||||
|
||||
## Table of contents
|
||||
This repository contains the *C++ bindings* for the [**Godot Engine**](https://github.com/godotengine/godot)'s GDNative API.
|
||||
|
||||
- [**Versioning**](#versioning)
|
||||
- [**Contributing**](#contributing)
|
||||
- [**Getting Started**](#getting-started)
|
||||
- [**Creating a simple class**](#creating-a-simple-class)
|
||||
|
||||
## Versioning
|
||||
|
||||
This repositories follows the same branch versioning as the main [Godot Engine
|
||||
repository](https://github.com/godotengine/godot):
|
||||
|
||||
- `master` tracks the current development branch.
|
||||
- `3.x` tracks the development of the next 3.x minor release.
|
||||
- Other versioned branches (e.g. `3.3`, `3.2`) track the latest stable release
|
||||
in the corresponding branch.
|
||||
|
||||
Stable releases are also tagged on this repository:
|
||||
[**Tags**](https://github.com/godotengine/godot-cpp/tags).
|
||||
|
||||
**For any project built against a stable release of Godot, we recommend using
|
||||
this repository as a Git submodule, checking out the specific tag matching your
|
||||
Godot version.**
|
||||
|
||||
> As the `master` and `3.x` branches are constantly getting updates, if you are
|
||||
> using `godot-cpp` against a more current version of Godot, see the instructions
|
||||
> in [**godot-headers**](https://github.com/godotengine/godot-headers) for
|
||||
> updating the relevant files.
|
||||
|
||||
## Contributing
|
||||
|
||||
We greatly appreciate help in maintaining and extending this project. If you
|
||||
wish to help out, ensure you have an account on GitHub and create a "fork" of
|
||||
this repository. Rémi "Akien" Verschelde wrote an excellent bit of documentation
|
||||
for the main Godot project on this:
|
||||
[Pull request workflow](https://docs.godotengine.org/en/3.0/community/contributing/pr_workflow.html)
|
||||
[Pull request workflow](https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html)
|
||||
|
||||
Please install clang-format and copy the files in `misc/hooks` into `.git/hooks`
|
||||
so formatting is done before your changes are submitted.
|
||||
@@ -275,9 +289,18 @@ Godot headers repository for more information.
|
||||
|
||||
#### HTML5
|
||||
|
||||
GDNative isn't supported on the HTML5 platform yet. Support is being tracked on
|
||||
[issue #12243](https://github.com/godotengine/godot/issues/12243) in the main
|
||||
Godot repository.
|
||||
GDNative is supported on [specific exports](https://docs.godotengine.org/en/latest/tutorials/export/exporting_for_web.html#export-options) for the HTML5 platform since Godot `3.3`. Linking webassembly modules is currently underspecified in the standard, but [emscripten](https://emscripten.org/), which Godot uses to build the HTML5 version, implements its own linking system.
|
||||
|
||||
To build GDNative libraries, you will need a recent version of [Emscripten](https://emscripten.org/).
|
||||
|
||||
```bash
|
||||
cd SimpleLibrary
|
||||
emcc -o bin/libtest.wasm -g -O3 -s SIDE_MODULE=1 src/init.cpp godot-cpp/bin/<name of the godot-cpp> -Igodot-cpp/include -Igodot-cpp/include/core -Igodot-cpp/include/gen -Igodot-cpp/godot-headers
|
||||
```
|
||||
|
||||
You'll need to replace `<name of the godot-cpp>` with the file that was created in [**Compiling the cpp bindings library**](#compiling-the-cpp-bindings-library).
|
||||
|
||||
This creates the file `libtest.so` in your `SimpleLibrary/bin` directory.
|
||||
|
||||
### Creating `.gdnlib` and `.gdns` files
|
||||
|
||||
|
||||
667
SConstruct
667
SConstruct
@@ -5,24 +5,35 @@ import sys
|
||||
import subprocess
|
||||
|
||||
if sys.version_info < (3,):
|
||||
|
||||
def decode_utf8(x):
|
||||
return x
|
||||
|
||||
else:
|
||||
import codecs
|
||||
|
||||
def decode_utf8(x):
|
||||
return codecs.utf_8_decode(x)[0]
|
||||
|
||||
|
||||
# Workaround for MinGW. See:
|
||||
# http://www.scons.org/wiki/LongCmdLinesOnWin32
|
||||
if (os.name=="nt"):
|
||||
if os.name == "nt":
|
||||
import subprocess
|
||||
|
||||
def mySubProcess(cmdline,env):
|
||||
#print "SPAWNED : " + cmdline
|
||||
def mySubProcess(cmdline, env):
|
||||
# print "SPAWNED : " + cmdline
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env)
|
||||
proc = subprocess.Popen(
|
||||
cmdline,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
startupinfo=startupinfo,
|
||||
shell=False,
|
||||
env=env,
|
||||
)
|
||||
data, err = proc.communicate()
|
||||
rv = proc.wait()
|
||||
if rv:
|
||||
@@ -33,383 +44,493 @@ if (os.name=="nt"):
|
||||
|
||||
def mySpawn(sh, escape, cmd, args, env):
|
||||
|
||||
newargs = ' '.join(args[1:])
|
||||
newargs = " ".join(args[1:])
|
||||
cmdline = cmd + " " + newargs
|
||||
|
||||
rv=0
|
||||
if len(cmdline) > 32000 and cmd.endswith("ar") :
|
||||
rv = 0
|
||||
if len(cmdline) > 32000 and cmd.endswith("ar"):
|
||||
cmdline = cmd + " " + args[1] + " " + args[2] + " "
|
||||
for i in range(3,len(args)) :
|
||||
rv = mySubProcess( cmdline + args[i], env )
|
||||
if rv :
|
||||
for i in range(3, len(args)):
|
||||
rv = mySubProcess(cmdline + args[i], env)
|
||||
if rv:
|
||||
break
|
||||
else:
|
||||
rv = mySubProcess( cmdline, env )
|
||||
rv = mySubProcess(cmdline, env)
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
def add_sources(sources, dir, extension):
|
||||
for f in os.listdir(dir):
|
||||
if f.endswith('.' + extension):
|
||||
sources.append(dir + '/' + f)
|
||||
if f.endswith("." + extension):
|
||||
sources.append(dir + "/" + f)
|
||||
|
||||
|
||||
# Try to detect the host platform automatically.
|
||||
# This is used if no `platform` argument is passed
|
||||
if sys.platform.startswith('linux'):
|
||||
host_platform = 'linux'
|
||||
elif sys.platform == 'darwin':
|
||||
host_platform = 'osx'
|
||||
elif sys.platform == 'win32' or sys.platform == 'msys':
|
||||
host_platform = 'windows'
|
||||
if sys.platform.startswith("linux"):
|
||||
host_platform = "linux"
|
||||
elif sys.platform.startswith("freebsd"):
|
||||
host_platform = "freebsd"
|
||||
elif sys.platform == "darwin":
|
||||
host_platform = "osx"
|
||||
elif sys.platform == "win32" or sys.platform == "msys":
|
||||
host_platform = "windows"
|
||||
else:
|
||||
raise ValueError(
|
||||
'Could not detect platform automatically, please specify with '
|
||||
'platform=<platform>'
|
||||
)
|
||||
raise ValueError("Could not detect platform automatically, please specify with platform=<platform>")
|
||||
|
||||
env = Environment(ENV = os.environ)
|
||||
env = Environment(ENV=os.environ)
|
||||
|
||||
is64 = sys.maxsize > 2**32
|
||||
# Default num_jobs to local cpu count if not user specified.
|
||||
# SCons has a peculiarity where user-specified options won't be overridden
|
||||
# by SetOption, so we can rely on this to know if we should use our default.
|
||||
initial_num_jobs = env.GetOption("num_jobs")
|
||||
altered_num_jobs = initial_num_jobs + 1
|
||||
env.SetOption("num_jobs", altered_num_jobs)
|
||||
# os.cpu_count() requires Python 3.4+.
|
||||
if hasattr(os, "cpu_count") and env.GetOption("num_jobs") == altered_num_jobs:
|
||||
cpu_count = os.cpu_count()
|
||||
if cpu_count is None:
|
||||
print("Couldn't auto-detect CPU count to configure build parallelism. Specify it with the -j argument.")
|
||||
else:
|
||||
safer_cpu_count = cpu_count if cpu_count <= 4 else cpu_count - 1
|
||||
print(
|
||||
"Auto-detected %d CPU cores available for build parallelism. Using %d cores by default. You can override it with the -j argument."
|
||||
% (cpu_count, safer_cpu_count)
|
||||
)
|
||||
env.SetOption("num_jobs", safer_cpu_count)
|
||||
|
||||
is64 = sys.maxsize > 2 ** 32
|
||||
if (
|
||||
env['TARGET_ARCH'] == 'amd64' or
|
||||
env['TARGET_ARCH'] == 'emt64' or
|
||||
env['TARGET_ARCH'] == 'x86_64' or
|
||||
env['TARGET_ARCH'] == 'arm64-v8a'
|
||||
env["TARGET_ARCH"] == "amd64"
|
||||
or env["TARGET_ARCH"] == "emt64"
|
||||
or env["TARGET_ARCH"] == "x86_64"
|
||||
or env["TARGET_ARCH"] == "arm64-v8a"
|
||||
):
|
||||
is64 = True
|
||||
|
||||
opts = Variables([], ARGUMENTS)
|
||||
opts.Add(EnumVariable(
|
||||
'platform',
|
||||
'Target platform',
|
||||
host_platform,
|
||||
allowed_values=('linux', 'osx', 'windows', 'android', 'ios'),
|
||||
ignorecase=2
|
||||
))
|
||||
opts.Add(EnumVariable(
|
||||
'bits',
|
||||
'Target platform bits',
|
||||
'64' if is64 else '32',
|
||||
('32', '64')
|
||||
))
|
||||
opts.Add(BoolVariable(
|
||||
'use_llvm',
|
||||
'Use the LLVM compiler - only effective when targeting Linux',
|
||||
False
|
||||
))
|
||||
opts.Add(BoolVariable(
|
||||
'use_mingw',
|
||||
'Use the MinGW compiler instead of MSVC - only effective on Windows',
|
||||
False
|
||||
))
|
||||
opts.Add(
|
||||
EnumVariable(
|
||||
"platform",
|
||||
"Target platform",
|
||||
host_platform,
|
||||
allowed_values=("linux", "freebsd", "osx", "windows", "android", "ios", "javascript"),
|
||||
ignorecase=2,
|
||||
)
|
||||
)
|
||||
opts.Add(EnumVariable("bits", "Target platform bits", "64" if is64 else "32", ("32", "64")))
|
||||
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler - only effective when targeting Linux or FreeBSD", False))
|
||||
opts.Add(BoolVariable("use_mingw", "Use the MinGW compiler instead of MSVC - only effective on Windows", False))
|
||||
# Must be the same setting as used for cpp_bindings
|
||||
opts.Add(EnumVariable(
|
||||
'target',
|
||||
'Compilation target',
|
||||
'debug',
|
||||
allowed_values=('debug', 'release'),
|
||||
ignorecase=2
|
||||
))
|
||||
opts.Add(PathVariable(
|
||||
'headers_dir',
|
||||
'Path to the directory containing Godot headers',
|
||||
'godot-headers',
|
||||
PathVariable.PathIsDir
|
||||
))
|
||||
opts.Add(PathVariable(
|
||||
'custom_api_file',
|
||||
'Path to a custom JSON API file',
|
||||
None,
|
||||
PathVariable.PathIsFile
|
||||
))
|
||||
opts.Add(BoolVariable(
|
||||
'generate_bindings',
|
||||
'Generate GDNative API bindings',
|
||||
False
|
||||
))
|
||||
opts.Add(EnumVariable(
|
||||
'android_arch',
|
||||
'Target Android architecture',
|
||||
'armv7',
|
||||
['armv7','arm64v8','x86','x86_64']
|
||||
))
|
||||
opts.Add(EnumVariable("target", "Compilation target", "debug", allowed_values=("debug", "release"), ignorecase=2))
|
||||
opts.Add(
|
||||
'macos_deployment_target',
|
||||
'macOS deployment target',
|
||||
'default'
|
||||
PathVariable(
|
||||
"headers_dir",
|
||||
"Path to the directory containing Godot headers",
|
||||
"godot-headers",
|
||||
PathVariable.PathIsDir,
|
||||
)
|
||||
)
|
||||
opts.Add(EnumVariable(
|
||||
'ios_arch',
|
||||
'Target iOS architecture',
|
||||
'arm64',
|
||||
['armv7', 'arm64', 'x86_64']
|
||||
))
|
||||
opts.Add(BoolVariable(
|
||||
'ios_simulator',
|
||||
'Target iOS Simulator',
|
||||
False
|
||||
))
|
||||
opts.Add(PathVariable("custom_api_file", "Path to a custom JSON API file", None, PathVariable.PathIsFile))
|
||||
opts.Add(
|
||||
'IPHONEPATH',
|
||||
'Path to iPhone toolchain',
|
||||
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain',
|
||||
EnumVariable(
|
||||
"generate_bindings",
|
||||
"Generate GDNative API bindings",
|
||||
"auto",
|
||||
allowed_values=["yes", "no", "auto", "true"],
|
||||
ignorecase=2,
|
||||
)
|
||||
)
|
||||
opts.Add(
|
||||
'android_api_level',
|
||||
'Target Android API level',
|
||||
'18' if ARGUMENTS.get("android_arch", 'armv7') in ['armv7', 'x86'] else '21'
|
||||
EnumVariable(
|
||||
"android_arch",
|
||||
"Target Android architecture",
|
||||
"armv7",
|
||||
["armv7", "arm64v8", "x86", "x86_64"],
|
||||
)
|
||||
)
|
||||
opts.Add("macos_deployment_target", "macOS deployment target", "default")
|
||||
opts.Add("macos_sdk_path", "macOS SDK path", "")
|
||||
opts.Add(EnumVariable("macos_arch", "Target macOS architecture", "universal", ["universal", "x86_64", "arm64"]))
|
||||
opts.Add(EnumVariable("ios_arch", "Target iOS architecture", "arm64", ["armv7", "arm64", "x86_64"]))
|
||||
opts.Add(BoolVariable("ios_simulator", "Target iOS Simulator", False))
|
||||
opts.Add(
|
||||
"IPHONEPATH",
|
||||
"Path to iPhone toolchain",
|
||||
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain",
|
||||
)
|
||||
opts.Add(
|
||||
'ANDROID_NDK_ROOT',
|
||||
'Path to your Android NDK installation. By default, uses ANDROID_NDK_ROOT from your defined environment variables.',
|
||||
os.environ.get("ANDROID_NDK_ROOT", None)
|
||||
"android_api_level",
|
||||
"Target Android API level",
|
||||
"18" if ARGUMENTS.get("android_arch", "armv7") in ["armv7", "x86"] else "21",
|
||||
)
|
||||
opts.Add(BoolVariable(
|
||||
'generate_template_get_node',
|
||||
"Generate a template version of the Node class's get_node.",
|
||||
True
|
||||
))
|
||||
opts.Add(
|
||||
"ANDROID_NDK_ROOT",
|
||||
"Path to your Android NDK installation. By default, uses ANDROID_NDK_ROOT from your defined environment variables.",
|
||||
os.environ.get("ANDROID_NDK_ROOT", None),
|
||||
)
|
||||
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.Update(env)
|
||||
Help(opts.GenerateHelpText(env))
|
||||
|
||||
# Detect and print a warning listing unknown SCons variables to ease troubleshooting.
|
||||
unknown = opts.UnknownVariables()
|
||||
if unknown:
|
||||
print("WARNING: Unknown SCons variables were passed and will be ignored:")
|
||||
for item in unknown.items():
|
||||
print(" " + item[0] + "=" + item[1])
|
||||
|
||||
# This makes sure to keep the session environment variables on Windows.
|
||||
# This way, you can run SCons in a Visual Studio 2017 prompt and it will find
|
||||
# all the required tools
|
||||
if host_platform == 'windows' and env['platform'] != 'android':
|
||||
if env['bits'] == '64':
|
||||
env = Environment(TARGET_ARCH='amd64')
|
||||
elif env['bits'] == '32':
|
||||
env = Environment(TARGET_ARCH='x86')
|
||||
if host_platform == "windows" and env["platform"] != "android":
|
||||
if env["bits"] == "64":
|
||||
env = Environment(TARGET_ARCH="amd64")
|
||||
elif env["bits"] == "32":
|
||||
env = Environment(TARGET_ARCH="x86")
|
||||
|
||||
opts.Update(env)
|
||||
|
||||
if env['platform'] == 'linux':
|
||||
if env['use_llvm']:
|
||||
env['CXX'] = 'clang++'
|
||||
# Require C++14
|
||||
if host_platform == "windows" and env["platform"] == "windows" and not env["use_mingw"]:
|
||||
# MSVC
|
||||
env.Append(CCFLAGS=["/std:c++14"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-std=c++14"])
|
||||
|
||||
env.Append(CCFLAGS=['-fPIC', '-std=c++14', '-Wwrite-strings'])
|
||||
if env["platform"] == "linux" or env["platform"] == "freebsd":
|
||||
if env["use_llvm"]:
|
||||
env["CXX"] = "clang++"
|
||||
|
||||
env.Append(CCFLAGS=["-fPIC", "-Wwrite-strings"])
|
||||
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
|
||||
|
||||
if env['target'] == 'debug':
|
||||
env.Append(CCFLAGS=['-Og', '-g'])
|
||||
elif env['target'] == 'release':
|
||||
env.Append(CCFLAGS=['-O3'])
|
||||
if env["target"] == "debug":
|
||||
env.Append(CCFLAGS=["-Og", "-g"])
|
||||
elif env["target"] == "release":
|
||||
env.Append(CCFLAGS=["-O3"])
|
||||
|
||||
if env['bits'] == '64':
|
||||
env.Append(CCFLAGS=['-m64'])
|
||||
env.Append(LINKFLAGS=['-m64'])
|
||||
elif env['bits'] == '32':
|
||||
env.Append(CCFLAGS=['-m32'])
|
||||
env.Append(LINKFLAGS=['-m32'])
|
||||
if env["bits"] == "64":
|
||||
env.Append(CCFLAGS=["-m64"])
|
||||
env.Append(LINKFLAGS=["-m64"])
|
||||
elif env["bits"] == "32":
|
||||
env.Append(CCFLAGS=["-m32"])
|
||||
env.Append(LINKFLAGS=["-m32"])
|
||||
|
||||
elif env['platform'] == 'osx':
|
||||
elif env["platform"] == "osx":
|
||||
# Use Clang on macOS by default
|
||||
env['CXX'] = 'clang++'
|
||||
env["CXX"] = "clang++"
|
||||
|
||||
if env['bits'] == '32':
|
||||
raise ValueError(
|
||||
'Only 64-bit builds are supported for the macOS target.'
|
||||
)
|
||||
if env["bits"] == "32":
|
||||
raise ValueError("Only 64-bit builds are supported for the macOS target.")
|
||||
|
||||
env.Append(CCFLAGS=['-std=c++14', '-arch', 'x86_64'])
|
||||
|
||||
if env['macos_deployment_target'] != 'default':
|
||||
env.Append(CCFLAGS=['-mmacosx-version-min=' + env['macos_deployment_target']])
|
||||
|
||||
env.Append(LINKFLAGS=[
|
||||
'-arch',
|
||||
'x86_64',
|
||||
'-framework',
|
||||
'Cocoa',
|
||||
'-Wl,-undefined,dynamic_lookup',
|
||||
])
|
||||
|
||||
if env['target'] == 'debug':
|
||||
env.Append(CCFLAGS=['-Og', '-g'])
|
||||
elif env['target'] == 'release':
|
||||
env.Append(CCFLAGS=['-O3'])
|
||||
|
||||
elif env['platform'] == 'ios':
|
||||
if env['ios_simulator']:
|
||||
sdk_name = 'iphonesimulator'
|
||||
env.Append(CCFLAGS=['-mios-simulator-version-min=10.0'])
|
||||
env['LIBSUFFIX'] = ".simulator" + env['LIBSUFFIX']
|
||||
if env["macos_arch"] == "universal":
|
||||
env.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
|
||||
env.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"])
|
||||
else:
|
||||
sdk_name = 'iphoneos'
|
||||
env.Append(CCFLAGS=['-miphoneos-version-min=10.0'])
|
||||
env.Append(LINKFLAGS=["-arch", env["macos_arch"]])
|
||||
env.Append(CCFLAGS=["-arch", env["macos_arch"]])
|
||||
|
||||
if env["macos_deployment_target"] != "default":
|
||||
env.Append(CCFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
|
||||
env.Append(LINKFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
|
||||
|
||||
if env["macos_sdk_path"]:
|
||||
env.Append(CCFLAGS=["-isysroot", env["macos_sdk_path"]])
|
||||
env.Append(LINKFLAGS=["-isysroot", env["macos_sdk_path"]])
|
||||
|
||||
env.Append(LINKFLAGS=["-Wl,-undefined,dynamic_lookup"])
|
||||
|
||||
if env["target"] == "debug":
|
||||
env.Append(CCFLAGS=["-Og", "-g"])
|
||||
elif env["target"] == "release":
|
||||
env.Append(CCFLAGS=["-O3"])
|
||||
|
||||
elif env["platform"] == "ios":
|
||||
if env["ios_simulator"]:
|
||||
sdk_name = "iphonesimulator"
|
||||
env.Append(CCFLAGS=["-mios-simulator-version-min=10.0"])
|
||||
else:
|
||||
sdk_name = "iphoneos"
|
||||
env.Append(CCFLAGS=["-miphoneos-version-min=10.0"])
|
||||
|
||||
try:
|
||||
sdk_path = decode_utf8(subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip())
|
||||
sdk_path = decode_utf8(subprocess.check_output(["xcrun", "--sdk", sdk_name, "--show-sdk-path"]).strip())
|
||||
except (subprocess.CalledProcessError, OSError):
|
||||
raise ValueError("Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name))
|
||||
|
||||
compiler_path = env['IPHONEPATH'] + '/usr/bin/'
|
||||
env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH']
|
||||
compiler_path = env["IPHONEPATH"] + "/usr/bin/"
|
||||
env["ENV"]["PATH"] = env["IPHONEPATH"] + "/Developer/usr/bin/:" + env["ENV"]["PATH"]
|
||||
|
||||
env['CC'] = compiler_path + 'clang'
|
||||
env['CXX'] = compiler_path + 'clang++'
|
||||
env['AR'] = compiler_path + 'ar'
|
||||
env['RANLIB'] = compiler_path + 'ranlib'
|
||||
env["CC"] = compiler_path + "clang"
|
||||
env["CXX"] = compiler_path + "clang++"
|
||||
env["AR"] = compiler_path + "ar"
|
||||
env["RANLIB"] = compiler_path + "ranlib"
|
||||
env["SHLIBSUFFIX"] = ".dylib"
|
||||
|
||||
env.Append(CCFLAGS=['-std=c++14', '-arch', env['ios_arch'], '-isysroot', sdk_path])
|
||||
env.Append(LINKFLAGS=[
|
||||
'-arch',
|
||||
env['ios_arch'],
|
||||
'-framework',
|
||||
'Cocoa',
|
||||
'-Wl,-undefined,dynamic_lookup',
|
||||
'-isysroot', sdk_path,
|
||||
'-F' + sdk_path
|
||||
])
|
||||
env.Append(CCFLAGS=["-arch", env["ios_arch"], "-isysroot", sdk_path])
|
||||
env.Append(
|
||||
LINKFLAGS=[
|
||||
"-arch",
|
||||
env["ios_arch"],
|
||||
"-Wl,-undefined,dynamic_lookup",
|
||||
"-isysroot",
|
||||
sdk_path,
|
||||
"-F" + sdk_path,
|
||||
]
|
||||
)
|
||||
|
||||
if env['target'] == 'debug':
|
||||
env.Append(CCFLAGS=['-Og', '-g'])
|
||||
elif env['target'] == 'release':
|
||||
env.Append(CCFLAGS=['-O3'])
|
||||
if env["target"] == "debug":
|
||||
env.Append(CCFLAGS=["-Og", "-g"])
|
||||
elif env["target"] == "release":
|
||||
env.Append(CCFLAGS=["-O3"])
|
||||
|
||||
elif env['platform'] == 'windows':
|
||||
if host_platform == 'windows' and not env['use_mingw']:
|
||||
elif env["platform"] == "windows":
|
||||
if host_platform == "windows" and not env["use_mingw"]:
|
||||
# MSVC
|
||||
env.Append(LINKFLAGS=['/WX'])
|
||||
if env['target'] == 'debug':
|
||||
env.Append(CCFLAGS=['/Z7', '/Od', '/EHsc', '/D_DEBUG', '/MDd'])
|
||||
elif env['target'] == 'release':
|
||||
env.Append(CCFLAGS=['/O2', '/EHsc', '/DNDEBUG', '/MD'])
|
||||
env.Append(LINKFLAGS=["/WX"])
|
||||
if env["target"] == "debug":
|
||||
env.Append(CCFLAGS=["/Z7", "/Od", "/EHsc", "/D_DEBUG", "/MDd"])
|
||||
elif env["target"] == "release":
|
||||
env.Append(CCFLAGS=["/O2", "/EHsc", "/DNDEBUG", "/MD"])
|
||||
|
||||
elif host_platform == 'linux' or host_platform == 'osx':
|
||||
elif host_platform == "linux" or host_platform == "freebsd" or host_platform == "osx":
|
||||
# Cross-compilation using MinGW
|
||||
if env['bits'] == '64':
|
||||
env['CXX'] = 'x86_64-w64-mingw32-g++'
|
||||
env['AR'] = "x86_64-w64-mingw32-ar"
|
||||
env['RANLIB'] = "x86_64-w64-mingw32-ranlib"
|
||||
env['LINK'] = "x86_64-w64-mingw32-g++"
|
||||
elif env['bits'] == '32':
|
||||
env['CXX'] = 'i686-w64-mingw32-g++'
|
||||
env['AR'] = "i686-w64-mingw32-ar"
|
||||
env['RANLIB'] = "i686-w64-mingw32-ranlib"
|
||||
env['LINK'] = "i686-w64-mingw32-g++"
|
||||
|
||||
elif host_platform == 'windows' and env['use_mingw']:
|
||||
if env["bits"] == "64":
|
||||
env["CXX"] = "x86_64-w64-mingw32-g++"
|
||||
env["AR"] = "x86_64-w64-mingw32-ar"
|
||||
env["RANLIB"] = "x86_64-w64-mingw32-ranlib"
|
||||
env["LINK"] = "x86_64-w64-mingw32-g++"
|
||||
elif env["bits"] == "32":
|
||||
env["CXX"] = "i686-w64-mingw32-g++"
|
||||
env["AR"] = "i686-w64-mingw32-ar"
|
||||
env["RANLIB"] = "i686-w64-mingw32-ranlib"
|
||||
env["LINK"] = "i686-w64-mingw32-g++"
|
||||
|
||||
elif host_platform == "windows" and env["use_mingw"]:
|
||||
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
|
||||
env = Environment(ENV = os.environ, tools=["mingw"])
|
||||
env = Environment(ENV=os.environ, tools=["mingw"])
|
||||
opts.Update(env)
|
||||
#env = env.Clone(tools=['mingw'])
|
||||
|
||||
# Still need to use C++14.
|
||||
env.Append(CCFLAGS=["-std=c++14"])
|
||||
# Don't want lib prefixes
|
||||
env["IMPLIBPREFIX"] = ""
|
||||
env["SHLIBPREFIX"] = ""
|
||||
|
||||
env["SPAWN"] = mySpawn
|
||||
env.Replace(ARFLAGS=["q"])
|
||||
|
||||
# Native or cross-compilation using MinGW
|
||||
if host_platform == 'linux' or host_platform == 'osx' or env['use_mingw']:
|
||||
if host_platform == "linux" or host_platform == "freebsd" or host_platform == "osx" or env["use_mingw"]:
|
||||
# These options are for a release build even using target=debug
|
||||
env.Append(CCFLAGS=['-O3', '-std=c++14', '-Wwrite-strings'])
|
||||
env.Append(LINKFLAGS=[
|
||||
'--static',
|
||||
'-Wl,--no-undefined',
|
||||
'-static-libgcc',
|
||||
'-static-libstdc++',
|
||||
])
|
||||
env.Append(CCFLAGS=["-O3", "-Wwrite-strings"])
|
||||
env.Append(
|
||||
LINKFLAGS=[
|
||||
"--static",
|
||||
"-Wl,--no-undefined",
|
||||
"-static-libgcc",
|
||||
"-static-libstdc++",
|
||||
]
|
||||
)
|
||||
|
||||
elif env['platform'] == 'android':
|
||||
if host_platform == 'windows':
|
||||
elif env["platform"] == "android":
|
||||
if host_platform == "windows":
|
||||
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
|
||||
env = Environment(ENV = os.environ, tools=["mingw"])
|
||||
env = Environment(ENV=os.environ, tools=["mingw"])
|
||||
opts.Update(env)
|
||||
#env = env.Clone(tools=['mingw'])
|
||||
|
||||
# Long line hack. Use custom spawn, quick AR append (to avoid files with the same names to override each other).
|
||||
env["SPAWN"] = mySpawn
|
||||
env.Replace(ARFLAGS=["q"])
|
||||
|
||||
# Verify NDK root
|
||||
if not 'ANDROID_NDK_ROOT' in env:
|
||||
raise ValueError("To build for Android, ANDROID_NDK_ROOT must be defined. Please set ANDROID_NDK_ROOT to the root folder of your Android NDK installation.")
|
||||
if not "ANDROID_NDK_ROOT" in env:
|
||||
raise ValueError(
|
||||
"To build for Android, ANDROID_NDK_ROOT must be defined. Please set ANDROID_NDK_ROOT to the root folder of your Android NDK installation."
|
||||
)
|
||||
|
||||
# Validate API level
|
||||
api_level = int(env['android_api_level'])
|
||||
if env['android_arch'] in ['x86_64', 'arm64v8'] and api_level < 21:
|
||||
api_level = int(env["android_api_level"])
|
||||
if env["android_arch"] in ["x86_64", "arm64v8"] and api_level < 21:
|
||||
print("WARN: 64-bit Android architectures require an API level of at least 21; setting android_api_level=21")
|
||||
env['android_api_level'] = '21'
|
||||
env["android_api_level"] = "21"
|
||||
api_level = 21
|
||||
|
||||
# Setup toolchain
|
||||
toolchain = env['ANDROID_NDK_ROOT'] + "/toolchains/llvm/prebuilt/"
|
||||
toolchain = env["ANDROID_NDK_ROOT"] + "/toolchains/llvm/prebuilt/"
|
||||
if host_platform == "windows":
|
||||
toolchain += "windows"
|
||||
import platform as pltfm
|
||||
|
||||
if pltfm.machine().endswith("64"):
|
||||
toolchain += "-x86_64"
|
||||
elif host_platform == "linux":
|
||||
toolchain += "linux-x86_64"
|
||||
elif host_platform == "osx":
|
||||
toolchain += "darwin-x86_64"
|
||||
env.PrependENVPath('PATH', toolchain + "/bin") # This does nothing half of the time, but we'll put it here anyways
|
||||
env.PrependENVPath("PATH", toolchain + "/bin") # This does nothing half of the time, but we'll put it here anyways
|
||||
|
||||
# Get architecture info
|
||||
arch_info_table = {
|
||||
"armv7" : {
|
||||
"march":"armv7-a", "target":"armv7a-linux-androideabi", "tool_path":"arm-linux-androideabi", "compiler_path":"armv7a-linux-androideabi",
|
||||
"ccflags" : ['-mfpu=neon']
|
||||
},
|
||||
"arm64v8" : {
|
||||
"march":"armv8-a", "target":"aarch64-linux-android", "tool_path":"aarch64-linux-android", "compiler_path":"aarch64-linux-android",
|
||||
"ccflags" : []
|
||||
},
|
||||
"x86" : {
|
||||
"march":"i686", "target":"i686-linux-android", "tool_path":"i686-linux-android", "compiler_path":"i686-linux-android",
|
||||
"ccflags" : ['-mstackrealign']
|
||||
},
|
||||
"x86_64" : {"march":"x86-64", "target":"x86_64-linux-android", "tool_path":"x86_64-linux-android", "compiler_path":"x86_64-linux-android",
|
||||
"ccflags" : []
|
||||
}
|
||||
"armv7": {
|
||||
"march": "armv7-a",
|
||||
"target": "armv7a-linux-androideabi",
|
||||
"tool_path": "arm-linux-androideabi",
|
||||
"compiler_path": "armv7a-linux-androideabi",
|
||||
"ccflags": ["-mfpu=neon"],
|
||||
},
|
||||
"arm64v8": {
|
||||
"march": "armv8-a",
|
||||
"target": "aarch64-linux-android",
|
||||
"tool_path": "aarch64-linux-android",
|
||||
"compiler_path": "aarch64-linux-android",
|
||||
"ccflags": [],
|
||||
},
|
||||
"x86": {
|
||||
"march": "i686",
|
||||
"target": "i686-linux-android",
|
||||
"tool_path": "i686-linux-android",
|
||||
"compiler_path": "i686-linux-android",
|
||||
"ccflags": ["-mstackrealign"],
|
||||
},
|
||||
"x86_64": {
|
||||
"march": "x86-64",
|
||||
"target": "x86_64-linux-android",
|
||||
"tool_path": "x86_64-linux-android",
|
||||
"compiler_path": "x86_64-linux-android",
|
||||
"ccflags": [],
|
||||
},
|
||||
}
|
||||
arch_info = arch_info_table[env['android_arch']]
|
||||
arch_info = arch_info_table[env["android_arch"]]
|
||||
|
||||
# Setup tools
|
||||
env['CC'] = toolchain + "/bin/clang"
|
||||
env['CXX'] = toolchain + "/bin/clang++"
|
||||
env['AR'] = toolchain + "/bin/" + arch_info['tool_path'] + "-ar"
|
||||
env["CC"] = toolchain + "/bin/clang"
|
||||
env["CXX"] = toolchain + "/bin/clang++"
|
||||
env["AR"] = toolchain + "/bin/llvm-ar"
|
||||
env["AS"] = toolchain + "/bin/llvm-as"
|
||||
env["LD"] = toolchain + "/bin/llvm-ld"
|
||||
env["STRIP"] = toolchain + "/bin/llvm-strip"
|
||||
env["RANLIB"] = toolchain + "/bin/llvm-ranlib"
|
||||
env["SHLIBSUFFIX"] = ".so"
|
||||
|
||||
env.Append(CCFLAGS=['--target=' + arch_info['target'] + env['android_api_level'], '-march=' + arch_info['march'], '-fPIC'])#, '-fPIE', '-fno-addrsig', '-Oz'])
|
||||
env.Append(CCFLAGS=arch_info['ccflags'])
|
||||
env.Append(
|
||||
CCFLAGS=[
|
||||
"--target=" + arch_info["target"] + env["android_api_level"],
|
||||
"-march=" + arch_info["march"],
|
||||
"-fPIC",
|
||||
]
|
||||
)
|
||||
env.Append(CCFLAGS=arch_info["ccflags"])
|
||||
env.Append(LINKFLAGS=["--target=" + arch_info["target"] + env["android_api_level"], "-march=" + arch_info["march"]])
|
||||
|
||||
env.Append(CPPPATH=[
|
||||
'.',
|
||||
env['headers_dir'],
|
||||
'include',
|
||||
'include/gen',
|
||||
'include/core',
|
||||
])
|
||||
if env["target"] == "debug":
|
||||
env.Append(CCFLAGS=["-Og", "-g"])
|
||||
elif env["target"] == "release":
|
||||
env.Append(CCFLAGS=["-O3"])
|
||||
|
||||
elif env["platform"] == "javascript":
|
||||
env["ENV"] = os.environ
|
||||
env["CC"] = "emcc"
|
||||
env["CXX"] = "em++"
|
||||
env["AR"] = "emar"
|
||||
env["RANLIB"] = "emranlib"
|
||||
env.Append(CPPFLAGS=["-s", "SIDE_MODULE=1"])
|
||||
env.Append(LINKFLAGS=["-s", "SIDE_MODULE=1"])
|
||||
env["SHOBJSUFFIX"] = ".bc"
|
||||
env["SHLIBSUFFIX"] = ".wasm"
|
||||
# Use TempFileMunge since some AR invocations are too long for cmd.exe.
|
||||
# Use POSIX-style paths, required with TempFileMunge.
|
||||
env["ARCOM_POSIX"] = env["ARCOM"].replace("$TARGET", "$TARGET.posix").replace("$SOURCES", "$SOURCES.posix")
|
||||
env["ARCOM"] = "${TEMPFILE(ARCOM_POSIX)}"
|
||||
|
||||
# All intermediate files are just LLVM bitcode.
|
||||
env["OBJPREFIX"] = ""
|
||||
env["OBJSUFFIX"] = ".bc"
|
||||
env["PROGPREFIX"] = ""
|
||||
# Program() output consists of multiple files, so specify suffixes manually at builder.
|
||||
env["PROGSUFFIX"] = ""
|
||||
env["LIBPREFIX"] = "lib"
|
||||
env["LIBSUFFIX"] = ".a"
|
||||
env["LIBPREFIXES"] = ["$LIBPREFIX"]
|
||||
env["LIBSUFFIXES"] = ["$LIBSUFFIX"]
|
||||
env.Replace(SHLINKFLAGS="$LINKFLAGS")
|
||||
env.Replace(SHLINKFLAGS="$LINKFLAGS")
|
||||
|
||||
if env["target"] == "debug":
|
||||
env.Append(CCFLAGS=["-O0", "-g"])
|
||||
elif env["target"] == "release":
|
||||
env.Append(CCFLAGS=["-O3"])
|
||||
|
||||
env.Append(
|
||||
CPPPATH=[
|
||||
".",
|
||||
env["headers_dir"],
|
||||
"include",
|
||||
"include/gen",
|
||||
"include/core",
|
||||
]
|
||||
)
|
||||
|
||||
# Generate bindings?
|
||||
json_api_file = ''
|
||||
json_api_file = ""
|
||||
|
||||
if 'custom_api_file' in env:
|
||||
json_api_file = env['custom_api_file']
|
||||
if "custom_api_file" in env:
|
||||
json_api_file = env["custom_api_file"]
|
||||
else:
|
||||
json_api_file = os.path.join(os.getcwd(), env['headers_dir'], 'api.json')
|
||||
json_api_file = os.path.join(os.getcwd(), env["headers_dir"], "api.json")
|
||||
|
||||
if env['generate_bindings']:
|
||||
if env["generate_bindings"] == "auto":
|
||||
# Check if generated files exist
|
||||
should_generate_bindings = not os.path.isfile(os.path.join(os.getcwd(), "src", "gen", "Object.cpp"))
|
||||
else:
|
||||
should_generate_bindings = env["generate_bindings"] in ["yes", "true"]
|
||||
|
||||
if should_generate_bindings:
|
||||
# Actually create the bindings here
|
||||
import binding_generator
|
||||
|
||||
binding_generator.generate_bindings(json_api_file, env['generate_template_get_node'])
|
||||
binding_generator.generate_bindings(json_api_file, env["generate_template_get_node"])
|
||||
|
||||
# Sources to compile
|
||||
sources = []
|
||||
add_sources(sources, 'src/core', 'cpp')
|
||||
add_sources(sources, 'src/gen', 'cpp')
|
||||
add_sources(sources, "src/core", "cpp")
|
||||
add_sources(sources, "src/gen", "cpp")
|
||||
|
||||
arch_suffix = env['bits']
|
||||
if env['platform'] == 'android':
|
||||
arch_suffix = env['android_arch']
|
||||
if env['platform'] == 'ios':
|
||||
arch_suffix = env['ios_arch']
|
||||
arch_suffix = env["bits"]
|
||||
if env["platform"] == "android":
|
||||
arch_suffix = env["android_arch"]
|
||||
elif env["platform"] == "ios":
|
||||
arch_suffix = env["ios_arch"]
|
||||
if env["ios_simulator"]:
|
||||
arch_suffix += ".simulator"
|
||||
elif env["platform"] == "osx":
|
||||
if env["macos_arch"] != "universal":
|
||||
arch_suffix = env["macos_arch"]
|
||||
elif env["platform"] == "javascript":
|
||||
arch_suffix = "wasm"
|
||||
# Expose it to projects that import this env.
|
||||
env["arch_suffix"] = arch_suffix
|
||||
|
||||
library = env.StaticLibrary(
|
||||
target='bin/' + 'libgodot-cpp.{}.{}.{}{}'.format(
|
||||
env['platform'],
|
||||
env['target'],
|
||||
arch_suffix,
|
||||
env['LIBSUFFIX']
|
||||
), source=sources
|
||||
)
|
||||
Default(library)
|
||||
library = None
|
||||
env["OBJSUFFIX"] = ".{}.{}.{}{}".format(env["platform"], env["target"], arch_suffix, env["OBJSUFFIX"])
|
||||
library_name = "libgodot-cpp.{}.{}.{}{}".format(env["platform"], env["target"], arch_suffix, env["LIBSUFFIX"])
|
||||
|
||||
if env["build_library"]:
|
||||
library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
|
||||
Default(library)
|
||||
|
||||
env.Append(CPPPATH=[env.Dir(f) for f in [env["headers_dir"], "include", "include/gen", "include/core"]])
|
||||
env.Append(LIBPATH=[env.Dir("bin")])
|
||||
env.Append(LIBS=library_name)
|
||||
Return("env")
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
import json
|
||||
|
||||
# comment.
|
||||
import os
|
||||
import errno
|
||||
from pathlib import Path
|
||||
|
||||
# Convenience function for using template get_node
|
||||
def correct_method_name(method_list):
|
||||
@@ -13,15 +14,58 @@ def correct_method_name(method_list):
|
||||
|
||||
classes = []
|
||||
|
||||
def generate_bindings(path, use_template_get_node):
|
||||
|
||||
def print_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||
global classes
|
||||
classes = json.load(open(path))
|
||||
end = ";"
|
||||
with open(api_filepath) as api_file:
|
||||
classes = json.load(api_file)
|
||||
include_gen_folder = Path(output_dir) / "include" / "gen"
|
||||
source_gen_folder = Path(output_dir) / "src" / "gen"
|
||||
for _class in classes:
|
||||
header_filename = include_gen_folder / (strip_name(_class["name"]) + ".hpp")
|
||||
source_filename = source_gen_folder / (strip_name(_class["name"]) + ".cpp")
|
||||
if headers:
|
||||
print(str(header_filename.as_posix()), end=end)
|
||||
if sources:
|
||||
print(str(source_filename.as_posix()), end=end)
|
||||
icall_header_filename = include_gen_folder / "__icalls.hpp"
|
||||
register_types_filename = source_gen_folder / "__register_types.cpp"
|
||||
init_method_bindings_filename = source_gen_folder / "__init_method_bindings.cpp"
|
||||
if headers:
|
||||
print(str(icall_header_filename.as_posix()), end=end)
|
||||
if sources:
|
||||
print(str(register_types_filename.as_posix()), end=end)
|
||||
print(str(init_method_bindings_filename.as_posix()), end=end)
|
||||
|
||||
|
||||
def generate_bindings(api_filepath, use_template_get_node, output_dir="."):
|
||||
global classes
|
||||
with open(api_filepath) as api_file:
|
||||
classes = json.load(api_file)
|
||||
|
||||
icalls = set()
|
||||
include_gen_folder = Path(output_dir) / "include" / "gen"
|
||||
source_gen_folder = Path(output_dir) / "src" / "gen"
|
||||
|
||||
try:
|
||||
include_gen_folder.mkdir(parents=True)
|
||||
except os.error as e:
|
||||
if e.errno == errno.EEXIST:
|
||||
print(str(source_gen_folder) + ": " + os.strerror(e.errno))
|
||||
else:
|
||||
exit(1)
|
||||
|
||||
try:
|
||||
source_gen_folder.mkdir(parents=True)
|
||||
except os.error as e:
|
||||
if e.errno == errno.EEXIST:
|
||||
print(str(source_gen_folder) + ": " + os.strerror(e.errno))
|
||||
else:
|
||||
exit(1)
|
||||
|
||||
for c in classes:
|
||||
# print c['name']
|
||||
# print(c['name'])
|
||||
used_classes = get_used_classes(c)
|
||||
if use_template_get_node and c["name"] == "Node":
|
||||
correct_method_name(c["methods"])
|
||||
@@ -30,31 +74,36 @@ def generate_bindings(path, use_template_get_node):
|
||||
|
||||
impl = generate_class_implementation(icalls, used_classes, c, use_template_get_node)
|
||||
|
||||
header_file = open("include/gen/" + strip_name(c["name"]) + ".hpp", "w+")
|
||||
header_file.write(header)
|
||||
header_filename = include_gen_folder / (strip_name(c["name"]) + ".hpp")
|
||||
with header_filename.open("w+") as header_file:
|
||||
header_file.write(header)
|
||||
|
||||
source_file = open("src/gen/" + strip_name(c["name"]) + ".cpp", "w+")
|
||||
source_file.write(impl)
|
||||
source_filename = source_gen_folder / (strip_name(c["name"]) + ".cpp")
|
||||
with source_filename.open("w+") as source_file:
|
||||
source_file.write(impl)
|
||||
|
||||
icall_header_filename = include_gen_folder / "__icalls.hpp"
|
||||
with icall_header_filename.open("w+") as icall_header_file:
|
||||
icall_header_file.write(generate_icall_header(icalls))
|
||||
|
||||
icall_header_file = open("include/gen/__icalls.hpp", "w+")
|
||||
icall_header_file.write(generate_icall_header(icalls))
|
||||
register_types_filename = source_gen_folder / "__register_types.cpp"
|
||||
with register_types_filename.open("w+") as register_types_file:
|
||||
register_types_file.write(generate_type_registry(classes))
|
||||
|
||||
register_types_file = open("src/gen/__register_types.cpp", "w+")
|
||||
register_types_file.write(generate_type_registry(classes))
|
||||
|
||||
init_method_bindings_file = open("src/gen/__init_method_bindings.cpp", "w+")
|
||||
init_method_bindings_file.write(generate_init_method_bindings(classes))
|
||||
init_method_bindings_filename = source_gen_folder / "__init_method_bindings.cpp"
|
||||
with init_method_bindings_filename.open("w+") as init_method_bindings_file:
|
||||
init_method_bindings_file.write(generate_init_method_bindings(classes))
|
||||
|
||||
|
||||
def is_reference_type(t):
|
||||
for c in classes:
|
||||
if c['name'] != t:
|
||||
if c["name"] != t:
|
||||
continue
|
||||
if c['is_reference']:
|
||||
if c["is_reference"]:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def make_gdnative_type(t, ref_allowed):
|
||||
if is_enum(t):
|
||||
return remove_enum_prefix(t) + " "
|
||||
@@ -80,10 +129,9 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
source.append("")
|
||||
|
||||
source.append("#include <gdnative_api_struct.gen.h>")
|
||||
source.append("#include <stdint.h>")
|
||||
source.append("#include <cstdint>")
|
||||
source.append("")
|
||||
|
||||
|
||||
source.append("#include <core/CoreTypes.hpp>")
|
||||
|
||||
class_name = strip_name(c["name"])
|
||||
@@ -97,7 +145,6 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
source.append("#include <core/TagDB.hpp>")
|
||||
ref_allowed = False
|
||||
|
||||
|
||||
included = []
|
||||
|
||||
for used_class in used_classes:
|
||||
@@ -105,36 +152,38 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
used_class_name = remove_enum_prefix(extract_nested_type(used_class))
|
||||
if used_class_name not in included:
|
||||
included.append(used_class_name)
|
||||
source.append("#include \"" + used_class_name + ".hpp\"")
|
||||
source.append('#include "' + used_class_name + '.hpp"')
|
||||
elif is_enum(used_class) and is_nested_type(used_class) and not is_nested_type(used_class, class_name):
|
||||
used_class_name = remove_enum_prefix(used_class)
|
||||
if used_class_name not in included:
|
||||
included.append(used_class_name)
|
||||
source.append("#include \"" + used_class_name + ".hpp\"")
|
||||
source.append('#include "' + used_class_name + '.hpp"')
|
||||
|
||||
source.append("")
|
||||
|
||||
if c["base_class"] != "":
|
||||
source.append("#include \"" + strip_name(c["base_class"]) + ".hpp\"")
|
||||
|
||||
source.append('#include "' + strip_name(c["base_class"]) + '.hpp"')
|
||||
|
||||
source.append("namespace godot {")
|
||||
source.append("")
|
||||
|
||||
|
||||
for used_type in used_classes:
|
||||
if is_enum(used_type) or is_nested_type(used_type, class_name):
|
||||
continue
|
||||
else:
|
||||
source.append("class " + strip_name(used_type) + ";")
|
||||
|
||||
|
||||
source.append("")
|
||||
|
||||
vararg_templates = ""
|
||||
|
||||
# generate the class definition here
|
||||
source.append("class " + class_name + (" : public _Wrapped" if c["base_class"] == "" else (" : public " + strip_name(c["base_class"])) ) + " {")
|
||||
source.append(
|
||||
"class "
|
||||
+ class_name
|
||||
+ (" : public _Wrapped" if c["base_class"] == "" else (" : public " + strip_name(c["base_class"])))
|
||||
+ " {"
|
||||
)
|
||||
|
||||
if c["base_class"] == "":
|
||||
source.append("public: enum { ___CLASS_IS_SCRIPT = 0, };")
|
||||
@@ -165,7 +214,6 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
|
||||
source.append("")
|
||||
|
||||
|
||||
if c["singleton"]:
|
||||
source.append("\tstatic inline " + class_name + " *get_singleton()")
|
||||
source.append("\t{")
|
||||
@@ -181,10 +229,18 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
# class name:
|
||||
# Two versions needed needed because when the user implements a custom class,
|
||||
# we want to override `___get_class_name` while `___get_godot_class_name` can keep returning the base name
|
||||
source.append("\tstatic inline const char *___get_class_name() { return (const char *) \"" + strip_name(c["name"]) + "\"; }")
|
||||
source.append("\tstatic inline const char *___get_godot_class_name() { return (const char *) \"" + strip_name(c["name"]) + "\"; }")
|
||||
source.append(
|
||||
'\tstatic inline const char *___get_class_name() { return (const char *) "' + strip_name(c["name"]) + '"; }'
|
||||
)
|
||||
source.append(
|
||||
'\tstatic inline const char *___get_godot_class_name() { return (const char *) "'
|
||||
+ strip_name(c["name"])
|
||||
+ '"; }'
|
||||
)
|
||||
|
||||
source.append("\tstatic inline Object *___get_from_variant(Variant a) { godot_object *o = (godot_object*) a; return (o) ? (Object *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, o) : nullptr; }")
|
||||
source.append(
|
||||
"\tstatic inline Object *___get_from_variant(Variant a) { godot_object *o = (godot_object*) a; return (o) ? (Object *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, o) : nullptr; }"
|
||||
)
|
||||
|
||||
enum_values = []
|
||||
|
||||
@@ -202,7 +258,6 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
if name not in enum_values:
|
||||
source.append("\tconst static int " + name + " = " + str(c["constants"][name]) + ";")
|
||||
|
||||
|
||||
if c["instanciable"]:
|
||||
source.append("")
|
||||
source.append("")
|
||||
@@ -210,7 +265,6 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
|
||||
source.append("\n\t// methods")
|
||||
|
||||
|
||||
if class_name == "Object":
|
||||
source.append("#ifndef GODOT_CPP_NO_OBJECT_CAST")
|
||||
source.append("\ttemplate<class T>")
|
||||
@@ -225,8 +279,7 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
# method_signature += "virtual " if method["is_virtual"] else ""
|
||||
method_signature += make_gdnative_type(method["return_type"], ref_allowed)
|
||||
method_name = escape_cpp(method["name"])
|
||||
method_signature += method_name + "("
|
||||
|
||||
method_signature += method_name + "("
|
||||
|
||||
has_default_argument = False
|
||||
method_arguments = ""
|
||||
@@ -237,7 +290,6 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
method_signature += argument_name
|
||||
method_arguments += argument_name
|
||||
|
||||
|
||||
# default arguments
|
||||
def escape_default_arg(_type, default_value):
|
||||
if _type == "Color":
|
||||
@@ -246,7 +298,15 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
return default_value.lower()
|
||||
if _type == "Array":
|
||||
return "Array()"
|
||||
if _type in ["PoolVector2Array", "PoolStringArray", "PoolVector3Array", "PoolColorArray", "PoolIntArray", "PoolRealArray"]:
|
||||
if _type in [
|
||||
"PoolVector2Array",
|
||||
"PoolStringArray",
|
||||
"PoolVector3Array",
|
||||
"PoolColorArray",
|
||||
"PoolIntArray",
|
||||
"PoolRealArray",
|
||||
"PoolByteArray",
|
||||
]:
|
||||
return _type + "()"
|
||||
if _type == "Vector2":
|
||||
return "Vector2" + default_value
|
||||
@@ -260,8 +320,8 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
return "Rect2" + default_value
|
||||
if _type == "Variant":
|
||||
return "Variant()" if default_value == "Null" else default_value
|
||||
if _type == "String":
|
||||
return "\"" + default_value + "\""
|
||||
if _type == "String" or _type == "NodePath":
|
||||
return '"' + default_value + '"'
|
||||
if _type == "RID":
|
||||
return "RID()"
|
||||
|
||||
@@ -270,15 +330,10 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
|
||||
return default_value
|
||||
|
||||
|
||||
|
||||
|
||||
if argument["has_default_value"] or has_default_argument:
|
||||
method_signature += " = " + escape_default_arg(argument["type"], argument["default_value"])
|
||||
has_default_argument = True
|
||||
|
||||
|
||||
|
||||
if i != len(method["arguments"]) - 1:
|
||||
method_signature += ", "
|
||||
method_arguments += ","
|
||||
@@ -287,12 +342,20 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
if len(method["arguments"]) > 0:
|
||||
method_signature += ", "
|
||||
method_arguments += ", "
|
||||
vararg_templates += "\ttemplate <class... Args> " + method_signature + "Args... args){\n\t\treturn " + method_name + "(" + method_arguments + "Array::make(args...));\n\t}\n"""
|
||||
vararg_templates += (
|
||||
"\ttemplate <class... Args> "
|
||||
+ method_signature
|
||||
+ "Args... args){\n\t\treturn "
|
||||
+ method_name
|
||||
+ "("
|
||||
+ method_arguments
|
||||
+ "Array::make(args...));\n\t}\n"
|
||||
""
|
||||
)
|
||||
method_signature += "const Array& __var_args = Array()"
|
||||
|
||||
method_signature += ")" + (" const" if method["is_const"] else "")
|
||||
|
||||
|
||||
source.append("\t" + method_signature + ";")
|
||||
|
||||
source.append(vararg_templates)
|
||||
@@ -322,20 +385,16 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
||||
|
||||
source.append("#endif")
|
||||
|
||||
|
||||
return "\n".join(source)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def generate_class_implementation(icalls, used_classes, c, use_template_get_node):
|
||||
class_name = strip_name(c["name"])
|
||||
|
||||
ref_allowed = class_name != "Object" and class_name != "Reference"
|
||||
|
||||
source = []
|
||||
source.append("#include \"" + class_name + ".hpp\"")
|
||||
source.append('#include "' + class_name + '.hpp"')
|
||||
source.append("")
|
||||
source.append("")
|
||||
|
||||
@@ -346,8 +405,7 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
source.append("#include <core/Godot.hpp>")
|
||||
source.append("")
|
||||
|
||||
|
||||
source.append("#include \"__icalls.hpp\"")
|
||||
source.append('#include "__icalls.hpp"')
|
||||
source.append("")
|
||||
source.append("")
|
||||
|
||||
@@ -355,17 +413,15 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
if is_enum(used_class):
|
||||
continue
|
||||
else:
|
||||
source.append("#include \"" + strip_name(used_class) + ".hpp\"")
|
||||
source.append('#include "' + strip_name(used_class) + '.hpp"')
|
||||
|
||||
source.append("")
|
||||
source.append("")
|
||||
|
||||
source.append("namespace godot {")
|
||||
|
||||
|
||||
core_object_name = "this"
|
||||
|
||||
|
||||
source.append("")
|
||||
source.append("")
|
||||
|
||||
@@ -376,7 +432,7 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
|
||||
# FIXME Test if inlining has a huge impact on binary size
|
||||
source.append(class_name + "::" + class_name + "() {")
|
||||
source.append("\t_owner = godot::api->godot_global_get_singleton((char *) \"" + strip_name(c["name"]) + "\");")
|
||||
source.append('\t_owner = godot::api->godot_global_get_singleton((char *) "' + strip_name(c["name"]) + '");')
|
||||
source.append("}")
|
||||
|
||||
source.append("")
|
||||
@@ -392,10 +448,18 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
source.append("void " + class_name + "::___init_method_bindings() {")
|
||||
|
||||
for method in c["methods"]:
|
||||
source.append("\t___mb.mb_" + method["name"] + " = godot::api->godot_method_bind_get_method(\"" + c["name"] + "\", \"" + ("get_node" if use_template_get_node and method["name"] == "get_node_internal" else method["name"]) + "\");")
|
||||
source.append(
|
||||
"\t___mb.mb_"
|
||||
+ method["name"]
|
||||
+ ' = godot::api->godot_method_bind_get_method("'
|
||||
+ c["name"]
|
||||
+ '", "'
|
||||
+ ("get_node" if use_template_get_node and method["name"] == "get_node_internal" else method["name"])
|
||||
+ '");'
|
||||
)
|
||||
|
||||
source.append("\tgodot_string_name class_name;")
|
||||
source.append("\tgodot::api->godot_string_name_new_data(&class_name, \"" + c["name"] + "\");")
|
||||
source.append('\tgodot::api->godot_string_name_new_data(&class_name, "' + c["name"] + '");')
|
||||
source.append("\t_detail_class_tag = godot::core_1_2_api->godot_get_class_tag(&class_name);")
|
||||
source.append("\tgodot::api->godot_string_name_destroy(&class_name);")
|
||||
|
||||
@@ -405,7 +469,13 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
if c["instanciable"]:
|
||||
source.append(class_name + " *" + strip_name(c["name"]) + "::_new()")
|
||||
source.append("{")
|
||||
source.append("\treturn (" + class_name + " *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, godot::api->godot_get_class_constructor((char *)\"" + c["name"] + "\")());")
|
||||
source.append(
|
||||
"\treturn ("
|
||||
+ class_name
|
||||
+ ' *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, godot::api->godot_get_class_constructor((char *)"'
|
||||
+ c["name"]
|
||||
+ '")());'
|
||||
)
|
||||
source.append("}")
|
||||
|
||||
for method in c["methods"]:
|
||||
@@ -430,7 +500,6 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
|
||||
source.append(method_signature + " {")
|
||||
|
||||
|
||||
if method["name"] == "free":
|
||||
# dirty hack because Object::free is marked virtual but doesn't actually exist...
|
||||
source.append("\tgodot::api->godot_object_destroy(_owner);")
|
||||
@@ -448,7 +517,9 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
elif return_type_is_ref:
|
||||
return_statement += "return Ref<" + strip_name(method["return_type"]) + ">::__internal_constructor("
|
||||
else:
|
||||
return_statement += "return " + ("(" + strip_name(method["return_type"]) + " *) " if is_class_type(method["return_type"]) else "")
|
||||
return_statement += "return " + (
|
||||
"(" + strip_name(method["return_type"]) + " *) " if is_class_type(method["return_type"]) else ""
|
||||
)
|
||||
else:
|
||||
return_statement += "return "
|
||||
|
||||
@@ -459,8 +530,6 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
return "Object"
|
||||
return name
|
||||
|
||||
|
||||
|
||||
if method["has_varargs"]:
|
||||
|
||||
if len(method["arguments"]) != 0:
|
||||
@@ -471,7 +540,6 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
|
||||
source.append("")
|
||||
|
||||
|
||||
for i, argument in enumerate(method["arguments"]):
|
||||
source.append("\t__given_args[" + str(i) + "] = " + escape_cpp(argument["name"]) + ";")
|
||||
|
||||
@@ -483,7 +551,9 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
else:
|
||||
size = "(" + str(len(method["arguments"])) + ")"
|
||||
|
||||
source.append("\tgodot_variant **__args = (godot_variant **) alloca(sizeof(godot_variant *) * " + size + ");")
|
||||
source.append(
|
||||
"\tgodot_variant **__args = (godot_variant **) alloca(sizeof(godot_variant *) * " + size + ");"
|
||||
)
|
||||
|
||||
source.append("")
|
||||
|
||||
@@ -494,24 +564,35 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
|
||||
if method["has_varargs"]:
|
||||
source.append("\tfor (int i = 0; i < __var_args.size(); i++) {")
|
||||
source.append("\t\t__args[i + " + str(len(method["arguments"])) + "] = (godot_variant *) &((Array &) __var_args)[i];")
|
||||
source.append(
|
||||
"\t\t__args[i + "
|
||||
+ str(len(method["arguments"]))
|
||||
+ "] = (godot_variant *) &((Array &) __var_args)[i];"
|
||||
)
|
||||
source.append("\t}")
|
||||
|
||||
source.append("")
|
||||
|
||||
source.append("\tVariant __result;")
|
||||
source.append("\t*(godot_variant *) &__result = godot::api->godot_method_bind_call(___mb.mb_" + method["name"] + ", ((const Object *) " + core_object_name + ")->_owner, (const godot_variant **) __args, " + size + ", nullptr);")
|
||||
source.append(
|
||||
"\t*(godot_variant *) &__result = godot::api->godot_method_bind_call(___mb.mb_"
|
||||
+ method["name"]
|
||||
+ ", ((const Object *) "
|
||||
+ core_object_name
|
||||
+ ")->_owner, (const godot_variant **) __args, "
|
||||
+ size
|
||||
+ ", nullptr);"
|
||||
)
|
||||
|
||||
source.append("")
|
||||
|
||||
if is_class_type(method["return_type"]):
|
||||
source.append("\tObject *obj = Object::___get_from_variant(__result);")
|
||||
source.append("\tif (obj->has_method(\"reference\"))")
|
||||
source.append("\t\tobj->callv(\"reference\", Array());")
|
||||
source.append('\tif (obj->has_method("reference"))')
|
||||
source.append('\t\tobj->callv("reference", Array());')
|
||||
|
||||
source.append("")
|
||||
|
||||
|
||||
for i, argument in enumerate(method["arguments"]):
|
||||
source.append("\tgodot::api->godot_variant_destroy((godot_variant *) &__given_args[" + str(i) + "]);")
|
||||
|
||||
@@ -523,12 +604,17 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
if return_type_is_ref:
|
||||
cast += "Ref<" + strip_name(method["return_type"]) + ">::__internal_constructor(__result);"
|
||||
else:
|
||||
cast += "(" + strip_name(method["return_type"]) + " *) " + strip_name(method["return_type"] + "::___get_from_variant(") + "__result);"
|
||||
cast += (
|
||||
"("
|
||||
+ strip_name(method["return_type"])
|
||||
+ " *) "
|
||||
+ strip_name(method["return_type"] + "::___get_from_variant(")
|
||||
+ "__result);"
|
||||
)
|
||||
else:
|
||||
cast += "__result;"
|
||||
source.append("\treturn " + cast)
|
||||
|
||||
|
||||
else:
|
||||
|
||||
args = []
|
||||
@@ -559,17 +645,11 @@ def generate_class_implementation(icalls, used_classes, c, use_template_get_node
|
||||
source.append("}")
|
||||
source.append("")
|
||||
|
||||
|
||||
|
||||
source.append("}")
|
||||
|
||||
|
||||
return "\n".join(source)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def generate_icall_header(icalls):
|
||||
|
||||
source = []
|
||||
@@ -584,7 +664,7 @@ def generate_icall_header(icalls):
|
||||
|
||||
source.append("#include <core/GodotGlobal.hpp>")
|
||||
source.append("#include <core/CoreTypes.hpp>")
|
||||
source.append("#include \"Object.hpp\"")
|
||||
source.append('#include "Object.hpp"')
|
||||
source.append("")
|
||||
source.append("")
|
||||
|
||||
@@ -597,7 +677,9 @@ def generate_icall_header(icalls):
|
||||
|
||||
method_signature = "static inline "
|
||||
|
||||
method_signature += get_icall_return_type(ret_type) + get_icall_name(icall) + "(godot_method_bind *mb, const Object *inst"
|
||||
method_signature += (
|
||||
get_icall_return_type(ret_type) + get_icall_name(icall) + "(godot_method_bind *mb, const Object *inst"
|
||||
)
|
||||
|
||||
for i, arg in enumerate(args):
|
||||
method_signature += ", const "
|
||||
@@ -620,11 +702,12 @@ def generate_icall_header(icalls):
|
||||
source.append(method_signature + " {")
|
||||
|
||||
if ret_type != "void":
|
||||
source.append("\t" + ("godot_object *" if is_class_type(ret_type) else get_icall_return_type(ret_type)) + "ret;")
|
||||
source.append(
|
||||
"\t" + ("godot_object *" if is_class_type(ret_type) else get_icall_return_type(ret_type)) + "ret;"
|
||||
)
|
||||
if is_class_type(ret_type):
|
||||
source.append("\tret = nullptr;")
|
||||
|
||||
|
||||
source.append("\tconst void *args[" + ("1" if len(args) == 0 else "") + "] = {")
|
||||
|
||||
for i, arg in enumerate(args):
|
||||
@@ -641,12 +724,18 @@ def generate_icall_header(icalls):
|
||||
source.append("\t};")
|
||||
source.append("")
|
||||
|
||||
source.append("\tgodot::api->godot_method_bind_ptrcall(mb, inst->_owner, args, " + ("nullptr" if ret_type == "void" else "&ret") + ");")
|
||||
source.append(
|
||||
"\tgodot::api->godot_method_bind_ptrcall(mb, inst->_owner, args, "
|
||||
+ ("nullptr" if ret_type == "void" else "&ret")
|
||||
+ ");"
|
||||
)
|
||||
|
||||
if ret_type != "void":
|
||||
if is_class_type(ret_type):
|
||||
source.append("\tif (ret) {")
|
||||
source.append("\t\treturn (Object *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, ret);")
|
||||
source.append(
|
||||
"\t\treturn (Object *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, ret);"
|
||||
)
|
||||
source.append("\t}")
|
||||
source.append("")
|
||||
source.append("\treturn (Object *) ret;")
|
||||
@@ -667,7 +756,7 @@ def generate_icall_header(icalls):
|
||||
def generate_type_registry(classes):
|
||||
source = []
|
||||
|
||||
source.append("#include \"TagDB.hpp\"")
|
||||
source.append('#include "TagDB.hpp"')
|
||||
source.append("#include <typeinfo>")
|
||||
source.append("\n")
|
||||
|
||||
@@ -693,14 +782,21 @@ def generate_type_registry(classes):
|
||||
if base_class_name == "":
|
||||
base_class_type_hash = "0"
|
||||
|
||||
source.append("\tgodot::_TagDB::register_global_type(\"" + c["name"] + "\", " + class_type_hash + ", " + base_class_type_hash + ");")
|
||||
source.append(
|
||||
'\tgodot::_TagDB::register_global_type("'
|
||||
+ c["name"]
|
||||
+ '", '
|
||||
+ class_type_hash
|
||||
+ ", "
|
||||
+ base_class_type_hash
|
||||
+ ");"
|
||||
)
|
||||
|
||||
source.append("}")
|
||||
|
||||
source.append("")
|
||||
source.append("}")
|
||||
|
||||
|
||||
return "\n".join(source)
|
||||
|
||||
|
||||
@@ -751,9 +847,6 @@ def get_icall_name(sig):
|
||||
return name
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_used_classes(c):
|
||||
classes = []
|
||||
for method in c["methods"]:
|
||||
@@ -766,85 +859,91 @@ def get_used_classes(c):
|
||||
return classes
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def strip_name(name):
|
||||
if len(name) == 0:
|
||||
return name
|
||||
if name[0] == '_':
|
||||
if name[0] == "_":
|
||||
return name[1:]
|
||||
return name
|
||||
|
||||
|
||||
def extract_nested_type(nested_type):
|
||||
return strip_name(nested_type[:nested_type.find("::")])
|
||||
return strip_name(nested_type[: nested_type.find("::")])
|
||||
|
||||
|
||||
def remove_nested_type_prefix(name):
|
||||
return name if name.find("::") == -1 else strip_name(name[name.find("::") + 2:])
|
||||
return name if name.find("::") == -1 else strip_name(name[name.find("::") + 2 :])
|
||||
|
||||
|
||||
def remove_enum_prefix(name):
|
||||
return strip_name(name[name.find("enum.") + 5:])
|
||||
return strip_name(name[name.find("enum.") + 5 :])
|
||||
|
||||
def is_nested_type(name, type = ""):
|
||||
|
||||
def is_nested_type(name, type=""):
|
||||
return name.find(type + "::") != -1
|
||||
|
||||
|
||||
def is_enum(name):
|
||||
return name.find("enum.") == 0
|
||||
|
||||
|
||||
def is_class_type(name):
|
||||
return not is_core_type(name) and not is_primitive(name)
|
||||
|
||||
|
||||
def is_core_type(name):
|
||||
core_types = ["Array",
|
||||
"Basis",
|
||||
"Color",
|
||||
"Dictionary",
|
||||
"Error",
|
||||
"NodePath",
|
||||
"Plane",
|
||||
"PoolByteArray",
|
||||
"PoolIntArray",
|
||||
"PoolRealArray",
|
||||
"PoolStringArray",
|
||||
"PoolVector2Array",
|
||||
"PoolVector3Array",
|
||||
"PoolColorArray",
|
||||
"PoolIntArray",
|
||||
"PoolRealArray",
|
||||
"Quat",
|
||||
"Rect2",
|
||||
"AABB",
|
||||
"RID",
|
||||
"String",
|
||||
"Transform",
|
||||
"Transform2D",
|
||||
"Variant",
|
||||
"Vector2",
|
||||
"Vector3"]
|
||||
core_types = [
|
||||
"Array",
|
||||
"Basis",
|
||||
"Color",
|
||||
"Dictionary",
|
||||
"Error",
|
||||
"NodePath",
|
||||
"Plane",
|
||||
"PoolByteArray",
|
||||
"PoolIntArray",
|
||||
"PoolRealArray",
|
||||
"PoolStringArray",
|
||||
"PoolVector2Array",
|
||||
"PoolVector3Array",
|
||||
"PoolColorArray",
|
||||
"PoolIntArray",
|
||||
"PoolRealArray",
|
||||
"Quat",
|
||||
"Rect2",
|
||||
"AABB",
|
||||
"RID",
|
||||
"String",
|
||||
"Transform",
|
||||
"Transform2D",
|
||||
"Variant",
|
||||
"Vector2",
|
||||
"Vector3",
|
||||
]
|
||||
return name in core_types
|
||||
|
||||
|
||||
|
||||
|
||||
def is_primitive(name):
|
||||
core_types = ["int", "bool", "real", "float", "void"]
|
||||
return name in core_types
|
||||
|
||||
|
||||
def escape_cpp(name):
|
||||
escapes = {
|
||||
"class": "_class",
|
||||
"char": "_char",
|
||||
"short": "_short",
|
||||
"bool": "_bool",
|
||||
"int": "_int",
|
||||
"default": "_default",
|
||||
"case": "_case",
|
||||
"switch": "_switch",
|
||||
"export": "_export",
|
||||
"class": "_class",
|
||||
"enum": "_enum",
|
||||
"char": "_char",
|
||||
"short": "_short",
|
||||
"bool": "_bool",
|
||||
"int": "_int",
|
||||
"default": "_default",
|
||||
"case": "_case",
|
||||
"switch": "_switch",
|
||||
"export": "_export",
|
||||
"template": "_template",
|
||||
"new": "new_",
|
||||
"new": "new_",
|
||||
"operator": "_operator",
|
||||
"typename": "_typename"
|
||||
"typename": "_typename",
|
||||
}
|
||||
if name in escapes:
|
||||
return escapes[name]
|
||||
|
||||
Submodule godot-headers updated: 815f34e1e9...86afe2307b
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* AABB.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef AABB_H
|
||||
#define AABB_H
|
||||
|
||||
@@ -16,12 +46,10 @@ public:
|
||||
|
||||
real_t get_area() const; /// get area
|
||||
inline bool has_no_area() const {
|
||||
|
||||
return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON);
|
||||
}
|
||||
|
||||
inline bool has_no_surface() const {
|
||||
|
||||
return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Array.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef ARRAY_H
|
||||
#define ARRAY_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Basis.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef BASIS_H
|
||||
#define BASIS_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* CameraMatrix.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef CAMERA_MATRIX_H
|
||||
#define CAMERA_MATRIX_H
|
||||
|
||||
@@ -14,7 +44,6 @@ using namespace godot;
|
||||
} // namespace
|
||||
|
||||
struct CameraMatrix {
|
||||
|
||||
enum Planes {
|
||||
PLANE_NEAR,
|
||||
PLANE_FAR,
|
||||
@@ -84,7 +113,6 @@ struct CameraMatrix {
|
||||
};
|
||||
|
||||
Vector3 CameraMatrix::xform(const Vector3 &p_vec3) const {
|
||||
|
||||
Vector3 ret;
|
||||
ret.x = matrix[0][0] * p_vec3.x + matrix[1][0] * p_vec3.y + matrix[2][0] * p_vec3.z + matrix[3][0];
|
||||
ret.y = matrix[0][1] * p_vec3.x + matrix[1][1] * p_vec3.y + matrix[2][1] * p_vec3.z + matrix[3][1];
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Color.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef COLOR_H
|
||||
#define COLOR_H
|
||||
|
||||
@@ -11,12 +41,10 @@
|
||||
namespace godot {
|
||||
|
||||
struct Color {
|
||||
|
||||
private:
|
||||
// static float _parse_col(const String& p_str, int p_ofs);
|
||||
public:
|
||||
union {
|
||||
|
||||
struct {
|
||||
float r;
|
||||
float g;
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* CoreTypes.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef CORETYPES_H
|
||||
#define CORETYPES_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Defs.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef DEFS_H
|
||||
#define DEFS_H
|
||||
|
||||
@@ -53,8 +83,6 @@ enum class Error {
|
||||
ERR_HELP, ///< user requested help!!
|
||||
ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior.
|
||||
ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
|
||||
ERR_OMFG_THIS_IS_VERY_VERY_BAD, ///< shit happens, has never been used, though
|
||||
ERR_WTF = ERR_OMFG_THIS_IS_VERY_VERY_BAD ///< short version of the above
|
||||
};
|
||||
|
||||
} // namespace godot
|
||||
@@ -208,7 +236,7 @@ typedef float real_t;
|
||||
do { \
|
||||
if (unlikely(cond)) { \
|
||||
FATAL_PRINT(ERR_MSG_COND(cond)); \
|
||||
return; \
|
||||
GENERATE_TRAP; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Dictionary.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef DICTIONARY_H
|
||||
#define DICTIONARY_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Godot.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef GODOT_HPP
|
||||
#define GODOT_HPP
|
||||
|
||||
@@ -17,6 +47,8 @@
|
||||
|
||||
#include "GodotGlobal.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace godot {
|
||||
namespace detail {
|
||||
|
||||
@@ -321,7 +353,6 @@ void register_method(const char *name, M method_ptr, godot_method_rpc_mode rpc_t
|
||||
template <class D, class B, class R, class... As>
|
||||
void register_method_explicit(const char *name, R (B::*method_ptr)(As...),
|
||||
godot_method_rpc_mode rpc_type = GODOT_METHOD_RPC_MODE_DISABLED) {
|
||||
|
||||
static_assert(std::is_base_of<B, D>::value, "Explicit class must derive from method class");
|
||||
register_method(name, static_cast<R (D::*)(As...)>(method_ptr), rpc_type);
|
||||
}
|
||||
@@ -394,7 +425,6 @@ void register_property(const char *name, P(T::*var), P default_value,
|
||||
godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
|
||||
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
||||
godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
||||
|
||||
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
||||
|
||||
Variant def_val = default_value;
|
||||
@@ -451,7 +481,6 @@ void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(),
|
||||
godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
|
||||
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
||||
godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
||||
|
||||
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
||||
|
||||
Variant def_val = default_value;
|
||||
@@ -495,12 +524,11 @@ void register_property(const char *name, void (T::*setter)(P), P (T::*getter)()
|
||||
godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
|
||||
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
||||
godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
||||
|
||||
register_property(name, setter, (P(T::*)())getter, default_value, rpc_mode, usage, hint, hint_string);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void register_signal(String name, Dictionary args = Dictionary()) {
|
||||
void register_signal(String name, Dictionary args) {
|
||||
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
||||
|
||||
godot_signal signal = {};
|
||||
@@ -544,6 +572,17 @@ void register_signal(String name, Args... varargs) {
|
||||
register_signal<T>(name, Dictionary::make(varargs...));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void register_signal(String name) {
|
||||
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
||||
|
||||
godot_signal signal = {};
|
||||
signal.name = *(godot_string *)&name;
|
||||
|
||||
godot::nativescript_api->godot_nativescript_register_signal(godot::_RegisterState::nativescript_handle,
|
||||
T::___get_class_name(), &signal);
|
||||
}
|
||||
|
||||
#ifndef GODOT_CPP_NO_OBJECT_CAST
|
||||
template <class T>
|
||||
T *Object::cast_to(const Object *obj) {
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* GodotGlobal.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef GODOT_GLOBAL_HPP
|
||||
#define GODOT_GLOBAL_HPP
|
||||
|
||||
@@ -23,7 +53,6 @@ extern "C" const godot_gdnative_ext_net_3_2_api_struct *net_3_2_api;
|
||||
extern "C" const void *gdnlib;
|
||||
|
||||
class Godot {
|
||||
|
||||
public:
|
||||
static void print(const String &message);
|
||||
static void print_warning(const String &description, const String &function, const String &file, int line);
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* GodotProfiling.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef GODOT_PROFILING_HPP
|
||||
#define GODOT_PROFILING_HPP
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Math.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef GODOT_MATH_H
|
||||
#define GODOT_MATH_H
|
||||
|
||||
@@ -52,6 +82,27 @@ inline float tan(float p_x) {
|
||||
return ::tanf(p_x);
|
||||
}
|
||||
|
||||
inline double asin(double p_x) {
|
||||
return ::asin(p_x);
|
||||
}
|
||||
inline float asin(float p_x) {
|
||||
return ::asinf(p_x);
|
||||
}
|
||||
|
||||
inline double acos(double p_x) {
|
||||
return ::acos(p_x);
|
||||
}
|
||||
inline float acos(float p_x) {
|
||||
return ::acosf(p_x);
|
||||
}
|
||||
|
||||
inline double atan(double p_x) {
|
||||
return ::atan(p_x);
|
||||
}
|
||||
inline float atan(float p_x) {
|
||||
return ::atanf(p_x);
|
||||
}
|
||||
|
||||
inline double atan2(double p_y, double p_x) {
|
||||
return ::atan2(p_y, p_x);
|
||||
}
|
||||
@@ -232,7 +283,6 @@ inline double stepify(double p_value, double p_step) {
|
||||
}
|
||||
|
||||
inline unsigned int next_power_of_2(unsigned int x) {
|
||||
|
||||
if (x == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* NodePath.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef NODEPATH_H
|
||||
#define NODEPATH_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Plane.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef PLANE_H
|
||||
#define PLANE_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* PoolArrays.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef POOLARRAYS_H
|
||||
#define POOLARRAYS_H
|
||||
|
||||
@@ -26,7 +56,6 @@ class PoolByteArray {
|
||||
|
||||
public:
|
||||
class Read {
|
||||
|
||||
friend class PoolByteArray;
|
||||
godot_pool_byte_array_read_access *_read_access;
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Quat.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef QUAT_H
|
||||
#define QUAT_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* RID.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef RID_H
|
||||
#define RID_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Rect2.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef RECT2_H
|
||||
#define RECT2_H
|
||||
|
||||
@@ -17,7 +47,6 @@ typedef Vector2 Point2;
|
||||
struct Transform2D;
|
||||
|
||||
struct Rect2 {
|
||||
|
||||
Point2 position;
|
||||
Size2 size;
|
||||
|
||||
@@ -48,14 +77,12 @@ struct Rect2 {
|
||||
bool intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_position = nullptr, Point2 *r_normal = nullptr) const;
|
||||
|
||||
inline bool encloses(const Rect2 &p_rect) const {
|
||||
|
||||
return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) &&
|
||||
((p_rect.position.x + p_rect.size.x) < (position.x + size.x)) &&
|
||||
((p_rect.position.y + p_rect.size.y) < (position.y + size.y));
|
||||
}
|
||||
|
||||
inline bool has_no_area() const {
|
||||
|
||||
return (size.x <= 0 || size.y <= 0);
|
||||
}
|
||||
Rect2 clip(const Rect2 &p_rect) const;
|
||||
@@ -82,7 +109,6 @@ struct Rect2 {
|
||||
inline bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }
|
||||
|
||||
inline Rect2 grow(real_t p_by) const {
|
||||
|
||||
Rect2 g = *this;
|
||||
g.position.x -= p_by;
|
||||
g.position.y -= p_by;
|
||||
@@ -92,7 +118,6 @@ struct Rect2 {
|
||||
}
|
||||
|
||||
inline Rect2 expand(const Vector2 &p_vector) const {
|
||||
|
||||
Rect2 r = *this;
|
||||
r.expand_to(p_vector);
|
||||
return r;
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Ref.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef REF_H
|
||||
#define REF_H
|
||||
|
||||
@@ -19,7 +49,6 @@ class Ref {
|
||||
T *reference = nullptr;
|
||||
|
||||
void ref(const Ref &p_from) {
|
||||
|
||||
if (p_from.reference == reference)
|
||||
return;
|
||||
|
||||
@@ -31,7 +60,6 @@ class Ref {
|
||||
}
|
||||
|
||||
void ref_pointer(T *p_ref) {
|
||||
|
||||
ERR_FAIL_COND(p_ref == nullptr);
|
||||
|
||||
if (p_ref->init_ref())
|
||||
@@ -40,44 +68,35 @@ class Ref {
|
||||
|
||||
public:
|
||||
inline bool operator<(const Ref<T> &p_r) const {
|
||||
|
||||
return reference < p_r.reference;
|
||||
}
|
||||
inline bool operator==(const Ref<T> &p_r) const {
|
||||
|
||||
return reference == p_r.reference;
|
||||
}
|
||||
inline bool operator!=(const Ref<T> &p_r) const {
|
||||
|
||||
return reference != p_r.reference;
|
||||
}
|
||||
|
||||
inline T *operator->() {
|
||||
|
||||
return reference;
|
||||
}
|
||||
|
||||
inline T *operator*() {
|
||||
|
||||
return reference;
|
||||
}
|
||||
|
||||
inline const T *operator->() const {
|
||||
|
||||
return reference;
|
||||
}
|
||||
|
||||
inline const T *ptr() const {
|
||||
|
||||
return reference;
|
||||
}
|
||||
inline T *ptr() {
|
||||
|
||||
return reference;
|
||||
}
|
||||
|
||||
inline const T *operator*() const {
|
||||
|
||||
return reference;
|
||||
}
|
||||
|
||||
@@ -88,7 +107,6 @@ public:
|
||||
}
|
||||
|
||||
void operator=(const Ref &p_from) {
|
||||
|
||||
ref(p_from);
|
||||
}
|
||||
|
||||
@@ -118,7 +136,6 @@ public:
|
||||
}
|
||||
|
||||
Ref(const Ref &p_from) {
|
||||
|
||||
reference = nullptr;
|
||||
ref(p_from);
|
||||
}
|
||||
@@ -138,7 +155,6 @@ public:
|
||||
}
|
||||
|
||||
Ref(T *p_reference) {
|
||||
|
||||
if (p_reference)
|
||||
ref_pointer(p_reference);
|
||||
else
|
||||
@@ -146,7 +162,6 @@ public:
|
||||
}
|
||||
|
||||
Ref(const Variant &p_variant) {
|
||||
|
||||
reference = nullptr;
|
||||
Object *refb = T::___get_from_variant(p_variant);
|
||||
if (refb == nullptr) {
|
||||
@@ -168,7 +183,6 @@ public:
|
||||
// mutexes will avoid more crashes?
|
||||
|
||||
if (reference && reference->unreference()) {
|
||||
|
||||
//memdelete(reference);
|
||||
reference->free();
|
||||
}
|
||||
@@ -181,12 +195,10 @@ public:
|
||||
}
|
||||
|
||||
Ref() {
|
||||
|
||||
reference = nullptr;
|
||||
}
|
||||
|
||||
~Ref() {
|
||||
|
||||
unref();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* String.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef STRING_H
|
||||
#define STRING_H
|
||||
|
||||
@@ -14,7 +44,6 @@ class PoolStringArray;
|
||||
class String;
|
||||
|
||||
class CharString {
|
||||
|
||||
friend class String;
|
||||
|
||||
godot_char_string _char_string;
|
||||
@@ -41,6 +70,7 @@ public:
|
||||
String(const wchar_t *contents);
|
||||
String(const wchar_t c);
|
||||
String(const String &other);
|
||||
String(String &&other);
|
||||
|
||||
~String();
|
||||
|
||||
@@ -56,6 +86,7 @@ public:
|
||||
wchar_t operator[](const int idx) const;
|
||||
|
||||
void operator=(const String &s);
|
||||
void operator=(String &&s);
|
||||
bool operator==(const String &s) const;
|
||||
bool operator!=(const String &s) const;
|
||||
String operator+(const String &s) const;
|
||||
@@ -74,14 +105,14 @@ public:
|
||||
CharString utf8() const;
|
||||
CharString ascii(bool p_extended = false) const;
|
||||
|
||||
bool begins_with(String &s) const;
|
||||
bool begins_with(const String &s) const;
|
||||
bool begins_with_char_array(const char *p_char_array) const;
|
||||
PoolStringArray bigrams() const;
|
||||
String c_escape() const;
|
||||
String c_unescape() const;
|
||||
String capitalize() const;
|
||||
bool empty() const;
|
||||
bool ends_with(String &text) const;
|
||||
bool ends_with(const String &text) const;
|
||||
void erase(int position, int chars);
|
||||
int find(String what, int from = 0) const;
|
||||
int find_last(String what) const;
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* TagDB.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TAGDB_HPP
|
||||
#define TAGDB_HPP
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Transform.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TRANSFORM_H
|
||||
#define TRANSFORM_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Transform2D.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef TRANSFORM2D_H
|
||||
#define TRANSFORM2D_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Variant.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VARIANT_H
|
||||
#define VARIANT_H
|
||||
|
||||
@@ -20,8 +50,6 @@
|
||||
#include "Vector2.hpp"
|
||||
#include "Vector3.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace godot {
|
||||
|
||||
class Dictionary;
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Vector2.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VECTOR2_H
|
||||
#define VECTOR2_H
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Vector3.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VECTOR3_H
|
||||
#define VECTOR3_H
|
||||
|
||||
@@ -14,7 +44,6 @@ namespace godot {
|
||||
class Basis;
|
||||
|
||||
struct Vector3 {
|
||||
|
||||
enum Axis {
|
||||
AXIS_X,
|
||||
AXIS_Y,
|
||||
@@ -305,7 +334,6 @@ inline Vector3 operator*(real_t p_scalar, const Vector3 &p_vec) {
|
||||
}
|
||||
|
||||
inline Vector3 vec3_cross(const Vector3 &p_a, const Vector3 &p_b) {
|
||||
|
||||
return p_a.cross(p_b);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Wrapped.hpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef WRAPPED_HPP
|
||||
#define WRAPPED_HPP
|
||||
|
||||
|
||||
4
misc/ci/sources.list
Normal file
4
misc/ci/sources.list
Normal file
@@ -0,0 +1,4 @@
|
||||
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
|
||||
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
|
||||
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
|
||||
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* AABB.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "AABB.hpp"
|
||||
#include "Plane.hpp"
|
||||
#include "Vector3.hpp"
|
||||
@@ -7,7 +37,6 @@
|
||||
namespace godot {
|
||||
|
||||
bool AABB::intersects(const AABB &p_aabb) const {
|
||||
|
||||
if (position.x >= (p_aabb.position.x + p_aabb.size.x))
|
||||
return false;
|
||||
if ((position.x + size.x) <= p_aabb.position.x)
|
||||
@@ -25,7 +54,6 @@ bool AABB::intersects(const AABB &p_aabb) const {
|
||||
}
|
||||
|
||||
bool AABB::intersects_inclusive(const AABB &p_aabb) const {
|
||||
|
||||
if (position.x > (p_aabb.position.x + p_aabb.size.x))
|
||||
return false;
|
||||
if ((position.x + size.x) < p_aabb.position.x)
|
||||
@@ -43,7 +71,6 @@ bool AABB::intersects_inclusive(const AABB &p_aabb) const {
|
||||
}
|
||||
|
||||
bool AABB::encloses(const AABB &p_aabb) const {
|
||||
|
||||
Vector3 src_min = position;
|
||||
Vector3 src_max = position + size;
|
||||
Vector3 dst_min = p_aabb.position;
|
||||
@@ -59,7 +86,6 @@ bool AABB::encloses(const AABB &p_aabb) const {
|
||||
}
|
||||
|
||||
Vector3 AABB::get_support(const Vector3 &p_normal) const {
|
||||
|
||||
Vector3 half_extents = size * 0.5;
|
||||
Vector3 ofs = position + half_extents;
|
||||
|
||||
@@ -71,23 +97,29 @@ Vector3 AABB::get_support(const Vector3 &p_normal) const {
|
||||
}
|
||||
|
||||
Vector3 AABB::get_endpoint(int p_point) const {
|
||||
|
||||
switch (p_point) {
|
||||
case 0: return Vector3(position.x, position.y, position.z);
|
||||
case 1: return Vector3(position.x, position.y, position.z + size.z);
|
||||
case 2: return Vector3(position.x, position.y + size.y, position.z);
|
||||
case 3: return Vector3(position.x, position.y + size.y, position.z + size.z);
|
||||
case 4: return Vector3(position.x + size.x, position.y, position.z);
|
||||
case 5: return Vector3(position.x + size.x, position.y, position.z + size.z);
|
||||
case 6: return Vector3(position.x + size.x, position.y + size.y, position.z);
|
||||
case 7: return Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
|
||||
case 0:
|
||||
return Vector3(position.x, position.y, position.z);
|
||||
case 1:
|
||||
return Vector3(position.x, position.y, position.z + size.z);
|
||||
case 2:
|
||||
return Vector3(position.x, position.y + size.y, position.z);
|
||||
case 3:
|
||||
return Vector3(position.x, position.y + size.y, position.z + size.z);
|
||||
case 4:
|
||||
return Vector3(position.x + size.x, position.y, position.z);
|
||||
case 5:
|
||||
return Vector3(position.x + size.x, position.y, position.z + size.z);
|
||||
case 6:
|
||||
return Vector3(position.x + size.x, position.y + size.y, position.z);
|
||||
case 7:
|
||||
return Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
|
||||
};
|
||||
|
||||
ERR_FAIL_V(Vector3());
|
||||
}
|
||||
|
||||
bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
|
||||
|
||||
Vector3 half_extents = size * 0.5;
|
||||
Vector3 ofs = position + half_extents;
|
||||
|
||||
@@ -106,7 +138,6 @@ bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count) con
|
||||
}
|
||||
|
||||
bool AABB::has_point(const Vector3 &p_point) const {
|
||||
|
||||
if (p_point.x < position.x)
|
||||
return false;
|
||||
if (p_point.y < position.y)
|
||||
@@ -124,7 +155,6 @@ bool AABB::has_point(const Vector3 &p_point) const {
|
||||
}
|
||||
|
||||
void AABB::expand_to(const Vector3 &p_vector) {
|
||||
|
||||
Vector3 begin = position;
|
||||
Vector3 end = position + size;
|
||||
|
||||
@@ -147,7 +177,6 @@ void AABB::expand_to(const Vector3 &p_vector) {
|
||||
}
|
||||
|
||||
void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
|
||||
|
||||
Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5);
|
||||
Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z);
|
||||
|
||||
@@ -158,7 +187,6 @@ void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r
|
||||
}
|
||||
|
||||
real_t AABB::get_longest_axis_size() const {
|
||||
|
||||
real_t max_size = size.x;
|
||||
|
||||
if (size.y > max_size) {
|
||||
@@ -173,7 +201,6 @@ real_t AABB::get_longest_axis_size() const {
|
||||
}
|
||||
|
||||
real_t AABB::get_shortest_axis_size() const {
|
||||
|
||||
real_t max_size = size.x;
|
||||
|
||||
if (size.y < max_size) {
|
||||
@@ -188,7 +215,6 @@ real_t AABB::get_shortest_axis_size() const {
|
||||
}
|
||||
|
||||
bool AABB::smits_intersect_ray(const Vector3 &from, const Vector3 &dir, real_t t0, real_t t1) const {
|
||||
|
||||
real_t divx = 1.0 / dir.x;
|
||||
real_t divy = 1.0 / dir.y;
|
||||
real_t divz = 1.0 / dir.z;
|
||||
@@ -232,7 +258,6 @@ bool AABB::smits_intersect_ray(const Vector3 &from, const Vector3 &dir, real_t t
|
||||
}
|
||||
|
||||
void AABB::grow_by(real_t p_amount) {
|
||||
|
||||
position.x -= p_amount;
|
||||
position.y -= p_amount;
|
||||
position.z -= p_amount;
|
||||
@@ -242,21 +267,17 @@ void AABB::grow_by(real_t p_amount) {
|
||||
}
|
||||
|
||||
real_t AABB::get_area() const {
|
||||
|
||||
return size.x * size.y * size.z;
|
||||
}
|
||||
|
||||
bool AABB::operator==(const AABB &p_rval) const {
|
||||
|
||||
return ((position == p_rval.position) && (size == p_rval.size));
|
||||
}
|
||||
bool AABB::operator!=(const AABB &p_rval) const {
|
||||
|
||||
return ((position != p_rval.position) || (size != p_rval.size));
|
||||
}
|
||||
|
||||
void AABB::merge_with(const AABB &p_aabb) {
|
||||
|
||||
Vector3 beg_1, beg_2;
|
||||
Vector3 end_1, end_2;
|
||||
Vector3 min, max;
|
||||
@@ -279,7 +300,6 @@ void AABB::merge_with(const AABB &p_aabb) {
|
||||
}
|
||||
|
||||
AABB AABB::intersection(const AABB &p_aabb) const {
|
||||
|
||||
Vector3 src_min = position;
|
||||
Vector3 src_max = position + size;
|
||||
Vector3 dst_min = p_aabb.position;
|
||||
@@ -290,7 +310,6 @@ AABB AABB::intersection(const AABB &p_aabb) const {
|
||||
if (src_min.x > dst_max.x || src_max.x < dst_min.x)
|
||||
return AABB();
|
||||
else {
|
||||
|
||||
min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x;
|
||||
max.x = (src_max.x < dst_max.x) ? src_max.x : dst_max.x;
|
||||
}
|
||||
@@ -298,7 +317,6 @@ AABB AABB::intersection(const AABB &p_aabb) const {
|
||||
if (src_min.y > dst_max.y || src_max.y < dst_min.y)
|
||||
return AABB();
|
||||
else {
|
||||
|
||||
min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y;
|
||||
max.y = (src_max.y < dst_max.y) ? src_max.y : dst_max.y;
|
||||
}
|
||||
@@ -306,7 +324,6 @@ AABB AABB::intersection(const AABB &p_aabb) const {
|
||||
if (src_min.z > dst_max.z || src_max.z < dst_min.z)
|
||||
return AABB();
|
||||
else {
|
||||
|
||||
min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z;
|
||||
max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z;
|
||||
}
|
||||
@@ -315,7 +332,6 @@ AABB AABB::intersection(const AABB &p_aabb) const {
|
||||
}
|
||||
|
||||
bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
|
||||
|
||||
Vector3 c1, c2;
|
||||
Vector3 end = position + size;
|
||||
real_t near = -1e20;
|
||||
@@ -358,7 +374,6 @@ bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *
|
||||
}
|
||||
|
||||
bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const {
|
||||
|
||||
real_t min = 0, max = 1;
|
||||
int axis = 0;
|
||||
real_t sign = 0;
|
||||
@@ -372,7 +387,6 @@ bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector
|
||||
real_t csign;
|
||||
|
||||
if (seg_from < seg_to) {
|
||||
|
||||
if (seg_from > box_end || seg_to < box_begin)
|
||||
return false;
|
||||
real_t length = seg_to - seg_from;
|
||||
@@ -381,7 +395,6 @@ bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector
|
||||
csign = -1.0;
|
||||
|
||||
} else {
|
||||
|
||||
if (seg_to > box_end || seg_from < box_begin)
|
||||
return false;
|
||||
real_t length = seg_to - seg_from;
|
||||
@@ -416,7 +429,6 @@ bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector
|
||||
}
|
||||
|
||||
bool AABB::intersects_plane(const Plane &p_plane) const {
|
||||
|
||||
Vector3 points[8] = {
|
||||
Vector3(position.x, position.y, position.z),
|
||||
Vector3(position.x, position.y, position.z + size.z),
|
||||
@@ -432,7 +444,6 @@ bool AABB::intersects_plane(const Plane &p_plane) const {
|
||||
bool under = false;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
|
||||
if (p_plane.distance_to(points[i]) > 0)
|
||||
over = true;
|
||||
else
|
||||
@@ -443,7 +454,6 @@ bool AABB::intersects_plane(const Plane &p_plane) const {
|
||||
}
|
||||
|
||||
Vector3 AABB::get_longest_axis() const {
|
||||
|
||||
Vector3 axis(1, 0, 0);
|
||||
real_t max_size = size.x;
|
||||
|
||||
@@ -460,7 +470,6 @@ Vector3 AABB::get_longest_axis() const {
|
||||
return axis;
|
||||
}
|
||||
int AABB::get_longest_axis_index() const {
|
||||
|
||||
int axis = 0;
|
||||
real_t max_size = size.x;
|
||||
|
||||
@@ -478,7 +487,6 @@ int AABB::get_longest_axis_index() const {
|
||||
}
|
||||
|
||||
Vector3 AABB::get_shortest_axis() const {
|
||||
|
||||
Vector3 axis(1, 0, 0);
|
||||
real_t max_size = size.x;
|
||||
|
||||
@@ -495,7 +503,6 @@ Vector3 AABB::get_shortest_axis() const {
|
||||
return axis;
|
||||
}
|
||||
int AABB::get_shortest_axis_index() const {
|
||||
|
||||
int axis = 0;
|
||||
real_t max_size = size.x;
|
||||
|
||||
@@ -513,7 +520,6 @@ int AABB::get_shortest_axis_index() const {
|
||||
}
|
||||
|
||||
AABB AABB::merge(const AABB &p_with) const {
|
||||
|
||||
AABB aabb = *this;
|
||||
aabb.merge_with(p_with);
|
||||
return aabb;
|
||||
@@ -524,24 +530,19 @@ AABB AABB::expand(const Vector3 &p_vector) const {
|
||||
return aabb;
|
||||
}
|
||||
AABB AABB::grow(real_t p_by) const {
|
||||
|
||||
AABB aabb = *this;
|
||||
aabb.grow_by(p_by);
|
||||
return aabb;
|
||||
}
|
||||
|
||||
void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
|
||||
|
||||
ERR_FAIL_INDEX(p_edge, 12);
|
||||
switch (p_edge) {
|
||||
|
||||
case 0: {
|
||||
|
||||
r_from = Vector3(position.x + size.x, position.y, position.z);
|
||||
r_to = Vector3(position.x, position.y, position.z);
|
||||
} break;
|
||||
case 1: {
|
||||
|
||||
r_from = Vector3(position.x + size.x, position.y, position.z + size.z);
|
||||
r_to = Vector3(position.x + size.x, position.y, position.z);
|
||||
} break;
|
||||
@@ -551,18 +552,15 @@ void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
|
||||
|
||||
} break;
|
||||
case 3: {
|
||||
|
||||
r_from = Vector3(position.x, position.y, position.z);
|
||||
r_to = Vector3(position.x, position.y, position.z + size.z);
|
||||
|
||||
} break;
|
||||
case 4: {
|
||||
|
||||
r_from = Vector3(position.x, position.y + size.y, position.z);
|
||||
r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
|
||||
} break;
|
||||
case 5: {
|
||||
|
||||
r_from = Vector3(position.x + size.x, position.y + size.y, position.z);
|
||||
r_to = Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
|
||||
} break;
|
||||
@@ -572,31 +570,26 @@ void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
|
||||
|
||||
} break;
|
||||
case 7: {
|
||||
|
||||
r_from = Vector3(position.x, position.y + size.y, position.z + size.z);
|
||||
r_to = Vector3(position.x, position.y + size.y, position.z);
|
||||
|
||||
} break;
|
||||
case 8: {
|
||||
|
||||
r_from = Vector3(position.x, position.y, position.z + size.z);
|
||||
r_to = Vector3(position.x, position.y + size.y, position.z + size.z);
|
||||
|
||||
} break;
|
||||
case 9: {
|
||||
|
||||
r_from = Vector3(position.x, position.y, position.z);
|
||||
r_to = Vector3(position.x, position.y + size.y, position.z);
|
||||
|
||||
} break;
|
||||
case 10: {
|
||||
|
||||
r_from = Vector3(position.x + size.x, position.y, position.z);
|
||||
r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
|
||||
|
||||
} break;
|
||||
case 11: {
|
||||
|
||||
r_from = Vector3(position.x + size.x, position.y, position.z + size.z);
|
||||
r_to = Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
|
||||
|
||||
@@ -605,7 +598,6 @@ void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
|
||||
}
|
||||
|
||||
AABB::operator String() const {
|
||||
|
||||
return String() + position + " - " + size;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Array.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Array.hpp"
|
||||
#include "GodotGlobal.hpp"
|
||||
#include "Variant.hpp"
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Basis.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Basis.hpp"
|
||||
#include "Defs.hpp"
|
||||
#include "Quat.hpp"
|
||||
@@ -19,12 +49,10 @@ Basis::Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) {
|
||||
}
|
||||
|
||||
Basis::Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
|
||||
|
||||
set(xx, xy, xz, yx, yy, yz, zx, zy, zz);
|
||||
}
|
||||
|
||||
Basis::Basis() {
|
||||
|
||||
elements[0][0] = 1;
|
||||
elements[0][1] = 0;
|
||||
elements[0][2] = 0;
|
||||
@@ -58,7 +86,6 @@ void Basis::invert() {
|
||||
#undef cofac
|
||||
|
||||
bool Basis::isequal_approx(const Basis &a, const Basis &b) const {
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if ((::fabs(a.elements[i][j] - b.elements[i][j]) < CMP_EPSILON) == false)
|
||||
@@ -174,7 +201,6 @@ Basis Basis::slerp(Basis b, float t) const {
|
||||
// the angles in the decomposition R = X(a1).Y(a2).Z(a3) where Z(a) rotates
|
||||
// around the z-axis by a and so on.
|
||||
Vector3 Basis::get_euler_xyz() const {
|
||||
|
||||
// Euler angles in XYZ convention.
|
||||
// See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
||||
//
|
||||
@@ -218,7 +244,6 @@ Vector3 Basis::get_euler_xyz() const {
|
||||
// and similar for other axes.
|
||||
// The current implementation uses XYZ convention (Z is the first rotation).
|
||||
void Basis::set_euler_xyz(const Vector3 &p_euler) {
|
||||
|
||||
real_t c, s;
|
||||
|
||||
c = ::cos(p_euler.x);
|
||||
@@ -241,7 +266,6 @@ void Basis::set_euler_xyz(const Vector3 &p_euler) {
|
||||
// as in first-Z, then-X, last-Y. The angles for X, Y, and Z rotations are returned
|
||||
// as the x, y, and z components of a Vector3 respectively.
|
||||
Vector3 Basis::get_euler_yxz() const {
|
||||
|
||||
// Euler angles in YXZ convention.
|
||||
// See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
||||
//
|
||||
@@ -287,7 +311,6 @@ Vector3 Basis::get_euler_yxz() const {
|
||||
// and similar for other axes.
|
||||
// The current implementation uses YXZ convention (Z is the first rotation).
|
||||
void Basis::set_euler_yxz(const Vector3 &p_euler) {
|
||||
|
||||
real_t c, s;
|
||||
|
||||
c = ::cos(p_euler.x);
|
||||
@@ -333,7 +356,6 @@ bool Basis::operator!=(const Basis &p_matrix) const {
|
||||
}
|
||||
|
||||
Vector3 Basis::xform(const Vector3 &p_vector) const {
|
||||
|
||||
return Vector3(
|
||||
elements[0].dot(p_vector),
|
||||
elements[1].dot(p_vector),
|
||||
@@ -341,7 +363,6 @@ Vector3 Basis::xform(const Vector3 &p_vector) const {
|
||||
}
|
||||
|
||||
Vector3 Basis::xform_inv(const Vector3 &p_vector) const {
|
||||
|
||||
return Vector3(
|
||||
(elements[0][0] * p_vector.x) + (elements[1][0] * p_vector.y) + (elements[2][0] * p_vector.z),
|
||||
(elements[0][1] * p_vector.x) + (elements[1][1] * p_vector.y) + (elements[2][1] * p_vector.z),
|
||||
@@ -362,42 +383,36 @@ Basis Basis::operator*(const Basis &p_matrix) const {
|
||||
}
|
||||
|
||||
void Basis::operator+=(const Basis &p_matrix) {
|
||||
|
||||
elements[0] += p_matrix.elements[0];
|
||||
elements[1] += p_matrix.elements[1];
|
||||
elements[2] += p_matrix.elements[2];
|
||||
}
|
||||
|
||||
Basis Basis::operator+(const Basis &p_matrix) const {
|
||||
|
||||
Basis ret(*this);
|
||||
ret += p_matrix;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Basis::operator-=(const Basis &p_matrix) {
|
||||
|
||||
elements[0] -= p_matrix.elements[0];
|
||||
elements[1] -= p_matrix.elements[1];
|
||||
elements[2] -= p_matrix.elements[2];
|
||||
}
|
||||
|
||||
Basis Basis::operator-(const Basis &p_matrix) const {
|
||||
|
||||
Basis ret(*this);
|
||||
ret -= p_matrix;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Basis::operator*=(real_t p_val) {
|
||||
|
||||
elements[0] *= p_val;
|
||||
elements[1] *= p_val;
|
||||
elements[2] *= p_val;
|
||||
}
|
||||
|
||||
Basis Basis::operator*(real_t p_val) const {
|
||||
|
||||
Basis ret(*this);
|
||||
ret *= p_val;
|
||||
return ret;
|
||||
@@ -406,9 +421,7 @@ Basis Basis::operator*(real_t p_val) const {
|
||||
Basis::operator String() const {
|
||||
String s;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
|
||||
if (i != 0 || j != 0)
|
||||
s += ", ";
|
||||
|
||||
@@ -421,7 +434,6 @@ Basis::operator String() const {
|
||||
/* create / set */
|
||||
|
||||
void Basis::set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
|
||||
|
||||
elements[0][0] = xx;
|
||||
elements[0][1] = xy;
|
||||
elements[0][2] = xz;
|
||||
@@ -433,12 +445,10 @@ void Basis::set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz
|
||||
elements[2][2] = zz;
|
||||
}
|
||||
Vector3 Basis::get_column(int i) const {
|
||||
|
||||
return Vector3(elements[0][i], elements[1][i], elements[2][i]);
|
||||
}
|
||||
|
||||
Vector3 Basis::get_row(int i) const {
|
||||
|
||||
return Vector3(elements[i][0], elements[i][1], elements[i][2]);
|
||||
}
|
||||
Vector3 Basis::get_main_diagonal() const {
|
||||
@@ -593,7 +603,6 @@ int Basis::get_orthogonal_index() const {
|
||||
Basis orth = *this;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
|
||||
real_t v = orth[i][j];
|
||||
if (v > 0.5)
|
||||
v = 1.0;
|
||||
@@ -607,7 +616,6 @@ int Basis::get_orthogonal_index() const {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 24; i++) {
|
||||
|
||||
if (_ortho_bases[i] == orth)
|
||||
return i;
|
||||
}
|
||||
@@ -616,7 +624,6 @@ int Basis::get_orthogonal_index() const {
|
||||
}
|
||||
|
||||
void Basis::set_orthogonal_index(int p_index) {
|
||||
|
||||
//there only exist 24 orthogonal bases in r3
|
||||
ERR_FAIL_COND(p_index >= 24);
|
||||
|
||||
@@ -624,7 +631,6 @@ void Basis::set_orthogonal_index(int p_index) {
|
||||
}
|
||||
|
||||
Basis::Basis(const Vector3 &p_euler) {
|
||||
|
||||
set_euler(p_euler);
|
||||
}
|
||||
|
||||
@@ -635,7 +641,6 @@ Basis::Basis(const Vector3 &p_euler) {
|
||||
namespace godot {
|
||||
|
||||
Basis::Basis(const Quat &p_quat) {
|
||||
|
||||
real_t d = p_quat.length_squared();
|
||||
real_t s = 2.0 / d;
|
||||
real_t xs = p_quat.x * s, ys = p_quat.y * s, zs = p_quat.z * s;
|
||||
@@ -685,8 +690,8 @@ Basis::operator Quat() const {
|
||||
temp[2] = ((elements[1][0] - elements[0][1]) * s);
|
||||
} else {
|
||||
int i = elements[0][0] < elements[1][1] ?
|
||||
(elements[1][1] < elements[2][2] ? 2 : 1) :
|
||||
(elements[0][0] < elements[2][2] ? 2 : 0);
|
||||
(elements[1][1] < elements[2][2] ? 2 : 1) :
|
||||
(elements[0][0] < elements[2][2] ? 2 : 0);
|
||||
int j = (i + 1) % 3;
|
||||
int k = (i + 2) % 3;
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*************************************************************************/
|
||||
/* camera_matrix.cpp */
|
||||
/* CameraMatrix.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
@@ -31,29 +31,22 @@
|
||||
#include "CameraMatrix.hpp"
|
||||
|
||||
void CameraMatrix::set_identity() {
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
|
||||
matrix[i][j] = (i == j) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CameraMatrix::set_zero() {
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
|
||||
matrix[i][j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Plane CameraMatrix::xform4(const Plane &p_vec4) const {
|
||||
|
||||
Plane ret;
|
||||
|
||||
ret.normal.x = matrix[0][0] * p_vec4.normal.x + matrix[1][0] * p_vec4.normal.y + matrix[2][0] * p_vec4.normal.z + matrix[3][0] * p_vec4.d;
|
||||
@@ -64,7 +57,6 @@ Plane CameraMatrix::xform4(const Plane &p_vec4) const {
|
||||
}
|
||||
|
||||
void CameraMatrix::set_perspective(real_t p_fovy_degrees, real_t p_aspect, real_t p_z_near, real_t p_z_far, bool p_flip_fov) {
|
||||
|
||||
if (p_flip_fov) {
|
||||
p_fovy_degrees = get_fovy(p_fovy_degrees, 1.0 / p_aspect);
|
||||
}
|
||||
@@ -157,7 +149,6 @@ void CameraMatrix::set_for_hmd(int p_eye, real_t p_aspect, real_t p_intraocular_
|
||||
};
|
||||
|
||||
void CameraMatrix::set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_znear, real_t p_zfar) {
|
||||
|
||||
set_identity();
|
||||
|
||||
matrix[0][0] = 2.0 / (p_right - p_left);
|
||||
@@ -170,7 +161,6 @@ void CameraMatrix::set_orthogonal(real_t p_left, real_t p_right, real_t p_bottom
|
||||
}
|
||||
|
||||
void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear, real_t p_zfar, bool p_flip_fov) {
|
||||
|
||||
if (!p_flip_fov) {
|
||||
p_size *= p_aspect;
|
||||
}
|
||||
@@ -179,7 +169,6 @@ void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear
|
||||
}
|
||||
|
||||
void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far) {
|
||||
|
||||
ERR_FAIL_COND(p_right <= p_left);
|
||||
ERR_FAIL_COND(p_top <= p_bottom);
|
||||
ERR_FAIL_COND(p_far <= p_near);
|
||||
@@ -220,7 +209,6 @@ void CameraMatrix::set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset,
|
||||
}
|
||||
|
||||
real_t CameraMatrix::get_z_far() const {
|
||||
|
||||
const real_t *matrix = (const real_t *)this->matrix;
|
||||
Plane new_plane = Plane(matrix[3] - matrix[2],
|
||||
matrix[7] - matrix[6],
|
||||
@@ -233,7 +221,6 @@ real_t CameraMatrix::get_z_far() const {
|
||||
return new_plane.d;
|
||||
}
|
||||
real_t CameraMatrix::get_z_near() const {
|
||||
|
||||
const real_t *matrix = (const real_t *)this->matrix;
|
||||
Plane new_plane = Plane(matrix[3] + matrix[2],
|
||||
matrix[7] + matrix[6],
|
||||
@@ -245,7 +232,6 @@ real_t CameraMatrix::get_z_near() const {
|
||||
}
|
||||
|
||||
Vector2 CameraMatrix::get_viewport_half_extents() const {
|
||||
|
||||
const real_t *matrix = (const real_t *)this->matrix;
|
||||
///////--- Near Plane ---///////
|
||||
Plane near_plane = Plane(matrix[3] + matrix[2],
|
||||
@@ -274,7 +260,6 @@ Vector2 CameraMatrix::get_viewport_half_extents() const {
|
||||
}
|
||||
|
||||
bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8points) const {
|
||||
|
||||
std::vector<Plane> planes = get_projection_planes(Transform());
|
||||
const Planes intersections[8][3] = {
|
||||
{ PLANE_FAR, PLANE_LEFT, PLANE_TOP },
|
||||
@@ -288,7 +273,6 @@ bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8point
|
||||
};
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
|
||||
Vector3 point;
|
||||
bool res = planes[intersections[i][0]].intersect_3(planes[intersections[i][1]], planes[intersections[i][2]], &point);
|
||||
ERR_FAIL_COND_V(!res, false);
|
||||
@@ -299,7 +283,6 @@ bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8point
|
||||
}
|
||||
|
||||
std::vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transform) const {
|
||||
|
||||
/** Fast Plane Extraction from combined modelview/projection matrices.
|
||||
* References:
|
||||
* https://web.archive.org/web/20011221205252/http://www.markmorley.com/opengl/frustumculling.html
|
||||
@@ -382,14 +365,12 @@ std::vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transf
|
||||
}
|
||||
|
||||
CameraMatrix CameraMatrix::inverse() const {
|
||||
|
||||
CameraMatrix cm = *this;
|
||||
cm.invert();
|
||||
return cm;
|
||||
}
|
||||
|
||||
void CameraMatrix::invert() {
|
||||
|
||||
int i, j, k;
|
||||
int pvt_i[4], pvt_j[4]; /* Locations of pivot matrix */
|
||||
real_t pvt_val; /* Value of current pivot element */
|
||||
@@ -440,20 +421,23 @@ void CameraMatrix::invert() {
|
||||
|
||||
/** Divide column by minus pivot value **/
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (i != k) matrix[i][k] /= (-pvt_val);
|
||||
if (i != k)
|
||||
matrix[i][k] /= (-pvt_val);
|
||||
}
|
||||
|
||||
/** Reduce the matrix **/
|
||||
for (i = 0; i < 4; i++) {
|
||||
hold = matrix[i][k];
|
||||
for (j = 0; j < 4; j++) {
|
||||
if (i != k && j != k) matrix[i][j] += hold * matrix[k][j];
|
||||
if (i != k && j != k)
|
||||
matrix[i][j] += hold * matrix[k][j];
|
||||
}
|
||||
}
|
||||
|
||||
/** Divide row by pivot **/
|
||||
for (j = 0; j < 4; j++) {
|
||||
if (j != k) matrix[k][j] /= pvt_val;
|
||||
if (j != k)
|
||||
matrix[k][j] /= pvt_val;
|
||||
}
|
||||
|
||||
/** Replace pivot by reciprocal (at last we can touch it). **/
|
||||
@@ -483,12 +467,10 @@ void CameraMatrix::invert() {
|
||||
}
|
||||
|
||||
CameraMatrix::CameraMatrix() {
|
||||
|
||||
set_identity();
|
||||
}
|
||||
|
||||
CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const {
|
||||
|
||||
CameraMatrix new_matrix;
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
@@ -504,7 +486,6 @@ CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const {
|
||||
}
|
||||
|
||||
void CameraMatrix::set_light_bias() {
|
||||
|
||||
real_t *m = &matrix[0][0];
|
||||
|
||||
m[0] = 0.5;
|
||||
@@ -526,7 +507,6 @@ void CameraMatrix::set_light_bias() {
|
||||
}
|
||||
|
||||
void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
|
||||
|
||||
real_t *m = &matrix[0][0];
|
||||
|
||||
m[0] = p_rect.size.width;
|
||||
@@ -548,7 +528,6 @@ void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
|
||||
}
|
||||
|
||||
CameraMatrix::operator String() const {
|
||||
|
||||
String str;
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
@@ -558,20 +537,17 @@ CameraMatrix::operator String() const {
|
||||
}
|
||||
|
||||
real_t CameraMatrix::get_aspect() const {
|
||||
|
||||
Vector2 vp_he = get_viewport_half_extents();
|
||||
return vp_he.x / vp_he.y;
|
||||
}
|
||||
|
||||
int CameraMatrix::get_pixels_per_meter(int p_for_pixel_width) const {
|
||||
|
||||
Vector3 result = xform(Vector3(1, 0, -1));
|
||||
|
||||
return int((result.x * 0.5 + 0.5) * p_for_pixel_width);
|
||||
}
|
||||
|
||||
bool CameraMatrix::is_orthogonal() const {
|
||||
|
||||
return matrix[3][3] == 1.0;
|
||||
}
|
||||
|
||||
@@ -585,7 +561,7 @@ real_t CameraMatrix::get_fov() const {
|
||||
right_plane.normalize();
|
||||
|
||||
if ((matrix[8] == 0) && (matrix[9] == 0)) {
|
||||
return Math::rad2deg(acos(abs(right_plane.normal.x))) * 2.0;
|
||||
return Math::rad2deg(acos(std::abs(right_plane.normal.x))) * 2.0;
|
||||
} else {
|
||||
// our frustum is asymmetrical need to calculate the left planes angle separately..
|
||||
Plane left_plane = Plane(matrix[3] + matrix[0],
|
||||
@@ -594,12 +570,11 @@ real_t CameraMatrix::get_fov() const {
|
||||
matrix[15] + matrix[12]);
|
||||
left_plane.normalize();
|
||||
|
||||
return Math::rad2deg(acos(abs(left_plane.normal.x))) + Math::rad2deg(acos(abs(right_plane.normal.x)));
|
||||
return Math::rad2deg(acos(std::abs(left_plane.normal.x))) + Math::rad2deg(acos(std::abs(right_plane.normal.x)));
|
||||
}
|
||||
}
|
||||
|
||||
void CameraMatrix::make_scale(const Vector3 &p_scale) {
|
||||
|
||||
set_identity();
|
||||
matrix[0][0] = p_scale.x;
|
||||
matrix[1][1] = p_scale.y;
|
||||
@@ -607,7 +582,6 @@ void CameraMatrix::make_scale(const Vector3 &p_scale) {
|
||||
}
|
||||
|
||||
void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
|
||||
|
||||
Vector3 min = p_aabb.position;
|
||||
Vector3 max = p_aabb.position + p_aabb.size;
|
||||
|
||||
@@ -633,7 +607,6 @@ void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
|
||||
}
|
||||
|
||||
CameraMatrix::operator Transform() const {
|
||||
|
||||
Transform tr;
|
||||
const real_t *m = &matrix[0][0];
|
||||
|
||||
@@ -657,7 +630,6 @@ CameraMatrix::operator Transform() const {
|
||||
}
|
||||
|
||||
CameraMatrix::CameraMatrix(const Transform &p_transform) {
|
||||
|
||||
const Transform &tr = p_transform;
|
||||
real_t *m = &matrix[0][0];
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Color.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Color.hpp"
|
||||
#include "Defs.hpp"
|
||||
#include "String.hpp"
|
||||
@@ -13,11 +43,9 @@ namespace godot {
|
||||
static String _to_hex(float p_val);
|
||||
|
||||
static float _parse_col(const String &p_str, int p_ofs) {
|
||||
|
||||
int ig = 0;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
int c = (int)(wchar_t)p_str[i + p_ofs];
|
||||
int v = 0;
|
||||
|
||||
@@ -43,7 +71,6 @@ static float _parse_col(const String &p_str, int p_ofs) {
|
||||
}
|
||||
|
||||
uint32_t Color::to_32() const {
|
||||
|
||||
uint32_t c = (uint8_t)(a * 255);
|
||||
c <<= 8;
|
||||
c |= (uint8_t)(r * 255);
|
||||
@@ -148,7 +175,6 @@ uint8_t Color::get_a8() const {
|
||||
}
|
||||
|
||||
float Color::get_h() const {
|
||||
|
||||
float min = MIN(r, g);
|
||||
min = MIN(min, b);
|
||||
float max = MAX(r, g);
|
||||
@@ -334,7 +360,6 @@ Color Color::contrasted() const {
|
||||
}
|
||||
|
||||
Color Color::linear_interpolate(const Color &p_b, float p_t) const {
|
||||
|
||||
Color res = *this;
|
||||
|
||||
res.r += (p_t * (p_b.r - r));
|
||||
@@ -346,7 +371,6 @@ Color Color::linear_interpolate(const Color &p_b, float p_t) const {
|
||||
}
|
||||
|
||||
Color Color::blend(const Color &p_over) const {
|
||||
|
||||
Color res;
|
||||
float sa = 1.0 - p_over.a;
|
||||
res.a = a * sa + p_over.a;
|
||||
@@ -361,7 +385,6 @@ Color Color::blend(const Color &p_over) const {
|
||||
}
|
||||
|
||||
Color Color::to_linear() const {
|
||||
|
||||
return Color(
|
||||
r < 0.04045 ? r * (1.0 / 12.92) : ::pow((r + 0.055) * (1.0 / (1 + 0.055)), 2.4),
|
||||
g < 0.04045 ? g * (1.0 / 12.92) : ::pow((g + 0.055) * (1.0 / (1 + 0.055)), 2.4),
|
||||
@@ -477,13 +500,11 @@ bool Color::html_is_valid(const String &p_color) {
|
||||
#define CLAMP(m_a, m_min, m_max) (((m_a) < (m_min)) ? (m_min) : (((m_a) > (m_max)) ? m_max : m_a))
|
||||
#endif
|
||||
static String _to_hex(float p_val) {
|
||||
|
||||
int v = p_val * 255;
|
||||
v = CLAMP(v, 0, 255);
|
||||
String ret;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
wchar_t c[2] = { 0, 0 };
|
||||
int lv = v & 0xF;
|
||||
if (lv < 10)
|
||||
@@ -514,7 +535,6 @@ Color::operator String() const {
|
||||
}
|
||||
|
||||
bool Color::operator<(const Color &p_color) const {
|
||||
|
||||
if (r == p_color.r) {
|
||||
if (g == p_color.g) {
|
||||
if (b == p_color.b) {
|
||||
@@ -528,7 +548,6 @@ bool Color::operator<(const Color &p_color) const {
|
||||
}
|
||||
|
||||
Color Color::operator+(const Color &p_color) const {
|
||||
|
||||
return Color(
|
||||
r + p_color.r,
|
||||
g + p_color.g,
|
||||
@@ -537,7 +556,6 @@ Color Color::operator+(const Color &p_color) const {
|
||||
}
|
||||
|
||||
void Color::operator+=(const Color &p_color) {
|
||||
|
||||
r = r + p_color.r;
|
||||
g = g + p_color.g;
|
||||
b = b + p_color.b;
|
||||
@@ -545,7 +563,6 @@ void Color::operator+=(const Color &p_color) {
|
||||
}
|
||||
|
||||
Color Color::operator-(const Color &p_color) const {
|
||||
|
||||
return Color(
|
||||
r - p_color.r,
|
||||
g - p_color.g,
|
||||
@@ -554,7 +571,6 @@ Color Color::operator-(const Color &p_color) const {
|
||||
}
|
||||
|
||||
void Color::operator-=(const Color &p_color) {
|
||||
|
||||
r = r - p_color.r;
|
||||
g = g - p_color.g;
|
||||
b = b - p_color.b;
|
||||
@@ -562,7 +578,6 @@ void Color::operator-=(const Color &p_color) {
|
||||
}
|
||||
|
||||
Color Color::operator*(const Color &p_color) const {
|
||||
|
||||
return Color(
|
||||
r * p_color.r,
|
||||
g * p_color.g,
|
||||
@@ -571,7 +586,6 @@ Color Color::operator*(const Color &p_color) const {
|
||||
}
|
||||
|
||||
Color Color::operator*(const real_t &rvalue) const {
|
||||
|
||||
return Color(
|
||||
r * rvalue,
|
||||
g * rvalue,
|
||||
@@ -580,7 +594,6 @@ Color Color::operator*(const real_t &rvalue) const {
|
||||
}
|
||||
|
||||
void Color::operator*=(const Color &p_color) {
|
||||
|
||||
r = r * p_color.r;
|
||||
g = g * p_color.g;
|
||||
b = b * p_color.b;
|
||||
@@ -588,7 +601,6 @@ void Color::operator*=(const Color &p_color) {
|
||||
}
|
||||
|
||||
void Color::operator*=(const real_t &rvalue) {
|
||||
|
||||
r = r * rvalue;
|
||||
g = g * rvalue;
|
||||
b = b * rvalue;
|
||||
@@ -596,7 +608,6 @@ void Color::operator*=(const real_t &rvalue) {
|
||||
}
|
||||
|
||||
Color Color::operator/(const Color &p_color) const {
|
||||
|
||||
return Color(
|
||||
r / p_color.r,
|
||||
g / p_color.g,
|
||||
@@ -605,7 +616,6 @@ Color Color::operator/(const Color &p_color) const {
|
||||
}
|
||||
|
||||
Color Color::operator/(const real_t &rvalue) const {
|
||||
|
||||
return Color(
|
||||
r / rvalue,
|
||||
g / rvalue,
|
||||
@@ -614,7 +624,6 @@ Color Color::operator/(const real_t &rvalue) const {
|
||||
}
|
||||
|
||||
void Color::operator/=(const Color &p_color) {
|
||||
|
||||
r = r / p_color.r;
|
||||
g = g / p_color.g;
|
||||
b = b / p_color.b;
|
||||
@@ -622,7 +631,6 @@ void Color::operator/=(const Color &p_color) {
|
||||
}
|
||||
|
||||
void Color::operator/=(const real_t &rvalue) {
|
||||
|
||||
if (rvalue == 0) {
|
||||
r = 1.0;
|
||||
g = 1.0;
|
||||
@@ -637,7 +645,6 @@ void Color::operator/=(const real_t &rvalue) {
|
||||
}
|
||||
|
||||
Color Color::operator-() const {
|
||||
|
||||
return Color(
|
||||
1.0 - r,
|
||||
1.0 - g,
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Dictionary.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Dictionary.hpp"
|
||||
#include "Array.hpp"
|
||||
#include "GodotGlobal.hpp"
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* GodotGlobal.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "GodotGlobal.hpp"
|
||||
|
||||
#include "String.hpp"
|
||||
@@ -55,9 +85,12 @@ void Godot::print_warning(const String &description, const String &function, con
|
||||
godot::api->godot_print_warning(c_desc, c_func, c_file, line);
|
||||
};
|
||||
|
||||
if (c_desc != nullptr) godot::api->godot_free(c_desc);
|
||||
if (c_func != nullptr) godot::api->godot_free(c_func);
|
||||
if (c_file != nullptr) godot::api->godot_free(c_file);
|
||||
if (c_desc != nullptr)
|
||||
godot::api->godot_free(c_desc);
|
||||
if (c_func != nullptr)
|
||||
godot::api->godot_free(c_func);
|
||||
if (c_file != nullptr)
|
||||
godot::api->godot_free(c_file);
|
||||
}
|
||||
|
||||
void Godot::print_error(const String &description, const String &function, const String &file, int line) {
|
||||
@@ -71,9 +104,12 @@ void Godot::print_error(const String &description, const String &function, const
|
||||
godot::api->godot_print_error(c_desc, c_func, c_file, line);
|
||||
};
|
||||
|
||||
if (c_desc != nullptr) godot::api->godot_free(c_desc);
|
||||
if (c_func != nullptr) godot::api->godot_free(c_func);
|
||||
if (c_file != nullptr) godot::api->godot_free(c_file);
|
||||
if (c_desc != nullptr)
|
||||
godot::api->godot_free(c_desc);
|
||||
if (c_func != nullptr)
|
||||
godot::api->godot_free(c_func);
|
||||
if (c_file != nullptr)
|
||||
godot::api->godot_free(c_file);
|
||||
}
|
||||
|
||||
void ___register_types();
|
||||
@@ -136,7 +172,8 @@ void Godot::gdnative_init(godot_gdnative_init_options *options) {
|
||||
}
|
||||
} break;
|
||||
|
||||
default: break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* NodePath.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "NodePath.hpp"
|
||||
#include "GodotGlobal.hpp"
|
||||
#include "String.hpp"
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Plane.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Plane.hpp"
|
||||
#include "Vector3.hpp"
|
||||
|
||||
@@ -10,12 +40,10 @@ void Plane::set_normal(const Vector3 &p_normal) {
|
||||
}
|
||||
|
||||
Vector3 Plane::project(const Vector3 &p_point) const {
|
||||
|
||||
return p_point - normal * distance_to(p_point);
|
||||
}
|
||||
|
||||
void Plane::normalize() {
|
||||
|
||||
real_t l = normal.length();
|
||||
if (l == 0) {
|
||||
*this = Plane(0, 0, 0, 0);
|
||||
@@ -26,19 +54,16 @@ void Plane::normalize() {
|
||||
}
|
||||
|
||||
Plane Plane::normalized() const {
|
||||
|
||||
Plane p = *this;
|
||||
p.normalize();
|
||||
return p;
|
||||
}
|
||||
|
||||
Vector3 Plane::get_any_point() const {
|
||||
|
||||
return get_normal() * d;
|
||||
}
|
||||
|
||||
Vector3 Plane::get_any_perpendicular_normal() const {
|
||||
|
||||
static const Vector3 p1 = Vector3(1, 0, 0);
|
||||
static const Vector3 p2 = Vector3(0, 1, 0);
|
||||
Vector3 p;
|
||||
@@ -57,7 +82,6 @@ Vector3 Plane::get_any_perpendicular_normal() const {
|
||||
/* intersections */
|
||||
|
||||
bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result) const {
|
||||
|
||||
const Plane &p_plane0 = *this;
|
||||
Vector3 normal0 = p_plane0.normal;
|
||||
Vector3 normal1 = p_plane1.normal;
|
||||
@@ -79,13 +103,11 @@ bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r
|
||||
}
|
||||
|
||||
bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const {
|
||||
|
||||
Vector3 segment = p_dir;
|
||||
real_t den = normal.dot(segment);
|
||||
|
||||
//printf("den is %i\n",den);
|
||||
if (::fabs(den) <= CMP_EPSILON) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,13 +126,11 @@ bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersectio
|
||||
}
|
||||
|
||||
bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const {
|
||||
|
||||
Vector3 segment = p_begin - p_end;
|
||||
real_t den = normal.dot(segment);
|
||||
|
||||
//printf("den is %i\n",den);
|
||||
if (::fabs(den) <= CMP_EPSILON) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -118,7 +138,6 @@ bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_inters
|
||||
//printf("dist is %i\n",dist);
|
||||
|
||||
if (dist < -CMP_EPSILON || dist > (1.0 + CMP_EPSILON)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -131,47 +150,39 @@ bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_inters
|
||||
/* misc */
|
||||
|
||||
bool Plane::is_almost_like(const Plane &p_plane) const {
|
||||
|
||||
return (normal.dot(p_plane.normal) > _PLANE_EQ_DOT_EPSILON && ::fabs(d - p_plane.d) < _PLANE_EQ_D_EPSILON);
|
||||
}
|
||||
|
||||
Plane::operator String() const {
|
||||
|
||||
// return normal.operator String() + ", " + rtos(d);
|
||||
return String(); // @Todo
|
||||
}
|
||||
|
||||
bool Plane::is_point_over(const Vector3 &p_point) const {
|
||||
|
||||
return (normal.dot(p_point) > d);
|
||||
}
|
||||
|
||||
real_t Plane::distance_to(const Vector3 &p_point) const {
|
||||
|
||||
return (normal.dot(p_point) - d);
|
||||
}
|
||||
|
||||
bool Plane::has_point(const Vector3 &p_point, real_t _epsilon) const {
|
||||
|
||||
real_t dist = normal.dot(p_point) - d;
|
||||
dist = ::fabs(dist);
|
||||
return (dist <= _epsilon);
|
||||
}
|
||||
|
||||
Plane::Plane(const Vector3 &p_normal, real_t p_d) {
|
||||
|
||||
normal = p_normal;
|
||||
d = p_d;
|
||||
}
|
||||
|
||||
Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal) {
|
||||
|
||||
normal = p_normal;
|
||||
d = p_normal.dot(p_point);
|
||||
}
|
||||
|
||||
Plane::Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir) {
|
||||
|
||||
if (p_dir == CLOCKWISE)
|
||||
normal = (p_point1 - p_point3).cross(p_point1 - p_point2);
|
||||
else
|
||||
@@ -182,12 +193,10 @@ Plane::Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_
|
||||
}
|
||||
|
||||
bool Plane::operator==(const Plane &p_plane) const {
|
||||
|
||||
return normal == p_plane.normal && d == p_plane.d;
|
||||
}
|
||||
|
||||
bool Plane::operator!=(const Plane &p_plane) const {
|
||||
|
||||
return normal != p_plane.normal || d != p_plane.d;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* PoolArrays.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "PoolArrays.hpp"
|
||||
#include "Color.hpp"
|
||||
#include "Defs.hpp"
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Quat.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Quat.hpp"
|
||||
#include "Basis.hpp"
|
||||
#include "Defs.hpp"
|
||||
@@ -100,7 +130,6 @@ Quat Quat::inverse() const {
|
||||
}
|
||||
|
||||
Quat Quat::slerp(const Quat &q, const real_t &t) const {
|
||||
|
||||
Quat to1;
|
||||
real_t omega, cosom, sinom, scale0, scale1;
|
||||
|
||||
@@ -144,12 +173,12 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const {
|
||||
}
|
||||
|
||||
Quat Quat::slerpni(const Quat &q, const real_t &t) const {
|
||||
|
||||
const Quat &from = *this;
|
||||
|
||||
real_t dot = from.dot(q);
|
||||
|
||||
if (::fabs(dot) > 0.9999) return from;
|
||||
if (::fabs(dot) > 0.9999)
|
||||
return from;
|
||||
|
||||
real_t theta = ::acos(dot),
|
||||
sinT = 1.0 / ::sin(theta),
|
||||
@@ -200,7 +229,6 @@ Quat Quat::operator*(const Vector3 &v) const {
|
||||
}
|
||||
|
||||
Vector3 Quat::xform(const Vector3 &v) const {
|
||||
|
||||
Quat q = *this * v;
|
||||
q *= this->inverse();
|
||||
return Vector3(q.x, q.y, q.z);
|
||||
@@ -234,7 +262,6 @@ Quat::Quat(const Vector3 &v0, const Vector3 &v1) // shortest arc
|
||||
z = 0;
|
||||
w = 0;
|
||||
} else {
|
||||
|
||||
real_t s = ::sqrt((1.0 + d) * 2.0);
|
||||
real_t rs = 1.0 / s;
|
||||
|
||||
@@ -282,7 +309,6 @@ void Quat::operator*=(const real_t &s) {
|
||||
}
|
||||
|
||||
void Quat::operator/=(const real_t &s) {
|
||||
|
||||
*this *= 1.0 / s;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* RID.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "RID.hpp"
|
||||
|
||||
#include <gdnative/rid.h>
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Rect2.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Rect2.hpp"
|
||||
#include "String.hpp"
|
||||
#include "Transform2D.hpp"
|
||||
@@ -16,26 +46,35 @@ namespace godot {
|
||||
#endif
|
||||
|
||||
real_t Rect2::distance_to(const Vector2 &p_point) const {
|
||||
|
||||
real_t dist = 1e20;
|
||||
real_t dist = 0.0;
|
||||
bool inside = true;
|
||||
|
||||
if (p_point.x < position.x) {
|
||||
dist = MIN(dist, position.x - p_point.x);
|
||||
real_t d = position.x - p_point.x;
|
||||
dist = d;
|
||||
inside = false;
|
||||
}
|
||||
if (p_point.y < position.y) {
|
||||
dist = MIN(dist, position.y - p_point.y);
|
||||
real_t d = position.y - p_point.y;
|
||||
dist = inside ? d : MIN(dist, d);
|
||||
inside = false;
|
||||
}
|
||||
if (p_point.x >= (position.x + size.x)) {
|
||||
dist = MIN(p_point.x - (position.x + size.x), dist);
|
||||
real_t d = p_point.x - (position.x + size.x);
|
||||
dist = inside ? d : MIN(dist, d);
|
||||
inside = false;
|
||||
}
|
||||
if (p_point.y >= (position.y + size.y)) {
|
||||
dist = MIN(p_point.y - (position.y + size.y), dist);
|
||||
real_t d = p_point.y - (position.y + size.y);
|
||||
dist = inside ? d : MIN(dist, d);
|
||||
inside = false;
|
||||
}
|
||||
|
||||
if (dist == 1e20)
|
||||
if (inside) {
|
||||
return 0;
|
||||
else
|
||||
} else {
|
||||
return dist;
|
||||
}
|
||||
}
|
||||
|
||||
Rect2 Rect2::clip(const Rect2 &p_rect) const { /// return a clipped rect
|
||||
@@ -77,7 +116,6 @@ Rect2::operator String() const {
|
||||
}
|
||||
|
||||
bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_position, Point2 *r_normal) const {
|
||||
|
||||
real_t min = 0, max = 1;
|
||||
int axis = 0;
|
||||
real_t sign = 0;
|
||||
@@ -91,7 +129,6 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
|
||||
real_t csign;
|
||||
|
||||
if (seg_from < seg_to) {
|
||||
|
||||
if (seg_from > box_end || seg_to < box_begin)
|
||||
return false;
|
||||
real_t length = seg_to - seg_from;
|
||||
@@ -100,7 +137,6 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
|
||||
csign = -1.0;
|
||||
|
||||
} else {
|
||||
|
||||
if (seg_to > box_end || seg_from < box_begin)
|
||||
return false;
|
||||
real_t length = seg_to - seg_from;
|
||||
@@ -135,7 +171,6 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
|
||||
}
|
||||
|
||||
bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const {
|
||||
|
||||
//SAT intersection between local and transformed rect2
|
||||
|
||||
Vector2 xf_points[4] = {
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* String.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "String.hpp"
|
||||
|
||||
#include "Array.hpp"
|
||||
@@ -73,6 +103,10 @@ String::String(const String &other) {
|
||||
godot::api->godot_string_new_copy(&_godot_string, &other._godot_string);
|
||||
}
|
||||
|
||||
String::String(String &&other) {
|
||||
godot::api->godot_string_new_copy(&_godot_string, &other._godot_string);
|
||||
}
|
||||
|
||||
String::~String() {
|
||||
godot::api->godot_string_destroy(&_godot_string);
|
||||
}
|
||||
@@ -94,6 +128,11 @@ void String::operator=(const String &s) {
|
||||
godot::api->godot_string_new_copy(&_godot_string, &s._godot_string);
|
||||
}
|
||||
|
||||
void String::operator=(String &&s) {
|
||||
godot::api->godot_string_destroy(&_godot_string);
|
||||
godot::api->godot_string_new_copy(&_godot_string, &s._godot_string);
|
||||
}
|
||||
|
||||
bool String::operator==(const String &s) const {
|
||||
return godot::api->godot_string_operator_equal(&_godot_string, &s._godot_string);
|
||||
}
|
||||
@@ -141,7 +180,6 @@ const wchar_t *String::unicode_str() const {
|
||||
}
|
||||
|
||||
char *String::alloc_c_string() const {
|
||||
|
||||
godot_char_string contents = godot::api->godot_string_utf8(&_godot_string);
|
||||
|
||||
int length = godot::api->godot_char_string_length(&contents);
|
||||
@@ -166,7 +204,6 @@ CharString String::utf8() const {
|
||||
}
|
||||
|
||||
CharString String::ascii(bool p_extended) const {
|
||||
|
||||
CharString ret;
|
||||
|
||||
if (p_extended)
|
||||
@@ -185,7 +222,7 @@ String operator+(const wchar_t *a, const String &b) {
|
||||
return String(a) + b;
|
||||
}
|
||||
|
||||
bool String::begins_with(String &p_string) const {
|
||||
bool String::begins_with(const String &p_string) const {
|
||||
return godot::api->godot_string_begins_with(&_godot_string, &p_string._godot_string);
|
||||
}
|
||||
|
||||
@@ -214,7 +251,7 @@ bool String::empty() const {
|
||||
return godot::api->godot_string_empty(&_godot_string);
|
||||
}
|
||||
|
||||
bool String::ends_with(String &p_string) const {
|
||||
bool String::ends_with(const String &p_string) const {
|
||||
return godot::api->godot_string_ends_with(&_godot_string, &p_string._godot_string);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* TagDP.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "TagDB.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
@@ -22,14 +52,12 @@ bool is_type_known(size_t type_tag) {
|
||||
}
|
||||
|
||||
void register_global_type(const char *name, size_t type_tag, size_t base_type_tag) {
|
||||
|
||||
godot::nativescript_1_1_api->godot_nativescript_set_global_type_tag(godot::_RegisterState::language_index, name, (const void *)type_tag);
|
||||
|
||||
register_type(type_tag, base_type_tag);
|
||||
}
|
||||
|
||||
bool is_type_compatible(size_t ask_tag, size_t have_tag) {
|
||||
|
||||
if (have_tag == 0)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Transform.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Transform.hpp"
|
||||
|
||||
#include "Basis.hpp"
|
||||
@@ -15,14 +45,12 @@ const Transform Transform::FLIP_Y = Transform(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0,
|
||||
const Transform Transform::FLIP_Z = Transform(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0);
|
||||
|
||||
Transform Transform::inverse_xform(const Transform &t) const {
|
||||
|
||||
Vector3 v = t.origin - origin;
|
||||
return Transform(basis.transpose_xform(t.basis),
|
||||
basis.xform(v));
|
||||
}
|
||||
|
||||
void Transform::set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t tx, real_t ty, real_t tz) {
|
||||
|
||||
basis.elements[0][0] = xx;
|
||||
basis.elements[0][1] = xy;
|
||||
basis.elements[0][2] = xz;
|
||||
@@ -38,14 +66,12 @@ void Transform::set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_
|
||||
}
|
||||
|
||||
Vector3 Transform::xform(const Vector3 &p_vector) const {
|
||||
|
||||
return Vector3(
|
||||
basis.elements[0].dot(p_vector) + origin.x,
|
||||
basis.elements[1].dot(p_vector) + origin.y,
|
||||
basis.elements[2].dot(p_vector) + origin.z);
|
||||
}
|
||||
Vector3 Transform::xform_inv(const Vector3 &p_vector) const {
|
||||
|
||||
Vector3 v = p_vector - origin;
|
||||
|
||||
return Vector3(
|
||||
@@ -55,7 +81,6 @@ Vector3 Transform::xform_inv(const Vector3 &p_vector) const {
|
||||
}
|
||||
|
||||
Plane Transform::xform(const Plane &p_plane) const {
|
||||
|
||||
Vector3 point = p_plane.normal * p_plane.d;
|
||||
Vector3 point_dir = point + p_plane.normal;
|
||||
point = xform(point);
|
||||
@@ -68,7 +93,6 @@ Plane Transform::xform(const Plane &p_plane) const {
|
||||
return Plane(normal, d);
|
||||
}
|
||||
Plane Transform::xform_inv(const Plane &p_plane) const {
|
||||
|
||||
Vector3 point = p_plane.normal * p_plane.d;
|
||||
Vector3 point_dir = point + p_plane.normal;
|
||||
point = xform_inv(point);
|
||||
@@ -100,7 +124,6 @@ AABB Transform::xform(const AABB &p_aabb) const {
|
||||
return new_aabb;
|
||||
}
|
||||
AABB Transform::xform_inv(const AABB &p_aabb) const {
|
||||
|
||||
/* define vertices */
|
||||
Vector3 vertices[8] = {
|
||||
Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z),
|
||||
@@ -118,7 +141,6 @@ AABB Transform::xform_inv(const AABB &p_aabb) const {
|
||||
ret.position = xform_inv(vertices[0]);
|
||||
|
||||
for (int i = 1; i < 8; i++) {
|
||||
|
||||
ret.expand_to(xform_inv(vertices[i]));
|
||||
}
|
||||
|
||||
@@ -126,20 +148,17 @@ AABB Transform::xform_inv(const AABB &p_aabb) const {
|
||||
}
|
||||
|
||||
void Transform::affine_invert() {
|
||||
|
||||
basis.invert();
|
||||
origin = basis.xform(-origin);
|
||||
}
|
||||
|
||||
Transform Transform::affine_inverse() const {
|
||||
|
||||
Transform ret = *this;
|
||||
ret.affine_invert();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Transform::invert() {
|
||||
|
||||
basis.transpose();
|
||||
origin = basis.xform(-origin);
|
||||
}
|
||||
@@ -153,29 +172,24 @@ Transform Transform::inverse() const {
|
||||
}
|
||||
|
||||
void Transform::rotate(const Vector3 &p_axis, real_t p_phi) {
|
||||
|
||||
*this = rotated(p_axis, p_phi);
|
||||
}
|
||||
|
||||
Transform Transform::rotated(const Vector3 &p_axis, real_t p_phi) const {
|
||||
|
||||
return Transform(Basis(p_axis, p_phi), Vector3()) * (*this);
|
||||
}
|
||||
|
||||
void Transform::rotate_basis(const Vector3 &p_axis, real_t p_phi) {
|
||||
|
||||
basis.rotate(p_axis, p_phi);
|
||||
}
|
||||
|
||||
Transform Transform::looking_at(const Vector3 &p_target, const Vector3 &p_up) const {
|
||||
|
||||
Transform t = *this;
|
||||
t.set_look_at(origin, p_target, p_up);
|
||||
return t;
|
||||
}
|
||||
|
||||
void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) {
|
||||
|
||||
// Reference: MESA source code
|
||||
Vector3 v_x, v_y, v_z;
|
||||
|
||||
@@ -203,7 +217,6 @@ void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const
|
||||
}
|
||||
|
||||
Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c) const {
|
||||
|
||||
/* not sure if very "efficient" but good enough? */
|
||||
|
||||
Vector3 src_scale = basis.get_scale();
|
||||
@@ -223,20 +236,17 @@ Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c)
|
||||
}
|
||||
|
||||
void Transform::scale(const Vector3 &p_scale) {
|
||||
|
||||
basis.scale(p_scale);
|
||||
origin *= p_scale;
|
||||
}
|
||||
|
||||
Transform Transform::scaled(const Vector3 &p_scale) const {
|
||||
|
||||
Transform t = *this;
|
||||
t.scale(p_scale);
|
||||
return t;
|
||||
}
|
||||
|
||||
void Transform::scale_basis(const Vector3 &p_scale) {
|
||||
|
||||
basis.scale(p_scale);
|
||||
}
|
||||
|
||||
@@ -244,60 +254,50 @@ void Transform::translate(real_t p_tx, real_t p_ty, real_t p_tz) {
|
||||
translate(Vector3(p_tx, p_ty, p_tz));
|
||||
}
|
||||
void Transform::translate(const Vector3 &p_translation) {
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
origin[i] += basis.elements[i].dot(p_translation);
|
||||
}
|
||||
}
|
||||
|
||||
Transform Transform::translated(const Vector3 &p_translation) const {
|
||||
|
||||
Transform t = *this;
|
||||
t.translate(p_translation);
|
||||
return t;
|
||||
}
|
||||
|
||||
void Transform::orthonormalize() {
|
||||
|
||||
basis.orthonormalize();
|
||||
}
|
||||
|
||||
Transform Transform::orthonormalized() const {
|
||||
|
||||
Transform _copy = *this;
|
||||
_copy.orthonormalize();
|
||||
return _copy;
|
||||
}
|
||||
|
||||
bool Transform::operator==(const Transform &p_transform) const {
|
||||
|
||||
return (basis == p_transform.basis && origin == p_transform.origin);
|
||||
}
|
||||
bool Transform::operator!=(const Transform &p_transform) const {
|
||||
|
||||
return (basis != p_transform.basis || origin != p_transform.origin);
|
||||
}
|
||||
|
||||
void Transform::operator*=(const Transform &p_transform) {
|
||||
|
||||
origin = xform(p_transform.origin);
|
||||
basis *= p_transform.basis;
|
||||
}
|
||||
|
||||
Transform Transform::operator*(const Transform &p_transform) const {
|
||||
|
||||
Transform t = *this;
|
||||
t *= p_transform;
|
||||
return t;
|
||||
}
|
||||
|
||||
Transform::operator String() const {
|
||||
|
||||
return basis.operator String() + " - " + origin.operator String();
|
||||
}
|
||||
|
||||
Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) {
|
||||
|
||||
basis = p_basis;
|
||||
origin = p_origin;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Transform2D.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Transform2D.hpp"
|
||||
#include "Rect2.hpp"
|
||||
#include "String.hpp"
|
||||
@@ -12,7 +42,6 @@ const Transform2D Transform2D::FLIP_X = Transform2D(-1, 0, 0, 1, 0, 0);
|
||||
const Transform2D Transform2D::FLIP_Y = Transform2D(1, 0, 0, -1, 0, 0);
|
||||
|
||||
Transform2D::Transform2D(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy) {
|
||||
|
||||
elements[0][0] = xx;
|
||||
elements[0][1] = xy;
|
||||
elements[1][0] = yx;
|
||||
@@ -22,28 +51,24 @@ Transform2D::Transform2D(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox,
|
||||
}
|
||||
|
||||
Vector2 Transform2D::basis_xform(const Vector2 &v) const {
|
||||
|
||||
return Vector2(
|
||||
tdotx(v),
|
||||
tdoty(v));
|
||||
}
|
||||
|
||||
Vector2 Transform2D::basis_xform_inv(const Vector2 &v) const {
|
||||
|
||||
return Vector2(
|
||||
elements[0].dot(v),
|
||||
elements[1].dot(v));
|
||||
}
|
||||
|
||||
Vector2 Transform2D::xform(const Vector2 &v) const {
|
||||
|
||||
return Vector2(
|
||||
tdotx(v),
|
||||
tdoty(v)) +
|
||||
elements[2];
|
||||
}
|
||||
Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const {
|
||||
|
||||
Vector2 v = p_vec - elements[2];
|
||||
|
||||
return Vector2(
|
||||
@@ -51,7 +76,6 @@ Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const {
|
||||
elements[1].dot(v));
|
||||
}
|
||||
Rect2 Transform2D::xform(const Rect2 &p_rect) const {
|
||||
|
||||
Vector2 x = elements[0] * p_rect.size.x;
|
||||
Vector2 y = elements[1] * p_rect.size.y;
|
||||
Vector2 position = xform(p_rect.position);
|
||||
@@ -65,7 +89,6 @@ Rect2 Transform2D::xform(const Rect2 &p_rect) const {
|
||||
}
|
||||
|
||||
void Transform2D::set_rotation_and_scale(real_t p_rot, const Size2 &p_scale) {
|
||||
|
||||
elements[0][0] = ::cos(p_rot) * p_scale.x;
|
||||
elements[1][1] = ::cos(p_rot) * p_scale.y;
|
||||
elements[1][0] = -::sin(p_rot) * p_scale.y;
|
||||
@@ -73,7 +96,6 @@ void Transform2D::set_rotation_and_scale(real_t p_rot, const Size2 &p_scale) {
|
||||
}
|
||||
|
||||
Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const {
|
||||
|
||||
Vector2 ends[4] = {
|
||||
xform_inv(p_rect.position),
|
||||
xform_inv(Vector2(p_rect.position.x, p_rect.position.y + p_rect.size.y)),
|
||||
@@ -98,14 +120,12 @@ void Transform2D::invert() {
|
||||
}
|
||||
|
||||
Transform2D Transform2D::inverse() const {
|
||||
|
||||
Transform2D inv = *this;
|
||||
inv.invert();
|
||||
return inv;
|
||||
}
|
||||
|
||||
void Transform2D::affine_invert() {
|
||||
|
||||
real_t det = basis_determinant();
|
||||
ERR_FAIL_COND(det == 0);
|
||||
real_t idet = 1.0 / det;
|
||||
@@ -118,7 +138,6 @@ void Transform2D::affine_invert() {
|
||||
}
|
||||
|
||||
Transform2D Transform2D::affine_inverse() const {
|
||||
|
||||
Transform2D inv = *this;
|
||||
inv.affine_invert();
|
||||
return inv;
|
||||
@@ -138,7 +157,6 @@ real_t Transform2D::get_rotation() const {
|
||||
}
|
||||
|
||||
void Transform2D::set_rotation(real_t p_rot) {
|
||||
|
||||
real_t cr = ::cos(p_rot);
|
||||
real_t sr = ::sin(p_rot);
|
||||
elements[0][0] = cr;
|
||||
@@ -148,7 +166,6 @@ void Transform2D::set_rotation(real_t p_rot) {
|
||||
}
|
||||
|
||||
Transform2D::Transform2D(real_t p_rot, const Vector2 &p_position) {
|
||||
|
||||
real_t cr = ::cos(p_rot);
|
||||
real_t sr = ::sin(p_rot);
|
||||
elements[0][0] = cr;
|
||||
@@ -168,23 +185,19 @@ void Transform2D::scale(const Size2 &p_scale) {
|
||||
elements[2] *= p_scale;
|
||||
}
|
||||
void Transform2D::scale_basis(const Size2 &p_scale) {
|
||||
|
||||
elements[0][0] *= p_scale.x;
|
||||
elements[0][1] *= p_scale.y;
|
||||
elements[1][0] *= p_scale.x;
|
||||
elements[1][1] *= p_scale.y;
|
||||
}
|
||||
void Transform2D::translate(real_t p_tx, real_t p_ty) {
|
||||
|
||||
translate(Vector2(p_tx, p_ty));
|
||||
}
|
||||
void Transform2D::translate(const Vector2 &p_translation) {
|
||||
|
||||
elements[2] += basis_xform(p_translation);
|
||||
}
|
||||
|
||||
void Transform2D::orthonormalize() {
|
||||
|
||||
// Gram-Schmidt Process
|
||||
|
||||
Vector2 x = elements[0];
|
||||
@@ -198,14 +211,12 @@ void Transform2D::orthonormalize() {
|
||||
elements[1] = y;
|
||||
}
|
||||
Transform2D Transform2D::orthonormalized() const {
|
||||
|
||||
Transform2D on = *this;
|
||||
on.orthonormalize();
|
||||
return on;
|
||||
}
|
||||
|
||||
bool Transform2D::operator==(const Transform2D &p_transform) const {
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (elements[i] != p_transform.elements[i])
|
||||
return false;
|
||||
@@ -215,7 +226,6 @@ bool Transform2D::operator==(const Transform2D &p_transform) const {
|
||||
}
|
||||
|
||||
bool Transform2D::operator!=(const Transform2D &p_transform) const {
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (elements[i] != p_transform.elements[i])
|
||||
return true;
|
||||
@@ -225,7 +235,6 @@ bool Transform2D::operator!=(const Transform2D &p_transform) const {
|
||||
}
|
||||
|
||||
void Transform2D::operator*=(const Transform2D &p_transform) {
|
||||
|
||||
elements[2] = xform(p_transform.elements[2]);
|
||||
|
||||
real_t x0, x1, y0, y1;
|
||||
@@ -242,54 +251,46 @@ void Transform2D::operator*=(const Transform2D &p_transform) {
|
||||
}
|
||||
|
||||
Transform2D Transform2D::operator*(const Transform2D &p_transform) const {
|
||||
|
||||
Transform2D t = *this;
|
||||
t *= p_transform;
|
||||
return t;
|
||||
}
|
||||
|
||||
Transform2D Transform2D::scaled(const Size2 &p_scale) const {
|
||||
|
||||
Transform2D copy = *this;
|
||||
copy.scale(p_scale);
|
||||
return copy;
|
||||
}
|
||||
|
||||
Transform2D Transform2D::basis_scaled(const Size2 &p_scale) const {
|
||||
|
||||
Transform2D copy = *this;
|
||||
copy.scale_basis(p_scale);
|
||||
return copy;
|
||||
}
|
||||
|
||||
Transform2D Transform2D::untranslated() const {
|
||||
|
||||
Transform2D copy = *this;
|
||||
copy.elements[2] = Vector2();
|
||||
return copy;
|
||||
}
|
||||
|
||||
Transform2D Transform2D::translated(const Vector2 &p_offset) const {
|
||||
|
||||
Transform2D copy = *this;
|
||||
copy.translate(p_offset);
|
||||
return copy;
|
||||
}
|
||||
|
||||
Transform2D Transform2D::rotated(real_t p_phi) const {
|
||||
|
||||
Transform2D copy = *this;
|
||||
copy.rotate(p_phi);
|
||||
return copy;
|
||||
}
|
||||
|
||||
real_t Transform2D::basis_determinant() const {
|
||||
|
||||
return elements[0].x * elements[1].y - elements[0].y * elements[1].x;
|
||||
}
|
||||
|
||||
Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t p_c) const {
|
||||
|
||||
//extract parameters
|
||||
Vector2 p1 = get_origin();
|
||||
Vector2 p2 = p_transform.get_origin();
|
||||
@@ -325,7 +326,6 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t
|
||||
}
|
||||
|
||||
Transform2D::operator String() const {
|
||||
|
||||
return String(String() + elements[0] + ", " + elements[1] + ", " + elements[2]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Variant.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Variant.hpp"
|
||||
|
||||
#include <gdnative/variant.h>
|
||||
@@ -7,8 +37,6 @@
|
||||
#include "GodotGlobal.hpp"
|
||||
#include "Object.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace godot {
|
||||
|
||||
Variant::Variant() {
|
||||
@@ -160,6 +188,7 @@ Variant::Variant(const PoolColorArray &p_color_array) {
|
||||
}
|
||||
|
||||
Variant &Variant::operator=(const Variant &v) {
|
||||
godot::api->godot_variant_destroy(&_godot_variant);
|
||||
godot::api->godot_variant_new_copy(&_godot_variant, &v._godot_variant);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Vector2.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Vector2.hpp"
|
||||
|
||||
#include <gdnative/vector2.h>
|
||||
@@ -6,9 +36,9 @@
|
||||
|
||||
namespace godot {
|
||||
|
||||
const Vector2 Vector2::ZERO;
|
||||
const Vector2 Vector2::ONE;
|
||||
const Vector2 Vector2::INF;
|
||||
const Vector2 Vector2::ZERO = Vector2();
|
||||
const Vector2 Vector2::ONE = Vector2(1, 1);
|
||||
const Vector2 Vector2::INF = Vector2(INFINITY, INFINITY);
|
||||
|
||||
const Vector2 Vector2::LEFT = Vector2(-1, 0);
|
||||
const Vector2 Vector2::RIGHT = Vector2(1, 0);
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* Vector3.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "Vector3.hpp"
|
||||
|
||||
#include "String.hpp"
|
||||
@@ -9,7 +39,7 @@
|
||||
namespace godot {
|
||||
|
||||
const Vector3 Vector3::ZERO = Vector3();
|
||||
const Vector3 Vector3::ONE = Vector3();
|
||||
const Vector3 Vector3::ONE = Vector3(1, 1, 1);
|
||||
const Vector3 Vector3::INF = Vector3(INFINITY, INFINITY, INFINITY);
|
||||
|
||||
const Vector3 Vector3::LEFT = Vector3(-1, 0, 0);
|
||||
|
||||
21
test/.gitignore
vendored
Normal file
21
test/.gitignore
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
|
||||
# Godot-specific ignores
|
||||
.import/
|
||||
export.cfg
|
||||
export_presets.cfg
|
||||
# Dummy HTML5 export presets file for continuous integration
|
||||
!.github/dist/export_presets.cfg
|
||||
|
||||
# Imported translations (automatically generated from CSV files)
|
||||
*.translation
|
||||
|
||||
# Mono-specific ignores
|
||||
.mono/
|
||||
data_*/
|
||||
mono_crash.*.json
|
||||
|
||||
# System/tool-specific ignores
|
||||
.directory
|
||||
*~
|
||||
132
test/SConstruct
132
test/SConstruct
@@ -1,134 +1,16 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Try to detect the host platform automatically.
|
||||
# This is used if no `platform` argument is passed
|
||||
if sys.platform.startswith('linux'):
|
||||
host_platform = 'linux'
|
||||
elif sys.platform == 'darwin':
|
||||
host_platform = 'osx'
|
||||
elif sys.platform == 'win32' or sys.platform == 'msys':
|
||||
host_platform = 'windows'
|
||||
else:
|
||||
raise ValueError(
|
||||
'Could not detect platform automatically, please specify with '
|
||||
'platform=<platform>'
|
||||
)
|
||||
|
||||
env = Environment(ENV = os.environ)
|
||||
|
||||
opts = Variables([], ARGUMENTS)
|
||||
|
||||
# Define our options
|
||||
opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release']))
|
||||
opts.Add(EnumVariable('platform', "Compilation platform", host_platform, ['', 'windows', 'x11', 'linux', 'osx']))
|
||||
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", host_platform, ['', 'windows', 'x11', 'linux', 'osx']))
|
||||
opts.Add(EnumVariable('bits', 'Target platform bits', '64', ('32', '64')))
|
||||
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
|
||||
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'bin/', PathVariable.PathAccept))
|
||||
opts.Add(PathVariable('target_name', 'The library name.', 'libgdexample', PathVariable.PathAccept))
|
||||
|
||||
# Local dependency paths, adapt them to your setup
|
||||
godot_headers_path = "../godot-headers/"
|
||||
cpp_bindings_path = "../"
|
||||
cpp_library = "libgodot-cpp"
|
||||
|
||||
# only support 64 at this time..
|
||||
bits = 64
|
||||
|
||||
# Updates the environment with the option variables.
|
||||
opts.Update(env)
|
||||
# Generates help for the -h scons option.
|
||||
Help(opts.GenerateHelpText(env))
|
||||
|
||||
# This makes sure to keep the session environment variables on Windows.
|
||||
# This way, you can run SCons in a Visual Studio 2017 prompt and it will find
|
||||
# all the required tools
|
||||
if host_platform == 'windows' and env['platform'] != 'android':
|
||||
if env['bits'] == '64':
|
||||
env = Environment(TARGET_ARCH='amd64')
|
||||
elif env['bits'] == '32':
|
||||
env = Environment(TARGET_ARCH='x86')
|
||||
|
||||
opts.Update(env)
|
||||
|
||||
# Process some arguments
|
||||
if env['use_llvm']:
|
||||
env['CC'] = 'clang'
|
||||
env['CXX'] = 'clang++'
|
||||
|
||||
if env['p'] != '':
|
||||
env['platform'] = env['p']
|
||||
|
||||
if env['platform'] == '':
|
||||
print("No valid target platform selected.")
|
||||
quit();
|
||||
|
||||
# For the reference:
|
||||
# - CCFLAGS are compilation flags shared between C and C++
|
||||
# - CFLAGS are for C-specific compilation flags
|
||||
# - CXXFLAGS are for C++-specific compilation flags
|
||||
# - CPPFLAGS are for pre-processor flags
|
||||
# - CPPDEFINES are for pre-processor defines
|
||||
# - LINKFLAGS are for linking flags
|
||||
|
||||
# Check our platform specifics
|
||||
if env['platform'] == "osx":
|
||||
env['target_path'] += 'osx/'
|
||||
cpp_library += '.osx'
|
||||
env.Append(CCFLAGS=['-arch', 'x86_64'])
|
||||
env.Append(CXXFLAGS=['-std=c++17'])
|
||||
env.Append(LINKFLAGS=['-arch', 'x86_64'])
|
||||
if env['target'] in ('debug', 'd'):
|
||||
env.Append(CCFLAGS=['-g', '-O2'])
|
||||
else:
|
||||
env.Append(CCFLAGS=['-g', '-O3'])
|
||||
|
||||
elif env['platform'] in ('x11', 'linux'):
|
||||
env['target_path'] += 'x11/'
|
||||
cpp_library += '.linux'
|
||||
env.Append(CCFLAGS=['-fPIC'])
|
||||
env.Append(CXXFLAGS=['-std=c++17'])
|
||||
if env['target'] in ('debug', 'd'):
|
||||
env.Append(CCFLAGS=['-g3', '-Og'])
|
||||
else:
|
||||
env.Append(CCFLAGS=['-g', '-O3'])
|
||||
|
||||
elif env['platform'] == "windows":
|
||||
env['target_path'] += 'win64/'
|
||||
cpp_library += '.windows'
|
||||
# This makes sure to keep the session environment variables on windows,
|
||||
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
||||
env.Append(ENV=os.environ)
|
||||
|
||||
env.Append(CPPDEFINES=['WIN32', '_WIN32', '_WINDOWS', '_CRT_SECURE_NO_WARNINGS'])
|
||||
env.Append(CCFLAGS=['-W3', '-GR'])
|
||||
if env['target'] in ('debug', 'd'):
|
||||
env.Append(CPPDEFINES=['_DEBUG'])
|
||||
env.Append(CCFLAGS=['-EHsc', '-MDd', '-ZI'])
|
||||
env.Append(LINKFLAGS=['-DEBUG'])
|
||||
else:
|
||||
env.Append(CPPDEFINES=['NDEBUG'])
|
||||
env.Append(CCFLAGS=['-O2', '-EHsc', '-MD'])
|
||||
|
||||
if env['target'] in ('debug', 'd'):
|
||||
cpp_library += '.debug'
|
||||
else:
|
||||
cpp_library += '.release'
|
||||
|
||||
cpp_library += '.' + str(bits)
|
||||
|
||||
# make sure our binding library is properly includes
|
||||
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])
|
||||
env.Append(LIBPATH=[cpp_bindings_path + 'bin/'])
|
||||
env.Append(LIBS=[cpp_library])
|
||||
env = SConscript("../SConstruct")
|
||||
|
||||
# tweak this if you want to use different folders, or more folders, to store your source code in.
|
||||
env.Append(CPPPATH=['src/'])
|
||||
sources = Glob('src/*.cpp')
|
||||
|
||||
library = env.SharedLibrary(target=env['target_path'] + env['target_name'] , source=sources)
|
||||
library = env.SharedLibrary(
|
||||
"bin/libgdexample.{}.{}.{}{}".format(
|
||||
env["platform"], env["target"], env["arch_suffix"], env["SHLIBSUFFIX"]
|
||||
),
|
||||
source=sources,
|
||||
)
|
||||
|
||||
Default(library)
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ reloadable=false
|
||||
|
||||
[entry]
|
||||
|
||||
X11.64="res://bin/x11/libgdexample.so"
|
||||
Server.64="res://bin/x11/libgdexample.so"
|
||||
Windows.64="res://bin/win64/libgdexample.dll"
|
||||
OSX.64="res://bin/osx/libgdexample.dylib"
|
||||
X11.64="res://bin/libgdexample.linux.release.64.so"
|
||||
Server.64="res://bin/libgdexample.linux.release.64.so"
|
||||
Windows.64="res://bin/libgdexample.windows.release.64.dll"
|
||||
OSX.64="res://bin/libgdexample.osx.release.64.dylib"
|
||||
|
||||
[dependencies]
|
||||
|
||||
|
||||
@@ -10,10 +10,8 @@ config_version=4
|
||||
|
||||
_global_script_classes=[ ]
|
||||
_global_script_class_icons={
|
||||
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Test CI project"
|
||||
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
|
||||
extends MainLoop
|
||||
|
||||
|
||||
func _initialize():
|
||||
OS.exit_code = 1
|
||||
var native_script = load("res://gdexample.gdns")
|
||||
print("Native Script ", native_script)
|
||||
if native_script == null || !is_instance_valid(native_script):
|
||||
return
|
||||
print("Library ", native_script.library)
|
||||
if native_script.library == null || !is_instance_valid(native_script.library):
|
||||
return
|
||||
var ref = native_script.new()
|
||||
print("Reference ", ref)
|
||||
if ref == null || !is_instance_valid(ref):
|
||||
return
|
||||
print("Reference name ", ref.name)
|
||||
if ref.name != "SimpleClass":
|
||||
return
|
||||
print("Reference value ", ref.value)
|
||||
if ref.value != 0:
|
||||
return
|
||||
print("Call method ", ref.method(1))
|
||||
if ref.method(1) != 1:
|
||||
return
|
||||
OS.exit_code = 0
|
||||
OS.exit_code = 1
|
||||
var native_script = load("res://gdexample.gdns")
|
||||
print("Native Script ", native_script)
|
||||
if not native_script || !is_instance_valid(native_script):
|
||||
return
|
||||
print("Library ", native_script.library)
|
||||
if not native_script.library || !is_instance_valid(native_script.library):
|
||||
return
|
||||
var ref = native_script.new()
|
||||
print("Reference ", ref)
|
||||
if not ref || !is_instance_valid(ref):
|
||||
return
|
||||
print("Reference name ", ref.name)
|
||||
if ref.name != "SimpleClass":
|
||||
return
|
||||
print("Reference value ", ref.value)
|
||||
if ref.value != 0:
|
||||
return
|
||||
print("Call method ", ref.method(1))
|
||||
if ref.method(1) != 1:
|
||||
return
|
||||
OS.exit_code = 0
|
||||
|
||||
|
||||
func _idle(_delta):
|
||||
return true
|
||||
|
||||
return true
|
||||
|
||||
@@ -1,3 +1,33 @@
|
||||
/*************************************************************************/
|
||||
/* init.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include <Godot.hpp>
|
||||
#include <Reference.hpp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user