Compare commits

..

242 Commits

Author SHA1 Message Date
9ed2084b42 Revert "-make sure single select after multi select works better"
This reverts commit f909634832.
It caused various regressions (#4556 and #4607).
2016-05-13 08:06:31 +02:00
c0df7da2ca Version 2.0.3 2016-05-12 19:54:11 +02:00
49bf494eac classref: Readd String.strip_edges description 2016-05-12 19:47:26 +02:00
b8d8ec09ee Remove nocpuid.c from builtin OpenSSL
Since opensslconf.h no longer defines OPENSSL_CPUID_OBJ, OpenSSL defines
OPENSSL_cpuid_setup itself (with the same empty definition)

(cherry picked from commit 2392824dba)
2016-05-12 19:35:49 +02:00
f120514402 classref: Fixed return types in Area and Area2D (#4635)
(cherry picked from commit 91c85ff1f5)
2016-05-12 19:35:41 +02:00
77573a76d1 classref: Sync with current source 2016-05-12 09:16:37 +02:00
c734a508c3 classref: Directory and ConfigFile
(cherry picked from commit 22d1385caf)
2016-05-12 09:07:43 +02:00
d66b04921f Windows: Fix GCC/Clang argument being passed to MSVC
Fixes #4620

(cherry picked from commits 972b0f78b3
and c7292b1f3d)
2016-05-12 09:06:48 +02:00
f61f515872 Updated caret blink method documentation
(cherry picked from commit 997476777a)
2016-05-12 09:06:10 +02:00
c5e17d553e Bind caret blink to gdscript and properties
(cherry picked from commit dc90cba42e)
2016-05-12 09:05:46 +02:00
2bd6e2402b OS.get_screen_size now returns the correct value on OSX
(cherry picked from commit b697de92ef)
2016-05-12 09:05:32 +02:00
c575f31d5d Added possibility to strip left and right to strip_edges (#4594)
(cherry picked from commit 49c473bb36)
2016-05-12 09:04:59 +02:00
6d50ccfd32 Joystick demo script cleanup
Removes a leftover variable and uses constants instead of magic numbers.

(cherry picked from commit 86b46c0b7e)
2016-05-12 09:04:41 +02:00
bd51dea8f6 Added caret blink in text editor
(cherry picked from commit e03e7deb1b)
2016-05-12 09:04:03 +02:00
abc97d3bb4 Fixed autocomplete truncate, issue 4554
(cherry picked from commit accc2a195b)
2016-05-12 09:03:59 +02:00
a5e54b83ec Add ignore error flag to OpenSSL driver
(cherry picked from commit 2e44e255ed)
2016-05-12 09:00:39 +02:00
18782aec61 Fixed autocomlete strings not appearing for function arguments
(cherry picked from commit 9e6234201b)
2016-05-12 09:00:22 +02:00
f58cfaf585 fix percent decode utf8 error
(cherry picked from commit f86cffd8e6)
2016-05-12 08:59:30 +02:00
5d98718c28 Fixed animation player auto-queue duplication and undo/redo
(cherry picked from commit 488495852b)
2016-05-12 08:58:39 +02:00
7ab1c1ea3b Fixed code completion after opening bracket, issue 3977
(cherry picked from commit 0a2b341d0a)
2016-05-12 08:55:43 +02:00
f8debd8152 cloning env for builtin_openssl _and_ openssl :)
(cherry picked from commit baaa74f215)
2016-05-12 08:55:34 +02:00
ac06e3d4db clonning env for builtin ssl
(cherry picked from commit 62c17d65a8)
2016-05-12 08:55:28 +02:00
b6be2f503d Rotation APIs: Better exposure for degrees methods
Made public the various set/getters for rotations in degrees.
For consistency, renamed the exposed method names to remove the leading
underscore, and kept the old names with a deprecation warning.

Fixes #4511.

(cherry picked from commit 4eab767a6f)
2016-05-12 08:55:14 +02:00
b224407770 Partial documentation for OS methods
(cherry picked from commit ed7c0a6caf)
2016-05-06 11:14:59 +02:00
7556391d20 Fix build for Windows 64-bits with GCC
(cherry picked from commit 81297f0fa1)
2016-05-06 11:14:53 +02:00
23c659fc47 -make sure single select after multi select works better
-fixed some warnings for OSX

(cherry picked from commit f909634832)
2016-05-06 11:14:11 +02:00
4832731477 Fix memory leak
As pointed out by @sanikoyes in #4541.

(cherry picked from commit 5930408746)
2016-05-06 11:13:41 +02:00
19f08eaa5b Fix wrong return and argument types in documentation
(cherry picked from commit 1e752c0120)
2016-05-06 11:13:35 +02:00
975b4d2927 Add missing Vector2Array case to Variant::operator String()
- Correcly display Vector2Array default arguments in the documentation

(cherry picked from commit 2060e6616c)
2016-05-06 11:13:25 +02:00
913818a246 Fix ds3 gamepad mapping
(cherry picked from commit d6cd5108e3)
2016-05-06 11:12:44 +02:00
4a4999451b Changed barely visible PROPERTY_HINT_ALL_FLAGS buttons for checkboxes
(cherry picked from commit 723c0d730c)
2016-05-06 11:12:38 +02:00
4f57e532b8 Fix windows 64-bits build.
The change in `tools/doc/doc_data.cpp` is needed because the MSVC
compiler does not support variable length arrays.

Fix #4113

(cherry picked from commit 9424c6c58f)
2016-05-06 11:12:31 +02:00
3449c81bdb Fixes 64 bit MSVC builds, disables bits parameter
Also Enables automatic detection of architecture for the MSVC compilers.
Builds without assembly optimisations for x64
Closes issue #3098

Signed-off-by: Aleksandar Danilovic <greatgames.alexandar@gmail.com>
(cherry picked from commit 7762e1afe6)
2016-05-06 11:12:23 +02:00
05857a5472 Update OpenSSL to 1.0.2h
(cherry picked from commit ab623c923d)
2016-05-06 11:11:21 +02:00
ec3b50fd65 Autocomplete no longer shows duplicates, issue 1824
(cherry picked from commit 084d0bef96)
2016-05-06 11:11:14 +02:00
f95918e05a Input Documentation
Input Documentation

(cherry picked from commit f6ae5e41de)
2016-05-06 11:11:09 +02:00
b3404c8c44 Fixed behavior of OS.set_window_resizable
Should fix #4428.
 * Minimize button is not hidden anymore
(cherry picked from commit 8fb7280f39)
2016-05-06 11:10:57 +02:00
7e077258c5 Fixed documentation generator for polymorphic functions
(cherry picked from commit 57d0b78426)
2016-05-06 11:10:48 +02:00
fb3d10c579 Documented bool methods
(cherry picked from commit 3ca1d0f1d5)
2016-05-06 11:10:41 +02:00
0b75c39c2b Documented float
(cherry picked from commit 520e6f5b09)
2016-05-06 11:10:34 +02:00
e0a13981fc Documented int methods
(cherry picked from commit 4453284388)
2016-05-06 11:10:28 +02:00
bdbb831261 Finished AnimationPlayer Documentation
(cherry picked from commit abf5f8c586)
2016-05-06 11:09:51 +02:00
97e30f4cd7 Fix checking unsaved changes only in current scene
(cherry picked from commit 107e62be70)
2016-05-06 11:07:46 +02:00
78dc8e79c4 Documented YSort (#4515)
Documented YSort
(cherry picked from commit 957c265f11)
2016-05-06 11:07:25 +02:00
40681d90e5 Debugger: Fix breaked signal binding (#4508)
Closes #4270.
(cherry picked from commit 8ceab5ddaf)
2016-05-06 11:07:17 +02:00
fbb8a2170c Documented ColorRamp
(cherry picked from commit c2bdb3727b)
2016-05-06 11:07:03 +02:00
e8a972197c Partial documentation for Particles2D
(cherry picked from commit 3cd58fe0ba)
2016-05-06 11:06:56 +02:00
047767b824 Document Popup, PopupDialog, PopupMenu, and PopupPanel
(cherry picked from commit 5cdf4a6379)
2016-05-06 11:06:49 +02:00
ef2f1ae811 Tabs: Fix align issue with right/close buttons
The stylebox around the close button was badly centered.
There were also bad margins applied when using right buttons.

(cherry picked from commit 21c181bd3c)
2016-05-06 11:06:42 +02:00
7c419032c7 Tabs: cleanup code, no functional change
Some dead code removed, a few cosmetic changes.

(cherry picked from commit 8b32c80529)
2016-05-06 11:06:35 +02:00
9bdcc97e56 Tabs: Fix navigation buttons overlap when resizing
It was not taking into account the minimum width of the stylebox.
Fixed by factorizing some duplicate code.

(cherry picked from commit 8574489dd2)
2016-05-06 11:06:29 +02:00
7f80fce464 Tabs: Fix icon size not taken into account for offset
Fixes #4107.

(cherry picked from commit bbaf296948)
2016-05-06 11:06:22 +02:00
ea9b552e27 Variant: readd Dict.has_all
Erroneously removed in 4bc494ae2e.
2016-05-06 10:56:39 +02:00
21ab3a030e missing default value 2016-05-05 18:44:29 -03:00
a14ff27337 fix to avoid video texture scaling 2016-05-05 18:44:20 -03:00
d6e30256ad ability to shrink all images x2 on load
this is for extreme cases when running on devices with very low video
memory, so you can still retain compatibility.
2016-05-05 18:43:47 -03:00
4bc494ae2e export fix_alpha_edges 2016-05-05 18:42:55 -03:00
d49fff6246 FileDialog: reset mkdir label after use (#4500)
Closes #1686.
(cherry picked from commit ab7886ffc4)
2016-05-01 12:28:27 +02:00
d29087cc53 OSX: Fix lib suffix for Android lib (#4499)
Fixes #1452.
(cherry picked from commit 94274b9ab5)
2016-05-01 12:28:20 +02:00
27461a79dc GridMap: Fix backwards rotate hotkeys (#4498)
Fixes #1237
(cherry picked from commit 8259c46707)
2016-05-01 12:28:14 +02:00
a86cfc258e AnimationPlayer: Prevent resetting timeline when pinned (#4497)
Fixes #1019
(cherry picked from commit 0b4f277184)
2016-05-01 12:28:07 +02:00
26c2e0d09d math: Fix rounding error for 0 in Math::round (#4495)
Thus revert the previous workaround in commit b123bc4a2a.
Fixes #3221.
(cherry picked from commit 6883325f92)
2016-05-01 12:28:01 +02:00
0b49d78a3f Project manager: unescape project names (#4494)
Fixes #3609
(cherry picked from commit 78adbf4790)
2016-05-01 12:27:54 +02:00
40b546fb83 Allow any directory for custom character set and gradient image file when import font
fix #4486

(cherry picked from commit b172cb524d)
2016-05-01 12:27:43 +02:00
3c453b7bd2 Ignore invalid folders in platform
Fixes #4479

(cherry picked from commit f938793e78)
2016-05-01 12:27:14 +02:00
f033763700 Implement OS.get_process_ID for Windows
Based on code by @ratsdiov.
Closes #1733

(cherry picked from commit 2cd8e86aa0)
2016-05-01 12:27:04 +02:00
944ac2500a classref: Sync with source 2016-04-29 18:12:33 +02:00
b4adb0d338 Add more documentations for this classes:
* BoxContainer
* CenterContainer
* ScrollContainer
* SplitContainer
* Vector2
* StringArray
* FileDiloags

(cherry picked from commit a518792d89)
2016-04-29 18:06:09 +02:00
227604a566 Fix launching from .app on OSX
(cherry picked from commit 6962fd91c6)
2016-04-29 18:05:39 +02:00
70644301dd Allow dragging on only one (global) axis when holding down shift
Closes #1723

(cherry picked from commit d82ff4ed09)
2016-04-29 18:02:27 +02:00
4228505cf0 Shader editor now uses text editor settings
(cherry picked from commit 64751e0a75)
2016-04-29 18:02:19 +02:00
9086a929b2 Specify the demos license
It was already under the MIT as the rest of the engine,
but some users seemed not convinced about it.
(cherry picked from commit fa3240a8e9)
2016-04-29 18:02:10 +02:00
5365ae9212 Add more documentations and fix AcceptDialog::add_cancel
(cherry picked from commit 5c61e17c10)
2016-04-29 18:02:03 +02:00
a3fd381a4f Fill in the blank in the Array, CenterContainer and Dictionary class reference (#4476)
(cherry picked from commit 4de3f8944e)
2016-04-29 07:44:23 +02:00
d81ffaf2ab Documentation for Canvas Modulate, ColorPicker, ColorPickerButton
(cherry picked from commit faf21b81e8)
2016-04-29 07:43:43 +02:00
c77a5f910e Fixed shader editor syntax coloring
(cherry picked from commit bda5ea0871)
2016-04-29 07:43:30 +02:00
91461b588d Move export GUI debug toggle to export settings window
(cherry picked from commit ab4caa7953)
2016-04-29 07:43:23 +02:00
3a3f56689e More precise InputMap Axis descriptions in project settings.
Now it's "Left Stick {Up, Down, Left, Right}" instead of just "Left Stick" repeated 4x.

(cherry picked from commit 418049b741)
2016-04-29 07:43:16 +02:00
35e05b092c Partial documentation for Polygon2D and Raycast2D (#4467)
(cherry picked from commit 9f29b4b26a)
2016-04-29 07:43:09 +02:00
238bbb6539 Classref: Document Button and ButtonArray
Also bind relevant constants and define some object types and better
argument names for the docs.

(cherry picked from commit 3a4ec88b37)
2016-04-29 07:42:59 +02:00
946ef8d478 GridContainer, CheckBox documentation, descriptions for Vector2 and CenterContainer.set_use_top_left
(cherry picked from commit a5b4c1d64f)
2016-04-29 07:42:48 +02:00
d3ee8de754 fix - HTTPClient connection keep-alive duplicate Headers #4208
(cherry picked from commit 6ad226ac38)
2016-04-29 07:42:40 +02:00
517518ae9a Added scroll lines, issue 4243
(cherry picked from commit 54244e0e1d)
2016-04-29 07:42:08 +02:00
084ce221d7 NACL removal: fix leftover 2016-04-27 23:17:18 +02:00
e38666b76a fixed some mistakes in WeakRef documentation
(cherry picked from commit e301ca3544)
2016-04-27 20:19:52 +02:00
6f76eca883 Documented WeakRef and member functions
(cherry picked from commit edff81c214)
2016-04-27 20:19:46 +02:00
d183a5361f Documented Node2D
(cherry picked from commit 87aa128228)
2016-04-27 20:19:37 +02:00
11aa0d1405 Various improvements to doc_status.py
- Make comments opt-in (smaller table in width)
- Reduce length of Brief Description and Description (also smaller table as output)
- Make names cyan (blue is too dark on black terminal)
- Drop some redundant synonyms for the flags

(cherry picked from commit 034d6e811f)
2016-04-27 20:19:30 +02:00
6efe8818a7 Edited classes.xml : GraphEdit finished (#4450)
(cherry picked from commit 81e405545b)
2016-04-27 20:19:20 +02:00
9023a84a93 Remove last NACL references
(cherry picked from commit d3811b490d)
2016-04-27 20:19:12 +02:00
1bd2145e34 Drop NACL platform
It's no longer maintained and Chrome-specific, so it's not a viable solution
to deploy Godot games in browsers. The current prefered alternative is asm.js
(platform/javascript), and we're looking forward to WebAssembly.

(cherry picked from commit ec606f94dc)
2016-04-27 20:18:59 +02:00
382a8250ba Drop obsolete WIP for Flash platform
It was apparently never fully functional and has not been maintained.
Flash itself is nowadays clearly a deprecated technology, so there will
not be further work on it. platform/javascript and the upcoming
WebAssembly technologies should have a brighter future.

(cherry picked from commit f368d380e7)
2016-04-27 20:17:37 +02:00
73296a9a6d Trim trailing white space on save, issue 4383
(cherry picked from commit f3e6569e00)
2016-04-27 20:17:25 +02:00
93b1f60ca2 Encode axis_value in Variant for InputEvent::JOYSTICK_MOTION.
Fixes a bug that caused InputMap actions which have been set to joystick axes
not to work correctly on exported builds as the axis_value property wouldn't be serialized into engine.cfb.
See recent discussion in #49 (Post 121+)

(cherry picked from commit 9201b5a27c)
2016-04-27 20:17:13 +02:00
7f4387d21e Fix continious update with Camera2D
Closes #4406

(cherry picked from commit b2e0cedbf0)
2016-04-27 20:17:07 +02:00
c0748bad06 Add a python script to check the current doc status
(cherry picked from commit c9340cdcc6)
2016-04-27 20:17:00 +02:00
94b321822d add sign comparison for joystick axis events in InputMap::_find_event
fixes #4400

(cherry picked from commit 3b12f9ea82)
2016-04-27 20:16:51 +02:00
c523749662 Fix Camera2D ignoring zoom when checking limits
Closes #1912

(cherry picked from commit 7a8aea0be9)
2016-04-27 20:16:08 +02:00
0f47311610 Add fallback to legacy KeyboardEvent in web export
Fallback to KeyboardEvent property `charCode` is absence of both `key`
and `char` for retrieval of unicode value.

(cherry picked from commit 45b90f16ca)
2016-04-27 20:16:01 +02:00
4c358b7043 Add preview of the Camera2D's screen boundaries
Closes #3365

(cherry picked from commit e7f66a88d6)
2016-04-27 20:15:46 +02:00
98b30e3aff Reimplement key input events in Emscripten export
Scancodes work, but unicode values are now completely broken in some
browser/OS combinations.

(cherry picked from commit 0e9eefb7d4)
2016-04-27 19:42:31 +02:00
9f5c6cf950 remove unused resources and add korean locale for android
- remove unused resources in platform/android/java/res/values/strings.xml
- add korean language resource for apk expansion download screen

(cherry picked from commit e94e710893)
2016-04-27 19:42:22 +02:00
07fc330241 Fixed zero-length arrays in nrex. Fixes #4346
(cherry picked from commit 48b2dfab9f)
2016-04-27 08:50:36 +02:00
c712e54b63 tiny fix to loop restart (#4358)
Closes #4355
(cherry picked from commit e566b17f91)
2016-04-27 08:50:28 +02:00
6a2efc48c5 Fix 'Quit to Project Manager' not stopping the running application
(cherry picked from commit e48c07750f)
2016-04-27 08:50:09 +02:00
ff1d370b9f Fix File.get_csv_line not including quoted newlines in the output
Close #1232

(cherry picked from commit 7a18bb8ace)
2016-04-27 08:50:03 +02:00
e654184888 Always set default clear color
(cherry picked from commit 0ee8b74101)
2016-04-27 08:49:56 +02:00
cabb80ecf4 Add openssl=builtin to build command in .travis.yml
(cherry picked from commit 1db2759f5e)
2016-04-27 08:49:45 +02:00
3efa0f130d Update OpenSSL to version 1.0.2g
(cherry picked from commit e97922f220)
2016-04-27 08:49:39 +02:00
47c7b535d2 BoneAttachments now position themselves instantly during bind.
(cherry picked from commit bc5ee6c98f)
2016-04-27 08:49:30 +02:00
5fac497aa2 Fixed curve baking, now always start at origin point
(cherry picked from commit 08b93da28a)
2016-04-27 08:49:23 +02:00
4bfcd14a6a correct typo "overwrite"
(cherry picked from commit 86c6326057)
2016-04-27 08:48:43 +02:00
dbcf969fbf Keep editable instances data when replacing tree root node
(cherry picked from commit 3029f5ee02)
2016-04-27 08:48:34 +02:00
52bf4a76b2 x11: Flush the X output buffer after changing mouse mode
(cherry picked from commit 5907a007dc)
2016-04-27 08:48:23 +02:00
f32a4dc516 Made trackpad behaviour optional in 3D mode (issue #4265)
(cherry picked from commit 84d706cb35)
2016-04-27 08:44:40 +02:00
a0b6645858 Fixed #4163 (intersect_shape crashes on results limit)
(cherry picked from commit d239e6bc0e)
2016-04-27 08:44:31 +02:00
b24c3be564 Update OpenSSL to version 1.0.1s
(cherry picked from commit c860574d8b
and commit 2cbd850979)
2016-04-27 08:43:39 +02:00
b2b5c495e1 Subclasses can now extend from other subclasses contained in scripts derived from relative paths.
(cherry picked from commit d643a40f95)
2016-04-27 08:42:48 +02:00
e367c6cdd8 Fixed undo redo interaction with find replace
(cherry picked from commit 189b306722)
2016-04-27 08:42:23 +02:00
b5a438413a Setting to change line number color
(cherry picked from commit 8c328474f2)
2016-04-27 08:42:18 +02:00
f4ebba513a Updated nrex to v0.2
* Fixed capturing groups matching to invalid results
 * Fixed parents of recursive quantifiers not expanding properly
 * Fixed LookAhead sometimes adding to result

(cherry picked from commit 6207d56b95)
2016-04-27 08:42:12 +02:00
40d21117f9 Fix RayCast not updating when debugging collissions
(cherry picked from commit 6cf3bdcf76)
2016-04-27 08:42:01 +02:00
e120e2265b CanvasItemEditorPlugin: Avoid selecting items from instanced scenes
- This behaviour is only applied to click selection. Rect selection and List selection can still select these items

(cherry picked from commit fab57f2fbc)
2016-04-27 08:41:51 +02:00
8746966194 Doc: fix type of stream object
(cherry picked from commit 7820e590ea)
2016-04-27 08:40:49 +02:00
76eeb457d3 Fix warn print when hide an control does not inside_tree
(cherry picked from commit 5ec7d3f264)
2016-04-27 08:40:38 +02:00
02afea1e4e Fix crash when tween control object previous freed
(cherry picked from commit da28a2f062)
2016-04-27 08:40:19 +02:00
692878b7f4 Fix Ctrl+LaunchMedia showing up as a shortcut for "Make Bones"
Close #4044

(cherry picked from commit 4af1839073)
2016-04-27 08:38:28 +02:00
b7f5418f8d Ability to change the caret color
(cherry picked from commit c7519f091d)
2016-04-27 08:37:20 +02:00
d4d810faac dictionary has_all
(cherry picked from commit a8ebd43ab7)
2016-04-27 08:36:08 +02:00
3a390e9b44 Update vector.h
using non-templated neares_power_of_2
2016-04-11 03:34:10 -03:00
5d63f4e758 Sync classref with source 2016-04-07 21:30:22 +02:00
cbac9a2ca3 Remove duplicate
(cherry picked from commit 473de561f8)
2016-04-07 21:28:28 +02:00
837d50714a Version 2.0.2 2016-04-07 08:34:27 +02:00
bb6cfc130b Option to toggle syntax highlighting
(cherry picked from commit d78e98e2a4)
2016-04-06 19:39:36 +02:00
b3891246e5 Fixed block indent inconsistency, fixes issue 3803
(cherry picked from commit 93700676b5)
2016-04-06 19:39:30 +02:00
00566a8592 Revert "free Material 'shadow_material_double_sided' on ::finish()"
This reverts commit 43c74056b1.
2016-04-06 19:37:16 +02:00
63e33cfdd2 Add a sleeping_state_changed signal to RigidBody and RigidBody2D classes
Closes #3911

(cherry picked from commit 6dcd1354c2)
2016-04-06 18:49:51 +02:00
dea6671d58 Bind Z key (without modifiers) to toggle wireframe in 3D view
Fixed #4124

(cherry picked from commit 8ee8802cbe)
2016-04-06 18:49:26 +02:00
7c6d2e7062 Fixed text edit undo and redo operation interaction
(cherry picked from commit 646e089782)
2016-04-06 18:48:31 +02:00
eb927383f2 Fixes errors occurring when switching to a new scene with a spatial editor from a canvas editor.
(cherry picked from commit f303e3483d)
2016-04-06 18:48:25 +02:00
5c98674a8b Added rotation/panning support for trackpads in 3D mode #53
(cherry picked from commit 3ebde34d8f)
2016-04-06 18:48:05 +02:00
4bde902de1 Fixed 'complex' typo in method name
(cherry picked from commit 971c3be52d)
2016-04-06 18:47:34 +02:00
a5f07d18ec Fixed undoing twice when removing selection
(cherry picked from commit 15f43149e1)
2016-04-06 18:47:28 +02:00
71da9a1a23 Separate help pages from scripts by default
Fixes #4199
(cherry picked from commit 9c89d3e042)
2016-04-06 18:47:22 +02:00
44daccc861 Change toggle comment behaviour. Fixes #4198
(cherry picked from commit 1b6f14d810)
2016-04-06 18:47:18 +02:00
MSC
4220ffbd8e memdelete 'joy_thread' + 'joy_mutex' on ::~joystick_linux()
(cherry picked from commit 391095e0ef)
2016-04-06 18:46:53 +02:00
MSC
43c74056b1 free Material 'shadow_material_double_sided' on ::finish()
(cherry picked from commit 7a9998370f)
2016-04-06 18:46:46 +02:00
48438e4f3b Fixed insert mode interaction with auto complete
(cherry picked from commit a984adb5a6)
2016-04-06 18:46:36 +02:00
5f901e2b27 Fixed insert mode removing first unselected character
(cherry picked from commit fe779d4386)
2016-04-06 18:46:32 +02:00
22ef9673dd Added insert mode to text editor
(cherry picked from commit 2b57cb94da)
2016-04-06 18:45:56 +02:00
5b1aa3a5cd Progress bar minsize now checks percent_visible
Allows for really thin progress bars such as for pixel-art styles.

(cherry picked from commit 0bba09c4cb)
2016-04-06 18:45:33 +02:00
f06f574735 Fix building against 2.0 API
812de22 used a method from the new plugin API in master,
so it failed building.
2016-04-02 23:11:38 +02:00
aac3b9db5c Add support for gnu-libstc++-4.9 needed by recent NDK versions
The 4.9 version is the default one, people can still build using 4.8
with older NDK versions by setting the (optional) NDK_TARGET
and NDK_TARGET_X86 environment variables.

(cherry picked from commit a0fb5b5f95)
2016-04-02 23:05:18 +02:00
9fdc1279cc Make hardcoded Mac version 2.0.x
To avoid having to bump it up every time.
2016-04-02 22:22:38 +02:00
01471e4c09 Function syntax highlighting
(cherry picked from commit 50aa78210c)
2016-04-02 22:19:54 +02:00
bac8248316 Remove trailing spaces
(cherry picked from commit 0a5472e697)
2016-04-02 22:19:40 +02:00
69e67d51c7 Port 2D demos to TSCN/TRES formats
Part of #4196.

(cherry picked from commit 23cf6a85bd)
2016-04-02 22:19:30 +02:00
c6ccd05fed Fix last two bindings in input_mapping demo
Also connect the signal from script, as it makes it easier to understand
than by having to check the connected signals via the GUI.

(cherry picked from commit 4eb49cc732)
2016-04-02 22:15:58 +02:00
937a96b26b Option to toggle line numbers
(cherry picked from commit 474911c533)
2016-04-02 22:15:38 +02:00
a52b1e866d inherit PKG_CONFIG_PATH from environment
(cherry picked from commit 32391ffd73)
2016-04-02 22:15:32 +02:00
fed11a662a doc/base/classes.xml: String.match, Node.find_node
Clarify wildcard behavior.

(cherry picked from commit ef08fed277)
2016-04-02 22:15:20 +02:00
26f2b7415c Fixed numbers not highlighting after space
(cherry picked from commit cd07badee3)
2016-04-02 22:15:11 +02:00
729dc5da83 Stopped save scene flicker, issue 4118
(cherry picked from commit 9d74b76a69)
2016-04-02 22:15:06 +02:00
54625bb771 Fix GDScript crash when call show/hide in func _exit_tree
(cherry picked from commit 0c6f089ce4)
2016-04-02 22:14:49 +02:00
523625a3d1 Syntax highlighting for numbers
(cherry picked from commit c844c2d604)
2016-04-02 22:14:27 +02:00
5caf6ad8b9 Expose android/shutdown_adb_on_exit parameter and default to true
It was added in 30d0ca9 for the Steam build but only enabled
when parsing a ._sc_ file that would define it.
It is now available for all users to toggle, in and outside of Steam.

Fixes #4073.

(cherry picked from commit c584940387)
2016-04-02 22:14:20 +02:00
7ddc17b18e BoxContainer: Bind method add_spacer(bool)
(cherry picked from commit 0571f961a8)
2016-04-02 22:13:58 +02:00
cf0a586a3e TextEdit: Fix Shift+Delete shortcut not calling cut()
(cherry picked from commit abb720438f)
2016-04-02 22:13:26 +02:00
41cc4ffe98 Fixes #3942 - Throws an error when exporting for X11 with no filename
(cherry picked from commit fb58bafc54)
2016-04-02 22:13:14 +02:00
0ea354c12a Fix issues with tilemap covering child nodes and old quadrants
Closes #4070

(cherry picked from commit 2a581835ca)
2016-04-02 22:12:53 +02:00
2bc4049b9b Fix for #4014, changed to 2 instead of 3 chars to trigger search
(cherry picked from commit 4e59d1c51f)
2016-04-02 22:12:41 +02:00
64a8fe6ad7 Option to toggle tab drawing
(cherry picked from commit 0fc7be89d3)
2016-04-02 22:12:29 +02:00
05c620b7ad Add -r flag to adb install for keep app user data
(cherry picked from commit 9e026fecef)
2016-04-02 22:12:12 +02:00
ca1ca6c7df Fix cursor getting locked on tree control if tree is cleared while modifying numerical element.
(cherry picked from commit 44fe74bfc3)
2016-04-02 22:12:02 +02:00
1369b38d85 Fixed highlighting when word occurs as substring first
(cherry picked from commit 9c0e1524e5)
2016-04-02 22:11:37 +02:00
68b7f9d87a Fixed highliting with shift and mouse
(cherry picked from commit 4cc3fbeaff)
2016-04-02 22:11:30 +02:00
8a78112e5b Highlight all occurrences of selected word
(cherry picked from commit b0488cacf2)
2016-04-02 22:10:41 +02:00
41326781d2 Fix editors panels, of the bottom panel, not resizing in some cases
(cherry picked from commit 4a0f835ece)
2016-04-02 22:10:31 +02:00
cacf7d136f LineEdit/TextEdit: Add Shift+Delete shortcut for cut
(cherry picked from commit fac027cb14)
2016-04-02 22:10:20 +02:00
a701c6ff68 TextEdit: Fix inconsistent copy, cut and paste behaviour
(cherry picked from commit 4dfd0c1863)
2016-04-02 22:10:15 +02:00
812de22194 Fix file dialog, of Particles2D plugin, showing "Error" icons
(cherry picked from commit 8d2a957e36)
2016-04-02 22:09:33 +02:00
8de0405032 Automatically create input node when creating a ShaderGraph
(cherry picked from commit 5ee67ba498)
2016-04-02 22:09:26 +02:00
e59c0610ca Fix crash when importing sub-scenes
(cherry picked from commit cb7db2d430)
2016-04-02 22:09:01 +02:00
8fd4c78caf Added configuable tab size
(cherry picked from commit 9234bd3ff9)
2016-04-02 22:08:41 +02:00
85820434de Correct spot light size conversion in Blender exporter.
The collada falloff angle is the angle from the center of the spot
light projection, whereas Blender's point light size is the angle from
one side to the opposite, meaning it's twice as much.

(cherry picked from commit 1f4a214987)
2016-04-02 22:08:23 +02:00
d0151daa69 Undo and redo commands on text editor now affect internal version which fixes inconsistent file saving validation.
(cherry picked from commit b2e471fd7c)
2016-04-02 22:07:40 +02:00
763b29ed18 Remove redundant buttons
Now the Load button is alone on its line,
we probably need to find it a better place.

(cherry picked from commit d36333b648)
2016-04-02 22:06:37 +02:00
1d096471dc Add stop and delete buttons to sample library
Based on the work by @rdcklinux in #3339.
The play button becomes a stop button while playing.
A delete button is added in the last column.

(cherry picked from commit 533b9b7342)
2016-04-02 22:06:30 +02:00
7c44cbee67 Fix link error when disable_3d=yes
(cherry picked from commit a638af886e)
2016-04-02 22:05:49 +02:00
d950a13c10 TileSet Export: Avoid invalid error when merge is enabled but file does not exist
(cherry picked from commit 897b33ce77)
2016-04-02 22:05:36 +02:00
6ce273b329 Fix crash when resizing ConcavePolygonShape2D segments
(cherry picked from commit 3fc16d4025)
2016-04-02 22:04:41 +02:00
0635a639e9 TimeScale node: return +inf remaining for 0 scale.
(cherry picked from commit 65b7791263)
2016-04-02 22:04:35 +02:00
424a104666 remove trailing whitespace
(cherry picked from commit 4a4f247914)
2016-04-02 22:03:48 +02:00
830947feaf AnimationTreePlayer: distinguish value tracks.
If the node had a 3D Transform, the transform would always get written,
even if the tracks on that node were supposed to be value tracks.

(cherry picked from commit 2fa200ff53)
2016-04-02 22:00:40 +02:00
ee20365f7c Variant::blend: add Quat, fix Vector3.
(cherry picked from commit f7fad32188)
2016-04-02 22:00:18 +02:00
0a24f562fb Update version in Info.plist
Getting info on Godot.app still shows version 1.0.0.  Would be nice to have this reflect the real version number via the build system.
(cherry picked from commit 3d9e26bfce)
2016-04-02 21:59:49 +02:00
60e4cfbcb7 TimeScale node: scale return value (time remaining).
(cherry picked from commit 2e1b1234a3)
2016-04-02 21:59:07 +02:00
656aa0a501 fix InputMap::action_erase_event()
fixes #3976

(cherry picked from commit 9544042adb)
2016-04-02 21:58:26 +02:00
7ad50eaea8 This will disable png arm neon optimizing for android template if compile on windows, but make compiling successful.
And arm neon opt is enabled if not on windows.

(cherry picked from commit db89a47e28)
2016-04-02 21:58:09 +02:00
83887ae16d migrate to container-based Travis CI
(cherry picked from commit 1f83ae9b5a)
2016-04-02 21:57:38 +02:00
827f4a895a osx: fix inverted horizontal scrolling
(cherry picked from commit 02eddbf7da)
2016-04-02 21:57:26 +02:00
da356eca0f Enabled scrolling past end of file
(cherry picked from commit f19eea2f2d)
2016-04-02 21:57:10 +02:00
53aa9cd51a Release 2.0.1 2016-03-06 19:05:45 +01:00
706d576f7b Add support for patch versions (2.0.x) 2016-03-06 19:05:27 +01:00
226e0a7f4f Fix Project Settings dialog add/delete global variable
(cherry picked from commit 48524384d6)
2016-03-06 18:07:42 +01:00
c44060bb82 doc: fix joystick left/right trigger axis description (index 6/7 instead of 4/5)
(cherry picked from commit 1b806ef54e)
2016-03-06 18:06:47 +01:00
4fee5f3915 Add more verbose build-in functions descriptions
Add descriptions for some global constants

(cherry picked from commit ff7c89ebaf)
2016-03-06 10:39:21 +01:00
e69c9021b5 The help page now show the entire object hierarchy
(cherry picked from commit fdd1209276)
2016-03-06 09:48:26 +01:00
edb3716da7 Fix Sprite doesn't updating region_rect value in certain conditions
(cherry picked from commit 1d188c1c7b)
2016-03-06 09:48:20 +01:00
1bdd5d24cb Removed "__editor_plugin_screen__" metadata creation
(cherry picked from commit b79e83ad6f)
2016-03-06 09:48:15 +01:00
a1a1c0b9f6 Added search box in Class List dialog (Script Editor)
(cherry picked from commit cc6a6ef08c)
2016-03-06 09:48:06 +01:00
450a7a9120 Write GDScript documentation
(cherry picked from commit cd1184d56c)
2016-03-05 15:12:24 +01:00
c850fa7331 Added relative paths for DirAccess::remove()
Follows similar behaviour to DirAccess::rename()

(cherry picked from commit d7052ddba3)
2016-03-05 13:35:48 +01:00
afd75013f9 html5: workaround for echo key events.
(cherry picked from commit 352db6b17e)
2016-03-05 13:35:36 +01:00
848c7378fd Add editor settings for call hint placement
Added settings: text_editor/put_callhint_tooltip_below_current_line
and text_editor/callhint_tooltip_offset

(cherry picked from commit 47206b409d)
2016-03-05 12:58:01 +01:00
4b2fcabb74 Hide hint if completion is active
(cherry picked from commit 26cc14e839)
2016-03-05 12:57:56 +01:00
cb7693c533 Move the call hint under the current line
(cherry picked from commit 03025f60b6)
2016-03-05 12:57:52 +01:00
7fea990b1b set_time_scale docs
This is correct?

(cherry picked from commit 6b7ec5de69)
2016-03-05 12:56:27 +01:00
95e46e6eac fix gradle build on windows
(cherry picked from commit d6cc887627)
2016-03-05 12:56:19 +01:00
bea8e1654e AnimationTreePlayer (Blend3): process all inputs.
Always call _process_node on all three inputs so that looped animations
don't get out of sync.

(cherry picked from commit b79351aa45)
2016-03-05 12:55:54 +01:00
cafcdb015d AnimationTreePlayer: blend value tracks (closes #2299)
Variant:
- zero() sets a Variant to the appropriate type of zero value
- blend() blends part of one Variant on top of another.

(cherry picked from commit 391ce81c5e)
2016-03-05 12:55:43 +01:00
459b914d9c Quick fixes to tween documentation formatting
Maybe the reST parser should be improved instead though ;)

(cherry picked from commit a12c63ef9e)
2016-03-01 08:38:23 +01:00
9ed3d21d5a Sync classes 2016-03-01 08:25:04 +01:00
82d06b0027 use joystick name from mapping-db if available 2016-03-01 08:16:27 +01:00
e0a66b6e56 deleted files added accidentally
(cherry picked from commit 96b60c281f)
2016-02-29 09:03:31 +01:00
186b82c350 Document Tween class
(cherry picked from commit 49e1cc6fa9)
2016-02-29 09:03:06 +01:00
1af2e1101d Remove grey capsule on official logo
It had been added by a contributor without prior discussion
with the rest of the team, but the grey capsule did not look
so good. Closes #3848.

Also renamed godot_{icon,logo} to just {icon,logo}.

(cherry picked from commit eb5f9ed89b)
2016-02-29 09:01:02 +01:00
a55f41e3d9 screen_shaders: convert demo images to JPG
(cherry picked from commit a97c1ca8f9)
2016-02-29 09:00:55 +01:00
439e29ea95 normalmap demo: convert images to JPG
To make the demos lighter

(cherry picked from commit 2fd177b2a5)
2016-02-29 09:00:48 +01:00
f5e8e89f50 Remove Noto Sans font from translation demo (heavy!)
(cherry picked from commit 0f087755cc)
2016-02-29 09:00:43 +01:00
f619b05751 added [presets] to ._sc_ and "android/shutdown_adb_on_exit" to editor_settings
(cherry picked from commit 30d0ca9766)
2016-02-29 09:00:35 +01:00
aa94ff6dae fix transform localization event in mouse motion
(cherry picked from commit 08e0e64a19)
2016-02-29 09:00:14 +01:00
ee5c250b63 OUYA gamepad mappings fix
Fix gamepad mappings for OUYA revision 4
2016-02-27 15:28:34 +01:00
e4d367e7a1 theora on server build 2016-02-27 15:28:22 +01:00
45a0bbe56e adds -pm and -project_manager command line options to start project manager
fixes bug where the user has an engine.cfg on the executable directory so it runs the game instead of opening the project manager
2016-02-27 15:27:33 +01:00
d86b12a397 Fixed closing a scene tab when it was not the CURRENT tab. Fixes #3810 2016-02-27 15:27:25 +01:00
f0ba9c7e78 x11: fix joysticks not recognizing some buttons
dpad on x360 pads with kernel < 4.3 is working now
2016-02-27 15:27:15 +01:00
61f17fb1bb applied some typo fixes. see godotengine/godot-docs#18 2016-02-27 15:27:10 +01:00
a43af20f31 added more Android gamepad mappings 2016-02-27 15:26:59 +01:00
7ba92ae9eb Fix typo in error 2016-02-27 15:26:27 +01:00
b05c27a27f Fix allocation bug if compiled with modern clang or gcc
* Add overflow checked intrinsic abstractions that check on overflow.
* Use them for memory allocation code.
* Use size_t type for memory allocation code to support full platform dependent width.

Fixes #3756.
2016-02-27 15:26:18 +01:00
e30cbc3b36 added a couple more Linux mappings, tweaked Ouya Linux mapping 2016-02-27 15:25:51 +01:00
16044 changed files with 1560892 additions and 4928790 deletions

View File

@ -1,199 +0,0 @@
# Commented out parameters are those with the same value as base LLVM style.
# We can uncomment them if we want to change their value, or enforce the
# chosen value in case the base style changes (last sync: Clang 14.0).
---
### General config, applies to all languages ###
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
# AlignArrayOfStructures: None
# AlignConsecutiveMacros: None
# AlignConsecutiveAssignments: None
# AlignConsecutiveBitFields: None
# AlignConsecutiveDeclarations: None
# AlignEscapedNewlines: Right
AlignOperands: DontAlign
AlignTrailingComments: false
# AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortEnumsOnASingleLine: true
# AllowShortBlocksOnASingleLine: Never
# AllowShortCaseLabelsOnASingleLine: false
# AllowShortFunctionsOnASingleLine: All
# AllowShortLambdasOnASingleLine: All
# AllowShortIfStatementsOnASingleLine: Never
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
# AlwaysBreakBeforeMultilineStrings: false
# AlwaysBreakTemplateDeclarations: MultiLine
# AttributeMacros:
# - __capability
# BinPackArguments: true
# BinPackParameters: true
# BraceWrapping:
# AfterCaseLabel: false
# AfterClass: false
# AfterControlStatement: Never
# AfterEnum: false
# AfterFunction: false
# AfterNamespace: false
# AfterObjCDeclaration: false
# AfterStruct: false
# AfterUnion: false
# AfterExternBlock: false
# BeforeCatch: false
# BeforeElse: false
# BeforeLambdaBody: false
# BeforeWhile: false
# IndentBraces: false
# SplitEmptyFunction: true
# SplitEmptyRecord: true
# SplitEmptyNamespace: true
# BreakBeforeBinaryOperators: None
# BreakBeforeConceptDeclarations: true
# BreakBeforeBraces: Attach
# BreakBeforeInheritanceComma: false
# BreakInheritanceList: BeforeColon
# BreakBeforeTernaryOperators: true
# BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
# BreakStringLiterals: true
ColumnLimit: 0
# CommentPragmas: '^ IWYU pragma:'
# QualifierAlignment: Leave
# CompactNamespaces: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
# DeriveLineEnding: true
# DerivePointerAlignment: false
# DisableFormat: false
# EmptyLineAfterAccessModifier: Never
# EmptyLineBeforeAccessModifier: LogicalBlock
# ExperimentalAutoDetectBinPacking: false
# PackConstructorInitializers: BinPack
ConstructorInitializerAllOnOneLineOrOnePerLine: true
# AllowAllConstructorInitializersOnNextLine: true
# FixNamespaceComments: true
# ForEachMacros:
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
# IfMacros:
# - KJ_IF_MAYBE
# IncludeBlocks: Preserve
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '^<.*'
Priority: 3
# IncludeIsMainRegex: '(Test)?$'
# IncludeIsMainSourceRegex: ''
# IndentAccessModifiers: false
IndentCaseLabels: true
# IndentCaseBlocks: false
# IndentGotoLabels: true
# IndentPPDirectives: None
# IndentExternBlock: AfterExternBlock
# IndentRequires: false
IndentWidth: 4
# IndentWrappedFunctionNames: false
# InsertTrailingCommas: None
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
# LambdaBodyIndentation: Signature
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
# NamespaceIndentation: None
# PenaltyBreakAssignment: 2
# PenaltyBreakBeforeFirstCallParameter: 19
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 120
# PenaltyBreakOpenParenthesis: 0
# PenaltyBreakString: 1000
# PenaltyBreakTemplateDeclaration: 10
# PenaltyExcessCharacter: 1000000
# PenaltyReturnTypeOnItsOwnLine: 60
# PenaltyIndentedWhitespace: 0
# PointerAlignment: Right
# PPIndentWidth: -1
# ReferenceAlignment: Pointer
# ReflowComments: true
# RemoveBracesLLVM: false
# SeparateDefinitionBlocks: Leave
# ShortNamespaceLines: 1
# SortIncludes: CaseSensitive
# SortJavaStaticImport: Before
# SortUsingDeclarations: true
# SpaceAfterCStyleCast: false
# SpaceAfterLogicalNot: false
# SpaceAfterTemplateKeyword: true
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeCaseColon: false
# SpaceBeforeCpp11BracedList: false
# SpaceBeforeCtorInitializerColon: true
# SpaceBeforeInheritanceColon: true
# SpaceBeforeParens: ControlStatements
# SpaceBeforeParensOptions:
# AfterControlStatements: true
# AfterForeachMacros: true
# AfterFunctionDefinitionName: false
# AfterFunctionDeclarationName: false
# AfterIfMacros: true
# AfterOverloadedOperator: false
# BeforeNonEmptyParentheses: false
# SpaceAroundPointerQualifiers: Default
# SpaceBeforeRangeBasedForLoopColon: true
# SpaceInEmptyBlock: false
# SpaceInEmptyParentheses: false
# SpacesBeforeTrailingComments: 1
# SpacesInAngles: Never
# SpacesInConditionalStatement: false
# SpacesInContainerLiterals: true
# SpacesInCStyleCastParentheses: false
## Godot TODO: We'll want to use a min of 1, but we need to see how to fix
## our comment capitalization at the same time.
SpacesInLineCommentPrefix:
Minimum: 0
Maximum: -1
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
# SpaceBeforeSquareBrackets: false
# BitFieldColonSpacing: Both
# StatementAttributeLikeMacros:
# - Q_EMIT
# StatementMacros:
# - Q_UNUSED
# - QT_REQUIRE_VERSION
TabWidth: 4
# UseCRLF: false
UseTab: Always
# WhitespaceSensitiveMacros:
# - STRINGIZE
# - PP_STRINGIZE
# - BOOST_PP_STRINGIZE
# - NS_SWIFT_NAME
# - CF_SWIFT_NAME
---
### C++ specific config ###
Language: Cpp
Standard: c++17
---
### ObjC specific config ###
Language: ObjC
# ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
# ObjCBreakBeforeNestedBlockParam: true
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
---
### Java specific config ###
Language: Java
# BreakAfterJavaFieldAnnotations: false
JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax']
...

View File

@ -1,22 +0,0 @@
---
Checks: >-
-*,
cppcoreguidelines-pro-type-member-init,
modernize-redundant-void-arg,
modernize-use-bool-literals,
modernize-use-default-member-init,
modernize-use-nullptr,
readability-braces-around-statements,
readability-redundant-member-init
WarningsAsErrors: ''
HeaderFileExtensions: ['', h, hh, hpp, hxx, inc, glsl]
ImplementationFileExtensions: [c, cc, cpp, cxx, m, mm, java]
HeaderFilterRegex: (core|doc|drivers|editor|main|modules|platform|scene|servers|tests)/
FormatStyle: file
CheckOptions:
cppcoreguidelines-pro-type-member-init.IgnoreArrays: true
cppcoreguidelines-pro-type-member-init.UseAssignment: true
modernize-use-bool-literals.IgnoreMacros: false
modernize-use-default-member-init.IgnoreMacros: false
modernize-use-default-member-init.UseAssignment: true
...

View File

@ -4,23 +4,7 @@ root = true
charset = utf-8
end_of_line = lf
indent_style = tab
insert_final_newline = true
[*.{cpp,hpp,c,h,mm}]
trim_trailing_whitespace = true
[{*.gradle,AndroidManifest.xml}]
indent_style = space
indent_size = 4
[{*.py,SConstruct,SCsub}]
indent_style = space
indent_size = 4
# YAML requires indentation with spaces instead of tabs.
[*.{yml,yaml}]
[.travis.yml]
indent_style = space
indent_size = 2
[*.svg]
insert_final_newline = false

View File

@ -1,56 +0,0 @@
# This file contains a list of Git commit hashes that should be hidden from the
# regular Git history. Typically, this includes commits involving mass auto-formatting
# or other normalizations. Commit hashes *must* use the full 40-character notation.
# To apply the ignore list in your local Git client, you must run:
#
# git config blame.ignoreRevsFile .git-blame-ignore-revs
#
# This file is automatically used by GitHub.com's blame view.
# A Whole New World (clang-format edition)
5dbf1809c6e3e905b94b8764e99491e608122261
# Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a
# Style: clang-format: Disable AllowShortIfStatementsOnASingleLine
e956e80c1fa1cc8aefcb1533e5acf5cf3c8ffdd9
# One Copyright Update to rule them all
d95794ec8a7c362b06a9cf080e2554ef77adb667
# Update copyright statements to 2022
fe52458154c64fb1b741df4f7bd10106395f7cbd
# Update copyright statements to 2021
b5334d14f7a471f94bcbd64d5bae2ad853d0b7f1
# Update copyright statements to 2020
a7f49ac9a107820a62677ee3fb49d38982a25165
# Update copyright statements to 2019
b16c309f82c77d606472c3c721a1857e323a09e7
# Update copyright statements to 2018
b50a9114b105dafafdda8248a38653bca314a6f3
# Welcome in 2017, dear changelog reader!
c7bc44d5ad9aae4902280012f7654e2318cd910e
# Update copyright to 2016 in headers
5be9ff7b6715a661e85f99b108f96340de7ef435
# Updated copyright year in all headers
fdaa2920eb21fff3320a17e9239e04dfadecdb00
# Add missing copyright headers and fix formatting
e4213e66b2dd8f5a87d8cf5015ac83ba3143279d
# Use HTTPS URL for Godot's website in the headers
bd282ff43f23fe845f29a3e25c8efc01bd65ffb0
# Add "Godot Engine contributors" copyright line
df61dc4b2bd54a5a40c515493c76f5a458e5b541
# Enforce template syntax `typename` over `class`
9903e6779b70fc03aae70a37b9cf053f4f355b91

27
.gitattributes vendored
View File

@ -1,23 +1,4 @@
# Properly detect languages on Github
*.h linguist-language=cpp
*.inc linguist-language=cpp
thirdparty/* linguist-vendored
# Normalize EOL for all files that Git considers text files
* text=auto eol=lf
# Except for Windows-only / Visual Studio files
*.bat eol=crlf
*.sln eol=crlf
*.csproj eol=crlf
misc/msvs/*.template eol=crlf
# And some test files where the EOL matters
*.test.txt -text
# The above only works properly for Git 2.10+, so for older versions
# we need to manually list the binary files we don't want modified.
*.icns binary
*.ico binary
*.jar binary
*.png binary
*.ttf binary
*.tza binary
*.cpp eol=lf
*.h eol=lf
*.py eol=lf
*.hpp eol=lf

183
.github/CODEOWNERS vendored
View File

@ -1,183 +0,0 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.
# Owners can be @users, @org/teams or emails
# Buildsystem
.* @godotengine/buildsystem
.github/ @godotengine/buildsystem
*.py @godotengine/buildsystem
SConstruct @godotengine/buildsystem
SCsub @godotengine/buildsystem
# Core
/core/ @godotengine/core
/core/crypto/ @godotengine/network
/core/debugger/ @godotengine/debugger
/core/extension/ @godotengine/gdextension
/core/input/ @godotengine/input
# Doc
/doc/ @godotengine/documentation
doc_classes/* @godotengine/documentation
# Drivers
## Audio
/drivers/alsa/ @godotengine/audio
/drivers/alsamidi/ @godotengine/audio
/drivers/coreaudio/ @godotengine/audio
/drivers/coremidi/ @godotengine/audio
/drivers/pulseaudio/ @godotengine/audio
/drivers/wasapi/ @godotengine/audio
/drivers/winmidi/ @godotengine/audio
/drivers/xaudio2/ @godotengine/audio
## Rendering
/drivers/d3d12/ @godotengine/rendering
/drivers/dummy/ @godotengine/rendering
/drivers/gles3/ @godotengine/rendering
/drivers/spirv-reflect/ @godotengine/rendering
/drivers/vulkan/ @godotengine/rendering
## OS
/drivers/unix/ @godotengine/_platforms
/drivers/windows/ @godotengine/windows
## Misc
/drivers/png/ @godotengine/import
# Editor
/editor/*debugger* @godotengine/debugger
/editor/gui/ @godotengine/usability @godotengine/gui-nodes
/editor/icons/ @godotengine/usability
/editor/import/ @godotengine/import
/editor/plugins/*2d_*.* @godotengine/2d-editor
/editor/plugins/*3d_*.* @godotengine/3d-editor
/editor/plugins/script_*.* @godotengine/script-editor
/editor/plugins/*shader*.* @godotengine/shaders
/editor/themes/ @godotengine/usability @godotengine/gui-nodes
/editor/code_editor.* @godotengine/script-editor
/editor/*dock*.* @godotengine/docks
/editor/*shader*.* @godotengine/shaders
# Main
/main/ @godotengine/core
# Misc
/misc/ @godotengine/buildsystem
/misc/extension_api_validation/ @godotengine/gdextension @godotengine/dotnet
# Modules
## Audio (+ video)
/modules/minimp3/ @godotengine/audio
/modules/ogg/ @godotengine/audio
/modules/opus/ @godotengine/audio
/modules/theora/ @godotengine/audio
/modules/vorbis/ @godotengine/audio
/modules/webm/ @godotengine/audio
## Import
/modules/basis_universal/ @godotengine/import
/modules/bmp/ @godotengine/import
/modules/cvtt/ @godotengine/import
/modules/dds/ @godotengine/import
/modules/etc/ @godotengine/import
/modules/fbx/ @godotengine/import
/modules/gltf/ @godotengine/import
/modules/hdr/ @godotengine/import
/modules/jpg/ @godotengine/import
/modules/pvr/ @godotengine/import
/modules/squish/ @godotengine/import
/modules/svg/ @godotengine/import
/modules/tga/ @godotengine/import
/modules/tinyexr/ @godotengine/import
/modules/webp/ @godotengine/import
## Network
/modules/enet/ @godotengine/network
/modules/mbedtls/ @godotengine/network
/modules/upnp/ @godotengine/network
/modules/webrtc/ @godotengine/network
/modules/websocket/ @godotengine/network
## Rendering
/modules/denoise/ @godotengine/rendering
/modules/glslang/ @godotengine/rendering
/modules/lightmapper_rd/ @godotengine/rendering
/modules/meshoptimizer/ @godotengine/rendering
/modules/vhacd/ @godotengine/rendering
/modules/xatlas_unwrap/ @godotengine/rendering
## Scripting
/modules/gdscript/ @godotengine/gdscript
/modules/jsonrpc/ @godotengine/gdscript
/modules/mono/ @godotengine/dotnet
## Text
/modules/freetype/ @godotengine/buildsystem
/modules/text_server_adv/ @godotengine/gui-nodes
/modules/text_server_fb/ @godotengine/gui-nodes
## XR
/modules/camera/ @godotengine/xr
/modules/gdextension/xr/ @godotengine/xr
/modules/mobile_vr/ @godotengine/xr
/modules/webxr/ @godotengine/xr
## Misc
/modules/bullet/ @godotengine/physics
/modules/csg/ @godotengine/3d-nodes
/modules/gdnavigation/ @godotengine/navigation
/modules/gridmap/ @godotengine/3d-nodes
/modules/opensimplex/ @godotengine/3d-nodes
/modules/regex/ @godotengine/core
# Platform
/platform/android/ @godotengine/android
/platform/ios/ @godotengine/ios
/platform/linuxbsd/ @godotengine/linux-bsd
/platform/macos/ @godotengine/macos
/platform/web/ @godotengine/web
/platform/windows/ @godotengine/windows
# Scene
/scene/2d/ @godotengine/2d-nodes
/scene/3d/ @godotengine/3d-nodes
/scene/animation/ @godotengine/animation
/scene/audio/ @godotengine/audio
/scene/debugger/ @godotengine/debugger
/scene/gui/ @godotengine/gui-nodes
/scene/main/ @godotengine/core
/scene/resources/font.* @godotengine/gui-nodes
/scene/resources/text_line.* @godotengine/gui-nodes
/scene/resources/text_paragraph.* @godotengine/gui-nodes
/scene/resources/visual_shader*.* @godotengine/shaders
/scene/theme/ @godotengine/gui-nodes
# Servers
/servers/audio* @godotengine/audio
/servers/camera* @godotengine/xr
/servers/display_server.* @godotengine/_platforms
/servers/navigation_server*.* @godotengine/navigation
/servers/physics* @godotengine/physics
/servers/rendering* @godotengine/rendering
/servers/text_server.* @godotengine/gui-nodes
/servers/xr* @godotengine/xr
# Tests
/tests/ @godotengine/tests
# Thirdparty
/thirdparty/ @godotengine/buildsystem

View File

@ -1,72 +0,0 @@
name: Bug report
description: Report a bug in Godot
body:
- type: markdown
attributes:
value: |
When reporting bugs, please follow the guidelines in this template. This helps identify the problem precisely and thus enables contributors to fix it faster.
- Write a descriptive issue title above.
- The golden rule is to **always open *one* issue for *one* bug**. If you notice several bugs and want to report them, make sure to create one new issue for each of them.
- Search [open](https://github.com/godotengine/godot/issues) and [closed](https://github.com/godotengine/godot/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported. If you don't find a relevant match or if you're unsure, don't hesitate to **open a new issue**. The bugsquad will handle it from there if it's a duplicate.
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/latest/about/release_policy.html). Please always check if your issue is reproducible in the latest version it may already have been fixed!
- If you use a custom build, please test if your issue is reproducible in official builds too. Likewise if you use any C++ modules, GDExtensions, or editor plugins, you should check if the bug is reproducible in a project without these.
- type: textarea
attributes:
label: Tested versions
description: |
To properly fix a bug, we need to identify if the bug was recently introduced in the engine, or if it was always present.
- Please specify the Godot version you found the issue in, including the **Git commit hash** if using a development or non-official build. The exact Godot version (including the commit hash) can be copied by clicking the version shown in the editor (bottom bar) or in the project manager (top bar).
- If you can, **please test earlier Godot versions** (previous stable branch, and development snapshots of the current feature release) and, if applicable, newer versions (development snapshots for the next feature release). Mention whether the bug is reproducible or not in the versions you tested. You can find all Godot releases in our [download archive](https://godotengine.org/download/archive/).
- The aim is for us to identify whether a bug is a **regression**, i.e. an issue that didn't exist in a previous version, but was introduced later on, breaking existing functionality. For example, if a bug is reproducible in 4.2.stable but not in 4.1.stable, we would like you to test intermediate 4.2 dev and beta snapshots to find which snapshot is the first one where the issue can be reproduced.
placeholder: |
- Reproducible in: 4.3.dev [d76c1d0e5], 4.2.stable, 4.2.dev5 and later 4.2 snapshots.
- Not reproducible in: 4.1.3.stable, 4.2.dev4 and earlier 4.2 snapshots.
validations:
required: true
- type: input
attributes:
label: System information
description: |
- Specify the OS version, and when relevant hardware information.
- For issues that are likely OS-specific and/or graphics-related, please specify the CPU model and architecture.
- For graphics-related issues, specify the GPU model, driver version, and the rendering backend (GLES2, GLES3, Vulkan).
- **Bug reports not including the required information may be closed at the maintainers' discretion.** If in doubt, always include all the requested information; it's better to include too much information than not enough information.
- **Starting from Godot 4.1, you can copy this information to your clipboard by using *Help > Copy System Info* at the top of the editor window.**
placeholder: Windows 10 - Godot v4.0.3.stable - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 970 (nvidia, 510.85.02) - Intel Core i7-10700KF CPU @ 3.80GHz (16 Threads)
validations:
required: true
- type: textarea
attributes:
label: Issue description
description: |
Describe your issue briefly. What doesn't work, and how do you expect it to work instead?
You can include images or videos with drag and drop, and format code blocks or logs with <code>\`\`\`</code> tags, on separate lines before and after the text. (Use <code>\`\`\`gdscript</code> to add GDScript syntax highlighting.)
Please do not add code examples or error messages as screenshots, but as text, this helps searching for issues and testing the code. If you are reporting a bug in the editor interface, like the script editor, please provide both a screenshot *and* the text of the code to help with testing.
validations:
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: |
List of steps or sample code that reproduces the issue. Having reproducible issues is a prerequisite for contributors to be able to solve them.
If you include a minimal reproduction project below, you can detail how to use it here.
validations:
required: true
- type: textarea
attributes:
label: Minimal reproduction project (MRP)
description: |
- A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the `.godot` folder in the archive (but keep `project.godot`).
- Having an MRP is very important for contributors to be able to reproduce the bug in the same way that you are experiencing it. When testing a potential fix for the issue, contributors will use the MRP to validate that the fix is working as intended.
- If the reproduction steps are not project dependent (e.g. the bug is visible in a brand new project), you can write "N/A" in the field.
- Drag and drop a ZIP archive to upload it (max 10 MB). **Do not select another field until the project is done uploading.**
- **Note for C# users:** If your issue is *not* C#-specific, please upload a minimal reproduction project written in GDScript. This will make it easier for contributors to reproduce the issue locally as not everyone has a .NET setup available.
validations:
required: true

View File

@ -1,14 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: Godot proposals
url: https://github.com/godotengine/godot-proposals
about: Please submit feature proposals on the Godot proposals repository, not here.
- name: Godot documentation repository
url: https://github.com/godotengine/godot-docs
about: Please report issues with documentation on the Godot documentation repository, not here.
- name: Godot community channels
url: https://godotengine.org/community
about: Please ask for technical support on one of the other community channels, not here.

View File

@ -1,8 +0,0 @@
<!--
Please target the `master` branch in priority.
Relevant fixes are cherry-picked for stable branches as needed by maintainers.
To speed up the contribution process and avoid CI errors, please set up pre-commit hooks locally:
https://docs.godotengine.org/en/latest/contributing/development/code_style_guidelines.html
-->

View File

@ -1,18 +0,0 @@
name: Download Godot artifact
description: Download the Godot artifact.
inputs:
name:
description: The artifact name.
default: "${{ github.job }}"
path:
description: The path to download and extract to.
required: true
default: "./"
runs:
using: "composite"
steps:
- name: Download Godot Artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}

View File

@ -1,23 +0,0 @@
name: Dump Godot API
description: Dump Godot API for GDExtension
inputs:
bin:
description: The path to the Godot executable
required: true
runs:
using: "composite"
steps:
# Dump GDExtension interface and API
- name: Dump GDExtension interface and API for godot-cpp build
shell: sh
run: |
${{ inputs.bin }} --headless --dump-gdextension-interface --dump-extension-api
mkdir godot-api
cp -f gdextension_interface.h godot-api/
cp -f extension_api.json godot-api/
- name: Upload API dump
uses: ./.github/actions/upload-artifact
with:
name: 'godot-api-dump'
path: './godot-api/*'

View File

@ -1,48 +0,0 @@
name: Build Godot
description: Build Godot with the provided options.
inputs:
target:
description: Build target (editor, template_release, template_debug).
default: "editor"
tests:
description: Unit tests.
default: false
platform:
description: Target platform.
required: false
sconsflags:
default: ""
scons-cache:
description: The SCons cache path.
default: "${{ github.workspace }}/.scons-cache/"
scons-cache-limit:
description: The SCons cache size limit.
# actions/cache has 10 GiB limit, and GitHub runners have a 14 GiB disk.
# Limit to 7 GiB to avoid having the extracted cache fill the disk.
default: 7168
runs:
using: "composite"
steps:
- name: Scons Build
shell: sh
env:
SCONSFLAGS: ${{ inputs.sconsflags }}
SCONS_CACHE: ${{ inputs.scons-cache }}
SCONS_CACHE_LIMIT: ${{ inputs.scons-cache-limit }}
run: |
echo "Building with flags:" platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }}
if [ "${{ inputs.target }}" != "editor" ]; then
# Ensure we don't include editor code in export template builds.
rm -rf editor
fi
if [ "${{ github.event.number }}" != "" ]; then
# Set build identifier with pull request number if available. This is displayed throughout the editor.
export BUILD_NAME="gh-${{ github.event.number }}"
else
export BUILD_NAME="gh"
fi
scons platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }}
ls -l bin/

View File

@ -1,34 +0,0 @@
name: Restore Godot build cache
description: Restore Godot build cache.
inputs:
cache-name:
description: The cache base name (job name by default).
default: "${{github.job}}"
scons-cache:
description: The SCons cache path.
default: "${{github.workspace}}/.scons-cache/"
runs:
using: "composite"
steps:
- name: Restore SCons cache directory
uses: actions/cache/restore@v4
with:
path: ${{inputs.scons-cache}}
key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
# We try to match an existing cache to restore from it. Each potential key is checked against
# all existing caches as a prefix. E.g. 'linux-template-minimal' would match any cache that
# starts with "linux-template-minimal", such as "linux-template-minimal-master-refs/heads/master-6588a4a29af1621086feac0117d5d4d37af957fd".
#
# We check these prefixes in this order:
#
# 1. The exact match, including the base branch, the commit reference, and the SHA hash of the commit.
# 2. A partial match for the same base branch and the same commit reference.
# 3. A partial match for the same base branch and the base branch commit reference.
# 4. A partial match for the same base branch only (not ideal, matches any PR with the same base branch).
restore-keys: |
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-refs/heads/${{env.GODOT_BASE_BRANCH}}
${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}

View File

@ -1,17 +0,0 @@
name: Save Godot build cache
description: Save Godot build cache.
inputs:
cache-name:
description: The cache base name (job name by default).
default: "${{github.job}}"
scons-cache:
description: The SCons cache path.
default: "${{github.workspace}}/.scons-cache/"
runs:
using: "composite"
steps:
- name: Save SCons cache directory
uses: actions/cache/save@v4
with:
path: ${{inputs.scons-cache}}
key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}

View File

@ -1,18 +0,0 @@
name: Test Godot project converter
description: Test the Godot project converter.
inputs:
bin:
description: The path to the Godot executable
required: true
runs:
using: "composite"
steps:
- name: Test 3-to-4 conversion
shell: sh
run: |
mkdir converter_test
cd converter_test
touch project.godot
../${{ inputs.bin }} --headless --validate-conversion-3to4
cd ..
rm converter_test -rf

View File

@ -1,30 +0,0 @@
name: Setup Python and SCons
description: Setup Python, install the pip version of SCons.
inputs:
python-version:
description: The Python version to use.
default: "3.x"
python-arch:
description: The Python architecture.
default: "x64"
scons-version:
description: The SCons version to use.
default: "4.8.0"
runs:
using: "composite"
steps:
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version.
python-version: ${{ inputs.python-version }}
# Optional - x64 or x86 architecture, defaults to x64.
architecture: ${{ inputs.python-arch }}
- name: Setup SCons
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -m pip install wheel
python -m pip install scons==${{ inputs.scons-version }}
scons --version

View File

@ -1,37 +0,0 @@
name: Test Godot project
description: Run the test Godot project.
inputs:
bin:
description: The path to the Godot executable
required: true
runs:
using: "composite"
steps:
# Download and extract zip archive with project, folder is renamed to be able to easy change used project
- name: Download test project
shell: sh
run: |
wget https://github.com/godotengine/regression-test-project/archive/4.0.zip
unzip 4.0.zip
mv "regression-test-project-4.0" "test_project"
# Editor is quite complicated piece of software, so it is easy to introduce bug here.
- name: Open and close editor (Vulkan)
shell: sh
run: |
xvfb-run ${{ inputs.bin }} --audio-driver Dummy --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true
misc/scripts/check_ci_log.py sanitizers_log.txt
- name: Open and close editor (GLES3)
shell: sh
run: |
DRI_PRIME=0 xvfb-run ${{ inputs.bin }} --audio-driver Dummy --rendering-driver opengl3 --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true
misc/scripts/check_ci_log.py sanitizers_log.txt
# Run test project
- name: Run project
shell: sh
run: |
xvfb-run ${{ inputs.bin }} 40 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true
misc/scripts/check_ci_log.py sanitizers_log.txt

View File

@ -1,20 +0,0 @@
name: Upload Godot artifact
description: Upload the Godot artifact.
inputs:
name:
description: The artifact name.
default: "${{ github.job }}"
path:
description: The path to upload.
required: true
default: "bin/*"
runs:
using: "composite"
steps:
- name: Upload Godot Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}
# Default is 90 days.
retention-days: 60

View File

@ -1,94 +0,0 @@
name: 🤖 Android Builds
on:
workflow_call:
# Global Settings
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes debug_symbols=no module_text_server_fb_enabled=yes
concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-android
cancel-in-progress: true
jobs:
build-android:
runs-on: "ubuntu-20.04"
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Editor (target=editor)
cache-name: android-editor
target: editor
tests: false
sconsflags: arch=arm64 production=yes
- name: Template arm32 (target=template_release, arch=arm32)
cache-name: android-template-arm32
target: template_release
tests: false
sconsflags: arch=arm32
- name: Template arm64 (target=template_release, arch=arm64)
cache-name: android-template-arm64
target: template_release
tests: false
sconsflags: arch=arm64
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Restore Godot build cache
uses: ./.github/actions/godot-cache-restore
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Setup Python and SCons
uses: ./.github/actions/godot-deps
- name: Compilation
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
platform: android
target: ${{ matrix.target }}
tests: ${{ matrix.tests }}
- name: Save Godot build cache
uses: ./.github/actions/godot-cache-save
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Generate Godot templates
if: matrix.target == 'template_release'
run: |
cd platform/android/java
./gradlew generateGodotTemplates
cd ../../..
ls -l bin/
- name: Generate Godot editor
if: matrix.target == 'editor'
run: |
cd platform/android/java
./gradlew generateGodotEditor
cd ../../..
ls -l bin/android_editor_builds/
- name: Upload artifact
uses: ./.github/actions/upload-artifact
with:
name: ${{ matrix.cache-name }}

View File

@ -1,58 +0,0 @@
name: 🪲 Godot CPP
on:
workflow_call:
# Global Settings
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
# Used for the godot-cpp checkout.
GODOT_CPP_BRANCH: '4.2'
concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-cpp-tests
cancel-in-progress: true
jobs:
godot-cpp-tests:
runs-on: "ubuntu-20.04"
name: "Build and test Godot CPP"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python and SCons
uses: ./.github/actions/godot-deps
# Checkout godot-cpp
- name: Checkout godot-cpp
uses: actions/checkout@v4
with:
repository: godotengine/godot-cpp
ref: ${{ env.GODOT_CPP_BRANCH }}
submodules: 'recursive'
path: 'godot-cpp'
# Download generated API dump
- name: Download GDExtension interface and API dump
uses: ./.github/actions/download-artifact
with:
name: 'godot-api-dump'
path: './godot-api'
# Extract and override existing files with generated files
- name: Extract GDExtension interface and API dump
run: |
cp -f godot-api/gdextension_interface.h godot-cpp/gdextension/
cp -f godot-api/extension_api.json godot-cpp/gdextension/
# TODO: Add caching to the SCons build and store it for CI via the godot-cache
# action.
# Build godot-cpp test extension
- name: Build godot-cpp test extension
run: |
cd godot-cpp/test
scons target=template_debug dev_build=yes
cd ../..

View File

@ -1,45 +0,0 @@
name: 🍏 iOS Builds
on:
workflow_call:
# Global Settings
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes debug_symbols=no module_text_server_fb_enabled=yes
concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-ios
cancel-in-progress: true
jobs:
ios-template:
runs-on: "macos-latest"
name: Template (target=template_release)
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Restore Godot build cache
uses: ./.github/actions/godot-cache-restore
continue-on-error: true
- name: Setup Python and SCons
uses: ./.github/actions/godot-deps
- name: Compilation (arm64)
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }}
platform: ios
target: template_release
tests: false
- name: Save Godot build cache
uses: ./.github/actions/godot-cache-save
continue-on-error: true
- name: Upload artifact
uses: ./.github/actions/upload-artifact

View File

@ -1,218 +0,0 @@
name: 🐧 Linux Builds
on:
workflow_call:
# Global Settings
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
TSAN_OPTIONS: suppressions=misc/error_suppressions/tsan.txt
concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-linux
cancel-in-progress: true
jobs:
build-linux:
runs-on: "ubuntu-20.04"
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Editor w/ Mono (target=editor)
cache-name: linux-editor-mono
target: editor
sconsflags: module_mono_enabled=yes
bin: "./bin/godot.linuxbsd.editor.x86_64.mono"
build-mono: true
tests: false # Disabled due freeze caused by mix Mono build and CI
doc-test: true
proj-conv: true
api-compat: true
artifact: true
- name: Editor with doubles and GCC sanitizers (target=editor, tests=yes, dev_build=yes, scu_build=yes, precision=double, use_asan=yes, use_ubsan=yes, linker=gold)
cache-name: linux-editor-double-sanitizers
target: editor
# Debug symbols disabled as they're huge on this build and we hit the 14 GB limit for runners.
sconsflags: dev_build=yes scu_build=yes debug_symbols=no precision=double use_asan=yes use_ubsan=yes linker=gold
bin: "./bin/godot.linuxbsd.editor.dev.double.x86_64.san"
build-mono: false
tests: true
proj-test: true
# Generate an API dump for godot-cpp tests.
api-dump: true
# Skip 2GiB artifact speeding up action.
artifact: false
- name: Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)
cache-name: linux-editor-llvm-sanitizers
target: editor
sconsflags: dev_build=yes use_asan=yes use_ubsan=yes use_llvm=yes linker=lld
bin: "./bin/godot.linuxbsd.editor.dev.x86_64.llvm.san"
build-mono: false
tests: true
# Skip 2GiB artifact speeding up action.
artifact: false
# Test our oldest supported SCons/Python versions on one arbitrary editor build.
legacy-scons: true
- name: Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)
cache-name: linux-editor-thread-sanitizer
target: editor
tests: true
sconsflags: dev_build=yes use_tsan=yes use_llvm=yes linker=lld
bin: "./bin/godot.linuxbsd.editor.dev.x86_64.llvm.san"
build-mono: false
# Skip 2GiB artifact speeding up action.
artifact: false
- name: Template w/ Mono (target=template_release)
cache-name: linux-template-mono
target: template_release
sconsflags: module_mono_enabled=yes tests=yes
bin: "./bin/godot.linuxbsd.template_release.x86_64.mono"
build-mono: false
tests: true
artifact: true
- name: Minimal template (target=template_release, everything disabled)
cache-name: linux-template-minimal
target: template_release
sconsflags: modules_enabled_by_default=no disable_3d=yes disable_advanced_gui=yes deprecated=no minizip=no tests=yes
bin: "./bin/godot.linuxbsd.template_release.x86_64"
tests: true
artifact: true
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# Need newer mesa for lavapipe to work properly.
- name: Linux dependencies for tests
if: ${{ matrix.proj-test }}
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EB8B81E14DA65431D7504EA8F63F0F2B90935439
sudo add-apt-repository "deb https://ppa.launchpadcontent.net/kisak/turtle/ubuntu focal main"
sudo apt-get install -qq mesa-vulkan-drivers
# TODO: Figure out somehow how to embed this one.
- name: wayland-scanner dependency
run: |
sudo apt-get install libwayland-bin
- name: Free disk space on runner
run: |
echo "Disk usage before:" && df -h
sudo rm -rf /usr/local/lib/android
echo "Disk usage after:" && df -h
- name: Restore Godot build cache
uses: ./.github/actions/godot-cache-restore
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Setup Python and SCons
if: ${{ ! matrix.legacy-scons }}
uses: ./.github/actions/godot-deps
- name: Setup Python and SCons (legacy versions)
if: ${{ matrix.legacy-scons }}
uses: ./.github/actions/godot-deps
with:
# Sync with Ensure*Version in SConstruct.
python-version: 3.6
scons-version: 3.1.2
- name: Setup GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master
- name: Compilation
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
platform: linuxbsd
target: ${{ matrix.target }}
tests: ${{ matrix.tests }}
- name: Save Godot build cache
uses: ./.github/actions/godot-cache-save
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Generate C# glue
if: ${{ matrix.build-mono }}
run: |
${{ matrix.bin }} --headless --generate-mono-glue ./modules/mono/glue
- name: Build .NET solutions
if: ${{ matrix.build-mono }}
run: |
./modules/mono/build_scripts/build_assemblies.py --godot-output-dir=./bin --godot-platform=linuxbsd
- name: Prepare artifact
if: ${{ matrix.artifact }}
run: |
strip bin/godot.*
chmod +x bin/godot.*
- name: Upload artifact
uses: ./.github/actions/upload-artifact
if: ${{ matrix.artifact }}
with:
name: ${{ matrix.cache-name }}
- name: Dump Godot API
uses: ./.github/actions/godot-api-dump
if: ${{ matrix.api-dump }}
with:
bin: ${{ matrix.bin }}
- name: Unit tests
if: ${{ matrix.tests }}
run: |
${{ matrix.bin }} --version
${{ matrix.bin }} --help
${{ matrix.bin }} --headless --test --force-colors
- name: .NET source generators tests
if: ${{ matrix.build-mono }}
run: |
dotnet test modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests
# Check class reference
- name: Check for class reference updates
if: ${{ matrix.doc-test }}
run: |
echo "Running --doctool to see if this changes the public API without updating the documentation."
echo -e "If a diff is shown, it means that your code/doc changes are incomplete and you should update the class reference with --doctool.\n\n"
${{ matrix.bin }} --doctool --headless 2>&1 > /dev/null || true
git diff --color --exit-code && ! git ls-files --others --exclude-standard | sed -e 's/^/New doc file missing in PR: /' | grep 'xml$'
# Check API backwards compatibility
- name: Check for GDExtension compatibility
if: ${{ matrix.api-compat }}
run: |
./misc/scripts/validate_extension_api.sh "${{ matrix.bin }}"
# Download and run the test project
- name: Test Godot project
uses: ./.github/actions/godot-project-test
if: ${{ matrix.proj-test }}
with:
bin: ${{ matrix.bin }}
# Test the project converter
- name: Test project converter
uses: ./.github/actions/godot-converter-test
if: ${{ matrix.proj-conv }}
with:
bin: ${{ matrix.bin }}

View File

@ -1,93 +0,0 @@
name: 🍎 macOS Builds
on:
workflow_call:
# Global Settings
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes
concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-macos
cancel-in-progress: true
jobs:
build-macos:
runs-on: "macos-latest"
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Editor (target=editor, tests=yes)
cache-name: macos-editor
target: editor
tests: true
bin: "./bin/godot.macos.editor.universal"
- name: Template (target=template_release)
cache-name: macos-template
target: template_release
tests: true
sconsflags: debug_symbols=no tests=yes
bin: "./bin/godot.macos.template_release.universal"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Restore Godot build cache
uses: ./.github/actions/godot-cache-restore
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Setup Python and SCons
uses: ./.github/actions/godot-deps
- name: Setup Vulkan SDK
run: |
sh misc/scripts/install_vulkan_sdk_macos.sh
- name: Compilation (x86_64)
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }} arch=x86_64
platform: macos
target: ${{ matrix.target }}
tests: ${{ matrix.tests }}
- name: Compilation (arm64)
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }} arch=arm64
platform: macos
target: ${{ matrix.target }}
tests: ${{ matrix.tests }}
- name: Save Godot build cache
uses: ./.github/actions/godot-cache-save
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Prepare artifact
run: |
lipo -create ./bin/godot.macos.${{ matrix.target }}.x86_64 ./bin/godot.macos.${{ matrix.target }}.arm64 -output ./bin/godot.macos.${{ matrix.target }}.universal
rm ./bin/godot.macos.${{ matrix.target }}.x86_64 ./bin/godot.macos.${{ matrix.target }}.arm64
strip bin/godot.*
chmod +x bin/godot.*
- name: Upload artifact
uses: ./.github/actions/upload-artifact
with:
name: ${{ matrix.cache-name }}
- name: Unit tests
if: ${{ matrix.tests }}
run: |
${{ matrix.bin }} --version
${{ matrix.bin }} --help
${{ matrix.bin }} --test --force-colors

View File

@ -1,65 +0,0 @@
name: 🔗 GHA
on: [push, pull_request]
concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-runner
cancel-in-progress: true
jobs:
# First stage: Only static checks, fast and prevent expensive builds from running.
static-checks:
if: ${{ vars.DISABLE_GODOT_CI == '' }}
name: 📊 Static checks
uses: ./.github/workflows/static_checks.yml
# Second stage: Run all the builds and some of the tests.
android-build:
if: ${{ vars.DISABLE_GODOT_CI == '' }}
name: 🤖 Android
needs: static-checks
uses: ./.github/workflows/android_builds.yml
ios-build:
if: ${{ vars.DISABLE_GODOT_CI == '' }}
name: 🍏 iOS
needs: static-checks
uses: ./.github/workflows/ios_builds.yml
linux-build:
if: ${{ vars.DISABLE_GODOT_CI == '' }}
name: 🐧 Linux
needs: static-checks
uses: ./.github/workflows/linux_builds.yml
macos-build:
if: ${{ vars.DISABLE_GODOT_CI == '' }}
name: 🍎 macOS
needs: static-checks
uses: ./.github/workflows/macos_builds.yml
windows-build:
if: ${{ vars.DISABLE_GODOT_CI == '' }}
name: 🏁 Windows
needs: static-checks
uses: ./.github/workflows/windows_builds.yml
web-build:
if: ${{ vars.DISABLE_GODOT_CI == '' }}
name: 🌐 Web
needs: static-checks
uses: ./.github/workflows/web_builds.yml
# Third stage: Run auxiliary tests using build artifacts from previous jobs.
# Can be turned off for PRs that intentionally break compat with godot-cpp,
# until both the upstream PR and the matching godot-cpp changes are merged.
godot-cpp-test:
if: ${{ vars.DISABLE_GODOT_CI == '' }}
name: 🪲 Godot CPP
# This can be changed to depend on another platform, if we decide to use it for
# godot-cpp instead. Make sure to move the .github/actions/godot-api-dump step
# appropriately.
needs: linux-build
uses: ./.github/workflows/godot_cpp_test.yml

View File

@ -1,59 +0,0 @@
name: 📊 Static Checks
on:
workflow_call:
concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-static
cancel-in-progress: true
jobs:
static-checks:
name: Code style, file formatting, and docs
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install APT dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libxml2-utils
- name: Install Python dependencies and general setup
run: |
pip3 install pytest==7.1.2
git config diff.wsErrorHighlight all
- name: Get changed files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
fi
echo "$files" >> changed.txt
cat changed.txt
files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ')
echo "CHANGED_FILES=$files" >> $GITHUB_ENV
# This needs to happen before Python and npm execution; it must happen before any extra files are written.
- name: .gitignore checks (gitignore_check.sh)
run: |
bash ./misc/scripts/gitignore_check.sh
- name: Style checks via pre-commit
uses: pre-commit/action@v3.0.1
with:
extra_args: --verbose --files ${{ env.CHANGED_FILES }}
- name: Python builders checks via pytest
run: |
pytest ./tests/python_build
- name: Class reference schema checks
run: |
xmllint --noout --schema doc/class.xsd doc/classes/*.xml modules/*/doc_classes/*.xml platform/*/doc_classes/*.xml

View File

@ -1,82 +0,0 @@
name: 🌐 Web Builds
on:
workflow_call:
# Global Settings
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes debug_symbols=no use_closure_compiler=yes
EM_VERSION: 3.1.64
EM_CACHE_FOLDER: "emsdk-cache"
concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-web
cancel-in-progress: true
jobs:
web-template:
runs-on: "ubuntu-22.04"
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Template w/ threads (target=template_release, threads=yes)
cache-name: web-template
target: template_release
sconsflags: threads=yes
tests: false
artifact: true
- name: Template w/o threads (target=template_release, threads=no)
cache-name: web-nothreads-template
target: template_release
sconsflags: threads=no
tests: false
artifact: true
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Emscripten latest
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
cache-key: emsdk-${{ matrix.cache-name }}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
- name: Verify Emscripten setup
run: |
emcc -v
- name: Restore Godot build cache
uses: ./.github/actions/godot-cache-restore
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Setup Python and SCons
uses: ./.github/actions/godot-deps
- name: Compilation
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
platform: web
target: ${{ matrix.target }}
tests: ${{ matrix.tests }}
- name: Save Godot build cache
uses: ./.github/actions/godot-cache-save
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Upload artifact
uses: ./.github/actions/upload-artifact
if: ${{ matrix.artifact }}
with:
name: ${{ matrix.cache-name }}

View File

@ -1,100 +0,0 @@
name: 🏁 Windows Builds
on:
workflow_call:
# Global Settings
# SCONS_CACHE for windows must be set in the build environment
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes d3d12=yes "angle_libs=${{github.workspace}}/"
SCONS_CACHE_MSVC_CONFIG: true
concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-windows
cancel-in-progress: true
jobs:
build-windows:
# Windows 10 with latest image
runs-on: "windows-latest"
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Editor (target=editor, tests=yes)
cache-name: windows-editor
target: editor
tests: true
# Skip debug symbols, they're way too big with MSVC.
sconsflags: debug_symbols=no vsproj=yes vsproj_gen_only=no windows_subsystem=console
bin: "./bin/godot.windows.editor.x86_64.exe"
- name: Template (target=template_release)
cache-name: windows-template
target: template_release
tests: true
sconsflags: debug_symbols=no tests=yes
bin: "./bin/godot.windows.template_release.x86_64.console.exe"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Restore Godot build cache
uses: ./.github/actions/godot-cache-restore
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Setup Python and SCons
uses: ./.github/actions/godot-deps
- name: Download Direct3D 12 SDK components
run: python ./misc/scripts/install_d3d12_sdk_windows.py
- name: Download pre-built ANGLE static libraries
uses: dsaltares/fetch-gh-release-asset@1.1.2
with:
repo: godotengine/godot-angle-static
version: tags/chromium/6029
file: Windows.6029-1.MSVC_17.x86_64.x86_32.zip
target: angle/angle.zip
- name: Extract pre-built ANGLE static libraries
run: Expand-Archive -Force angle/angle.zip ${{github.workspace}}/
- name: Setup MSVC problem matcher
uses: ammaraskar/msvc-problem-matcher@master
- name: Compilation
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
platform: windows
target: ${{ matrix.target }}
tests: ${{ matrix.tests }}
- name: Save Godot build cache
uses: ./.github/actions/godot-cache-save
with:
cache-name: ${{ matrix.cache-name }}
continue-on-error: true
- name: Prepare artifact
run: |
Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force
- name: Upload artifact
uses: ./.github/actions/upload-artifact
with:
name: ${{ matrix.cache-name }}
- name: Unit tests
if: ${{ matrix.tests }}
run: |
${{ matrix.bin }} --version
${{ matrix.bin }} --help
${{ matrix.bin }} --test --force-colors

475
.gitignore vendored
View File

@ -1,284 +1,122 @@
# Godot .gitignore config
#
# Aims to encompass the most commonly found files that we don't want committed
# to Git, such as compilation output, IDE specific files, etc.
#
# It doesn't cover *all* thirdparty IDE extensions under the sun so if you have
# specific needs covered here, you can add them to:
# .git/info/exclude
#
# Or contribute them to this file if they're common enough that a good number of
# users would benefit from the shared rules.
#
# This file is organized by sections, with subsections ordered alphabetically.
# - Build configuration
# - Godot generated files
# - General build output
# - IDE and tool specific
# - Visual Studio specific
# - OS specific
# Godot auto generated files
platform/server/logo.h
platform/android/logo.h
platform/bb10/logo.h
platform/iphone/logo.h
platform/javascript/logo.h
platform/osx/logo.h
platform/windows/logo.h
platform/x11/logo.h
drivers/gles2/shaders/*.h
modules/register_module_types.cpp
core/version.h
core/method_bind.inc
core/method_bind_ext.inc
core/script_encryption_key.cpp
core/global_defaults.cpp
drivers/unix/os_unix_global_settings_path.cpp
tools/editor/register_exporters.cpp
tools/editor/doc_data_compressed.h
tools/editor/editor_icons.cpp
-fpic
.fscache
make.bat
log.txt
###########################
### Build configuration ###
###########################
# Documentation generated by doxygen or from classes.xml
doc/_build/
/custom.py
misc/hooks/pre-commit-custom-*
# Javascript specific
*.bc
#############################
### Godot generated files ###
#############################
# Android specific
platform/android/java/.gradle
platform/android/java/.gradletasknamecache
platform/android/java/local.properties
platform/android/java/project.properties
platform/android/java/AndroidManifest.xml
platform/android/java/bin/*
platform/android/java/libs/*
platform/android/java/gen/*
platform/android/java/assets
platform/android/libs/apk_expansion/bin/*
platform/android/libs/apk_expansion/gen/*
platform/android/libs/google_play_services/bin/*
platform/android/libs/google_play_services/gen/*
platform/android/libs/play_licensing/bin/*
platform/android/libs/play_licensing/gen/*
# Buildsystem
bin
*.gen.*
compile_commands.json
platform/windows/godot_res.res
# Ninja build files
build.ninja
.ninja
run_ninja_env.bat
# Generated by Godot binary
.import/
/gdextension_interface.h
extension_api.json
logs/
# Generated by unit tests
tests/data/*.translation
tests/data/crypto/out*
############################
### General build output ###
############################
# C/C++ generated
# General c++ generated files
*.lib
*.o
*.ox
*.a
*.ax
*.d
*.dll
*.lib
*.lo
*.o
*.os
*.ox
*.Plo
*.so
# Binutils tmp linker output of the form "stXXXXXX" where "X" is alphanumeric
st[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]
*.os
*.Plo
*.lo
*.Po
# Python development
.venv
venv
# Python generated
__pycache__/
*.pyc
# Documentation
doc/_build/
# Android
.gradle/
local.properties
*.iml
.gradletasknamecache
project.properties
platform/android/java/*/.cxx/
platform/android/java/*/build/
platform/android/java/*/libs/
# iOS
*.dSYM
# Web platform
*.bc
platform/web/node_modules/
# Misc
*.debug
#############################
### IDE and tool specific ###
#############################
# Automake
# Libs generated files
.deps/*
.dirstamp
# ccls
.ccls-cache/
# clangd
.clangd/
.cache/
# CLion
cmake-build-debug
# Code::Blocks
*.cbp
*.layout
*.depend
# CodeLite
*.project
*.workspace
.codelite/
# Cppcheck
*.cppcheck
cppcheck-cppcheck-build-dir/
# Eclipse CDT
.cproject
.settings/
*.pydevproject
*.launch
# Emacs
\#*\#
.\#*
# GCOV code coverage
*.gcda
*.gcno
# Geany
*.geany
.geanyprj
# Gprof
gmon.out
# Jetbrains IDEs
.idea/
.fleet/
# Kate
*.kate-swp
.kateproject.build
# Kdevelop
*.kdev4
# Mypy
.mypy_cache
# Qt Creator
# QT project files
*.config
*.creator
*.creator.*
*.files
*.includes
*.cflags
*.cxxflags
# SCons
.sconf_temp
.sconsign*.dblite
.scons_env.json
.scons_node_count
# Misc
.DS_Store
# Sourcetrail
*.srctrl*
# for projects that use SCons for building: http://http://www.scons.org/
.sconsign.dblite
*.pyc
# Tags
# https://github.com/github/gitignore/blob/master/Global/Tags.gitignore
# Ignore tags created by etags, ctags, gtags (GNU global) and cscope
TAGS
!TAGS/
tags
*.tags
!tags/
gtags.files
GTAGS
GRTAGS
GPATH
cscope.files
cscope.out
cscope.in.out
cscope.po.out
# Vim
*.swo
*.swp
# Visual Studio Code
.vscode/
*.code-workspace
.history/
# Xcode
xcuserdata/
*.xcscmblueprint
*.xccheckout
*.xcodeproj/*
##############################
### Visual Studio specific ###
##############################
# https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# Ignore Visual Studio temporary files, build results, and
# files generated by popular Visual Studio add-ons.
# Actual VS project files we don't use
*.sln
*.vcxproj*
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
*.sln
*.vcxproj*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
build/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Do not ignore arch-specific folders anywhere under thirdparty libraries
!thirdparty/**/x64/
!thirdparty/**/x86/
!thirdparty/**/arm/
!thirdparty/**/arm64/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# Visual Studio 2015/2017 cache/options directory
.vs/
#NUNIT
*.VisualState.xml
TestResult.xml
# Visual Studio 2017 auto generated files
Generated\ Files/
# Files built by Visual Studio
*.o
*.a
*_i.c
*_p.c
*_h.h
*_i.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
@ -288,9 +126,7 @@ Generated\ Files/
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
@ -298,84 +134,165 @@ Generated\ Files/
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# CodeLite project files
*.project
*.workspace
.codelite/
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# JustCode is a .NET coding addin-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/*
## TODO: If the tool you use requires repositories.config, also uncomment the next line
#!packages/repositories.config
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
!packages/build/
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
enc_temp_folder/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
node_modules/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
# KDE
.directory
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# Hint file for IntelliSense
cpp.hint
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
###################
### OS specific ###
###################
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Linux
*~
.directory
# Microsoft Fakes
FakesAssemblies/
# macOS
.DS_Store
__MACOSX
# =========================
# Windows detritus
# =========================
# Windows
# https://github.com/github/gitignore/blob/main/Global/Windows.gitignore
[Tt]humbs.db
[Tt]humbs.db:encryptable
# Windows image file caches
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
*.stackdump
[Dd]esktop.ini
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
*.cab
*.msi
*.msix
*.msm
*.msp
*.lnk
*.generated.props
logo.h
*.autosave
# https://github.com/github/gitignore/blob/master/Global/Tags.gitignore
# Ignore tags created by etags, ctags, gtags (GNU global) and cscope
TAGS
!TAGS/
tags
!tags/
gtags.files
GTAGS
GRTAGS
GPATH
cscope.files
cscope.out
cscope.in.out
cscope.po.out
godot.creator.*
projects/
platform/windows/godot_res.res

182
.mailmap
View File

@ -1,182 +0,0 @@
Aaron Record <aaronjrecord@gmail.com>
ajreckof <66184050+ajreckof@users.noreply.github.com> <tbonhoure@ymail.com>
Alexander Holland <alexander.holland@live.de>
Alexander Holland <alexander.holland@live.de> <alexander.holland@haw-hamburg.de>
Alexander Holland <alexander.holland@live.de> <AlexHolly>
Alfred Reinold Baudisch <alfred@alfredbaudisch.com>
Andrea Catania <info@andreacatania.com>
Anish Bhobe <anishbhobe@hotmail.com>
Anutrix <numaanzaheerahmed@yahoo.com>
Aren Villanueva <arenvillanueva@yomogi-soft.com> <aren@displaysweet.com>
Ariel Manzur <ariel@godotengine.org>
Ariel Manzur <ariel@godotengine.org> <puntob@gmail.com>
Ariel Manzur <ariel@godotengine.org> <punto@godotengine.org>
Ariel Manzur <ariel@godotengine.org> <ariel@okamstudio.com>
Ariel Manzur <ariel@godotengine.org> <punto@Ariels-Mac-mini.local>
Ariel Manzur <ariel@godotengine.org> <punto@Ariels-Mac-mini-2.local>
Arman Elgudzhyan <48544263+puchik@users.noreply.github.com>
A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> <over999ships@gmail.com>
Bastiaan Olij <mux213@gmail.com>
Benjamin <mafortion.benjamin@gmail.com>
Bernhard Liebl <Bernhard.Liebl@gmx.org> <poke1024@gmx.de>
Bernhard Liebl <Bernhard.Liebl@gmx.org> <poke1024@gmx.org>
Bruno Lourenço <madequa@users.noreply.github.com> <bmlourenco@gmail.com>
Chaosus <chaosus89@gmail.com>
ChibiDenDen <pdaniq@gmail.com>
Chris Bradfield <chris@kidscancode.org> <cb@scribe.net>
Clay John <claynjohn@gmail.com>
Clay John <claynjohn@gmail.com> <clayjohn@shaw.ca>
CookieBadger <emil.dobetsberger@gmail.com>
Dana Olson <dana@shineuponthee.com> <adolson@gmail.com>
dankan1890 <mewuidev2@gmail.com>
Daniel J. Ramirez <djrmuv@gmail.com>
David Cambré <david.cambre@gmail.com> <David.Cambre@gmail.com>
DmitriySalnikov <salnikov.mine@yandex.ru>
DmitriySalnikov <salnikov.mine@yandex.ru> <dimokgamer@gmail.com>
Dominik 'dreamsComeTrue' Jasiński <dominikjasinski@o2.pl>
DeeJayLSP <djlsplays@gmail.com> <60024671+DeeJayLSP@users.noreply.github.com>
Emmanuel Barroga <emmanuelbarroga@gmail.com>
Eric M <itsjusteza@gmail.com>
Eric Rybicki <info@ericrybicki.com> <stratos695@googlemail.com>
Erik Selecký <35656626+rxlecky@users.noreply.github.com>
Erik Selecký <35656626+rxlecky@users.noreply.github.com> <35656626+SeleckyErik@users.noreply.github.com>
Eveline Jarosz <marqin.pl@gmail.com>
Eveline Jarosz <marqin.pl@gmail.com> <marqin.pl+git@gmail.com>
Fabian <supagu@gmail.com>
Ferenc Arn <tagcup@yahoo.com>
Ferenc Arn <tagcup@yahoo.com> <tagcup@users.noreply.github.com>
FireForge <67974470+fire-forge@users.noreply.github.com> <isaacr.7.2005@gmail.com>
Florian Kothmeier <floriankothmeier@web.de>
foxydevloper <12120644+foxydevloper@users.noreply.github.com>
Fredia Huya-Kouadio <fhuyakou@gmail.com>
Fredia Huya-Kouadio <fhuyakou@gmail.com> <fhuya@google.com>
Fredia Huya-Kouadio <fhuyakou@gmail.com> <fhuya@fb.com>
Fredia Huya-Kouadio <fhuyakou@gmail.com> <fhuya@meta.com>
Geequlim <geequlim@gmail.com>
Gilles Roudiere <gilles.roudiere@gmail.com>
Gilles Roudiere <gilles.roudiere@gmail.com> <gilles.roudiere@laas.fr>
Gordon MacPherson <gordon@gordonite.tech>
Guilherme Felipe <guilhermefelipecgs@gmail.com>
Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
HaSa1002 <johawitt@outlook.de>
Hein-Pieter van Braam-Stewart <hp@tmm.cx>
Hugo Locurcio <hugo.locurcio@hugo.pro> <hugo.l@openmailbox.org>
Hugo Locurcio <hugo.locurcio@hugo.pro> <Calinou@users.noreply.github.com>
Hugo Locurcio <hugo.locurcio@hugo.pro> Calinou <calinou@opmbx.org>
Ian Bishop <ianb96@gmail.com>
Ignacio Etcheverry <ignalfonsore@gmail.com>
Ignacio Etcheverry <ignalfonsore@gmail.com> <neikeq@users.noreply.github.com>
Ilaria Cislaghi <cislaghi.ilaria@gmail.com>
Ilaria Cislaghi <cislaghi.ilaria@gmail.com> <ilaria.cislaghi@simedis.com>
Indah Sylvia <ISylvox@yahoo.com>
Ivan Shakhov <ivan.shakhov@jetbrains.com> <Ivan.Shakhov@jetbrains.com>
Ivan Shakhov <ivan.shakhov@jetbrains.com> <van800@gmail.com>
iwek <miwanczuk7@gmail.com>
J08nY <johny@neuromancer.sk> <jancar.jj@gmail.com>
J08nY <johny@neuromancer.sk> <J08nY@users.noreply.github.com>
Jake Young <young9003@gmail.com>
Jakub Grzesik <kubecz3k@gmail.com>
Jakub Marcowski <chubercikbattle@gmail.com> <01158831@pw.edu.pl>
Jakub Marcowski <chubercikbattle@gmail.com> <37378746+Chubercik@users.noreply.github.com>
janglee <merupatel123@gmail.com>
Jason Knight <00jknight@gmail.com> <jason@winterpixel.com>
Jean-Michel Bernard <jmb462@gmail.com>
Jérôme Gully <jerome.gully0@gmail.com>
JFonS <joan.fonssanchez@gmail.com>
jitspoe <jitspoe@yahoo.com> <jitspoeAyahoooDcom>
Juan Linietsky <reduzio@gmail.com>
Juan Linietsky <reduzio@gmail.com> <juan@godotengine.org>
Juan Linietsky <reduzio@gmail.com> <juan@okamstudio.com>
Juan Linietsky <reduzio@gmail.com> <reduz@Juans-MBP.fibertel.com.ar>
Juan Linietsky <reduzio@gmail.com> <red@kyoko>
Julian Murgia <the.straton@gmail.com>
Kanabenki <lucien.menassol@gmail.com> <18357657+Kanabenki@users.noreply.github.com>
karroffel <therzog@mail.de>
karroffel <therzog@mail.de> <thomas.herzog@mail.com>
karroffel <therzog@mail.de> <thomas.herzog@simedis.com>
Kelly Thomas <kelly.thomas@hotmail.com.au>
Kongfa Waroros <gongpha@hotmail.com>
K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
kleonc <9283098+kleonc@users.noreply.github.com> <kleonc@users.noreply.github.com>
Leon Krause <lk@leonkrause.com> <eska@eska.me>
Leon Krause <lk@leonkrause.com> <eska014@users.noreply.github.com>
Liz Haas <27thLiz@gmail.com>
Liz Haas <27thLiz@gmail.com> <liu.gam3@gmail.com>
Liz Haas <27thLiz@gmail.com> <hinsbart@gmail.com>
Liz Haas <27thLiz@gmail.com> <hinsbart@users.noreply.github.com>
Liz Haas <27thLiz@gmail.com> <entenflugstuhl@gmail.com>
Manuele Finocchiaro <m4nu3lf@gmail.com>
Manuel Strey <manuel.strey@gmx.de>
Marcel Admiraal <madmiraal@users.noreply.github.com>
Marcelo Fernandez <marcelofg55@gmail.com>
Marcin Zawiejski <dragmz@gmail.com>
Marcus Elg <marcusaccounts@yahoo.se>
Mariano Javier Suligoy <marianognu.easyrpg@gmail.com>
Mario Schlack <m4r10.5ch14ck@gmail.com>
Mark DiBarry <markdibarry@protonmail.com>
marxin <mliska@suse.cz>
marynate <mary.w.nate@gmail.com> <marynate@github.com>
Mateo Kuruk Miccino <mateomiccino@gmail.com>
Max Hilbrunner <m.hilbrunner@gmail.com>
Max Hilbrunner <m.hilbrunner@gmail.com> <mhilbrunner@users.noreply.github.com>
MewPurPur <mew.pur.pur@abv.bg>
Michael Alexsander <michaelalexsander@protonmail.com>
Micky <micheledevita2@gmail.com> <66727710+Mickeon@users.noreply.github.com>
Nathan Franke <natfra@pm.me> <nathanwfranke@gmail.com>
Nathan Lovato <nathan@gdquest.com>
Nathan Warden <nathan@nathanwarden.com> <nathanwardenlee@icloud.com>
Nicholas Huelin <62965063+SirQuartz@users.noreply.github.com>
Nils ANDRÉ-CHANG <nils@nilsand.re>
Nils ANDRÉ-CHANG <nils@nilsand.re> <nils.andre.chang@gmail.com>
Nông Văn Tình <vannongtinh@gmail.com>
Nuno Donato <nunodonato@gmail.com> <n.donato@estrelasustentavel.pt>
ocean (they/them) <anvilfolk@gmail.com>
Pawel Kowal <pkowal1982@gmail.com>
Pedro J. Estébanez <pedrojrulez@gmail.com> <RandomShaper@users.noreply.github.com>
Patrick Exner <patrick.exner1@web.de>
Patrick <firefly2442@gmail.com>
Paul Batty <p_batty@hotmail.co.uk>
Paul Batty <p_batty@hotmail.co.uk> <Paulb23@users.noreply.github.com>
Pawel Kowal <pkowal1982@gmail.com> <pawel.kowal@javart.eu>
Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
Pieter-Jan Briers <pieterjan.briers+git@gmail.com> <pieterjan.briers@gmail.com>
Poommetee Ketson <poommetee@protonmail.com>
Przemysław Gołąb (n-pigeon) <golab.przemyslaw@gmail.com>
Rafał Mikrut <mikrutrafal@protonmail.com>
Rafał Mikrut <mikrutrafal@protonmail.com> <mikrutrafal54@gmail.com>
Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@posteo.de>
Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@users.noreply.github.com>
Ramesh Ravone <ramesh.maran443@gmail.com>
RaphaelHunter <raphael10241024@gmail.com>
RaphaelHunter <raphael10241024@gmail.com> <Raphael10241024@gmail.com>
RaphaelHunter <raphael10241024@gmail.com> <raphael20141024@gmail.com>
Rémi Verschelde <rverschelde@gmail.com> <remi@verschelde.fr>
Rhody Lugo <rhodylugo@gmail.com> <rhodylugo@me.com>
Ricardo Subtil <ricasubtil@gmail.com>
Rindbee <idleman@yeah.net>
Riteo Siuga <riteo@posteo.net>
Robin Hübner <profan@prfn.se> <robinhubner@gmail.com>
romulox_x <romulox_x@yahoo.com>
rune-scape <allie.smith.epic@gmail.com>
rune-scape <allie.smith.epic@gmail.com> <spartacrafter@gmail.com>
Ruslan Mustakov <r.mustakov@gmail.com> <ruslan.mustakov@xored.com>
Saracen <SaracenOne@gmail.com>
sheepandshepherd <sheepandshepherd@hotmail.com> <sheepandshepherd@users.noreply.github.com>
Silc 'Tokage' Renew <tokage.it.lab@gmail.com>
Silc 'Tokage' Renew <tokage.it.lab@gmail.com> <61938263+TokageItLab@users.noreply.github.com>
Swarnim Arun <swarnimarun11@gmail.com>
TechnoPorg <jonah.janzen@gmail.com> <69441745+TechnoPorg@users.noreply.github.com>
Theo Hallenius <redsymbzone@hotmail.com>
Tomasz Chabora <kobewi4e@gmail.com>
Twarit <wtwarit@gmail.com>
Vitika9 <vitika.program@gmail.com>
V.VamsiKrishna <vk@bsb.in> <vamsikrishna.v@gmail.com>
Wilhem Barbier <nounoursheureux@openmailbox.org> <wilhem.b@free.fr>
Wilhem Barbier <nounoursheureux@openmailbox.org> <schtroumps31@gmail.com>
Will Nations <willnationsdev@gmail.com>
yg2f <yoann@terminajones.com>
Yuri Sizov <yuris@humnom.net> <pycbouh@users.noreply.github.com>
Yuri Sizov <yuris@humnom.net> <yaschik4ilicha@gmail.com>
Zae <zaevi@live.com>
Zak Stam <zakscomputers@hotmail.com>
Zher Huei Lee <lee.zh.92@gmail.com>

View File

@ -1,184 +0,0 @@
default_language_version:
python: python3
exclude: |
(?x)^(
.*thirdparty/.*|
.*-so_wrap\.(h|c)$
)
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
hooks:
- id: clang-format
files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java|glsl)$
types_or: [text]
exclude: |
(?x)^(
tests/python_build/.*|
platform/android/java/lib/src/com/.*
)
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-tidy
files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java|glsl)$
args: [--fix, --quiet, --use-color]
types_or: [text]
exclude: |
(?x)^(
tests/python_build/.*|
platform/android/java/lib/src/com/.*
)
additional_dependencies: [clang-tidy==18.1.1]
require_serial: true
stages: [manual] # Not automatically triggered, invoked via `pre-commit run --hook-stage manual clang-tidy`
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.971
hooks:
- id: mypy
files: \.py$
types_or: [text]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies: [tomli]
### Requires Docker; look into alternative implementation.
# - repo: https://github.com/comkieffer/pre-commit-xmllint.git
# rev: 1.0.0
# hooks:
# - id: xmllint
# language: docker
# types_or: [text]
# files: ^(doc/classes|.*/doc_classes)/.*\.xml$
# args: [--schema, doc/class.xsd]
- repo: local
hooks:
- id: make-rst
name: make-rst
language: python
entry: python doc/tools/make_rst.py
args: [doc/classes, modules, platform, --dry-run, --color]
pass_filenames: false
files: ^(doc/classes|.*/doc_classes)/.*\.xml$
- id: doc-status
name: doc-status
language: python
entry: python doc/tools/doc_status.py
args: [doc/classes, modules/*/doc_classes, platform/*/doc_classes]
pass_filenames: false
files: ^(doc/classes|.*/doc_classes)/.*\.xml$
- id: eslint
name: eslint
language: node
entry: eslint
files: ^(platform/web/js/|modules/|misc/dist/html/).*\.(js|html)$
args: [--fix, --no-warn-ignored, --no-config-lookup, --config, platform/web/eslint.config.cjs]
additional_dependencies:
- '@eslint/js@^9.3.0'
- '@html-eslint/eslint-plugin@^0.24.1'
- '@html-eslint/parser@^0.24.1'
- '@stylistic/eslint-plugin@^2.1.0'
- 'eslint@^9.3.0'
- 'eslint-plugin-html@^8.1.1'
- 'globals@^15.3.0'
- 'espree@^10.0.1'
- id: jsdoc
name: jsdoc
language: node
entry: jsdoc
files: ^platform/web/js/engine/(engine|config|features)\.js$
args:
- --template
- platform/web/js/jsdoc2rst/
- platform/web/js/engine/engine.js
- platform/web/js/engine/config.js
- platform/web/js/engine/features.js
- --destination
- ''
- -d
- dry-run
pass_filenames: false
additional_dependencies: ['jsdoc@^4.0.3']
- id: svgo
name: svgo
language: node
entry: svgo
files: \.svg$
args: [--quiet, --config, misc/utility/svgo.config.mjs]
additional_dependencies: ["svgo@3.3.2"]
- id: copyright-headers
name: copyright-headers
language: python
entry: python misc/scripts/copyright_headers.py
files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java)$
exclude: |
(?x)^(
core/math/bvh_.*\.inc$|
platform/(?!android|ios|linuxbsd|macos|web|windows)\w+/.*|
platform/android/java/lib/src/com/.*|
platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView\.java$|
platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper\.java$|
platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix\.java$
)
- id: header-guards
name: header-guards
language: python
entry: python misc/scripts/header_guards.py
files: \.(h|hpp|hh|hxx)$
exclude: ^.*/(thread|platform_config|platform_gl)\.h$
- id: file-format
name: file-format
language: python
entry: python misc/scripts/file_format.py
types_or: [text]
exclude: |
(?x)^(
.*\.test\.txt$|
.*\.svg$|
.*\.patch$|
.*\.out$|
modules/gdscript/tests/scripts/parser/features/mixed_indentation_on_blank_lines\.gd$|
modules/gdscript/tests/scripts/parser/warnings/empty_file_newline_comment\.notest\.gd$|
modules/gdscript/tests/scripts/parser/warnings/empty_file_newline\.notest\.gd$|
platform/android/java/lib/src/com/google/.*
)
- id: dotnet-format
name: dotnet-format
language: python
entry: python misc/scripts/dotnet_format.py
types_or: [c#]
# End of upstream Godot pre-commit hooks.
#
# Keep this separation to let downstream forks add their own hooks to this file,
# without running into merge conflicts when rebasing on latest upstream.
#
# Start of downstream pre-commit hooks.
#
# This is still the "repo: local" scope, so new local hooks can be defined directly at this indentation:
# - id: new-local-hook
# To add external repo hooks, bring the indentation back to:
# - repo: my-remote-hook

74
.travis.yml Normal file
View File

@ -0,0 +1,74 @@
language: cpp
sudo: false
compiler:
- gcc
- clang
os:
- linux
- osx
env:
- GODOT_TARGET=iphone
- GODOT_TARGET=osx
- GODOT_TARGET=x11
- GODOT_TARGET=android
- GODOT_TARGET=windows
matrix:
exclude:
- os: linux
env: GODOT_TARGET=iphone
- os: linux
env: GODOT_TARGET=osx
- os: linux
env: GODOT_TARGET=android
- os: osx
env: GODOT_TARGET=x11
- os: osx
env: GODOT_TARGET=windows
- compiler: gcc
env: GODOT_TARGET=iphone
- compiler: gcc
env: GODOT_TARGET=osx
- compiler: clang
env: GODOT_TARGET=android
- compiler: clang
env: GODOT_TARGET=windows
- compiler: clang
env: GODOT_TARGET=x11
addons:
apt:
packages:
- build-essential
- scons
- pkg-config
- libx11-dev
- libxcursor-dev
- libasound2-dev
- libfreetype6-dev
- libgl1-mesa-dev
- libglu1-mesa-dev
- libssl-dev
- libxinerama-dev
- libudev-dev
# For cross-compiling to Windows.
- binutils-mingw-w64-i686
- binutils-mingw-w64-x86-64
- gcc-mingw-w64-i686
- gcc-mingw-w64-x86-64
- g++-mingw-w64-i686
- g++-mingw-w64-x86-64
- mingw-w64
before_script:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install scons; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$GODOT_TARGET" = "android" ]; then brew update; brew install android-sdk android-ndk; export ANDROID_HOME=/usr/local/opt/android-sdk; export ANDROID_NDK_ROOT=/usr/local/opt/android-ndk; fi
script:
- scons platform=$GODOT_TARGET CXX=$CXX openssl=builtin

View File

@ -1,321 +0,0 @@
# Godot Engine authors
Godot Engine is developed by a community of voluntary contributors who
contribute code, bug reports, documentation, artwork, support, etc.
It is impossible to list them all; nevertheless, this file aims at listing
the developers who contributed significant patches to this MIT licensed
source code. "Significant" is arbitrarily decided, but should be fair :)
GitHub usernames are indicated in parentheses, or as sole entry when no other
name is available.
## Project Founders
Juan Linietsky (reduz)
Ariel Manzur (punto-)
## Lead Developer
Juan Linietsky (reduz)
## Project Manager
Rémi Verschelde (akien-mga)
## Developers
(in alphabetical order, with over 10 commits excluding merges)
Aaron Franke (aaronfranke)
Aaron Pagano (aaronp64)
Aaron Record (LightningAA)
Adam Scott (adamscott)
Alexander Hartmann (Alex2782)
Alexander Holland (AlexHolly)
Alex Drozd (brno32)
Alexey Khoroshavin (allkhor)
Alfred Reinold Baudisch (alfredbaudisch)
Alistair Leslie-Hughes (alesliehughes)
Alket Rexhepi (alketii)
Andrea Catania (AndreaCatania)
Andreia Gaita (shana)
Andrii Doroshenko (Xrayez)
Andy Maloney (asmaloney)
Andy Moss (MillionOstrich)
Angad Kambli (angad-k)
Anilforextra (AnilBK)
Anish Bhobe (KidRigger)
Anton Yabchinskiy (a12n)
Anutrix
Aren Villanueva (kurikaesu)
Ariel Manzur (punto-)
Arman Elgudzhyan (puchik)
AThousandShips
aXu-AP
Bartłomiej T. Listwon (Listwon)
Bastiaan Olij (BastiaanOlij)
Ben Brookshire (sheepandshepherd)
Benjamin Larsson (Nallebeorn)
Bernhard Liebl (poke1024)
Bhuvan Vemula (Bhu1-V)
bitsawer
Błażej Szczygieł (zaps166)
BlueCube3310
Bojidar Marinov (bojidar-bg)
Brian Semrau (briansemrau)
Bruno Lourenço (MadEqua)
Cameron Reikes (creikey)
Camille Mohr-Daurat (pouleyKetchoupp)
Caner Demirer (cdemirer)
Carl Olsson (not-surt)
Carter Anderson (cart)
ChibiDenDen
Chris Bradfield (cbscribe)
Christian Kaiser (ckaiser)
Clay John (clayjohn)
ConteZero
CookieBadger
Dana Olson (adolson)
Daniel J. Ramirez (djrm)
Daniel Rakos (aqnuep)
Daniel Zilberleyb (dzil123)
Danil Alexeev (dalexeev)
dankan1890
Darío Banini (DarioSamo)
David Cambré (Gallilus)
David Sichma (DavidSichma)
David Snopek (dsnopek)
Dharkael (lupoDharkael)
Dmitry Koteroff (Krakean)
Dmitry Maganov (vonagam)
Dominik Jasiński (dreamsComeTrue)
Douglas Leão (DeeJayLSP)
DualMatrix
Ellen Poe (ellenhp)
Emilio Coppola (coppolaemilio)
Emmanuel Barroga (codecustard)
Emmanuel Leblond (touilleMan)
Eoin O'Neill (Eoin-ONeill-Yokai)
Eric Lasota (elasota)
Eric M (EricEzaM)
Eric Rybicki (ericrybick)
Erik Selecký (rxlecky)
est31
Eveline Jarosz (Marqin)
Fabian Mathews (supagu)
Fabio Alessandrelli (Faless)
Fabrice Cipolla (fabriceci)
Ferenc Arn (tagcup)
FireForge (fire-forge)
Florian Kothmeier (Dragoncraft89)
follower
foxydevloper
François Belair (Razoric480)
Franklin Sobrinho (TheHX)
Fredia Huya-Kouadio (m4gr3d)
Geequlim
George Marques (vnen)
Gerrit Großkopf (Grosskopf)
Gilles Roudiere (groud)
Gordon MacPherson (RevoluPowered)
Guilherme Felipe de C. G. da Silva (guilhermefelipecgs)
Hakim Rouatbi (hakro)
Hanif Bin Ariffin (hbina)
Haoyu Qiu (timothyqiu)
Hein-Pieter van Braam-Stewart (hpvb)
Hendrik Brucker (Geometror)
Hilderin
hilfazer
Hiroshi Ogawa (hi-ogawa)
HolonProduction
homer666
hoontee
Hugo Locurcio (Calinou)
Ian Bishop (ianb96)
Ibrahn Sahir (ibrahn)
Ignacio Roldán Etcheverry (neikeq)
Igor Kordiukiewicz (IgorKordiukiewicz)
Ilaria Cislaghi (QbieShay)
Indah Sylvia (ISylvox)
Ivan Šachov (van800)
J08nY
Jake Young (Duroxxigar)
Jakub Grzesik (kubecz3k)
Jakub Marcowski (Chubercik)
James Buck (jbuck3)
Jan Haller (Bromeon)
Jason Knight (jasonwinterpixel)
Jean-Michel Bernard (jmb462)
Jérôme Gully (Nutriz)
Jia Jun Chai (SkyLucilfer)
jitspoe
Joan Fons Sanchez (JFonS)
Johan Manuel (29jm)
Johannes Witt (HaSa1002)
Jonathan Nicholl (jtnicholl)
Jordan Schidlowsky (winterpixelgames)
Josh Jones (DarkKilauea)
Joshua Grams (JoshuaGrams)
Juan Linietsky (reduz)
Julian Murgia (StraToN)
Julien Nguyen (Blackiris)
Jummit
Justo Delgado (mrcdk)
karroffel
Kelly Thomas (KellyThomas)
kleonc
Kongfa Waroros (gongpha)
Kostadin Damyanov (Max-Might)
K. S. Ernest (iFire) Lee (fire)
lawnjelly
Leon Krause (leonkrause)
Liz Haas (27thLiz)
Lucien Menassol (Kanabenki)
Lyuma
Maganty Rushyendra (mrushyendra)
Magian (magian1127)
Mai Lavelle (maiself)
Malcolm Nixon (Malcolmnixon)
Manuele Finocchiaro (m4nu3lf)
Marcel Admiraal (madmiraal)
Marcelo Fernandez (marcelofg55)
Marc Gilleron (Zylann)
Marcin Zawiejski (dragmz)
Marcus Brummer (mbrlabs)
Marcus Elg (MCrafterzz)
Mariano Javier Suligoy (MarianoGnu)
Mario Schlack (hurikhan)
Marios Staikopoulos (marstaik)
Marius Hanl (Maran23)
Mark DiBarry (markdibarry)
Mark Riedesel (klowner)
Markus Sauermann (Sauermann)
Martin Capitanio (capnm)
Martin Liška (marxin)
Martin Sjursen (binbitten)
marynate
Masoud BH (masoudbh3)
Mateo Kuruk Miccino (kuruk-mm)
Matias N. Goldberg (darksylinc)
Matthew (skyace65)
Matthias Hölzl (hoelzl)
Max Hilbrunner (mhilbrunner)
merumelu
Meru Patel (Janglee123)
MewPurPur
Michael Alexsander (YeldhamDev)
Michał Iwańczuk (iwek7)
MichiRecRoom (LikeLakers2)
Micky (Mickeon)
Mikael Hermansson (mihe)
MinusKube
MJacred
Morris "Tabor" Arroad (mortarroad)
mrezai
Muhammad Huri (CakHuri)
muiroc
myaaaaaaaaa
Nathalie Galla (MurderVeggie)
Nathan Franke (nathanfranke)
Nathan Lovato (NathanLovato)
Nathan Warden (NathanWarden)
Nicholas Huelin (SirQuartz)
Nikita Lita (nikitalita)
Nils André-Chang (NilsIrl)
Noah Beard (TwistedTwigleg)
Nông Văn Tình (nongvantinh)
Nuno Donato (nunodonato)
ocean (they/them) (anvilfolk)
Omar El Sheikh (The-O-King)
Ovnuniarchos
Pascal Richter (ShyRed)
passivestar
Patrick Dawson (pkdawson)
Patrick Exner (FlameLizard)
Patrick (firefly2442)
Paul Batty (Paulb23)
Paul Joannon (paulloz)
Paul Trojahn (ptrojahn)
Pāvels Nadtočajevs (bruvzg)
Paweł Fertyk (pfertyk)
Pawel Kowal (pkowal1982)
Pawel Lampe (Scony)
Pedro J. Estébanez (RandomShaper)
Pieter-Jan Briers (PJB3005)
Poommetee Ketson (Noshyaar)
Przemysław Gołąb (n-pigeon)
Rafael M. G. (rafallus)
Rafał Mikrut (qarmin)
Raffaele Picca (RPicster)
Ralf Hölzemer (rollenrolm)
Ramesh Ravone (RameshRavone)
Raphael2048
Raul Santos (raulsntos)
Ray Koopa (RayKoopa)
RedMser
RedworkDE
Rémi Verschelde (akien-mga)
Rhody Lugo (rraallvv)
Ricardo Buring (rburing)
Ricardo Subtil (Ev1lbl0w)
Riteo Siuga (Riteo)
Roberto F. Arroyo (robfram)
Robert Yevdokimov (ryevdokimov)
Robin Hübner (profan)
romulox-x
Rune Smith (rune-scape)
Ruslan Mustakov (endragor)
Ryan Roden-Corrent (rrcore)
Saniko (sanikoyes)
santouits
SaracenOne
Septian Ganendra S. K. (sepTN)
Sergey Minakov (naithar)
sersoong
Shiqing (kawa-yoiko)
Silc 'Tokage' Renew (TokageItLab)
Simon Wenner (swenner)
smix8
snailrhymer
Sofox (TheSofox)
Stanislav Labzyuk (DarkMessiah)
Stijn Hinlopen (hinlopen)
stmSi
Swarnim Arun (minraws)
TC (floppyhammer)
TechnoPorg
Thaddeus Crews (Repiteo)
Thakee Nathees (ThakeeNathees)
thebestnom
Theo Hallenius (TheoXD)
Timo Schwarzer (timoschwarzer)
Timothé Bonhoure (ajreckof)
Timo (toger5)
Tomasz Chabora (KoBeWi)
trollodel
Twarit Waikar (IronicallySerious)
Umang Kalra (theoway)
Vinzenz Feenstra (vinzenz)
Vitika Soni (Vitika9)
박한얼 (volzhs)
V. Vamsi Krishna (vkbsb)
Wilhem Barbier (nounoursheureux)
William Deurwaarder (williamd67)
Will Nations (willnationsdev)
Wilson E. Alvarez (Rubonnek)
Xavier Cho (mysticfall)
Yaohua Xiong (xiongyaohua)
yg2f (SuperUserNameMan)
Yordan Dolchinkov (Jordyfel)
Yuri Rubinsky (Chaosus)
Yuri Sizov (YuriSizov)
Zae Chao (zaevi)
Zak Stam (zaksnet)
Zher Huei Lee (leezh)
Zi Ye (MajorMcDoom)
ZuBsPaCe
Дмитрий Сальников (DmitriySalnikov)
忘忧の (Daylily-Zeleen)
谢天 (jsjtxietian)
风青山 (Rindbee)

File diff suppressed because it is too large Load Diff

View File

@ -1,213 +1,59 @@
# Contributors guidelines
# How to contribute efficiently
This document summarizes the most important points for people interested in
contributing to Godot, especially via bug reports or pull requests.
**Please read the first section before reporting a bug!**
The Godot documentation has a dedicated [Contributing section](https://docs.godotengine.org/en/latest/contributing/how_to_contribute.html)
which details these points and more, and is a recommended read.
## Reporting bugs or proposing features
## Table of contents
The golden rule is to **always open *one* issue for *one* bug**. If you notice several bugs and want to report them, make sure to create one new issue for each of them.
- [Reporting bugs](#reporting-bugs)
- [Proposing features or improvements](#proposing-features-or-improvements)
- [Contributing pull requests](#contributing-pull-requests)
- [Contributing to Godot translations](#contributing-to-godot-translations)
- [Communicating with developers](#communicating-with-developers)
Everything refered to hereafter as "bug" also applies for feature requests.
## Reporting bugs
If you are reporting a new issue, you will make our life much simpler (and the fix come much sooner) by following those guidelines:
Report bugs [here](https://github.com/godotengine/godot/issues/new?assignees=&labels=&template=bug_report.yml).
Please follow the instructions in the template when you do.
#### Search first in the existing database
Notably, please include a Minimal Reproduction Project (MRP), which is a small
Godot project which reproduces the issue, with no unnecessary files included.
Be sure to not include the `.godot` folder in the archive to save space.
Issues are often reported several times by various users. It's a good practice to **search first** in the issues database before reporting your issue. If you don't find a relevant match or if you are unsure, don't hesitate to **open a new issue**. The bugsquad will handle it from there if it's a duplicate.
Make sure that the bug you are experiencing is reproducible in the latest Godot
releases. You can find an overview of all Godot releases [on the website](https://godotengine.org/download/archive/)
to confirm whether your current version is the latest one. It's worth testing
against both the latest stable release and the latest dev snapshot for the next
Godot release.
#### Specify the platform
Godot runs on a large variety of platforms and operating systems and devices. If you believe your issue is device/platform dependent (for example if it is related to the rendering, crashes or compilation errors), please specify:
* Operating system
* Device (including architecture, e.g. x86, x86_64, arm, etc.)
* GPU model (and driver in use if you know it)
If you run into a bug which wasn't present in an earlier Godot version (what we
call a _regression_), please mention it and clarify which versions you tested
(both the one(s) working and the one(s) exhibiting the bug).
#### Specify steps to reproduce
## Proposing features or improvements
Many bugs can't be reproduced unless specific steps are taken. Please **specify the exact steps** that must be taken to reproduce the condition, and try to keep them as minimal as possible.
**The main issue tracker is for bug reports and does not accept feature proposals.**
#### Provide a simple, example project
Instead, head to the [Godot Proposals repository](https://github.com/godotengine/godot-proposals)
and follow the instructions in the README file and issue template.
Sometimes an unexpected behavior happens in your project. In such case, understand that:
* What happens to you may not happen to other users.
* We can't take the time to look at your project, understand how it is set up and then figure out why it's failing.
To speed up our work, please prepare for us **a simple project** that isolates and reproduces the issue. This is always the **the best way for us to fix it**. You can attach a zip file with the minimal project directly to the bug report, by drag and dropping the file in the GitHub edition field.
## Contributing pull requests
If you want to add new engine features, please make sure that:
If you want to add new engine functionalities, please make sure that:
- This functionality is desired, which means that it solves a common use case
that several users will need in their real-life projects.
- You talked to other developers on how to implement it best. See also
[Proposing features or improvements](#proposing-features-or-improvements).
- Even if it doesn't get merged, your PR is useful for future work by another
developer.
* This functionality is desired.
* You talked to other developers on how to implement it best (on either communication channel, and maybe in a GitHub issue first before making your PR).
* Even if it does not get merged, your PR is useful for future work by another developer.
Similar rules can be applied when contributing bug fixes - it's always best to
discuss the implementation in the bug report first if you are not 100% about
what would be the best fix.
Similar rules can be applied when contributing bug fixes - it's always best to discuss the implementation in the bug report first if you are not 100% about what would be the best fix.
You can refer to the [Pull request review process](https://docs.godotengine.org/en/latest/contributing/workflow/pr_review_guidelines.html)
for insights into the intended lifecycle of pull requests. This should help you
ensure that your pull request fulfills the requirements.
#### Be nice to the git history
In addition to the following tips, also take a look at the
[Engine development guide](https://docs.godotengine.org/en/latest/contributing/development/index.html)
for an introduction to developing on Godot.
Try to make simple PRs with that handle one specific topic. Just like for reporting issues, it's better to open 3 different PRs that each address a different issue than one big PR with three commits.
The [Contributing docs](https://docs.godotengine.org/en/latest/contributing/how_to_contribute.html)
also have important information on the [PR workflow](https://docs.godotengine.org/en/latest/contributing/workflow/pr_workflow.html)
(with a helpful guide for Git usage), and our [Code style guidelines](https://docs.godotengine.org/en/latest/contributing/development/code_style_guidelines.html)
which all contributions need to follow.
When updating your fork with upstream changes, please use ``git pull --rebase`` to avoid creating "merge commits". Those commits unnecessarily pollute the git history when coming from PRs.
### Be mindful of your commits
Also try to make commits that bring the engine from one stable state to another stable state, i.e. if your first commit has a bug that you fixed in the second commit, try to merge them together before making your pull request (see ``git rebase -i`` and relevant help about rebasing or ammending commits on the Internet).
Try to make simple PRs that handle one specific topic. Just like for reporting
issues, it's better to open 3 different PRs that each address a different issue
than one big PR with three commits. This makes it easier to review, approve, and
merge the changes independently.
This git style guide has some good practices to have in mind: https://github.com/agis-/git-style-guide
When updating your fork with upstream changes, please use ``git pull --rebase``
to avoid creating "merge commits". Those commits unnecessarily pollute the git
history when coming from PRs.
Thanks!
Also try to make commits that bring the engine from one stable state to another
stable state, i.e. if your first commit has a bug that you fixed in the second
commit, try to merge them together before making your pull request. This
includes fixing build issues or typos, adding documentation, etc.
See our [PR workflow](https://docs.godotengine.org/en/latest/contributing/workflow/pr_workflow.html)
documentation for tips on using Git, amending commits and rebasing branches.
This [Git style guide](https://github.com/agis-/git-style-guide) also has some
good practices to have in mind.
### Format your commit messages with readability in mind
The way you format your commit messages is quite important to ensure that the
commit history and changelog will be easy to read and understand. A Git commit
message is formatted as a short title (first line) and an extended description
(everything after the first line and an empty separation line).
The short title is the most important part, as it is what will appear in the
changelog or in the GitHub interface unless you click the "expand" button.
Try to keep that first line under 72 characters, but you can go slightly above
if necessary to keep the sentence clear.
It should be written in English, starting with a capital letter, and usually
with a verb in imperative form. A typical bugfix would start with "Fix", while
the addition of a new feature would start with "Add". A prefix can be added to
specify the engine area affected by the commit. Some examples:
- Add C# iOS support
- Show doc tooltips when hovering properties in the theme editor
- Fix GLES3 instanced rendering color and custom data defaults
- Core: Fix `Object::has_method()` for script static methods
If your commit fixes a reported issue, please include it in the _description_
of the PR (not in the title, or the commit message) using one of the
[GitHub closing keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
such as "Fixes #1234". This will cause the issue to be closed automatically if
the PR is merged. Adding it to the commit message is easier, but adds a lot of
unnecessary updates in the issue distracting from the thread.
Here's an example of a well-formatted commit message (note how the extended
description is also manually wrapped at 80 chars for readability):
```text
Prevent French fries carbonization by fixing heat regulation
When using the French fries frying module, Godot would not regulate the heat
and thus bring the oil bath to supercritical liquid conditions, thus causing
unwanted side effects in the physics engine.
By fixing the regulation system via an added binding to the internal feature,
this commit now ensures that Godot will not go past the ebullition temperature
of cooking oil under normal atmospheric conditions.
```
**Note:** When using the GitHub online editor or its drag-and-drop
feature, *please* edit the commit title to something meaningful. Commits named
"Update my_file.cpp" won't be accepted.
### Document your changes
If your pull request adds methods, properties or signals that are exposed to
scripting APIs, you **must** update the class reference to document those.
This is to ensure the documentation coverage doesn't decrease as contributions
are merged.
[Update documentation XML files](https://docs.godotengine.org/en/latest/contributing/documentation/updating_the_class_reference.html)
using your compiled binary, then fill in the descriptions.
Follow the style guide described in the
[Documentation writing guidelines](https://docs.godotengine.org/en/latest/contributing/documentation/docs_writing_guidelines.html).
If your pull request modifies parts of the code in a non-obvious way, make sure
to add comments in the code as well. This helps other people understand the
change without having to dive into the Git history.
### Write unit tests
When fixing a bug or contributing a new feature, we recommend including unit
tests in the same commit as the rest of the pull request. Unit tests are pieces
of code that compare the output to a predetermined *expected result* to detect
regressions. Tests are compiled and run on GitHub Actions for every commit and
pull request.
Pull requests that include tests are more likely to be merged, since we can have
greater confidence in them not being the target of regressions in the future.
For bugs, the unit tests should cover the functionality that was previously
broken. If done well, this ensures regressions won't appear in the future
again. For new features, the unit tests should cover the newly added
functionality, testing both the "success" and "expected failure" cases if
applicable.
Feel free to contribute standalone pull requests to add new tests or improve
existing tests as well.
See [Unit testing](https://docs.godotengine.org/en/latest/contributing/development/core_and_modules/unit_testing.html)
for information on writing tests in Godot's C++ codebase.
## Contributing to Godot translations
You can contribute to Godot translations on [Hosted Weblate](https://hosted.weblate.org/projects/godot-engine/),
an open source and web-based translation platform.
Please refer to our [editor and documentation localization guidelines](https://docs.godotengine.org/en/latest/contributing/documentation/editor_and_docs_localization.html)
for an overview of the translation resources and what they correspond to.
## Communicating with developers
The Godot Engine community has [many communication
channels](https://godotengine.org/community), some used more for user-level
discussions and support, others more for development discussions.
To communicate with developers (e.g. to discuss a feature you want to implement
or a bug you want to fix), the following channels can be used:
- [Godot Contributors Chat](https://chat.godotengine.org): You will
find most core developers there, so it's the go-to platform for direct chat
about Godot Engine development. Browse the [Directory](https://chat.godotengine.org/directory/channels)
for an overview of public channels focusing on various engine areas which you
might be interested in.
- [Bug tracker](https://github.com/godotengine/godot/issues): If there is an
existing issue about a topic you want to discuss, you can participate directly.
If not, you can open a new issue. Please mind the guidelines outlined above
for bug reporting.
- [Feature proposals](https://github.com/godotengine/godot-proposals/issues):
To propose a new feature, we have a dedicated issue tracker for that. Don't
hesitate to start by talking about your idea on the Godot Contributors Chat
to make sure that it makes sense in Godot's context.
Thanks for your interest in contributing!
—The Godot development team
The Godot development team

File diff suppressed because it is too large Load Diff

516
DONORS.md
View File

@ -1,516 +0,0 @@
# Donors to the Godot Engine project
Godot Engine is a non-profit project developed by a community of voluntary
contributors, as well as occasional paid contributors thanks to the financial
support of generous donors.
The ways to donate to the project, as well as details on how the funds are
used, are described on [Godot's website](https://godotengine.org/donate).
The following is a list of the current monthly donors, who will have their
generous deed immortalized in the next stable release of Godot Engine.
## Patrons
OSS Capital <https://oss.capital/>
Re-Logic <https://re-logic.com/>
## Platinum sponsors
Google Play <https://play.google.com/>
Ramatak <https://ramatak.com/>
V-Sekai <https://github.com/V-Sekai>
W4 Games <https://w4games.com/>
## Gold sponsors
Mega Crit <https://www.megacrit.com/>
Pirate Software <https://gopiratesoftware.com/>
Prehensile Tales <https://prehensile-tales.com/>
Robot Gentleman <http://robotgentleman.com/>
## Silver sponsors
Broken Rules <https://brokenrul.es/>
Chasing Carrots <https://www.chasing-carrots.com/>
Copia Wealth Studios <https://copiawealthstudios.com/>
Indoor Astronaut <https://indoorastronaut.ch/>
Load Complete <https://loadcomplete.com/>
Null <https://null.com/>
Orbital Knight <https://www.orbitalknight.com/>
Playful Studios <https://playfulstudios.com/>
## Diamond members
Bippinbits <http://domekeepergame.com/>
Sealow
And 5 anonymous donors
## Titanium members
Adriaan de Jongh <https://adriaan.games/>
Anitya Space <https://www.anitya.space/>
Basically Games
FDG Entertainment <https://www.fdg-entertainment.com/>
Game Dev Artisan <https://gamedevartisan.com/>
Garry Newman
Isaiah Smith <https://www.isaiahsmith.dev/>
Libretrend <https://libretrend.com/>
Life Art Studios <https://lifeartstudios.net/>
Lucid Silence Games
Matthew Campbell
PolyMars <https://polymars.dev/>
RPG in a Box <https://www.rpginabox.com/>
Razenpok <https://www.youtube.com/watch?v=-QxI-RP6-HM>
Smirk Software <https://smirk.gg/>
粟二华 (Su Erhua)
And 6 anonymous donors
## Platinum members
Andy Touch
BlockImperiumGames (BIG)
Christoph Woinke
Christopher Shifflett
Cody Bentley
Darrin Massena
Edward Flick
GetIntoGameDev
HP van Braam
iCommitGames
Jonah Stich
katnamag
Marek Belski
Matthew Ekenstedt
Memories in 8Bit
Mike King
Neal Gompa (Conan Kudo)
Radivarig
Ronnie Cheng
Ryan Heath
Scott Pezza
ShikadiGum
Silver Creek Entertainment
SolarLabyrinth
Stephan Kessler
Stephan Lanfermann
TigerJ
Violin Iliev
Vladimír Chvátil
And 16 anonymous donors
## Gold members
80px
afreytes
alMoo Games
Alva Majo
Antti Vesanen
Asher Glick
Axthelm
Bellbird Studio
Benito
Benjamin Sarsgard
Ben Rog-Wilhelm
Bernd Barsuhn
BetaTester704
Brian Levinsen
Brut
Bryce Dixon
c64cosmin
Carlo del Mundo
Cindy Trieu
ClarkThyLord
Codex404
cora
Daniel Eichler
Daniel Krafft
David Chen Zhen
David Coles
David Hubber
David Snopek
Deakcor
Delton Ding
dfseifert
dgehrig
dhanielk
Distorted Realities
Dono
Don't You Know Who I Am? Inc.
Dustuu
Edelweiss
Ends
Eren Ogrul
Eric Brand
Eric Phy
Faisal Al-Kubaisi (QatariGameDev)
FeralBytes
Festzeltgaming.de
Gaudipern
GlassBrick
Grau
Guangzhou Lingchan
Hayden Oliver
hiulit
Illyan
Ivan Tabashki
Jacob (HACKhalo2 Studios)
Jam
Jason Cawood
Javier Roman
Jeff Hungerford
Jeronimo Schreyer
Joel Martinez
Johannes Wuensch
John Gabriel
Jonas Yamazaki
José Canepa
Joshua Stelly
Justin Sasso
Kalydi Balázs
KAR Games
Kiri "ExpiredPopsicle" Artemis
KOGA Mitsuhiro (@shiena)
korinVR
Kristian Kriehl
Lars Thießen
Lisandro Lorea (Red Mage Games)
Logan Apple
Luca Junge
LyaaaaaGames
m1n1ster
Manuel Requena
Mara Huldra
Martin Šenkeřík
Michael Gooch
Modus Ponens
Moshe Harris
Moth
Mr. Byte
Nassor Paulino da Silva
nezticle
Niklas Wahrman
Niwl Games
NotNet
Oathbringer
Officine Pixel
ohanaya3
Okatima AB
Oleksii Nosov
Osirisa
Patrick Traynor
Petr Malac
pirey
Rafa Laguna
@reilaos
Request
re:thinc
Richard Ivánek
Rudi P
Samuel Judd
ScoreSpace
Shiny Shinken
Silverclad Studios
Sofox
Space Kraken Studios
spacesloth
Spoony Panda
TANAKA Yu
TaraSophieDev (pls fix #43093)
Thad Guidry
ThatGamer
The Polyglot Programmer
TheRiverNyx
Thomas Lobig
Tim Nedvyga
Tom Langwaldt
Trevor Slocum
tukon
Tyler C
Vagastella
Vincent Foulon
Vojtech Lacina
Watchinofoye
Weasel Games
Wilson Birney
Wolfram
WuotanStudios.com
Zhu Li
zikes
嗯大爷
Alex Khayrullin
Algebrute
Andriy
Antanas Paskauskas
anti666
Ari
Arisaka Mayuki
Arthur S. Muszynski
Cameron Connolly
Charlie Whitfield
Craig Ostrin
Craig Swain
CzechBlueBear
Dennis Belfrage
Emily A. Bellows
Felix Winterhalter
Fransiska
Harry Tumber
James Couzens
Jared White
Jesús Chicharro
Joel Fivat
Johnathan Kupferer
Josef Stumpfegger
Joshua Lesperance
Kelteseth
kickmaniac
Liam Smyth
LoparPanda
Martin Gulliksson
Martin Soucek
Michael Dürwald
Michael Policastro
n00sh
Nicolás Monner Sans
Nikita Rotskov
Nikola Whallon
Oliver Dick
Patrick Wuttke
Pete Goodwin
Philip Woods
Reilt
Rickard Hermanson
Rob
Rob McInroy
RodZilla
Ruzgud
Ryan Breaker
"Sage Automatic Systems, LLC"
spacechase0
sus
Thomas Kurz
Tobias Bocanegra
Torbulous
toto bibi
Valryia
VoidPointer
Yifan Lai
Aaron Mayfield
Adam Carr
Adam Smeltzer
Adisibio
Aidan Marwick
Aidan O'Flannagain
AJWolbers
Alan Beauchamp
Alexander Erlemann
Alex Clavelle
alex raeside
Andre Altmueller
Andreas Østergaard Nielsen
Andrew
Ano Nim
Arch Toasty
Arda Erol
A Really Tall Horse
Arturo Rosales
Ash K
Aubrey Falconer
Austin Miller
AzulCrescent
Beau Seymour
Benedikt
Bread
Brian Ford
Caleb Makela
Cameron Meyer
Carl van der Geest
Checkpoint Charlie
Chris Cavalluzzi
Chris Jagusch
Chris Lee
Christian Mauduit
Christian Ringshofer
Christoph Czurda
Christophe Gagnier
Cody Parker
Conall O
Corchari
Corey W
Dakota Watkins
Daniele Tolomelli
Daniel Ramos
Dave Jansen
Davesnothere
David Baker
David Bôle
David May
David Maziarka
Devin Carraway
Devin R
Dimitri Roche
Donovan Hutcheon
Ducky
Duodecimal
Egon Elbre
Elijah Anderson
Eric Persson
Eric Stokes
Eric Williams
Erkki Seppälä
Ewan Holmes
Felix Adam
Frank
Frying☆Pan
Game Endeavor
gamerminstrel
Gary Thomas
gebba
Greyson Richey
Guo Hongci
Haplo
Helge Maus
Heribert Hirth
Ian Richard Kunert
Ian Williams
itsybitesyspider
iveks
Jacob Wallace
Jako Danar
James Gary
James Hulsizer
Jamie Massey
JARKKO PARVIAINEN
Jason Evans
Joakim Askenbäck
Jonas
Jonas Arndt
Jonas Yamazaki
Jonathan Bieber
Jon Sully
Joseph Catrambone
Josh Taylor
Juanfran
Julian le Roux
Justin Spedding
Keith Bradner
kindzadza
KsyTek Games
Kyle Burnett
Kyle Haltermann
Kyle Jacobs
Leland Vakarian
Levi Berciu
liberodark
Linus Lind Lundgren
Ludovic DELVAL
Luigi Renna
Luis Morao
Lukas Komischke
Luke Diasio
Major Haul
Malcolm
Manuele Finocchiaro
Marcos Heitor Carvalho
Markie Music
Mark Tyler
Markus Michael Egger
Martin Holas
Martin Liška
Martin Trbola
Matěj Drábek
Mathieu
Matt Edwards
Maverick
Maxime Blade
Maxwell
Melissa Mears
Metal Demon 2000
Michael Morrison
Mike Copley
Molly Jameson
Moritz Weissenberger
Mrjemandem
naonya3
Nathaniel
neighty
Neil Blakey-Milner
Neofytos Chimonas
Nerdforge
Nerdyninja
Nick Eldrenkamp
Nik Rudenko
Noel Billig
ozrk
Patrick Horn
Patrickm
Patrick Nafarrete
Paul Black
Paul Gieske
Paul Mozet
Pete
Phoenix Jauregui
Pierre Caye
Pixel Archipel
Point08
PsycHead
Quincy Quincy
Quinn Morrison
Raghava Kovvali
Ragnar Pettersson
Rammeow
Rebecca H
Richard Hayes
Riley
RobotCritter
Roland Rząsa
Russ
Ryan Groom
Sammy Fischer
Satnam Singh
Sebastian Michailidis
SeongWan Kim
Shane Lillie
Shane Spoor
Shaun Kohanowski
Simon Jonas Larsen
Simon Schoenenberger
Sina Yeganeh
Skalli
slavfox
smo1704
SpicyCactuar
Stephen Rice
Stephen Schlie
Sven Walter
SxP
tadashi endo
Tarch
TheVoiceInMyHead
Thibaut DECROMBECQUE
thomas
Thomas Pickett
Tim Drumheller
Tim Klein
Tom Webster
Trent Skinner
Tyler Stepke
Uther
Vaughan Ling
vlnx
Wapiti .
Wiley Thompson
Xatonym
Zekim
ケルベロス
貴宏 小松
And 181 anonymous donors
## Silver and bronze donors
There are even more donors that support the project with a small monthly donation.
Every bit counts and we thank every one of them for their amazing support!

10
ISSUE_TEMPLATE Normal file
View File

@ -0,0 +1,10 @@
**Operating system or device:**
**Issue description** (what happened, and what was expected):
**Steps to reproduce:**
**Link to minimal example project** (optional but very welcome):

27
LICENSE.md Normal file
View File

@ -0,0 +1,27 @@
GODOT ENGINE
http://www.godotengine.org
************************************************************************
Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur.
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.
************************************************************************

View File

@ -1,20 +0,0 @@
Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md).
Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.
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.

2
LOGO_LICENSE.md Normal file
View File

@ -0,0 +1,2 @@
Godot Logo (c) Andrea Calabró, distributed under the terms of the CC By License:
https://creativecommons.org/licenses/by/3.0/legalcode

View File

@ -1,5 +0,0 @@
Godot Engine Logo
Copyright (c) 2017 Andrea Calabró
This work is licensed under the Creative Commons Attribution 4.0 International
license (CC BY 4.0 International): https://creativecommons.org/licenses/by/4.0/

View File

@ -1,78 +1,29 @@
# Godot Engine
![GODOT](/logo.png)
<p align="center">
<a href="https://godotengine.org">
<img src="logo_outlined.svg" width="400" alt="Godot Engine logo">
</a>
</p>
http://www.godotengine.org
## 2D and 3D cross-platform game engine
### The Engine
**[Godot Engine](https://godotengine.org) is a feature-packed, cross-platform
game engine to create 2D and 3D games from a unified interface.** It provides a
comprehensive set of [common tools](https://godotengine.org/features), so that
users can focus on making games without having to reinvent the wheel. Games can
be exported with one click to a number of platforms, including the major desktop
platforms (Linux, macOS, Windows), mobile platforms (Android, iOS), as well as
Web-based platforms and [consoles](https://docs.godotengine.org/en/latest/tutorials/platform/consoles.html).
Godot is a fully featured, open source, MIT licensed, game engine. It focuses on having great tools, and a visual oriented workflow that can export to PC, Mobile and Web platforms with no hassle.
The editor, language and APIs are feature rich, yet simple to learn, allowing you to become productive in a matter of hours.
## Free, open source and community-driven
### About
Godot is completely free and open source under the very permissive [MIT license](https://godotengine.org/license).
No strings attached, no royalties, nothing. The users' games are theirs, down
to the last line of engine code. Godot's development is fully independent and
community-driven, empowering users to help shape their engine to match their
expectations. It is supported by the [Godot Foundation](https://godot.foundation/)
not-for-profit.
Godot has been developed by Juan Linietsky and Ariel Manzur for several years, and was born as an in-house engine, used to publish several work-for-hire titles. Godot is a member project of the [Software Freedom Conservancy](https://sfconservancy.org)
Before being open sourced in [February 2014](https://github.com/godotengine/godot/commit/0b806ee0fc9097fa7bda7ac0109191c9c5e0a1ac),
Godot had been developed by [Juan Linietsky](https://github.com/reduz) and
[Ariel Manzur](https://github.com/punto-) (both still maintaining the project)
for several years as an in-house engine, used to publish several work-for-hire
titles.
### Documentation
![Screenshot of a 3D scene in the Godot Engine editor](https://raw.githubusercontent.com/godotengine/godot-design/master/screenshots/editor_tps_demo_1920x1080.jpg)
Documentation has been moved to [ReadTheDocs](http://docs.godotengine.org).
## Getting the engine
### Binary Downloads, Community, etc.
### Binary downloads
Binary downloads, community, etc. can be found in Godot homepage:
Official binaries for the Godot editor and the export templates can be found
[on the Godot website](https://godotengine.org/download).
http://www.godotengine.org
### Compiling from source
### Compiling from Source
[See the official docs](https://docs.godotengine.org/en/latest/contributing/development/compiling)
for compilation instructions for every supported platform.
Compilation instructions for every platform can be found in the Wiki:
http://docs.godotengine.org/en/latest/reference/_compiling.html
## Community and contributing
Godot is not only an engine but an ever-growing community of users and engine
developers. The main community channels are listed [on the homepage](https://godotengine.org/community).
The best way to get in touch with the core engine developers is to join the
[Godot Contributors Chat](https://chat.godotengine.org).
To get started contributing to the project, see the [contributing guide](CONTRIBUTING.md).
This document also includes guidelines for reporting bugs.
## Documentation and demos
The official documentation is hosted on [Read the Docs](https://docs.godotengine.org).
It is maintained by the Godot community in its own [GitHub repository](https://github.com/godotengine/godot-docs).
The [class reference](https://docs.godotengine.org/en/latest/classes/)
is also accessible from the Godot editor.
We also maintain official demos in their own [GitHub repository](https://github.com/godotengine/godot-demo-projects)
as well as a list of [awesome Godot community resources](https://github.com/godotengine/awesome-godot).
There are also a number of other
[learning resources](https://docs.godotengine.org/en/latest/community/tutorials.html)
provided by the community, such as text and video tutorials, demos, etc.
Consult the [community channels](https://godotengine.org/community)
for more information.
[![Code Triagers Badge](https://www.codetriage.com/godotengine/godot/badges/users.svg)](https://www.codetriage.com/godotengine/godot)
[![Translate on Weblate](https://hosted.weblate.org/widgets/godot-engine/-/godot/svg-badge.svg)](https://hosted.weblate.org/engage/godot-engine/?utm_source=widget)
[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/godotengine/godot)](https://www.tickgit.com/browse?repo=github.com/godotengine/godot)
[![Build Status](https://travis-ci.org/godotengine/godot.svg?branch=master)](https://travis-ci.org/godotengine/godot)

1406
SConstruct

File diff suppressed because it is too large Load Diff

4
bin/SCsub Normal file
View File

@ -0,0 +1,4 @@
Import('env')
Export('env')
SConscript('tests/SCsub');

12
bin/tests/SCsub Normal file
View File

@ -0,0 +1,12 @@
Import('env')
env.tests_sources=[]
env.add_source_files(env.tests_sources,"*.cpp")
Export('env')
#SConscript('math/SCsub');
lib = env.Library("tests",env.tests_sources)
env.Prepend(LIBS=[lib])

View File

@ -0,0 +1,107 @@
/*************************************************************************/
/* test_containers.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_containers.h"
#include "dvector.h"
#include "set.h"
#include "print_string.h"
#include "math_funcs.h"
#include "servers/visual/default_mouse_cursor.xpm"
#include "variant.h"
#include "list.h"
#include "image.h"
namespace TestContainers {
MainLoop * test() {
/*
HashMap<int,int> int_map;
for (int i=0;i<68000;i++) {
int num=(int)Math::random(0,1024);
int_map[i]=num;
}
*/
{
// static const int size = 16;
Image img;
img.create(default_mouse_cursor_xpm);
{
for (int i=0; i<8; i++) {
Image mipmap;
//img.make_mipmap(mipmap);
img = mipmap;
if (img.get_width() <= 4) break;
};
};
};
#if 0
Set<int> set;
print_line("Begin Insert");
for (int i=0;i<1100;i++) {
int num=i;//(int)Math::random(0,1024);
// print_line("inserting "+itos(num));
set.insert( num );
}
/*
for (int i=0;i<400;i++) {
int num=(int)Math::random(0,1024);
set.erase(num);
}
*/
//set.print_tree();
for(Set<int>::Element *I=set.front();I;I=I->next()) {
print_line("inserted "+itos(I->get())+" prev is "+itos(I->prev()?I->prev()->get():-100));
}
print_line("depth is "+itos(set.calculate_depth()));
print_line("Insert Success");
#endif
return NULL;
}
}

View File

@ -0,0 +1,43 @@
/*************************************************************************/
/* test_containers.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_CONTAINERS_H
#define TEST_CONTAINERS_H
#include "os/main_loop.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
namespace TestContainers {
MainLoop * test();
}
#endif

217
bin/tests/test_detailer.cpp Normal file
View File

@ -0,0 +1,217 @@
/*************************************************************************/
/* test_detailer.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_detailer.h"
#include "servers/visual_server.h"
#include "os/main_loop.h"
#include "math_funcs.h"
#include "print_string.h"
#include "geometry.h"
#include "quick_hull.h"
namespace TestMultiMesh {
class TestMainLoop : public MainLoop {
RID instance;
RID camera;
RID viewport;
RID light;
RID mesh;
RID scenario;
#define MULTIMESH_COUNT 1500
float ofs_x,ofs_y;
bool quit;
public:
virtual void _update_qh() {
VisualServer *vs=VisualServer::get_singleton();
Vector<Vector3> vts;
/*
static const int s = 20;
for(int i=0;i<s;i++) {
Matrix3 rot(Vector3(0,1,0),i*Math_PI/s);
for(int j=0;j<s;j++) {
Vector3 v;
v.x=Math::sin(j*Math_PI*2/s);
v.y=Math::cos(j*Math_PI*2/s);
vts.push_back( rot.xform(v*2 ) );
}
}*/
/*
Math::seed(0);
for(int i=0;i<50;i++) {
vts.push_back( Vector3(Math::randf()*2-1.0,Math::randf()*2-1.0,Math::randf()*2-1.0).normalized()*2);
}*/
/*
vts.push_back(Vector3(0,0,1));
vts.push_back(Vector3(0,0,-1));
vts.push_back(Vector3(0,1,0));
vts.push_back(Vector3(0,-1,0));
vts.push_back(Vector3(1,0,0));
vts.push_back(Vector3(-1,0,0));*/
/*
vts.push_back(Vector3(1,1,1));
vts.push_back(Vector3(1,-1,1));
vts.push_back(Vector3(-1,1,1));
vts.push_back(Vector3(-1,-1,1));
vts.push_back(Vector3(1,1,-1));
vts.push_back(Vector3(1,-1,-1));
vts.push_back(Vector3(-1,1,-1));
vts.push_back(Vector3(-1,-1,-1));
*/
DVector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5,0.7,4,Vector3::AXIS_Z);
Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes);
vts=convex_data.vertices;
Geometry::MeshData md;
Error err = QuickHull::build(vts,md);
print_line("ERR: "+itos(err));
vs->mesh_remove_surface(mesh,0);
vs->mesh_add_surface_from_mesh_data(mesh,md);
//vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME);
/*
RID sm = vs->shader_create();
//vs->shader_set_fragment_code(sm,"OUT_ALPHA=mod(TIME,1);");
//vs->shader_set_vertex_code(sm,"OUT_VERTEX=IN_VERTEX*mod(TIME,1);");
vs->shader_set_fragment_code(sm,"OUT_DIFFUSE=vec3(1,0,1);OUT_GLOW=abs(sin(TIME));");
RID tcmat = vs->mesh_surface_get_material(test_cube,0);
vs->material_set_shader(tcmat,sm);
*/
}
virtual void input_event(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&4) {
ofs_x+=p_event.mouse_motion.relative_y/200.0;
ofs_y+=p_event.mouse_motion.relative_x/200.0;
}
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index==1) {
QuickHull::debug_stop_after++;
_update_qh();
}
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index==2) {
if (QuickHull::debug_stop_after>0)
QuickHull::debug_stop_after--;
_update_qh();
}
}
virtual void request_quit() {
quit=true;
}
virtual void init() {
VisualServer *vs=VisualServer::get_singleton();
mesh = vs->mesh_create();
scenario = vs->scenario_create();
QuickHull::debug_stop_after=0;
_update_qh();
instance = vs->instance_create2(mesh,scenario);
camera = vs->camera_create();
vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
viewport = vs->viewport_create();
vs->viewport_attach_camera( viewport, camera );
vs->viewport_attach_to_screen(viewport);
vs->viewport_set_scenario( viewport, scenario );
vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,0,2 ) ) );
RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.3,0.3,0.3) );
light = vs->instance_create2( lightaux,scenario );
vs->instance_set_transform(light,Transform(Matrix3(Vector3(0.1,0.4,0.7).normalized(),0.9)));
ofs_x=0;
ofs_y=0;
quit=false;
}
virtual bool idle(float p_time) {
return false;
}
virtual bool iteration(float p_time) {
VisualServer *vs=VisualServer::get_singleton();
Transform tr_camera;
tr_camera.rotate( Vector3(0,1,0), ofs_y );
tr_camera.rotate( Vector3(1,0,0),ofs_x );
tr_camera.translate(0,0,10);
vs->camera_set_transform( camera, tr_camera );
return quit;
}
virtual void finish() {
}
};
MainLoop* test() {
return memnew(TestMainLoop);
}
}

44
bin/tests/test_detailer.h Normal file
View File

@ -0,0 +1,44 @@
/*************************************************************************/
/* test_detailer.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_MULTIMESH_H
#define TEST_MULTIMESH_H
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
#include "os/main_loop.h"
namespace TestMultiMesh {
MainLoop* test();
}
#endif

1042
bin/tests/test_gdscript.cpp Normal file

File diff suppressed because it is too large Load Diff

47
bin/tests/test_gdscript.h Normal file
View File

@ -0,0 +1,47 @@
/*************************************************************************/
/* test_gdscript.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_GDSCRIPT_H
#define TEST_GDSCRIPT_H
#include "os/main_loop.h"
namespace TestGDScript {
enum TestType {
TEST_TOKENIZER,
TEST_PARSER,
TEST_COMPILER,
TEST_BYTECODE,
};
MainLoop* test(TestType p_type);
}
#endif // TEST_GDSCRIPT_H

402
bin/tests/test_gui.cpp Normal file
View File

@ -0,0 +1,402 @@
/*************************************************************************/
/* test_gui.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 _3D_DISABLED
#include "test_gui.h"
#include "scene/main/scene_main_loop.h"
#include "os/os.h"
#include "scene/gui/control.h"
#include "scene/gui/button.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
#include "scene/gui/scroll_bar.h"
#include "scene/gui/popup_menu.h"
#include "scene/gui/option_button.h"
#include "scene/gui/spin_box.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/progress_bar.h"
#include "scene/gui/panel.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tree.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/texture_frame.h"
#include "io/image_loader.h"
#include "print_string.h"
#include "scene/2d/sprite.h"
#include "scene/main/viewport.h"
#include "scene/3d/camera.h"
#include "scene/3d/test_cube.h"
namespace TestGUI {
class TestMainLoop : public SceneTree {
Control *control;
public:
virtual void request_quit() {
quit();
}
virtual void init() {
SceneTree::init();
#if 0
Viewport *vp = memnew( Viewport );
vp->set_world( Ref<World>( memnew( World )));
get_root()->add_child(vp);
vp->set_rect(Rect2(0,0,256,256));
vp->set_as_render_target(true);
vp->set_render_target_update_mode(Viewport::RENDER_TARGET_UPDATE_ALWAYS);
Camera *camera = memnew( Camera );
vp->add_child(camera);
camera->make_current();
TestCube *testcube = memnew( TestCube );
vp->add_child(testcube);
testcube->set_transform(Transform( Matrix3().rotated(Vector3(0,1,0),Math_PI*0.25), Vector3(0,0,-8)));
Sprite *sp = memnew( Sprite );
sp->set_texture( vp->get_render_target_texture() );
// sp->set_texture( ResourceLoader::load("res://ball.png") );
sp->set_pos(Point2(300,300));
get_root()->add_child(sp);
return;
#endif
Panel * frame = memnew( Panel );
frame->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
frame->set_anchor( MARGIN_BOTTOM, Control::ANCHOR_END );
frame->set_end( Point2(0,0) );
Ref<Theme> t = memnew( Theme );
frame->set_theme(t);
get_root()->add_child( frame );
Label *label = memnew( Label );
label->set_pos( Point2( 80,90 ) );
label->set_size( Point2( 170,80 ) );
label->set_align( Label::ALIGN_FILL );
//label->set_text("There");
label->set_text("There was once upon a time a beautiful unicorn that loved to play with little girls...");
frame->add_child(label);
Button *button = memnew( Button );
button->set_pos( Point2( 20,20 ) );
button->set_size( Point2( 1,1 ) );
button->set_text("This is a biggie button");
frame->add_child( button );
#if 0
Sprite *tf = memnew( Sprite );
frame->add_child(tf);
Image img;
ImageLoader::load_image("LarvoClub.png",&img);
img.resize(512,512);
img.generate_mipmaps();
img.compress(Image::COMPRESS_PVRTC4);
Ref<ImageTexture> tt = memnew( ImageTexture );
tt->create_from_image(img);
tf->set_texture(tt);
tf->set_pos(Point2(50,50));
//tf->set_scale(Point2(0.3,0.3));
return;
#endif
Tree * tree = memnew( Tree );
tree->set_columns(2);
tree->set_pos( Point2( 230,210 ) );
tree->set_size( Point2( 150,250 ) );
TreeItem *item = tree->create_item();
item->set_editable(0,true);
item->set_text(0,"root");
item = tree->create_item( tree->get_root() );
item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
item->set_editable(0,true);
item->set_text(0,"check");
item->set_cell_mode(1, TreeItem::CELL_MODE_CHECK);
item->set_editable(1,true);
item->set_text(1,"check2");
item = tree->create_item( tree->get_root() );
item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
item->set_editable(0,true);
item->set_range_config(0,0,20,0.1);
item->set_range(0,2);
item->add_button(0,Theme::get_default()->get_icon("folder","FileDialog"));
item->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
item->set_editable(1,true);
item->set_range_config(1,0,20,0.1);
item->set_range(1,3);
item = tree->create_item( tree->get_root() );
item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
item->set_editable(0,true);
item->set_text(0,"Have,Many,Several,Options!");
item->set_range(0,2);
item = tree->create_item( item );
item->set_editable(0,true);
item->set_text(0,"Gershwin!");
frame->add_child(tree);
//control = memnew( Control );
//root->add_child( control );
LineEdit *line_edit = memnew( LineEdit );
line_edit->set_pos( Point2( 30,190 ) );
line_edit->set_size( Point2( 180,1 ) );
frame->add_child(line_edit);
HScrollBar *hscroll = memnew( HScrollBar );
hscroll->set_pos( Point2( 30,290 ) );
hscroll->set_size( Point2( 180,1 ) );
hscroll->set_max(10);
hscroll->set_page(4);
frame->add_child(hscroll);
SpinBox *spin = memnew( SpinBox );
spin->set_pos( Point2( 30,260 ) );
spin->set_size( Point2( 120,1 ) );
frame->add_child(spin);
hscroll->share(spin);
ProgressBar *progress = memnew( ProgressBar );
progress->set_pos( Point2( 30,330 ) );
progress->set_size( Point2( 120,1 ) );
frame->add_child(progress);
hscroll->share(progress);
MenuButton *menu_button = memnew( MenuButton );
menu_button->set_text("I'm a menu!");
menu_button->set_pos( Point2( 30,380 ) );
menu_button->set_size( Point2( 1,1 ) );
frame->add_child(menu_button);
PopupMenu *popup = menu_button->get_popup();
popup->add_item("Hello, testing");
popup->add_item("My Dearest");
popup->add_separator();
popup->add_item("Popup");
popup->add_check_item("Check Popup");
popup->set_item_checked(4,true);
OptionButton *options = memnew( OptionButton );
options->add_item("Hello, testing");
options->add_item("My Dearest");
options->set_pos( Point2( 230,180 ) );
options->set_size( Point2( 1,1 ) );
frame->add_child(options);
/*
Tree * tree = memnew( Tree );
tree->set_columns(2);
tree->set_pos( Point2( 230,210 ) );
tree->set_size( Point2( 150,250 ) );
TreeItem *item = tree->create_item();
item->set_editable(0,true);
item->set_text(0,"root");
item = tree->create_item( tree->get_root() );
item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
item->set_editable(0,true);
item->set_text(0,"check");
item = tree->create_item( tree->get_root() );
item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
item->set_editable(0,true);
item->set_range_config(0,0,20,0.1);
item->set_range(0,2);
item->add_button(0,Theme::get_default()->get_icon("folder","FileDialog"));
item = tree->create_item( tree->get_root() );
item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE);
item->set_editable(0,true);
item->set_text(0,"Have,Many,Several,Options!");
item->set_range(0,2);
frame->add_child(tree);
*/
RichTextLabel *richtext = memnew( RichTextLabel );
richtext->set_pos( Point2( 600,210 ) );
richtext->set_size( Point2( 180,250 ) );
richtext->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,20);
frame->add_child(richtext);
richtext->add_text("Hello, My Friends!\n\nWelcome to the amazing world of ");
richtext->add_newline();
richtext->add_newline();
richtext->push_color(Color(1,0.5,0.5));
richtext->add_text("leprechauns");
richtext->pop();
richtext->add_text(" and ");
richtext->push_color(Color(0,1.0,0.5));
richtext->add_text("faeries.\n");
richtext->pop();
richtext->add_text("In this new episode, we will attemp to ");
richtext->push_font(richtext->get_font("mono_font","Fonts"));
richtext->push_color(Color(0.7,0.5,1.0));
richtext->add_text("deliver something nice");
richtext->pop();
richtext->pop();
richtext->add_text(" to all the viewers! Unfortunately, I need to ");
richtext->push_underline();
richtext->add_text("keep writing a lot of text");
richtext->pop();
richtext->add_text(" so the label control overflows and the scrollbar appears.\n");
//richtext->push_indent(1);
//richtext->add_text("By the way, testing indent levels! Yohohoho! Everything should appear to the right sightly here!\n");
//richtext->pop();
richtext->push_meta("http://www.scrollingcapabilities.xz");
richtext->add_text("This allows to test for the scrolling capabilities ");
richtext->pop();
richtext->add_text("of the rich text label for huge text (not like this text will really be huge but, you know).\nAs long as it is so long that it will work nicely for a test/demo, then it's welcomed in my book...\nChanging subject, the day is cloudy today and I'm wondering if I'll get che chance to travel somewhere nice. Sometimes, watching the clouds from satellite images may give a nice insight about how pressure zones in our planet work, althogh it also makes it pretty obvious to see why most weather forecasts get it wrong so often.\nClouds are so difficult to predict!\nBut it's pretty cool how our civilization has adapted to having water falling from the sky each time it rains...");
//richtext->add_text("Hello!\nGorgeous..");
//richtext->push_meta("http://www.scrollingcapabilities.xz");
///richtext->add_text("Hello!\n");
//richtext->pop();
richtext->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END);
TabContainer * tabc = memnew( TabContainer );
Control *ctl= memnew( Control );
ctl->set_name("tab 1");
tabc->add_child(ctl);
ctl= memnew( Control );
ctl->set_name("tab 2");
tabc->add_child(ctl);
label = memnew( Label );
label->set_text("Some Label");
label->set_pos( Point2(20,20) );
ctl->add_child(label);;
ctl= memnew( Control );
ctl->set_name("tab 3");
button = memnew( Button );
button->set_text("Some Button");
button->set_pos( Point2(30,50) );
ctl->add_child(button);;
tabc->add_child(ctl);
frame->add_child(tabc);
tabc->set_pos( Point2( 400,210 ) );
tabc->set_size( Point2( 180,250 ) );
Ref<ImageTexture> text = memnew( ImageTexture );
text->load("test_data/concave.png");
Sprite* sprite = memnew(Sprite);
sprite->set_texture(text);
sprite->set_pos(Point2(300, 300));
frame->add_child(sprite);
sprite->show();
Sprite* sprite2 = memnew(Sprite);
sprite->set_texture(text);
sprite->add_child(sprite2);
sprite2->set_pos(Point2(50, 50));
sprite2->show();
}
};
MainLoop* test() {
return memnew( TestMainLoop );
}
}
#endif

44
bin/tests/test_gui.h Normal file
View File

@ -0,0 +1,44 @@
/*************************************************************************/
/* test_gui.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_GUI_H
#define TEST_GUI_H
#include "os/main_loop.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
namespace TestGUI {
MainLoop* test();
}
#endif

77
bin/tests/test_image.cpp Normal file
View File

@ -0,0 +1,77 @@
/*************************************************************************/
/* test_image.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_image.h"
#include "os/main_loop.h"
#include "math_funcs.h"
#include "print_string.h"
#include "io/image_loader.h"
namespace TestImage {
class TestMainLoop : public MainLoop {
bool quit;
public:
virtual void input_event(const InputEvent& p_event) {
}
virtual void init() {
quit=false;
}
virtual bool iteration(float p_time) {
return quit;
}
virtual bool idle(float p_time) {
return quit;
}
virtual void finish() {
}
};
MainLoop* test() {
Image img;
ImageLoader::load_image("as1.png",&img);
img.resize(512,512);
return memnew( TestMainLoop );
}
}

44
bin/tests/test_image.h Normal file
View File

@ -0,0 +1,44 @@
/*************************************************************************/
/* test_image.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_IMAGE_H
#define TEST_IMAGE_H
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
#include "os/main_loop.h"
namespace TestImage {
MainLoop* test();
}
#endif

208
bin/tests/test_io.cpp Normal file
View File

@ -0,0 +1,208 @@
/*************************************************************************/
/* test_io.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_io.h"
#ifdef MINIZIP_ENABLED
#include "os/main_loop.h"
#include "os/os.h"
#include "scene/resources/texture.h"
#include "print_string.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
#include "core/globals.h"
#include "io/file_access_memory.h"
namespace TestIO {
class TestMainLoop : public MainLoop {
bool quit;
public:
virtual void input_event(const InputEvent& p_event) {
}
virtual bool idle(float p_time) {
return false;
}
virtual void request_quit() {
quit=true;
}
virtual void init() {
quit=true;
}
virtual bool iteration(float p_time) {
return quit;
}
virtual void finish() {
}
};
MainLoop* test() {
print_line("this is test io");
DirAccess* da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->change_dir(".");
print_line("Opening current dir "+ da->get_current_dir());
String entry;
da->list_dir_begin();
while ( (entry = da->get_next()) != "") {
print_line("entry "+entry+" is dir: " + Variant(da->current_is_dir()));
};
da->list_dir_end();
RES texture = ResourceLoader::load("test_data/rock.png");
ERR_FAIL_COND_V(texture.is_null(), NULL);
ResourceSaver::save("test_data/rock.xml",texture);
print_line("localize paths");
print_line(Globals::get_singleton()->localize_path("algo.xml"));
print_line(Globals::get_singleton()->localize_path("c:\\windows\\algo.xml"));
print_line(Globals::get_singleton()->localize_path(Globals::get_singleton()->get_resource_path()+"/something/something.xml"));
print_line(Globals::get_singleton()->localize_path("somedir/algo.xml"));
{
FileAccess* z = FileAccess::open("test_data/archive.zip", FileAccess::READ);
int len = z->get_len();
Vector<uint8_t> zip;
zip.resize(len);
z->get_buffer(&zip[0], len);
z->close();
memdelete(z);
FileAccessMemory::register_file("a_package", zip);
FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_RESOURCES);
FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_FILESYSTEM);
FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_USERDATA);
print_line("archive test");
#if 0
Archive arch;
Archive::get_singleton()->add_package("a_package");
FileAccessArchive f;
print_line("opening for read");
f._open("file.txt", FileAccess::READ);
int pos = f.get_pos();
printf("file has %i bytes, initial pos %i\n", (int)f.get_len(), pos);
do {
printf("%c", f.get_8());
} while (!f.eof_reached());
print_line("opening for stored seek");
f.open("seek.bin", FileAccess::READ);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.seek(128);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
print_line("opening for deflated seek");
f.open("seek_deflated.bin", FileAccess::READ);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.seek(128);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.seek(256);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.seek(4);
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
pos = f.get_pos();
printf("byte at pos %i is %i\n", pos, (int)f.get_8());
f.close();
DirAccessArchive d;
String dir = "../blah1/blah2/blahask/../blah3/.//blah4/";
printf("changing dir to %s\n", dir.utf8().get_data());
d.change_dir(dir);
printf("current dir is %s\n", d.get_current_dir().utf8().get_data());
FileAccessMemory::cleanup();
#endif
};
print_line("test done");
return memnew( TestMainLoop );
}
}
#else
namespace TestIO {
MainLoop* test() {
return NULL;
}
}
#endif

44
bin/tests/test_io.h Normal file
View File

@ -0,0 +1,44 @@
/*************************************************************************/
/* test_io.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_IO_H
#define TEST_IO_H
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
#include "os/main_loop.h"
namespace TestIO {
MainLoop* test();
}
#endif

198
bin/tests/test_main.cpp Normal file
View File

@ -0,0 +1,198 @@
/*************************************************************************/
/* test_main.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "list.h"
#include "os/main_loop.h"
#ifdef DEBUG_ENABLED
#include "test_string.h"
#include "test_containers.h"
#include "test_math.h"
#include "test_gui.h"
#include "test_render.h"
#include "test_sound.h"
#include "test_misc.h"
#include "test_physics.h"
#include "test_physics_2d.h"
#include "test_python.h"
#include "test_io.h"
#include "test_particles.h"
#include "test_detailer.h"
#include "test_shader_lang.h"
#include "test_gdscript.h"
#include "test_image.h"
const char ** tests_get_names() {
static const char* test_names[]={
"string",
"containers",
"math",
"render",
"particles",
"multimesh",
"gui",
"io",
"shaderlang",
"physics",
NULL
};
return test_names;
}
MainLoop* test_main(String p_test,const List<String>& p_args) {
if (p_test=="string") {
return TestString::test();
}
if (p_test=="containers") {
return TestContainers::test();
}
if (p_test=="math") {
return TestMath::test();
}
if (p_test=="physics") {
return TestPhysics::test();
}
if (p_test=="physics_2d") {
return TestPhysics2D::test();
}
if (p_test=="misc") {
return TestMisc::test();
}
if (p_test=="render") {
return TestRender::test();
}
#ifndef _3D_DISABLED
if (p_test=="gui") {
return TestGUI::test();
}
#endif
if (p_test=="sound") {
return TestSound::test();
}
if (p_test=="io") {
return TestIO::test();
}
if (p_test=="particles") {
return TestParticles::test();
}
if (p_test=="multimesh") {
return TestMultiMesh::test();
}
if (p_test=="shaderlang") {
return TestShaderLang::test();
}
if (p_test=="gd_tokenizer") {
return TestGDScript::test(TestGDScript::TEST_TOKENIZER);
}
if (p_test=="gd_parser") {
return TestGDScript::test(TestGDScript::TEST_PARSER);
}
if (p_test=="gd_compiler") {
return TestGDScript::test(TestGDScript::TEST_COMPILER);
}
if (p_test=="gd_bytecode") {
return TestGDScript::test(TestGDScript::TEST_BYTECODE);
}
if (p_test=="image") {
return TestImage::test();
}
if (p_test=="detailer") {
return TestMultiMesh::test();
}
#ifdef PYTHON_ENABLED
if (p_test=="python") {
return TestPython::test();
}
#endif
return NULL;
}
#else
const char ** tests_get_names() {
static const char* test_names[]={
NULL
};
return test_names;
}
MainLoop* test_main(String p_test,const List<String>& p_args) {
return NULL;
}
#endif

41
bin/tests/test_main.h Normal file
View File

@ -0,0 +1,41 @@
/*************************************************************************/
/* test_main.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_MAIN_H
#define TEST_MAIN_H
#include "ustring.h"
#include "list.h"
const char ** tests_get_names();
MainLoop* test_main(String p_test,const List<String>& p_args);
#endif

382
bin/tests/test_math.cpp Normal file
View File

@ -0,0 +1,382 @@
/*************************************************************************/
/* test_math.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_math.h"
#include "ustring.h"
#include "print_string.h"
#include "transform.h"
#include "matrix3.h"
#include "math_funcs.h"
#include "camera_matrix.h"
#include "scene/main/node.h"
#include "variant.h"
#include "servers/visual/shader_language.h"
#include "os/keyboard.h"
#include "scene/resources/texture.h"
#include "vmap.h"
#include "os/os.h"
namespace TestMath {
void test_vec(Plane p_vec) {
CameraMatrix cm;
cm.set_perspective(45,1,0,100);
Plane v0=cm.xform4(p_vec);
print_line("out: "+v0);
v0.normal.z = (v0.d/100.0 *2.0-1.0) * v0.d;
print_line("out_F: "+v0);
/*v0: 0, 0, -0.1, 0.1
v1: 0, 0, 0, 0.1
fix: 0, 0, 0, 0.1
v0: 0, 0, 1.302803, 1.5
v1: 0, 0, 1.401401, 1.5
fix: 0, 0, 1.401401, 1.5
v0: 0, 0, 25.851850, 26
v1: 0, 0, 25.925926, 26
fix: 0, 0, 25.925924, 26
v0: 0, 0, 49.899902, 50
v1: 0, 0, 49.949947, 50
fix: 0, 0, 49.949951, 50
v0: 0, 0, 100, 100
v1: 0, 0, 100, 100
fix: 0, 0, 100, 100
*/
}
uint32_t ihash( uint32_t a)
{
a = (a+0x7ed55d16) + (a<<12);
a = (a^0xc761c23c) ^ (a>>19);
a = (a+0x165667b1) + (a<<5);
a = (a+0xd3a2646c) ^ (a<<9);
a = (a+0xfd7046c5) + (a<<3);
a = (a^0xb55a4f09) ^ (a>>16);
return a;
}
uint32_t ihash2( uint32_t a) {
a = (a ^ 61) ^ (a >> 16);
a = a + (a << 3);
a = a ^ (a >> 4);
a = a * 0x27d4eb2d;
a = a ^ (a >> 15);
return a;
}
uint32_t ihash3( uint32_t a)
{
a = (a+0x479ab41d) + (a<<8);
a = (a^0xe4aa10ce) ^ (a>>5);
a = (a+0x9942f0a6) - (a<<14);
a = (a^0x5aedd67d) ^ (a>>3);
a = (a+0x17bea992) + (a<<7);
return a;
}
MainLoop* test() {
{
Vector<int32_t> hashes;
List<StringName> tl;
ObjectTypeDB::get_type_list(&tl);
for (List<StringName>::Element *E=tl.front();E;E=E->next()) {
Vector<uint8_t> m5b = E->get().operator String().md5_buffer();
uint32_t *ub = (uint32_t*)m5b.ptr();
//hashes.push_back(ihash(ihash2(ihash3(*ub))));
hashes.push_back(hashes.size());
//hashes.push_back(E->get().hash());
}
//hashes.resize(50);
for(int i=nearest_shift(hashes.size());i<20;i++) {
bool success=true;
for(int s=0;s<10000;s++) {
Set<uint32_t> existing;
success=true;
for(int j=0;j<hashes.size();j++) {
uint32_t eh = ihash2(ihash3(hashes[j]+ihash(s)+s))&((1<<i)-1);
if (existing.has(eh)) {
success=false;
break;
}
existing.insert(eh);
}
if (success) {
print_line("success at "+itos(i)+"/"+itos(nearest_shift(hashes.size()))+" shift "+itos(s));
break;
}
}
if (success)
break;
}
print_line("DONE");
return NULL;
}
{
// print_line("NUM: "+itos(237641278346127));
print_line("NUM: "+itos(-128));
return NULL;
}
{
Vector3 v(1,2,3);
v.normalize();
float a=0.3;
//Quat q(v,a);
Matrix3 m(v,a);
Vector3 v2(7,3,1);
v2.normalize();
float a2=0.8;
//Quat q(v,a);
Matrix3 m2(v2,a2);
Quat q=m;
Quat q2=m2;
Matrix3 m3 = m.inverse() * m2;
Quat q3 = (q.inverse() * q2);//.normalized();
print_line(Quat(m3));
print_line(q3);
print_line("before v: "+v+" a: "+rtos(a));
q.get_axis_and_angle(v,a);
print_line("after v: "+v+" a: "+rtos(a));
}
return NULL;
String ret;
List<String> args;
args.push_back("-l");
Error err = OS::get_singleton()->execute("/bin/ls",args,true,NULL,&ret);
print_line("error: "+itos(err));
print_line(ret);
return NULL;
Matrix3 m3;
m3.rotate(Vector3(1,0,0),0.2);
m3.rotate(Vector3(0,1,0),1.77);
m3.rotate(Vector3(0,0,1),212);
Matrix3 m32;
m32.set_euler(m3.get_euler());
print_line("ELEULEEEEEEEEEEEEEEEEEER: "+m3.get_euler()+" vs "+m32.get_euler());
return NULL;
{
Dictionary d;
d["momo"]=1;
Dictionary b=d;
b["44"]=4;
}
return NULL;
print_line("inters: "+rtos(Geometry::segment_intersects_circle(Vector2(-5,0),Vector2(-2,0),Vector2(),1.0)));
print_line("cross: "+Vector3(1,2,3).cross(Vector3(4,5,7)));
print_line("dot: "+rtos(Vector3(1,2,3).dot(Vector3(4,5,7))));
print_line("abs: "+Vector3(-1,2,-3).abs());
print_line("distance_to: "+rtos(Vector3(1,2,3).distance_to(Vector3(4,5,7))));
print_line("distance_squared_to: "+rtos(Vector3(1,2,3).distance_squared_to(Vector3(4,5,7))));
print_line("plus: "+(Vector3(1,2,3)+Vector3(Vector3(4,5,7))));
print_line("minus: "+(Vector3(1,2,3)-Vector3(Vector3(4,5,7))));
print_line("mul: "+(Vector3(1,2,3)*Vector3(Vector3(4,5,7))));
print_line("div: "+(Vector3(1,2,3)/Vector3(Vector3(4,5,7))));
print_line("mul scalar: "+(Vector3(1,2,3)*2));
print_line("premul scalar: "+(2*Vector3(1,2,3)));
print_line("div scalar: "+(Vector3(1,2,3)/3.0));
print_line("length: "+rtos(Vector3(1,2,3).length()));
print_line("length squared: "+rtos(Vector3(1,2,3).length_squared()));
print_line("normalized: "+Vector3(1,2,3).normalized());
print_line("inverse: "+Vector3(1,2,3).inverse());
{
Vector3 v(4,5,7);
v.normalize();
print_line("normalize: "+v);
}
{
Vector3 v(4,5,7);
v+=Vector3(1,2,3);
print_line("+=: "+v);
}
{
Vector3 v(4,5,7);
v-=Vector3(1,2,3);
print_line("-=: "+v);
}
{
Vector3 v(4,5,7);
v*=Vector3(1,2,3);
print_line("*=: "+v);
}
{
Vector3 v(4,5,7);
v/=Vector3(1,2,3);
print_line("/=: "+v);
}
{
Vector3 v(4,5,7);
v*=2.0;
print_line("scalar *=: "+v);
}
{
Vector3 v(4,5,7);
v/=2.0;
print_line("scalar /=: "+v);
}
#if 0
print_line(String("C:\\momo\\.\\popo\\..\\gongo").simplify_path());
print_line(String("res://../popo/..//gongo").simplify_path());
print_line(String("res://..").simplify_path());
DVector<uint8_t> a;
DVector<uint8_t> b;
a.resize(20);
b=a;
b.resize(30);
a=b;
#endif
#if 0
String za = String::utf8("á");
printf("unicode: %x\n",za[0]);
CharString cs=za.utf8();
for(int i=0;i<cs.size();i++) {
uint32_t v = uint8_t(cs[i]);
printf("%i - %x\n",i,v);
}
return NULL;
print_line(String("C:\\window\\system\\momo").path_to("C:\\window\\momonga"));
print_line(String("res://momo/sampler").path_to("res://pindonga"));
print_line(String("/margarito/terere").path_to("/margarito/pilates"));
print_line(String("/algo").path_to("/algo"));
print_line(String("c:").path_to("c:\\"));
print_line(String("/").path_to("/"));
print_line(itos(sizeof(Variant)));
return NULL;
Vector<StringName> path;
path.push_back("three");
path.push_back("two");
path.push_back("one");
path.push_back("comeon");
path.revert();
NodePath np(path,true);
print_line(np);
return NULL;
bool a=2;
print_line(Variant(a));
Matrix32 mat2_1;
mat2_1.rotate(0.5);
Matrix32 mat2_2;
mat2_2.translate(Vector2(1,2));
Matrix32 mat2_3 = mat2_1 * mat2_2;
mat2_3.affine_invert();
print_line(mat2_3.elements[0]);
print_line(mat2_3.elements[1]);
print_line(mat2_3.elements[2]);
Transform mat3_1;
mat3_1.basis.rotate(Vector3(0,0,1),0.5);
Transform mat3_2;
mat3_2.translate(Vector3(1,2,0));
Transform mat3_3 = mat3_1 * mat3_2;
mat3_3.affine_invert();
print_line(mat3_3.basis.get_axis(0));
print_line(mat3_3.basis.get_axis(1));
print_line(mat3_3.origin);
#endif
return NULL;
}
}

40
bin/tests/test_math.h Normal file
View File

@ -0,0 +1,40 @@
/*************************************************************************/
/* test_math.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_MATH_H
#define TEST_MATH_H
#include "os/main_loop.h"
namespace TestMath {
MainLoop* test();
}
#endif

499
bin/tests/test_misc.cpp Normal file
View File

@ -0,0 +1,499 @@
/*************************************************************************/
/* test_misc.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_misc.h"
#include "servers/visual_server.h"
#include "os/main_loop.h"
#include "math_funcs.h"
#include "print_string.h"
namespace TestMisc {
struct ConvexTestResult
{
Vector3 edgeA[2];
Vector3 edgeB[2];
bool valid;
Vector3 contactA;
Vector3 contactB;
Vector3 contactNormal;
float depth;
/*
Vector3 contactA;
Vector3 contactB;
Vector3 contactNormal;
Vector3 contactX;
Vector3 contactY;
Vector3 edgeA[2];
Vector3 edgeB[2];
float depth;
bool valid;
bool isEdgeEdge;
bool needTransform;
neBool ComputerEdgeContactPoint(ConvexTestResult & res);
neBool ComputerEdgeContactPoint2(float & au, float & bu);
void Reverse()
{
neSwap(contactA, contactB);
contactNormal *= -1.0f;
}*/
bool ComputerEdgeContactPoint2(float & au, float & bu);
};
bool ConvexTestResult::ComputerEdgeContactPoint2(float & au, float & bu)
{
float d1343, d4321, d1321, d4343, d2121;
float numer, denom;
Vector3 p13;
Vector3 p43;
Vector3 p21;
Vector3 diff;
p13 = (edgeA[0]) - (edgeB[0]);
p43 = (edgeB[1]) - (edgeB[0]);
if ( p43.length_squared() < CMP_EPSILON2 )
{
valid = false;
goto ComputerEdgeContactPoint2_Exit;
}
p21 = (edgeA[1]) - (edgeA[0]);
if ( p21.length_squared()<CMP_EPSILON2 )
{
valid = false;
goto ComputerEdgeContactPoint2_Exit;
}
d1343 = p13.dot(p43);
d4321 = p43.dot(p21);
d1321 = p13.dot(p21);
d4343 = p43.dot(p43);
d2121 = p21.dot(p21);
denom = d2121 * d4343 - d4321 * d4321;
if (ABS(denom) < CMP_EPSILON)
{
valid = false;
goto ComputerEdgeContactPoint2_Exit;
}
numer = d1343 * d4321 - d1321 * d4343;
au = numer / denom;
bu = (d1343 + d4321 * (au)) / d4343;
if (au < 0.0f || au >= 1.0f)
{
valid = false;
}
else if (bu < 0.0f || bu >= 1.0f)
{
valid = false;
}
else
{
valid = true;
}
{
Vector3 tmpv;
tmpv = p21 * au;
contactA = (edgeA[0]) + tmpv;
tmpv = p43 * bu;
contactB = (edgeB[0]) + tmpv;
}
diff = contactA - contactB;
depth = Math::sqrt(diff.dot(diff));
return true;
ComputerEdgeContactPoint2_Exit:
return false;
}
struct neCollisionResult {
float depth;
bool penetrate;
Matrix3 collisionFrame;
Vector3 contactA;
Vector3 contactB;
};
struct TConvex {
float radius;
float half_height;
float CylinderRadius() const { return radius; }
float CylinderHalfHeight() const { return half_height; }
};
float GetDistanceFromLine2(Vector3 v, Vector3 & project, const Vector3 & pointA, const Vector3 & pointB)
{
Vector3 ba = pointB - pointA;
float len = ba.length();
if (len<CMP_EPSILON)
ba=Vector3();
else
ba *= 1.0f / len;
Vector3 pa = v - pointA;
float k = pa.dot(ba);
project = pointA + ba * k;
Vector3 diff = v - project;
return diff.length();
}
void TestCylinderVertEdge(neCollisionResult & result, Vector3 & edgeA1, Vector3 & edgeA2, Vector3 & vertB,
TConvex & cA, TConvex & cB, Transform & transA, Transform & transB, bool flip)
{
Vector3 project;
float dist = GetDistanceFromLine2(vertB,project, edgeA1, edgeA2);
float depth = cA.CylinderRadius() + cB.CylinderRadius() - dist;
if (depth <= 0.0f)
return;
if (depth <= result.depth)
return;
result.penetrate = true;
result.depth = depth;
if (!flip)
{
result.collisionFrame.set_axis(2,(project - vertB).normalized());
result.contactA = project - result.collisionFrame.get_axis(2) * cA.CylinderRadius();
result.contactB = vertB + result.collisionFrame.get_axis(2) * cB.CylinderRadius();
}
else
{
result.collisionFrame.set_axis(2,(vertB - project).normalized());
result.contactA = vertB - result.collisionFrame.get_axis(2) * cB.CylinderRadius();
result.contactB = project + result.collisionFrame.get_axis(2) * cA.CylinderRadius();
}
}
void TestCylinderVertVert(neCollisionResult & result, Vector3 & vertA, Vector3 & vertB,
TConvex & cA, TConvex & cB, Transform & transA, Transform & transB)
{
Vector3 diff = vertA - vertB;
float dist = diff.length();
float depth = cA.CylinderRadius() + cB.CylinderRadius() - dist;
if (depth <= 0.0f)
return;
if (depth <= result.depth)
return;
result.penetrate = true;
result.depth = depth;
result.collisionFrame.set_axis(2, diff * (1.0f / dist));
result.contactA = vertA - result.collisionFrame.get_axis(2) * cA.CylinderRadius();
result.contactB = vertB + result.collisionFrame.get_axis(2) * cB.CylinderRadius();
}
void Cylinder2CylinderTest(neCollisionResult & result, TConvex & cA, Transform & transA, TConvex & cB, Transform & transB)
{
result.penetrate = false;
Vector3 dir = transA.basis.get_axis(1).cross(transB.basis.get_axis(1));
float len = dir.length();
// bool isParallel = len<CMP_EPSILON;
// int doVertCheck = 0;
ConvexTestResult cr;
cr.edgeA[0] = transA.origin + transA.basis.get_axis(1) * cA.CylinderHalfHeight();
cr.edgeA[1] = transA.origin - transA.basis.get_axis(1) * cA.CylinderHalfHeight();
cr.edgeB[0] = transB.origin + transB.basis.get_axis(1) * cB.CylinderHalfHeight();
cr.edgeB[1] = transB.origin - transB.basis.get_axis(1) * cB.CylinderHalfHeight();
// float dot = transA.basis.get_axis(1).dot(transB.basis.get_axis(1));
if (len>CMP_EPSILON)
{
float au, bu;
cr.ComputerEdgeContactPoint2(au, bu);
if (cr.valid)
{
float depth = cA.CylinderRadius() + cB.CylinderRadius() - cr.depth;
if (depth <= 0.0f)
return;
result.depth = depth;
result.penetrate = true;
result.collisionFrame.set_axis(2, (cr.contactA - cr.contactB)*(1.0f / cr.depth));
result.contactA = cr.contactA - result.collisionFrame.get_axis(2) * cA.CylinderRadius();
result.contactB = cr.contactB + result.collisionFrame.get_axis(2) * cB.CylinderRadius();
return;
}
}
result.depth = -1.0e6f;
int i;
for (i = 0; i < 2; i++)
{
//project onto edge b
Vector3 diff = cr.edgeA[i] - cr.edgeB[1];
float dot = diff.dot(transB.basis.get_axis(1));
if (dot < 0.0f)
{
TestCylinderVertVert(result, cr.edgeA[i], cr.edgeB[1], cA, cB, transA, transB);
}
else if (dot > (2.0f * cB.CylinderHalfHeight()))
{
TestCylinderVertVert(result, cr.edgeA[i], cr.edgeB[0], cA, cB, transA, transB);
}
else
{
TestCylinderVertEdge(result, cr.edgeB[0], cr.edgeB[1], cr.edgeA[i], cB, cA, transB, transA, true);
}
}
for (i = 0; i < 2; i++)
{
//project onto edge b
Vector3 diff = cr.edgeB[i] - cr.edgeA[1];
float dot = diff.dot(transA.basis.get_axis(1));
if (dot < 0.0f)
{
TestCylinderVertVert(result, cr.edgeB[i], cr.edgeA[1], cA, cB, transA, transB);
}
else if (dot > (2.0f * cB.CylinderHalfHeight()))
{
TestCylinderVertVert(result, cr.edgeB[i], cr.edgeA[0], cA, cB, transA, transB);
}
else
{
TestCylinderVertEdge(result, cr.edgeA[0], cr.edgeA[1], cr.edgeB[i], cA, cB, transA, transB, false);
}
}
}
class TestMainLoop : public MainLoop {
RID meshA;
RID meshB;
RID poly;
RID instance;
RID camera;
RID viewport;
RID boxA;
RID boxB;
RID scenario;
Transform rot_a;
Transform rot_b;
bool quit;
public:
virtual void input_event(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
rot_b.origin.y+=-p_event.mouse_motion.relative_y/100.0;
rot_b.origin.x+=p_event.mouse_motion.relative_x/100.0;
}
if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&BUTTON_MASK_MIDDLE) {
//rot_b.origin.x+=-p_event.mouse_motion.relative_y/100.0;
rot_b.origin.z+=p_event.mouse_motion.relative_x/100.0;
}
if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&BUTTON_MASK_RIGHT) {
float rot_x=-p_event.mouse_motion.relative_y/100.0;
float rot_y=p_event.mouse_motion.relative_x/100.0;
rot_b.basis = rot_b.basis * Matrix3(Vector3(1,0,0),rot_x) * Matrix3(Vector3(0,1,0),rot_y);
}
}
virtual void request_quit() {
quit=true;
}
virtual void init() {
VisualServer *vs=VisualServer::get_singleton();
camera = vs->camera_create();
viewport = vs->viewport_create();
vs->viewport_attach_to_screen(viewport);
vs->viewport_attach_camera( viewport, camera );
vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,0,3 ) ) );
/* CONVEX SHAPE */
DVector<Plane> cylinder_planes = Geometry::build_cylinder_planes(0.5,2,9,Vector3::AXIS_Y);
RID cylinder_material = vs->fixed_material_create();
vs->fixed_material_set_param( cylinder_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(0.8,0.2,0.9));
vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_ONTOP,true);
//vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_WIREFRAME,true);
vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_DOUBLE_SIDED,true);
vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_UNSHADED,true);
RID cylinder_mesh = vs->mesh_create();
Geometry::MeshData cylinder_data = Geometry::build_convex_mesh(cylinder_planes);
vs->mesh_add_surface_from_mesh_data(cylinder_mesh,cylinder_data);
vs->mesh_surface_set_material( cylinder_mesh, 0, cylinder_material );
meshA=vs->instance_create2(cylinder_mesh,scenario);
meshB=vs->instance_create2(cylinder_mesh,scenario);
boxA=vs->instance_create2(vs->get_test_cube(),scenario);
boxB=vs->instance_create2(vs->get_test_cube(),scenario);
/*
RID lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_RADIUS, 80 );
vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ATTENUATION, 1 );
vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ENERGY, 1.5 );
light = vs->instance_create2( lightaux );
*/
RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
//vs->light_set_shadow( lightaux, true );
RID light = vs->instance_create2( lightaux,scenario );
//rot_a=Transform(Matrix3(Vector3(1,0,0),Math_PI/2.0),Vector3());
rot_b=Transform(Matrix3(),Vector3(2,0,0));
//rot_x=0;
//rot_y=0;
quit=false;
}
virtual bool idle(float p_time) {
VisualServer *vs=VisualServer::get_singleton();
vs->instance_set_transform(meshA,rot_a);
vs->instance_set_transform(meshB,rot_b);
neCollisionResult res;
TConvex a;
a.radius=0.5;
a.half_height=1;
Cylinder2CylinderTest(res,a,rot_a,a,rot_b);
if (res.penetrate) {
Matrix3 scale;
scale.scale(Vector3(0.1,0.1,0.1));
vs->instance_set_transform(boxA,Transform(scale,res.contactA));
vs->instance_set_transform(boxB,Transform(scale,res.contactB));
print_line("depth: "+rtos(res.depth));
} else {
Matrix3 scale;
scale.scale(Vector3());
vs->instance_set_transform(boxA,Transform(scale,res.contactA));
vs->instance_set_transform(boxB,Transform(scale,res.contactB));
}
print_line("collided: "+itos(res.penetrate));
return false;
}
virtual bool iteration(float p_time) {
return quit;
}
virtual void finish() {
}
};
MainLoop* test() {
return memnew( TestMainLoop );
}
}

40
bin/tests/test_misc.h Normal file
View File

@ -0,0 +1,40 @@
/*************************************************************************/
/* test_misc.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_MISC_H
#define TEST_MISC_H
#include "os/main_loop.h"
namespace TestMisc {
MainLoop* test();
}
#endif

View File

@ -0,0 +1,121 @@
/*************************************************************************/
/* test_particles.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_particles.h"
#include "servers/visual_server.h"
#include "os/main_loop.h"
#include "math_funcs.h"
#include "print_string.h"
namespace TestParticles {
class TestMainLoop : public MainLoop {
RID particles;
RID instance;
RID camera;
RID viewport;
RID light;
RID scenario;
struct InstanceInfo {
RID instance;
Transform base;
Vector3 rot_axis;
};
List<InstanceInfo> instances;
float ofs;
bool quit;
public:
virtual void input_event(const InputEvent& p_event) {
}
virtual void request_quit() {
quit=true;
}
virtual void init() {
VisualServer *vs=VisualServer::get_singleton();
particles = vs->particles_create();
vs->particles_set_amount(particles,1000);
instance = vs->instance_create2(particles,scenario);
camera = vs->camera_create();
// vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
viewport = vs->viewport_create();
vs->viewport_attach_camera( viewport, camera );
vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,0,20 ) ) );
/*
RID lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_RADIUS, 80 );
vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ATTENUATION, 1 );
vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ENERGY, 1.5 );
light = vs->instance_create2( lightaux );
*/
RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
// vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
light = vs->instance_create2( lightaux, scenario );
ofs=0;
quit=false;
}
virtual bool idle(float p_time) {
return false;
}
virtual bool iteration(float p_time) {
// VisualServer *vs=VisualServer::get_singleton();
ofs+=p_time;
return quit;
}
virtual void finish() {
}
};
MainLoop* test() {
return memnew( TestMainLoop );
}
}

View File

@ -0,0 +1,43 @@
/*************************************************************************/
/* test_particles.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_PARTICLES_H
#define TEST_PARTICLES_H
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
#include "os/main_loop.h"
namespace TestParticles {
MainLoop* test();
}
#endif

662
bin/tests/test_physics.cpp Normal file
View File

@ -0,0 +1,662 @@
/*************************************************************************/
/* test_physics.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_physics.h"
#include "servers/visual_server.h"
#include "servers/physics_server.h"
#include "os/main_loop.h"
#include "math_funcs.h"
#include "print_string.h"
#include "map.h"
#include "os/os.h"
#include "quick_hull.h"
class TestPhysicsMainLoop : public MainLoop {
OBJ_TYPE( TestPhysicsMainLoop, MainLoop );
enum {
LINK_COUNT = 20,
};
RID test_cube;
RID plane;
RID sphere;
RID light;
RID camera;
RID mover;
RID scenario;
RID space;
RID character;
float ofs_x,ofs_y;
Point2 joy_direction;
List<RID> bodies;
Map<PhysicsServer::ShapeType,RID> type_shape_map;
Map<PhysicsServer::ShapeType,RID> type_mesh_map;
void body_changed_transform(Object *p_state, RID p_visual_instance) {
PhysicsDirectBodyState *state = (PhysicsDirectBodyState*)p_state;
VisualServer *vs=VisualServer::get_singleton();
Transform t=state->get_transform();
//t.basis.scale( Vector3(1.0,0.5,0.2) );
vs->instance_set_transform(p_visual_instance,t);
}
bool quit;
protected:
static void _bind_methods() {
ObjectTypeDB::bind_method("body_changed_transform",&TestPhysicsMainLoop::body_changed_transform);
}
RID create_body(PhysicsServer::ShapeType p_shape, PhysicsServer::BodyMode p_body,const Transform p_location,bool p_active_default=true,const Transform&p_shape_xform=Transform()) {
VisualServer *vs=VisualServer::get_singleton();
PhysicsServer * ps = PhysicsServer::get_singleton();
RID mesh_instance = vs->instance_create2(type_mesh_map[p_shape],scenario);
RID body = ps->body_create(p_body,!p_active_default);
ps->body_set_space(body,space);
ps->body_set_param(body,PhysicsServer::BODY_PARAM_BOUNCE,0.0);
//todo set space
ps->body_add_shape(body,type_shape_map[p_shape]);
ps->body_set_force_integration_callback(body,this,"body_changed_transform",mesh_instance);
ps->body_set_state( body, PhysicsServer::BODY_STATE_TRANSFORM,p_location);
bodies.push_back(body);
if (p_body==PhysicsServer::BODY_MODE_STATIC) {
vs->instance_set_transform(mesh_instance,p_location);
}
return body;
}
RID create_static_plane(const Plane& p_plane) {
PhysicsServer * ps = PhysicsServer::get_singleton();
RID plane_shape = ps->shape_create(PhysicsServer::SHAPE_PLANE);;
ps->shape_set_data( plane_shape, p_plane );
RID b = ps->body_create( PhysicsServer::BODY_MODE_STATIC );
ps->body_set_space(b,space);
//todo set space
ps->body_add_shape(b, plane_shape);
return b;
}
void configure_body(RID p_body,float p_mass, float p_friction, float p_bounce) {
PhysicsServer * ps = PhysicsServer::get_singleton();
ps->body_set_param( p_body, PhysicsServer::BODY_PARAM_MASS, p_mass );
ps->body_set_param( p_body, PhysicsServer::BODY_PARAM_FRICTION, p_friction );
ps->body_set_param( p_body, PhysicsServer::BODY_PARAM_BOUNCE, p_bounce );
}
void init_shapes() {
VisualServer *vs=VisualServer::get_singleton();
PhysicsServer * ps = PhysicsServer::get_singleton();
/* SPHERE SHAPE */
RID sphere_mesh = vs->make_sphere_mesh(10,20,0.5);
RID sphere_material = vs->fixed_material_create();
//vs->material_set_flag( sphere_material, VisualServer::MATERIAL_FLAG_WIREFRAME, true );
vs->fixed_material_set_param( sphere_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(0.7,0.8,3.0) );
vs->mesh_surface_set_material( sphere_mesh, 0, sphere_material );
type_mesh_map[PhysicsServer::SHAPE_SPHERE]=sphere_mesh;
RID sphere_shape=ps->shape_create(PhysicsServer::SHAPE_SPHERE);
ps->shape_set_data( sphere_shape, 0.5 );
type_shape_map[PhysicsServer::SHAPE_SPHERE]=sphere_shape;
/* BOX SHAPE */
DVector<Plane> box_planes = Geometry::build_box_planes(Vector3(0.5,0.5,0.5));
RID box_material = vs->fixed_material_create();
vs->fixed_material_set_param( box_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(1.0,0.2,0.2) );
RID box_mesh = vs->mesh_create();
Geometry::MeshData box_data = Geometry::build_convex_mesh(box_planes);
vs->mesh_add_surface_from_mesh_data(box_mesh,box_data);
vs->mesh_surface_set_material( box_mesh, 0, box_material );
type_mesh_map[PhysicsServer::SHAPE_BOX]=box_mesh;
RID box_shape=ps->shape_create(PhysicsServer::SHAPE_BOX);
ps->shape_set_data( box_shape, Vector3(0.5,0.5,0.5) );
type_shape_map[PhysicsServer::SHAPE_BOX]=box_shape;
/* CAPSULE SHAPE */
DVector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5,0.7,12,Vector3::AXIS_Z);
RID capsule_material = vs->fixed_material_create();
vs->fixed_material_set_param( capsule_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(0.3,0.4,1.0) );
RID capsule_mesh = vs->mesh_create();
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh,capsule_data);
vs->mesh_surface_set_material( capsule_mesh, 0, capsule_material );
type_mesh_map[PhysicsServer::SHAPE_CAPSULE]=capsule_mesh;
RID capsule_shape=ps->shape_create(PhysicsServer::SHAPE_CAPSULE);
Dictionary capsule_params;
capsule_params["radius"]=0.5;
capsule_params["height"]=1.4;
ps->shape_set_data( capsule_shape, capsule_params );
type_shape_map[PhysicsServer::SHAPE_CAPSULE]=capsule_shape;
/* CONVEX SHAPE */
DVector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5,0.7,5,Vector3::AXIS_Z);
RID convex_material = vs->fixed_material_create();
vs->fixed_material_set_param( convex_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(0.8,0.2,0.9));
RID convex_mesh = vs->mesh_create();
Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes);
QuickHull::build(convex_data.vertices,convex_data);
vs->mesh_add_surface_from_mesh_data(convex_mesh,convex_data);
vs->mesh_surface_set_material( convex_mesh, 0, convex_material );
type_mesh_map[PhysicsServer::SHAPE_CONVEX_POLYGON]=convex_mesh;
RID convex_shape=ps->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON);
ps->shape_set_data( convex_shape, convex_data.vertices );
type_shape_map[PhysicsServer::SHAPE_CONVEX_POLYGON]=convex_shape;
}
void make_trimesh(Vector<Vector3> p_faces,const Transform& p_xform=Transform()) {
VisualServer *vs=VisualServer::get_singleton();
PhysicsServer * ps = PhysicsServer::get_singleton();
RID trimesh_shape = ps->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON);
ps->shape_set_data(trimesh_shape, p_faces);
p_faces=ps->shape_get_data(trimesh_shape); // optimized one
Vector<Vector3> normals; // for drawing
for (int i=0;i<p_faces.size()/3;i++) {
Plane p( p_faces[i*3+0],p_faces[i*3+1], p_faces[i*3+2] );
normals.push_back(p.normal);
normals.push_back(p.normal);
normals.push_back(p.normal);
}
RID trimesh_mesh = vs->mesh_create();
Array d;
d.resize(VS::ARRAY_MAX);
d[VS::ARRAY_VERTEX]=p_faces;
d[VS::ARRAY_NORMAL]=normals;
vs->mesh_add_surface(trimesh_mesh, VS::PRIMITIVE_TRIANGLES, d );
RID trimesh_mat = vs->fixed_material_create();
vs->fixed_material_set_param( trimesh_mat, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(1.0,0.5,0.8));
//vs->material_set_flag( trimesh_mat, VisualServer::MATERIAL_FLAG_UNSHADED,true);
vs->mesh_surface_set_material( trimesh_mesh, 0, trimesh_mat );
RID triins = vs->instance_create2(trimesh_mesh,scenario);
RID tribody = ps->body_create( PhysicsServer::BODY_MODE_STATIC);
ps->body_set_space(tribody,space);
//todo set space
ps->body_add_shape(tribody, trimesh_shape);
Transform tritrans = p_xform;
ps->body_set_state( tribody, PhysicsServer::BODY_STATE_TRANSFORM, tritrans );
vs->instance_set_transform( triins, tritrans );
//RID trimesh_material = vs->fixed_material_create();
//vs->material_generate( trimesh_material, Color(0.2,0.4,0.6) );
//vs->mesh_surface_set_material( trimesh_mesh, 0, trimesh_material );
}
void make_grid(int p_width,int p_height,float p_cellsize,float p_cellheight,const Transform& p_xform=Transform()) {
Vector< Vector< float > > grid;
grid.resize(p_width);
for (int i=0;i<p_width;i++) {
grid[i].resize(p_height);
for (int j=0;j<p_height;j++) {
grid[i][j]=1.0+Math::random(-p_cellheight, p_cellheight );
}
}
Vector<Vector3> faces;
for (int i=1;i<p_width;i++) {
for (int j=1;j<p_height;j++) {
#define MAKE_VERTEX(m_x,m_z)\
faces.push_back( Vector3( (m_x-p_width/2)*p_cellsize, grid[m_x][m_z], (m_z-p_height/2)*p_cellsize ) )
MAKE_VERTEX(i,j-1);
MAKE_VERTEX(i,j);
MAKE_VERTEX(i-1,j);
MAKE_VERTEX(i-1,j-1);
MAKE_VERTEX(i,j-1);
MAKE_VERTEX(i-1,j);
}
}
make_trimesh(faces,p_xform);
}
public:
virtual void input_event(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&4) {
ofs_y-=p_event.mouse_motion.relative_y/200.0;
ofs_x+=p_event.mouse_motion.relative_x/200.0;
}
if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&1) {
float y=-p_event.mouse_motion.relative_y/20.0;
float x=p_event.mouse_motion.relative_x/20.0;
if (mover.is_valid()) {
PhysicsServer * ps = PhysicsServer::get_singleton();
Transform t = ps->body_get_state(mover,PhysicsServer::BODY_STATE_TRANSFORM);
t.origin+=Vector3(x,y,0);
ps->body_set_state(mover,PhysicsServer::BODY_STATE_TRANSFORM,t);
}
}
if (p_event.type == InputEvent::JOYSTICK_MOTION) {
if (p_event.joy_motion.axis == 0) {
joy_direction.x = p_event.joy_motion.axis_value;
};
if (p_event.joy_motion.axis == 1) {
joy_direction.y = p_event.joy_motion.axis_value;
};
};
}
virtual void request_quit() {
quit=true;
}
virtual void init() {
ofs_x=ofs_y=0;
init_shapes();
PhysicsServer *ps = PhysicsServer::get_singleton();
space=ps->space_create();
ps->space_set_active(space,true);
VisualServer *vs=VisualServer::get_singleton();
/* LIGHT */
RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
scenario = vs->scenario_create();
vs->light_set_shadow(lightaux,true);
light = vs->instance_create2( lightaux,scenario );
Transform t;
t.rotate(Vector3(1.0,0,0),0.6);
vs->instance_set_transform(light,t);
/* CAMERA */
camera = vs->camera_create();
RID viewport = vs->viewport_create();
vs->viewport_attach_camera( viewport, camera );
vs->viewport_attach_to_screen(viewport);
vs->viewport_set_scenario( viewport, scenario );
vs->camera_set_perspective(camera,60,0.1,40.0);
vs->camera_set_transform(camera,Transform( Matrix3(), Vector3(0,9,12)));
//vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME);
Transform gxf;
gxf.basis.scale(Vector3(1.4,0.4,1.4));
gxf.origin=Vector3(-2,1,-2);
make_grid(5,5,2.5,1,gxf);
// create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,gxf);
//create_static_plane( Plane( Vector3(0,1,0), -2) );
// test_joint();
test_fall();
//test_joint();
/*
Vector<Vector3> faces;
faces.push_back( Vector3(10,0,-5) );
faces.push_back( Vector3(0,0,10) );
faces.push_back( Vector3(-10,-0.2,-5) );
make_trimesh(faces);
*/
/* Make Trimesh */
quit=false;
return;
#if 0
#define GRID_SIZE 5
float grid[GRID_SIZE][GRID_SIZE];
for (int i=0;i<GRID_SIZE;i++) {
for (int j=0;j<GRID_SIZE;j++) {
grid[j][i]=Math::random(0.0, 1.0 );
}
}
Vector<Vector3> faces;
for (int i=1;i<GRID_SIZE;i++) {
for (int j=1;j<GRID_SIZE;j++) {
#define MAKE_VERTEX(m_x,m_z)\
faces.push_back( Vector3( m_x-GRID_SIZE/2.0, grid[m_x][m_z], m_z-GRID_SIZE/2.0 )*3.0 )
MAKE_VERTEX(i,j-1);
MAKE_VERTEX(i,j);
MAKE_VERTEX(i-1,j);
MAKE_VERTEX(i-1,j-1);
MAKE_VERTEX(i,j-1);
MAKE_VERTEX(i-1,j);
}
}
/*
faces.clear();
faces.push_back( Vector3(0,0,-5) );
faces.push_back( Vector3(1,0,-1) );
faces.push_back( Vector3(-1,-0,-1) );
*/
RID trimesh_shape = ps->shape_create();
ps->shape_set_data(trimesh_shape, PhysicsServer::SHAPE_CONCAVE_POLYGON,faces);
faces=ps->shape_get_shape(trimesh_shape, 0);
Vector<Vector3> normals; // for drawing
for (int i=0;i<faces.size()/3;i++) {
Plane p( faces[i*3+0],faces[i*3+1], faces[i*3+2] );
normals.push_back(p.normal);
normals.push_back(p.normal);
normals.push_back(p.normal);
}
RID trimesh_mesh = vs->mesh_create();
vs->mesh_add_surface(trimesh_mesh, VS::PRIMITIVE_TRIANGLES, VS::ARRAY_FORMAT_VERTEX|VS::ARRAY_FORMAT_NORMAL, faces.size() );
vs->mesh_surface_set_array(trimesh_mesh,0,VS::ARRAY_VERTEX, faces );
vs->mesh_surface_set_array(trimesh_mesh,0,VS::ARRAY_NORMAL, normals );
RID trimesh_mat = vs->fixed_material_create();
vs->material_generate( trimesh_mat, Color(1.0,0.5,0.3) );
vs->mesh_surface_set_material( trimesh_mesh, 0, trimesh_mat );
RID triins = vs->instance_create2(trimesh_mesh);
RID tribody = ps->body_create( PhysicsServer::BODY_MODE_STATIC, trimesh_shape);
Transform tritrans = Transform( Matrix3(), Vector3(0,0,-2) );
ps->body_set_state( tribody, PhysicsServer::BODY_STATE_TRANSFORM, tritrans );
vs->instance_set_transform( triins, tritrans );
RID trimesh_material = vs->fixed_material_create();
vs->material_generate( trimesh_material, Color(0.2,0.4,0.6) );
vs->mesh_surface_set_material( trimesh_mesh, 0, trimesh_material );
#endif
}
virtual bool iteration(float p_time) {
if (mover) {
static float joy_speed = 10;
PhysicsServer * ps = PhysicsServer::get_singleton();
Transform t = ps->body_get_state(mover,PhysicsServer::BODY_STATE_TRANSFORM);
t.origin+=Vector3(joy_speed * joy_direction.x * p_time, -joy_speed * joy_direction.y * p_time,0);
ps->body_set_state(mover,PhysicsServer::BODY_STATE_TRANSFORM,t);
};
Transform cameratr;
cameratr.rotate(Vector3(0,1,0),ofs_x);
cameratr.rotate(Vector3(1,0,0),-ofs_y);
cameratr.translate(Vector3(0,2,8));
VisualServer *vs=VisualServer::get_singleton();
vs->camera_set_transform(camera,cameratr);
return quit;
}
virtual void finish() {
}
void test_joint() {
#if 0
PhysicsServer * ps = PhysicsServer::get_singleton();
mover = create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,Transform(Matrix3(),Vector3(0,0,-24)));
RID b = create_body(PhysicsServer::SHAPE_CAPSULE,PhysicsServer::BODY_MODE_RIGID,Transform());
ps->joint_create_double_pin(b,Vector3(0,0,1.0),mover,Vector3(0,0,0));
ps->body_add_collision_exception(mover,b);
List<String> cmdline = OS::get_singleton()->get_cmdline_args();
int link_count = LINK_COUNT;
if (cmdline.size() > 0 && cmdline[cmdline.size()-1].to_int()) {
link_count = cmdline[cmdline.size()-1].to_int();
};
for(int i=0;i<link_count;i++) {
RID c = create_body(PhysicsServer::SHAPE_CAPSULE,PhysicsServer::BODY_MODE_RIGID,Transform());
ps->joint_create_double_pin(b,Vector3(0,0,-0.7),c,Vector3(0,0,0.7));
ps->body_add_collision_exception(c,b);
b=c;
}
create_static_plane(Plane(Vector3(0,1,0),-8));
#endif
}
void test_hinge() {
#if 0
PhysicsServer * ps = PhysicsServer::get_singleton();
mover = create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,Transform(Matrix3(),Vector3(0,0,-24)));
RID b = create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_RIGID,Transform());
ps->joint_create_double_hinge(b,Transform(Matrix3(),Vector3(1,1,1.0)),mover,Transform(Matrix3(),Vector3(0,0,0)));
ps->body_add_collision_exception(mover,b);
/*
for(int i=0;i<20;i++) {
RID c = create_body(PhysicsServer::SHAPE_CAPSULE,PhysicsServer::BODY_MODE_RIGID,Transform());
ps->joint_create_double_hinge(b,Transform(Matrix3(),Vector3(0,0,-0.7)),c,Transform(Matrix3(),Vector3(0,0,0.7)));
ps->body_add_collision_exception(c,b);
b=c;
}
*/
//create_static_plane(Plane(Vector3(0,1,0),-8));
#endif
}
void test_character() {
VisualServer *vs=VisualServer::get_singleton();
PhysicsServer * ps = PhysicsServer::get_singleton();
DVector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5,1,12,5,Vector3::AXIS_Y);
RID capsule_material = vs->fixed_material_create();
vs->fixed_material_set_param( capsule_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(1,1,1) );
RID capsule_mesh = vs->mesh_create();
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh,capsule_data);
vs->mesh_surface_set_material( capsule_mesh, 0, capsule_material );
type_mesh_map[PhysicsServer::SHAPE_CAPSULE]=capsule_mesh;
RID capsule_shape=ps->shape_create(PhysicsServer::SHAPE_CAPSULE);
Dictionary capsule_params;
capsule_params["radius"]=0.5;
capsule_params["height"]=1;
Transform shape_xform;
shape_xform.rotate(Vector3(1,0,0),Math_PI/2.0);
//shape_xform.origin=Vector3(1,1,1);
ps->shape_set_data( capsule_shape, capsule_params);
RID mesh_instance = vs->instance_create2(capsule_mesh,scenario);
character = ps->body_create(PhysicsServer::BODY_MODE_CHARACTER);
ps->body_set_space(character,space);
//todo add space
ps->body_add_shape(character,capsule_shape);
ps->body_set_force_integration_callback(character,this,"body_changed_transform",mesh_instance);
ps->body_set_state( character, PhysicsServer::BODY_STATE_TRANSFORM,Transform(Matrix3(),Vector3(-2,5,-2)));
bodies.push_back(character);
}
void test_fall() {
for (int i=0;i<35;i++) {
static const PhysicsServer::ShapeType shape_idx[]={
PhysicsServer::SHAPE_CAPSULE,
PhysicsServer::SHAPE_BOX,
PhysicsServer::SHAPE_SPHERE,
PhysicsServer::SHAPE_CONVEX_POLYGON
};
PhysicsServer::ShapeType type=shape_idx[i%4];
//type=PhysicsServer::SHAPE_CONVEX_POLYGON;
Transform t;
t.origin=Vector3(0.0*i,3.5+1.1*i,0.7+0.0*i);
//t.origin=Vector3(-0.7+0.0*i,0.5+4.1*i,0);
t.basis.rotate(Vector3(0.2,-1,0),Math_PI/2*0.6);
//t.basis.rotate(Vector3(0,-1,0),Math_PI/4*i);
//t.basis.rotate(Vector3(0,-1,0),Math_PI/4*i);
//t.basis.rotate(Vector3(-1,0,0),Math_PI/4*i);
RID b = create_body(type,PhysicsServer::BODY_MODE_RIGID,t);
//RID b = create_body(type,i==0?PhysicsServer::BODY_MODE_STATIC:PhysicsServer::BODY_MODE_RIGID,t);
}
create_static_plane( Plane( Vector3(0,1,0), -1) );
/*
create_static_plane( Plane( Vector3(1,0,0), -2) );
create_static_plane( Plane( Vector3(-1,0,0), -2) );
create_static_plane( Plane( Vector3(0,0,1), -2) );
create_static_plane( Plane( Vector3(0,0,-1), -2) );
*/
}
void test_activate() {
create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_RIGID,Transform(Matrix3(),Vector3(0,2,0)),true);
//create_body(PhysicsServer::SHAPE_SPHERE,PhysicsServer::BODY_MODE_RIGID,Transform(Matrix3(),Vector3(0,6,0)),true);
create_static_plane( Plane( Vector3(0,1,0), -1) );
}
virtual bool idle(float p_time) {
return false;
}
TestPhysicsMainLoop() {
}
};
namespace TestPhysics {
MainLoop* test() {
return memnew( TestPhysicsMainLoop );
}
}

44
bin/tests/test_physics.h Normal file
View File

@ -0,0 +1,44 @@
/*************************************************************************/
/* test_physics.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_PHYSICS_H
#define TEST_PHYSICS_H
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
#include "os/main_loop.h"
namespace TestPhysics {
MainLoop* test();
}
#endif

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,41 @@
/*************************************************************************/
/* test_physics_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_PHYSICS_2D_H
#define TEST_PHYSICS_2D_H
#include "os/main_loop.h"
namespace TestPhysics2D {
MainLoop* test();
}
#endif // TEST_PHYSICS_2D_H

56
bin/tests/test_python.cpp Normal file
View File

@ -0,0 +1,56 @@
/*************************************************************************/
/* test_python.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_python.h"
#ifdef PYTHON_ENABLED
#include "Python.h"
#include "print_string.h"
namespace TestPython {
void test() {
print_line("testing python");
PyRun_SimpleString("import engine\n");
PyRun_SimpleString("def test(self):\n\tprint(\"noway\")\n");
PyRun_SimpleString("a=engine.ObjectPtr()\n");
PyRun_SimpleString("a.noway(22,'hello')\n");
PyRun_SimpleString("a.normalize()\n");
PyRun_SimpleString("class Moch(engine.ObjectPtr):\n\tdef mooch(self):\n\t\tprint('muchi')\n");
PyRun_SimpleString("b=Moch();\n");
PyRun_SimpleString("b.mooch();\n");
PyRun_SimpleString("b.meis();\n");
}
}
#endif

43
bin/tests/test_python.h Normal file
View File

@ -0,0 +1,43 @@
/*************************************************************************/
/* test_python.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_PYTHON_H
#define TEST_PYTHON_H
#ifdef PYTHON_ENABLED
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
namespace TestPython {
void test();
}
#endif
#endif

263
bin/tests/test_render.cpp Normal file
View File

@ -0,0 +1,263 @@
/*************************************************************************/
/* test_render.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_render.h"
#include "servers/visual_server.h"
#include "os/main_loop.h"
#include "math_funcs.h"
#include "print_string.h"
#include "os/os.h"
#include "quick_hull.h"
#include "os/keyboard.h"
#define OBJECT_COUNT 50
namespace TestRender {
class TestMainLoop : public MainLoop {
RID test_cube;
RID instance;
RID camera;
RID viewport;
RID light;
RID scenario;
struct InstanceInfo {
RID instance;
Transform base;
Vector3 rot_axis;
};
List<InstanceInfo> instances;
float ofs;
bool quit;
protected:
public:
virtual void input_event(const InputEvent& p_event) {
if (p_event.type==InputEvent::KEY && p_event.key.pressed)
quit=true;
}
virtual void init() {
print_line("INITIALIZING TEST RENDER");
VisualServer *vs=VisualServer::get_singleton();
test_cube = vs->get_test_cube();
scenario = vs->scenario_create();
Vector<Vector3> vts;
/*
DVector<Plane> sp = Geometry::build_sphere_planes(2,5,5);
Geometry::MeshData md2 = Geometry::build_convex_mesh(sp);
vts=md2.vertices;
*/
/*
static const int s = 20;
for(int i=0;i<s;i++) {
Matrix3 rot(Vector3(0,1,0),i*Math_PI/s);
for(int j=0;j<s;j++) {
Vector3 v;
v.x=Math::sin(j*Math_PI*2/s);
v.y=Math::cos(j*Math_PI*2/s);
vts.push_back( rot.xform(v*2 ) );
}
}*/
/*for(int i=0;i<100;i++) {
vts.push_back( Vector3(Math::randf()*2-1.0,Math::randf()*2-1.0,Math::randf()*2-1.0).normalized()*2);
}*/
/*
vts.push_back(Vector3(0,0,1));
vts.push_back(Vector3(0,0,-1));
vts.push_back(Vector3(0,1,0));
vts.push_back(Vector3(0,-1,0));
vts.push_back(Vector3(1,0,0));
vts.push_back(Vector3(-1,0,0));*/
vts.push_back(Vector3(1,1,1));
vts.push_back(Vector3(1,-1,1));
vts.push_back(Vector3(-1,1,1));
vts.push_back(Vector3(-1,-1,1));
vts.push_back(Vector3(1,1,-1));
vts.push_back(Vector3(1,-1,-1));
vts.push_back(Vector3(-1,1,-1));
vts.push_back(Vector3(-1,-1,-1));
Geometry::MeshData md;
Error err = QuickHull::build(vts,md);
print_line("ERR: "+itos(err));
test_cube = vs->mesh_create();
vs->mesh_add_surface_from_mesh_data(test_cube,md);
//vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME);
/*
RID sm = vs->shader_create();
//vs->shader_set_fragment_code(sm,"OUT_ALPHA=mod(TIME,1);");
//vs->shader_set_vertex_code(sm,"OUT_VERTEX=IN_VERTEX*mod(TIME,1);");
vs->shader_set_fragment_code(sm,"OUT_DIFFUSE=vec3(1,0,1);OUT_GLOW=abs(sin(TIME));");
RID tcmat = vs->mesh_surface_get_material(test_cube,0);
vs->material_set_shader(tcmat,sm);
*/
List<String> cmdline = OS::get_singleton()->get_cmdline_args();
int object_count = OBJECT_COUNT;
if (cmdline.size() > 0 && cmdline[cmdline.size()-1].to_int()) {
object_count = cmdline[cmdline.size()-1].to_int();
};
for (int i=0;i<object_count;i++) {
InstanceInfo ii;
ii.instance = vs->instance_create2( test_cube, scenario );
ii.base.translate( Math::random(-20,20), Math::random(-20,20),Math::random(-20,18) );
ii.base.rotate( Vector3(0,1,0), Math::randf() * Math_PI );
ii.base.rotate( Vector3(1,0,0), Math::randf() * Math_PI );
vs->instance_set_transform( ii.instance, ii.base );
ii.rot_axis = Vector3( Math::random(-1,1), Math::random(-1,1), Math::random(-1,1) ).normalized();
instances.push_back(ii);
}
camera = vs->camera_create();
// vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
viewport = vs->viewport_create();
vs->viewport_attach_to_screen(viewport);
vs->viewport_attach_camera( viewport, camera );
vs->viewport_set_scenario( viewport, scenario );
vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,3,30 ) ) );
vs->camera_set_perspective( camera, 60, 0.1, 1000);
/*
RID lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_RADIUS, 80 );
vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ATTENUATION, 1 );
vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ENERGY, 1.5 );
light = vs->instance_create( lightaux );
*/
RID lightaux;
//*
lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_DIFFUSE, Color(1.0,1.0,1.0) );
//vs->light_set_shadow( lightaux, true );
light = vs->instance_create2( lightaux, scenario );
Transform lla;
//lla.set_look_at(Vector3(),Vector3(1,-1,1),Vector3(0,1,0));
lla.set_look_at(Vector3(),Vector3(-0.000000,-0.836026,-0.548690),Vector3(0,1,0));
vs->instance_set_transform( light, lla );
// */
//*
lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
// vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_DIFFUSE, Color(1.0,1.0,0.0) );
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_RADIUS, 4 );
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_ENERGY, 8 );
//vs->light_set_shadow( lightaux, true );
//light = vs->instance_create( lightaux );
// */
ofs=0;
quit=false;
}
virtual bool iteration(float p_time) {
VisualServer *vs=VisualServer::get_singleton();
//Transform t;
//t.rotate(Vector3(0, 1, 0), ofs);
//t.translate(Vector3(0,0,20 ));
//vs->camera_set_transform(camera, t);
ofs+=p_time*0.05;
//return quit;
for(List<InstanceInfo>::Element *E=instances.front();E;E=E->next()) {
Transform pre( Matrix3(E->get().rot_axis, ofs), Vector3() );
vs->instance_set_transform( E->get().instance, pre * E->get().base );
/*
if( !E->next() ) {
vs->free( E->get().instance );
instances.erase(E );
}*/
}
return quit;
}
virtual bool idle(float p_time) {
return quit;
}
virtual void finish() {
}
};
MainLoop* test() {
return memnew( TestMainLoop );
}
}

44
bin/tests/test_render.h Normal file
View File

@ -0,0 +1,44 @@
/*************************************************************************/
/* test_render.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_RENDER_H
#define TEST_RENDER_H
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
#include "os/main_loop.h"
namespace TestRender {
MainLoop* test();
}
#endif

View File

@ -0,0 +1,340 @@
/*************************************************************************/
/* test_shader_lang.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_shader_lang.h"
#include "os/main_loop.h"
#include "os/os.h"
#include "os/file_access.h"
#include "scene/gui/control.h"
#include "scene/gui/text_edit.h"
#include "print_string.h"
#include "servers/visual/shader_language.h"
#include "drivers/gles2/shader_compiler_gles2.h"
typedef ShaderLanguage SL;
namespace TestShaderLang {
static String _mktab(int p_level) {
String tb;
for(int i=0;i<p_level;i++) {
tb+="\t";
}
return tb;
}
static String _typestr(SL::DataType p_type) {
switch(p_type) {
case SL::TYPE_VOID: return "void";
case SL::TYPE_BOOL: return "bool";
case SL::TYPE_FLOAT: return "float";
case SL::TYPE_VEC2: return "vec2";
case SL::TYPE_VEC3: return "vec3";
case SL::TYPE_VEC4: return "vec4";
case SL::TYPE_MAT3: return "mat3";
case SL::TYPE_MAT4: return "mat4";
case SL::TYPE_TEXTURE: return "texture";
case SL::TYPE_CUBEMAP: return "cubemap";
default: {}
}
return "";
}
static String _opstr(SL::Operator p_op) {
switch(p_op) {
case SL::OP_ASSIGN: return "=";
case SL::OP_ADD: return "+";
case SL::OP_SUB: return "-";
case SL::OP_MUL: return "*";
case SL::OP_DIV: return "/";
case SL::OP_ASSIGN_ADD: return "+=";
case SL::OP_ASSIGN_SUB: return "-=";
case SL::OP_ASSIGN_MUL: return "*=";
case SL::OP_ASSIGN_DIV: return "/=";
case SL::OP_NEG: return "-";
case SL::OP_NOT: return "!";
case SL::OP_CMP_EQ: return "==";
case SL::OP_CMP_NEQ: return "!=";
case SL::OP_CMP_LEQ: return "<=";
case SL::OP_CMP_GEQ: return ">=";
case SL::OP_CMP_LESS: return "<";
case SL::OP_CMP_GREATER: return ">";
case SL::OP_CMP_OR: return "||";
case SL::OP_CMP_AND: return "&&";
default: return "";
}
return "";
}
static String dump_node_code(SL::Node *p_node,int p_level) {
String code;
switch(p_node->type) {
case SL::Node::TYPE_PROGRAM: {
SL::ProgramNode *pnode=(SL::ProgramNode*)p_node;
for(Map<StringName,SL::Uniform>::Element *E=pnode->uniforms.front();E;E=E->next()) {
String ucode="uniform ";
ucode+=_typestr(E->get().type)+"="+String(E->get().default_value)+"\n";
code+=ucode;
}
for(int i=0;i<pnode->functions.size();i++) {
SL::FunctionNode *fnode=pnode->functions[i].function;
String header;
header=_typestr(fnode->return_type)+" "+fnode->name+"(";
for(int i=0;i<fnode->arguments.size();i++) {
if (i>0)
header+=", ";
header+=_typestr(fnode->arguments[i].type)+" "+fnode->arguments[i].name;
}
header+=") {\n";
code+=header;
code+=dump_node_code(fnode->body,p_level+1);
code+="}\n";
}
code+=dump_node_code(pnode->body,p_level);
} break;
case SL::Node::TYPE_FUNCTION: {
} break;
case SL::Node::TYPE_BLOCK: {
SL::BlockNode *bnode=(SL::BlockNode*)p_node;
//variables
for(Map<StringName,SL::DataType>::Element *E=bnode->variables.front();E;E=E->next()) {
code+=_mktab(p_level)+_typestr(E->value())+" "+E->key()+";\n";
}
for(int i=0;i<bnode->statements.size();i++) {
code+=_mktab(p_level)+dump_node_code(bnode->statements[i],p_level)+";\n";
}
} break;
case SL::Node::TYPE_VARIABLE: {
SL::VariableNode *vnode=(SL::VariableNode*)p_node;
code=vnode->name;
} break;
case SL::Node::TYPE_CONSTANT: {
SL::ConstantNode *cnode=(SL::ConstantNode*)p_node;
switch(cnode->datatype) {
case SL::TYPE_BOOL: code=cnode->value.operator bool()?"true":"false"; break;
case SL::TYPE_FLOAT: code=cnode->value; break;
case SL::TYPE_VEC2: { Vector2 v = cnode->value; code="vec2("+rtos(v.x)+", "+rtos(v.y)+")"; } break;
case SL::TYPE_VEC3: { Vector3 v = cnode->value; code="vec3("+rtos(v.x)+", "+rtos(v.y)+", "+rtos(v.z)+")"; } break;
case SL::TYPE_VEC4: { Plane v = cnode->value; code="vec4("+rtos(v.normal.x)+", "+rtos(v.normal.y)+", "+rtos(v.normal.z)+", "+rtos(v.d)+")"; } break;
case SL::TYPE_MAT3: { Matrix3 x = cnode->value; code="mat3( vec3("+rtos(x.get_axis(0).x)+", "+rtos(x.get_axis(0).y)+", "+rtos(x.get_axis(0).z)+"), vec3("+rtos(x.get_axis(1).x)+", "+rtos(x.get_axis(1).y)+", "+rtos(x.get_axis(1).z)+"), vec3("+rtos(x.get_axis(2).x)+", "+rtos(x.get_axis(2).y)+", "+rtos(x.get_axis(2).z)+"))"; } break;
case SL::TYPE_MAT4: { Transform x = cnode->value; code="mat4( vec3("+rtos(x.basis.get_axis(0).x)+", "+rtos(x.basis.get_axis(0).y)+", "+rtos(x.basis.get_axis(0).z)+"), vec3("+rtos(x.basis.get_axis(1).x)+", "+rtos(x.basis.get_axis(1).y)+", "+rtos(x.basis.get_axis(1).z)+"), vec3("+rtos(x.basis.get_axis(2).x)+", "+rtos(x.basis.get_axis(2).y)+", "+rtos(x.basis.get_axis(2).z)+"), vec3("+rtos(x.origin.x)+", "+rtos(x.origin.y)+", "+rtos(x.origin.z)+"))"; } break;
default: code="<error: "+Variant::get_type_name(cnode->value.get_type())+" ("+itos(cnode->datatype)+">";
}
} break;
case SL::Node::TYPE_OPERATOR: {
SL::OperatorNode *onode=(SL::OperatorNode*)p_node;
switch(onode->op) {
case SL::OP_ASSIGN:
case SL::OP_ASSIGN_ADD:
case SL::OP_ASSIGN_SUB:
case SL::OP_ASSIGN_MUL:
case SL::OP_ASSIGN_DIV:
code=dump_node_code(onode->arguments[0],p_level)+_opstr(onode->op)+dump_node_code(onode->arguments[1],p_level);
break;
case SL::OP_ADD:
case SL::OP_SUB:
case SL::OP_MUL:
case SL::OP_DIV:
case SL::OP_CMP_EQ:
case SL::OP_CMP_NEQ:
case SL::OP_CMP_LEQ:
case SL::OP_CMP_GEQ:
case SL::OP_CMP_LESS:
case SL::OP_CMP_GREATER:
case SL::OP_CMP_OR:
case SL::OP_CMP_AND:
code="("+dump_node_code(onode->arguments[0],p_level)+_opstr(onode->op)+dump_node_code(onode->arguments[1],p_level)+")";
break;
case SL::OP_NEG:
case SL::OP_NOT:
code=_opstr(onode->op)+dump_node_code(onode->arguments[0],p_level);
break;
case SL::OP_CALL:
case SL::OP_CONSTRUCT:
code=dump_node_code(onode->arguments[0],p_level)+"(";
for(int i=1;i<onode->arguments.size();i++) {
if (i>1)
code+=", ";
code+=dump_node_code(onode->arguments[i],p_level);
}
code+=")";
break;
default: {}
}
} break;
case SL::Node::TYPE_CONTROL_FLOW: {
SL::ControlFlowNode *cfnode=(SL::ControlFlowNode*)p_node;
if (cfnode->flow_op==SL::FLOW_OP_IF) {
code+="if ("+dump_node_code(cfnode->statements[0],p_level)+") {\n";
code+=dump_node_code(cfnode->statements[1],p_level+1);
if (cfnode->statements.size()==3) {
code+="} else {\n";
code+=dump_node_code(cfnode->statements[2],p_level+1);
}
code+="}\n";
} else if (cfnode->flow_op==SL::FLOW_OP_RETURN) {
if (cfnode->statements.size()) {
code="return "+dump_node_code(cfnode->statements[0],p_level);
} else {
code="return";
}
}
} break;
case SL::Node::TYPE_MEMBER: {
SL::MemberNode *mnode=(SL::MemberNode*)p_node;
code=dump_node_code(mnode->owner,p_level)+"."+mnode->name;
} break;
}
return code;
}
static Error recreate_code(void *p_str,SL::ProgramNode *p_program) {
print_line("recr");
String *str=(String*)p_str;
*str=dump_node_code(p_program,0);
return OK;
}
MainLoop* test() {
List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
if (cmdlargs.empty()) {
//try editor!
return NULL;
}
String test = cmdlargs.back()->get();
FileAccess *fa = FileAccess::open(test,FileAccess::READ);
if (!fa) {
ERR_FAIL_V(NULL);
}
String code;
while(true) {
CharType c = fa->get_8();
if (fa->eof_reached())
break;
code+=c;
}
int errline;
int errcol;
String error;
print_line(SL::lex_debug(code));
Error err = SL::compile(code,ShaderLanguage::SHADER_MATERIAL_FRAGMENT,NULL,NULL,&error,&errline,&errcol);
if (err) {
print_line("Error: "+itos(errline)+":"+itos(errcol)+" "+error);
return NULL;
}
print_line("Compile OK! - pretty printing");
String rcode;
err = SL::compile(code,ShaderLanguage::SHADER_MATERIAL_FRAGMENT,recreate_code,&rcode,&error,&errline,&errcol);
if (!err) {
print_line(rcode);
}
ShaderCompilerGLES2 comp;
String codeline,globalsline;
SL::VarInfo vi;
vi.name="mongs";
vi.type=SL::TYPE_VEC3;
ShaderCompilerGLES2::Flags fl;
comp.compile(code,ShaderLanguage::SHADER_MATERIAL_FRAGMENT,codeline,globalsline,fl);
return NULL;
}
}

View File

@ -0,0 +1,40 @@
/*************************************************************************/
/* test_shader_lang.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_SHADER_LANG_H
#define TEST_SHADER_LANG_H
#include "os/main_loop.h"
namespace TestShaderLang {
MainLoop* test();
}
#endif // TEST_SHADER_LANG_H

95
bin/tests/test_sound.cpp Normal file
View File

@ -0,0 +1,95 @@
/*************************************************************************/
/* test_sound.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "test_sound.h"
#include "servers/visual_server.h"
#include "os/main_loop.h"
#include "math_funcs.h"
#include "scene/resources/sample.h"
#include "io/resource_loader.h"
#include "print_string.h"
#include "servers/audio_server.h"
#include "os/os.h"
namespace TestSound {
class TestMainLoop : public MainLoop {
bool quit;
Ref<Sample> sample;
public:
virtual void input_event(const InputEvent& p_event) {
}
virtual void request_quit() {
quit=true;
}
virtual void init() {
List<String> cmdline = OS::get_singleton()->get_cmdline_args();
quit=false;
if (cmdline.size()) {
sample=ResourceLoader::load(cmdline.back()->get());
ERR_FAIL_COND(sample.is_null());
print_line("Sample loaded OK");
}
RID voice = AudioServer::get_singleton()->voice_create();
AudioServer::get_singleton()->voice_play( voice, sample->get_rid() );
}
virtual bool idle(float p_time) {
return false;
}
virtual bool iteration(float p_time) {
return quit;
}
virtual void finish() {
}
};
MainLoop* test() {
return memnew( TestMainLoop );
}
}

40
bin/tests/test_sound.h Normal file
View File

@ -0,0 +1,40 @@
/*************************************************************************/
/* test_sound.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_SOUND_H
#define TEST_SOUND_H
#include "os/main_loop.h"
namespace TestSound {
MainLoop* test();
}
#endif // TEST_SOUND_H

912
bin/tests/test_string.cpp Normal file
View File

@ -0,0 +1,912 @@
/*************************************************************************/
/* test_string.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "ustring.h"
#include <wchar.h>
//#include "math_funcs.h"
#include <stdio.h>
#include "os/os.h"
#include "drivers/nrex/regex.h"
#include "test_string.h"
namespace TestString {
bool test_1() {
OS::get_singleton()->print("\n\nTest 1: Assign from cstr\n");
String s = "Hello";
OS::get_singleton()->print("\tExpected: Hello\n");
OS::get_singleton()->print("\tResulted: %ls\n",s.c_str());
return (wcscmp(s.c_str(),L"Hello")==0);
}
bool test_2() {
OS::get_singleton()->print("\n\nTest 2: Assign from string (operator=)\n");
String s = "Dolly";
String t = s;
OS::get_singleton()->print("\tExpected: Dolly\n");
OS::get_singleton()->print("\tResulted: %ls\n",t.c_str());
return (wcscmp(t.c_str(),L"Dolly")==0);
}
bool test_3() {
OS::get_singleton()->print("\n\nTest 3: Assign from c-string (copycon)\n");
String s("Sheep");
String t(s);
OS::get_singleton()->print("\tExpected: Sheep\n");
OS::get_singleton()->print("\tResulted: %ls\n",t.c_str());
return (wcscmp(t.c_str(),L"Sheep")==0);
}
bool test_4() {
OS::get_singleton()->print("\n\nTest 4: Assign from c-widechar (operator=)\n");
String s(L"Give me");
OS::get_singleton()->print("\tExpected: Give me\n");
OS::get_singleton()->print("\tResulted: %ls\n",s.c_str());
return (wcscmp(s.c_str(),L"Give me")==0);
}
bool test_5() {
OS::get_singleton()->print("\n\nTest 5: Assign from c-widechar (copycon)\n");
String s(L"Wool");
OS::get_singleton()->print("\tExpected: Wool\n");
OS::get_singleton()->print("\tResulted: %ls\n",s.c_str());
return (wcscmp(s.c_str(),L"Wool")==0);
}
bool test_6() {
OS::get_singleton()->print("\n\nTest 6: comparisons (equal)\n");
String s="Test Compare";
OS::get_singleton()->print("\tComparing to \"Test Compare\"\n");
if (! ( s=="Test Compare" ) )
return false;
if (! ( s==L"Test Compare" ) )
return false;
if (! ( s==String("Test Compare") ) )
return false;
return true;
}
bool test_7() {
OS::get_singleton()->print("\n\nTest 7: comparisons (unequal)\n");
String s="Test Compare";
OS::get_singleton()->print("\tComparing to \"Test Compare\"\n");
if (! ( s!="Peanut" ) )
return false;
if (! ( s!=L"Coconut" ) )
return false;
if (! ( s!=String("Butter") ) )
return false;
return true;
}
bool test_8() {
OS::get_singleton()->print("\n\nTest 8: comparisons (operator<)\n");
String s="Bees";
OS::get_singleton()->print("\tComparing to \"Bees\"\n");
if ( ! (s < "Elephant") )
return false;
if ( s < L"Amber" )
return false;
if ( s < String("Beatrix") )
return false;
return true;
}
bool test_9() {
OS::get_singleton()->print("\n\nTest 9: Concatenation\n");
String s;
s+="Have";
s+=' ';
s+='a';
s+=String(" ");
s = s + L"Nice";
s = s + " ";
s = s + String("Day");
OS::get_singleton()->print("\tComparing to \"Have a Nice Day\"\n");
return (s == "Have a Nice Day");
}
bool test_10() {
OS::get_singleton()->print("\n\nTest 10: Misc funcs (size/length/empty/etc)\n");
if (! String("").empty())
return false;
if (String("Mellon").size() != 7)
return false;
if (String("Oranges").length() != 7)
return false;
return true;
}
bool test_11() {
OS::get_singleton()->print("\n\nTest 11: Operator[]\n");
String a="Kugar Sane";
a[0]='S';
a[6]='C';
if (a != "Sugar Cane")
return false;
if (a[1]!='u')
return false;
return true;
}
bool test_12() {
OS::get_singleton()->print("\n\nTest 12: case functions\n");
String a="MoMoNgA";
if (a.to_upper() != "MOMONGA")
return false;
if (a.nocasecmp_to("momonga")!=0)
return false;
return true;
}
bool test_13() {
OS::get_singleton()->print("\n\nTest 13: UTF8\n");
/* how can i embed UTF in here? */
static const CharType ustr[] = { 0x304A , 0x360F, 0x3088, 0x3046, 0 };
// static const wchar_t ustr[] = { 'P', 0xCE, 'p',0xD3, 0 };
String s=ustr;
OS::get_singleton()->print("\tUnicode: %ls\n",ustr);
s.parse_utf8( s.utf8().get_data() );
OS::get_singleton()->print("\tConvert/Parse UTF8: %ls\n",s.c_str());
return (s==ustr);
}
bool test_14() {
OS::get_singleton()->print("\n\nTest 14: ASCII\n");
String s = L"Primero Leche";
OS::get_singleton()->print("\tAscii: %s\n",s.ascii().get_data());
String t=s.ascii().get_data();
return (s==t);
}
bool test_15() {
OS::get_singleton()->print("\n\nTest 15: substr\n");
String s="Killer Baby";
OS::get_singleton()->print("\tsubstr(3,4) of \"%ls\" is \"%ls\"\n",s.c_str(),s.substr(3,4).c_str());
return (s.substr(3,4)=="ler ");
}
bool test_16() {
OS::get_singleton()->print("\n\nTest 16: find\n");
String s="Pretty Woman";
OS::get_singleton()->print("\tString: %ls\n",s.c_str());
OS::get_singleton()->print("\t\"tty\" is at %i pos.\n",s.find("tty"));
OS::get_singleton()->print("\t\"Revenge of the Monster Truck\" is at %i pos.\n",s.find("Revenge of the Monster Truck"));
if (s.find("tty")!=3)
return false;
if (s.find("Revenge of the Monster Truck")!=-1)
return false;
return true;
}
bool test_17() {
OS::get_singleton()->print("\n\nTest 17: find no case\n");
String s="Pretty Whale";
OS::get_singleton()->print("\tString: %ls\n",s.c_str());
OS::get_singleton()->print("\t\"WHA\" is at %i pos.\n",s.findn("WHA"));
OS::get_singleton()->print("\t\"Revenge of the Monster SawFish\" is at %i pos.\n",s.findn("Revenge of the Monster Truck"));
if (s.findn("WHA")!=7)
return false;
if (s.findn("Revenge of the Monster SawFish")!=-1)
return false;
return true;
}
bool test_18() {
OS::get_singleton()->print("\n\nTest 18: find no case\n");
String s="Pretty Whale";
OS::get_singleton()->print("\tString: %ls\n",s.c_str());
OS::get_singleton()->print("\t\"WHA\" is at %i pos.\n",s.findn("WHA"));
OS::get_singleton()->print("\t\"Revenge of the Monster SawFish\" is at %i pos.\n",s.findn("Revenge of the Monster Truck"));
if (s.findn("WHA")!=7)
return false;
if (s.findn("Revenge of the Monster SawFish")!=-1)
return false;
return true;
}
bool test_19() {
OS::get_singleton()->print("\n\nTest 19: Search & replace\n");
String s="Happy Birthday, Anna!";
OS::get_singleton()->print("\tString: %ls\n",s.c_str());
s=s.replace("Birthday","Halloween");
OS::get_singleton()->print("\tReplaced Birthday/Halloween: %ls.\n",s.c_str());
return (s=="Happy Halloween, Anna!");
}
bool test_20() {
OS::get_singleton()->print("\n\nTest 20: Insertion\n");
String s="Who is Frederic?";
OS::get_singleton()->print("\tString: %ls\n",s.c_str());
s=s.insert( s.find("?")," Chopin" );
OS::get_singleton()->print("\tInserted Chopin: %ls.\n",s.c_str());
return (s=="Who is Frederic Chopin?");
}
bool test_21() {
OS::get_singleton()->print("\n\nTest 21: Number -> String\n");
OS::get_singleton()->print("\tPi is %f\n",33.141593);
OS::get_singleton()->print("\tPi String is %ls\n",String::num(3.141593).c_str());
return String::num(3.141593)=="3.141593";
}
bool test_22() {
OS::get_singleton()->print("\n\nTest 22: String -> Int\n");
static const char* nums[4]={ "1237461283", "- 22", "0", " - 1123412" };
static const int num[4]={ 1237461283, -22, 0, -1123412 };
for (int i=0;i<4;i++) {
OS::get_singleton()->print("\tString: \"%s\" as Int is %i\n",nums[i],String(nums[i]).to_int());
if (String(nums[i]).to_int()!=num[i])
return false;
}
return true;
}
bool test_23() {
OS::get_singleton()->print("\n\nTest 23: String -> Float\n");
static const char* nums[4]={ "-12348298412.2", "0.05", "2.0002", " -0.0001" };
static const double num[4]={ -12348298412.2, 0.05, 2.0002, -0.0001 };
for (int i=0;i<4;i++) {
OS::get_singleton()->print("\tString: \"%s\" as Float is %f\n",nums[i],String(nums[i]).to_double());
if ( ABS(String(nums[i]).to_double()-num[i])>0.00001)
return false;
}
return true;
}
bool test_24() {
OS::get_singleton()->print("\n\nTest 24: Slicing\n");
String s="Mars,Jupiter,Saturn,Uranus";
const char*slices[4]={"Mars","Jupiter","Saturn","Uranus"};
OS::get_singleton()->print("\tSlicing \"%ls\" by \"%s\"..\n",s.c_str(),",");
for (int i=0;i<s.get_slice_count(",");i++) {
OS::get_singleton()->print("\t\t%i- %ls\n",i+1,s.get_slice(",",i).c_str());
if (s.get_slice(",",i)!=slices[i])
return false;
}
return true;
}
bool test_25() {
OS::get_singleton()->print("\n\nTest 25: Erasing\n");
String s="Josephine is such a cute girl!";
OS::get_singleton()->print("\tString: %ls\n",s.c_str());
OS::get_singleton()->print("\tRemoving \"cute\"\n");
s.erase(s.find("cute "),String("cute ").length());
OS::get_singleton()->print("\tResult: %ls\n",s.c_str());
return (s=="Josephine is such a girl!");
}
bool test_26() {
OS::get_singleton()->print("\n\nTest 26: RegEx\n");
RegEx regexp("(.*):(.*)");
int res = regexp.find("name:password");
printf("\tmatch: %s\n", (res>=0)?"true":"false");
printf("\t%i captures:\n", regexp.get_capture_count());
for (int i = 0; i<regexp.get_capture_count(); i++)
{
printf("%ls\n", regexp.get_capture(i).c_str());
}
return (res>=0);
};
struct test_27_data {
char const * data;
char const * begin;
bool expected;
};
bool test_27() {
OS::get_singleton()->print("\n\nTest 27: begins_with\n");
test_27_data tc[] = {
{"res://foobar", "res://", true},
{"res", "res://", false},
{"abc", "abc", true}
};
size_t count = sizeof(tc) / sizeof(tc[0]);
bool state = true;
for (size_t i = 0;state && i < count; ++i) {
String s = tc[i].data;
state = s.begins_with(tc[i].begin) == tc[i].expected;
if (state) {
String sb = tc[i].begin;
state = s.begins_with(sb) == tc[i].expected;
}
if (!state) {
OS::get_singleton()->print("\n\t Failure on:\n\t\tstring: ", tc[i].data, "\n\t\tbegin: ", tc[i].begin, "\n\t\texpected: ", tc[i].expected ? "true" : "false", "\n");
break;
}
};
return state;
};
bool test_28() {
OS::get_singleton()->print("\n\nTest 28: sprintf\n");
bool success, state = true;
char output_format[] = "\tTest:\t%ls => %ls (%s)\n";
String format, output;
Array args;
bool error;
// %%
format = "fish %% frog";
args.clear();
output = format.sprintf(args, &error);
success = (output == String("fish % frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
//////// INTS
// Int
format = "fish %d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args, &error);
success = (output == String("fish 5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Int left padded with zeroes.
format = "fish %05d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args, &error);
success = (output == String("fish 00005 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Int left padded with spaces.
format = "fish %5d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args, &error);
success = (output == String("fish 5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Int right padded with spaces.
format = "fish %-5d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args, &error);
success = (output == String("fish 5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Int with sign (positive).
format = "fish %+d frog";
args.clear();
args.push_back(5);
output = format.sprintf(args, &error);
success = (output == String("fish +5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Negative int.
format = "fish %d frog";
args.clear();
args.push_back(-5);
output = format.sprintf(args, &error);
success = (output == String("fish -5 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Hex (lower)
format = "fish %x frog";
args.clear();
args.push_back(45);
output = format.sprintf(args, &error);
success = (output == String("fish 2d frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Hex (upper)
format = "fish %X frog";
args.clear();
args.push_back(45);
output = format.sprintf(args, &error);
success = (output == String("fish 2D frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Octal
format = "fish %o frog";
args.clear();
args.push_back(99);
output = format.sprintf(args, &error);
success = (output == String("fish 143 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
////// REALS
// Real
format = "fish %f frog";
args.clear();
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Real left-padded
format = "fish %11f frog";
args.clear();
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Real right-padded
format = "fish %-11f frog";
args.clear();
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Real given int.
format = "fish %f frog";
args.clear();
args.push_back(99);
output = format.sprintf(args, &error);
success = (output == String("fish 99.000000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Real with sign (positive).
format = "fish %+f frog";
args.clear();
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == String("fish +99.990000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Real with 1 decimals.
format = "fish %.1f frog";
args.clear();
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == String("fish 100.0 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Real with 12 decimals.
format = "fish %.12f frog";
args.clear();
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == String("fish 99.990000000000 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Real with no decimals.
format = "fish %.f frog";
args.clear();
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == String("fish 100 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
/////// Strings.
// String
format = "fish %s frog";
args.clear();
args.push_back("cheese");
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// String left-padded
format = "fish %10s frog";
args.clear();
args.push_back("cheese");
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// String right-padded
format = "fish %-10s frog";
args.clear();
args.push_back("cheese");
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
///// Characters
// Character as string.
format = "fish %c frog";
args.clear();
args.push_back("A");
output = format.sprintf(args, &error);
success = (output == String("fish A frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Character as int.
format = "fish %c frog";
args.clear();
args.push_back(65);
output = format.sprintf(args, &error);
success = (output == String("fish A frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
///// Dynamic width
// String dynamic width
format = "fish %*s frog";
args.clear();
args.push_back(10);
args.push_back("cheese");
output = format.sprintf(args, &error);
success = (output == String("fish cheese frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Int dynamic width
format = "fish %*d frog";
args.clear();
args.push_back(10);
args.push_back(99);
output = format.sprintf(args, &error);
success = (output == String("fish 99 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Float dynamic width
format = "fish %*.*f frog";
args.clear();
args.push_back(10);
args.push_back(3);
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == String("fish 99.990 frog") && !error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
///// Errors
// More formats than arguments.
format = "fish %s %s frog";
args.clear();
args.push_back("cheese");
output = format.sprintf(args, &error);
success = (output == "not enough arguments for format string" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// More arguments than formats.
format = "fish %s frog";
args.clear();
args.push_back("hello");
args.push_back("cheese");
output = format.sprintf(args, &error);
success = (output == "not all arguments converted during string formatting" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Incomplete format.
format = "fish %10";
args.clear();
args.push_back("cheese");
output = format.sprintf(args, &error);
success = (output == "incomplete format" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Bad character in format string
format = "fish %&f frog";
args.clear();
args.push_back("cheese");
output = format.sprintf(args, &error);
success = (output == "unsupported format character" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Too many decimals.
format = "fish %2.2.2f frog";
args.clear();
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == "too many decimal points in format" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// * not a number
format = "fish %*f frog";
args.clear();
args.push_back("cheese");
args.push_back(99.99);
output = format.sprintf(args, &error);
success = (output == "* wants number" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Character too long.
format = "fish %c frog";
args.clear();
args.push_back("sc");
output = format.sprintf(args, &error);
success = (output == "%c requires number or single-character string" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
// Character bad type.
format = "fish %c frog";
args.clear();
args.push_back(Array());
output = format.sprintf(args, &error);
success = (output == "%c requires number or single-character string" && error);
OS::get_singleton()->print(output_format, format.c_str(), output.c_str(), success ? "OK" : "FAIL");
if (!success) state = false;
return state;
}
typedef bool (*TestFunc)(void);
TestFunc test_funcs[] = {
test_1,
test_2,
test_3,
test_4,
test_5,
test_6,
test_7,
test_8,
test_9,
test_10,
test_11,
test_12,
test_13,
test_14,
test_15,
test_16,
test_17,
test_18,
test_19,
test_20,
test_21,
test_22,
test_23,
test_24,
test_25,
test_26,
test_27,
test_28,
0
};
MainLoop* test() {
/** A character length != wchar_t may be forced, so the tests wont work */
ERR_FAIL_COND_V( sizeof(CharType) != sizeof(wchar_t), NULL );
int count=0;
int passed=0;
while(true) {
if (!test_funcs[count])
break;
bool pass=test_funcs[count]();
if (pass)
passed++;
OS::get_singleton()->print("\t%s\n",pass?"PASS":"FAILED");
count++;
}
OS::get_singleton()->print("\n\n\n");
OS::get_singleton()->print("*************\n");
OS::get_singleton()->print("***TOTALS!***\n");
OS::get_singleton()->print("*************\n");
OS::get_singleton()->print("Passed %i of %i tests\n", passed, count);
return NULL;
}
}

44
bin/tests/test_string.h Normal file
View File

@ -0,0 +1,44 @@
/*************************************************************************/
/* test_string.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 TEST_STRING_H
#define TEST_STRING_H
#include "ustring.h"
#include "os/main_loop.h"
namespace TestString {
MainLoop* test();
}
#endif

View File

@ -1,298 +1,65 @@
#!/usr/bin/env python
Import('env')
Import("env")
env.core_sources=[]
gd_call=""
gd_inc=""
for x in env.global_defaults:
env.core_sources.append("#platform/"+x+"/globals/global_defaults.cpp")
gd_inc+='#include "platform/'+x+'/globals/global_defaults.h"\n'
gd_call+="\tregister_"+x+"_global_defaults();\n"
gd_cpp='#include "globals.h"\n'
gd_cpp+=gd_inc
gd_cpp+="void Globals::register_global_defaults() {\n"+gd_call+"\n}\n"
f = open("global_defaults.cpp","wb")
f.write(gd_cpp)
f.close()
import os
txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
e=os.environ["SCRIPT_AES256_ENCRYPTION_KEY"]
txt = ""
ec_valid=True
if (len(e)!=64):
ec_valid=False
else:
import core_builders
for i in range(len(e)>>1):
if (i>0):
txt+=","
txts="0x"+e[i*2:i*2+2]
try:
int(txts,16)
except:
ec_valid=False
txt+=txts
if (not ec_valid):
txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
print("Invalid AES256 encryption key, not 64 bits hex: "+e)
import methods
env.core_sources = []
# Add required thirdparty code.
thirdparty_obj = []
env_thirdparty = env.Clone()
env_thirdparty.disable_warnings()
# Misc thirdparty code: header paths are hardcoded, we don't need to append
# to the include path (saves a few chars on the compiler invocation for touchy MSVC...)
thirdparty_misc_dir = "#thirdparty/misc/"
thirdparty_misc_sources = [
# C sources
"fastlz.c",
"r128.c",
"smaz.c",
# C++ sources
"pcg.cpp",
"polypartition.cpp",
"smolv.cpp",
]
thirdparty_misc_sources = [thirdparty_misc_dir + file for file in thirdparty_misc_sources]
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_misc_sources)
# Brotli
if env["brotli"] and env["builtin_brotli"]:
thirdparty_brotli_dir = "#thirdparty/brotli/"
thirdparty_brotli_sources = [
"common/constants.c",
"common/context.c",
"common/dictionary.c",
"common/platform.c",
"common/shared_dictionary.c",
"common/transform.c",
"dec/bit_reader.c",
"dec/decode.c",
"dec/huffman.c",
"dec/state.c",
]
thirdparty_brotli_sources = [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
env_thirdparty.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
env.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
if env.get("use_ubsan") or env.get("use_asan") or env.get("use_tsan") or env.get("use_lsan") or env.get("use_msan"):
env_thirdparty.Append(CPPDEFINES=["BROTLI_BUILD_PORTABLE"])
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_brotli_sources)
# Clipper2 Thirdparty source files used for polygon and polyline boolean operations.
if env["builtin_clipper2"]:
thirdparty_clipper_dir = "#thirdparty/clipper2/"
thirdparty_clipper_sources = [
"src/clipper.engine.cpp",
"src/clipper.offset.cpp",
"src/clipper.rectclip.cpp",
]
thirdparty_clipper_sources = [thirdparty_clipper_dir + file for file in thirdparty_clipper_sources]
env_thirdparty.Prepend(CPPPATH=[thirdparty_clipper_dir + "include"])
env.Prepend(CPPPATH=[thirdparty_clipper_dir + "include"])
env_thirdparty.Append(CPPDEFINES=["CLIPPER2_ENABLED"])
env.Append(CPPDEFINES=["CLIPPER2_ENABLED"])
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_clipper_sources)
# Zlib library, can be unbundled
if env["builtin_zlib"]:
thirdparty_zlib_dir = "#thirdparty/zlib/"
thirdparty_zlib_sources = [
"adler32.c",
"compress.c",
"crc32.c",
"deflate.c",
"inffast.c",
"inflate.c",
"inftrees.c",
"trees.c",
"uncompr.c",
"zutil.c",
]
thirdparty_zlib_sources = [thirdparty_zlib_dir + file for file in thirdparty_zlib_sources]
env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir])
# Needs to be available in main env too
env.Prepend(CPPPATH=[thirdparty_zlib_dir])
if env.dev_build:
env_thirdparty.Append(CPPDEFINES=["ZLIB_DEBUG"])
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_zlib_sources)
# Minizip library, could be unbundled in theory
# However, our version has some custom modifications, so it won't compile with the system one
thirdparty_minizip_dir = "#thirdparty/minizip/"
thirdparty_minizip_sources = ["ioapi.c", "unzip.c", "zip.c"]
thirdparty_minizip_sources = [thirdparty_minizip_dir + file for file in thirdparty_minizip_sources]
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_minizip_sources)
# Zstd library, can be unbundled in theory
# though we currently use some private symbols
# https://github.com/godotengine/godot/issues/17374
if env["builtin_zstd"]:
thirdparty_zstd_dir = "#thirdparty/zstd/"
thirdparty_zstd_sources = [
"common/debug.c",
"common/entropy_common.c",
"common/error_private.c",
"common/fse_decompress.c",
"common/pool.c",
"common/threading.c",
"common/xxhash.c",
"common/zstd_common.c",
"compress/fse_compress.c",
"compress/hist.c",
"compress/huf_compress.c",
"compress/zstd_compress.c",
"compress/zstd_double_fast.c",
"compress/zstd_fast.c",
"compress/zstd_lazy.c",
"compress/zstd_ldm.c",
"compress/zstd_opt.c",
"compress/zstdmt_compress.c",
"compress/zstd_compress_literals.c",
"compress/zstd_compress_sequences.c",
"compress/zstd_compress_superblock.c",
"decompress/huf_decompress.c",
"decompress/zstd_ddict.c",
"decompress/zstd_decompress_block.c",
"decompress/zstd_decompress.c",
]
if env["platform"] in ["android", "ios", "linuxbsd", "macos"]:
# Match platforms with ZSTD_ASM_SUPPORTED in common/portability_macros.h
thirdparty_zstd_sources.append("decompress/huf_decompress_amd64.S")
thirdparty_zstd_sources = [thirdparty_zstd_dir + file for file in thirdparty_zstd_sources]
env_thirdparty.Prepend(CPPPATH=[thirdparty_zstd_dir, thirdparty_zstd_dir + "common"])
env_thirdparty.Append(CPPDEFINES=["ZSTD_STATIC_LINKING_ONLY"])
env.Prepend(CPPPATH=thirdparty_zstd_dir)
# Also needed in main env includes will trigger warnings
env.Append(CPPDEFINES=["ZSTD_STATIC_LINKING_ONLY"])
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_zstd_sources)
f = open("script_encryption_key.cpp", "wb")
f.write("#include \"globals.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
f.close()
env.core_sources += thirdparty_obj
env.add_source_files(env.core_sources,"*.cpp")
# Godot source files
Export('env')
env.add_source_files(env.core_sources, "*.cpp")
import make_binders
env.Command(['method_bind.inc','method_bind_ext.inc'], 'make_binders.py', make_binders.run)
SConscript('os/SCsub');
SConscript('math/SCsub');
SConscript('io/SCsub');
SConscript('bind/SCsub');
# Generate disabled classes
def disabled_class_builder(target, source, env):
with methods.generated_wrapper(target) as file:
for c in source[0].read():
cs = c.strip()
if cs != "":
file.write(f"#define ClassDB_Disable_{cs} 1\n")
lib = env.Library("core",env.core_sources)
env.CommandNoCache("disabled_classes.gen.h", env.Value(env.disabled_classes), env.Run(disabled_class_builder))
# Generate version info
def version_info_builder(target, source, env):
with methods.generated_wrapper(target) as file:
file.write(
"""\
#define VERSION_SHORT_NAME "{short_name}"
#define VERSION_NAME "{name}"
#define VERSION_MAJOR {major}
#define VERSION_MINOR {minor}
#define VERSION_PATCH {patch}
#define VERSION_STATUS "{status}"
#define VERSION_BUILD "{build}"
#define VERSION_MODULE_CONFIG "{module_config}"
#define VERSION_WEBSITE "{website}"
#define VERSION_DOCS_BRANCH "{docs_branch}"
#define VERSION_DOCS_URL "https://docs.godotengine.org/en/" VERSION_DOCS_BRANCH
""".format(**env.version_info)
)
env.CommandNoCache("version_generated.gen.h", env.Value(env.version_info), env.Run(version_info_builder))
# Generate version hash
def version_hash_builder(target, source, env):
with methods.generated_wrapper(target) as file:
file.write(
"""\
#include "core/version.h"
const char *const VERSION_HASH = "{git_hash}";
const uint64_t VERSION_TIMESTAMP = {git_timestamp};
""".format(**env.version_info)
)
gen_hash = env.CommandNoCache(
"version_hash.gen.cpp", env.Value(env.version_info["git_hash"]), env.Run(version_hash_builder)
)
env.add_source_files(env.core_sources, gen_hash)
# Generate AES256 script encryption key
def encryption_key_builder(target, source, env):
with methods.generated_wrapper(target) as file:
file.write(
f"""\
#include "core/config/project_settings.h"
uint8_t script_encryption_key[32] = {{
{source[0]}
}};"""
)
gdkey = os.environ.get("SCRIPT_AES256_ENCRYPTION_KEY", "0" * 64)
ec_valid = len(gdkey) == 64
if ec_valid:
try:
gdkey = ", ".join([str(int(f"{a}{b}", 16)) for a, b in zip(gdkey[0::2], gdkey[1::2])])
except Exception:
ec_valid = False
if not ec_valid:
methods.print_error(
f'Invalid AES256 encryption key, not 64 hexadecimal characters: "{gdkey}".\n'
"Unset `SCRIPT_AES256_ENCRYPTION_KEY` in your environment "
"or make sure that it contains exactly 64 hexadecimal characters."
)
Exit(255)
gen_encrypt = env.CommandNoCache("script_encryption_key.gen.cpp", env.Value(gdkey), env.Run(encryption_key_builder))
env.add_source_files(env.core_sources, gen_encrypt)
# Certificates
env.Depends(
"#core/io/certs_compressed.gen.h",
["#thirdparty/certs/ca-certificates.crt", env.Value(env["builtin_certs"]), env.Value(env["system_certs_path"])],
)
env.CommandNoCache(
"#core/io/certs_compressed.gen.h",
"#thirdparty/certs/ca-certificates.crt",
env.Run(core_builders.make_certs_header),
)
# Authors
env.Depends("#core/authors.gen.h", "../AUTHORS.md")
env.CommandNoCache("#core/authors.gen.h", "../AUTHORS.md", env.Run(core_builders.make_authors_header))
# Donors
env.Depends("#core/donors.gen.h", "../DONORS.md")
env.CommandNoCache("#core/donors.gen.h", "../DONORS.md", env.Run(core_builders.make_donors_header))
# License
env.Depends("#core/license.gen.h", ["../COPYRIGHT.txt", "../LICENSE.txt"])
env.CommandNoCache(
"#core/license.gen.h",
["../COPYRIGHT.txt", "../LICENSE.txt"],
env.Run(core_builders.make_license_header),
)
# Chain load SCsubs
SConscript("os/SCsub")
SConscript("math/SCsub")
SConscript("crypto/SCsub")
SConscript("io/SCsub")
SConscript("debugger/SCsub")
SConscript("input/SCsub")
SConscript("variant/SCsub")
SConscript("extension/SCsub")
SConscript("object/SCsub")
SConscript("templates/SCsub")
SConscript("string/SCsub")
SConscript("config/SCsub")
SConscript("error/SCsub")
# Build it all as a library
lib = env.add_library("core", env.core_sources)
env.Prepend(LIBS=[lib])
# Needed to force rebuilding the core files when the thirdparty code is updated.
env.Depends(lib, thirdparty_obj)

198
core/allocators.h Normal file
View File

@ -0,0 +1,198 @@
/*************************************************************************/
/* allocators.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 ALLOCATORS_H
#define ALLOCATORS_H
#include "os/memory.h"
template<int PREALLOC_COUNT=64, int MAX_HANDS=8>
class BalloonAllocator {
enum {
USED_FLAG=(1<<30),
USED_MASK=USED_FLAG-1
};
struct Balloon {
Balloon *next;
Balloon *prev;
uint32_t hand;
};
struct Hand {
int used;
int allocated;
Balloon *first;
Balloon *last;
};
Hand hands[MAX_HANDS];
public:
void* alloc(size_t p_size) {
size_t max=(1<<MAX_HANDS);
ERR_FAIL_COND_V( p_size>max, NULL );
unsigned int hand=0;
while(p_size>(size_t)(1<<hand)) ++hand;
Hand &h=hands[hand];
if (h.used==h.allocated) {
for(int i=0;i<PREALLOC_COUNT;i++) {
Balloon *b = (Balloon*)memalloc(sizeof(Balloon)+(1<<hand));
b->hand=hand;
if (h.last) {
b->prev=h.last;
h.last->next=b;
h.last=b;
} else {
b->prev=NULL;
h.last=b;
h.first=b;
}
}
h.last->next=NULL;
h.allocated+=PREALLOC_COUNT;
}
Balloon *pick=h.last;
ERR_FAIL_COND_V( (pick->hand&USED_FLAG), NULL );
// remove last
h.last=h.last->prev;
h.last->next=NULL;
pick->next=h.first;
h.first->prev=pick;
pick->prev=NULL;
h.first=pick;
h.used++;
pick->hand|=USED_FLAG;
return (void*)(pick+1);
}
void free(void* p_ptr) {
Balloon *b=(Balloon*)p_ptr;
b-=1;
ERR_FAIL_COND(!(b->hand&USED_FLAG) );
b->hand=b->hand&USED_MASK; // not used
int hand=b->hand;
Hand &h=hands[hand];
if (b==h.first)
h.first=b->next;
if (b->prev)
b->prev->next=b->next;
if (b->next)
b->next->prev=b->prev;
if (h.last!=b) {
h.last->next=b;
b->prev=h.last;
b->next=NULL;
h.last=b;
}
h.used--;
if (h.used<=(h.allocated-(PREALLOC_COUNT*2))) { // this is done to ensure no alloc/free is done constantly
for(int i=0;i<PREALLOC_COUNT;i++) {
ERR_CONTINUE( h.last->hand& USED_FLAG );
Balloon *new_last=h.last->prev;
if (new_last)
new_last->next=NULL;
memfree( h.last );
h.last=new_last;
}
h.allocated-=PREALLOC_COUNT;
}
}
BalloonAllocator() {
for(int i=0;i<MAX_HANDS;i++) {
hands[i].allocated=0;
hands[i].used=0;
hands[i].first=NULL;
hands[i].last=NULL;
}
}
void clear() {
for(int i=0;i<MAX_HANDS;i++) {
while(hands[i].first) {
Balloon *b=hands[i].first;
hands[i].first=b->next;
memfree(b);
}
hands[i].allocated=0;
hands[i].used=0;
hands[i].first=NULL;
hands[i].last=NULL;
}
}
~BalloonAllocator() {
clear();
}
};
#endif // ALLOCATORS_H

259
core/array.cpp Normal file
View File

@ -0,0 +1,259 @@
/*************************************************************************/
/* array.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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.h"
#include "vector.h"
#include "hashfuncs.h"
#include "variant.h"
#include "object.h"
struct ArrayPrivate {
SafeRefCount refcount;
Vector<Variant> array;
bool shared;
};
void Array::_ref(const Array& p_from) const {
ArrayPrivate *_fp = p_from._p;
ERR_FAIL_COND(!_fp); // should NOT happen.
if (_fp == _p)
return; //wathever it is, nothing to do here move along
bool success = _fp->refcount.ref();
ERR_FAIL_COND(!success); //should really not happen either
_unref();
if (_fp->shared) {
_p = p_from._p;
} else {
_p = memnew( ArrayPrivate );
_p->shared=false;
_p->refcount.init();
_p->array=_fp->array;
if (_fp->refcount.unref())
memdelete(_fp);
}
}
void Array::_unref() const {
if (!_p)
return;
if (_p->refcount.unref()) {
memdelete(_p);
}
_p=NULL;
}
Variant& Array::operator[](int p_idx) {
return _p->array[p_idx];
}
const Variant& Array::operator[](int p_idx) const {
return _p->array[p_idx];
}
int Array::size() const {
return _p->array.size();
}
bool Array::empty() const {
return _p->array.empty();
}
void Array::clear() {
_p->array.clear();
}
bool Array::is_shared() const {
return _p->shared;
}
bool Array::operator==(const Array& p_array) const {
return _p==p_array._p;
}
uint32_t Array::hash() const {
uint32_t h=hash_djb2_one_32(0);
for (int i=0;i<_p->array.size();i++) {
h = hash_djb2_one_32( _p->array[i].hash(), h);
}
return h;
}
void Array::operator=(const Array& p_array) {
_ref(p_array);
}
void Array::push_back(const Variant& p_value) {
_p->array.push_back(p_value);
}
Error Array::resize(int p_new_size) {
return _p->array.resize(p_new_size);
}
void Array::insert(int p_pos, const Variant& p_value) {
_p->array.insert(p_pos,p_value);
}
void Array::erase(const Variant& p_value) {
_p->array.erase(p_value);
}
int Array::find(const Variant& p_value) const {
return _p->array.find(p_value);
}
void Array::remove(int p_pos) {
_p->array.remove(p_pos);
}
void Array::set(int p_idx,const Variant& p_value) {
operator[](p_idx)=p_value;
}
const Variant& Array::get(int p_idx) const {
return operator[](p_idx);
}
struct _ArrayVariantSort {
_FORCE_INLINE_ bool operator()(const Variant& p_l, const Variant& p_r) const {
bool valid=false;
Variant res;
Variant::evaluate(Variant::OP_LESS,p_l,p_r,res,valid);
if (!valid)
res=false;
return res;
}
};
void Array::sort() {
_p->array.sort_custom<_ArrayVariantSort>();
}
struct _ArrayVariantSortCustom {
Object *obj;
StringName func;
_FORCE_INLINE_ bool operator()(const Variant& p_l, const Variant& p_r) const {
const Variant*args[2]={&p_l,&p_r};
Variant::CallError err;
bool res = obj->call(func,args,2,err);
if (err.error!=Variant::CallError::CALL_OK)
res=false;
return res;
}
};
void Array::sort_custom(Object *p_obj,const StringName& p_function){
ERR_FAIL_NULL(p_obj);
SortArray<Variant,_ArrayVariantSortCustom> avs;
avs.compare.obj=p_obj;
avs.compare.func=p_function;
avs.sort(_p->array.ptr(),_p->array.size());
}
void Array::invert(){
_p->array.invert();
}
void Array::push_front(const Variant& p_value) {
_p->array.insert(0,p_value);
}
void Array::pop_back(){
if (!_p->array.empty())
_p->array.resize( _p->array.size() -1 );
}
void Array::pop_front(){
if (!_p->array.empty())
_p->array.remove(0);
}
Array::Array(const Array& p_from) {
_p=NULL;
_ref(p_from);
}
Array::Array(bool p_shared) {
_p = memnew( ArrayPrivate );
_p->refcount.init();
_p->shared=p_shared;
}
Array::~Array() {
_unref();
}

88
core/array.h Normal file
View File

@ -0,0 +1,88 @@
/*************************************************************************/
/* array.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef ARRAY_H
#define ARRAY_H
#include "typedefs.h"
class Variant;
class ArrayPrivate;
class Object;
class StringName;
class Array {
mutable ArrayPrivate *_p;
void _ref(const Array& p_from) const;
void _unref() const;
public:
Variant& operator[](int p_idx);
const Variant& operator[](int p_idx) const;
void set(int p_idx,const Variant& p_value);
const Variant& get(int p_idx) const;
int size() const;
bool empty() const;
void clear();
bool is_shared() const;
bool operator==(const Array& p_array) const;
uint32_t hash() const;
void operator=(const Array& p_array);
void push_back(const Variant& p_value);
_FORCE_INLINE_ void append(const Variant& p_value) { push_back(p_value); } //for python compatibility
Error resize(int p_new_size);
void insert(int p_pos, const Variant& p_value);
void remove(int p_pos);
void sort();
void sort_custom(Object *p_obj,const StringName& p_function);
void invert();
int find(const Variant& p_value) const;
void erase(const Variant& p_value);
void push_front(const Variant& p_value);
void pop_back();
void pop_front();
Array(const Array& p_from);
Array(bool p_shared=false);
~Array();
};
#endif // ARRAY_H

35
core/balloon_allocator.h Normal file
View File

@ -0,0 +1,35 @@
/*************************************************************************/
/* balloon_allocator.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 BALLOON_ALLOCATOR_H
#define BALLOON_ALLOCATOR_H
#include "os/memory.h"
#include "allocators.h"
#endif // BALLOON_ALLOCATOR_H

5
core/bind/SCsub Normal file
View File

@ -0,0 +1,5 @@
Import('env')
env.add_source_files(env.core_sources,"*.cpp")
Export('env')

2027
core/bind/core_bind.cpp Normal file

File diff suppressed because it is too large Load Diff

538
core/bind/core_bind.h Normal file
View File

@ -0,0 +1,538 @@
#ifndef CORE_BIND_H
#define CORE_BIND_H
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/file_access.h"
#include "os/dir_access.h"
#include "os/thread.h"
#include "os/semaphore.h"
class _ResourceLoader : public Object {
OBJ_TYPE(_ResourceLoader,Object);
protected:
static void _bind_methods();
static _ResourceLoader *singleton;
public:
static _ResourceLoader *get_singleton() { return singleton; }
Ref<ResourceInteractiveLoader> load_interactive(const String& p_path,const String& p_type_hint="");
RES load(const String &p_path,const String& p_type_hint="", bool p_no_cache = false);
DVector<String> get_recognized_extensions_for_type(const String& p_type);
void set_abort_on_missing_resources(bool p_abort);
StringArray get_dependencies(const String& p_path);
bool has(const String& p_path);
_ResourceLoader();
};
class _ResourceSaver : public Object {
OBJ_TYPE(_ResourceSaver,Object);
protected:
static void _bind_methods();
static _ResourceSaver *singleton;
public:
enum SaverFlags {
FLAG_RELATIVE_PATHS=1,
FLAG_BUNDLE_RESOURCES=2,
FLAG_CHANGE_PATH=4,
FLAG_OMIT_EDITOR_PROPERTIES=8,
FLAG_SAVE_BIG_ENDIAN=16,
FLAG_COMPRESS=32,
};
static _ResourceSaver *get_singleton() { return singleton; }
Error save(const String &p_path,const RES& p_resource, uint32_t p_flags);
DVector<String> get_recognized_extensions(const RES& p_resource);
_ResourceSaver();
};
class MainLoop;
class _OS : public Object {
OBJ_TYPE(_OS,Object);
protected:
static void _bind_methods();
static _OS *singleton;
public:
enum Weekday {
DAY_SUNDAY,
DAY_MONDAY,
DAY_TUESDAY,
DAY_WEDNESDAY,
DAY_THURSDAY,
DAY_FRIDAY,
DAY_SATURDAY
};
enum Month {
MONTH_JANUARY,
MONTH_FEBRUARY,
MONTH_MARCH,
MONTH_APRIL,
MONTH_MAY,
MONTH_JUNE,
MONTH_JULY,
MONTH_AUGUST,
MONTH_SEPTEMBER,
MONTH_OCTOBER,
MONTH_NOVEMBER,
MONTH_DECEMBER
};
Point2 get_mouse_pos() const;
void set_window_title(const String& p_title);
int get_mouse_button_state() const;
void set_clipboard(const String& p_text);
String get_clipboard() const;
void set_video_mode(const Size2& p_size, bool p_fullscreen,bool p_resizeable,int p_screen=0);
Size2 get_video_mode(int p_screen=0) const;
bool is_video_mode_fullscreen(int p_screen=0) const;
bool is_video_mode_resizable(int p_screen=0) const;
Array get_fullscreen_mode_list(int p_screen=0) const;
virtual int get_screen_count() const;
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
virtual Point2 get_screen_position(int p_screen=0) const;
virtual Size2 get_screen_size(int p_screen=0) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2& p_position);
virtual Size2 get_window_size() const;
virtual void set_window_size(const Size2& p_size);
virtual void set_window_fullscreen(bool p_enabled);
virtual bool is_window_fullscreen() const;
virtual void set_window_resizable(bool p_enabled);
virtual bool is_window_resizable() const;
virtual void set_window_minimized(bool p_enabled);
virtual bool is_window_minimized() const;
virtual void set_window_maximized(bool p_enabled);
virtual bool is_window_maximized() const;
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
bool native_video_is_playing();
void native_video_pause();
void native_video_unpause();
void native_video_stop();
void set_iterations_per_second(int p_ips);
int get_iterations_per_second() const;
void set_target_fps(int p_fps);
float get_target_fps() const;
void set_low_processor_usage_mode(bool p_enabled);
bool is_in_low_processor_usage_mode() const;
String get_executable_path() const;
int execute(const String& p_path, const Vector<String> & p_arguments,bool p_blocking,Array p_output=Array());
Error kill(int p_pid);
Error shell_open(String p_uri);
int get_process_ID() const;
bool has_environment(const String& p_var) const;
String get_environment(const String& p_var) const;
String get_name() const;
Vector<String> get_cmdline_args();
String get_locale() const;
String get_model_name() const;
MainLoop *get_main_loop() const;
String get_custom_level() const;
float get_frames_per_second() const;
void dump_memory_to_file(const String& p_file);
void dump_resources_to_file(const String& p_file);
void print_resources_in_use(bool p_short=false);
void print_all_resources(const String& p_to_file);
void print_all_textures_by_size();
void print_resources_by_type(const Vector<String>& p_types);
bool has_touchscreen_ui_hint() const;
bool is_debug_build() const;
String get_unique_ID() const;
String get_scancode_string(uint32_t p_code) const;
bool is_scancode_unicode(uint32_t p_unicode) const;
int find_scancode_from_string(const String& p_code) const;
/*
struct Date {
int year;
Month month;
int day;
Weekday weekday;
bool dst;
};
struct Time {
int hour;
int min;
int sec;
};
*/
void set_use_file_access_save_and_swap(bool p_enable);
void set_icon(const Image& p_icon);
Dictionary get_date(bool utc) const;
Dictionary get_time(bool utc) const;
Dictionary get_time_zone_info() const;
uint64_t get_unix_time() const;
uint64_t get_system_time_secs() const;
int get_static_memory_usage() const;
int get_static_memory_peak_usage() const;
int get_dynamic_memory_usage() const;
void delay_usec(uint32_t p_usec) const;
void delay_msec(uint32_t p_msec) const;
uint32_t get_ticks_msec() const;
uint32_t get_splash_tick_msec() const;
bool can_use_threads() const;
bool can_draw() const;
int get_frames_drawn();
bool is_stdout_verbose() const;
int get_processor_count() const;
enum SystemDir {
SYSTEM_DIR_DESKTOP,
SYSTEM_DIR_DCIM,
SYSTEM_DIR_DOCUMENTS,
SYSTEM_DIR_DOWNLOADS,
SYSTEM_DIR_MOVIES,
SYSTEM_DIR_MUSIC,
SYSTEM_DIR_PICTURES,
SYSTEM_DIR_RINGTONES,
};
enum ScreenOrientation {
SCREEN_ORIENTATION_LANDSCAPE,
SCREEN_ORIENTATION_PORTRAIT,
SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
SCREEN_ORIENTATION_REVERSE_PORTRAIT,
SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
SCREEN_ORIENTATION_SENSOR_PORTRAIT,
SCREEN_ORIENTATION_SENSOR,
};
String get_system_dir(SystemDir p_dir) const;
String get_data_dir() const;
void alert(const String& p_alert,const String& p_title="ALERT!");
void set_screen_orientation(ScreenOrientation p_orientation);
ScreenOrientation get_screen_orientation() const;
void set_keep_screen_on(bool p_enabled);
bool is_keep_screen_on() const;
void set_time_scale(float p_scale);
float get_time_scale();
bool is_ok_left_and_cancel_right() const;
Error set_thread_name(const String& p_name);
static _OS *get_singleton() { return singleton; }
_OS();
};
VARIANT_ENUM_CAST(_OS::SystemDir);
VARIANT_ENUM_CAST(_OS::ScreenOrientation);
class _Geometry : public Object {
OBJ_TYPE(_Geometry, Object);
static _Geometry *singleton;
protected:
static void _bind_methods();
public:
static _Geometry *get_singleton();
DVector<Plane> build_box_planes(const Vector3& p_extents);
DVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis=Vector3::AXIS_Z);
DVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis=Vector3::AXIS_Z);
Variant segment_intersects_segment_2d(const Vector2& p_from_a,const Vector2& p_to_a,const Vector2& p_from_b,const Vector2& p_to_b);
DVector<Vector2> get_closest_points_between_segments_2d( const Vector2& p1,const Vector2& q1, const Vector2& p2,const Vector2& q2);
DVector<Vector3> get_closest_points_between_segments(const Vector3& p1,const Vector3& p2,const Vector3& q1,const Vector3& q2);
Vector3 get_closest_point_to_segment(const Vector3& p_point, const Vector3& p_a,const Vector3& p_b);
Variant ray_intersects_triangle( const Vector3& p_from, const Vector3& p_dir, const Vector3& p_v0,const Vector3& p_v1,const Vector3& p_v2);
Variant segment_intersects_triangle( const Vector3& p_from, const Vector3& p_to, const Vector3& p_v0,const Vector3& p_v1,const Vector3& p_v2);
bool point_is_inside_triangle(const Vector2& s, const Vector2& a, const Vector2& b, const Vector2& c) const;
DVector<Vector3> segment_intersects_sphere( const Vector3& p_from, const Vector3& p_to, const Vector3& p_sphere_pos,real_t p_sphere_radius);
DVector<Vector3> segment_intersects_cylinder( const Vector3& p_from, const Vector3& p_to, float p_height,float p_radius);
DVector<Vector3> segment_intersects_convex(const Vector3& p_from, const Vector3& p_to,const Vector<Plane>& p_planes);
real_t segment_intersects_circle(const Vector2& p_from, const Vector2& p_to, const Vector2& p_circle_pos, real_t p_circle_radius);
int get_uv84_normal_bit(const Vector3& p_vector);
Vector<int> triangulate_polygon(const Vector<Vector2>& p_polygon);
Dictionary make_atlas(const Vector<Size2>& p_rects);
_Geometry();
};
class _File : public Reference {
OBJ_TYPE(_File,Reference);
FileAccess *f;
bool eswap;
protected:
static void _bind_methods();
public:
enum ModeFlags {
READ=1,
WRITE=2,
READ_WRITE=3,
WRITE_READ=7,
};
Error open_encrypted(const String& p_path, int p_mode_flags,const Vector<uint8_t>& p_key);
Error open_encrypted_pass(const String& p_path, int p_mode_flags,const String& p_pass);
Error open(const String& p_path, int p_mode_flags); ///< open a file
void close(); ///< close a file
bool is_open() const; ///< true when file is open
void seek(int64_t p_position); ///< seek to a given position
void seek_end(int64_t p_position=0); ///< seek from the end of file
int64_t get_pos() const; ///< get position in the file
int64_t get_len() const; ///< get size of the file
bool eof_reached() const; ///< reading passed EOF
uint8_t get_8() const; ///< get a byte
uint16_t get_16() const; ///< get 16 bits uint
uint32_t get_32() const; ///< get 32 bits uint
uint64_t get_64() const; ///< get 64 bits uint
float get_float() const;
double get_double() const;
real_t get_real() const;
Variant get_var() const;
DVector<uint8_t> get_buffer(int p_length) const; ///< get an array of bytes
String get_line() const;
String get_as_text() const;
/**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
* It's not about the current CPU type but file formats.
* this flags get reset to false (little endian) on each open
*/
void set_endian_swap(bool p_swap);
bool get_endian_swap();
Error get_error() const; ///< get last error
void store_8(uint8_t p_dest); ///< store a byte
void store_16(uint16_t p_dest); ///< store 16 bits uint
void store_32(uint32_t p_dest); ///< store 32 bits uint
void store_64(uint64_t p_dest); ///< store 64 bits uint
void store_float(float p_dest);
void store_double(double p_dest);
void store_real(real_t p_real);
void store_string(const String& p_string);
void store_line(const String& p_string);
virtual void store_pascal_string(const String& p_string);
virtual String get_pascal_string();
Vector<String> get_csv_line(String delim=",") const;
void store_buffer(const DVector<uint8_t>& p_buffer); ///< store an array of bytes
void store_var(const Variant& p_var);
bool file_exists(const String& p_name) const; ///< return true if a file exists
_File();
virtual ~_File();
};
class _Directory : public Reference {
OBJ_TYPE(_Directory,Reference);
DirAccess *d;
protected:
static void _bind_methods();
public:
Error open(const String& p_path);
bool list_dir_begin(); ///< This starts dir listing
String get_next();
bool current_is_dir() const;
void list_dir_end(); ///<
int get_drive_count();
String get_drive(int p_drive);
Error change_dir(String p_dir); ///< can be relative or absolute, return false on success
String get_current_dir(); ///< return current dir location
Error make_dir(String p_dir);
Error make_dir_recursive(String p_dir);
bool file_exists(String p_file);
bool dir_exists(String p_dir);
int get_space_left();
Error copy(String p_from,String p_to);
Error rename(String p_from, String p_to);
Error remove(String p_name);
_Directory();
virtual ~_Directory();
};
class _Marshalls : public Reference {
OBJ_TYPE(_Marshalls,Reference);
protected:
static void _bind_methods();
public:
String variant_to_base64(const Variant& p_var);
Variant base64_to_variant(const String& p_str);
String raw_to_base64(const DVector<uint8_t>& p_arr);
DVector<uint8_t> base64_to_raw(const String& p_str);
String utf8_to_base64(const String& p_str);
String base64_to_utf8(const String& p_str);
_Marshalls() {};
};
class _Mutex : public Reference {
OBJ_TYPE(_Mutex,Reference);
Mutex *mutex;
static void _bind_methods();
public:
void lock();
Error try_lock();
void unlock();
_Mutex();
~_Mutex();
};
class _Semaphore : public Reference {
OBJ_TYPE(_Semaphore,Reference);
Semaphore *semaphore;
static void _bind_methods();
public:
Error wait();
Error post();
_Semaphore();
~_Semaphore();
};
class _Thread : public Reference {
OBJ_TYPE(_Thread,Reference);
protected:
Variant ret;
Variant userdata;
volatile bool active;
Object *target_instance;
StringName target_method;
Thread *thread;
static void _bind_methods();
static void _start_func(void *ud);
public:
enum Priority {
PRIORITY_LOW,
PRIORITY_NORMAL,
PRIORITY_HIGH
};
Error start(Object *p_instance,const StringName& p_method,const Variant& p_userdata=Variant(),int p_priority=PRIORITY_NORMAL);
String get_id() const;
bool is_active() const;
Variant wait_to_finish();
_Thread();
~_Thread();
};
#endif // CORE_BIND_H

379
core/color.cpp Normal file
View File

@ -0,0 +1,379 @@
/*************************************************************************/
/* color.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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.h"
#include "math_funcs.h"
#include "print_string.h"
uint32_t Color::to_ARGB32() const {
uint32_t c=(uint8_t)(a*255);
c<<=8;
c|=(uint8_t)(r*255);
c<<=8;
c|=(uint8_t)(g*255);
c<<=8;
c|=(uint8_t)(b*255);
return c;
}
uint32_t Color::to_32() const {
uint32_t c=(uint8_t)(a*255);
c<<=8;
c|=(uint8_t)(r*255);
c<<=8;
c|=(uint8_t)(g*255);
c<<=8;
c|=(uint8_t)(b*255);
return c;
}
float Color::get_h() const {
float min = MIN( r, g );
min = MIN( min, b );
float max = MAX( r, g );
max = MAX( max, b );
float delta = max - min;
if( delta == 0 )
return 0;
float h;
if( r == max )
h = ( g - b ) / delta; // between yellow & magenta
else if( g == max )
h = 2 + ( b - r ) / delta; // between cyan & yellow
else
h = 4 + ( r - g ) / delta; // between magenta & cyan
h/=6.0;
if (h<0)
h+=1.0;
return h;
}
float Color::get_s() const {
float min = MIN( r, g );
min = MIN( min, b );
float max = MAX( r, g );
max = MAX( max, b );
float delta = max - min;
return (max!=0) ? (delta / max) : 0;
}
float Color::get_v() const {
float max = MAX( r, g );
max = MAX( max, b );
return max;
}
void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
int i;
float f, p, q, t;
a=p_alpha;
if( p_s == 0 ) {
// acp_hromatic (grey)
r = g = b = p_v;
return;
}
p_h *=6.0;
p_h = Math::fmod(p_h,6);
i = Math::floor( p_h );
f = p_h - i;
p = p_v * ( 1 - p_s );
q = p_v * ( 1 - p_s * f );
t = p_v * ( 1 - p_s * ( 1 - f ) );
switch( i ) {
case 0: // Red is the dominant color
r = p_v;
g = t;
b = p;
break;
case 1: // Green is the dominant color
r = q;
g = p_v;
b = p;
break;
case 2:
r = p;
g = p_v;
b = t;
break;
case 3: // Blue is the dominant color
r = p;
g = q;
b = p_v;
break;
case 4:
r = t;
g = p;
b = p_v;
break;
default: // (5) Red is the dominant color
r = p_v;
g = p;
b = q;
break;
}
}
void Color::invert() {
r=1.0-r;
g=1.0-g;
b=1.0-b;
}
void Color::contrast() {
r=Math::fmod(r+0.5,1.0);
g=Math::fmod(g+0.5,1.0);
b=Math::fmod(b+0.5,1.0);
}
Color Color::hex(uint32_t p_hex) {
float a = (p_hex&0xFF)/255.0;
p_hex>>=8;
float b = (p_hex&0xFF)/255.0;
p_hex>>=8;
float g = (p_hex&0xFF)/255.0;
p_hex>>=8;
float r = (p_hex&0xFF)/255.0;
return Color(r,g,b,a);
}
static float _parse_col(const String& p_str, int p_ofs) {
int ig=0;
for(int i=0;i<2;i++) {
int c=p_str[i+p_ofs];
int v=0;
if (c>='0' && c<='9') {
v=c-'0';
} else if (c>='a' && c<='f') {
v=c-'a';
v+=10;
} else if (c>='A' && c<='F') {
v=c-'A';
v+=10;
} else {
return -1;
}
if (i==0)
ig+=v*16;
else
ig+=v;
}
return ig;
}
Color Color::inverted() const {
Color c=*this;
c.invert();
return c;
}
Color Color::contrasted() const {
Color c=*this;
c.contrast();
return c;
}
Color Color::html(const String& p_color) {
String color = p_color;
if (color.length()==0)
return Color();
if (color[0]=='#')
color=color.substr(1,color.length()-1);
bool alpha=false;
if (color.length()==8) {
alpha=true;
} else if (color.length()==6) {
alpha=false;
} else {
ERR_EXPLAIN("Invalid Color Code: "+p_color);
ERR_FAIL_V(Color());
}
int a=255;
if (alpha) {
a=_parse_col(color,0);
if (a<0) {
ERR_EXPLAIN("Invalid Color Code: "+p_color);
ERR_FAIL_V(Color());
}
}
int from=alpha?2:0;
int r=_parse_col(color,from+0);
if (r<0) {
ERR_EXPLAIN("Invalid Color Code: "+p_color);
ERR_FAIL_V(Color());
}
int g=_parse_col(color,from+2);
if (g<0) {
ERR_EXPLAIN("Invalid Color Code: "+p_color);
ERR_FAIL_V(Color());
}
int b=_parse_col(color,from+4);
if (b<0) {
ERR_EXPLAIN("Invalid Color Code: "+p_color);
ERR_FAIL_V(Color());
}
return Color(r/255.0,g/255.0,b/255.0,a/255.0);
}
bool Color::html_is_valid(const String& p_color) {
String color = p_color;
if (color.length()==0)
return false;
if (color[0]=='#')
color=color.substr(1,color.length()-1);
bool alpha=false;
if (color.length()==8) {
alpha=true;
} else if (color.length()==6) {
alpha=false;
} else {
return false;
}
int a=255;
if (alpha) {
a=_parse_col(color,0);
if (a<0) {
return false;
}
}
int from=alpha?2:0;
int r=_parse_col(color,from+0);
if (r<0) {
return false;
}
int g=_parse_col(color,from+2);
if (g<0) {
return false;
}
int b=_parse_col(color,from+4);
if (b<0) {
return false;
}
return true;
}
String _to_hex(float p_val) {
int v = p_val * 255;
v = CLAMP(v,0,255);
String ret;
for(int i=0;i<2;i++) {
CharType c[2]={0,0};
int lv = v&0xF;
if (lv<10)
c[0]='0'+lv;
else
c[0]='a'+lv-10;
v>>=4;
String cs=(const CharType*)c;
ret = cs + ret;
}
return ret;
}
String Color::to_html(bool p_alpha) const {
String txt;
txt+=_to_hex(r);
txt+=_to_hex(g);
txt+=_to_hex(b);
if (p_alpha)
txt=_to_hex(a)+txt;
return txt;
}
float Color::gray() const {
return (r+g+b)/3.0;
}
Color::operator String() const {
return rtos(r)+", "+rtos(g)+", "+rtos(b)+", "+rtos(a);
}

147
core/color.h Normal file
View File

@ -0,0 +1,147 @@
/*************************************************************************/
/* color.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef COLOR_H
#define COLOR_H
#include "ustring.h"
#include "math_funcs.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
struct Color {
union {
struct {
float r;
float g;
float b;
float a;
};
float components[4];
};
bool operator==(const Color &p_color) const { return (r==p_color.r && g==p_color.g && b==p_color.b && a==p_color.a ); }
bool operator!=(const Color &p_color) const { return (r!=p_color.r || g!=p_color.g || b!=p_color.b || a!=p_color.a ); }
uint32_t to_32() const;
uint32_t to_ARGB32() const;
float gray() const;
float get_h() const;
float get_s() const;
float get_v() const;
void set_hsv(float p_h, float p_s, float p_v, float p_alpha=1.0);
_FORCE_INLINE_ float& operator[](int idx) {
return components[idx];
}
_FORCE_INLINE_ const float& operator[](int idx) const {
return components[idx];
}
void invert();
void contrast();
Color inverted() const;
Color contrasted() const;
_FORCE_INLINE_ Color linear_interpolate(const Color& p_b, float p_t) const {
Color res=*this;
res.r+= (p_t * (p_b.r-r));
res.g+= (p_t * (p_b.g-g));
res.b+= (p_t * (p_b.b-b));
res.a+= (p_t * (p_b.a-a));
return res;
}
_FORCE_INLINE_ Color blend(const Color& p_over) const {
Color res;
float sa = 1.0 - p_over.a;
res.a = a*sa+p_over.a;
if (res.a==0) {
return Color(0,0,0,0);
} else {
res.r = (r*a*sa + p_over.r * p_over.a)/res.a;
res.g = (g*a*sa + p_over.g * p_over.a)/res.a;
res.b = (b*a*sa + p_over.b * p_over.a)/res.a;
}
return res;
}
_FORCE_INLINE_ Color to_linear() const {
return Color(
r<0.04045 ? r * (1.0 / 12.92) : Math::pow((r + 0.055) * (1.0 / (1 + 0.055)), 2.4),
g<0.04045 ? g * (1.0 / 12.92) : Math::pow((g + 0.055) * (1.0 / (1 + 0.055)), 2.4),
b<0.04045 ? b * (1.0 / 12.92) : Math::pow((b + 0.055) * (1.0 / (1 + 0.055)), 2.4),
a
);
}
static Color hex(uint32_t p_hex);
static Color html(const String& p_color);
static bool html_is_valid(const String& p_color);
String to_html(bool p_alpha=true) const;
_FORCE_INLINE_ bool operator<(const Color& p_color) const; //used in set keys
operator String() const;
/**
* No construct parameters, r=0, g=0, b=0. a=255
*/
_FORCE_INLINE_ Color() {
r=0; g=0; b=0; a=1.0;
}
/**
* RGB / RGBA construct parameters. Alpha is optional, but defaults to 1.0
*/
_FORCE_INLINE_ Color(float p_r,float p_g,float p_b,float p_a=1.0) { r=p_r; g=p_g; b=p_b; a=p_a; }
};
bool Color::operator<(const Color& p_color) const {
if (r==p_color.r) {
if (g==p_color.g) {
if(b==p_color.b) {
return (a<p_color.a);
} else
return (b<p_color.b);
} else
return g<p_color.g;
} else
return r<p_color.r;
}
#endif

107
core/command_queue_mt.cpp Normal file
View File

@ -0,0 +1,107 @@
/*************************************************************************/
/* command_queue_mt.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "command_queue_mt.h"
#include "os/os.h"
void CommandQueueMT::lock() {
if (mutex)
mutex->lock();
}
void CommandQueueMT::unlock() {
if (mutex)
mutex->unlock();
}
void CommandQueueMT::wait_for_flush() {
// wait one millisecond for a flush to happen
OS::get_singleton()->delay_usec(1000);
}
CommandQueueMT::SyncSemaphore* CommandQueueMT::_alloc_sync_sem() {
int idx=-1;
while(true) {
for(int i=0;i<SYNC_SEMAPHORES;i++) {
if (!sync_sems[i].in_use) {
sync_sems[i].in_use=true;
idx=i;
break;
}
}
if (idx==-1) {
wait_for_flush();
} else {
break;
}
}
return &sync_sems[idx];
}
CommandQueueMT::CommandQueueMT(bool p_sync){
read_ptr=0;
write_ptr=0;
mutex = Mutex::create();
for(int i=0;i<SYNC_SEMAPHORES;i++) {
sync_sems[i].sem=Semaphore::create();
sync_sems[i].in_use=false;
}
if (p_sync)
sync = Semaphore::create();
else
sync=NULL;
}
CommandQueueMT::~CommandQueueMT() {
if (sync)
memdelete(sync);
memdelete(mutex);
for(int i=0;i<SYNC_SEMAPHORES;i++) {
memdelete(sync_sems[i].sem);
}
}

999
core/command_queue_mt.h Normal file
View File

@ -0,0 +1,999 @@
/*************************************************************************/
/* command_queue_mt.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 COMMAND_QUEUE_MT_H
#define COMMAND_QUEUE_MT_H
#include "typedefs.h"
#include "os/semaphore.h"
#include "os/mutex.h"
#include "os/memory.h"
#include "simple_type.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class CommandQueueMT {
struct SyncSemaphore {
Semaphore *sem;
bool in_use;
};
struct CommandBase {
virtual void call()=0;
virtual ~CommandBase() {};
};
template<class T,class M>
struct Command0 : public CommandBase {
T*instance;
M method;
virtual void call() { (instance->*method)(); }
};
template<class T,class M,class P1>
struct Command1 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
virtual void call() { (instance->*method)(p1); }
};
template<class T,class M,class P1,class P2>
struct Command2 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
virtual void call() { (instance->*method)(p1,p2); }
};
template<class T,class M,class P1,class P2,class P3>
struct Command3 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
virtual void call() { (instance->*method)(p1,p2,p3); }
};
template<class T,class M,class P1,class P2,class P3,class P4>
struct Command4 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
virtual void call() { (instance->*method)(p1,p2,p3,p4); }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5>
struct Command5 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
typename GetSimpleTypeT<P5>::type_t p5;
virtual void call() { (instance->*method)(p1,p2,p3,p4,p5); }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6>
struct Command6 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
typename GetSimpleTypeT<P5>::type_t p5;
typename GetSimpleTypeT<P6>::type_t p6;
virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6); }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7>
struct Command7 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
typename GetSimpleTypeT<P5>::type_t p5;
typename GetSimpleTypeT<P6>::type_t p6;
typename GetSimpleTypeT<P7>::type_t p7;
virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); }
};
/* comands that return */
template<class T,class M,class R>
struct CommandRet0 : public CommandBase {
T*instance;
M method;
R* ret;
SyncSemaphore *sync;
virtual void call() { *ret = (instance->*method)(); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class R>
struct CommandRet1 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
R* ret;
SyncSemaphore *sync;
virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); sync->in_use=false; }
};
template<class T,class M,class P1,class P2,class R>
struct CommandRet2 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
R* ret;
SyncSemaphore *sync;
virtual void call() { *ret = (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3,class R>
struct CommandRet3 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
R* ret;
SyncSemaphore *sync;
virtual void call() { *ret = (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class R>
struct CommandRet4 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
R* ret;
SyncSemaphore *sync;
virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class R>
struct CommandRet5 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
typename GetSimpleTypeT<P5>::type_t p5;
R* ret;
SyncSemaphore *sync;
virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class R>
struct CommandRet6 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
typename GetSimpleTypeT<P5>::type_t p5;
typename GetSimpleTypeT<P6>::type_t p6;
R* ret;
SyncSemaphore *sync;
virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7,class R>
struct CommandRet7 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
typename GetSimpleTypeT<P5>::type_t p5;
typename GetSimpleTypeT<P6>::type_t p6;
typename GetSimpleTypeT<P7>::type_t p7;
R* ret;
SyncSemaphore *sync;
virtual void call() { *ret = (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; }
};
/** commands that don't return but sync */
/* comands that return */
template<class T,class M>
struct CommandSync0 : public CommandBase {
T*instance;
M method;
SyncSemaphore *sync;
virtual void call() { (instance->*method)(); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1>
struct CommandSync1 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
SyncSemaphore *sync;
virtual void call() { (instance->*method)(p1); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2>
struct CommandSync2 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
SyncSemaphore *sync;
virtual void call() { (instance->*method)(p1,p2); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3>
struct CommandSync3 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
SyncSemaphore *sync;
virtual void call() { (instance->*method)(p1,p2,p3); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3,class P4>
struct CommandSync4 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
SyncSemaphore *sync;
virtual void call() { (instance->*method)(p1,p2,p3,p4); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5>
struct CommandSync5 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
typename GetSimpleTypeT<P5>::type_t p5;
SyncSemaphore *sync;
virtual void call() { (instance->*method)(p1,p2,p3,p4,p5); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6>
struct CommandSync6 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
typename GetSimpleTypeT<P5>::type_t p5;
typename GetSimpleTypeT<P6>::type_t p6;
SyncSemaphore *sync;
virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6); sync->sem->post(); sync->in_use=false; ; }
};
template<class T,class M,class P1,class P2,class P3,class P4,class P5,class P6,class P7>
struct CommandSync7 : public CommandBase {
T*instance;
M method;
typename GetSimpleTypeT<P1>::type_t p1;
typename GetSimpleTypeT<P2>::type_t p2;
typename GetSimpleTypeT<P3>::type_t p3;
typename GetSimpleTypeT<P4>::type_t p4;
typename GetSimpleTypeT<P5>::type_t p5;
typename GetSimpleTypeT<P6>::type_t p6;
typename GetSimpleTypeT<P7>::type_t p7;
SyncSemaphore *sync;
virtual void call() { (instance->*method)(p1,p2,p3,p4,p5,p6,p7); sync->sem->post(); sync->in_use=false; ; }
};
/***** BASE *******/
enum {
COMMAND_MEM_SIZE_KB=256,
COMMAND_MEM_SIZE=COMMAND_MEM_SIZE_KB*1024,
SYNC_SEMAPHORES=8
};
uint8_t command_mem[COMMAND_MEM_SIZE];
uint32_t read_ptr;
uint32_t write_ptr;
SyncSemaphore sync_sems[SYNC_SEMAPHORES];
Mutex *mutex;
Semaphore *sync;
template<class T>
T* allocate() {
// alloc size is size+T+safeguard
uint32_t alloc_size=sizeof(T)+sizeof(uint32_t);
tryagain:
if (write_ptr < read_ptr) {
// behind read_ptr, check that there is room
if ( (read_ptr-write_ptr) <= alloc_size )
return NULL;
} else if (write_ptr >= read_ptr) {
// ahead of read_ptr, check that there is room
if ( (COMMAND_MEM_SIZE-write_ptr) < alloc_size+4 ) {
// no room at the end, wrap down;
if (read_ptr==0) // dont want write_ptr to become read_ptr
return NULL;
// if this happens, it's a bug
ERR_FAIL_COND_V( (COMMAND_MEM_SIZE-write_ptr) < sizeof(uint32_t), NULL );
// zero means, wrap to begining
uint32_t * p = (uint32_t*)&command_mem[write_ptr];
*p=0;
write_ptr=0;
goto tryagain;
}
}
// allocate the size
uint32_t * p = (uint32_t*)&command_mem[write_ptr];
*p=sizeof(T);
write_ptr+=sizeof(uint32_t);
// allocate the command
T* cmd = memnew_placement( &command_mem[write_ptr], T );
write_ptr+=sizeof(T);
return cmd;
}
template<class T>
T* allocate_and_lock() {
lock();
T* ret;
while ( (ret=allocate<T>())==NULL ) {
unlock();
// sleep a little until fetch happened and some room is made
wait_for_flush();
lock();
}
return ret;
}
bool flush_one() {
tryagain:
// tried to read an empty queue
if (read_ptr == write_ptr )
return false;
uint32_t size = *(uint32_t*)( &command_mem[read_ptr] );
if (size==0) {
//end of ringbuffer, wrap
read_ptr=0;
goto tryagain;
}
read_ptr+=sizeof(uint32_t);
CommandBase *cmd = reinterpret_cast<CommandBase*>( &command_mem[read_ptr] );
cmd->call();
cmd->~CommandBase();
read_ptr+=size;
return true;
}
void lock();
void unlock();
void wait_for_flush();
SyncSemaphore* _alloc_sync_sem();
public:
/* NORMAL PUSH COMMANDS */
template<class T, class M>
void push( T * p_instance, M p_method ) {
Command0<T,M> * cmd = allocate_and_lock< Command0<T,M> >();
cmd->instance=p_instance;
cmd->method=p_method;
unlock();
if (sync) sync->post();
}
template<class T, class M, class P1>
void push( T * p_instance, M p_method, P1 p1 ) {
Command1<T,M,P1> * cmd = allocate_and_lock< Command1<T,M,P1> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
unlock();
if (sync) sync->post();
}
template<class T, class M, class P1, class P2>
void push( T * p_instance, M p_method, P1 p1, P2 p2 ) {
Command2<T,M,P1,P2> * cmd = allocate_and_lock< Command2<T,M,P1,P2> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
unlock();
if (sync) sync->post();
}
template<class T, class M, class P1, class P2, class P3>
void push( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3 ) {
Command3<T,M,P1,P2,P3> * cmd = allocate_and_lock< Command3<T,M,P1,P2,P3> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
unlock();
if (sync) sync->post();
}
template<class T, class M, class P1, class P2, class P3, class P4>
void push( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4 ) {
Command4<T,M,P1,P2,P3,P4> * cmd = allocate_and_lock< Command4<T,M,P1,P2,P3,P4> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
unlock();
if (sync) sync->post();
}
template<class T, class M, class P1, class P2, class P3, class P4, class P5>
void push( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 ) {
Command5<T,M,P1,P2,P3,P4,P5> * cmd = allocate_and_lock< Command5<T,M,P1,P2,P3,P4,P5> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->p5=p5;
unlock();
if (sync) sync->post();
}
template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6>
void push( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6 ) {
Command6<T,M,P1,P2,P3,P4,P5,P6> * cmd = allocate_and_lock< Command6<T,M,P1,P2,P3,P4,P5,P6> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->p5=p5;
cmd->p6=p6;
unlock();
if (sync) sync->post();
}
template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
void push( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7 ) {
Command7<T,M,P1,P2,P3,P4,P5,P6,P7> * cmd = allocate_and_lock< Command7<T,M,P1,P2,P3,P4,P5,P6,P7> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->p5=p5;
cmd->p6=p6;
cmd->p7=p7;
unlock();
if (sync) sync->post();
}
/*** PUSH AND RET COMMANDS ***/
template<class T, class M,class R>
void push_and_ret( T * p_instance, M p_method, R* r_ret) {
CommandRet0<T,M,R> * cmd = allocate_and_lock< CommandRet0<T,M,R> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->ret=r_ret;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1,class R>
void push_and_ret( T * p_instance, M p_method, P1 p1, R* r_ret) {
CommandRet1<T,M,P1,R> * cmd = allocate_and_lock< CommandRet1<T,M,P1,R> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->ret=r_ret;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2,class R>
void push_and_ret( T * p_instance, M p_method, P1 p1, P2 p2, R* r_ret) {
CommandRet2<T,M,P1,P2,R> * cmd = allocate_and_lock< CommandRet2<T,M,P1,P2,R> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->ret=r_ret;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3,class R>
void push_and_ret( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, R* r_ret ) {
CommandRet3<T,M,P1,P2,P3,R> * cmd = allocate_and_lock< CommandRet3<T,M,P1,P2,P3,R> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->ret=r_ret;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3, class P4,class R>
void push_and_ret( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, R* r_ret ) {
CommandRet4<T,M,P1,P2,P3,P4,R> * cmd = allocate_and_lock< CommandRet4<T,M,P1,P2,P3,P4,R> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->ret=r_ret;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3, class P4, class P5,class R>
void push_and_ret( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, R* r_ret ) {
CommandRet5<T,M,P1,P2,P3,P4,P5,R> * cmd = allocate_and_lock< CommandRet5<T,M,P1,P2,P3,P4,P5,R> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->p5=p5;
cmd->ret=r_ret;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6,class R>
void push_and_ret( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, R* r_ret ) {
CommandRet6<T,M,P1,P2,P3,P4,P5,P6,R> * cmd = allocate_and_lock< CommandRet6<T,M,P1,P2,P3,P4,P5,P6,R> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->p5=p5;
cmd->p6=p6;
cmd->ret=r_ret;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6,class P7,class R>
void push_and_ret( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,P7 p7, R* r_ret ) {
CommandRet7<T,M,P1,P2,P3,P4,P5,P6,P7,R> * cmd = allocate_and_lock< CommandRet7<T,M,P1,P2,P3,P4,P5,P6,P7,R> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->p5=p5;
cmd->p6=p6;
cmd->p7=p7;
cmd->ret=r_ret;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M>
void push_and_sync( T * p_instance, M p_method) {
CommandSync0<T,M> * cmd = allocate_and_lock< CommandSync0<T,M> >();
cmd->instance=p_instance;
cmd->method=p_method;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1>
void push_and_sync( T * p_instance, M p_method, P1 p1) {
CommandSync1<T,M,P1> * cmd = allocate_and_lock< CommandSync1<T,M,P1> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2>
void push_and_sync( T * p_instance, M p_method, P1 p1, P2 p2) {
CommandSync2<T,M,P1,P2> * cmd = allocate_and_lock< CommandSync2<T,M,P1,P2> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3>
void push_and_sync( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3 ) {
CommandSync3<T,M,P1,P2,P3> * cmd = allocate_and_lock< CommandSync3<T,M,P1,P2,P3> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3, class P4>
void push_and_sync( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4 ) {
CommandSync4<T,M,P1,P2,P3,P4> * cmd = allocate_and_lock< CommandSync4<T,M,P1,P2,P3,P4> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3, class P4, class P5>
void push_and_sync( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 ) {
CommandSync5<T,M,P1,P2,P3,P4,P5> * cmd = allocate_and_lock< CommandSync5<T,M,P1,P2,P3,P4,P5> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->p5=p5;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6>
void push_and_sync( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6 ) {
CommandSync6<T,M,P1,P2,P3,P4,P5,P6> * cmd = allocate_and_lock< CommandSync6<T,M,P1,P2,P3,P4,P5,P6> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->p5=p5;
cmd->p6=p6;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
template<class T, class M, class P1, class P2, class P3, class P4, class P5, class P6,class P7>
void push_and_sync( T * p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6,P7 p7 ) {
CommandSync7<T,M,P1,P2,P3,P4,P5,P6,P7> * cmd = allocate_and_lock< CommandSync7<T,M,P1,P2,P3,P4,P5,P6,P7> >();
cmd->instance=p_instance;
cmd->method=p_method;
cmd->p1=p1;
cmd->p2=p2;
cmd->p3=p3;
cmd->p4=p4;
cmd->p5=p5;
cmd->p6=p6;
cmd->p7=p7;
SyncSemaphore *ss=_alloc_sync_sem();
cmd->sync=ss;
unlock();
if (sync) sync->post();
ss->sem->wait();
}
void wait_and_flush_one() {
ERR_FAIL_COND(!sync);
sync->wait();
lock();
flush_one();
unlock();
}
void flush_all() {
//ERR_FAIL_COND(sync);
lock();
while (true) {
bool exit = !flush_one();
if (exit)
break;
}
unlock();
}
CommandQueueMT(bool p_sync);
~CommandQueueMT();
};
#endif

View File

@ -0,0 +1,534 @@
/*************************************************************************/
/* compressed_translation.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "compressed_translation.h"
#include "pair.h"
#include <string.h>
/////////// SMAZ /////////////
/*
Copyright (c) 2006-2009, Salvatore Sanfilippo
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Smaz nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Our compression codebook, used for compression */
static const char *Smaz_cb[241] = {
"\002s,\266", "\003had\232\002leW", "\003on \216", "", "\001yS",
"\002ma\255\002li\227", "\003or \260", "", "\002ll\230\003s t\277",
"\004fromg\002mel", "", "\003its\332", "\001z\333", "\003ingF", "\001>\336",
"\001 \000\003 (\002nc\344", "\002nd=\003 on\312",
"\002ne\213\003hat\276\003re q", "", "\002ngT\003herz\004have\306\003s o\225",
"", "\003ionk\003s a\254\002ly\352", "\003hisL\003 inN\003 be\252", "",
"\003 fo\325\003 of \003 ha\311", "", "\002of\005",
"\003 co\241\002no\267\003 ma\370", "", "", "\003 cl\356\003enta\003 an7",
"\002ns\300\001\"e", "\003n t\217\002ntP\003s, \205",
"\002pe\320\003 we\351\002om\223", "\002on\037", "", "\002y G", "\003 wa\271",
"\003 re\321\002or*", "", "\002=\"\251\002ot\337", "\003forD\002ou[",
"\003 toR", "\003 th\r", "\003 it\366",
"\003but\261\002ra\202\003 wi\363\002</\361", "\003 wh\237", "\002 4",
"\003nd ?", "\002re!", "", "\003ng c", "",
"\003ly \307\003ass\323\001a\004\002rir", "", "", "", "\002se_", "\003of \"",
"\003div\364\002ros\003ere\240", "", "\002ta\310\001bZ\002si\324", "",
"\003and\a\002rs\335", "\002rt\362", "\002teE", "\003ati\316", "\002so\263",
"\002th\021", "\002tiJ\001c\034\003allp", "\003ate\345", "\002ss\246",
"\002stM", "", "\002><\346", "\002to\024", "\003arew", "\001d\030",
"\002tr\303", "", "\001\n1\003 a \222", "\003f tv\002veo", "\002un\340", "",
"\003e o\242", "\002a \243\002wa\326\001e\002", "\002ur\226\003e a\274",
"\002us\244\003\n\r\n\247", "\002ut\304\003e c\373", "\002we\221", "", "",
"\002wh\302", "\001f,", "", "", "", "\003d t\206", "", "", "\003th \343",
"\001g;", "", "", "\001\r9\003e s\265", "\003e t\234", "", "\003to Y",
"\003e\r\n\236", "\002d \036\001h\022", "", "\001,Q", "\002 a\031", "\002 b^",
"\002\r\n\025\002 cI", "\002 d\245", "\002 e\253", "\002 fh\001i\b\002e \v",
"", "\002 hU\001-\314", "\002 i8", "", "", "\002 l\315", "\002 m{",
"\002f :\002 n\354", "\002 o\035", "\002 p}\001.n\003\r\n\r\250", "",
"\002 r\275", "\002 s>", "\002 t\016", "", "\002g \235\005which+\003whi\367",
"\002 w5", "\001/\305", "\003as \214", "\003at \207", "", "\003who\331", "",
"\001l\026\002h \212", "", "\002, $", "", "\004withV", "", "", "", "\001m-", "",
"", "\002ac\357", "\002ad\350", "\003TheH", "", "", "\004this\233\001n\t",
"", "\002. y", "", "\002alX\003e, \365", "\003tio\215\002be\\",
"\002an\032\003ver\347", "", "\004that0\003tha\313\001o\006", "\003was2",
"\002arO", "\002as.", "\002at'\003the\001\004they\200\005there\322\005theird",
"\002ce\210", "\004were]", "", "\002ch\231\002l \264\001p<", "", "",
"\003one\256", "", "\003he \023\002dej", "\003ter\270", "\002cou", "",
"\002by\177\002di\201\002eax", "", "\002ec\327", "\002edB", "\002ee\353", "",
"", "\001r\f\002n )", "", "", "", "\002el\262", "", "\003in i\002en3", "",
"\002o `\001s\n", "", "\002er\033", "\003is t\002es6", "", "\002ge\371",
"\004.com\375", "\002fo\334\003our\330", "\003ch \301\001t\003", "\002hab", "",
"\003men\374", "", "\002he\020", "", "", "\001u&", "\002hif", "",
"\003not\204\002ic\203", "\003ed @\002id\355", "", "", "\002ho\273",
"\002r K\001vm", "", "", "", "\003t t\257\002il\360", "\002im\342",
"\003en \317\002in\017", "\002io\220", "\002s \027\001wA", "", "\003er |",
"\003es ~\002is%", "\002it/", "", "\002iv\272", "",
"\002t #\ahttp://C\001x\372", "\002la\211", "\001<\341", "\003, a\224"
};
/* Reverse compression codebook, used for decompression */
static const char *Smaz_rcb[254] = {
" ", "the", "e", "t", "a", "of", "o", "and", "i", "n", "s", "e ", "r", " th",
" t", "in", "he", "th", "h", "he ", "to", "\r\n", "l", "s ", "d", " a", "an",
"er", "c", " o", "d ", "on", " of", "re", "of ", "t ", ", ", "is", "u", "at",
" ", "n ", "or", "which", "f", "m", "as", "it", "that", "\n", "was", "en",
" ", " w", "es", " an", " i", "\r", "f ", "g", "p", "nd", " s", "nd ", "ed ",
"w", "ed", "http://", "for", "te", "ing", "y ", "The", " c", "ti", "r ", "his",
"st", " in", "ar", "nt", ",", " to", "y", "ng", " h", "with", "le", "al", "to ",
"b", "ou", "be", "were", " b", "se", "o ", "ent", "ha", "ng ", "their", "\"",
"hi", "from", " f", "in ", "de", "ion", "me", "v", ".", "ve", "all", "re ",
"ri", "ro", "is ", "co", "f t", "are", "ea", ". ", "her", " m", "er ", " p",
"es ", "by", "they", "di", "ra", "ic", "not", "s, ", "d t", "at ", "ce", "la",
"h ", "ne", "as ", "tio", "on ", "n t", "io", "we", " a ", "om", ", a", "s o",
"ur", "li", "ll", "ch", "had", "this", "e t", "g ", "e\r\n", " wh", "ere",
" co", "e o", "a ", "us", " d", "ss", "\n\r\n", "\r\n\r", "=\"", " be", " e",
"s a", "ma", "one", "t t", "or ", "but", "el", "so", "l ", "e s", "s,", "no",
"ter", " wa", "iv", "ho", "e a", " r", "hat", "s t", "ns", "ch ", "wh", "tr",
"ut", "/", "have", "ly ", "ta", " ha", " on", "tha", "-", " l", "ati", "en ",
"pe", " re", "there", "ass", "si", " fo", "wa", "ec", "our", "who", "its", "z",
"fo", "rs", ">", "ot", "un", "<", "im", "th ", "nc", "ate", "><", "ver", "ad",
" we", "ly", "ee", " n", "id", " cl", "ac", "il", "</", "rt", " wi", "div",
"e, ", " it", "whi", " ma", "ge", "x", "e c", "men", ".com"
};
static int smaz_compress(const char *in, int inlen, char *out, int outlen) {
unsigned int h1,h2,h3=0;
int verblen = 0, _outlen = outlen;
char verb[256], *_out = out;
while(inlen) {
int j = 7, needed;
char *flush = NULL;
const char *slot;
h1 = h2 = in[0]<<3;
if (inlen > 1) h2 += in[1];
if (inlen > 2) h3 = h2^in[2];
if (j > inlen) j = inlen;
/* Try to lookup substrings into the hash table, starting from the
* longer to the shorter substrings */
for (; j > 0; j--) {
switch(j) {
case 1: slot = Smaz_cb[h1%241]; break;
case 2: slot = Smaz_cb[h2%241]; break;
default: slot = Smaz_cb[h3%241]; break;
}
while(slot[0]) {
if (slot[0] == j && memcmp(slot+1,in,j) == 0) {
/* Match found in the hash table,
* prepare a verbatim bytes flush if needed */
if (verblen) {
needed = (verblen == 1) ? 2 : 2+verblen;
flush = out;
out += needed;
outlen -= needed;
}
/* Emit the byte */
if (outlen <= 0) return _outlen+1;
out[0] = slot[slot[0]+1];
out++;
outlen--;
inlen -= j;
in += j;
goto out;
} else {
slot += slot[0]+2;
}
}
}
/* Match not found - add the byte to the verbatim buffer */
verb[verblen] = in[0];
verblen++;
inlen--;
in++;
out:
/* Prepare a flush if we reached the flush length limit, and there
* is not already a pending flush operation. */
if (!flush && (verblen == 256 || (verblen > 0 && inlen == 0))) {
needed = (verblen == 1) ? 2 : 2+verblen;
flush = out;
out += needed;
outlen -= needed;
if (outlen < 0) return _outlen+1;
}
/* Perform a verbatim flush if needed */
if (flush) {
if (verblen == 1) {
flush[0] = (signed char)254;
flush[1] = verb[0];
} else {
flush[0] = (signed char)255;
flush[1] = (signed char)(verblen-1);
memcpy(flush+2,verb,verblen);
}
flush = NULL;
verblen = 0;
}
}
return out-_out;
}
static int smaz_decompress(const char *in, int inlen, char *out, int outlen) {
unsigned char *c = (unsigned char*) in;
char *_out = out;
int _outlen = outlen;
while(inlen) {
if (*c == 254) {
/* Verbatim byte */
if (outlen < 1) return _outlen+1;
*out = *(c+1);
out++;
outlen--;
c += 2;
inlen -= 2;
} else if (*c == 255) {
/* Verbatim string */
int len = (*(c+1))+1;
if (outlen < len) return _outlen+1;
memcpy(out,c+2,len);
out += len;
outlen -= len;
c += 2+len;
inlen -= 2+len;
} else {
/* Codebook entry */
const char *s = Smaz_rcb[*c];
int len = strlen(s);
if (outlen < len) return _outlen+1;
memcpy(out,s,len);
out += len;
outlen -= len;
c++;
inlen--;
}
}
return out-_out;
}
/////////// END OF SMAZ /////////////
struct _PHashTranslationCmp {
int orig_len;
CharString compressed;
int offset;
};
void PHashTranslation::generate(const Ref<Translation> &p_from) {
#ifdef TOOLS_ENABLED
List<StringName> keys;
p_from->get_message_list(&keys);
int size=Math::larger_prime(keys.size());
print_line("compressing keys: "+itos(keys.size()));
Vector< Vector< Pair<int,CharString> > > buckets;
Vector< Map< uint32_t, int > > table;
Vector< uint32_t > hfunc_table;
Vector< _PHashTranslationCmp > compressed;
table.resize(size);
hfunc_table.resize(size);
buckets.resize(size);
compressed.resize(keys.size());
int idx=0;
int total_compression_size=0;
int total_string_size=0;
for(List<StringName>::Element *E=keys.front();E;E=E->next()) {
//hash string
CharString cs = E->get().operator String().utf8();
uint32_t h = hash(0,cs.get_data());
Pair<int,CharString> p;
p.first=idx;
p.second=cs;
buckets[h % size].push_back(p);
//compress string
CharString src_s = p_from->get_message(E->get()).operator String().utf8();
_PHashTranslationCmp ps;
ps.orig_len=src_s.size();
ps.offset=total_compression_size;
if (ps.orig_len!=0) {
CharString dst_s;
dst_s.resize(src_s.size());
int ret = smaz_compress(src_s.get_data(),src_s.size(),&dst_s[0],src_s.size());
if (ret>=src_s.size()) {
//if compressed is larger than original, just use original
ps.orig_len=src_s.size();
ps.compressed=src_s;
} else {
dst_s.resize(ret);
//ps.orig_len=;
ps.compressed=dst_s;
}
} else {
ps.orig_len=1;
ps.compressed.resize(1);
ps.compressed[0]=0;
}
compressed[idx]=ps;
total_compression_size+=ps.compressed.size();
total_string_size+=src_s.size();
idx++;
}
int bucket_table_size=0;
print_line("total compressed string size: "+itos(total_compression_size)+" ("+itos(total_string_size)+" uncompressed).");
for(int i=0;i<size;i++) {
Vector< Pair<int,CharString> > &b = buckets[i];
Map< uint32_t, int > &t=table[i];
if (b.size()==0)
continue;
//print_line("bucket: "+itos(i)+" - elements: "+itos(b.size()));
int d = 1;
int item =0;
while(item < b.size()) {
uint32_t slot = hash(d,b[item].second.get_data());
if (t.has(slot)) {
item=0;
d++;
t.clear();
} else {
t[slot]=b[item].first;
item++;
}
}
hfunc_table[i]=d;
bucket_table_size+=2+b.size()*4;
}
print_line("bucket table size: "+itos(bucket_table_size*4));
print_line("hash table size: "+itos(size*4));
hash_table.resize(size);
bucket_table.resize(bucket_table_size);
DVector<int>::Write htwb = hash_table.write();
DVector<int>::Write btwb = bucket_table.write();
uint32_t *htw = (uint32_t*)&htwb[0];
uint32_t *btw = (uint32_t*)&btwb[0];
int btindex=0;
int collisions=0;
for(int i=0;i<size;i++) {
Map< uint32_t, int > &t=table[i];
if (t.size()==0) {
htw[i]=0xFFFFFFFF; //nothing
continue;
} else if (t.size()>1) {
collisions+=t.size()-1;
}
htw[i]=btindex;
btw[btindex++]=t.size();
btw[btindex++]=hfunc_table[i];
for( Map< uint32_t, int >::Element *E=t.front();E;E=E->next()) {
btw[btindex++]=E->key();
btw[btindex++]=compressed[E->get()].offset;
btw[btindex++]=compressed[E->get()].compressed.size();
btw[btindex++]=compressed[E->get()].orig_len;
}
}
print_line("total collisions: "+itos(collisions));
strings.resize(total_compression_size);
DVector<uint8_t>::Write cw = strings.write();
for(int i=0;i<compressed.size();i++) {
memcpy(&cw[compressed[i].offset],compressed[i].compressed.get_data(),compressed[i].compressed.size());
}
ERR_FAIL_COND(btindex!=bucket_table_size);
set_locale(p_from->get_locale());
#endif
}
bool PHashTranslation::_set(const StringName& p_name, const Variant& p_value) {
String name = p_name.operator String();
if (name=="hash_table") {
hash_table=p_value;
//print_line("translation: loaded hash table of size: "+itos(hash_table.size()));
} else if (name=="bucket_table") {
bucket_table=p_value;
//print_line("translation: loaded bucket table of size: "+itos(bucket_table.size()));
} else if (name=="strings") {
strings=p_value;
//print_line("translation: loaded string table of size: "+itos(strings.size()));
} else if (name=="load_from") {
//print_line("generating");
generate(p_value);
} else
return false;
return true;
}
bool PHashTranslation::_get(const StringName& p_name,Variant &r_ret) const{
String name = p_name.operator String();
if (name=="hash_table")
r_ret=hash_table;
else if (name=="bucket_table")
r_ret=bucket_table;
else if (name=="strings")
r_ret=strings;
else
return false;
return true;
}
StringName PHashTranslation::get_message(const StringName& p_src_text) const {
int htsize = hash_table.size();
if (htsize==0)
return StringName();
CharString str = p_src_text.operator String().utf8();
uint32_t h = hash(0,str.get_data());
DVector<int>::Read htr = hash_table.read();
const uint32_t *htptr = (const uint32_t*)&htr[0];
DVector<int>::Read btr = bucket_table.read();
const uint32_t *btptr = (const uint32_t*)&btr[0];
DVector<uint8_t>::Read sr = strings.read();
const char *sptr= (const char*)&sr[0];
uint32_t p = htptr[ h % htsize];
//print_line("String: "+p_src_text.operator String());
//print_line("Hash: "+itos(p));
if (p==0xFFFFFFFF) {
// print_line("GETMSG: Nothing!");
return StringName(); //nothing
}
const Bucket &bucket = *(const Bucket*)&btptr[p];
h = hash(bucket.func,str.get_data());
int idx=-1;
for(int i=0;i<bucket.size;i++) {
if (bucket.elem[i].key==h) {
idx=i;
break;
}
}
//print_line("bucket pos: "+itos(idx));
if (idx==-1) {
// print_line("GETMSG: Not in Bucket!");
return StringName();
}
if (bucket.elem[idx].comp_size == bucket.elem[idx].uncomp_size) {
String rstr;
rstr.parse_utf8(&sptr[ bucket.elem[idx].str_offset ], bucket.elem[idx].uncomp_size );
// print_line("Uncompressed, size: "+itos(bucket.elem[idx].comp_size));
// print_line("Return: "+rstr);
return rstr;
} else {
CharString uncomp;
uncomp.resize( bucket.elem[idx].uncomp_size+1 );
smaz_decompress(&sptr[ bucket.elem[idx].str_offset ], bucket.elem[idx].comp_size,uncomp.ptr(),bucket.elem[idx].uncomp_size );
String rstr;
rstr.parse_utf8(uncomp.get_data());
// print_line("Compressed, size: "+itos(bucket.elem[idx].comp_size));
// print_line("Return: "+rstr);
return rstr;
}
}
void PHashTranslation::_get_property_list( List<PropertyInfo> *p_list) const{
p_list->push_back( PropertyInfo(Variant::INT_ARRAY, "hash_table"));
p_list->push_back( PropertyInfo(Variant::INT_ARRAY, "bucket_table"));
p_list->push_back( PropertyInfo(Variant::RAW_ARRAY, "strings"));
p_list->push_back( PropertyInfo(Variant::OBJECT, "load_from",PROPERTY_HINT_RESOURCE_TYPE,"Translation",PROPERTY_USAGE_EDITOR));
}
void PHashTranslation::_bind_methods() {
ObjectTypeDB::bind_method(_MD("generate","from:Translation"),&PHashTranslation::generate);
}
PHashTranslation::PHashTranslation()
{
}

View File

@ -0,0 +1,93 @@
/*************************************************************************/
/* compressed_translation.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 COMPRESSED_TRANSLATION_H
#define COMPRESSED_TRANSLATION_H
#include "translation.h"
class PHashTranslation : public Translation {
OBJ_TYPE(PHashTranslation,Translation);
//this translation uses a sort of modified perfect hash algorithm
//it requieres hashing strings twice and then does a binary search,
//so it's slower, but at the same time it has an extreemly high chance
//of catching untranslated strings
//load/store friendly types
DVector<int> hash_table;
DVector<int> bucket_table;
DVector<uint8_t> strings;
struct Bucket {
int size;
uint32_t func;
struct Elem {
uint32_t key;
uint32_t str_offset;
uint32_t comp_size;
uint32_t uncomp_size;
};
Elem elem[1];
};
_FORCE_INLINE_ uint32_t hash( uint32_t d, const char *p_str ) const {
if (d==0)
d=0x1000193;
while(*p_str) {
d = (d * 0x1000193) ^ uint32_t(*p_str);
p_str++;
}
return d;
}
protected:
bool _set(const StringName& p_name, const Variant& p_value);
bool _get(const StringName& p_name,Variant &r_ret) const;
void _get_property_list( List<PropertyInfo> *p_list) const;
static void _bind_methods();
public:
virtual StringName get_message(const StringName& p_src_text) const; //overridable for other implementations
void generate(const Ref<Translation> &p_from);
PHashTranslation();
};
#endif // COMPRESSED_TRANSLATION_H

View File

@ -1,7 +0,0 @@
#!/usr/bin/env python
Import("env")
env_config = env.Clone()
env_config.add_source_files(env.core_sources, "*.cpp")

View File

@ -1,403 +0,0 @@
/**************************************************************************/
/* engine.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "engine.h"
#include "core/authors.gen.h"
#include "core/config/project_settings.h"
#include "core/donors.gen.h"
#include "core/license.gen.h"
#include "core/variant/typed_array.h"
#include "core/version.h"
void Engine::set_physics_ticks_per_second(int p_ips) {
ERR_FAIL_COND_MSG(p_ips <= 0, "Engine iterations per second must be greater than 0.");
ips = p_ips;
}
int Engine::get_physics_ticks_per_second() const {
return ips;
}
void Engine::set_max_physics_steps_per_frame(int p_max_physics_steps) {
ERR_FAIL_COND_MSG(p_max_physics_steps <= 0, "Maximum number of physics steps per frame must be greater than 0.");
max_physics_steps_per_frame = p_max_physics_steps;
}
int Engine::get_max_physics_steps_per_frame() const {
return max_physics_steps_per_frame;
}
void Engine::set_physics_jitter_fix(double p_threshold) {
if (p_threshold < 0) {
p_threshold = 0;
}
physics_jitter_fix = p_threshold;
}
double Engine::get_physics_jitter_fix() const {
return physics_jitter_fix;
}
void Engine::set_max_fps(int p_fps) {
_max_fps = p_fps > 0 ? p_fps : 0;
}
int Engine::get_max_fps() const {
return _max_fps;
}
void Engine::set_audio_output_latency(int p_msec) {
_audio_output_latency = p_msec > 1 ? p_msec : 1;
}
int Engine::get_audio_output_latency() const {
return _audio_output_latency;
}
void Engine::increment_frames_drawn() {
if (frame_server_synced) {
server_syncs++;
} else {
server_syncs = 0;
}
frame_server_synced = false;
frames_drawn++;
}
uint64_t Engine::get_frames_drawn() {
return frames_drawn;
}
void Engine::set_frame_delay(uint32_t p_msec) {
_frame_delay = p_msec;
}
uint32_t Engine::get_frame_delay() const {
return _frame_delay;
}
void Engine::set_time_scale(double p_scale) {
_time_scale = p_scale;
}
double Engine::get_time_scale() const {
return _time_scale;
}
Dictionary Engine::get_version_info() const {
Dictionary dict;
dict["major"] = VERSION_MAJOR;
dict["minor"] = VERSION_MINOR;
dict["patch"] = VERSION_PATCH;
dict["hex"] = VERSION_HEX;
dict["status"] = VERSION_STATUS;
dict["build"] = VERSION_BUILD;
String hash = String(VERSION_HASH);
dict["hash"] = hash.is_empty() ? String("unknown") : hash;
dict["timestamp"] = VERSION_TIMESTAMP;
String stringver = String(dict["major"]) + "." + String(dict["minor"]);
if ((int)dict["patch"] != 0) {
stringver += "." + String(dict["patch"]);
}
stringver += "-" + String(dict["status"]) + " (" + String(dict["build"]) + ")";
dict["string"] = stringver;
return dict;
}
static Array array_from_info(const char *const *info_list) {
Array arr;
for (int i = 0; info_list[i] != nullptr; i++) {
arr.push_back(String::utf8(info_list[i]));
}
return arr;
}
static Array array_from_info_count(const char *const *info_list, int info_count) {
Array arr;
for (int i = 0; i < info_count; i++) {
arr.push_back(String::utf8(info_list[i]));
}
return arr;
}
Dictionary Engine::get_author_info() const {
Dictionary dict;
dict["lead_developers"] = array_from_info(AUTHORS_LEAD_DEVELOPERS);
dict["project_managers"] = array_from_info(AUTHORS_PROJECT_MANAGERS);
dict["founders"] = array_from_info(AUTHORS_FOUNDERS);
dict["developers"] = array_from_info(AUTHORS_DEVELOPERS);
return dict;
}
TypedArray<Dictionary> Engine::get_copyright_info() const {
TypedArray<Dictionary> components;
for (int component_index = 0; component_index < COPYRIGHT_INFO_COUNT; component_index++) {
const ComponentCopyright &cp_info = COPYRIGHT_INFO[component_index];
Dictionary component_dict;
component_dict["name"] = String::utf8(cp_info.name);
Array parts;
for (int i = 0; i < cp_info.part_count; i++) {
const ComponentCopyrightPart &cp_part = cp_info.parts[i];
Dictionary part_dict;
part_dict["files"] = array_from_info_count(cp_part.files, cp_part.file_count);
part_dict["copyright"] = array_from_info_count(cp_part.copyright_statements, cp_part.copyright_count);
part_dict["license"] = String::utf8(cp_part.license);
parts.push_back(part_dict);
}
component_dict["parts"] = parts;
components.push_back(component_dict);
}
return components;
}
Dictionary Engine::get_donor_info() const {
Dictionary donors;
donors["patrons"] = array_from_info(DONORS_PATRONS);
donors["platinum_sponsors"] = array_from_info(DONORS_SPONSORS_PLATINUM);
donors["gold_sponsors"] = array_from_info(DONORS_SPONSORS_GOLD);
donors["silver_sponsors"] = array_from_info(DONORS_SPONSORS_SILVER);
donors["diamond_members"] = array_from_info(DONORS_MEMBERS_DIAMOND);
donors["titanium_members"] = array_from_info(DONORS_MEMBERS_TITANIUM);
donors["platinum_members"] = array_from_info(DONORS_MEMBERS_PLATINUM);
donors["gold_members"] = array_from_info(DONORS_MEMBERS_GOLD);
return donors;
}
Dictionary Engine::get_license_info() const {
Dictionary licenses;
for (int i = 0; i < LICENSE_COUNT; i++) {
licenses[LICENSE_NAMES[i]] = LICENSE_BODIES[i];
}
return licenses;
}
String Engine::get_license_text() const {
return String(GODOT_LICENSE_TEXT);
}
String Engine::get_architecture_name() const {
#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(_M_X64)
return "x86_64";
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
return "x86_32";
#elif defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
return "arm64";
#elif defined(__arm__) || defined(_M_ARM)
return "arm32";
#elif defined(__riscv)
#if __riscv_xlen == 8
return "rv64";
#else
return "riscv";
#endif
#elif defined(__powerpc__)
#if defined(__powerpc64__)
return "ppc64";
#else
return "ppc";
#endif
#elif defined(__wasm__)
#if defined(__wasm64__)
return "wasm64";
#elif defined(__wasm32__)
return "wasm32";
#endif
#endif
}
bool Engine::is_abort_on_gpu_errors_enabled() const {
return abort_on_gpu_errors;
}
int32_t Engine::get_gpu_index() const {
return gpu_idx;
}
bool Engine::is_validation_layers_enabled() const {
return use_validation_layers;
}
bool Engine::is_generate_spirv_debug_info_enabled() const {
return generate_spirv_debug_info;
}
void Engine::set_print_error_messages(bool p_enabled) {
CoreGlobals::print_error_enabled = p_enabled;
}
bool Engine::is_printing_error_messages() const {
return CoreGlobals::print_error_enabled;
}
void Engine::print_header(const String &p_string) const {
if (_print_header) {
print_line(p_string);
}
}
void Engine::print_header_rich(const String &p_string) const {
if (_print_header) {
print_line_rich(p_string);
}
}
void Engine::add_singleton(const Singleton &p_singleton) {
ERR_FAIL_COND_MSG(singleton_ptrs.has(p_singleton.name), vformat("Can't register singleton '%s' because it already exists.", p_singleton.name));
singletons.push_back(p_singleton);
singleton_ptrs[p_singleton.name] = p_singleton.ptr;
}
Object *Engine::get_singleton_object(const StringName &p_name) const {
HashMap<StringName, Object *>::ConstIterator E = singleton_ptrs.find(p_name);
ERR_FAIL_COND_V_MSG(!E, nullptr, vformat("Failed to retrieve non-existent singleton '%s'.", p_name));
#ifdef TOOLS_ENABLED
if (!is_editor_hint() && is_singleton_editor_only(p_name)) {
ERR_FAIL_V_MSG(nullptr, vformat("Can't retrieve singleton '%s' outside of editor.", p_name));
}
#endif
return E->value;
}
bool Engine::is_singleton_user_created(const StringName &p_name) const {
ERR_FAIL_COND_V(!singleton_ptrs.has(p_name), false);
for (const Singleton &E : singletons) {
if (E.name == p_name && E.user_created) {
return true;
}
}
return false;
}
bool Engine::is_singleton_editor_only(const StringName &p_name) const {
ERR_FAIL_COND_V(!singleton_ptrs.has(p_name), false);
for (const Singleton &E : singletons) {
if (E.name == p_name && E.editor_only) {
return true;
}
}
return false;
}
void Engine::remove_singleton(const StringName &p_name) {
ERR_FAIL_COND(!singleton_ptrs.has(p_name));
for (List<Singleton>::Element *E = singletons.front(); E; E = E->next()) {
if (E->get().name == p_name) {
singletons.erase(E);
singleton_ptrs.erase(p_name);
return;
}
}
}
bool Engine::has_singleton(const StringName &p_name) const {
return singleton_ptrs.has(p_name);
}
void Engine::get_singletons(List<Singleton> *p_singletons) {
for (const Singleton &E : singletons) {
#ifdef TOOLS_ENABLED
if (!is_editor_hint() && E.editor_only) {
continue;
}
#endif
p_singletons->push_back(E);
}
}
String Engine::get_write_movie_path() const {
return write_movie_path;
}
void Engine::set_write_movie_path(const String &p_path) {
write_movie_path = p_path;
}
void Engine::set_shader_cache_path(const String &p_path) {
shader_cache_path = p_path;
}
String Engine::get_shader_cache_path() const {
return shader_cache_path;
}
Engine *Engine::singleton = nullptr;
Engine *Engine::get_singleton() {
return singleton;
}
bool Engine::notify_frame_server_synced() {
frame_server_synced = true;
return server_syncs > SERVER_SYNC_FRAME_COUNT_WARNING;
}
Engine::Engine() {
singleton = this;
}
Engine::~Engine() {
if (singleton == this) {
singleton = nullptr;
}
}
Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr, const StringName &p_class_name) :
name(p_name),
ptr(p_ptr),
class_name(p_class_name) {
#ifdef DEBUG_ENABLED
RefCounted *rc = Object::cast_to<RefCounted>(p_ptr);
if (rc && !rc->is_referenced()) {
WARN_PRINT("You must use Ref<> to ensure the lifetime of a RefCounted object intended to be used as a singleton.");
}
#endif
}

View File

@ -1,193 +0,0 @@
/**************************************************************************/
/* engine.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 ENGINE_H
#define ENGINE_H
#include "core/os/main_loop.h"
#include "core/string/ustring.h"
#include "core/templates/list.h"
#include "core/templates/vector.h"
template <typename T>
class TypedArray;
class Engine {
public:
struct Singleton {
StringName name;
Object *ptr = nullptr;
StringName class_name; // Used for binding generation hinting.
// Singleton scope flags.
bool user_created = false;
bool editor_only = false;
Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr, const StringName &p_class_name = StringName());
};
private:
friend class Main;
uint64_t frames_drawn = 0;
uint32_t _frame_delay = 0;
uint64_t _frame_ticks = 0;
double _process_step = 0;
int ips = 60;
double physics_jitter_fix = 0.5;
double _fps = 1;
int _max_fps = 0;
int _audio_output_latency = 0;
double _time_scale = 1.0;
uint64_t _physics_frames = 0;
int max_physics_steps_per_frame = 8;
double _physics_interpolation_fraction = 0.0f;
bool abort_on_gpu_errors = false;
bool use_validation_layers = false;
bool generate_spirv_debug_info = false;
int32_t gpu_idx = -1;
uint64_t _process_frames = 0;
bool _in_physics = false;
List<Singleton> singletons;
HashMap<StringName, Object *> singleton_ptrs;
bool editor_hint = false;
bool project_manager_hint = false;
bool extension_reloading = false;
bool _print_header = true;
static Engine *singleton;
String write_movie_path;
String shader_cache_path;
static constexpr int SERVER_SYNC_FRAME_COUNT_WARNING = 5;
int server_syncs = 0;
bool frame_server_synced = false;
public:
static Engine *get_singleton();
virtual void set_physics_ticks_per_second(int p_ips);
virtual int get_physics_ticks_per_second() const;
virtual void set_max_physics_steps_per_frame(int p_max_physics_steps);
virtual int get_max_physics_steps_per_frame() const;
void set_physics_jitter_fix(double p_threshold);
double get_physics_jitter_fix() const;
virtual void set_max_fps(int p_fps);
virtual int get_max_fps() const;
virtual void set_audio_output_latency(int p_msec);
virtual int get_audio_output_latency() const;
virtual double get_frames_per_second() const { return _fps; }
uint64_t get_frames_drawn();
uint64_t get_physics_frames() const { return _physics_frames; }
uint64_t get_process_frames() const { return _process_frames; }
bool is_in_physics_frame() const { return _in_physics; }
uint64_t get_frame_ticks() const { return _frame_ticks; }
double get_process_step() const { return _process_step; }
double get_physics_interpolation_fraction() const { return _physics_interpolation_fraction; }
void set_time_scale(double p_scale);
double get_time_scale() const;
void set_print_error_messages(bool p_enabled);
bool is_printing_error_messages() const;
void print_header(const String &p_string) const;
void print_header_rich(const String &p_string) const;
void set_frame_delay(uint32_t p_msec);
uint32_t get_frame_delay() const;
void add_singleton(const Singleton &p_singleton);
void get_singletons(List<Singleton> *p_singletons);
bool has_singleton(const StringName &p_name) const;
Object *get_singleton_object(const StringName &p_name) const;
void remove_singleton(const StringName &p_name);
bool is_singleton_user_created(const StringName &p_name) const;
bool is_singleton_editor_only(const StringName &p_name) const;
#ifdef TOOLS_ENABLED
_FORCE_INLINE_ void set_editor_hint(bool p_enabled) { editor_hint = p_enabled; }
_FORCE_INLINE_ bool is_editor_hint() const { return editor_hint; }
_FORCE_INLINE_ void set_project_manager_hint(bool p_enabled) { project_manager_hint = p_enabled; }
_FORCE_INLINE_ bool is_project_manager_hint() const { return project_manager_hint; }
_FORCE_INLINE_ void set_extension_reloading_enabled(bool p_enabled) { extension_reloading = p_enabled; }
_FORCE_INLINE_ bool is_extension_reloading_enabled() const { return extension_reloading; }
#else
_FORCE_INLINE_ void set_editor_hint(bool p_enabled) {}
_FORCE_INLINE_ bool is_editor_hint() const { return false; }
_FORCE_INLINE_ void set_project_manager_hint(bool p_enabled) {}
_FORCE_INLINE_ bool is_project_manager_hint() const { return false; }
_FORCE_INLINE_ void set_extension_reloading_enabled(bool p_enabled) {}
_FORCE_INLINE_ bool is_extension_reloading_enabled() const { return false; }
#endif
Dictionary get_version_info() const;
Dictionary get_author_info() const;
TypedArray<Dictionary> get_copyright_info() const;
Dictionary get_donor_info() const;
Dictionary get_license_info() const;
String get_license_text() const;
void set_write_movie_path(const String &p_path);
String get_write_movie_path() const;
String get_architecture_name() const;
void set_shader_cache_path(const String &p_path);
String get_shader_cache_path() const;
bool is_abort_on_gpu_errors_enabled() const;
bool is_validation_layers_enabled() const;
bool is_generate_spirv_debug_info_enabled() const;
int32_t get_gpu_index() const;
void increment_frames_drawn();
bool notify_frame_server_synced();
Engine();
virtual ~Engine();
};
#endif // ENGINE_H

File diff suppressed because it is too large Load Diff

View File

@ -1,248 +0,0 @@
/**************************************************************************/
/* project_settings.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 PROJECT_SETTINGS_H
#define PROJECT_SETTINGS_H
#include "core/object/class_db.h"
template <typename T>
class TypedArray;
class ProjectSettings : public Object {
GDCLASS(ProjectSettings, Object);
_THREAD_SAFE_CLASS_
friend class TestProjectSettingsInternalsAccessor;
bool is_changed = false;
public:
typedef HashMap<String, Variant> CustomMap;
static const String PROJECT_DATA_DIR_NAME_SUFFIX;
enum {
// Properties that are not for built in values begin from this value, so builtin ones are displayed first.
NO_BUILTIN_ORDER_BASE = 1 << 16
};
#ifdef TOOLS_ENABLED
const static PackedStringArray get_required_features();
const static PackedStringArray get_unsupported_features(const PackedStringArray &p_project_features);
#endif // TOOLS_ENABLED
struct AutoloadInfo {
StringName name;
String path;
bool is_singleton = false;
};
protected:
struct VariantContainer {
int order = 0;
bool persist = false;
bool basic = false;
bool internal = false;
Variant variant;
Variant initial;
bool hide_from_editor = false;
bool restart_if_changed = false;
#ifdef DEBUG_METHODS_ENABLED
bool ignore_value_in_docs = false;
#endif
VariantContainer() {}
VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) :
order(p_order),
persist(p_persist),
variant(p_variant) {
}
};
int last_order = NO_BUILTIN_ORDER_BASE;
int last_builtin_order = 0;
uint64_t last_save_time = 0;
RBMap<StringName, VariantContainer> props; // NOTE: Key order is used e.g. in the save_custom method.
String resource_path;
HashMap<StringName, PropertyInfo> custom_prop_info;
bool using_datapack = false;
bool project_loaded = false;
List<String> input_presets;
HashSet<String> custom_features;
HashMap<StringName, LocalVector<Pair<StringName, StringName>>> feature_overrides;
LocalVector<String> hidden_prefixes;
HashMap<StringName, AutoloadInfo> autoloads;
HashMap<StringName, String> global_groups;
HashMap<StringName, HashSet<StringName>> scene_groups_cache;
Array global_class_list;
bool is_global_class_list_loaded = false;
String project_data_dir_name;
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
bool _property_can_revert(const StringName &p_name) const;
bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
void _queue_changed();
void _emit_changed();
static ProjectSettings *singleton;
Error _load_settings_text(const String &p_path);
Error _load_settings_binary(const String &p_path);
Error _load_settings_text_or_binary(const String &p_text_path, const String &p_bin_path);
Error _save_settings_text(const String &p_file, const RBMap<String, List<String>> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
Error _save_settings_binary(const String &p_file, const RBMap<String, List<String>> &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
Error _save_custom_bnd(const String &p_file);
#ifdef TOOLS_ENABLED
const static PackedStringArray _get_supported_features();
const static PackedStringArray _trim_to_supported_features(const PackedStringArray &p_project_features);
#endif // TOOLS_ENABLED
void _convert_to_last_version(int p_from_version);
bool _load_resource_pack(const String &p_pack, bool p_replace_files = true, int p_offset = 0);
void _add_property_info_bind(const Dictionary &p_info);
Error _setup(const String &p_path, const String &p_main_pack, bool p_upwards = false, bool p_ignore_override = false);
void _add_builtin_input_map();
protected:
static void _bind_methods();
public:
static const int CONFIG_VERSION = 5;
void set_setting(const String &p_setting, const Variant &p_value);
Variant get_setting(const String &p_setting, const Variant &p_default_value = Variant()) const;
TypedArray<Dictionary> get_global_class_list();
void refresh_global_class_list();
void store_global_class_list(const Array &p_classes);
String get_global_class_list_path() const;
bool has_setting(const String &p_var) const;
String localize_path(const String &p_path) const;
String globalize_path(const String &p_path) const;
void set_initial_value(const String &p_name, const Variant &p_value);
void set_as_basic(const String &p_name, bool p_basic);
void set_as_internal(const String &p_name, bool p_internal);
void set_restart_if_changed(const String &p_name, bool p_restart);
void set_ignore_value_in_docs(const String &p_name, bool p_ignore);
bool get_ignore_value_in_docs(const String &p_name) const;
void add_hidden_prefix(const String &p_prefix);
String get_project_data_dir_name() const;
String get_project_data_path() const;
String get_resource_path() const;
String get_imported_files_path() const;
static ProjectSettings *get_singleton();
void clear(const String &p_name);
int get_order(const String &p_name) const;
void set_order(const String &p_name, int p_order);
void set_builtin_order(const String &p_name);
bool is_builtin_setting(const String &p_name) const;
Error setup(const String &p_path, const String &p_main_pack, bool p_upwards = false, bool p_ignore_override = false);
Error load_custom(const String &p_path);
Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true);
Error save();
void set_custom_property_info(const PropertyInfo &p_info);
const HashMap<StringName, PropertyInfo> &get_custom_property_info() const;
uint64_t get_last_saved_time() { return last_save_time; }
List<String> get_input_presets() const { return input_presets; }
Variant get_setting_with_override(const StringName &p_name) const;
bool is_using_datapack() const;
bool is_project_loaded() const;
bool has_custom_feature(const String &p_feature) const;
const HashMap<StringName, AutoloadInfo> &get_autoload_list() const;
void add_autoload(const AutoloadInfo &p_autoload);
void remove_autoload(const StringName &p_autoload);
bool has_autoload(const StringName &p_autoload) const;
AutoloadInfo get_autoload(const StringName &p_name) const;
const HashMap<StringName, String> &get_global_groups_list() const;
void add_global_group(const StringName &p_name, const String &p_description);
void remove_global_group(const StringName &p_name);
bool has_global_group(const StringName &p_name) const;
const HashMap<StringName, HashSet<StringName>> &get_scene_groups_cache() const;
void add_scene_groups_cache(const StringName &p_path, const HashSet<StringName> &p_cache);
void remove_scene_groups_cache(const StringName &p_path);
void save_scene_groups_cache();
String get_scene_groups_cache_path() const;
void load_scene_groups_cache();
#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
ProjectSettings();
ProjectSettings(const String &p_path);
~ProjectSettings();
};
// Not a macro any longer.
Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed = false, bool p_ignore_value_in_docs = false, bool p_basic = false, bool p_internal = false);
Variant _GLOBAL_DEF(const PropertyInfo &p_info, const Variant &p_default, bool p_restart_if_changed = false, bool p_ignore_value_in_docs = false, bool p_basic = false, bool p_internal = false);
#define GLOBAL_DEF(m_var, m_value) _GLOBAL_DEF(m_var, m_value)
#define GLOBAL_DEF_RST(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true)
#define GLOBAL_DEF_NOVAL(m_var, m_value) _GLOBAL_DEF(m_var, m_value, false, true)
#define GLOBAL_DEF_RST_NOVAL(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true, true)
#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get_setting_with_override(m_var)
#define GLOBAL_DEF_BASIC(m_var, m_value) _GLOBAL_DEF(m_var, m_value, false, false, true)
#define GLOBAL_DEF_RST_BASIC(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true, false, true)
#define GLOBAL_DEF_NOVAL_BASIC(m_var, m_value) _GLOBAL_DEF(m_var, m_value, false, true, true)
#define GLOBAL_DEF_RST_NOVAL_BASIC(m_var, m_value) _GLOBAL_DEF(m_var, m_value, true, true, true)
#define GLOBAL_DEF_INTERNAL(m_var, m_value) _GLOBAL_DEF(m_var, m_value, false, false, false, true)
#endif // PROJECT_SETTINGS_H

File diff suppressed because it is too large Load Diff

View File

@ -1,621 +0,0 @@
/**************************************************************************/
/* core_bind.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 CORE_BIND_H
#define CORE_BIND_H
#include "core/debugger/engine_profiler.h"
#include "core/io/image.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/object/script_language.h"
#include "core/os/os.h"
#include "core/os/semaphore.h"
#include "core/os/thread.h"
#include "core/templates/safe_refcount.h"
class MainLoop;
template <typename T>
class TypedArray;
namespace core_bind {
class ResourceLoader : public Object {
GDCLASS(ResourceLoader, Object);
protected:
static void _bind_methods();
static ResourceLoader *singleton;
public:
enum ThreadLoadStatus {
THREAD_LOAD_INVALID_RESOURCE,
THREAD_LOAD_IN_PROGRESS,
THREAD_LOAD_FAILED,
THREAD_LOAD_LOADED
};
enum CacheMode {
CACHE_MODE_IGNORE,
CACHE_MODE_REUSE,
CACHE_MODE_REPLACE,
CACHE_MODE_IGNORE_DEEP,
CACHE_MODE_REPLACE_DEEP,
};
static ResourceLoader *get_singleton() { return singleton; }
Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false, CacheMode p_cache_mode = CACHE_MODE_REUSE);
ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = Array());
Ref<Resource> load_threaded_get(const String &p_path);
Ref<Resource> load(const String &p_path, const String &p_type_hint = "", CacheMode p_cache_mode = CACHE_MODE_REUSE);
Vector<String> get_recognized_extensions_for_type(const String &p_type);
void add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front);
void remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader);
void set_abort_on_missing_resources(bool p_abort);
PackedStringArray get_dependencies(const String &p_path);
bool has_cached(const String &p_path);
bool exists(const String &p_path, const String &p_type_hint = "");
ResourceUID::ID get_resource_uid(const String &p_path);
ResourceLoader() { singleton = this; }
};
class ResourceSaver : public Object {
GDCLASS(ResourceSaver, Object);
protected:
static void _bind_methods();
static ResourceSaver *singleton;
public:
enum SaverFlags {
FLAG_NONE = 0,
FLAG_RELATIVE_PATHS = 1,
FLAG_BUNDLE_RESOURCES = 2,
FLAG_CHANGE_PATH = 4,
FLAG_OMIT_EDITOR_PROPERTIES = 8,
FLAG_SAVE_BIG_ENDIAN = 16,
FLAG_COMPRESS = 32,
FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
};
static ResourceSaver *get_singleton() { return singleton; }
Error save(const Ref<Resource> &p_resource, const String &p_path, BitField<SaverFlags> p_flags);
Vector<String> get_recognized_extensions(const Ref<Resource> &p_resource);
void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front);
void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver);
ResourceSaver() { singleton = this; }
};
class OS : public Object {
GDCLASS(OS, Object);
mutable HashMap<String, bool> feature_cache;
protected:
static void _bind_methods();
static OS *singleton;
public:
enum RenderingDriver {
RENDERING_DRIVER_VULKAN,
RENDERING_DRIVER_OPENGL3,
RENDERING_DRIVER_D3D12,
};
PackedByteArray get_entropy(int p_bytes);
String get_system_ca_certificates();
virtual PackedStringArray get_connected_midi_inputs();
virtual void open_midi_inputs();
virtual void close_midi_inputs();
void set_low_processor_usage_mode(bool p_enabled);
bool is_in_low_processor_usage_mode() const;
void set_low_processor_usage_mode_sleep_usec(int p_usec);
int get_low_processor_usage_mode_sleep_usec() const;
void set_delta_smoothing(bool p_enabled);
bool is_delta_smoothing_enabled() const;
void alert(const String &p_alert, const String &p_title = "ALERT!");
void crash(const String &p_message);
Vector<String> get_system_fonts() const;
String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const;
Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const;
String get_executable_path() const;
String read_string_from_stdin();
int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = Array(), bool p_read_stderr = false, bool p_open_console = false);
Dictionary execute_with_pipe(const String &p_path, const Vector<String> &p_arguments);
int create_process(const String &p_path, const Vector<String> &p_arguments, bool p_open_console = false);
int create_instance(const Vector<String> &p_arguments);
Error kill(int p_pid);
Error shell_open(const String &p_uri);
Error shell_show_in_file_manager(const String &p_path, bool p_open_folder = true);
bool is_process_running(int p_pid) const;
int get_process_exit_code(int p_pid) const;
int get_process_id() const;
void set_restart_on_exit(bool p_restart, const Vector<String> &p_restart_arguments = Vector<String>());
bool is_restart_on_exit_set() const;
Vector<String> get_restart_on_exit_arguments() const;
bool has_environment(const String &p_var) const;
String get_environment(const String &p_var) const;
void set_environment(const String &p_var, const String &p_value) const;
void unset_environment(const String &p_var) const;
String get_name() const;
String get_distribution_name() const;
String get_version() const;
Vector<String> get_cmdline_args();
Vector<String> get_cmdline_user_args();
Vector<String> get_video_adapter_driver_info() const;
String get_locale() const;
String get_locale_language() const;
String get_model_name() const;
bool is_debug_build() const;
String get_unique_id() const;
String get_keycode_string(Key p_code) const;
bool is_keycode_unicode(char32_t p_unicode) const;
Key find_keycode_from_string(const String &p_code) const;
void set_use_file_access_save_and_swap(bool p_enable);
uint64_t get_static_memory_usage() const;
uint64_t get_static_memory_peak_usage() const;
Dictionary get_memory_info() const;
void delay_usec(int p_usec) const;
void delay_msec(int p_msec) const;
uint64_t get_ticks_msec() const;
uint64_t get_ticks_usec() const;
bool is_userfs_persistent() const;
bool is_stdout_verbose() const;
int get_processor_count() const;
String get_processor_name() const;
enum SystemDir {
SYSTEM_DIR_DESKTOP,
SYSTEM_DIR_DCIM,
SYSTEM_DIR_DOCUMENTS,
SYSTEM_DIR_DOWNLOADS,
SYSTEM_DIR_MOVIES,
SYSTEM_DIR_MUSIC,
SYSTEM_DIR_PICTURES,
SYSTEM_DIR_RINGTONES,
};
String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const;
Error move_to_trash(const String &p_path) const;
String get_user_data_dir() const;
String get_config_dir() const;
String get_data_dir() const;
String get_cache_dir() const;
Error set_thread_name(const String &p_name);
::Thread::ID get_thread_caller_id() const;
::Thread::ID get_main_thread_id() const;
bool has_feature(const String &p_feature) const;
bool is_sandboxed() const;
bool request_permission(const String &p_name);
bool request_permissions();
Vector<String> get_granted_permissions() const;
void revoke_granted_permissions();
static OS *get_singleton() { return singleton; }
OS() { singleton = this; }
};
class Geometry2D : public Object {
GDCLASS(Geometry2D, Object);
static Geometry2D *singleton;
protected:
static void _bind_methods();
public:
static Geometry2D *get_singleton();
Variant segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
Variant line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
Vector<Vector2> get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
Vector2 get_closest_point_to_segment(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
Vector2 get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
Vector<int> triangulate_delaunay(const Vector<Vector2> &p_points);
Vector<Point2> convex_hull(const Vector<Point2> &p_points);
TypedArray<PackedVector2Array> decompose_polygon_in_convex(const Vector<Vector2> &p_polygon);
enum PolyBooleanOperation {
OPERATION_UNION,
OPERATION_DIFFERENCE,
OPERATION_INTERSECTION,
OPERATION_XOR
};
// 2D polygon boolean operations.
TypedArray<PackedVector2Array> merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
TypedArray<PackedVector2Array> clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
TypedArray<PackedVector2Array> intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
TypedArray<PackedVector2Array> exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
// 2D polyline vs polygon operations.
TypedArray<PackedVector2Array> clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
TypedArray<PackedVector2Array> intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
// 2D offset polygons/polylines.
enum PolyJoinType {
JOIN_SQUARE,
JOIN_ROUND,
JOIN_MITER
};
enum PolyEndType {
END_POLYGON,
END_JOINED,
END_BUTT,
END_SQUARE,
END_ROUND
};
TypedArray<PackedVector2Array> offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
TypedArray<PackedVector2Array> offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
Dictionary make_atlas(const Vector<Size2> &p_rects);
Geometry2D() { singleton = this; }
};
class Geometry3D : public Object {
GDCLASS(Geometry3D, Object);
static Geometry3D *singleton;
protected:
static void _bind_methods();
public:
static Geometry3D *get_singleton();
Vector<Vector3> compute_convex_mesh_points(const TypedArray<Plane> &p_planes);
TypedArray<Plane> build_box_planes(const Vector3 &p_extents);
TypedArray<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
TypedArray<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
Vector3 get_triangle_barycentric_coords(const Vector3 &p_point, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const TypedArray<Plane> &p_planes);
Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
Vector<int32_t> tetrahedralize_delaunay(const Vector<Vector3> &p_points);
Geometry3D() { singleton = this; }
};
class Marshalls : public Object {
GDCLASS(Marshalls, Object);
static Marshalls *singleton;
protected:
static void _bind_methods();
public:
static Marshalls *get_singleton();
String variant_to_base64(const Variant &p_var, bool p_full_objects = false);
Variant base64_to_variant(const String &p_str, bool p_allow_objects = false);
String raw_to_base64(const Vector<uint8_t> &p_arr);
Vector<uint8_t> base64_to_raw(const String &p_str);
String utf8_to_base64(const String &p_str);
String base64_to_utf8(const String &p_str);
Marshalls() { singleton = this; }
~Marshalls() { singleton = nullptr; }
};
class Mutex : public RefCounted {
GDCLASS(Mutex, RefCounted);
::Mutex mutex;
static void _bind_methods();
public:
void lock();
bool try_lock();
void unlock();
};
class Semaphore : public RefCounted {
GDCLASS(Semaphore, RefCounted);
::Semaphore semaphore;
static void _bind_methods();
public:
void wait();
bool try_wait();
void post();
};
class Thread : public RefCounted {
GDCLASS(Thread, RefCounted);
protected:
Variant ret;
SafeFlag running;
Callable target_callable;
::Thread thread;
static void _bind_methods();
static void _start_func(void *ud);
public:
enum Priority {
PRIORITY_LOW,
PRIORITY_NORMAL,
PRIORITY_HIGH,
PRIORITY_MAX
};
Error start(const Callable &p_callable, Priority p_priority = PRIORITY_NORMAL);
String get_id() const;
bool is_started() const;
bool is_alive() const;
Variant wait_to_finish();
static void set_thread_safety_checks_enabled(bool p_enabled);
};
namespace special {
class ClassDB : public Object {
GDCLASS(ClassDB, Object);
protected:
static void _bind_methods();
public:
PackedStringArray get_class_list() const;
PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
StringName get_parent_class(const StringName &p_class) const;
bool class_exists(const StringName &p_class) const;
bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
bool can_instantiate(const StringName &p_class) const;
Variant instantiate(const StringName &p_class) const;
bool class_has_signal(const StringName &p_class, const StringName &p_signal) const;
Dictionary class_get_signal(const StringName &p_class, const StringName &p_signal) const;
TypedArray<Dictionary> class_get_signal_list(const StringName &p_class, bool p_no_inheritance = false) const;
TypedArray<Dictionary> class_get_property_list(const StringName &p_class, bool p_no_inheritance = false) const;
Variant class_get_property(Object *p_object, const StringName &p_property) const;
Error class_set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
Variant class_get_property_default_value(const StringName &p_class, const StringName &p_property) const;
bool class_has_method(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
int class_get_method_argument_count(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
TypedArray<Dictionary> class_get_method_list(const StringName &p_class, bool p_no_inheritance = false) const;
PackedStringArray class_get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
bool class_has_integer_constant(const StringName &p_class, const StringName &p_name) const;
int64_t class_get_integer_constant(const StringName &p_class, const StringName &p_name) const;
bool class_has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
PackedStringArray class_get_enum_list(const StringName &p_class, bool p_no_inheritance = false) const;
PackedStringArray class_get_enum_constants(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
StringName class_get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
bool is_class_enum_bitfield(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
bool is_class_enabled(const StringName &p_class) const;
#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
ClassDB() {}
~ClassDB() {}
};
} // namespace special
class Engine : public Object {
GDCLASS(Engine, Object);
protected:
static void _bind_methods();
static Engine *singleton;
public:
static Engine *get_singleton() { return singleton; }
void set_physics_ticks_per_second(int p_ips);
int get_physics_ticks_per_second() const;
void set_max_physics_steps_per_frame(int p_max_physics_steps);
int get_max_physics_steps_per_frame() const;
void set_physics_jitter_fix(double p_threshold);
double get_physics_jitter_fix() const;
double get_physics_interpolation_fraction() const;
void set_max_fps(int p_fps);
int get_max_fps() const;
double get_frames_per_second() const;
uint64_t get_physics_frames() const;
uint64_t get_process_frames() const;
int get_frames_drawn();
void set_time_scale(double p_scale);
double get_time_scale();
MainLoop *get_main_loop() const;
Dictionary get_version_info() const;
Dictionary get_author_info() const;
TypedArray<Dictionary> get_copyright_info() const;
Dictionary get_donor_info() const;
Dictionary get_license_info() const;
String get_license_text() const;
String get_architecture_name() const;
bool is_in_physics_frame() const;
bool has_singleton(const StringName &p_name) const;
Object *get_singleton_object(const StringName &p_name) const;
void register_singleton(const StringName &p_name, Object *p_object);
void unregister_singleton(const StringName &p_name);
Vector<String> get_singleton_list() const;
Error register_script_language(ScriptLanguage *p_language);
Error unregister_script_language(const ScriptLanguage *p_language);
int get_script_language_count();
ScriptLanguage *get_script_language(int p_index) const;
void set_editor_hint(bool p_enabled);
bool is_editor_hint() const;
// `set_write_movie_path()` is not exposed to the scripting API as changing it at run-time has no effect.
String get_write_movie_path() const;
void set_print_error_messages(bool p_enabled);
bool is_printing_error_messages() const;
#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
Engine() { singleton = this; }
};
class EngineDebugger : public Object {
GDCLASS(EngineDebugger, Object);
HashMap<StringName, Callable> captures;
HashMap<StringName, Ref<EngineProfiler>> profilers;
protected:
static void _bind_methods();
static EngineDebugger *singleton;
public:
static EngineDebugger *get_singleton() { return singleton; }
bool is_active();
void register_profiler(const StringName &p_name, Ref<EngineProfiler> p_profiler);
void unregister_profiler(const StringName &p_name);
bool is_profiling(const StringName &p_name);
bool has_profiler(const StringName &p_name);
void profiler_add_frame_data(const StringName &p_name, const Array &p_data);
void profiler_enable(const StringName &p_name, bool p_enabled, const Array &p_opts = Array());
void register_message_capture(const StringName &p_name, const Callable &p_callable);
void unregister_message_capture(const StringName &p_name);
bool has_capture(const StringName &p_name);
void send_message(const String &p_msg, const Array &p_data);
void debug(bool p_can_continue = true, bool p_is_error_breakpoint = false);
void script_debug(ScriptLanguage *p_lang, bool p_can_continue = true, bool p_is_error_breakpoint = false);
static Error call_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured);
void line_poll();
void set_lines_left(int p_lines);
int get_lines_left() const;
void set_depth(int p_depth);
int get_depth() const;
bool is_breakpoint(int p_line, const StringName &p_source) const;
bool is_skipping_breakpoints() const;
void insert_breakpoint(int p_line, const StringName &p_source);
void remove_breakpoint(int p_line, const StringName &p_source);
void clear_breakpoints();
EngineDebugger() { singleton = this; }
~EngineDebugger();
};
} // namespace core_bind
VARIANT_ENUM_CAST(core_bind::ResourceLoader::ThreadLoadStatus);
VARIANT_ENUM_CAST(core_bind::ResourceLoader::CacheMode);
VARIANT_BITFIELD_CAST(core_bind::ResourceSaver::SaverFlags);
VARIANT_ENUM_CAST(core_bind::OS::RenderingDriver);
VARIANT_ENUM_CAST(core_bind::OS::SystemDir);
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyBooleanOperation);
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyJoinType);
VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyEndType);
VARIANT_ENUM_CAST(core_bind::Thread::Priority);
#endif // CORE_BIND_H

Some files were not shown because too many files have changed in this diff Show More