mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-03 18:09:13 +03:00
Compare commits
97 Commits
3.2
...
godot-3.4.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59ecf3b990 | ||
|
|
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 | ||
|
|
45fef69aca | ||
|
|
5f24388b04 | ||
|
|
f669380811 | ||
|
|
2989a385d7 | ||
|
|
73f1f90bf7 | ||
|
|
2007e6f81e |
@@ -13,9 +13,9 @@ AlignAfterOpenBracket: DontAlign
|
|||||||
AlignTrailingComments: false
|
AlignTrailingComments: false
|
||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
# AllowShortBlocksOnASingleLine: false
|
# AllowShortBlocksOnASingleLine: false
|
||||||
AllowShortCaseLabelsOnASingleLine: true
|
# AllowShortCaseLabelsOnASingleLine: false
|
||||||
AllowShortFunctionsOnASingleLine: Inline
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
AllowShortIfStatementsOnASingleLine: true
|
# AllowShortIfStatementsOnASingleLine: false
|
||||||
# AllowShortLoopsOnASingleLine: false
|
# AllowShortLoopsOnASingleLine: false
|
||||||
# AlwaysBreakAfterDefinitionReturnType: None
|
# AlwaysBreakAfterDefinitionReturnType: None
|
||||||
# AlwaysBreakAfterReturnType: None
|
# AlwaysBreakAfterReturnType: None
|
||||||
@@ -76,7 +76,7 @@ IndentWidth: 4
|
|||||||
# IndentWrappedFunctionNames: false
|
# IndentWrappedFunctionNames: false
|
||||||
# JavaScriptQuotes: Leave
|
# JavaScriptQuotes: Leave
|
||||||
# JavaScriptWrapImports: true
|
# JavaScriptWrapImports: true
|
||||||
# KeepEmptyLinesAtTheStartOfBlocks: true
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
# MacroBlockBegin: ''
|
# MacroBlockBegin: ''
|
||||||
# MacroBlockEnd: ''
|
# MacroBlockEnd: ''
|
||||||
# MaxEmptyLinesToKeep: 1
|
# MaxEmptyLinesToKeep: 1
|
||||||
@@ -112,10 +112,11 @@ UseTab: Always
|
|||||||
---
|
---
|
||||||
### C++ specific config ###
|
### C++ specific config ###
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
Standard: Cpp03
|
Standard: Cpp11
|
||||||
---
|
---
|
||||||
### ObjC specific config ###
|
### ObjC specific config ###
|
||||||
Language: ObjC
|
Language: ObjC
|
||||||
|
Standard: Cpp11
|
||||||
ObjCBlockIndentWidth: 4
|
ObjCBlockIndentWidth: 4
|
||||||
# ObjCSpaceAfterProperty: false
|
# ObjCSpaceAfterProperty: false
|
||||||
# ObjCSpaceBeforeProtocolList: true
|
# ObjCSpaceBeforeProtocolList: true
|
||||||
@@ -123,4 +124,5 @@ ObjCBlockIndentWidth: 4
|
|||||||
### Java specific config ###
|
### Java specific config ###
|
||||||
Language: Java
|
Language: Java
|
||||||
# BreakAfterJavaFieldAnnotations: false
|
# BreakAfterJavaFieldAnnotations: false
|
||||||
|
JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax']
|
||||||
...
|
...
|
||||||
|
|||||||
60
.github/workflows/ci.yml
vendored
60
.github/workflows/ci.yml
vendored
@@ -4,34 +4,34 @@ on: [push, pull_request]
|
|||||||
jobs:
|
jobs:
|
||||||
linux:
|
linux:
|
||||||
name: Build (Linux, GCC)
|
name: Build (Linux, GCC)
|
||||||
runs-on: ubuntu-16.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2.3.4
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Set up Python (for SCons)
|
- name: Set up Python (for SCons)
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: '3.9.1'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update -qq
|
sudo apt-get update -qq
|
||||||
sudo apt-get install -qqq build-essential pkg-config
|
sudo apt-get install -qqq build-essential pkg-config
|
||||||
python -m pip install scons
|
python -m pip install scons
|
||||||
curl -LO https://downloads.tuxfamily.org/godotengine/3.2.3/Godot_v3.2.3-stable_linux_server.64.zip
|
curl -LO https://downloads.tuxfamily.org/godotengine/3.4/Godot_v3.4-stable_linux_server.64.zip
|
||||||
unzip Godot_v3.2.3-stable_linux_server.64.zip
|
unzip Godot_v3.4-stable_linux_server.64.zip
|
||||||
|
|
||||||
- name: Build godot-cpp
|
- name: Build godot-cpp
|
||||||
run: |
|
run: |
|
||||||
scons target=release generate_bindings=yes -j $(nproc)
|
scons target=release generate_bindings=yes -j $(nproc)
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v2.2.1
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: godot-cpp-linux-glibc2.23-x86_64-release
|
name: godot-cpp-linux-glibc2.27-x86_64-release
|
||||||
path: bin/libgodot-cpp.linux.release.64.a
|
path: bin/libgodot-cpp.linux.release.64.a
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
@@ -41,21 +41,21 @@ jobs:
|
|||||||
|
|
||||||
- name: Run test GDNative library
|
- name: Run test GDNative library
|
||||||
run: |
|
run: |
|
||||||
./Godot_v3.2.3-stable_linux_server.64 --path test -s script.gd
|
./Godot_v3.4-stable_linux_server.64 --path test -s script.gd
|
||||||
|
|
||||||
windows-msvc:
|
windows-msvc:
|
||||||
name: Build (Windows, MSVC)
|
name: Build (Windows, MSVC)
|
||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2.3.4
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Set up Python (for SCons)
|
- name: Set up Python (for SCons)
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: '3.9.1'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -66,7 +66,7 @@ jobs:
|
|||||||
scons target=release generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS
|
scons target=release generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v2.2.1
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: godot-cpp-windows-msvc2019-x86_64-release
|
name: godot-cpp-windows-msvc2019-x86_64-release
|
||||||
path: bin/libgodot-cpp.windows.release.64.lib
|
path: bin/libgodot-cpp.windows.release.64.lib
|
||||||
@@ -77,14 +77,14 @@ jobs:
|
|||||||
runs-on: windows-2019
|
runs-on: windows-2019
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2.3.4
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Set up Python (for SCons)
|
- name: Set up Python (for SCons)
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: '3.9.1'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
@@ -100,7 +100,7 @@ jobs:
|
|||||||
scons target=release generate_bindings=yes use_mingw=yes -j $env:NUMBER_OF_PROCESSORS
|
scons target=release generate_bindings=yes use_mingw=yes -j $env:NUMBER_OF_PROCESSORS
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v2.2.1
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: godot-cpp-linux-mingw-x86_64-release
|
name: godot-cpp-linux-mingw-x86_64-release
|
||||||
path: bin/libgodot-cpp.windows.release.64.a
|
path: bin/libgodot-cpp.windows.release.64.a
|
||||||
@@ -108,38 +108,38 @@ jobs:
|
|||||||
|
|
||||||
macos:
|
macos:
|
||||||
name: Build (macOS, Clang)
|
name: Build (macOS, Clang)
|
||||||
runs-on: macos-10.15
|
runs-on: macos-11
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2.3.4
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Set up Python (for SCons)
|
- name: Set up Python (for SCons)
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: '3.9.1'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install scons
|
python -m pip install scons
|
||||||
curl -LO https://downloads.tuxfamily.org/godotengine/3.2.3/Godot_v3.2.3-stable_osx.64.zip
|
curl -LO https://downloads.tuxfamily.org/godotengine/3.4/Godot_v3.4-stable_osx.universal.zip
|
||||||
unzip Godot_v3.2.3-stable_osx.64.zip
|
unzip Godot_v3.4-stable_osx.universal.zip
|
||||||
|
|
||||||
- name: Build godot-cpp
|
- name: Build godot-cpp
|
||||||
run: |
|
run: |
|
||||||
scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu)
|
scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu)
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v2.2.1
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: godot-cpp-macos-x86_64-release
|
name: godot-cpp-macos-universal-release
|
||||||
path: bin/libgodot-cpp.osx.release.64.a
|
path: bin/libgodot-cpp.osx.release.64.a
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Build test GDNative library
|
- name: Build test GDNative library
|
||||||
run: |
|
run: |
|
||||||
scons target=release platform=osx bits=64 -j $(sysctl -n hw.logicalcpu) -C test
|
scons target=release platform=osx bits=64 macos_arch=universal -j $(sysctl -n hw.logicalcpu) -C test
|
||||||
|
|
||||||
- name: Run test GDNative library
|
- name: Run test GDNative library
|
||||||
run: |
|
run: |
|
||||||
@@ -147,14 +147,22 @@ jobs:
|
|||||||
|
|
||||||
static-checks:
|
static-checks:
|
||||||
name: Static Checks (clang-format)
|
name: Static Checks (clang-format)
|
||||||
runs-on: ubuntu-16.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2.3.4
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- 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
|
- name: Install dependencies
|
||||||
run: |
|
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
|
- name: Style checks via clang-format
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,11 +1,13 @@
|
|||||||
# Misc
|
# Misc
|
||||||
logs/*
|
logs/*
|
||||||
|
*.log
|
||||||
|
|
||||||
# Binaries
|
# Binaries
|
||||||
*.o
|
*.o
|
||||||
*.os
|
*.os
|
||||||
*.so
|
*.so
|
||||||
*.obj
|
*.obj
|
||||||
|
*.bc
|
||||||
*.pyc
|
*.pyc
|
||||||
*.dblite
|
*.dblite
|
||||||
*.pdb
|
*.pdb
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
project(godot-cpp)
|
project(godot-cpp)
|
||||||
cmake_minimum_required(VERSION 3.6)
|
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
|
# Change the output directory to the bin directory
|
||||||
set(BUILD_PATH ${CMAKE_SOURCE_DIR}/bin)
|
set(BUILD_PATH ${CMAKE_SOURCE_DIR}/bin)
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_PATH}")
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_PATH}")
|
||||||
@@ -109,7 +111,7 @@ else()
|
|||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wchar-subscripts -Wcomment -Wdisabled-optimization")
|
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} -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} -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} -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} -Wredundant-decls -Wreturn-type -Wsequence-point")
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wswitch -Wswitch-enum -Wtrigraphs")
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wswitch -Wswitch-enum -Wtrigraphs")
|
||||||
@@ -131,24 +133,53 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Generate source from the bindings file
|
# Generate source from the bindings file
|
||||||
|
find_package(PythonInterp REQUIRED)
|
||||||
|
if(GENERATE_TEMPLATE_GET_NODE)
|
||||||
|
set(GENERATE_BINDING_PARAMETERS "True")
|
||||||
|
else()
|
||||||
|
set(GENERATE_BINDING_PARAMETERS "False")
|
||||||
|
endif()
|
||||||
|
|
||||||
message(STATUS "Generating Bindings")
|
message(STATUS "Generating Bindings")
|
||||||
execute_process(COMMAND "python" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_CUSTOM_API_FILE}\")"
|
execute_process(COMMAND "${PYTHON_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}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
RESULT_VARIABLE GENERATION_RESULT
|
RESULT_VARIABLE HEADERS_FILE_LIST_RESULT
|
||||||
OUTPUT_VARIABLE GENERATION_OUTPUT)
|
OUTPUT_VARIABLE HEADERS_FILE_LIST
|
||||||
message(STATUS ${GENERATION_RESULT} ${GENERATION_OUTPUT})
|
)
|
||||||
|
set(HEADERS_FILE_LIST ${HEADERS_FILE_LIST})
|
||||||
|
|
||||||
|
execute_process(COMMAND "${PYTHON_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 "${PYTHON_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
|
# Get Sources
|
||||||
file(GLOB_RECURSE SOURCES src/*.c**)
|
file(GLOB_RECURSE SOURCES src/*.c**)
|
||||||
file(GLOB_RECURSE HEADERS include/*.h**)
|
file(GLOB_RECURSE HEADERS include/*.h**)
|
||||||
|
|
||||||
# Define our godot-cpp library
|
# 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}
|
target_include_directories(${PROJECT_NAME}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
include
|
include
|
||||||
include/core
|
include/core
|
||||||
include/gen
|
${CMAKE_CURRENT_BINARY_DIR}/include/gen/
|
||||||
)
|
)
|
||||||
|
|
||||||
# Put godot headers as SYSTEM PUBLIC to exclude warnings from irrelevant headers
|
# Put godot headers as SYSTEM PUBLIC to exclude warnings from irrelevant headers
|
||||||
@@ -168,8 +199,8 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|||||||
set(BITS 64)
|
set(BITS 64)
|
||||||
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
|
||||||
string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME)
|
string(TOLOWER "${CMAKE_SYSTEM_NAME}" SYSTEM_NAME)
|
||||||
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
|
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE)
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
# Added the android abi after system name
|
# Added the android abi after system name
|
||||||
|
|||||||
51
README.md
51
README.md
@@ -1,27 +1,41 @@
|
|||||||
# godot-cpp
|
# godot-cpp
|
||||||
|
|
||||||
**C++ bindings for the Godot script API.**
|
This repository contains the *C++ bindings* for the [**Godot Engine**](https://github.com/godotengine/godot)'s GDNative 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
|
|
||||||
|
|
||||||
|
- [**Versioning**](#versioning)
|
||||||
- [**Contributing**](#contributing)
|
- [**Contributing**](#contributing)
|
||||||
- [**Getting Started**](#getting-started)
|
- [**Getting Started**](#getting-started)
|
||||||
- [**Creating a simple class**](#creating-a-simple-class)
|
- [**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
|
## Contributing
|
||||||
|
|
||||||
We greatly appreciate help in maintaining and extending this project. If you
|
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
|
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
|
this repository. Rémi "Akien" Verschelde wrote an excellent bit of documentation
|
||||||
for the main Godot project on this:
|
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`
|
Please install clang-format and copy the files in `misc/hooks` into `.git/hooks`
|
||||||
so formatting is done before your changes are submitted.
|
so formatting is done before your changes are submitted.
|
||||||
@@ -275,9 +289,18 @@ Godot headers repository for more information.
|
|||||||
|
|
||||||
#### HTML5
|
#### HTML5
|
||||||
|
|
||||||
GDNative isn't supported on the HTML5 platform yet. Support is being tracked on
|
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.
|
||||||
[issue #12243](https://github.com/godotengine/godot/issues/12243) in the main
|
|
||||||
Godot repository.
|
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
|
### Creating `.gdnlib` and `.gdns` files
|
||||||
|
|
||||||
|
|||||||
106
SConstruct
106
SConstruct
@@ -14,7 +14,7 @@ else:
|
|||||||
|
|
||||||
# Workaround for MinGW. See:
|
# Workaround for MinGW. See:
|
||||||
# http://www.scons.org/wiki/LongCmdLinesOnWin32
|
# http://www.scons.org/wiki/LongCmdLinesOnWin32
|
||||||
if (os.name=="nt"):
|
if os.name == "nt":
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
def mySubProcess(cmdline,env):
|
def mySubProcess(cmdline,env):
|
||||||
@@ -58,6 +58,8 @@ def add_sources(sources, dir, extension):
|
|||||||
# This is used if no `platform` argument is passed
|
# This is used if no `platform` argument is passed
|
||||||
if sys.platform.startswith('linux'):
|
if sys.platform.startswith('linux'):
|
||||||
host_platform = 'linux'
|
host_platform = 'linux'
|
||||||
|
elif sys.platform.startswith('freebsd'):
|
||||||
|
host_platform = 'freebsd'
|
||||||
elif sys.platform == 'darwin':
|
elif sys.platform == 'darwin':
|
||||||
host_platform = 'osx'
|
host_platform = 'osx'
|
||||||
elif sys.platform == 'win32' or sys.platform == 'msys':
|
elif sys.platform == 'win32' or sys.platform == 'msys':
|
||||||
@@ -84,7 +86,7 @@ opts.Add(EnumVariable(
|
|||||||
'platform',
|
'platform',
|
||||||
'Target platform',
|
'Target platform',
|
||||||
host_platform,
|
host_platform,
|
||||||
allowed_values=('linux', 'osx', 'windows', 'android', 'ios'),
|
allowed_values=('linux', 'freebsd', 'osx', 'windows', 'android', 'ios', 'javascript'),
|
||||||
ignorecase=2
|
ignorecase=2
|
||||||
))
|
))
|
||||||
opts.Add(EnumVariable(
|
opts.Add(EnumVariable(
|
||||||
@@ -95,7 +97,7 @@ opts.Add(EnumVariable(
|
|||||||
))
|
))
|
||||||
opts.Add(BoolVariable(
|
opts.Add(BoolVariable(
|
||||||
'use_llvm',
|
'use_llvm',
|
||||||
'Use the LLVM compiler - only effective when targeting Linux',
|
'Use the LLVM compiler - only effective when targeting Linux or FreeBSD',
|
||||||
False
|
False
|
||||||
))
|
))
|
||||||
opts.Add(BoolVariable(
|
opts.Add(BoolVariable(
|
||||||
@@ -123,10 +125,12 @@ opts.Add(PathVariable(
|
|||||||
None,
|
None,
|
||||||
PathVariable.PathIsFile
|
PathVariable.PathIsFile
|
||||||
))
|
))
|
||||||
opts.Add(BoolVariable(
|
opts.Add(EnumVariable(
|
||||||
'generate_bindings',
|
'generate_bindings',
|
||||||
'Generate GDNative API bindings',
|
'Generate GDNative API bindings',
|
||||||
False
|
'auto',
|
||||||
|
allowed_values = ['yes', 'no', 'auto', 'true'],
|
||||||
|
ignorecase = 2
|
||||||
))
|
))
|
||||||
opts.Add(EnumVariable(
|
opts.Add(EnumVariable(
|
||||||
'android_arch',
|
'android_arch',
|
||||||
@@ -139,6 +143,17 @@ opts.Add(
|
|||||||
'macOS deployment target',
|
'macOS deployment target',
|
||||||
'default'
|
'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(
|
opts.Add(EnumVariable(
|
||||||
'ios_arch',
|
'ios_arch',
|
||||||
'Target iOS architecture',
|
'Target iOS architecture',
|
||||||
@@ -185,7 +200,7 @@ if host_platform == 'windows' and env['platform'] != 'android':
|
|||||||
|
|
||||||
opts.Update(env)
|
opts.Update(env)
|
||||||
|
|
||||||
if env['platform'] == 'linux':
|
if env['platform'] == 'linux' or env['platform'] == 'freebsd':
|
||||||
if env['use_llvm']:
|
if env['use_llvm']:
|
||||||
env['CXX'] = 'clang++'
|
env['CXX'] = 'clang++'
|
||||||
|
|
||||||
@@ -213,14 +228,24 @@ elif env['platform'] == 'osx':
|
|||||||
'Only 64-bit builds are supported for the macOS target.'
|
'Only 64-bit builds are supported for the macOS target.'
|
||||||
)
|
)
|
||||||
|
|
||||||
env.Append(CCFLAGS=['-std=c++14', '-arch', 'x86_64'])
|
if env["macos_arch"] == "universal":
|
||||||
|
env.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
|
||||||
|
env.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"])
|
||||||
|
else:
|
||||||
|
env.Append(LINKFLAGS=["-arch", env["macos_arch"]])
|
||||||
|
env.Append(CCFLAGS=["-arch", env["macos_arch"]])
|
||||||
|
|
||||||
|
env.Append(CCFLAGS=['-std=c++14'])
|
||||||
|
|
||||||
if env['macos_deployment_target'] != 'default':
|
if env['macos_deployment_target'] != 'default':
|
||||||
env.Append(CCFLAGS=['-mmacosx-version-min=' + env['macos_deployment_target']])
|
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=[
|
env.Append(LINKFLAGS=[
|
||||||
'-arch',
|
|
||||||
'x86_64',
|
|
||||||
'-framework',
|
'-framework',
|
||||||
'Cocoa',
|
'Cocoa',
|
||||||
'-Wl,-undefined,dynamic_lookup',
|
'-Wl,-undefined,dynamic_lookup',
|
||||||
@@ -278,7 +303,7 @@ elif env['platform'] == 'windows':
|
|||||||
elif env['target'] == 'release':
|
elif env['target'] == 'release':
|
||||||
env.Append(CCFLAGS=['/O2', '/EHsc', '/DNDEBUG', '/MD'])
|
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
|
# Cross-compilation using MinGW
|
||||||
if env['bits'] == '64':
|
if env['bits'] == '64':
|
||||||
env['CXX'] = 'x86_64-w64-mingw32-g++'
|
env['CXX'] = 'x86_64-w64-mingw32-g++'
|
||||||
@@ -300,7 +325,7 @@ elif env['platform'] == 'windows':
|
|||||||
env["SPAWN"] = mySpawn
|
env["SPAWN"] = mySpawn
|
||||||
|
|
||||||
# Native or cross-compilation using MinGW
|
# 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
|
# These options are for a release build even using target=debug
|
||||||
env.Append(CCFLAGS=['-O3', '-std=c++14', '-Wwrite-strings'])
|
env.Append(CCFLAGS=['-O3', '-std=c++14', '-Wwrite-strings'])
|
||||||
env.Append(LINKFLAGS=[
|
env.Append(LINKFLAGS=[
|
||||||
@@ -367,10 +392,52 @@ elif env['platform'] == 'android':
|
|||||||
env['CC'] = toolchain + "/bin/clang"
|
env['CC'] = toolchain + "/bin/clang"
|
||||||
env['CXX'] = toolchain + "/bin/clang++"
|
env['CXX'] = toolchain + "/bin/clang++"
|
||||||
env['AR'] = toolchain + "/bin/" + arch_info['tool_path'] + "-ar"
|
env['AR'] = toolchain + "/bin/" + arch_info['tool_path'] + "-ar"
|
||||||
|
env["AS"] = toolchain + "/bin/" + arch_info['tool_path'] + "-as"
|
||||||
|
env["LD"] = toolchain + "/bin/" + arch_info['tool_path'] + "-ld"
|
||||||
|
env["STRIP"] = toolchain + "/bin/" + arch_info['tool_path'] + "-strip"
|
||||||
|
env["RANLIB"] = toolchain + "/bin/" + arch_info['tool_path'] + "-ranlib"
|
||||||
|
|
||||||
env.Append(CCFLAGS=['--target=' + arch_info['target'] + env['android_api_level'], '-march=' + arch_info['march'], '-fPIC'])#, '-fPIE', '-fno-addrsig', '-Oz'])
|
env.Append(CCFLAGS=['--target=' + arch_info['target'] + env['android_api_level'], '-march=' + arch_info['march'], '-fPIC'])
|
||||||
env.Append(CCFLAGS=arch_info['ccflags'])
|
env.Append(CCFLAGS=arch_info['ccflags'])
|
||||||
|
|
||||||
|
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.Append(CPPPATH=[
|
||||||
'.',
|
'.',
|
||||||
env['headers_dir'],
|
env['headers_dir'],
|
||||||
@@ -387,7 +454,13 @@ if 'custom_api_file' in env:
|
|||||||
else:
|
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
|
# Actually create the bindings here
|
||||||
import binding_generator
|
import binding_generator
|
||||||
|
|
||||||
@@ -401,8 +474,13 @@ add_sources(sources, 'src/gen', 'cpp')
|
|||||||
arch_suffix = env['bits']
|
arch_suffix = env['bits']
|
||||||
if env['platform'] == 'android':
|
if env['platform'] == 'android':
|
||||||
arch_suffix = env['android_arch']
|
arch_suffix = env['android_arch']
|
||||||
if env['platform'] == 'ios':
|
elif env['platform'] == 'ios':
|
||||||
arch_suffix = env['ios_arch']
|
arch_suffix = env['ios_arch']
|
||||||
|
elif env['platform'] == 'osx':
|
||||||
|
if env['macos_arch'] != 'universal':
|
||||||
|
arch_suffix = env['macos_arch']
|
||||||
|
elif env['platform'] == 'javascript':
|
||||||
|
arch_suffix = 'wasm'
|
||||||
|
|
||||||
library = env.StaticLibrary(
|
library = env.StaticLibrary(
|
||||||
target='bin/' + 'libgodot-cpp.{}.{}.{}{}'.format(
|
target='bin/' + 'libgodot-cpp.{}.{}.{}{}'.format(
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
# comment.
|
import errno
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
# Convenience function for using template get_node
|
# Convenience function for using template get_node
|
||||||
def correct_method_name(method_list):
|
def correct_method_name(method_list):
|
||||||
@@ -13,15 +14,58 @@ def correct_method_name(method_list):
|
|||||||
|
|
||||||
classes = []
|
classes = []
|
||||||
|
|
||||||
def generate_bindings(path, use_template_get_node):
|
|
||||||
|
|
||||||
|
def print_file_list(api_filepath, output_dir, headers=False, sources=False):
|
||||||
global classes
|
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()
|
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:
|
for c in classes:
|
||||||
# print c['name']
|
# print(c['name'])
|
||||||
used_classes = get_used_classes(c)
|
used_classes = get_used_classes(c)
|
||||||
if use_template_get_node and c["name"] == "Node":
|
if use_template_get_node and c["name"] == "Node":
|
||||||
correct_method_name(c["methods"])
|
correct_method_name(c["methods"])
|
||||||
@@ -30,21 +74,25 @@ def generate_bindings(path, use_template_get_node):
|
|||||||
|
|
||||||
impl = generate_class_implementation(icalls, used_classes, c, 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_filename = include_gen_folder / (strip_name(c["name"]) + ".hpp")
|
||||||
header_file.write(header)
|
with header_filename.open("w+") as header_file:
|
||||||
|
header_file.write(header)
|
||||||
|
|
||||||
source_file = open("src/gen/" + strip_name(c["name"]) + ".cpp", "w+")
|
source_filename = source_gen_folder / (strip_name(c["name"]) + ".cpp")
|
||||||
source_file.write(impl)
|
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+")
|
register_types_filename = source_gen_folder / '__register_types.cpp'
|
||||||
icall_header_file.write(generate_icall_header(icalls))
|
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+")
|
init_method_bindings_filename = source_gen_folder / '__init_method_bindings.cpp'
|
||||||
register_types_file.write(generate_type_registry(classes))
|
with init_method_bindings_filename.open("w+") as init_method_bindings_file:
|
||||||
|
init_method_bindings_file.write(generate_init_method_bindings(classes))
|
||||||
init_method_bindings_file = open("src/gen/__init_method_bindings.cpp", "w+")
|
|
||||||
init_method_bindings_file.write(generate_init_method_bindings(classes))
|
|
||||||
|
|
||||||
|
|
||||||
def is_reference_type(t):
|
def is_reference_type(t):
|
||||||
@@ -80,7 +128,7 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
|||||||
source.append("")
|
source.append("")
|
||||||
|
|
||||||
source.append("#include <gdnative_api_struct.gen.h>")
|
source.append("#include <gdnative_api_struct.gen.h>")
|
||||||
source.append("#include <stdint.h>")
|
source.append("#include <cstdint>")
|
||||||
source.append("")
|
source.append("")
|
||||||
|
|
||||||
|
|
||||||
@@ -246,7 +294,7 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
|||||||
return default_value.lower()
|
return default_value.lower()
|
||||||
if _type == "Array":
|
if _type == "Array":
|
||||||
return "Array()"
|
return "Array()"
|
||||||
if _type in ["PoolVector2Array", "PoolStringArray", "PoolVector3Array", "PoolColorArray", "PoolIntArray", "PoolRealArray"]:
|
if _type in ["PoolVector2Array", "PoolStringArray", "PoolVector3Array", "PoolColorArray", "PoolIntArray", "PoolRealArray", "PoolByteArray"]:
|
||||||
return _type + "()"
|
return _type + "()"
|
||||||
if _type == "Vector2":
|
if _type == "Vector2":
|
||||||
return "Vector2" + default_value
|
return "Vector2" + default_value
|
||||||
@@ -260,7 +308,7 @@ def generate_class_header(used_classes, c, use_template_get_node):
|
|||||||
return "Rect2" + default_value
|
return "Rect2" + default_value
|
||||||
if _type == "Variant":
|
if _type == "Variant":
|
||||||
return "Variant()" if default_value == "Null" else default_value
|
return "Variant()" if default_value == "Null" else default_value
|
||||||
if _type == "String":
|
if _type == "String" or _type == "NodePath":
|
||||||
return "\"" + default_value + "\""
|
return "\"" + default_value + "\""
|
||||||
if _type == "RID":
|
if _type == "RID":
|
||||||
return "RID()"
|
return "RID()"
|
||||||
@@ -833,6 +881,7 @@ def is_primitive(name):
|
|||||||
def escape_cpp(name):
|
def escape_cpp(name):
|
||||||
escapes = {
|
escapes = {
|
||||||
"class": "_class",
|
"class": "_class",
|
||||||
|
"enum": "_enum",
|
||||||
"char": "_char",
|
"char": "_char",
|
||||||
"short": "_short",
|
"short": "_short",
|
||||||
"bool": "_bool",
|
"bool": "_bool",
|
||||||
|
|||||||
Submodule godot-headers updated: 815f34e1e9...c941c6076f
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* AABB.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef AABB_H
|
||||||
#define AABB_H
|
#define AABB_H
|
||||||
|
|
||||||
@@ -16,12 +46,10 @@ public:
|
|||||||
|
|
||||||
real_t get_area() const; /// get area
|
real_t get_area() const; /// get area
|
||||||
inline bool has_no_area() const {
|
inline bool has_no_area() const {
|
||||||
|
|
||||||
return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON);
|
return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool has_no_surface() const {
|
inline bool has_no_surface() const {
|
||||||
|
|
||||||
return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON);
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef ARRAY_H
|
||||||
#define ARRAY_H
|
#define ARRAY_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Basis.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef BASIS_H
|
||||||
#define BASIS_H
|
#define BASIS_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* CameraMatrix.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef CAMERA_MATRIX_H
|
||||||
#define CAMERA_MATRIX_H
|
#define CAMERA_MATRIX_H
|
||||||
|
|
||||||
@@ -14,7 +44,6 @@ using namespace godot;
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct CameraMatrix {
|
struct CameraMatrix {
|
||||||
|
|
||||||
enum Planes {
|
enum Planes {
|
||||||
PLANE_NEAR,
|
PLANE_NEAR,
|
||||||
PLANE_FAR,
|
PLANE_FAR,
|
||||||
@@ -84,7 +113,6 @@ struct CameraMatrix {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Vector3 CameraMatrix::xform(const Vector3 &p_vec3) const {
|
Vector3 CameraMatrix::xform(const Vector3 &p_vec3) const {
|
||||||
|
|
||||||
Vector3 ret;
|
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.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];
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef COLOR_H
|
||||||
#define COLOR_H
|
#define COLOR_H
|
||||||
|
|
||||||
@@ -11,12 +41,10 @@
|
|||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
struct Color {
|
struct Color {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// static float _parse_col(const String& p_str, int p_ofs);
|
// static float _parse_col(const String& p_str, int p_ofs);
|
||||||
public:
|
public:
|
||||||
union {
|
union {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
float r;
|
float r;
|
||||||
float g;
|
float g;
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* CoreTypes.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef CORETYPES_H
|
||||||
#define CORETYPES_H
|
#define CORETYPES_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Defs.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef DEFS_H
|
||||||
#define DEFS_H
|
#define DEFS_H
|
||||||
|
|
||||||
@@ -53,8 +83,6 @@ enum class Error {
|
|||||||
ERR_HELP, ///< user requested help!!
|
ERR_HELP, ///< user requested help!!
|
||||||
ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior.
|
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_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
|
} // namespace godot
|
||||||
@@ -208,7 +236,7 @@ typedef float real_t;
|
|||||||
do { \
|
do { \
|
||||||
if (unlikely(cond)) { \
|
if (unlikely(cond)) { \
|
||||||
FATAL_PRINT(ERR_MSG_COND(cond)); \
|
FATAL_PRINT(ERR_MSG_COND(cond)); \
|
||||||
return; \
|
GENERATE_TRAP; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Dictionary.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef DICTIONARY_H
|
||||||
#define DICTIONARY_H
|
#define DICTIONARY_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Godot.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef GODOT_HPP
|
||||||
#define GODOT_HPP
|
#define GODOT_HPP
|
||||||
|
|
||||||
@@ -17,6 +47,8 @@
|
|||||||
|
|
||||||
#include "GodotGlobal.hpp"
|
#include "GodotGlobal.hpp"
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
namespace detail {
|
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>
|
template <class D, class B, class R, class... As>
|
||||||
void register_method_explicit(const char *name, R (B::*method_ptr)(As...),
|
void register_method_explicit(const char *name, R (B::*method_ptr)(As...),
|
||||||
godot_method_rpc_mode rpc_type = GODOT_METHOD_RPC_MODE_DISABLED) {
|
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");
|
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);
|
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_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
|
||||||
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
||||||
godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
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");
|
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
||||||
|
|
||||||
Variant def_val = default_value;
|
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_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
|
||||||
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
||||||
godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
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");
|
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
||||||
|
|
||||||
Variant def_val = default_value;
|
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_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
|
||||||
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
|
||||||
godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {
|
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);
|
register_property(name, setter, (P(T::*)())getter, default_value, rpc_mode, usage, hint, hint_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
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");
|
static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");
|
||||||
|
|
||||||
godot_signal signal = {};
|
godot_signal signal = {};
|
||||||
@@ -544,6 +572,17 @@ void register_signal(String name, Args... varargs) {
|
|||||||
register_signal<T>(name, Dictionary::make(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
|
#ifndef GODOT_CPP_NO_OBJECT_CAST
|
||||||
template <class T>
|
template <class T>
|
||||||
T *Object::cast_to(const Object *obj) {
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef GODOT_GLOBAL_HPP
|
||||||
#define 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;
|
extern "C" const void *gdnlib;
|
||||||
|
|
||||||
class Godot {
|
class Godot {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void print(const String &message);
|
static void print(const String &message);
|
||||||
static void print_warning(const String &description, const String &function, const String &file, int line);
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef GODOT_PROFILING_HPP
|
||||||
#define 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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef GODOT_MATH_H
|
||||||
#define GODOT_MATH_H
|
#define GODOT_MATH_H
|
||||||
|
|
||||||
@@ -52,6 +82,27 @@ inline float tan(float p_x) {
|
|||||||
return ::tanf(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) {
|
inline double atan2(double p_y, double p_x) {
|
||||||
return ::atan2(p_y, 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) {
|
inline unsigned int next_power_of_2(unsigned int x) {
|
||||||
|
|
||||||
if (x == 0)
|
if (x == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* NodePath.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef NODEPATH_H
|
||||||
#define NODEPATH_H
|
#define NODEPATH_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Plane.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef PLANE_H
|
||||||
#define PLANE_H
|
#define PLANE_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* PoolArrays.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef POOLARRAYS_H
|
||||||
#define POOLARRAYS_H
|
#define POOLARRAYS_H
|
||||||
|
|
||||||
@@ -26,7 +56,6 @@ class PoolByteArray {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
class Read {
|
class Read {
|
||||||
|
|
||||||
friend class PoolByteArray;
|
friend class PoolByteArray;
|
||||||
godot_pool_byte_array_read_access *_read_access;
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef QUAT_H
|
||||||
#define QUAT_H
|
#define QUAT_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* RID.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef RID_H
|
||||||
#define RID_H
|
#define RID_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Rect2.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef RECT2_H
|
||||||
#define RECT2_H
|
#define RECT2_H
|
||||||
|
|
||||||
@@ -17,7 +47,6 @@ typedef Vector2 Point2;
|
|||||||
struct Transform2D;
|
struct Transform2D;
|
||||||
|
|
||||||
struct Rect2 {
|
struct Rect2 {
|
||||||
|
|
||||||
Point2 position;
|
Point2 position;
|
||||||
Size2 size;
|
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;
|
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 {
|
inline bool encloses(const Rect2 &p_rect) const {
|
||||||
|
|
||||||
return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) &&
|
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.x + p_rect.size.x) < (position.x + size.x)) &&
|
||||||
((p_rect.position.y + p_rect.size.y) < (position.y + size.y));
|
((p_rect.position.y + p_rect.size.y) < (position.y + size.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool has_no_area() const {
|
inline bool has_no_area() const {
|
||||||
|
|
||||||
return (size.x <= 0 || size.y <= 0);
|
return (size.x <= 0 || size.y <= 0);
|
||||||
}
|
}
|
||||||
Rect2 clip(const Rect2 &p_rect) const;
|
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 bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }
|
||||||
|
|
||||||
inline Rect2 grow(real_t p_by) const {
|
inline Rect2 grow(real_t p_by) const {
|
||||||
|
|
||||||
Rect2 g = *this;
|
Rect2 g = *this;
|
||||||
g.position.x -= p_by;
|
g.position.x -= p_by;
|
||||||
g.position.y -= p_by;
|
g.position.y -= p_by;
|
||||||
@@ -92,7 +118,6 @@ struct Rect2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Rect2 expand(const Vector2 &p_vector) const {
|
inline Rect2 expand(const Vector2 &p_vector) const {
|
||||||
|
|
||||||
Rect2 r = *this;
|
Rect2 r = *this;
|
||||||
r.expand_to(p_vector);
|
r.expand_to(p_vector);
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Ref.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef REF_H
|
||||||
#define REF_H
|
#define REF_H
|
||||||
|
|
||||||
@@ -19,7 +49,6 @@ class Ref {
|
|||||||
T *reference = nullptr;
|
T *reference = nullptr;
|
||||||
|
|
||||||
void ref(const Ref &p_from) {
|
void ref(const Ref &p_from) {
|
||||||
|
|
||||||
if (p_from.reference == reference)
|
if (p_from.reference == reference)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -31,7 +60,6 @@ class Ref {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ref_pointer(T *p_ref) {
|
void ref_pointer(T *p_ref) {
|
||||||
|
|
||||||
ERR_FAIL_COND(p_ref == nullptr);
|
ERR_FAIL_COND(p_ref == nullptr);
|
||||||
|
|
||||||
if (p_ref->init_ref())
|
if (p_ref->init_ref())
|
||||||
@@ -40,44 +68,35 @@ class Ref {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
inline bool operator<(const Ref<T> &p_r) const {
|
inline bool operator<(const Ref<T> &p_r) const {
|
||||||
|
|
||||||
return reference < p_r.reference;
|
return reference < p_r.reference;
|
||||||
}
|
}
|
||||||
inline bool operator==(const Ref<T> &p_r) const {
|
inline bool operator==(const Ref<T> &p_r) const {
|
||||||
|
|
||||||
return reference == p_r.reference;
|
return reference == p_r.reference;
|
||||||
}
|
}
|
||||||
inline bool operator!=(const Ref<T> &p_r) const {
|
inline bool operator!=(const Ref<T> &p_r) const {
|
||||||
|
|
||||||
return reference != p_r.reference;
|
return reference != p_r.reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline T *operator->() {
|
inline T *operator->() {
|
||||||
|
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline T *operator*() {
|
inline T *operator*() {
|
||||||
|
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const T *operator->() const {
|
inline const T *operator->() const {
|
||||||
|
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const T *ptr() const {
|
inline const T *ptr() const {
|
||||||
|
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
inline T *ptr() {
|
inline T *ptr() {
|
||||||
|
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const T *operator*() const {
|
inline const T *operator*() const {
|
||||||
|
|
||||||
return reference;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +107,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void operator=(const Ref &p_from) {
|
void operator=(const Ref &p_from) {
|
||||||
|
|
||||||
ref(p_from);
|
ref(p_from);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +136,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ref(const Ref &p_from) {
|
Ref(const Ref &p_from) {
|
||||||
|
|
||||||
reference = nullptr;
|
reference = nullptr;
|
||||||
ref(p_from);
|
ref(p_from);
|
||||||
}
|
}
|
||||||
@@ -138,7 +155,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ref(T *p_reference) {
|
Ref(T *p_reference) {
|
||||||
|
|
||||||
if (p_reference)
|
if (p_reference)
|
||||||
ref_pointer(p_reference);
|
ref_pointer(p_reference);
|
||||||
else
|
else
|
||||||
@@ -146,7 +162,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ref(const Variant &p_variant) {
|
Ref(const Variant &p_variant) {
|
||||||
|
|
||||||
reference = nullptr;
|
reference = nullptr;
|
||||||
Object *refb = T::___get_from_variant(p_variant);
|
Object *refb = T::___get_from_variant(p_variant);
|
||||||
if (refb == nullptr) {
|
if (refb == nullptr) {
|
||||||
@@ -168,7 +183,6 @@ public:
|
|||||||
// mutexes will avoid more crashes?
|
// mutexes will avoid more crashes?
|
||||||
|
|
||||||
if (reference && reference->unreference()) {
|
if (reference && reference->unreference()) {
|
||||||
|
|
||||||
//memdelete(reference);
|
//memdelete(reference);
|
||||||
reference->free();
|
reference->free();
|
||||||
}
|
}
|
||||||
@@ -181,12 +195,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ref() {
|
Ref() {
|
||||||
|
|
||||||
reference = nullptr;
|
reference = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Ref() {
|
~Ref() {
|
||||||
|
|
||||||
unref();
|
unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* String.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef STRING_H
|
||||||
#define STRING_H
|
#define STRING_H
|
||||||
|
|
||||||
@@ -14,7 +44,6 @@ class PoolStringArray;
|
|||||||
class String;
|
class String;
|
||||||
|
|
||||||
class CharString {
|
class CharString {
|
||||||
|
|
||||||
friend class String;
|
friend class String;
|
||||||
|
|
||||||
godot_char_string _char_string;
|
godot_char_string _char_string;
|
||||||
@@ -41,6 +70,7 @@ public:
|
|||||||
String(const wchar_t *contents);
|
String(const wchar_t *contents);
|
||||||
String(const wchar_t c);
|
String(const wchar_t c);
|
||||||
String(const String &other);
|
String(const String &other);
|
||||||
|
String(String &&other);
|
||||||
|
|
||||||
~String();
|
~String();
|
||||||
|
|
||||||
@@ -56,6 +86,7 @@ public:
|
|||||||
wchar_t operator[](const int idx) const;
|
wchar_t operator[](const int idx) const;
|
||||||
|
|
||||||
void operator=(const String &s);
|
void operator=(const String &s);
|
||||||
|
void operator=(String &&s);
|
||||||
bool operator==(const String &s) const;
|
bool operator==(const String &s) const;
|
||||||
bool operator!=(const String &s) const;
|
bool operator!=(const String &s) const;
|
||||||
String operator+(const String &s) const;
|
String operator+(const String &s) const;
|
||||||
@@ -74,14 +105,14 @@ public:
|
|||||||
CharString utf8() const;
|
CharString utf8() const;
|
||||||
CharString ascii(bool p_extended = false) 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;
|
bool begins_with_char_array(const char *p_char_array) const;
|
||||||
PoolStringArray bigrams() const;
|
PoolStringArray bigrams() const;
|
||||||
String c_escape() const;
|
String c_escape() const;
|
||||||
String c_unescape() const;
|
String c_unescape() const;
|
||||||
String capitalize() const;
|
String capitalize() const;
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
bool ends_with(String &text) const;
|
bool ends_with(const String &text) const;
|
||||||
void erase(int position, int chars);
|
void erase(int position, int chars);
|
||||||
int find(String what, int from = 0) const;
|
int find(String what, int from = 0) const;
|
||||||
int find_last(String what) 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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef TAGDB_HPP
|
||||||
#define TAGDB_HPP
|
#define TAGDB_HPP
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Transform.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef TRANSFORM_H
|
||||||
#define TRANSFORM_H
|
#define TRANSFORM_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Transform2D.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef TRANSFORM2D_H
|
||||||
#define TRANSFORM2D_H
|
#define TRANSFORM2D_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Variant.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef VARIANT_H
|
||||||
#define VARIANT_H
|
#define VARIANT_H
|
||||||
|
|
||||||
@@ -20,8 +50,6 @@
|
|||||||
#include "Vector2.hpp"
|
#include "Vector2.hpp"
|
||||||
#include "Vector3.hpp"
|
#include "Vector3.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
class Dictionary;
|
class Dictionary;
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Vector2.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef VECTOR2_H
|
||||||
#define VECTOR2_H
|
#define VECTOR2_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Vector3.hpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef VECTOR3_H
|
||||||
#define VECTOR3_H
|
#define VECTOR3_H
|
||||||
|
|
||||||
@@ -14,7 +44,6 @@ namespace godot {
|
|||||||
class Basis;
|
class Basis;
|
||||||
|
|
||||||
struct Vector3 {
|
struct Vector3 {
|
||||||
|
|
||||||
enum Axis {
|
enum Axis {
|
||||||
AXIS_X,
|
AXIS_X,
|
||||||
AXIS_Y,
|
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) {
|
inline Vector3 vec3_cross(const Vector3 &p_a, const Vector3 &p_b) {
|
||||||
|
|
||||||
return p_a.cross(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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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
|
#ifndef WRAPPED_HPP
|
||||||
#define 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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "AABB.hpp"
|
||||||
#include "Plane.hpp"
|
#include "Plane.hpp"
|
||||||
#include "Vector3.hpp"
|
#include "Vector3.hpp"
|
||||||
@@ -7,7 +37,6 @@
|
|||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
bool AABB::intersects(const AABB &p_aabb) const {
|
bool AABB::intersects(const AABB &p_aabb) const {
|
||||||
|
|
||||||
if (position.x >= (p_aabb.position.x + p_aabb.size.x))
|
if (position.x >= (p_aabb.position.x + p_aabb.size.x))
|
||||||
return false;
|
return false;
|
||||||
if ((position.x + size.x) <= p_aabb.position.x)
|
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 {
|
bool AABB::intersects_inclusive(const AABB &p_aabb) const {
|
||||||
|
|
||||||
if (position.x > (p_aabb.position.x + p_aabb.size.x))
|
if (position.x > (p_aabb.position.x + p_aabb.size.x))
|
||||||
return false;
|
return false;
|
||||||
if ((position.x + size.x) < p_aabb.position.x)
|
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 {
|
bool AABB::encloses(const AABB &p_aabb) const {
|
||||||
|
|
||||||
Vector3 src_min = position;
|
Vector3 src_min = position;
|
||||||
Vector3 src_max = position + size;
|
Vector3 src_max = position + size;
|
||||||
Vector3 dst_min = p_aabb.position;
|
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 AABB::get_support(const Vector3 &p_normal) const {
|
||||||
|
|
||||||
Vector3 half_extents = size * 0.5;
|
Vector3 half_extents = size * 0.5;
|
||||||
Vector3 ofs = position + half_extents;
|
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 {
|
Vector3 AABB::get_endpoint(int p_point) const {
|
||||||
|
|
||||||
switch (p_point) {
|
switch (p_point) {
|
||||||
case 0: return Vector3(position.x, position.y, position.z);
|
case 0:
|
||||||
case 1: return Vector3(position.x, position.y, position.z + size.z);
|
return Vector3(position.x, position.y, position.z);
|
||||||
case 2: return Vector3(position.x, position.y + size.y, position.z);
|
case 1:
|
||||||
case 3: return Vector3(position.x, position.y + size.y, position.z + size.z);
|
return Vector3(position.x, position.y, position.z + size.z);
|
||||||
case 4: return Vector3(position.x + size.x, position.y, position.z);
|
case 2:
|
||||||
case 5: return Vector3(position.x + size.x, position.y, position.z + size.z);
|
return Vector3(position.x, position.y + size.y, position.z);
|
||||||
case 6: return Vector3(position.x + size.x, position.y + size.y, position.z);
|
case 3:
|
||||||
case 7: return Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
|
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());
|
ERR_FAIL_V(Vector3());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
|
bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
|
||||||
|
|
||||||
Vector3 half_extents = size * 0.5;
|
Vector3 half_extents = size * 0.5;
|
||||||
Vector3 ofs = position + half_extents;
|
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 {
|
bool AABB::has_point(const Vector3 &p_point) const {
|
||||||
|
|
||||||
if (p_point.x < position.x)
|
if (p_point.x < position.x)
|
||||||
return false;
|
return false;
|
||||||
if (p_point.y < position.y)
|
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) {
|
void AABB::expand_to(const Vector3 &p_vector) {
|
||||||
|
|
||||||
Vector3 begin = position;
|
Vector3 begin = position;
|
||||||
Vector3 end = position + size;
|
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 {
|
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 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);
|
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 AABB::get_longest_axis_size() const {
|
||||||
|
|
||||||
real_t max_size = size.x;
|
real_t max_size = size.x;
|
||||||
|
|
||||||
if (size.y > max_size) {
|
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 AABB::get_shortest_axis_size() const {
|
||||||
|
|
||||||
real_t max_size = size.x;
|
real_t max_size = size.x;
|
||||||
|
|
||||||
if (size.y < max_size) {
|
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 {
|
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 divx = 1.0 / dir.x;
|
||||||
real_t divy = 1.0 / dir.y;
|
real_t divy = 1.0 / dir.y;
|
||||||
real_t divz = 1.0 / dir.z;
|
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) {
|
void AABB::grow_by(real_t p_amount) {
|
||||||
|
|
||||||
position.x -= p_amount;
|
position.x -= p_amount;
|
||||||
position.y -= p_amount;
|
position.y -= p_amount;
|
||||||
position.z -= p_amount;
|
position.z -= p_amount;
|
||||||
@@ -242,21 +267,17 @@ void AABB::grow_by(real_t p_amount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
real_t AABB::get_area() const {
|
real_t AABB::get_area() const {
|
||||||
|
|
||||||
return size.x * size.y * size.z;
|
return size.x * size.y * size.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABB::operator==(const AABB &p_rval) const {
|
bool AABB::operator==(const AABB &p_rval) const {
|
||||||
|
|
||||||
return ((position == p_rval.position) && (size == p_rval.size));
|
return ((position == p_rval.position) && (size == p_rval.size));
|
||||||
}
|
}
|
||||||
bool AABB::operator!=(const AABB &p_rval) const {
|
bool AABB::operator!=(const AABB &p_rval) const {
|
||||||
|
|
||||||
return ((position != p_rval.position) || (size != p_rval.size));
|
return ((position != p_rval.position) || (size != p_rval.size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AABB::merge_with(const AABB &p_aabb) {
|
void AABB::merge_with(const AABB &p_aabb) {
|
||||||
|
|
||||||
Vector3 beg_1, beg_2;
|
Vector3 beg_1, beg_2;
|
||||||
Vector3 end_1, end_2;
|
Vector3 end_1, end_2;
|
||||||
Vector3 min, max;
|
Vector3 min, max;
|
||||||
@@ -279,7 +300,6 @@ void AABB::merge_with(const AABB &p_aabb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AABB AABB::intersection(const AABB &p_aabb) const {
|
AABB AABB::intersection(const AABB &p_aabb) const {
|
||||||
|
|
||||||
Vector3 src_min = position;
|
Vector3 src_min = position;
|
||||||
Vector3 src_max = position + size;
|
Vector3 src_max = position + size;
|
||||||
Vector3 dst_min = p_aabb.position;
|
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)
|
if (src_min.x > dst_max.x || src_max.x < dst_min.x)
|
||||||
return AABB();
|
return AABB();
|
||||||
else {
|
else {
|
||||||
|
|
||||||
min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x;
|
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;
|
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)
|
if (src_min.y > dst_max.y || src_max.y < dst_min.y)
|
||||||
return AABB();
|
return AABB();
|
||||||
else {
|
else {
|
||||||
|
|
||||||
min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y;
|
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;
|
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)
|
if (src_min.z > dst_max.z || src_max.z < dst_min.z)
|
||||||
return AABB();
|
return AABB();
|
||||||
else {
|
else {
|
||||||
|
|
||||||
min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z;
|
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;
|
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 {
|
bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
|
||||||
|
|
||||||
Vector3 c1, c2;
|
Vector3 c1, c2;
|
||||||
Vector3 end = position + size;
|
Vector3 end = position + size;
|
||||||
real_t near = -1e20;
|
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 {
|
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;
|
real_t min = 0, max = 1;
|
||||||
int axis = 0;
|
int axis = 0;
|
||||||
real_t sign = 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;
|
real_t csign;
|
||||||
|
|
||||||
if (seg_from < seg_to) {
|
if (seg_from < seg_to) {
|
||||||
|
|
||||||
if (seg_from > box_end || seg_to < box_begin)
|
if (seg_from > box_end || seg_to < box_begin)
|
||||||
return false;
|
return false;
|
||||||
real_t length = seg_to - seg_from;
|
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;
|
csign = -1.0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (seg_to > box_end || seg_from < box_begin)
|
if (seg_to > box_end || seg_from < box_begin)
|
||||||
return false;
|
return false;
|
||||||
real_t length = seg_to - seg_from;
|
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 {
|
bool AABB::intersects_plane(const Plane &p_plane) const {
|
||||||
|
|
||||||
Vector3 points[8] = {
|
Vector3 points[8] = {
|
||||||
Vector3(position.x, position.y, position.z),
|
Vector3(position.x, position.y, position.z),
|
||||||
Vector3(position.x, position.y, position.z + size.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;
|
bool under = false;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
|
||||||
if (p_plane.distance_to(points[i]) > 0)
|
if (p_plane.distance_to(points[i]) > 0)
|
||||||
over = true;
|
over = true;
|
||||||
else
|
else
|
||||||
@@ -443,7 +454,6 @@ bool AABB::intersects_plane(const Plane &p_plane) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector3 AABB::get_longest_axis() const {
|
Vector3 AABB::get_longest_axis() const {
|
||||||
|
|
||||||
Vector3 axis(1, 0, 0);
|
Vector3 axis(1, 0, 0);
|
||||||
real_t max_size = size.x;
|
real_t max_size = size.x;
|
||||||
|
|
||||||
@@ -460,7 +470,6 @@ Vector3 AABB::get_longest_axis() const {
|
|||||||
return axis;
|
return axis;
|
||||||
}
|
}
|
||||||
int AABB::get_longest_axis_index() const {
|
int AABB::get_longest_axis_index() const {
|
||||||
|
|
||||||
int axis = 0;
|
int axis = 0;
|
||||||
real_t max_size = size.x;
|
real_t max_size = size.x;
|
||||||
|
|
||||||
@@ -478,7 +487,6 @@ int AABB::get_longest_axis_index() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector3 AABB::get_shortest_axis() const {
|
Vector3 AABB::get_shortest_axis() const {
|
||||||
|
|
||||||
Vector3 axis(1, 0, 0);
|
Vector3 axis(1, 0, 0);
|
||||||
real_t max_size = size.x;
|
real_t max_size = size.x;
|
||||||
|
|
||||||
@@ -495,7 +503,6 @@ Vector3 AABB::get_shortest_axis() const {
|
|||||||
return axis;
|
return axis;
|
||||||
}
|
}
|
||||||
int AABB::get_shortest_axis_index() const {
|
int AABB::get_shortest_axis_index() const {
|
||||||
|
|
||||||
int axis = 0;
|
int axis = 0;
|
||||||
real_t max_size = size.x;
|
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::merge(const AABB &p_with) const {
|
||||||
|
|
||||||
AABB aabb = *this;
|
AABB aabb = *this;
|
||||||
aabb.merge_with(p_with);
|
aabb.merge_with(p_with);
|
||||||
return aabb;
|
return aabb;
|
||||||
@@ -524,24 +530,19 @@ AABB AABB::expand(const Vector3 &p_vector) const {
|
|||||||
return aabb;
|
return aabb;
|
||||||
}
|
}
|
||||||
AABB AABB::grow(real_t p_by) const {
|
AABB AABB::grow(real_t p_by) const {
|
||||||
|
|
||||||
AABB aabb = *this;
|
AABB aabb = *this;
|
||||||
aabb.grow_by(p_by);
|
aabb.grow_by(p_by);
|
||||||
return aabb;
|
return aabb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
|
void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
|
||||||
|
|
||||||
ERR_FAIL_INDEX(p_edge, 12);
|
ERR_FAIL_INDEX(p_edge, 12);
|
||||||
switch (p_edge) {
|
switch (p_edge) {
|
||||||
|
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
||||||
r_from = Vector3(position.x + size.x, position.y, position.z);
|
r_from = Vector3(position.x + size.x, position.y, position.z);
|
||||||
r_to = Vector3(position.x, position.y, position.z);
|
r_to = Vector3(position.x, position.y, position.z);
|
||||||
} break;
|
} break;
|
||||||
case 1: {
|
case 1: {
|
||||||
|
|
||||||
r_from = Vector3(position.x + size.x, position.y, position.z + size.z);
|
r_from = Vector3(position.x + size.x, position.y, position.z + size.z);
|
||||||
r_to = Vector3(position.x + size.x, position.y, position.z);
|
r_to = Vector3(position.x + size.x, position.y, position.z);
|
||||||
} break;
|
} break;
|
||||||
@@ -551,18 +552,15 @@ void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
|
|||||||
|
|
||||||
} break;
|
} break;
|
||||||
case 3: {
|
case 3: {
|
||||||
|
|
||||||
r_from = Vector3(position.x, position.y, position.z);
|
r_from = Vector3(position.x, position.y, position.z);
|
||||||
r_to = Vector3(position.x, position.y, position.z + size.z);
|
r_to = Vector3(position.x, position.y, position.z + size.z);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case 4: {
|
case 4: {
|
||||||
|
|
||||||
r_from = Vector3(position.x, position.y + size.y, position.z);
|
r_from = Vector3(position.x, position.y + size.y, position.z);
|
||||||
r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
|
r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
|
||||||
} break;
|
} break;
|
||||||
case 5: {
|
case 5: {
|
||||||
|
|
||||||
r_from = Vector3(position.x + size.x, position.y + size.y, position.z);
|
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);
|
r_to = Vector3(position.x + size.x, position.y + size.y, position.z + size.z);
|
||||||
} break;
|
} break;
|
||||||
@@ -572,31 +570,26 @@ void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
|
|||||||
|
|
||||||
} break;
|
} break;
|
||||||
case 7: {
|
case 7: {
|
||||||
|
|
||||||
r_from = Vector3(position.x, position.y + size.y, position.z + size.z);
|
r_from = Vector3(position.x, position.y + size.y, position.z + size.z);
|
||||||
r_to = Vector3(position.x, position.y + size.y, position.z);
|
r_to = Vector3(position.x, position.y + size.y, position.z);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case 8: {
|
case 8: {
|
||||||
|
|
||||||
r_from = Vector3(position.x, position.y, position.z + size.z);
|
r_from = Vector3(position.x, position.y, position.z + size.z);
|
||||||
r_to = Vector3(position.x, position.y + size.y, position.z + size.z);
|
r_to = Vector3(position.x, position.y + size.y, position.z + size.z);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case 9: {
|
case 9: {
|
||||||
|
|
||||||
r_from = Vector3(position.x, position.y, position.z);
|
r_from = Vector3(position.x, position.y, position.z);
|
||||||
r_to = Vector3(position.x, position.y + size.y, position.z);
|
r_to = Vector3(position.x, position.y + size.y, position.z);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case 10: {
|
case 10: {
|
||||||
|
|
||||||
r_from = Vector3(position.x + size.x, position.y, position.z);
|
r_from = Vector3(position.x + size.x, position.y, position.z);
|
||||||
r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
|
r_to = Vector3(position.x + size.x, position.y + size.y, position.z);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case 11: {
|
case 11: {
|
||||||
|
|
||||||
r_from = Vector3(position.x + size.x, position.y, position.z + size.z);
|
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);
|
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 {
|
AABB::operator String() const {
|
||||||
|
|
||||||
return String() + position + " - " + size;
|
return String() + position + " - " + size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Array.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Array.hpp"
|
||||||
#include "GodotGlobal.hpp"
|
#include "GodotGlobal.hpp"
|
||||||
#include "Variant.hpp"
|
#include "Variant.hpp"
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Basis.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Basis.hpp"
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
#include "Quat.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) {
|
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);
|
set(xx, xy, xz, yx, yy, yz, zx, zy, zz);
|
||||||
}
|
}
|
||||||
|
|
||||||
Basis::Basis() {
|
Basis::Basis() {
|
||||||
|
|
||||||
elements[0][0] = 1;
|
elements[0][0] = 1;
|
||||||
elements[0][1] = 0;
|
elements[0][1] = 0;
|
||||||
elements[0][2] = 0;
|
elements[0][2] = 0;
|
||||||
@@ -58,7 +86,6 @@ void Basis::invert() {
|
|||||||
#undef cofac
|
#undef cofac
|
||||||
|
|
||||||
bool Basis::isequal_approx(const Basis &a, const Basis &b) const {
|
bool Basis::isequal_approx(const Basis &a, const Basis &b) const {
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
if ((::fabs(a.elements[i][j] - b.elements[i][j]) < CMP_EPSILON) == false)
|
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
|
// 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.
|
// around the z-axis by a and so on.
|
||||||
Vector3 Basis::get_euler_xyz() const {
|
Vector3 Basis::get_euler_xyz() const {
|
||||||
|
|
||||||
// Euler angles in XYZ convention.
|
// Euler angles in XYZ convention.
|
||||||
// See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
// 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.
|
// and similar for other axes.
|
||||||
// The current implementation uses XYZ convention (Z is the first rotation).
|
// The current implementation uses XYZ convention (Z is the first rotation).
|
||||||
void Basis::set_euler_xyz(const Vector3 &p_euler) {
|
void Basis::set_euler_xyz(const Vector3 &p_euler) {
|
||||||
|
|
||||||
real_t c, s;
|
real_t c, s;
|
||||||
|
|
||||||
c = ::cos(p_euler.x);
|
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 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.
|
// as the x, y, and z components of a Vector3 respectively.
|
||||||
Vector3 Basis::get_euler_yxz() const {
|
Vector3 Basis::get_euler_yxz() const {
|
||||||
|
|
||||||
// Euler angles in YXZ convention.
|
// Euler angles in YXZ convention.
|
||||||
// See https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix
|
// 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.
|
// and similar for other axes.
|
||||||
// The current implementation uses YXZ convention (Z is the first rotation).
|
// The current implementation uses YXZ convention (Z is the first rotation).
|
||||||
void Basis::set_euler_yxz(const Vector3 &p_euler) {
|
void Basis::set_euler_yxz(const Vector3 &p_euler) {
|
||||||
|
|
||||||
real_t c, s;
|
real_t c, s;
|
||||||
|
|
||||||
c = ::cos(p_euler.x);
|
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 {
|
Vector3 Basis::xform(const Vector3 &p_vector) const {
|
||||||
|
|
||||||
return Vector3(
|
return Vector3(
|
||||||
elements[0].dot(p_vector),
|
elements[0].dot(p_vector),
|
||||||
elements[1].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 {
|
Vector3 Basis::xform_inv(const Vector3 &p_vector) const {
|
||||||
|
|
||||||
return Vector3(
|
return Vector3(
|
||||||
(elements[0][0] * p_vector.x) + (elements[1][0] * p_vector.y) + (elements[2][0] * p_vector.z),
|
(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),
|
(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) {
|
void Basis::operator+=(const Basis &p_matrix) {
|
||||||
|
|
||||||
elements[0] += p_matrix.elements[0];
|
elements[0] += p_matrix.elements[0];
|
||||||
elements[1] += p_matrix.elements[1];
|
elements[1] += p_matrix.elements[1];
|
||||||
elements[2] += p_matrix.elements[2];
|
elements[2] += p_matrix.elements[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
Basis Basis::operator+(const Basis &p_matrix) const {
|
Basis Basis::operator+(const Basis &p_matrix) const {
|
||||||
|
|
||||||
Basis ret(*this);
|
Basis ret(*this);
|
||||||
ret += p_matrix;
|
ret += p_matrix;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Basis::operator-=(const Basis &p_matrix) {
|
void Basis::operator-=(const Basis &p_matrix) {
|
||||||
|
|
||||||
elements[0] -= p_matrix.elements[0];
|
elements[0] -= p_matrix.elements[0];
|
||||||
elements[1] -= p_matrix.elements[1];
|
elements[1] -= p_matrix.elements[1];
|
||||||
elements[2] -= p_matrix.elements[2];
|
elements[2] -= p_matrix.elements[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
Basis Basis::operator-(const Basis &p_matrix) const {
|
Basis Basis::operator-(const Basis &p_matrix) const {
|
||||||
|
|
||||||
Basis ret(*this);
|
Basis ret(*this);
|
||||||
ret -= p_matrix;
|
ret -= p_matrix;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Basis::operator*=(real_t p_val) {
|
void Basis::operator*=(real_t p_val) {
|
||||||
|
|
||||||
elements[0] *= p_val;
|
elements[0] *= p_val;
|
||||||
elements[1] *= p_val;
|
elements[1] *= p_val;
|
||||||
elements[2] *= p_val;
|
elements[2] *= p_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
Basis Basis::operator*(real_t p_val) const {
|
Basis Basis::operator*(real_t p_val) const {
|
||||||
|
|
||||||
Basis ret(*this);
|
Basis ret(*this);
|
||||||
ret *= p_val;
|
ret *= p_val;
|
||||||
return ret;
|
return ret;
|
||||||
@@ -406,9 +421,7 @@ Basis Basis::operator*(real_t p_val) const {
|
|||||||
Basis::operator String() const {
|
Basis::operator String() const {
|
||||||
String s;
|
String s;
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
|
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
|
|
||||||
if (i != 0 || j != 0)
|
if (i != 0 || j != 0)
|
||||||
s += ", ";
|
s += ", ";
|
||||||
|
|
||||||
@@ -421,7 +434,6 @@ Basis::operator String() const {
|
|||||||
/* create / set */
|
/* 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) {
|
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][0] = xx;
|
||||||
elements[0][1] = xy;
|
elements[0][1] = xy;
|
||||||
elements[0][2] = xz;
|
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;
|
elements[2][2] = zz;
|
||||||
}
|
}
|
||||||
Vector3 Basis::get_column(int i) const {
|
Vector3 Basis::get_column(int i) const {
|
||||||
|
|
||||||
return Vector3(elements[0][i], elements[1][i], elements[2][i]);
|
return Vector3(elements[0][i], elements[1][i], elements[2][i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Basis::get_row(int i) const {
|
Vector3 Basis::get_row(int i) const {
|
||||||
|
|
||||||
return Vector3(elements[i][0], elements[i][1], elements[i][2]);
|
return Vector3(elements[i][0], elements[i][1], elements[i][2]);
|
||||||
}
|
}
|
||||||
Vector3 Basis::get_main_diagonal() const {
|
Vector3 Basis::get_main_diagonal() const {
|
||||||
@@ -593,7 +603,6 @@ int Basis::get_orthogonal_index() const {
|
|||||||
Basis orth = *this;
|
Basis orth = *this;
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
|
|
||||||
real_t v = orth[i][j];
|
real_t v = orth[i][j];
|
||||||
if (v > 0.5)
|
if (v > 0.5)
|
||||||
v = 1.0;
|
v = 1.0;
|
||||||
@@ -607,7 +616,6 @@ int Basis::get_orthogonal_index() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 24; i++) {
|
for (int i = 0; i < 24; i++) {
|
||||||
|
|
||||||
if (_ortho_bases[i] == orth)
|
if (_ortho_bases[i] == orth)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -616,7 +624,6 @@ int Basis::get_orthogonal_index() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Basis::set_orthogonal_index(int p_index) {
|
void Basis::set_orthogonal_index(int p_index) {
|
||||||
|
|
||||||
//there only exist 24 orthogonal bases in r3
|
//there only exist 24 orthogonal bases in r3
|
||||||
ERR_FAIL_COND(p_index >= 24);
|
ERR_FAIL_COND(p_index >= 24);
|
||||||
|
|
||||||
@@ -624,7 +631,6 @@ void Basis::set_orthogonal_index(int p_index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Basis::Basis(const Vector3 &p_euler) {
|
Basis::Basis(const Vector3 &p_euler) {
|
||||||
|
|
||||||
set_euler(p_euler);
|
set_euler(p_euler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,7 +641,6 @@ Basis::Basis(const Vector3 &p_euler) {
|
|||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
Basis::Basis(const Quat &p_quat) {
|
Basis::Basis(const Quat &p_quat) {
|
||||||
|
|
||||||
real_t d = p_quat.length_squared();
|
real_t d = p_quat.length_squared();
|
||||||
real_t s = 2.0 / d;
|
real_t s = 2.0 / d;
|
||||||
real_t xs = p_quat.x * s, ys = p_quat.y * s, zs = p_quat.z * s;
|
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);
|
temp[2] = ((elements[1][0] - elements[0][1]) * s);
|
||||||
} else {
|
} else {
|
||||||
int i = elements[0][0] < elements[1][1] ?
|
int i = elements[0][0] < elements[1][1] ?
|
||||||
(elements[1][1] < elements[2][2] ? 2 : 1) :
|
(elements[1][1] < elements[2][2] ? 2 : 1) :
|
||||||
(elements[0][0] < elements[2][2] ? 2 : 0);
|
(elements[0][0] < elements[2][2] ? 2 : 0);
|
||||||
int j = (i + 1) % 3;
|
int j = (i + 1) % 3;
|
||||||
int k = (i + 2) % 3;
|
int k = (i + 2) % 3;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* camera_matrix.cpp */
|
/* CameraMatrix.cpp */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
/* https://godotengine.org */
|
/* https://godotengine.org */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||||
/* */
|
/* */
|
||||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||||
/* a copy of this software and associated documentation files (the */
|
/* a copy of this software and associated documentation files (the */
|
||||||
@@ -31,29 +31,22 @@
|
|||||||
#include "CameraMatrix.hpp"
|
#include "CameraMatrix.hpp"
|
||||||
|
|
||||||
void CameraMatrix::set_identity() {
|
void CameraMatrix::set_identity() {
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
|
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
|
|
||||||
matrix[i][j] = (i == j) ? 1 : 0;
|
matrix[i][j] = (i == j) ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraMatrix::set_zero() {
|
void CameraMatrix::set_zero() {
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
|
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
|
|
||||||
matrix[i][j] = 0;
|
matrix[i][j] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Plane CameraMatrix::xform4(const Plane &p_vec4) const {
|
Plane CameraMatrix::xform4(const Plane &p_vec4) const {
|
||||||
|
|
||||||
Plane ret;
|
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;
|
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) {
|
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) {
|
if (p_flip_fov) {
|
||||||
p_fovy_degrees = get_fovy(p_fovy_degrees, 1.0 / p_aspect);
|
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) {
|
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();
|
set_identity();
|
||||||
|
|
||||||
matrix[0][0] = 2.0 / (p_right - p_left);
|
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) {
|
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) {
|
if (!p_flip_fov) {
|
||||||
p_size *= p_aspect;
|
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) {
|
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_right <= p_left);
|
||||||
ERR_FAIL_COND(p_top <= p_bottom);
|
ERR_FAIL_COND(p_top <= p_bottom);
|
||||||
ERR_FAIL_COND(p_far <= p_near);
|
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 {
|
real_t CameraMatrix::get_z_far() const {
|
||||||
|
|
||||||
const real_t *matrix = (const real_t *)this->matrix;
|
const real_t *matrix = (const real_t *)this->matrix;
|
||||||
Plane new_plane = Plane(matrix[3] - matrix[2],
|
Plane new_plane = Plane(matrix[3] - matrix[2],
|
||||||
matrix[7] - matrix[6],
|
matrix[7] - matrix[6],
|
||||||
@@ -233,7 +221,6 @@ real_t CameraMatrix::get_z_far() const {
|
|||||||
return new_plane.d;
|
return new_plane.d;
|
||||||
}
|
}
|
||||||
real_t CameraMatrix::get_z_near() const {
|
real_t CameraMatrix::get_z_near() const {
|
||||||
|
|
||||||
const real_t *matrix = (const real_t *)this->matrix;
|
const real_t *matrix = (const real_t *)this->matrix;
|
||||||
Plane new_plane = Plane(matrix[3] + matrix[2],
|
Plane new_plane = Plane(matrix[3] + matrix[2],
|
||||||
matrix[7] + matrix[6],
|
matrix[7] + matrix[6],
|
||||||
@@ -245,7 +232,6 @@ real_t CameraMatrix::get_z_near() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector2 CameraMatrix::get_viewport_half_extents() const {
|
Vector2 CameraMatrix::get_viewport_half_extents() const {
|
||||||
|
|
||||||
const real_t *matrix = (const real_t *)this->matrix;
|
const real_t *matrix = (const real_t *)this->matrix;
|
||||||
///////--- Near Plane ---///////
|
///////--- Near Plane ---///////
|
||||||
Plane near_plane = Plane(matrix[3] + matrix[2],
|
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 {
|
bool CameraMatrix::get_endpoints(const Transform &p_transform, Vector3 *p_8points) const {
|
||||||
|
|
||||||
std::vector<Plane> planes = get_projection_planes(Transform());
|
std::vector<Plane> planes = get_projection_planes(Transform());
|
||||||
const Planes intersections[8][3] = {
|
const Planes intersections[8][3] = {
|
||||||
{ PLANE_FAR, PLANE_LEFT, PLANE_TOP },
|
{ 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++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
|
|
||||||
Vector3 point;
|
Vector3 point;
|
||||||
bool res = planes[intersections[i][0]].intersect_3(planes[intersections[i][1]], planes[intersections[i][2]], &point);
|
bool res = planes[intersections[i][0]].intersect_3(planes[intersections[i][1]], planes[intersections[i][2]], &point);
|
||||||
ERR_FAIL_COND_V(!res, false);
|
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 {
|
std::vector<Plane> CameraMatrix::get_projection_planes(const Transform &p_transform) const {
|
||||||
|
|
||||||
/** Fast Plane Extraction from combined modelview/projection matrices.
|
/** Fast Plane Extraction from combined modelview/projection matrices.
|
||||||
* References:
|
* References:
|
||||||
* https://web.archive.org/web/20011221205252/http://www.markmorley.com/opengl/frustumculling.html
|
* 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 CameraMatrix::inverse() const {
|
||||||
|
|
||||||
CameraMatrix cm = *this;
|
CameraMatrix cm = *this;
|
||||||
cm.invert();
|
cm.invert();
|
||||||
return cm;
|
return cm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraMatrix::invert() {
|
void CameraMatrix::invert() {
|
||||||
|
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
int pvt_i[4], pvt_j[4]; /* Locations of pivot matrix */
|
int pvt_i[4], pvt_j[4]; /* Locations of pivot matrix */
|
||||||
real_t pvt_val; /* Value of current pivot element */
|
real_t pvt_val; /* Value of current pivot element */
|
||||||
@@ -440,20 +421,23 @@ void CameraMatrix::invert() {
|
|||||||
|
|
||||||
/** Divide column by minus pivot value **/
|
/** Divide column by minus pivot value **/
|
||||||
for (i = 0; i < 4; i++) {
|
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 **/
|
/** Reduce the matrix **/
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
hold = matrix[i][k];
|
hold = matrix[i][k];
|
||||||
for (j = 0; j < 4; j++) {
|
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 **/
|
/** Divide row by pivot **/
|
||||||
for (j = 0; j < 4; j++) {
|
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). **/
|
/** Replace pivot by reciprocal (at last we can touch it). **/
|
||||||
@@ -483,12 +467,10 @@ void CameraMatrix::invert() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CameraMatrix::CameraMatrix() {
|
CameraMatrix::CameraMatrix() {
|
||||||
|
|
||||||
set_identity();
|
set_identity();
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const {
|
CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const {
|
||||||
|
|
||||||
CameraMatrix new_matrix;
|
CameraMatrix new_matrix;
|
||||||
|
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
@@ -504,7 +486,6 @@ CameraMatrix CameraMatrix::operator*(const CameraMatrix &p_matrix) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CameraMatrix::set_light_bias() {
|
void CameraMatrix::set_light_bias() {
|
||||||
|
|
||||||
real_t *m = &matrix[0][0];
|
real_t *m = &matrix[0][0];
|
||||||
|
|
||||||
m[0] = 0.5;
|
m[0] = 0.5;
|
||||||
@@ -526,7 +507,6 @@ void CameraMatrix::set_light_bias() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
|
void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
|
||||||
|
|
||||||
real_t *m = &matrix[0][0];
|
real_t *m = &matrix[0][0];
|
||||||
|
|
||||||
m[0] = p_rect.size.width;
|
m[0] = p_rect.size.width;
|
||||||
@@ -548,7 +528,6 @@ void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CameraMatrix::operator String() const {
|
CameraMatrix::operator String() const {
|
||||||
|
|
||||||
String str;
|
String str;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
@@ -558,20 +537,17 @@ CameraMatrix::operator String() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
real_t CameraMatrix::get_aspect() const {
|
real_t CameraMatrix::get_aspect() const {
|
||||||
|
|
||||||
Vector2 vp_he = get_viewport_half_extents();
|
Vector2 vp_he = get_viewport_half_extents();
|
||||||
return vp_he.x / vp_he.y;
|
return vp_he.x / vp_he.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CameraMatrix::get_pixels_per_meter(int p_for_pixel_width) const {
|
int CameraMatrix::get_pixels_per_meter(int p_for_pixel_width) const {
|
||||||
|
|
||||||
Vector3 result = xform(Vector3(1, 0, -1));
|
Vector3 result = xform(Vector3(1, 0, -1));
|
||||||
|
|
||||||
return int((result.x * 0.5 + 0.5) * p_for_pixel_width);
|
return int((result.x * 0.5 + 0.5) * p_for_pixel_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CameraMatrix::is_orthogonal() const {
|
bool CameraMatrix::is_orthogonal() const {
|
||||||
|
|
||||||
return matrix[3][3] == 1.0;
|
return matrix[3][3] == 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,7 +561,7 @@ real_t CameraMatrix::get_fov() const {
|
|||||||
right_plane.normalize();
|
right_plane.normalize();
|
||||||
|
|
||||||
if ((matrix[8] == 0) && (matrix[9] == 0)) {
|
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 {
|
} else {
|
||||||
// our frustum is asymmetrical need to calculate the left planes angle separately..
|
// our frustum is asymmetrical need to calculate the left planes angle separately..
|
||||||
Plane left_plane = Plane(matrix[3] + matrix[0],
|
Plane left_plane = Plane(matrix[3] + matrix[0],
|
||||||
@@ -594,12 +570,11 @@ real_t CameraMatrix::get_fov() const {
|
|||||||
matrix[15] + matrix[12]);
|
matrix[15] + matrix[12]);
|
||||||
left_plane.normalize();
|
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) {
|
void CameraMatrix::make_scale(const Vector3 &p_scale) {
|
||||||
|
|
||||||
set_identity();
|
set_identity();
|
||||||
matrix[0][0] = p_scale.x;
|
matrix[0][0] = p_scale.x;
|
||||||
matrix[1][1] = p_scale.y;
|
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) {
|
void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
|
||||||
|
|
||||||
Vector3 min = p_aabb.position;
|
Vector3 min = p_aabb.position;
|
||||||
Vector3 max = p_aabb.position + p_aabb.size;
|
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 {
|
CameraMatrix::operator Transform() const {
|
||||||
|
|
||||||
Transform tr;
|
Transform tr;
|
||||||
const real_t *m = &matrix[0][0];
|
const real_t *m = &matrix[0][0];
|
||||||
|
|
||||||
@@ -657,7 +630,6 @@ CameraMatrix::operator Transform() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CameraMatrix::CameraMatrix(const Transform &p_transform) {
|
CameraMatrix::CameraMatrix(const Transform &p_transform) {
|
||||||
|
|
||||||
const Transform &tr = p_transform;
|
const Transform &tr = p_transform;
|
||||||
real_t *m = &matrix[0][0];
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Color.hpp"
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
@@ -13,11 +43,9 @@ namespace godot {
|
|||||||
static String _to_hex(float p_val);
|
static String _to_hex(float p_val);
|
||||||
|
|
||||||
static float _parse_col(const String &p_str, int p_ofs) {
|
static float _parse_col(const String &p_str, int p_ofs) {
|
||||||
|
|
||||||
int ig = 0;
|
int ig = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
|
|
||||||
int c = (int)(wchar_t)p_str[i + p_ofs];
|
int c = (int)(wchar_t)p_str[i + p_ofs];
|
||||||
int v = 0;
|
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 Color::to_32() const {
|
||||||
|
|
||||||
uint32_t c = (uint8_t)(a * 255);
|
uint32_t c = (uint8_t)(a * 255);
|
||||||
c <<= 8;
|
c <<= 8;
|
||||||
c |= (uint8_t)(r * 255);
|
c |= (uint8_t)(r * 255);
|
||||||
@@ -148,7 +175,6 @@ uint8_t Color::get_a8() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float Color::get_h() const {
|
float Color::get_h() const {
|
||||||
|
|
||||||
float min = MIN(r, g);
|
float min = MIN(r, g);
|
||||||
min = MIN(min, b);
|
min = MIN(min, b);
|
||||||
float max = MAX(r, g);
|
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 Color::linear_interpolate(const Color &p_b, float p_t) const {
|
||||||
|
|
||||||
Color res = *this;
|
Color res = *this;
|
||||||
|
|
||||||
res.r += (p_t * (p_b.r - r));
|
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 Color::blend(const Color &p_over) const {
|
||||||
|
|
||||||
Color res;
|
Color res;
|
||||||
float sa = 1.0 - p_over.a;
|
float sa = 1.0 - p_over.a;
|
||||||
res.a = a * sa + 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 {
|
Color Color::to_linear() const {
|
||||||
|
|
||||||
return Color(
|
return Color(
|
||||||
r < 0.04045 ? r * (1.0 / 12.92) : ::pow((r + 0.055) * (1.0 / (1 + 0.055)), 2.4),
|
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),
|
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))
|
#define CLAMP(m_a, m_min, m_max) (((m_a) < (m_min)) ? (m_min) : (((m_a) > (m_max)) ? m_max : m_a))
|
||||||
#endif
|
#endif
|
||||||
static String _to_hex(float p_val) {
|
static String _to_hex(float p_val) {
|
||||||
|
|
||||||
int v = p_val * 255;
|
int v = p_val * 255;
|
||||||
v = CLAMP(v, 0, 255);
|
v = CLAMP(v, 0, 255);
|
||||||
String ret;
|
String ret;
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
|
|
||||||
wchar_t c[2] = { 0, 0 };
|
wchar_t c[2] = { 0, 0 };
|
||||||
int lv = v & 0xF;
|
int lv = v & 0xF;
|
||||||
if (lv < 10)
|
if (lv < 10)
|
||||||
@@ -514,7 +535,6 @@ Color::operator String() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Color::operator<(const Color &p_color) const {
|
bool Color::operator<(const Color &p_color) const {
|
||||||
|
|
||||||
if (r == p_color.r) {
|
if (r == p_color.r) {
|
||||||
if (g == p_color.g) {
|
if (g == p_color.g) {
|
||||||
if (b == p_color.b) {
|
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 {
|
Color Color::operator+(const Color &p_color) const {
|
||||||
|
|
||||||
return Color(
|
return Color(
|
||||||
r + p_color.r,
|
r + p_color.r,
|
||||||
g + p_color.g,
|
g + p_color.g,
|
||||||
@@ -537,7 +556,6 @@ Color Color::operator+(const Color &p_color) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Color::operator+=(const Color &p_color) {
|
void Color::operator+=(const Color &p_color) {
|
||||||
|
|
||||||
r = r + p_color.r;
|
r = r + p_color.r;
|
||||||
g = g + p_color.g;
|
g = g + p_color.g;
|
||||||
b = b + p_color.b;
|
b = b + p_color.b;
|
||||||
@@ -545,7 +563,6 @@ void Color::operator+=(const Color &p_color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color Color::operator-(const Color &p_color) const {
|
Color Color::operator-(const Color &p_color) const {
|
||||||
|
|
||||||
return Color(
|
return Color(
|
||||||
r - p_color.r,
|
r - p_color.r,
|
||||||
g - p_color.g,
|
g - p_color.g,
|
||||||
@@ -554,7 +571,6 @@ Color Color::operator-(const Color &p_color) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Color::operator-=(const Color &p_color) {
|
void Color::operator-=(const Color &p_color) {
|
||||||
|
|
||||||
r = r - p_color.r;
|
r = r - p_color.r;
|
||||||
g = g - p_color.g;
|
g = g - p_color.g;
|
||||||
b = b - p_color.b;
|
b = b - p_color.b;
|
||||||
@@ -562,7 +578,6 @@ void Color::operator-=(const Color &p_color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color Color::operator*(const Color &p_color) const {
|
Color Color::operator*(const Color &p_color) const {
|
||||||
|
|
||||||
return Color(
|
return Color(
|
||||||
r * p_color.r,
|
r * p_color.r,
|
||||||
g * p_color.g,
|
g * p_color.g,
|
||||||
@@ -571,7 +586,6 @@ Color Color::operator*(const Color &p_color) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color Color::operator*(const real_t &rvalue) const {
|
Color Color::operator*(const real_t &rvalue) const {
|
||||||
|
|
||||||
return Color(
|
return Color(
|
||||||
r * rvalue,
|
r * rvalue,
|
||||||
g * rvalue,
|
g * rvalue,
|
||||||
@@ -580,7 +594,6 @@ Color Color::operator*(const real_t &rvalue) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Color::operator*=(const Color &p_color) {
|
void Color::operator*=(const Color &p_color) {
|
||||||
|
|
||||||
r = r * p_color.r;
|
r = r * p_color.r;
|
||||||
g = g * p_color.g;
|
g = g * p_color.g;
|
||||||
b = b * p_color.b;
|
b = b * p_color.b;
|
||||||
@@ -588,7 +601,6 @@ void Color::operator*=(const Color &p_color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Color::operator*=(const real_t &rvalue) {
|
void Color::operator*=(const real_t &rvalue) {
|
||||||
|
|
||||||
r = r * rvalue;
|
r = r * rvalue;
|
||||||
g = g * rvalue;
|
g = g * rvalue;
|
||||||
b = b * rvalue;
|
b = b * rvalue;
|
||||||
@@ -596,7 +608,6 @@ void Color::operator*=(const real_t &rvalue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color Color::operator/(const Color &p_color) const {
|
Color Color::operator/(const Color &p_color) const {
|
||||||
|
|
||||||
return Color(
|
return Color(
|
||||||
r / p_color.r,
|
r / p_color.r,
|
||||||
g / p_color.g,
|
g / p_color.g,
|
||||||
@@ -605,7 +616,6 @@ Color Color::operator/(const Color &p_color) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color Color::operator/(const real_t &rvalue) const {
|
Color Color::operator/(const real_t &rvalue) const {
|
||||||
|
|
||||||
return Color(
|
return Color(
|
||||||
r / rvalue,
|
r / rvalue,
|
||||||
g / rvalue,
|
g / rvalue,
|
||||||
@@ -614,7 +624,6 @@ Color Color::operator/(const real_t &rvalue) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Color::operator/=(const Color &p_color) {
|
void Color::operator/=(const Color &p_color) {
|
||||||
|
|
||||||
r = r / p_color.r;
|
r = r / p_color.r;
|
||||||
g = g / p_color.g;
|
g = g / p_color.g;
|
||||||
b = b / p_color.b;
|
b = b / p_color.b;
|
||||||
@@ -622,7 +631,6 @@ void Color::operator/=(const Color &p_color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Color::operator/=(const real_t &rvalue) {
|
void Color::operator/=(const real_t &rvalue) {
|
||||||
|
|
||||||
if (rvalue == 0) {
|
if (rvalue == 0) {
|
||||||
r = 1.0;
|
r = 1.0;
|
||||||
g = 1.0;
|
g = 1.0;
|
||||||
@@ -637,7 +645,6 @@ void Color::operator/=(const real_t &rvalue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Color Color::operator-() const {
|
Color Color::operator-() const {
|
||||||
|
|
||||||
return Color(
|
return Color(
|
||||||
1.0 - r,
|
1.0 - r,
|
||||||
1.0 - g,
|
1.0 - g,
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Dictionary.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Dictionary.hpp"
|
||||||
#include "Array.hpp"
|
#include "Array.hpp"
|
||||||
#include "GodotGlobal.hpp"
|
#include "GodotGlobal.hpp"
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* GodotGlobal.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "GodotGlobal.hpp"
|
||||||
|
|
||||||
#include "String.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);
|
godot::api->godot_print_warning(c_desc, c_func, c_file, line);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (c_desc != nullptr) godot::api->godot_free(c_desc);
|
if (c_desc != nullptr)
|
||||||
if (c_func != nullptr) godot::api->godot_free(c_func);
|
godot::api->godot_free(c_desc);
|
||||||
if (c_file != nullptr) godot::api->godot_free(c_file);
|
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) {
|
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);
|
godot::api->godot_print_error(c_desc, c_func, c_file, line);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (c_desc != nullptr) godot::api->godot_free(c_desc);
|
if (c_desc != nullptr)
|
||||||
if (c_func != nullptr) godot::api->godot_free(c_func);
|
godot::api->godot_free(c_desc);
|
||||||
if (c_file != nullptr) godot::api->godot_free(c_file);
|
if (c_func != nullptr)
|
||||||
|
godot::api->godot_free(c_func);
|
||||||
|
if (c_file != nullptr)
|
||||||
|
godot::api->godot_free(c_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ___register_types();
|
void ___register_types();
|
||||||
@@ -136,7 +172,8 @@ void Godot::gdnative_init(godot_gdnative_init_options *options) {
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default: break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* NodePath.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "NodePath.hpp"
|
||||||
#include "GodotGlobal.hpp"
|
#include "GodotGlobal.hpp"
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Plane.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Plane.hpp"
|
||||||
#include "Vector3.hpp"
|
#include "Vector3.hpp"
|
||||||
|
|
||||||
@@ -10,12 +40,10 @@ void Plane::set_normal(const Vector3 &p_normal) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Plane::project(const Vector3 &p_point) const {
|
Vector3 Plane::project(const Vector3 &p_point) const {
|
||||||
|
|
||||||
return p_point - normal * distance_to(p_point);
|
return p_point - normal * distance_to(p_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plane::normalize() {
|
void Plane::normalize() {
|
||||||
|
|
||||||
real_t l = normal.length();
|
real_t l = normal.length();
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
*this = Plane(0, 0, 0, 0);
|
*this = Plane(0, 0, 0, 0);
|
||||||
@@ -26,19 +54,16 @@ void Plane::normalize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Plane Plane::normalized() const {
|
Plane Plane::normalized() const {
|
||||||
|
|
||||||
Plane p = *this;
|
Plane p = *this;
|
||||||
p.normalize();
|
p.normalize();
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Plane::get_any_point() const {
|
Vector3 Plane::get_any_point() const {
|
||||||
|
|
||||||
return get_normal() * d;
|
return get_normal() * d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Plane::get_any_perpendicular_normal() const {
|
Vector3 Plane::get_any_perpendicular_normal() const {
|
||||||
|
|
||||||
static const Vector3 p1 = Vector3(1, 0, 0);
|
static const Vector3 p1 = Vector3(1, 0, 0);
|
||||||
static const Vector3 p2 = Vector3(0, 1, 0);
|
static const Vector3 p2 = Vector3(0, 1, 0);
|
||||||
Vector3 p;
|
Vector3 p;
|
||||||
@@ -57,7 +82,6 @@ Vector3 Plane::get_any_perpendicular_normal() const {
|
|||||||
/* intersections */
|
/* intersections */
|
||||||
|
|
||||||
bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result) const {
|
bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result) const {
|
||||||
|
|
||||||
const Plane &p_plane0 = *this;
|
const Plane &p_plane0 = *this;
|
||||||
Vector3 normal0 = p_plane0.normal;
|
Vector3 normal0 = p_plane0.normal;
|
||||||
Vector3 normal1 = p_plane1.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 {
|
bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const {
|
||||||
|
|
||||||
Vector3 segment = p_dir;
|
Vector3 segment = p_dir;
|
||||||
real_t den = normal.dot(segment);
|
real_t den = normal.dot(segment);
|
||||||
|
|
||||||
//printf("den is %i\n",den);
|
//printf("den is %i\n",den);
|
||||||
if (::fabs(den) <= CMP_EPSILON) {
|
if (::fabs(den) <= CMP_EPSILON) {
|
||||||
|
|
||||||
return false;
|
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 {
|
bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const {
|
||||||
|
|
||||||
Vector3 segment = p_begin - p_end;
|
Vector3 segment = p_begin - p_end;
|
||||||
real_t den = normal.dot(segment);
|
real_t den = normal.dot(segment);
|
||||||
|
|
||||||
//printf("den is %i\n",den);
|
//printf("den is %i\n",den);
|
||||||
if (::fabs(den) <= CMP_EPSILON) {
|
if (::fabs(den) <= CMP_EPSILON) {
|
||||||
|
|
||||||
return false;
|
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);
|
//printf("dist is %i\n",dist);
|
||||||
|
|
||||||
if (dist < -CMP_EPSILON || dist > (1.0 + CMP_EPSILON)) {
|
if (dist < -CMP_EPSILON || dist > (1.0 + CMP_EPSILON)) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,47 +150,39 @@ bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_inters
|
|||||||
/* misc */
|
/* misc */
|
||||||
|
|
||||||
bool Plane::is_almost_like(const Plane &p_plane) const {
|
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);
|
return (normal.dot(p_plane.normal) > _PLANE_EQ_DOT_EPSILON && ::fabs(d - p_plane.d) < _PLANE_EQ_D_EPSILON);
|
||||||
}
|
}
|
||||||
|
|
||||||
Plane::operator String() const {
|
Plane::operator String() const {
|
||||||
|
|
||||||
// return normal.operator String() + ", " + rtos(d);
|
// return normal.operator String() + ", " + rtos(d);
|
||||||
return String(); // @Todo
|
return String(); // @Todo
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plane::is_point_over(const Vector3 &p_point) const {
|
bool Plane::is_point_over(const Vector3 &p_point) const {
|
||||||
|
|
||||||
return (normal.dot(p_point) > d);
|
return (normal.dot(p_point) > d);
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Plane::distance_to(const Vector3 &p_point) const {
|
real_t Plane::distance_to(const Vector3 &p_point) const {
|
||||||
|
|
||||||
return (normal.dot(p_point) - d);
|
return (normal.dot(p_point) - d);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plane::has_point(const Vector3 &p_point, real_t _epsilon) const {
|
bool Plane::has_point(const Vector3 &p_point, real_t _epsilon) const {
|
||||||
|
|
||||||
real_t dist = normal.dot(p_point) - d;
|
real_t dist = normal.dot(p_point) - d;
|
||||||
dist = ::fabs(dist);
|
dist = ::fabs(dist);
|
||||||
return (dist <= _epsilon);
|
return (dist <= _epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
Plane::Plane(const Vector3 &p_normal, real_t p_d) {
|
Plane::Plane(const Vector3 &p_normal, real_t p_d) {
|
||||||
|
|
||||||
normal = p_normal;
|
normal = p_normal;
|
||||||
d = p_d;
|
d = p_d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal) {
|
Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal) {
|
||||||
|
|
||||||
normal = p_normal;
|
normal = p_normal;
|
||||||
d = p_normal.dot(p_point);
|
d = p_normal.dot(p_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
Plane::Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir) {
|
Plane::Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir) {
|
||||||
|
|
||||||
if (p_dir == CLOCKWISE)
|
if (p_dir == CLOCKWISE)
|
||||||
normal = (p_point1 - p_point3).cross(p_point1 - p_point2);
|
normal = (p_point1 - p_point3).cross(p_point1 - p_point2);
|
||||||
else
|
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 {
|
bool Plane::operator==(const Plane &p_plane) const {
|
||||||
|
|
||||||
return normal == p_plane.normal && d == p_plane.d;
|
return normal == p_plane.normal && d == p_plane.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plane::operator!=(const Plane &p_plane) const {
|
bool Plane::operator!=(const Plane &p_plane) const {
|
||||||
|
|
||||||
return normal != p_plane.normal || d != p_plane.d;
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "PoolArrays.hpp"
|
||||||
#include "Color.hpp"
|
#include "Color.hpp"
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Quat.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Quat.hpp"
|
||||||
#include "Basis.hpp"
|
#include "Basis.hpp"
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
@@ -100,7 +130,6 @@ Quat Quat::inverse() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Quat Quat::slerp(const Quat &q, const real_t &t) const {
|
Quat Quat::slerp(const Quat &q, const real_t &t) const {
|
||||||
|
|
||||||
Quat to1;
|
Quat to1;
|
||||||
real_t omega, cosom, sinom, scale0, scale1;
|
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 {
|
Quat Quat::slerpni(const Quat &q, const real_t &t) const {
|
||||||
|
|
||||||
const Quat &from = *this;
|
const Quat &from = *this;
|
||||||
|
|
||||||
real_t dot = from.dot(q);
|
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),
|
real_t theta = ::acos(dot),
|
||||||
sinT = 1.0 / ::sin(theta),
|
sinT = 1.0 / ::sin(theta),
|
||||||
@@ -200,7 +229,6 @@ Quat Quat::operator*(const Vector3 &v) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector3 Quat::xform(const Vector3 &v) const {
|
Vector3 Quat::xform(const Vector3 &v) const {
|
||||||
|
|
||||||
Quat q = *this * v;
|
Quat q = *this * v;
|
||||||
q *= this->inverse();
|
q *= this->inverse();
|
||||||
return Vector3(q.x, q.y, q.z);
|
return Vector3(q.x, q.y, q.z);
|
||||||
@@ -234,7 +262,6 @@ Quat::Quat(const Vector3 &v0, const Vector3 &v1) // shortest arc
|
|||||||
z = 0;
|
z = 0;
|
||||||
w = 0;
|
w = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
real_t s = ::sqrt((1.0 + d) * 2.0);
|
real_t s = ::sqrt((1.0 + d) * 2.0);
|
||||||
real_t rs = 1.0 / s;
|
real_t rs = 1.0 / s;
|
||||||
|
|
||||||
@@ -282,7 +309,6 @@ void Quat::operator*=(const real_t &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Quat::operator/=(const real_t &s) {
|
void Quat::operator/=(const real_t &s) {
|
||||||
|
|
||||||
*this *= 1.0 / s;
|
*this *= 1.0 / s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* RID.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "RID.hpp"
|
||||||
|
|
||||||
#include <gdnative/rid.h>
|
#include <gdnative/rid.h>
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Rect2.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Rect2.hpp"
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
#include "Transform2D.hpp"
|
#include "Transform2D.hpp"
|
||||||
@@ -16,7 +46,6 @@ namespace godot {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
real_t Rect2::distance_to(const Vector2 &p_point) const {
|
real_t Rect2::distance_to(const Vector2 &p_point) const {
|
||||||
|
|
||||||
real_t dist = 1e20;
|
real_t dist = 1e20;
|
||||||
|
|
||||||
if (p_point.x < position.x) {
|
if (p_point.x < position.x) {
|
||||||
@@ -77,7 +106,6 @@ Rect2::operator String() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_position, Point2 *r_normal) 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;
|
real_t min = 0, max = 1;
|
||||||
int axis = 0;
|
int axis = 0;
|
||||||
real_t sign = 0;
|
real_t sign = 0;
|
||||||
@@ -91,7 +119,6 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
|
|||||||
real_t csign;
|
real_t csign;
|
||||||
|
|
||||||
if (seg_from < seg_to) {
|
if (seg_from < seg_to) {
|
||||||
|
|
||||||
if (seg_from > box_end || seg_to < box_begin)
|
if (seg_from > box_end || seg_to < box_begin)
|
||||||
return false;
|
return false;
|
||||||
real_t length = seg_to - seg_from;
|
real_t length = seg_to - seg_from;
|
||||||
@@ -100,7 +127,6 @@ bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2
|
|||||||
csign = -1.0;
|
csign = -1.0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (seg_to > box_end || seg_from < box_begin)
|
if (seg_to > box_end || seg_from < box_begin)
|
||||||
return false;
|
return false;
|
||||||
real_t length = seg_to - seg_from;
|
real_t length = seg_to - seg_from;
|
||||||
@@ -135,7 +161,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 {
|
bool Rect2::intersects_transformed(const Transform2D &p_xform, const Rect2 &p_rect) const {
|
||||||
|
|
||||||
//SAT intersection between local and transformed rect2
|
//SAT intersection between local and transformed rect2
|
||||||
|
|
||||||
Vector2 xf_points[4] = {
|
Vector2 xf_points[4] = {
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* String.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "String.hpp"
|
||||||
|
|
||||||
#include "Array.hpp"
|
#include "Array.hpp"
|
||||||
@@ -73,6 +103,10 @@ String::String(const String &other) {
|
|||||||
godot::api->godot_string_new_copy(&_godot_string, &other._godot_string);
|
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() {
|
String::~String() {
|
||||||
godot::api->godot_string_destroy(&_godot_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);
|
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 {
|
bool String::operator==(const String &s) const {
|
||||||
return godot::api->godot_string_operator_equal(&_godot_string, &s._godot_string);
|
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 {
|
char *String::alloc_c_string() const {
|
||||||
|
|
||||||
godot_char_string contents = godot::api->godot_string_utf8(&_godot_string);
|
godot_char_string contents = godot::api->godot_string_utf8(&_godot_string);
|
||||||
|
|
||||||
int length = godot::api->godot_char_string_length(&contents);
|
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 String::ascii(bool p_extended) const {
|
||||||
|
|
||||||
CharString ret;
|
CharString ret;
|
||||||
|
|
||||||
if (p_extended)
|
if (p_extended)
|
||||||
@@ -185,7 +222,7 @@ String operator+(const wchar_t *a, const String &b) {
|
|||||||
return String(a) + 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);
|
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);
|
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);
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "TagDB.hpp"
|
||||||
|
|
||||||
#include <unordered_map>
|
#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) {
|
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);
|
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);
|
register_type(type_tag, base_type_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_type_compatible(size_t ask_tag, size_t have_tag) {
|
bool is_type_compatible(size_t ask_tag, size_t have_tag) {
|
||||||
|
|
||||||
if (have_tag == 0)
|
if (have_tag == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Transform.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Transform.hpp"
|
||||||
|
|
||||||
#include "Basis.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);
|
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 {
|
Transform Transform::inverse_xform(const Transform &t) const {
|
||||||
|
|
||||||
Vector3 v = t.origin - origin;
|
Vector3 v = t.origin - origin;
|
||||||
return Transform(basis.transpose_xform(t.basis),
|
return Transform(basis.transpose_xform(t.basis),
|
||||||
basis.xform(v));
|
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) {
|
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][0] = xx;
|
||||||
basis.elements[0][1] = xy;
|
basis.elements[0][1] = xy;
|
||||||
basis.elements[0][2] = xz;
|
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 {
|
Vector3 Transform::xform(const Vector3 &p_vector) const {
|
||||||
|
|
||||||
return Vector3(
|
return Vector3(
|
||||||
basis.elements[0].dot(p_vector) + origin.x,
|
basis.elements[0].dot(p_vector) + origin.x,
|
||||||
basis.elements[1].dot(p_vector) + origin.y,
|
basis.elements[1].dot(p_vector) + origin.y,
|
||||||
basis.elements[2].dot(p_vector) + origin.z);
|
basis.elements[2].dot(p_vector) + origin.z);
|
||||||
}
|
}
|
||||||
Vector3 Transform::xform_inv(const Vector3 &p_vector) const {
|
Vector3 Transform::xform_inv(const Vector3 &p_vector) const {
|
||||||
|
|
||||||
Vector3 v = p_vector - origin;
|
Vector3 v = p_vector - origin;
|
||||||
|
|
||||||
return Vector3(
|
return Vector3(
|
||||||
@@ -55,7 +81,6 @@ Vector3 Transform::xform_inv(const Vector3 &p_vector) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Plane Transform::xform(const Plane &p_plane) const {
|
Plane Transform::xform(const Plane &p_plane) const {
|
||||||
|
|
||||||
Vector3 point = p_plane.normal * p_plane.d;
|
Vector3 point = p_plane.normal * p_plane.d;
|
||||||
Vector3 point_dir = point + p_plane.normal;
|
Vector3 point_dir = point + p_plane.normal;
|
||||||
point = xform(point);
|
point = xform(point);
|
||||||
@@ -68,7 +93,6 @@ Plane Transform::xform(const Plane &p_plane) const {
|
|||||||
return Plane(normal, d);
|
return Plane(normal, d);
|
||||||
}
|
}
|
||||||
Plane Transform::xform_inv(const Plane &p_plane) const {
|
Plane Transform::xform_inv(const Plane &p_plane) const {
|
||||||
|
|
||||||
Vector3 point = p_plane.normal * p_plane.d;
|
Vector3 point = p_plane.normal * p_plane.d;
|
||||||
Vector3 point_dir = point + p_plane.normal;
|
Vector3 point_dir = point + p_plane.normal;
|
||||||
point = xform_inv(point);
|
point = xform_inv(point);
|
||||||
@@ -100,7 +124,6 @@ AABB Transform::xform(const AABB &p_aabb) const {
|
|||||||
return new_aabb;
|
return new_aabb;
|
||||||
}
|
}
|
||||||
AABB Transform::xform_inv(const AABB &p_aabb) const {
|
AABB Transform::xform_inv(const AABB &p_aabb) const {
|
||||||
|
|
||||||
/* define vertices */
|
/* define vertices */
|
||||||
Vector3 vertices[8] = {
|
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),
|
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]);
|
ret.position = xform_inv(vertices[0]);
|
||||||
|
|
||||||
for (int i = 1; i < 8; i++) {
|
for (int i = 1; i < 8; i++) {
|
||||||
|
|
||||||
ret.expand_to(xform_inv(vertices[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() {
|
void Transform::affine_invert() {
|
||||||
|
|
||||||
basis.invert();
|
basis.invert();
|
||||||
origin = basis.xform(-origin);
|
origin = basis.xform(-origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform Transform::affine_inverse() const {
|
Transform Transform::affine_inverse() const {
|
||||||
|
|
||||||
Transform ret = *this;
|
Transform ret = *this;
|
||||||
ret.affine_invert();
|
ret.affine_invert();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::invert() {
|
void Transform::invert() {
|
||||||
|
|
||||||
basis.transpose();
|
basis.transpose();
|
||||||
origin = basis.xform(-origin);
|
origin = basis.xform(-origin);
|
||||||
}
|
}
|
||||||
@@ -153,29 +172,24 @@ Transform Transform::inverse() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Transform::rotate(const Vector3 &p_axis, real_t p_phi) {
|
void Transform::rotate(const Vector3 &p_axis, real_t p_phi) {
|
||||||
|
|
||||||
*this = rotated(p_axis, p_phi);
|
*this = rotated(p_axis, p_phi);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform Transform::rotated(const Vector3 &p_axis, real_t p_phi) const {
|
Transform Transform::rotated(const Vector3 &p_axis, real_t p_phi) const {
|
||||||
|
|
||||||
return Transform(Basis(p_axis, p_phi), Vector3()) * (*this);
|
return Transform(Basis(p_axis, p_phi), Vector3()) * (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::rotate_basis(const Vector3 &p_axis, real_t p_phi) {
|
void Transform::rotate_basis(const Vector3 &p_axis, real_t p_phi) {
|
||||||
|
|
||||||
basis.rotate(p_axis, p_phi);
|
basis.rotate(p_axis, p_phi);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform Transform::looking_at(const Vector3 &p_target, const Vector3 &p_up) const {
|
Transform Transform::looking_at(const Vector3 &p_target, const Vector3 &p_up) const {
|
||||||
|
|
||||||
Transform t = *this;
|
Transform t = *this;
|
||||||
t.set_look_at(origin, p_target, p_up);
|
t.set_look_at(origin, p_target, p_up);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) {
|
void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) {
|
||||||
|
|
||||||
// Reference: MESA source code
|
// Reference: MESA source code
|
||||||
Vector3 v_x, v_y, v_z;
|
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 {
|
Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c) const {
|
||||||
|
|
||||||
/* not sure if very "efficient" but good enough? */
|
/* not sure if very "efficient" but good enough? */
|
||||||
|
|
||||||
Vector3 src_scale = basis.get_scale();
|
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) {
|
void Transform::scale(const Vector3 &p_scale) {
|
||||||
|
|
||||||
basis.scale(p_scale);
|
basis.scale(p_scale);
|
||||||
origin *= p_scale;
|
origin *= p_scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform Transform::scaled(const Vector3 &p_scale) const {
|
Transform Transform::scaled(const Vector3 &p_scale) const {
|
||||||
|
|
||||||
Transform t = *this;
|
Transform t = *this;
|
||||||
t.scale(p_scale);
|
t.scale(p_scale);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::scale_basis(const Vector3 &p_scale) {
|
void Transform::scale_basis(const Vector3 &p_scale) {
|
||||||
|
|
||||||
basis.scale(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));
|
translate(Vector3(p_tx, p_ty, p_tz));
|
||||||
}
|
}
|
||||||
void Transform::translate(const Vector3 &p_translation) {
|
void Transform::translate(const Vector3 &p_translation) {
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
origin[i] += basis.elements[i].dot(p_translation);
|
origin[i] += basis.elements[i].dot(p_translation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform Transform::translated(const Vector3 &p_translation) const {
|
Transform Transform::translated(const Vector3 &p_translation) const {
|
||||||
|
|
||||||
Transform t = *this;
|
Transform t = *this;
|
||||||
t.translate(p_translation);
|
t.translate(p_translation);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::orthonormalize() {
|
void Transform::orthonormalize() {
|
||||||
|
|
||||||
basis.orthonormalize();
|
basis.orthonormalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform Transform::orthonormalized() const {
|
Transform Transform::orthonormalized() const {
|
||||||
|
|
||||||
Transform _copy = *this;
|
Transform _copy = *this;
|
||||||
_copy.orthonormalize();
|
_copy.orthonormalize();
|
||||||
return _copy;
|
return _copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transform::operator==(const Transform &p_transform) const {
|
bool Transform::operator==(const Transform &p_transform) const {
|
||||||
|
|
||||||
return (basis == p_transform.basis && origin == p_transform.origin);
|
return (basis == p_transform.basis && origin == p_transform.origin);
|
||||||
}
|
}
|
||||||
bool Transform::operator!=(const Transform &p_transform) const {
|
bool Transform::operator!=(const Transform &p_transform) const {
|
||||||
|
|
||||||
return (basis != p_transform.basis || origin != p_transform.origin);
|
return (basis != p_transform.basis || origin != p_transform.origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform::operator*=(const Transform &p_transform) {
|
void Transform::operator*=(const Transform &p_transform) {
|
||||||
|
|
||||||
origin = xform(p_transform.origin);
|
origin = xform(p_transform.origin);
|
||||||
basis *= p_transform.basis;
|
basis *= p_transform.basis;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform Transform::operator*(const Transform &p_transform) const {
|
Transform Transform::operator*(const Transform &p_transform) const {
|
||||||
|
|
||||||
Transform t = *this;
|
Transform t = *this;
|
||||||
t *= p_transform;
|
t *= p_transform;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform::operator String() const {
|
Transform::operator String() const {
|
||||||
|
|
||||||
return basis.operator String() + " - " + origin.operator String();
|
return basis.operator String() + " - " + origin.operator String();
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) {
|
Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) {
|
||||||
|
|
||||||
basis = p_basis;
|
basis = p_basis;
|
||||||
origin = p_origin;
|
origin = p_origin;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Transform2D.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Transform2D.hpp"
|
||||||
#include "Rect2.hpp"
|
#include "Rect2.hpp"
|
||||||
#include "String.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);
|
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) {
|
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][0] = xx;
|
||||||
elements[0][1] = xy;
|
elements[0][1] = xy;
|
||||||
elements[1][0] = yx;
|
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 {
|
Vector2 Transform2D::basis_xform(const Vector2 &v) const {
|
||||||
|
|
||||||
return Vector2(
|
return Vector2(
|
||||||
tdotx(v),
|
tdotx(v),
|
||||||
tdoty(v));
|
tdoty(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Transform2D::basis_xform_inv(const Vector2 &v) const {
|
Vector2 Transform2D::basis_xform_inv(const Vector2 &v) const {
|
||||||
|
|
||||||
return Vector2(
|
return Vector2(
|
||||||
elements[0].dot(v),
|
elements[0].dot(v),
|
||||||
elements[1].dot(v));
|
elements[1].dot(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Transform2D::xform(const Vector2 &v) const {
|
Vector2 Transform2D::xform(const Vector2 &v) const {
|
||||||
|
|
||||||
return Vector2(
|
return Vector2(
|
||||||
tdotx(v),
|
tdotx(v),
|
||||||
tdoty(v)) +
|
tdoty(v)) +
|
||||||
elements[2];
|
elements[2];
|
||||||
}
|
}
|
||||||
Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const {
|
Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const {
|
||||||
|
|
||||||
Vector2 v = p_vec - elements[2];
|
Vector2 v = p_vec - elements[2];
|
||||||
|
|
||||||
return Vector2(
|
return Vector2(
|
||||||
@@ -51,7 +76,6 @@ Vector2 Transform2D::xform_inv(const Vector2 &p_vec) const {
|
|||||||
elements[1].dot(v));
|
elements[1].dot(v));
|
||||||
}
|
}
|
||||||
Rect2 Transform2D::xform(const Rect2 &p_rect) const {
|
Rect2 Transform2D::xform(const Rect2 &p_rect) const {
|
||||||
|
|
||||||
Vector2 x = elements[0] * p_rect.size.x;
|
Vector2 x = elements[0] * p_rect.size.x;
|
||||||
Vector2 y = elements[1] * p_rect.size.y;
|
Vector2 y = elements[1] * p_rect.size.y;
|
||||||
Vector2 position = xform(p_rect.position);
|
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) {
|
void Transform2D::set_rotation_and_scale(real_t p_rot, const Size2 &p_scale) {
|
||||||
|
|
||||||
elements[0][0] = ::cos(p_rot) * p_scale.x;
|
elements[0][0] = ::cos(p_rot) * p_scale.x;
|
||||||
elements[1][1] = ::cos(p_rot) * p_scale.y;
|
elements[1][1] = ::cos(p_rot) * p_scale.y;
|
||||||
elements[1][0] = -::sin(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 {
|
Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const {
|
||||||
|
|
||||||
Vector2 ends[4] = {
|
Vector2 ends[4] = {
|
||||||
xform_inv(p_rect.position),
|
xform_inv(p_rect.position),
|
||||||
xform_inv(Vector2(p_rect.position.x, p_rect.position.y + p_rect.size.y)),
|
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 Transform2D::inverse() const {
|
||||||
|
|
||||||
Transform2D inv = *this;
|
Transform2D inv = *this;
|
||||||
inv.invert();
|
inv.invert();
|
||||||
return inv;
|
return inv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform2D::affine_invert() {
|
void Transform2D::affine_invert() {
|
||||||
|
|
||||||
real_t det = basis_determinant();
|
real_t det = basis_determinant();
|
||||||
ERR_FAIL_COND(det == 0);
|
ERR_FAIL_COND(det == 0);
|
||||||
real_t idet = 1.0 / det;
|
real_t idet = 1.0 / det;
|
||||||
@@ -118,7 +138,6 @@ void Transform2D::affine_invert() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Transform2D Transform2D::affine_inverse() const {
|
Transform2D Transform2D::affine_inverse() const {
|
||||||
|
|
||||||
Transform2D inv = *this;
|
Transform2D inv = *this;
|
||||||
inv.affine_invert();
|
inv.affine_invert();
|
||||||
return inv;
|
return inv;
|
||||||
@@ -138,7 +157,6 @@ real_t Transform2D::get_rotation() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Transform2D::set_rotation(real_t p_rot) {
|
void Transform2D::set_rotation(real_t p_rot) {
|
||||||
|
|
||||||
real_t cr = ::cos(p_rot);
|
real_t cr = ::cos(p_rot);
|
||||||
real_t sr = ::sin(p_rot);
|
real_t sr = ::sin(p_rot);
|
||||||
elements[0][0] = cr;
|
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) {
|
Transform2D::Transform2D(real_t p_rot, const Vector2 &p_position) {
|
||||||
|
|
||||||
real_t cr = ::cos(p_rot);
|
real_t cr = ::cos(p_rot);
|
||||||
real_t sr = ::sin(p_rot);
|
real_t sr = ::sin(p_rot);
|
||||||
elements[0][0] = cr;
|
elements[0][0] = cr;
|
||||||
@@ -168,23 +185,19 @@ void Transform2D::scale(const Size2 &p_scale) {
|
|||||||
elements[2] *= p_scale;
|
elements[2] *= p_scale;
|
||||||
}
|
}
|
||||||
void Transform2D::scale_basis(const Size2 &p_scale) {
|
void Transform2D::scale_basis(const Size2 &p_scale) {
|
||||||
|
|
||||||
elements[0][0] *= p_scale.x;
|
elements[0][0] *= p_scale.x;
|
||||||
elements[0][1] *= p_scale.y;
|
elements[0][1] *= p_scale.y;
|
||||||
elements[1][0] *= p_scale.x;
|
elements[1][0] *= p_scale.x;
|
||||||
elements[1][1] *= p_scale.y;
|
elements[1][1] *= p_scale.y;
|
||||||
}
|
}
|
||||||
void Transform2D::translate(real_t p_tx, real_t p_ty) {
|
void Transform2D::translate(real_t p_tx, real_t p_ty) {
|
||||||
|
|
||||||
translate(Vector2(p_tx, p_ty));
|
translate(Vector2(p_tx, p_ty));
|
||||||
}
|
}
|
||||||
void Transform2D::translate(const Vector2 &p_translation) {
|
void Transform2D::translate(const Vector2 &p_translation) {
|
||||||
|
|
||||||
elements[2] += basis_xform(p_translation);
|
elements[2] += basis_xform(p_translation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transform2D::orthonormalize() {
|
void Transform2D::orthonormalize() {
|
||||||
|
|
||||||
// Gram-Schmidt Process
|
// Gram-Schmidt Process
|
||||||
|
|
||||||
Vector2 x = elements[0];
|
Vector2 x = elements[0];
|
||||||
@@ -198,14 +211,12 @@ void Transform2D::orthonormalize() {
|
|||||||
elements[1] = y;
|
elements[1] = y;
|
||||||
}
|
}
|
||||||
Transform2D Transform2D::orthonormalized() const {
|
Transform2D Transform2D::orthonormalized() const {
|
||||||
|
|
||||||
Transform2D on = *this;
|
Transform2D on = *this;
|
||||||
on.orthonormalize();
|
on.orthonormalize();
|
||||||
return on;
|
return on;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transform2D::operator==(const Transform2D &p_transform) const {
|
bool Transform2D::operator==(const Transform2D &p_transform) const {
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (elements[i] != p_transform.elements[i])
|
if (elements[i] != p_transform.elements[i])
|
||||||
return false;
|
return false;
|
||||||
@@ -215,7 +226,6 @@ bool Transform2D::operator==(const Transform2D &p_transform) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Transform2D::operator!=(const Transform2D &p_transform) const {
|
bool Transform2D::operator!=(const Transform2D &p_transform) const {
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (elements[i] != p_transform.elements[i])
|
if (elements[i] != p_transform.elements[i])
|
||||||
return true;
|
return true;
|
||||||
@@ -225,7 +235,6 @@ bool Transform2D::operator!=(const Transform2D &p_transform) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Transform2D::operator*=(const Transform2D &p_transform) {
|
void Transform2D::operator*=(const Transform2D &p_transform) {
|
||||||
|
|
||||||
elements[2] = xform(p_transform.elements[2]);
|
elements[2] = xform(p_transform.elements[2]);
|
||||||
|
|
||||||
real_t x0, x1, y0, y1;
|
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 Transform2D::operator*(const Transform2D &p_transform) const {
|
||||||
|
|
||||||
Transform2D t = *this;
|
Transform2D t = *this;
|
||||||
t *= p_transform;
|
t *= p_transform;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform2D Transform2D::scaled(const Size2 &p_scale) const {
|
Transform2D Transform2D::scaled(const Size2 &p_scale) const {
|
||||||
|
|
||||||
Transform2D copy = *this;
|
Transform2D copy = *this;
|
||||||
copy.scale(p_scale);
|
copy.scale(p_scale);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform2D Transform2D::basis_scaled(const Size2 &p_scale) const {
|
Transform2D Transform2D::basis_scaled(const Size2 &p_scale) const {
|
||||||
|
|
||||||
Transform2D copy = *this;
|
Transform2D copy = *this;
|
||||||
copy.scale_basis(p_scale);
|
copy.scale_basis(p_scale);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform2D Transform2D::untranslated() const {
|
Transform2D Transform2D::untranslated() const {
|
||||||
|
|
||||||
Transform2D copy = *this;
|
Transform2D copy = *this;
|
||||||
copy.elements[2] = Vector2();
|
copy.elements[2] = Vector2();
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform2D Transform2D::translated(const Vector2 &p_offset) const {
|
Transform2D Transform2D::translated(const Vector2 &p_offset) const {
|
||||||
|
|
||||||
Transform2D copy = *this;
|
Transform2D copy = *this;
|
||||||
copy.translate(p_offset);
|
copy.translate(p_offset);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform2D Transform2D::rotated(real_t p_phi) const {
|
Transform2D Transform2D::rotated(real_t p_phi) const {
|
||||||
|
|
||||||
Transform2D copy = *this;
|
Transform2D copy = *this;
|
||||||
copy.rotate(p_phi);
|
copy.rotate(p_phi);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
real_t Transform2D::basis_determinant() const {
|
real_t Transform2D::basis_determinant() const {
|
||||||
|
|
||||||
return elements[0].x * elements[1].y - elements[0].y * elements[1].x;
|
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 {
|
Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t p_c) const {
|
||||||
|
|
||||||
//extract parameters
|
//extract parameters
|
||||||
Vector2 p1 = get_origin();
|
Vector2 p1 = get_origin();
|
||||||
Vector2 p2 = p_transform.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 {
|
Transform2D::operator String() const {
|
||||||
|
|
||||||
return String(String() + elements[0] + ", " + elements[1] + ", " + elements[2]);
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Variant.hpp"
|
||||||
|
|
||||||
#include <gdnative/variant.h>
|
#include <gdnative/variant.h>
|
||||||
@@ -7,8 +37,6 @@
|
|||||||
#include "GodotGlobal.hpp"
|
#include "GodotGlobal.hpp"
|
||||||
#include "Object.hpp"
|
#include "Object.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
Variant::Variant() {
|
Variant::Variant() {
|
||||||
@@ -160,6 +188,7 @@ Variant::Variant(const PoolColorArray &p_color_array) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Variant &Variant::operator=(const Variant &v) {
|
Variant &Variant::operator=(const Variant &v) {
|
||||||
|
godot::api->godot_variant_destroy(&_godot_variant);
|
||||||
godot::api->godot_variant_new_copy(&_godot_variant, &v._godot_variant);
|
godot::api->godot_variant_new_copy(&_godot_variant, &v._godot_variant);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,33 @@
|
|||||||
|
/*************************************************************************/
|
||||||
|
/* Vector2.cpp */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* This file is part of: */
|
||||||
|
/* GODOT ENGINE */
|
||||||
|
/* https://godotengine.org */
|
||||||
|
/*************************************************************************/
|
||||||
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Vector2.hpp"
|
||||||
|
|
||||||
#include <gdnative/vector2.h>
|
#include <gdnative/vector2.h>
|
||||||
@@ -6,9 +36,9 @@
|
|||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
const Vector2 Vector2::ZERO;
|
const Vector2 Vector2::ZERO = Vector2();
|
||||||
const Vector2 Vector2::ONE;
|
const Vector2 Vector2::ONE = Vector2(1, 1);
|
||||||
const Vector2 Vector2::INF;
|
const Vector2 Vector2::INF = Vector2(INFINITY, INFINITY);
|
||||||
|
|
||||||
const Vector2 Vector2::LEFT = Vector2(-1, 0);
|
const Vector2 Vector2::LEFT = Vector2(-1, 0);
|
||||||
const Vector2 Vector2::RIGHT = 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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 "Vector3.hpp"
|
||||||
|
|
||||||
#include "String.hpp"
|
#include "String.hpp"
|
||||||
@@ -9,7 +39,7 @@
|
|||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
const Vector3 Vector3::ZERO = Vector3();
|
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::INF = Vector3(INFINITY, INFINITY, INFINITY);
|
||||||
|
|
||||||
const Vector3 Vector3::LEFT = Vector3(-1, 0, 0);
|
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
|
||||||
|
*~
|
||||||
@@ -104,6 +104,7 @@ elif env['platform'] == "windows":
|
|||||||
|
|
||||||
env.Append(CPPDEFINES=['WIN32', '_WIN32', '_WINDOWS', '_CRT_SECURE_NO_WARNINGS'])
|
env.Append(CPPDEFINES=['WIN32', '_WIN32', '_WINDOWS', '_CRT_SECURE_NO_WARNINGS'])
|
||||||
env.Append(CCFLAGS=['-W3', '-GR'])
|
env.Append(CCFLAGS=['-W3', '-GR'])
|
||||||
|
env.Append(CXXFLAGS=['-std:c++17'])
|
||||||
if env['target'] in ('debug', 'd'):
|
if env['target'] in ('debug', 'd'):
|
||||||
env.Append(CPPDEFINES=['_DEBUG'])
|
env.Append(CPPDEFINES=['_DEBUG'])
|
||||||
env.Append(CCFLAGS=['-EHsc', '-MDd', '-ZI'])
|
env.Append(CCFLAGS=['-EHsc', '-MDd', '-ZI'])
|
||||||
|
|||||||
@@ -10,10 +10,8 @@ config_version=4
|
|||||||
|
|
||||||
_global_script_classes=[ ]
|
_global_script_classes=[ ]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Test CI project"
|
config/name="Test CI project"
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
|
|
||||||
extends MainLoop
|
extends MainLoop
|
||||||
|
|
||||||
|
|
||||||
func _initialize():
|
func _initialize():
|
||||||
OS.exit_code = 1
|
OS.exit_code = 1
|
||||||
var native_script = load("res://gdexample.gdns")
|
var native_script = load("res://gdexample.gdns")
|
||||||
print("Native Script ", native_script)
|
print("Native Script ", native_script)
|
||||||
if native_script == null || !is_instance_valid(native_script):
|
if not native_script || !is_instance_valid(native_script):
|
||||||
return
|
return
|
||||||
print("Library ", native_script.library)
|
print("Library ", native_script.library)
|
||||||
if native_script.library == null || !is_instance_valid(native_script.library):
|
if not native_script.library || !is_instance_valid(native_script.library):
|
||||||
return
|
return
|
||||||
var ref = native_script.new()
|
var ref = native_script.new()
|
||||||
print("Reference ", ref)
|
print("Reference ", ref)
|
||||||
if ref == null || !is_instance_valid(ref):
|
if not ref || !is_instance_valid(ref):
|
||||||
return
|
return
|
||||||
print("Reference name ", ref.name)
|
print("Reference name ", ref.name)
|
||||||
if ref.name != "SimpleClass":
|
if ref.name != "SimpleClass":
|
||||||
return
|
return
|
||||||
print("Reference value ", ref.value)
|
print("Reference value ", ref.value)
|
||||||
if ref.value != 0:
|
if ref.value != 0:
|
||||||
return
|
return
|
||||||
print("Call method ", ref.method(1))
|
print("Call method ", ref.method(1))
|
||||||
if ref.method(1) != 1:
|
if ref.method(1) != 1:
|
||||||
return
|
return
|
||||||
OS.exit_code = 0
|
OS.exit_code = 0
|
||||||
|
|
||||||
|
|
||||||
func _idle(_delta):
|
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-2021 Juan Linietsky, Ariel Manzur. */
|
||||||
|
/* Copyright (c) 2014-2021 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 <Godot.hpp>
|
||||||
#include <Reference.hpp>
|
#include <Reference.hpp>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user