mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 09:29:44 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
bf59e520a7
109 changed files with 1908 additions and 474 deletions
6
.github/workflows/appimage.yml
vendored
6
.github/workflows/appimage.yml
vendored
|
|
@ -50,13 +50,13 @@ jobs:
|
|||
- name: Run engine tests
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
chmod +x build/VoxelEngine
|
||||
chmod +x build/VoxelCore
|
||||
chmod +x AppDir/usr/bin/vctest
|
||||
AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --memchecker valgrind
|
||||
AppDir/usr/bin/vctest -e build/VoxelCore -d dev/tests -u build --memchecker valgrind
|
||||
- name: Build AppImage
|
||||
uses: AppImageCrafters/build-appimage-action@fe2205a4d6056be47051f7b1b3811106e9814910
|
||||
env:
|
||||
UPDATE_INFO: gh-releases-zsync|MihailRis|VoxelEngine-Cpp|latest|*x86_64.AppImage.zsync
|
||||
UPDATE_INFO: gh-releases-zsync|MihailRis|voxelcore|latest|*x86_64.AppImage.zsync
|
||||
with:
|
||||
recipe: dev/AppImageBuilder.yml
|
||||
- uses: actions/upload-artifact@v4
|
||||
|
|
|
|||
6
.github/workflows/cmake.yml
vendored
6
.github/workflows/cmake.yml
vendored
|
|
@ -62,7 +62,7 @@ jobs:
|
|||
# Build your program with the given configuration
|
||||
run: |
|
||||
cmake --build ${{github.workspace}}/build --config ${{inputs.build_type}}
|
||||
mv ${{github.workspace}}/build/VoxelEngine VoxelEngine
|
||||
mv ${{github.workspace}}/build/VoxelCore VoxelCore
|
||||
- name: Run tests
|
||||
if: ${{ inputs.run_tests }}
|
||||
run: ctest --test-dir ${{github.workspace}}/build
|
||||
|
|
@ -70,7 +70,7 @@ jobs:
|
|||
if: ${{ inputs.upload_artifacts }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: VoxelEngine
|
||||
name: VoxelCore
|
||||
path: |
|
||||
VoxelEngine
|
||||
VoxelCore
|
||||
res/*
|
||||
|
|
|
|||
20
.github/workflows/macos.yml
vendored
20
.github/workflows/macos.yml
vendored
|
|
@ -39,7 +39,7 @@ jobs:
|
|||
run: chmod +x dev/fix_dylibs.sh
|
||||
|
||||
- name: Fix dylibs
|
||||
run: ./dev/fix_dylibs.sh VoxelEngine Release build
|
||||
run: ./dev/fix_dylibs.sh VoxelCore Release build
|
||||
|
||||
- name: Run tests
|
||||
run: ctest --output-on-failure --test-dir build
|
||||
|
|
@ -47,19 +47,19 @@ jobs:
|
|||
- name: Run engine tests
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
chmod +x build/VoxelEngine
|
||||
chmod +x build/VoxelCore
|
||||
chmod +x AppDir/usr/bin/vctest
|
||||
AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- "
|
||||
AppDir/usr/bin/vctest -e build/VoxelCore -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- "
|
||||
- name: Create DMG
|
||||
run: |
|
||||
mkdir VoxelEngineDmgContent
|
||||
cp -r build/res VoxelEngineDmgContent/
|
||||
cp -r build/VoxelEngine VoxelEngineDmgContent/
|
||||
cp -r build/libs VoxelEngineDmgContent/libs
|
||||
hdiutil create VoxelEngineMacApp.dmg -volname "VoxelEngine" -srcfolder VoxelEngineDmgContent -ov -format UDZO
|
||||
mkdir VoxelCoreDmgContent
|
||||
cp -r build/res VoxelCoreDmgContent/
|
||||
cp -r build/VoxelCore VoxelCoreDmgContent/
|
||||
cp -r build/libs VoxelCoreDmgContent/libs
|
||||
hdiutil create VoxelCoreMacApp.dmg -volname "VoxelCore" -srcfolder VoxelCoreDmgContent -ov -format UDZO
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: VoxelEngineMacOs
|
||||
path: VoxelEngineMacApp.dmg
|
||||
name: VoxelCoreMacOs
|
||||
path: VoxelCoreMacApp.dmg
|
||||
|
|
|
|||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
|
@ -48,7 +48,7 @@ jobs:
|
|||
mkdir release
|
||||
mv ./artifacts/AppImage/VoxelCore-latest-x86_64.AppImage \
|
||||
./release/voxelcore-${RELEASE_VERSION}_x86-64.AppImage
|
||||
mv ./artifacts/VoxelEngineMacOs/VoxelEngineMacApp.dmg \
|
||||
mv ./artifacts/VoxelCoreMacOs/VoxelCoreMacApp.dmg \
|
||||
./release/voxelcore-${RELEASE_VERSION}_macos.dmg
|
||||
(cd ./artifacts/Windows-Build && zip -r ../../release/voxelcore-${RELEASE_VERSION}_win64.zip .)
|
||||
ls -la ./release
|
||||
|
|
|
|||
3
.github/workflows/windows-clang.yml
vendored
3
.github/workflows/windows-clang.yml
vendored
|
|
@ -59,11 +59,10 @@ jobs:
|
|||
run: |
|
||||
mkdir packaged
|
||||
mkdir packaged/res
|
||||
cp build/VoxelEngine.exe packaged/
|
||||
cp build/VoxelCore.exe packaged/
|
||||
cp build/vctest/vctest.exe packaged/
|
||||
cp build/*.dll packaged/
|
||||
cp -r build/res/* packaged/res/
|
||||
mv packaged/VoxelEngine.exe packaged/VoxelCore.exe
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Windows-Build
|
||||
|
|
|
|||
3
.github/workflows/windows.yml
vendored
3
.github/workflows/windows.yml
vendored
|
|
@ -37,7 +37,7 @@ jobs:
|
|||
run: ctest --preset default-vs-msvc-windows
|
||||
- name: Run engine tests
|
||||
run: |
|
||||
build/vctest/RelWithDebInfo/vctest.exe -e build/RelWithDebInfo/VoxelEngine.exe -d dev/tests -u build
|
||||
build/vctest/RelWithDebInfo/vctest.exe -e build/RelWithDebInfo/VoxelCore.exe -d dev/tests -u build
|
||||
timeout-minutes: 5
|
||||
- name: Package for Windows
|
||||
run: |
|
||||
|
|
@ -45,7 +45,6 @@ jobs:
|
|||
cp -r build/RelWithDebInfo/* packaged/
|
||||
cp build/vctest/RelWithDebInfo/vctest.exe packaged/
|
||||
cp C:/Windows/System32/msvcp140.dll packaged/msvcp140.dll
|
||||
mv packaged/VoxelEngine.exe packaged/VoxelCore.exe
|
||||
working-directory: ${{ github.workspace }}
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
|
|
|
|||
427
CHANGELOG.md
427
CHANGELOG.md
|
|
@ -1,6 +1,6 @@
|
|||
# 0.31 - 2026.03.22
|
||||
# 0.32 - 2026.10.03
|
||||
|
||||
[Documentation](https://github.com/MihailRis/VoxelEngine-Cpp/tree/release-0.31/doc/en/main-page.md) for 0.31
|
||||
[Documentation](https://github.com/MihailRis/VoxelEngine-Cpp/tree/release-0.32/doc/en/main-page.md) for 0.32
|
||||
|
||||
Table of contents:
|
||||
|
||||
|
|
@ -13,169 +13,288 @@ Table of contents:
|
|||
|
||||
## New Features
|
||||
|
||||
- solid entities with solid hitboxes
|
||||
- rendering ui to texture with 'frame' element
|
||||
- loading vector fonts support with freetype library
|
||||
- defining skeletons in VCM files
|
||||
- project permissions system
|
||||
- executing commands from stdin ('--stdin-cmd' command line argument enables it)
|
||||
- animation
|
||||
- semi-transparent entities
|
||||
- client-side --script, --test support
|
||||
- environments (in-development)
|
||||
- translators
|
||||
- VCA format
|
||||
|
||||
## Added
|
||||
|
||||
- added clouds, so sky is no more so deadly clear
|
||||
- ui:
|
||||
- added 'onmouseenter', 'onmouseleave' events
|
||||
- added 'zIndex' common scripting property
|
||||
- added 'inventory' scripting property to slot element
|
||||
- added 'font' attribute
|
||||
- added 'text-align' label attribute
|
||||
- added 'frame' element
|
||||
- added 'fallback' image attribute
|
||||
- particles:
|
||||
- added 'spawn_offset' property
|
||||
- audio:
|
||||
- added acoustic effects (reverb)
|
||||
- added 'audio.acoustic-effects' setting
|
||||
- added 'record-audio' project permission
|
||||
- projects system:
|
||||
- added project permissions configuration
|
||||
- added 'debugging' permission
|
||||
- added 'base:flat_grass' world generator
|
||||
- added ssao quality setting
|
||||
- added background assets loader
|
||||
- vcm format:
|
||||
- added 'bone' (model/skeleton node) element
|
||||
- added 'tri' (triangle) element
|
||||
- added 'on_inventory_interact' hud event
|
||||
- added weather properties:
|
||||
- 'sky_tint'
|
||||
- 'clouds_tint'
|
||||
- 'min_sky_light'
|
||||
- added block properties:
|
||||
- 'grounding-behaviour' (extended blocks)
|
||||
- explicit 'solid' visual property
|
||||
- added world generator parameters:
|
||||
- 'player-spawn-radius'
|
||||
- 'player-min-spawn-height'
|
||||
- 'player-max-spawn-height'
|
||||
- added 'material' entity property
|
||||
- added patch number to engine build produced by release pipeline
|
||||
- new functions arguments:
|
||||
- added 'skeleton_name' argument to assets.parse_model
|
||||
- added 'include_non_selectable' argument to block.raycast
|
||||
- added 'variant_index' argument to block.get_model, block.model_name, block.get_textures
|
||||
- added optional 'emission' argument to gfx.blockwraps.wrap
|
||||
- added gui.load_document namespace extension table
|
||||
- added freetype dependency
|
||||
- events:
|
||||
- main.lua script:
|
||||
- on_scripts_loading
|
||||
- on_content_loaded
|
||||
- world.lua script:
|
||||
- on_entity_spawned
|
||||
- on_entity_despawned
|
||||
- entity component:
|
||||
- on_player_set
|
||||
- libraries:
|
||||
- animation
|
||||
- crypto
|
||||
- ctypes
|
||||
- test
|
||||
- vc
|
||||
- xml
|
||||
- new classes:
|
||||
- debug.Logger
|
||||
- I8view
|
||||
- I64view
|
||||
- U64view
|
||||
- FLTview
|
||||
- DBLview
|
||||
- private PlayingTrack
|
||||
- private Hash
|
||||
- 3d text 'font' property
|
||||
- documented:
|
||||
- block `material` property
|
||||
- defaults:
|
||||
- block-material
|
||||
- permissions:
|
||||
- sub-instances
|
||||
- `--log` command line argument
|
||||
- `ladder` rotation profile
|
||||
- new ui properties:
|
||||
- `select` element `button` mode
|
||||
- `onrightclick`
|
||||
- `onmiddleclick`
|
||||
- verbose parsing error messages
|
||||
- content menu: pack version display
|
||||
- Heightmap.normalNoise field
|
||||
- content menu: filtering by pack id
|
||||
- `hot-reload` VC-DBG signal
|
||||
- `normal` attribute for `tri` and `rect` VCM primitives
|
||||
- `lighting-mode` entity property
|
||||
- vca syntax highlighting
|
||||
- `cull-face` property for `tri` and `rect` VCM primitives
|
||||
- `graphics.enable-fog` setting
|
||||
|
||||
## New Functions
|
||||
|
||||
- assets.request_texture
|
||||
- block.get_hitbox
|
||||
- entity.rigidbody:get_elasticity
|
||||
- entity.rigidbody:get_mass
|
||||
- entity.rigidbody:get_material
|
||||
- entity.rigidbody:set_elasticity
|
||||
- entity.rigidbody:set_mass
|
||||
- entity.rigidbody:set_material
|
||||
- entity.rigidbody:get_ground_vel
|
||||
- gfx.blockwraps.set_faces
|
||||
- gfx.blockwraps.set_tints
|
||||
- gui.close_menu
|
||||
- gui.create_frame
|
||||
- gui.get_active_frame
|
||||
- gui.set_active_frame
|
||||
- hud.get_second_inventory
|
||||
- hud.is_player_inventory_open
|
||||
- mat4.perspective
|
||||
- quat.from_euler
|
||||
- session.get
|
||||
- session.has
|
||||
- session.reset
|
||||
- animation.action
|
||||
- animation.play
|
||||
- app.get_content
|
||||
- app.is_instance_alive
|
||||
- app.start_background_instance
|
||||
- app.terminate_instance
|
||||
- assets.parse_animation
|
||||
- Bytearray:copy
|
||||
- Bytearray:fill
|
||||
- Bytearray:move
|
||||
- crypto.aes_gcm_decrypt
|
||||
- crypto.aes_gcm_encrypt
|
||||
- crypto.chacha20_poly1305_decrypt
|
||||
- crypto.chacha20_poly1305_encrypt
|
||||
- crypto.constant_time_equal
|
||||
- crypto.ecdsa_keypair
|
||||
- crypto.ecdsa_public
|
||||
- crypto.ecdsa_sign
|
||||
- crypto.ecdsa_verify
|
||||
- crypto.ed25519_keypair
|
||||
- crypto.ed25519_public
|
||||
- crypto.ed25519_sign
|
||||
- crypto.ed25519_verify
|
||||
- crypto.features
|
||||
- crypto.hash
|
||||
- crypto.hkdf_expand
|
||||
- crypto.hkdf_extract
|
||||
- crypto.hmac
|
||||
- crypto.md5
|
||||
- crypto.p256_keypair
|
||||
- crypto.p256_public
|
||||
- crypto.p256_shared
|
||||
- crypto.pbkdf2
|
||||
- crypto.random_bytes
|
||||
- crypto.rsa_pkcs1_verify
|
||||
- crypto.rsa_pss_verify
|
||||
- crypto.scrypt
|
||||
- crypto.sha256
|
||||
- crypto.sha384
|
||||
- crypto.sha512
|
||||
- crypto.x25519
|
||||
- crypto.x25519_keypair
|
||||
- crypto.x25519_public
|
||||
- crypto.x25519_shared
|
||||
- ctypes.int16
|
||||
- ctypes.int32
|
||||
- ctypes.int64
|
||||
- ctypes.int8
|
||||
- ctypes.uint16
|
||||
- ctypes.uint32
|
||||
- ctypes.uint64
|
||||
- ctypes.uint8
|
||||
- entities.def_solid
|
||||
- events.remove
|
||||
- file.remove_ext
|
||||
- gfx.text3d.get_entity
|
||||
- gfx.text3d.set_entity
|
||||
- gui.screenshot
|
||||
- Hash:final
|
||||
- Hash:update
|
||||
- Heightmap:ceil
|
||||
- Heightmap:cos
|
||||
- Heightmap:floor
|
||||
- Heightmap:round
|
||||
- Heightmap:sin
|
||||
- Heightmap:tan
|
||||
- input.get_mouse_scroll
|
||||
- inventory.set_all_data
|
||||
- io_stream:available
|
||||
- io_stream:tell
|
||||
- io_stream:wrap_bytearray
|
||||
- math.noise
|
||||
- math.noise2d
|
||||
- math.sign
|
||||
- network.request
|
||||
- PlayingTrack:pause
|
||||
- PlayingTrack:stop
|
||||
- quat.mul
|
||||
- quat.mul_vec3
|
||||
- rigidbody:set_selectable
|
||||
- socket:as_stream
|
||||
- socket:peek
|
||||
- socket:peek_async
|
||||
- string.url_decode
|
||||
- string.url_encode
|
||||
- table.keys
|
||||
- test.click
|
||||
- test.fill
|
||||
- test.find_by_attr
|
||||
- test.find_by_attr_presence
|
||||
- test.find_by_text
|
||||
- test.press
|
||||
- time.precise_time
|
||||
- time.precise_utc_time
|
||||
- Tview:typesize
|
||||
- vc.get_setting
|
||||
- vc.get_setting_info
|
||||
- vc.get_version
|
||||
- vc.is_client
|
||||
- vc.is_headless
|
||||
- vc.str_setting
|
||||
- world.raycast
|
||||
- xml.parse
|
||||
- xml.parse_vcd
|
||||
- xml.tostring
|
||||
|
||||
now documented:
|
||||
New overloads:
|
||||
|
||||
- audio.input.get_input_info
|
||||
- gui.ask
|
||||
- gui.show_message
|
||||
- asserts.equals(Canvas)
|
||||
- skeleton:set_color(int, ...)
|
||||
|
||||
## Changes
|
||||
|
||||
- minor visual restoration
|
||||
- assets.parse_model now supports OBJ format
|
||||
- chunks loading optimizations
|
||||
- app.load_content, app.reset_content, app.reconfig_packs and app.config_packs calling limited to app script coroutine and time.post_runnable context
|
||||
- debug panel updated a bit
|
||||
- pass app library from standard pages loader
|
||||
- skeletons are now assets
|
||||
- inventory interaction enchancements [#897](https://github.com/MihailRis/voxelcore/issues/897)
|
||||
- breaking: document events removed from 'events' library temporary
|
||||
|
||||
## Fixes
|
||||
|
||||
- [fix vec3 shadeless flag](https://github.com/MihailRis/voxelcore/commit/5e05b44c26c1b57aaceb5e3478ccf5f98e3f14d7)
|
||||
- [fix: missing extended block size limit check](https://github.com/MihailRis/voxelcore/commit/9628177698b29488965bffc60fa305e752245c13)
|
||||
- [fix extended block grounding](https://github.com/MihailRis/voxelcore/commit/0b7dc14f5512478c7b7df408bab007d06de6f9ae)
|
||||
- [fix blocks variants](https://github.com/MihailRis/voxelcore/commit/0cc8c70a1704bf511635c1c1e19fe707e8477127)
|
||||
- [fix fatal exception caused by empty skeleton model texture name](https://github.com/MihailRis/voxelcore/commit/fc04284b34d5dfc8afd008933b61644dda6b73c6)
|
||||
- [fix blocks random tick](https://github.com/MihailRis/voxelcore/commit/9ac8406558ebe6183071545aeb8e34a968503c18)
|
||||
- [fix 'attempt to compare string with number' in audio.input.fetch](https://github.com/MihailRis/voxelcore/commit/ba2546e096c93e13fc0abfcf0e0447eb1721960f)
|
||||
- [fix: FFI library access from non-built-in scripts vulnerability](https://github.com/MihailRis/voxelcore/commit/a32845d083f3d2528f04eebe173ed7358cd2cf14)
|
||||
- [fix non-lighted chunks saving](https://github.com/MihailRis/voxelcore/commit/5b8c2d6162092f3655e2d857fa75ee42d879e604)
|
||||
- [fix: attempting to build lights in non-local players chunk matrices](https://github.com/MihailRis/voxelcore/commit/3308a61d560c2d9bbff0c81d2ed5d391103ec5d0)
|
||||
- [fix extended blocks collision detection](https://github.com/MihailRis/voxelcore/commit/c8e884009bdc7b7ee8025b05cfb12284f340d0af)
|
||||
- [fix: block inventory not removing in some cases](https://github.com/MihailRis/voxelcore/commit/e4d21c940be9048076180976eaba31f0138661a3)
|
||||
- [fix extended blocks culling on chunk borders](https://github.com/MihailRis/voxelcore/commit/7abbe43c3cf21bbf7afa3cf392b08e52950fa163)
|
||||
- [fix: player name text is still visible when suspended](https://github.com/MihailRis/voxelcore/commit/49aa7cdfba19ebc6d141dca28f7ed269c2e443fa)
|
||||
- [fix: crouching falling prevention does not reset velocity & fix small hitboxes horizontal collision](https://github.com/MihailRis/voxelcore/commit/bfa8b7cf3d483b2ea3f4f7166f49b1682a471363)
|
||||
- [fix: macos build pipeline uses OpenAL.Framework instead of openal-soft](https://github.com/MihailRis/voxelcore/commit/cd537cc1cbf490b614cdbd8ab38a3a26364c29f6)
|
||||
- [fix: assets access attempts in headless mode leading to segfaults](https://github.com/MihailRis/voxelcore/commit/a92efe581f3b6a37f3217684a7174efb50bb6ef9)
|
||||
- [fix crash in headless](https://github.com/MihailRis/voxelcore/commit/2b4c3c08f35c0ce0de85789a27b77a47ce134c53)
|
||||
- [fix advanced render setting tooltip](https://github.com/MihailRis/voxelcore/commit/fcbbf4814a10b6db09ba30e90b21be7dc0c96d9f)
|
||||
- [fix io_stream.write_line](https://github.com/MihailRis/voxelcore/commit/4809003aa8af28ed04d78a396f32580ee5506c39)
|
||||
- [fix bytearray view classes](https://github.com/MihailRis/voxelcore/commit/3f68fc1fc4fce39328a570253583d9a796779d7d)
|
||||
- [fix extra faces when dense mode is off](https://github.com/MihailRis/voxelcore/commit/89485dc592f138cd244d61ac6871d745c3e82e9d)
|
||||
- [fix fatal error when skeleton is missing](https://github.com/MihailRis/voxelcore/commit/8b5261f4f14ee31894dcf5125a4836ff140de8a9)
|
||||
- [fix entity skeleton name serialization](https://github.com/MihailRis/voxelcore/commit/d07c8e523429393a26dbccaaf7fc7275079fa577)
|
||||
- [fix on_chunk_register_event](https://github.com/MihailRis/voxelcore/commit/d197415739f0e75369a4b14de808ce9c16c808d8)
|
||||
- [fix: player entity body is active before player flight state applied](https://github.com/MihailRis/voxelcore/commit/5785060ffb85edb33c72410e0c65123c094fb3dd)
|
||||
- [fix: player not spawning entity after set_suspended(pid, false)](https://github.com/MihailRis/voxelcore/commit/088bfc878efc05fdd92078581068e16d1e38f652)
|
||||
- [fix incorrect 3d text preset for existing players](https://github.com/MihailRis/voxelcore/commit/d9a914ee5423ec216e216f6839785a887eb47036)
|
||||
- [fix: player.set_suspend(pid, true) leaves entity in the world](https://github.com/MihailRis/voxelcore/commit/a4fc4a5044d394a8f1d054ecf76d18c6ebba0a78)
|
||||
- [fix nested vcm elements](https://github.com/MihailRis/voxelcore/commit/22e0c469c006217b82b1dcac9193cd38b8072cd2)
|
||||
- [fix unchecked indices buffer overflow](https://github.com/MihailRis/voxelcore/commit/336ae09f669fe734ac9a69ebcbb3550596f26a56)
|
||||
- [fix gui.show_input_dialog key:escape reaction](https://github.com/MihailRis/voxelcore/commit/1644751b1a32a3ecc2b4604e4a5a1cb00c7692bd)
|
||||
- [fix app.reset_content args](https://github.com/MihailRis/voxelcore/commit/43fa181398c6064fd165cd6244ed4847933cef4c)
|
||||
- [fix gfx.posteffects.set_intensity](https://github.com/MihailRis/voxelcore/commit/f171d3e30844c69a0675d23db583f34abdcd4f6c)
|
||||
- [fix blocks raycast filter](https://github.com/MihailRis/voxelcore/commit/ce769143f881afbaa1136ec6a0692ff2b4cc2bd4)
|
||||
- [fix conditional jump or move depends on uninitialised value in GLFWWindow](https://github.com/MihailRis/voxelcore/commit/e371153288c3eb99e568fe19fb725f151d6a58ac)
|
||||
- [fix debugging server creation](https://github.com/MihailRis/voxelcore/commit/72040b5dbb37c6588a53e6d7584f16e98ed0a8e2)
|
||||
- [fix on_blocks_tick interval](https://github.com/MihailRis/voxelcore/commit/cd43d9545a52ca153b7548585c65af8b98bbfc7f)
|
||||
- [fix: inventory interaction on "disablePlayerInventory = true"](https://github.com/MihailRis/voxelcore/commit/dba10805f8d98aedf6d7ab3f5f8d7ca5c2280e8e)
|
||||
- [fix: checkbox hover color](https://github.com/MihailRis/voxelcore/commit/76d5af85cc04b6560e7dde4cb9116b8d6d638036)
|
||||
- [fix a typo in the vector3:rot and duplicate vector2.\_\_eq](https://github.com/MihailRis/voxelcore/commit/334666a5615e0996fa036cc44ed94777aee76867)
|
||||
- [fix gfx.blockwraps.set_texture](https://github.com/MihailRis/voxelcore/commit/e423c746280c690ab26a217b1e8668253cdd1372)
|
||||
- [fix: chunk border wigth change when render block selection](https://github.com/MihailRis/voxelcore/commit/963e7d78f5f555940517e9afa4dccafbe7085d17)
|
||||
- [fix block model change wrapper reaction](https://github.com/MihailRis/voxelcore/commit/6d6d38c2180ae79d69498acdd3a525399579995a)
|
||||
- [fix: InventoryView: when moving one object with the right mouse button, the phantom remained](https://github.com/MihailRis/voxelcore/commit/c7da5fa5698113710dca986516372a483ebfa0c7)
|
||||
- [fix: integers signs are unspecified in binary_json_spec.md](https://github.com/MihailRis/voxelcore/commit/e5f9e4d02aba96678afac533be9679523487006b)
|
||||
- [fix fragment:place lights](https://github.com/MihailRis/voxelcore/commit/7a513949e94764797abd09410836f4475da8156a)
|
||||
- [fix: 'shadeless' block property ignored if custom model is used](https://github.com/MihailRis/voxelcore/commit/78062e2197be750d3a6fa87d44e8079286323cdd)
|
||||
- [fix custom model blocks lighting](https://github.com/MihailRis/voxelcore/commit/36f7fb759a6266edae91f2e2986882eba066bdaf)
|
||||
- [fix inventory.set](https://github.com/MihailRis/voxelcore/commit/c394df4e07641b9c18dc8a4ee1bcd1c519a82f66)
|
||||
- [fix fatal error on invalid item id in inventory](https://github.com/MihailRis/voxelcore/commit/180dd5051b5a7358200ae705fd20b632b0d96f72)
|
||||
- [fix on_block_tick timer](https://github.com/MihailRis/voxelcore/commit/77b4382577dc9cc3a21317190290e9019355ec9b)
|
||||
- [fix on_block_tick triggered while paused](https://github.com/MihailRis/voxelcore/commit/4d53eb97c359b7453209af91eedfe56b03042a6e)
|
||||
- [fix hover elements lifetime](https://github.com/MihailRis/voxelcore/commit/55e4e6de02e606b756dba57cefe2fdb3574c389d)
|
||||
- [fix shadeless blocks with soft lights disabled](https://github.com/MihailRis/voxelcore/commit/ea8e1301eadcc1298668bcc5d7c6d9893f916e1d)
|
||||
- [fix libpng error handling](https://github.com/MihailRis/voxelcore/commit/ba405ee6fc1541c2e84f62a6a047da711a313ff4)
|
||||
- [fix corrupted voxel reset](https://github.com/MihailRis/voxelcore/commit/e0b5c8457b93d2caa9d7959a28960cd456bbd61d)
|
||||
- [fix overriden content units scripts overriding](https://github.com/MihailRis/voxelcore/commit/719ba6e17a995d689e2c6e4845d920b6c42856c1)
|
||||
- [fix block ticks](https://github.com/MihailRis/voxelcore/commit/4a880177da63b282d0889493c4497bf81c4780ae)
|
||||
- [fix nil coords passed to on_block_tick](https://github.com/MihailRis/voxelcore/commit/ee21debe520a48759af9bbe2a27de148d91b371c)
|
||||
- [fix: incomplete size transform support by entities](https://github.com/MihailRis/voxelcore/commit/fefc975832685f1377736aefd8a048b1fd943130)
|
||||
- [fix exception if model having invalid variable texture passed to modelviewer](https://github.com/MihailRis/voxelcore/commit/1d56d83b72d59da34ceac5cc104ce3aa278dd299)
|
||||
- [fix canvas:set_data with table argument](https://github.com/MihailRis/voxelcore/commit/e678195a2ae3cfd1ddc39435dd103292806dd4bc)
|
||||
- [fix generated item's script](https://github.com/MihailRis/voxelcore/commit/4df4209bc59944e97102be7a618292378dc301a4)
|
||||
- [fix ui elements overriding](https://github.com/MihailRis/voxelcore/commit/c214d70f1d33785f9262c552a6f7b933b41e9125)
|
||||
- [fix: pack environment not passed to components](https://github.com/MihailRis/voxelcore/commit/69cf4c1c046281106571341702c48d74c27a3788)
|
||||
- [fix 'unexpected end' while parsing .obj](https://github.com/MihailRis/voxelcore/commit/31e7a4ebc0076b6fdb12f4775ffba0903a11ba4e)
|
||||
- [fix: bad_alloc if canvas element size is negative](https://github.com/MihailRis/voxelcore/commit/7c74eece99e1ec52e3022803975c92b951ec11c0)
|
||||
- [fix exception safety in util::stack_vector::push_back](https://github.com/MihailRis/voxelcore/commit/273682355a32827658568757a76830864249a12d)
|
||||
- [fix recursive iframe](https://github.com/MihailRis/voxelcore/commit/c3b50b5ab2ebc88719e25f8964d70a4f389e389f)
|
||||
- [fix infinite recursion on moveInto used to move to descendant node](https://github.com/MihailRis/voxelcore/commit/4f1411b005859a510fe8d8f1af8db9b848dd4454)
|
||||
- [fix camera exponentially shaking](https://github.com/MihailRis/voxelcore/commit/3de6d7f4025f310426a5111fa6ce047e190888f1)
|
||||
- [fix slow xml/vcm loading in Windows](https://github.com/MihailRis/voxelcore/pull/983)
|
||||
- [fix file.ext](https://github.com/MihailRis/voxelcore/commit/b9b17358a1576e740c4dcf7cf28e553b9d829db0)
|
||||
- [fix stack_vector](https://github.com/MihailRis/voxelcore/commit/1fbf16e3dcf145f322849b182be20bac1272a82b)
|
||||
- [fix audio.input.request_open](https://github.com/MihailRis/voxelcore/commit/8a19c903e44b7569a38e470ec7b260a03cd4d673)
|
||||
- [fix: block/item.properties not inheriting parent content unit properties](https://github.com/MihailRis/voxelcore/commit/a9d185256ae14789c17b005b27f7be94895f7dca)
|
||||
- [fix: player name 3d text not updating by Decorator](https://github.com/MihailRis/voxelcore/commit/33db2633a282a9ba532143e223e3ae8b4d12fc22)
|
||||
- [fix lua::toquat](https://github.com/MihailRis/voxelcore/commit/9d7e95db807f6210cd18e3e4b58d05eb5ab165d3)
|
||||
- [fix: destroyed skeleton config access on skeleton reload](https://github.com/MihailRis/voxelcore/commit/9893c09fd5459eda2f013b7603fd32db18e02b98)
|
||||
- [fix entity bounding box check on block place](https://github.com/MihailRis/voxelcore/commit/bb44b4186bd617281614c5f04329bd4221b08c0d)
|
||||
- [fix: cursor is not hidden in wayland if previously changed by glfwSetCursor](https://github.com/MihailRis/voxelcore/commit/6896fa433ca2a5f6bfd5205072edfaded7107a42)
|
||||
- [fix process_properties](https://github.com/MihailRis/voxelcore/commit/dde8c674b81835e6d7a6591bd0732a9c5c140be0)
|
||||
- [fix stringutil locale-related functions](https://github.com/MihailRis/voxelcore/commit/30177b9d2a3f87955005f39418dbcf8b1c76dfca)
|
||||
- [fix teleports loop on low obstacles](https://github.com/MihailRis/voxelcore/commit/e28af89de2ff4b79cbfc84515005fc3ae3074004)
|
||||
- [fix entity spawn/despawn](https://github.com/MihailRis/voxelcore/commit/2dd8024b7e0f82bfc79cd6e5e389c3dd6a5a700c)
|
||||
- [fix 3d text scaling in projected display mode](https://github.com/MihailRis/voxelcore/commit/736cdb0980f68f64e5b3c0135cf5962169c05349)
|
||||
- [fix audio.play type checks](https://github.com/MihailRis/voxelcore/commit/6daaa4895bee30e4a92b3e769116ec8e473f2728)
|
||||
- [fix app.reconfig_packs](https://github.com/MihailRis/voxelcore/commit/73837082c2f629614dd28e04880d9ca6f59908b1)
|
||||
- [fix skeletons behaviour in preload.json](https://github.com/MihailRis/voxelcore/commit/acff9454924f630fb69719f868e78bcf319956e4)
|
||||
- [fix LevelScreen::saveWorldPreview](https://github.com/MihailRis/voxelcore/commit/91b14f4264b57cda3779e991b426bf832fc1d9a7)
|
||||
- [fix core:player component mob.set_flight call](https://github.com/MihailRis/voxelcore/commit/66796019af77d33be0577bb7bf7a0f30307246e7)
|
||||
- [fix components parent environment](https://github.com/MihailRis/voxelcore/commit/dcaf87988bfac2b622eba4003ff7c52b41088601)
|
||||
- [fix utf8.sub behaviour](https://github.com/MihailRis/voxelcore/commit/31478977099e501752271094802a6f057eb4f01e)
|
||||
- [fix multiline textbox wrappping](https://github.com/MihailRis/voxelcore/commit/99c66c61bb4da0b8defc7aa3219088de32ae4fab)
|
||||
- [fix: manually changing textbox.caret does not reset selection](https://github.com/MihailRis/voxelcore/commit/843cc3769dffe1318b32a25f1dbeb8a0390a074d)
|
||||
- [fix tick intervals in headless mode](https://github.com/MihailRis/voxelcore/commit/0975fcd8193025c171acf0644babfb570e53c468)
|
||||
- [fix player ticks](https://github.com/MihailRis/voxelcore/commit/47f2bf75d79f73a28afd618f52509767c0876881)
|
||||
- [fix selection reset on end reached with shift pressed](https://github.com/MihailRis/voxelcore/commit/1d4abd7758db633fd389990ddd015f37c5803ed3)
|
||||
- [fix textbox scrolling](https://github.com/MihailRis/voxelcore/commit/bebb5049efaa8b242b3eba25eeb8227dfb06a161)
|
||||
- [fix lua syntax highlighting](https://github.com/MihailRis/voxelcore/commit/b307b5c93b6ab2d2102e81310e3441930f55e682)
|
||||
- [fix controls settings panel height](https://github.com/MihailRis/voxelcore/commit/c4bddba6b73a42b7ed1da4cbc81e4c79d48b7117)
|
||||
- [fix lua::bytearray_as_string](https://github.com/MihailRis/voxelcore/commit/3f81494d4b14f3a8d6be0f9e9a489f0d26c88e37)
|
||||
- [particles fix](https://github.com/MihailRis/voxelcore/commit/e6ac30143c8e0ade446d61b92119ebdecb616e28)
|
||||
- [blocks.fill fix](https://github.com/MihailRis/voxelcore/commit/31a90bd91172eb07923ea41c0ed18bdaee83f462)
|
||||
- [lighting fix](https://github.com/MihailRis/voxelcore/commit/0bbde3a778762f7f6740cd65b494824111313c2e)
|
||||
- [fix gui.load_document environment extension](https://github.com/MihailRis/voxelcore/commit/b1974405c69596edf0cfd4a4b5cd42ba0d65448e)
|
||||
- [fix serialization error for specific types](https://github.com/MihailRis/voxelcore/commit/2f729bd3cbb793f20c5e060a75e38a18d0d88d0f)
|
||||
- [fix vcm texture sides](https://github.com/MihailRis/voxelcore/commit/38bebac37ee2a290315c3148576e98c825efa46d)
|
||||
- [fix post-runnable context in content-related functions](https://github.com/MihailRis/voxelcore/commit/0ffefddee1781389fc6e8014ea00856e09cfff1d)
|
||||
- [fix: app.reconfig_packs attempts to remove indices in generator test mode](https://github.com/MihailRis/voxelcore/commit/ce189c810d13512225b82933724603781a1ecef1)
|
||||
- [fix: duplicating core:chat event handlers in in-game chat](https://github.com/MihailRis/voxelcore/commit/52829023c2718876ce97bc91345b3cadfdd7d10e)
|
||||
- [fix document events & breaking: document events removed from 'events' library temporary](https://github.com/MihailRis/voxelcore/commit/089bcbbb64b8009db03fb9b6ed04c491e46d6933)
|
||||
- [fix uinode.parent property](https://github.com/MihailRis/voxelcore/commit/902c885fe0d72cbe5bd2ea9a95d4551516197d4a)
|
||||
- [fix ui elements related things](https://github.com/MihailRis/voxelcore/commit/84b2aef81f82d46b07d9bd059540d7ac90cae3ec)
|
||||
- [fix segfault on world.get_chunk_data if no world open](https://github.com/MihailRis/voxelcore/commit/4a11dd28ec9b7a0344c21a6fc4c3ab80c429eb50)
|
||||
- [fix ceiling collision](https://github.com/MihailRis/voxelcore/commit/625a5caeccbce1d06a0ad1c743e56995d9b42343)
|
||||
- [fix of io_stream:read_fully for binary and yield mode](https://github.com/MihailRis/voxelcore/commit/fdec2d722d2b81e7bdbdfec2209a9df28d10dde0)
|
||||
- [fix of io_stream:available for non-buffered streams when "length" arg defined](https://github.com/MihailRis/voxelcore/commit/cd040cfeb47f91b29c6d138f745b442483f4cf44)
|
||||
- [fix dead skeleton model references](https://github.com/MihailRis/voxelcore/commit/9d3a60328f7a44e0361a31e2e8c5b9079282810b)
|
||||
- [fix maths_inline version of mat4.rotate](https://github.com/MihailRis/voxelcore/commit/87310dd38f848ca059b627fc0b6d1d2503d05071)
|
||||
- [fix BasicParser power function](https://github.com/MihailRis/voxelcore/commit/c45d994216e57811b36d9463fab7ad2c7cc051c0)
|
||||
- [fix exponential notation parsing (](https://github.com/MihailRis/voxelcore/commit/b024b6cddfcee9bc436d8260cdb3f1647087af96 "fix exponential notation parsing (#857)")[#857](https://github.com/MihailRis/voxelcore/pull/857)[)](https://github.com/MihailRis/voxelcore/commit/b024b6cddfcee9bc436d8260cdb3f1647087af96)
|
||||
- [fix graphics settings & reduce extra GL calls](https://github.com/MihailRis/voxelcore/commit/5b868ae857b1b425a4f529c663b3dad55fcbf59a)
|
||||
- [fix integer raycast filters & add simple raycast test](https://github.com/MihailRis/voxelcore/commit/39a42365534ebd4c4c0be690e9ea0646e1459a7b)
|
||||
- [fix canvas:encode produces flipped images for png](https://github.com/MihailRis/voxelcore/commit/279fb92b94a0f8b8d28ed141b54b160450ec91f7)
|
||||
- [fix canvas:line lines clipping](https://github.com/MihailRis/voxelcore/commit/a5596ed5cd65bc62b983ec9dff3263beeced2dd7)
|
||||
- [fix newly created raycast bug](https://github.com/MihailRis/voxelcore/commit/46b4aab6dce9e7c195b5c29584168f8e5b8fbb52)
|
||||
- [fix Skeleton::setConfig](https://github.com/MihailRis/voxelcore/commit/a0b7e81a94d8a4f2750fbbd507ba6bd2e688f8b4)
|
||||
- [fix audio input device settings](https://github.com/MihailRis/voxelcore/commit/a99c6aa8e08d440d9b049007747ac769c2fff431)
|
||||
- [fix: missing font usage produces fatal error](https://github.com/MihailRis/voxelcore/commit/420d0daf28853e1db1a985f9a74ec38f3d978ddc)
|
||||
- [fix texture-faces reading](https://github.com/MihailRis/voxelcore/commit/d3eb7a10bea6825c0ff2da9f459a1b528a6a410f)
|
||||
- [fix the margin](https://github.com/MihailRis/voxelcore/commit/86fdcb289b1cfa510c861c677731599b4f0f0519)
|
||||
- [fix components order & add skeleton:get_matrix overload & add skeleton:reset_pose](https://github.com/MihailRis/voxelcore/commit/8242d299ed68c8f27e691e464562e43c936788da)
|
||||
- [fix user component initialization exception handling & fix fatal error on uninitialized component access](https://github.com/MihailRis/voxelcore/commit/28385f236c3e3d2ccf020b116f08a8f6d33ec1a3)
|
||||
- [fix projected 3d text for non-monospace fonts](https://github.com/MihailRis/voxelcore/commit/4837e1de027e738bd59c4ba9c91b654e5d866f9a)
|
||||
- [fix custom model blocks render (with some conditions)](https://github.com/MihailRis/voxelcore/commit/e0be7a8d8c9f8d54d7af1b6b976fefc941ebba1f)
|
||||
- [fix 3d texts antialiasing render issue](https://github.com/MihailRis/voxelcore/commit/40e73ca34b14939468f64a5d349a98400e704bbb)
|
||||
- [fixing errors in rules.lua](https://github.com/MihailRis/voxelcore/commit/81af4b9e2acba5d67b5bacdb343618c686dd9d5f)
|
||||
- [fix block.index() calls in grass_block.lua and export base:util.calc_loot()](https://github.com/MihailRis/voxelcore/commit/2eae8f6f275e7a41ac30309e61f8d22d8a644ac7)
|
||||
- [fix fix lua version comparision](https://github.com/MihailRis/voxelcore/commit/4be73acc61f6805c9df2743e68a86ee646d43e25)
|
||||
- [fix lua version compare](https://github.com/MihailRis/voxelcore/commit/9444dc0c4596bd0c1fd2710488c8d412da8aab1f)
|
||||
- [fix zIndex type in docs](https://github.com/MihailRis/voxelcore/commit/c445f1a68f9bc1c9c9877cd91d010a1dd5240f0d)
|
||||
- [fix double click behaviour](https://github.com/MihailRis/voxelcore/commit/9ea50148b8a02a74befbcbc618a6a7dca7643316)
|
||||
- [fix horizontal panel behaviour](https://github.com/MihailRis/voxelcore/commit/2448869bf922a5773dbfd420a0a0e2cb151b0712)
|
||||
- [fix: stdcomp calling non-component global functions](https://github.com/MihailRis/voxelcore/commit/64a5a74f53722aa0db17b47bd0aa9fce106a661c)
|
||||
- [fix missing keys support](https://github.com/MihailRis/voxelcore/commit/df67236adbb9c29eddb3ec5a455dd61fb03c0a16)
|
||||
- [fix: temporary focus fix](https://github.com/MihailRis/voxelcore/commit/9fa6070cced55583ff6e0eaa654e4ca5b5495c32)
|
||||
- [fix rivers in base:demo](https://github.com/MihailRis/voxelcore/commit/75cd9aeefb2cccb544e0169063908760977d6615)
|
||||
- [fix gui.ask](https://github.com/MihailRis/voxelcore/commit/dd7e01488f3cbc4b2df58a945027ac3a9ea35eac)
|
||||
- [fix 3d text render](https://github.com/MihailRis/voxelcore/commit/717d41e7a544d657ae8b27397b5c5dbd9fb50b80)
|
||||
- [fix skeleton:get_model](https://github.com/MihailRis/voxelcore/commit/a73c181b0173b4d1c61159e03407cb5f3b3eb3bd)
|
||||
- [fix iframe.src = ""](https://github.com/MihailRis/voxelcore/commit/e2a65412bc6d49b0b2d264b11cd8df2e2c4e1d8f)
|
||||
- [fix blank texture overwritten by screen frame output](https://github.com/MihailRis/voxelcore/commit/fa0f87349b5c61ee0ca43d7d6b5b64237c39a6a4)
|
||||
- [fix stairs model](https://github.com/MihailRis/voxelcore/commit/423685139fe83bb2e571fbdfa41327ce61a64dd0)
|
||||
- [fix custom models solidity detection](https://github.com/MihailRis/voxelcore/commit/02dbd01e73f2c69168a1ba4c1929c9d5be263718)
|
||||
- [fix default vcm aabb uv generation](https://github.com/MihailRis/voxelcore/commit/693befcde8d6a4dddfc9049d74d303b027953b25)
|
||||
- [fix panel extra interval at end](https://github.com/MihailRis/voxelcore/commit/bd4d5f0e4bc8dd1d9652cde42b3c2b13a9924be4)
|
||||
- [fix xml escapes in attribute values](https://github.com/MihailRis/voxelcore/commit/fc8065e5505654906e59d744ba636753d79e0210)
|
||||
- [fix Texture::reload](https://github.com/MihailRis/voxelcore/commit/f2018334cb97c7b9a8187eb4e155dbda97b0b1cb)
|
||||
- [fix side collision](https://github.com/MihailRis/voxelcore/commit/78e27c812a87c8ee2cec1d6605049b9f8535ef2d)
|
||||
- [fix WorldConverter::createBlockFieldsConvertTasks](https://github.com/MihailRis/voxelcore/commit/fbe992755e70a3b4d321dc7d17981aec512bf0c1)
|
||||
- [fix heightmap noise multiplier argument](https://github.com/MihailRis/voxelcore/commit/95b9b346ac16a50d3c72423503f579d3d712c392)
|
||||
- [fix blocks render at the top of the world](https://github.com/MihailRis/voxelcore/commit/8214f1bd096ca3682212ac57648017ab8179948f)
|
||||
- [fix containers scroll](https://github.com/MihailRis/voxelcore/commit/bf50c37b823cab0a5bc20d8877ae4b5c23eee697)
|
||||
- [fix typos in comments and log messages](https://github.com/MihailRis/voxelcore/commit/515e27b402fd09a33d0e9800792e15f1f6caa7f8)
|
||||
- [fix models load functions](https://github.com/MihailRis/voxelcore/commit/395dc15fb6460d5e50c3e613cb1ea46d3332580c)
|
||||
- [fix rig:set_matrix for nil index](https://github.com/MihailRis/voxelcore/commit/4370eedc0a4324de15916f1a7890295133aa75c3)
|
||||
- [fix maths_inline mat4.idt(dst)](https://github.com/MihailRis/voxelcore/commit/32876aa9e461afb687ddb1f94a8672bd81543018)
|
||||
- [fixed packages for arch distro](https://github.com/MihailRis/voxelcore/commit/05cea922eb334607a2ffbb9229b9f22bf6b2dc74)
|
||||
- [fix weather effects render](https://github.com/MihailRis/voxelcore/commit/9989f8119601b6f8d21eaccc7c554253a5cd5667)
|
||||
- [fix missing textures load request for vcm](https://github.com/MihailRis/voxelcore/commit/41713e89a4f2a8d83d7dc62f8d25b7e23653c8ca)
|
||||
- [fix: block fields not inherited](https://github.com/MihailRis/voxelcore/commit/7d0f714cf232809f609862c3a2b793ae84012e5e)
|
||||
- [fix: validate content pack dependency versions](https://github.com/MihailRis/voxelcore/commit/28b849229c7bd7d52c25aa1f009ff1d342f3f423)
|
||||
- [fix custom model blocks with disabled ambient-occlusion](https://github.com/MihailRis/voxelcore/commit/56d2ab9f1466b781a45e17298c3b4907c70a40bc)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
project(VoxelEngine)
|
||||
project(VoxelCore)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
|
@ -27,23 +27,23 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_executable(VoxelEngine src/main.cpp)
|
||||
add_executable(VoxelCore src/main.cpp)
|
||||
|
||||
if(VOXELENGINE_BUILD_APPDIR)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake)
|
||||
endif()
|
||||
|
||||
target_link_libraries(VoxelEngine PRIVATE VoxelEngineSrc
|
||||
target_link_libraries(VoxelCore PRIVATE VoxelCoreSrc
|
||||
$<$<PLATFORM_ID:Windows>:winmm>)
|
||||
|
||||
target_link_options(VoxelEngine PRIVATE $<$<CXX_COMPILER_ID:GNU>:-no-pie>)
|
||||
target_link_options(VoxelCore PRIVATE $<$<CXX_COMPILER_ID:GNU>:-no-pie>)
|
||||
|
||||
# Deploy res to build dir
|
||||
add_custom_command(
|
||||
TARGET VoxelEngine
|
||||
TARGET VoxelCore
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/res $<TARGET_FILE_DIR:VoxelEngine>/res)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/res $<TARGET_FILE_DIR:VoxelCore>/res)
|
||||
|
||||
if(VOXELENGINE_BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
|
|
|||
|
|
@ -2,19 +2,36 @@
|
|||
"version": 6,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default-vs-msvc-windows",
|
||||
"name": "windows-msvc-base",
|
||||
"hidden": true,
|
||||
"condition": {
|
||||
"type": "equals",
|
||||
"rhs": "${hostSystemName}",
|
||||
"lhs": "Windows"
|
||||
},
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||
"VOXELENGINE_BUILD_TESTS": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "default-vs-msvc-windows",
|
||||
"displayName": "Visual Studio (auto: latest installed)",
|
||||
"inherits": "windows-msvc-base"
|
||||
},
|
||||
{
|
||||
"name": "vs2022",
|
||||
"displayName": "Visual Studio 2022",
|
||||
"inherits": "windows-msvc-base",
|
||||
"generator": "Visual Studio 17 2022"
|
||||
},
|
||||
{
|
||||
"name": "vs2026",
|
||||
"displayName": "Visual Studio 2026",
|
||||
"inherits": "windows-msvc-base",
|
||||
"generator": "Visual Studio 18 2026"
|
||||
},
|
||||
{
|
||||
"name": "default-ninja-mingw-windows",
|
||||
"condition": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Build docker container: docker build -t voxelcore .
|
||||
# Build project: docker run --rm -it -v$(pwd):/project voxelcore bash -c "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -Bbuild && cmake --build build"
|
||||
# Run project in docker: docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxelcore ./build/VoxelEngine
|
||||
# Run project in docker: docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxelcore ./build/VoxelCore
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
LABEL Description="Docker container for building VoxelCore for Linux"
|
||||
|
|
|
|||
373
LICENSE
Normal file
373
LICENSE
Normal file
|
|
@ -0,0 +1,373 @@
|
|||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
||||
14
README.md
14
README.md
|
|
@ -3,7 +3,7 @@
|
|||
## Latest release
|
||||
|
||||
- [Download](https://github.com/MihailRis/VoxelCore/releases/latest) | [Скачать](https://github.com/MihailRis/VoxelCore/releases/latest)
|
||||
- [Documentation](https://github.com/MihailRis/VoxelCore/blob/release-0.31/doc/en/main-page.md) | [Документация](https://github.com/MihailRis/VoxelCore/blob/release-0.31/doc/ru/main-page.md)
|
||||
- [Documentation](https://github.com/MihailRis/VoxelCore/blob/release-0.32/doc/en/main-page.md) | [Документация](https://github.com/MihailRis/VoxelCore/blob/release-0.32/doc/ru/main-page.md)
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -30,13 +30,13 @@ sudo make install
|
|||
|
||||
```sh
|
||||
su -
|
||||
apt-get install entt-devel libglfw3-devel libGLEW-devel libglm-devel libpng-devel libvorbis-devel libopenal-devel libluajit-devel libstdc++13-devel-static libcurl-devel libfreetype-devel
|
||||
apt-get install entt-devel libglfw3-devel libGLEW-devel libglm-devel libpng-devel libvorbis-devel libopenal-devel libluajit-devel libstdc++13-devel-static libcurl-devel libfreetype-devel libssl-devel
|
||||
```
|
||||
|
||||
#### Debian based distros
|
||||
|
||||
```sh
|
||||
sudo apt install libglfw3 libglfw3-dev libglew-dev libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev libvorbis-dev libcurl4-openssl-dev libfreetype6-dev
|
||||
sudo apt install libglfw3 libglfw3-dev libglew-dev libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev libvorbis-dev libcurl4-openssl-dev libssl-dev libfreetype6-dev
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
|
|
@ -50,13 +50,13 @@ sudo apt install libglfw3 libglfw3-dev libglew-dev libglm-dev libpng-dev libopen
|
|||
#### RHEL based distros
|
||||
|
||||
```sh
|
||||
sudo dnf install glfw-devel glew-devel glm-devel libpng-devel libvorbis-devel openal-soft-devel luajit-devel libcurl-devel libfreetype-devel
|
||||
sudo dnf install glfw-devel glew-devel glm-devel libpng-devel libvorbis-devel openal-soft-devel luajit-devel libcurl-devel libfreetype-devel openssl-devel
|
||||
```
|
||||
|
||||
#### Arch based distros
|
||||
|
||||
```sh
|
||||
sudo pacman -S glfw glew glm libpng libvorbis openal luajit curl freetype2
|
||||
sudo pacman -S glfw glew glm libpng libvorbis openal luajit curl freetype2 openssl
|
||||
```
|
||||
|
||||
### Building engine with CMake
|
||||
|
|
@ -188,7 +188,7 @@ docker run --rm -it \
|
|||
-v "$XAUTHORITY:/home/user/.Xauthority:ro" \
|
||||
-e DISPLAY="$DISPLAY" \
|
||||
--network=host \
|
||||
voxel-engine ./build/VoxelEngine
|
||||
voxel-engine ./build/VoxelCore
|
||||
```
|
||||
|
||||
### On Windows
|
||||
|
|
@ -218,5 +218,5 @@ docker run --rm -it -v "${PWD}:/project" voxel-engine bash -c "cmake -DCMAKE_BUI
|
|||
#### Step 4. Run the application
|
||||
|
||||
```powershell
|
||||
docker run --rm -it -v "${PWD}:/project" -e DISPLAY=host.docker.internal:0.0 --network=host voxel-engine ./build/VoxelEngine
|
||||
docker run --rm -it -v "${PWD}:/project" -e DISPLAY=host.docker.internal:0.0 --network=host voxel-engine ./build/VoxelCore
|
||||
```
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ AppDir:
|
|||
name: VoxelCore
|
||||
icon: VoxelCore
|
||||
version: latest
|
||||
exec: usr/bin/VoxelEngine
|
||||
exec: usr/bin/VoxelCore
|
||||
exec_args: --dir $HOME/.config/voxelcore --res $APPDIR/usr/share/VoxelCore/res $@
|
||||
apt:
|
||||
arch: amd64
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Version=1.0
|
|||
Type=Application
|
||||
Name=VoxelCore
|
||||
Comment=Minecraft-like game engine in C++ with OpenGL
|
||||
TryExec=VoxelEngine
|
||||
Exec=VoxelEngine
|
||||
TryExec=VoxelCore
|
||||
Exec=VoxelCore
|
||||
Icon=VoxelCore
|
||||
MimeType=image/x-foo;
|
||||
Categories=Game;
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.desktop DESTINATION ${CMAKE_
|
|||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
|
||||
install(TARGETS VoxelEngine DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
|
||||
install(TARGETS VoxelCore DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
debug.log("file extension")
|
||||
asserts.equals(nil, file.ext("config:test"))
|
||||
asserts.equals("cfg", file.ext("config:test.cfg"))
|
||||
asserts.equals("gz", file.ext("config:test.cfg.gz"))
|
||||
asserts.equals("config:test.cfg", file.remove_ext("config:test.cfg.gz"))
|
||||
|
||||
debug.log("check initial state")
|
||||
assert(file.exists("config:"))
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,17 @@ assert(entries[1] == "memtest:dir/subdir/a.txt")
|
|||
assert(entries[2] == "memtest:dir/subdir/b.txt")
|
||||
assert(entries[3] == "memtest:dir/subdir/other")
|
||||
|
||||
debug.log("create sibling directory")
|
||||
file.mkdir("memtest:dir/subdir/sibling")
|
||||
assert(file.isfile("memtest:dir/subdir/a.txt"))
|
||||
assert(file.isdir("memtest:dir/subdir/other"))
|
||||
asserts.equals(4, #file.list("memtest:dir/subdir"))
|
||||
|
||||
debug.log("overwrite file")
|
||||
file.write("memtest:dir/subdir/a.txt", "overwritten")
|
||||
asserts.equals("overwritten", file.read("memtest:dir/subdir/a.txt"))
|
||||
asserts.equals(4, #file.list("memtest:dir/subdir"))
|
||||
|
||||
debug.log("remove tree")
|
||||
file.remove_tree("memtest:dir")
|
||||
assert(not file.isdir("memtest:dir"))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
local response_received = false
|
||||
|
||||
network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s)
|
||||
network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s)
|
||||
print(json.parse(s).name)
|
||||
response_received = true
|
||||
end, function (code)
|
||||
|
|
|
|||
33
dev/tests/parsing.lua
Normal file
33
dev/tests/parsing.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
local src = "<test><sub>test</sub></test>"
|
||||
local parsed = xml.parse(src)
|
||||
asserts.equals(src, xml.tostring(parsed, false))
|
||||
|
||||
local src = "{\"test\": \"test\", \"sub\": {\"test\": \"test\"}}"
|
||||
local parsed = json.parse(src)
|
||||
asserts.equals("test", parsed.test)
|
||||
asserts.equals("test", parsed.sub.test)
|
||||
|
||||
-- toml
|
||||
local src = [[
|
||||
[section]
|
||||
key = "value"
|
||||
# comment
|
||||
key2 = "other value"
|
||||
number = 42
|
||||
pi = 3.14159
|
||||
enabled = true
|
||||
items = ["a", "b", "c"]
|
||||
table = { x = 1, y = 2 }
|
||||
]]
|
||||
local parsed = toml.parse(src)
|
||||
|
||||
asserts.equals("value", parsed.section.key)
|
||||
asserts.equals("other value", parsed.section.key2)
|
||||
asserts.equals(42, parsed.section.number)
|
||||
asserts.equals(3.14159, parsed.section.pi)
|
||||
asserts.equals(true, parsed.section.enabled)
|
||||
asserts.equals("a", parsed.section.items[1])
|
||||
asserts.equals("b", parsed.section.items[2])
|
||||
asserts.equals("c", parsed.section.items[3])
|
||||
asserts.equals(1, parsed.section.table.x)
|
||||
asserts.equals(2, parsed.section.table.y)
|
||||
33
dev/tests/reload_module.lua
Normal file
33
dev/tests/reload_module.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
-- reload_module must run the module in its pack environment, as require does
|
||||
local util = require "core:tests_util"
|
||||
util.create_demo_world()
|
||||
|
||||
-- a pack with a module that uses pack environment (PACK_ID)
|
||||
local PACK = "world:content/reload_test"
|
||||
file.mkdirs(PACK .. "/modules")
|
||||
file.write(PACK .. "/package.json", json.tostring({id="reload_test", title="reload_test"}))
|
||||
|
||||
local function write_module(version)
|
||||
file.write(PACK .. "/modules/mod.lua", string.format([[
|
||||
local this = {}
|
||||
function this.info() return PACK_ID, %d end
|
||||
return this
|
||||
]], version))
|
||||
end
|
||||
|
||||
write_module(1)
|
||||
app.reconfig_packs({"reload_test"}, {})
|
||||
app.tick()
|
||||
|
||||
local mod = require "reload_test:mod"
|
||||
local packid, version = mod.info()
|
||||
assert(packid == "reload_test" and version == 1)
|
||||
|
||||
write_module(2)
|
||||
reload_module("reload_test:mod")
|
||||
packid, version = mod.info()
|
||||
assert(version == 2, "module is not reloaded")
|
||||
assert(packid == "reload_test", "reloaded module has no pack environment")
|
||||
|
||||
app.close_world(true)
|
||||
app.delete_world("demo")
|
||||
119
dev/tests/zip_files.lua
Normal file
119
dev/tests/zip_files.lua
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
local function sorted_list(path)
|
||||
local entries = file.list(path)
|
||||
table.sort(entries)
|
||||
return entries
|
||||
end
|
||||
|
||||
local function check_list(expected, path)
|
||||
local entries = sorted_list(path)
|
||||
asserts.equals(#expected, #entries)
|
||||
for i, name in ipairs(expected) do
|
||||
asserts.equals(name, entries[i])
|
||||
end
|
||||
end
|
||||
|
||||
local function join(root, name)
|
||||
if root:sub(-1) == ":" then
|
||||
return root..name
|
||||
end
|
||||
return root.."/"..name
|
||||
end
|
||||
|
||||
local bytes = {0xDE, 0xAD, 0x00, 0xC0, 0xDE}
|
||||
|
||||
local function create_tree(root)
|
||||
file.mkdirs(join(root, "sub/deep"))
|
||||
file.mkdir(join(root, "empty"))
|
||||
file.write(join(root, "root.txt"), "root file")
|
||||
file.write(join(root, "sub/a.txt"), "example, пример")
|
||||
file.write_bytes(join(root, "sub/deep/binary"), bytes)
|
||||
end
|
||||
|
||||
local function check_tree(m)
|
||||
debug.log("check directories")
|
||||
assert(file.exists(m..":"))
|
||||
assert(file.isdir(m..":"))
|
||||
assert(file.isdir(m..":sub"))
|
||||
assert(file.isdir(m..":sub/deep"))
|
||||
assert(file.isdir(m..":empty"))
|
||||
assert(not file.isfile(m..":sub"))
|
||||
|
||||
debug.log("check files")
|
||||
assert(file.isfile(m..":root.txt"))
|
||||
assert(file.isfile(m..":sub/a.txt"))
|
||||
assert(not file.isdir(m..":sub/a.txt"))
|
||||
assert(not file.exists(m..":missing.txt"))
|
||||
assert(not file.exists(m..":sub/missing.txt"))
|
||||
|
||||
debug.log("read files")
|
||||
asserts.equals("root file", file.read(m..":root.txt"))
|
||||
asserts.equals("example, пример", file.read(m..":sub/a.txt"))
|
||||
asserts.equals(#"root file", file.length(m..":root.txt"))
|
||||
|
||||
local rbytes = file.read_bytes(m..":sub/deep/binary")
|
||||
asserts.equals(#bytes, #rbytes)
|
||||
for i, b in ipairs(bytes) do
|
||||
asserts.equals(b, rbytes[i])
|
||||
end
|
||||
|
||||
debug.log("read file with io_stream")
|
||||
local stream = file.open(m..":root.txt", "r")
|
||||
asserts.equals("root file", stream:read_line())
|
||||
stream:close()
|
||||
|
||||
debug.log("list directories")
|
||||
check_list({m..":empty", m..":root.txt", m..":sub"}, m..":")
|
||||
check_list({m..":sub/a.txt", m..":sub/deep"}, m..":sub")
|
||||
check_list({m..":sub/deep/binary"}, m..":sub/deep")
|
||||
check_list({}, m..":empty")
|
||||
|
||||
debug.log("check read-only")
|
||||
assert(not file.is_writeable(m..":"))
|
||||
assert(not pcall(file.write, m..":new.txt", "text"))
|
||||
local ok, created = pcall(file.mkdir, m..":newdir")
|
||||
assert(not (ok and created))
|
||||
assert(not file.exists(m..":newdir"))
|
||||
end
|
||||
|
||||
local function check_zip(src, zipfile)
|
||||
debug.log("create zip "..zipfile.." from "..src)
|
||||
file.create_zip(src, zipfile)
|
||||
assert(file.isfile(zipfile))
|
||||
|
||||
debug.log("mount "..zipfile)
|
||||
local m = file.mount(zipfile)
|
||||
check_tree(m)
|
||||
|
||||
debug.log("unmount "..m)
|
||||
file.unmount(m)
|
||||
assert(not file.exists(m..":"))
|
||||
assert(not pcall(file.read, m..":root.txt"))
|
||||
assert(not pcall(file.unmount, m))
|
||||
end
|
||||
|
||||
local mem = file.create_memory_device()
|
||||
local out = file.create_memory_device()
|
||||
|
||||
debug.log("zip memory device root")
|
||||
create_tree(mem..":")
|
||||
check_zip(mem..":", out..":root.zip")
|
||||
|
||||
debug.log("zip memory device subdirectory")
|
||||
create_tree(mem..":pack")
|
||||
check_zip(mem..":pack", out..":pack.zip")
|
||||
|
||||
debug.log("zip nested subdirectory")
|
||||
create_tree(mem..":a/b/pack")
|
||||
check_zip(mem..":a/b/pack", out..":nested.zip")
|
||||
|
||||
debug.log("zip real filesystem directory")
|
||||
if file.exists("config:ziptest") then
|
||||
file.remove_tree("config:ziptest")
|
||||
end
|
||||
create_tree("config:ziptest/pack")
|
||||
check_zip("config:ziptest/pack", "config:ziptest/pack.zip")
|
||||
file.remove_tree("config:ziptest")
|
||||
|
||||
debug.log("mount non-zip file")
|
||||
file.write(out..":text.txt", "not an archive")
|
||||
assert(not pcall(file.mount, out..":text.txt"))
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
# Documentation
|
||||
|
||||
> [!WARNING]
|
||||
> Version is in development. Proceed to [Documentation for 0.31.](https://github.com/MihailRis/voxelcore/blob/release-0.31/doc/en/main-page.md)
|
||||
|
||||
## Sections
|
||||
|
||||
- [Assets preloading](assets-preload.md)
|
||||
|
|
@ -20,5 +17,6 @@
|
|||
- [Scripting](scripting.md)
|
||||
- [Text styles](text-styles.md)
|
||||
- [VCM models format](vcm.md)
|
||||
- [VCM animation format](vca.md)
|
||||
- [World generator engine](world-generator.md)
|
||||
- [XML UI building](xml-ui-layouts.md)
|
||||
|
|
|
|||
|
|
@ -163,6 +163,12 @@ file.ext(path: str) --> str
|
|||
|
||||
Extracts the extension from the path. Example: `world:data/base/config.toml` -> `toml`.
|
||||
|
||||
```lua
|
||||
file.remove_ext(path: string) -> string
|
||||
```
|
||||
|
||||
Returns the path without the extension. Example: `world:data/base/config.toml` -> `world:data/base/config`.
|
||||
|
||||
```lua
|
||||
file.prefix(path: str) --> str
|
||||
```
|
||||
|
|
|
|||
|
|
@ -41,8 +41,14 @@ skeleton:is_visible([optional] index: int) -> bool
|
|||
skeleton:set_visible([optional] index: int, status: bool)
|
||||
|
||||
-- Returns the color of the entity
|
||||
skeleton:get_color() -> vec3
|
||||
skeleton:get_color() -> vec4
|
||||
|
||||
-- Returns the color of the bone
|
||||
skeleton:get_color(index: int) -> vec4
|
||||
|
||||
-- Sets the color of the entity
|
||||
skeleton:set_color(color: vec3)
|
||||
skeleton:set_color(color: vec4)
|
||||
|
||||
-- Sets the color of the bone
|
||||
skeleton:set_color(color: vec4, bone: int)
|
||||
```
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ network.get(
|
|||
)
|
||||
|
||||
-- Example:
|
||||
network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s)
|
||||
network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s)
|
||||
print(json.parse(s).name) -- will output the name of the latest engine release
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -185,9 +185,11 @@ rig:index(name: str) -> int
|
|||
-- or the skeleton if no index is specified
|
||||
rig:is_visible([optional] index: int) -> bool
|
||||
|
||||
-- Sets the visibility status of the skeleton
|
||||
rig:set_visible(status: bool)
|
||||
|
||||
-- Sets the visibility status of a bone by index
|
||||
-- or the skeleton if no index is specified
|
||||
rig:set_visible([optional] index: int, status: bool)
|
||||
rig:set_visible(index: int, status: bool)
|
||||
|
||||
-- Returns the color of the entity
|
||||
rig:get_color() -> vec4
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ packid.binding.name="inputtype:codename"
|
|||
- a..z
|
||||
- 0..9
|
||||
- f1..f25
|
||||
- grave-accent, minus, equal, left-bracket, right-bracket, backslash
|
||||
- semicolon, apostrophe, comma, period, slash
|
||||
|
||||
## *input* library
|
||||
|
||||
|
|
|
|||
141
doc/en/vca.md
Normal file
141
doc/en/vca.md
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
# VCA
|
||||
|
||||
A text-based animation format that uses [VCM](vcm.md) syntax.
|
||||
|
||||
A VCA file consists of a set of directives. The order of the directives does not affect the order in which transformations are applied.
|
||||
|
||||
Directives are applied to the given target, which can be an entity skeleton or a camera.
|
||||
When targeting a skeleton, the directive specifies the bone name via the `bone` attribute:
|
||||
|
||||
```vcd
|
||||
@move bone bone_name ...
|
||||
```
|
||||
|
||||
Each directive controls a single scalar value, such as x, y, z, etc., specified via the `by` attribute:
|
||||
|
||||
```vcd
|
||||
@move bone hand by y ...
|
||||
```
|
||||
|
||||
Two kinds of curve definitions are currently available, each producing a value `f(t) = x`, where t is time:
|
||||
- [keyframe curves (curve)](#keyframe-curves)
|
||||
- [expression curves (func)](#expression-curves)
|
||||
|
||||
## Animation directives
|
||||
|
||||
- `@move` - translates an object/bone
|
||||
- `@rotate` - rotates an object/bone
|
||||
- `@scale` - scales an object/bone (multiplier)
|
||||
- `@zoom` - camera zoom (multiplier)
|
||||
- `@texture` - change of a dynamically assigned texture (see [skeleton:set_texture](scripting/ecs.md#skeleton))
|
||||
|
||||
## Metadata
|
||||
|
||||
Animation metadata is set in the file via the `configure` directive:
|
||||
- `fps` - frame rate, used as the divisor when calculating duration
|
||||
- `frames` - number of animation frames, used as the dividend when calculating duration
|
||||
- `duration` - explicitly specified duration in seconds (requires `fps` to be specified when keyframes are present)
|
||||
- `rotation-order` - specifies the order in which Euler angles are applied during rotation (since the format does not take directive order into account). Examples: XYZ, ZYX, YZX.
|
||||
|
||||
Metadata applies globally. Its behavior does not depend on its position in the file, but placing it at the beginning is recommended.
|
||||
|
||||
## Additional
|
||||
|
||||
- `curve` - declares a custom curve type. Specify the curve name `name` and the value expression `func`.
|
||||
|
||||
Two keys, `kl` and `kr`, and the value `t` in the range [0..1] are available in the expression.
|
||||
|
||||
Example:
|
||||
|
||||
`@curve test-linear func (kl.value + (kr.value - kl.value) * t)`
|
||||
|
||||
Custom curves are referenced with a `.` prefix. Example: `@move by y curve .test-linear {...}`.
|
||||
|
||||
## Keyframe curves
|
||||
|
||||
The curve type must be specified via the `curve` attribute:
|
||||
- `const` - values are not interpolated; they switch when a keyframe is reached
|
||||
- `linear` - a polyline; linear interpolation is used
|
||||
- `bezier` - Bézier curve keyframes with explicitly specified left and right tangents (lx, ly, rx, ry)
|
||||
|
||||
Keyframes are described in the following `{...}` block as ordered `@key` directives:
|
||||
|
||||
```vcd
|
||||
@rotate by z curve linear {
|
||||
@key ...
|
||||
@key ...
|
||||
}
|
||||
```
|
||||
|
||||
A keyframe must contain a frame number `frame` and a value `value`. For `bezier` keyframes, the tangents are also specified.
|
||||
|
||||
Example for `curve bezier`:
|
||||
```vcd
|
||||
@key frame 138 value 53.00411 lx 127.067 ly 53.00411 rx 138.001 ry 53.00411
|
||||
```
|
||||
|
||||
For the `texture` directive, it is simpler. Example:
|
||||
|
||||
```vcd
|
||||
@texture name $0 {
|
||||
@key frame 0 value entities/tireman:face_0
|
||||
@key frame 24 value entities/tireman:face_1
|
||||
}
|
||||
```
|
||||
|
||||
> Here, `entities/tireman` is the name of the texture atlas containing `face_*` textures.
|
||||
> The texture does not necessarily have to be in an atlas.
|
||||
|
||||
If you do not wish to limit the animation duration via `configure` but want to loop the keyframe animation for a specific line, you can use the `period` parameter to specify the animation's repetition period in frames. Example:
|
||||
|
||||
```vcd
|
||||
@move by y curve linear period 24 {
|
||||
@key frame 0 value 0
|
||||
@key frame 12 value 1
|
||||
@key frame 24 value 0
|
||||
}
|
||||
```
|
||||
|
||||
## Expression curves
|
||||
|
||||
The attribute describes a function `f(t) = x`, where t is time in seconds.
|
||||
|
||||
Example: `func (sin(t * 2.5) + pi)`.
|
||||
|
||||
Operators available in expressions:
|
||||
|
||||
- `a + b` - addition
|
||||
- `a * b` - multiplication
|
||||
- `a / b` - division
|
||||
- `a % b` - modulo
|
||||
- `a ^ b` - exponentiation
|
||||
|
||||
Constants available in expressions:
|
||||
|
||||
- `pi` - the number π
|
||||
- `e` - Euler's number
|
||||
|
||||
Functions available in expressions:
|
||||
|
||||
- `sin(x)` - sine of x
|
||||
- `cos(x)` - cosine of x
|
||||
- `tan(x)` - tangent of x
|
||||
- `noise(x, octaves)` - fast 1D noise of x with the given number of octaves
|
||||
- `noise2d(x, y, octaves)` - 2D noise of x,y with the given number of octaves
|
||||
- `sign(x)` - an integer indicating the sign of x (-1/0/1)
|
||||
- `rand(low, high)` - a pseudo-random floating-point number in the range from low to high
|
||||
- `round(x, places)` - rounds x to the given number of decimal places `places` (optional)
|
||||
- `floor(x)` - rounds x down to the nearest integer
|
||||
- `ceil(x)` - rounds x up to the nearest integer
|
||||
- `exp(x)` - $e^{x}$
|
||||
- `min(x, ...)` - returns the smallest of the given arguments
|
||||
- `max(x, ...)` - returns the largest of the given arguments
|
||||
- `sqrt(x)` - square root of x
|
||||
- `log(x)` - $ln({x})$
|
||||
- `log10(x)` - $log_{10}({x})$
|
||||
- `deg(x)` - converts radians to degrees
|
||||
- `rad(x)` - converts degrees to radians
|
||||
|
||||
|
||||
>[!WARNING]
|
||||
> Using undocumented functions may have any undocumented consequences.
|
||||
|
|
@ -42,6 +42,7 @@ This primitive describes a triangle.
|
|||
- `region-scale` - multiplier vector for the UV region. Example: `region-scale (0.5,1)`
|
||||
- `shading` - determines whether shading is enabled on the primitive. Example: `shading off`
|
||||
- `normal` - overrides normal vector. Example: `normal (0,1,0)`
|
||||
- `cull-face` - determines which side will be culled. Example: `cull-face front` or `cull-face off` (disables face culling)
|
||||
|
||||
By default, texture coordinates are not affected by shape or size, unlike other primitives.
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ This primitive describes a parallelogram using the right and up vectors.
|
|||
- `shading` - determines whether shading is enabled on the primitive. Example: `shading off`
|
||||
- `flip` - flips the UV region horizontally or vertically. Example: `flip v`
|
||||
- `normal` - overrides normal vector. Example: `normal (0,1,0)`
|
||||
- `cull-face` - determines which side will be culled. Example: `cull-face front` or `cull-face off` (disables face culling)
|
||||
|
||||
### `box` Properties
|
||||
|
||||
|
|
|
|||
|
|
@ -215,6 +215,9 @@ Element is a container. Does not have specific attributes.
|
|||
> [!WARNING]
|
||||
> Inventories position is controlled by the engine and can not be changed by attributes *pos* and *margin*
|
||||
|
||||
> [!WARNING]
|
||||
> Slots not linked to an inventory will not be displayed. "Linked to an inventory" refers to the association between an inventory UI element and an inventory via an ID. This link can be explicitly established using `inventory_ui.inventory = inventory_id`. [(see ui.md)](scripting/ui.md#inventory)
|
||||
|
||||
## *slot*
|
||||
|
||||
Element must be in direct sub-element of *inventory*.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
# Документация
|
||||
|
||||
> [!WARNING]
|
||||
> Версия находится в разработке. Перейдите к [документации для 0.31.](https://github.com/MihailRis/voxelcore/blob/release-0.31/doc/ru/main-page.md)
|
||||
|
||||
## Разделы
|
||||
|
||||
- [XML разметка интерфейса](xml-ui-layouts.md)
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ file.stem(путь: string) -> string
|
|||
|
||||
-- Извлекает расширение из пути. Пример: `world:data/base/config.toml` -> `toml`.
|
||||
file.ext(путь: string) -> string
|
||||
|
||||
-- Возвращает путь без расширения. Пример: `world:data/base/config.toml` -> `world:data/base/config`.
|
||||
file.remove_ext(путь: string) -> string
|
||||
```
|
||||
|
||||
## Директории
|
||||
|
|
@ -145,4 +148,4 @@ file.open(путь: string, режим: string) -> io_stream
|
|||
-- * `/tmp/` или `\\\\.\\pipe\\` добавлять не нужно - движок делает это автоматически.
|
||||
-- * Недоступен режим с `+`
|
||||
file.open_named_pipe(имя: string, режим: string) -> io_stream
|
||||
```
|
||||
```
|
||||
|
|
|
|||
|
|
@ -42,8 +42,14 @@ skeleton:is_visible([опционально] index: int) -> boolean
|
|||
skeleton:set_visible([опционально] index: int, status: boolean)
|
||||
|
||||
-- Возвращает цвет сущности
|
||||
skeleton:get_color() -> vec3
|
||||
skeleton:get_color() -> vec4
|
||||
|
||||
-- Возвращает цвет кости
|
||||
skeleton:get_color(index: int) -> vec4
|
||||
|
||||
-- Устанавливает цвет сущности
|
||||
skeleton:set_color(color: vec3)
|
||||
```
|
||||
skeleton:set_color(color: vec4)
|
||||
|
||||
-- Устанавливает цвет кости
|
||||
skeleton:set_color(color: vec4, index: int)
|
||||
```
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ network.get(
|
|||
)
|
||||
|
||||
-- Пример:
|
||||
network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s)
|
||||
network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s)
|
||||
print(json.parse(s).name) -- выведет имя последнего релиза движка
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -174,9 +174,11 @@ rig:index(name: str) -> int
|
|||
-- или всего скелета, если индекс не указан
|
||||
rig:is_visible([optional] index: int) -> bool
|
||||
|
||||
-- Устанавливает статус видимости всего скелета
|
||||
rig:set_visible(status: bool)
|
||||
|
||||
-- Устанавливает статус видимости кости по индексу
|
||||
-- или всего скелета, если индекс не указан
|
||||
rig:set_visible([optional] index: int, status: bool)
|
||||
rig:set_visible(index: int, status: bool)
|
||||
|
||||
-- Возвращает цвет сущности
|
||||
rig:get_color() -> vec4
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ packid.binding.name="inputtype:codename"
|
|||
- a..z
|
||||
- 0..9
|
||||
- f1..f25
|
||||
- grave-accent, minus, equal, left-bracket, right-bracket, backslash
|
||||
- semicolon, apostrophe, comma, period, slash
|
||||
|
||||
## Библиотека input
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ VCA файл состоит из набора директив, порядок
|
|||
- `@rotate` - поворот объекта/кости
|
||||
- `@scale` - масштабирование объекта/кости (множитель)
|
||||
- `@zoom` - масштаб камеры (множитель)
|
||||
- `@texture` - смена динамически-назначаемой текстуры (см. [skeleton:set_texture](scripting/ecs.md#skeleton))
|
||||
|
||||
## Мета-информация
|
||||
|
||||
|
|
@ -73,6 +74,28 @@ VCA файл состоит из набора директив, порядок
|
|||
@key frame 138 value 53.00411 lx 127.067 ly 53.00411 rx 138.001 ry 53.00411
|
||||
```
|
||||
|
||||
Для директивы texture всё проще. Пример:
|
||||
|
||||
```vcd
|
||||
@texture name $0 {
|
||||
@key frame 0 value entities/tireman:face_0
|
||||
@key frame 24 value entities/tireman:face_1
|
||||
}
|
||||
```
|
||||
|
||||
> entities/tireman здесь - имя текстурного атласа, в котором находятся face_\* текстуры.
|
||||
> Текстура не обязательно должна находиться в атласе.
|
||||
|
||||
Если вы не хотите ограничивать длительность анимации через `configure`, но хотите зациклить анимацию по ключевым кадрам для конкретной линии, то можно использовать параметр `period` для указания периода повторения анимации в кадрах. Пример:
|
||||
|
||||
```vcd
|
||||
@move by y curve linear period 24 {
|
||||
@key frame 0 value 0
|
||||
@key frame 12 value 1
|
||||
@key frame 24 value 0
|
||||
}
|
||||
```
|
||||
|
||||
## Кривые через выражения
|
||||
|
||||
Через атрибут описывается функция `f(t) = x` где t - время в секундах.
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
- `region-scale` вектор-множитель для UV региона. Пример: `region-scale (0.5,1)`
|
||||
- `shading` определяет возможность затенения на примитиве. Пример: `shading off`
|
||||
- `normal` переопределяет вектор нормали. Пример: `normal (0,1,0)`
|
||||
- `cull-face` - определяет, какая сторона будет отсечена. Пример: `cull-face front` или `cull-face off` (отлючает отсечение сторон)
|
||||
|
||||
Текстурные координаты по-умолчанию не зависят от формы из размера, в отличие от других примитивов.
|
||||
|
||||
|
|
@ -58,6 +59,7 @@
|
|||
- `shading` - определяет возможность затенения на примитиве. Пример: `shading off`
|
||||
- `flip` - отражает UV регион по горизонтали или вертикали. Пример: `flip v`
|
||||
- `normal` - переопределяет вектор нормали. Пример: `normal (0,1,0)`
|
||||
- `cull-face` - определяет, какая сторона будет отсечена. Пример: `cull-face front` или `cull-face off` (отлючает отсечение сторон)
|
||||
|
||||
### Свойства `box`
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,9 @@
|
|||
> [!WARNING]
|
||||
> Расположение инвентарей управляется движком и не может быть изменено свойствами pos, margin и т.д.
|
||||
|
||||
> [!WARNING]
|
||||
> Слоты без привязки к инвентарю не будут отображаться. Под приязкой к инвентарю понимается связь UI элемента inventory с инвентарём по id. Которая может быть явно создана через `inventory_ui.inventory = inventory_id`. [(см ui.md)](scripting/ui.md#инвентарь-inventory)
|
||||
|
||||
## Одиночный слот - *slot*
|
||||
|
||||
Элемент должен находиться внутри `inventory` элемента, без посредников.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Format version: 1.1
|
||||
|
||||
This binary data format is developed for use as binary version of JSON in [VoxelEngine-Cpp](https://github.com/MihailRis/VoxelEngine-Cpp) and not compatible with [BSON](https://bsonspec.org/spec.html) due to elements/entries syntax and type codes differences
|
||||
This binary data format is developed for use as binary version of JSON in [voxelcore](https://github.com/MihailRis/voxelcore) and not compatible with [BSON](https://bsonspec.org/spec.html) due to elements/entries syntax and type codes differences
|
||||
|
||||
## Basic types
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp VoxelEngine $out/bin/
|
||||
cp VoxelCore $out/bin/
|
||||
'';
|
||||
};
|
||||
in
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
<panel size='400' color='0' interval='1' context='menu'>
|
||||
<panel size='400' max-length='420' padding='0,0,16,0' color='0' interval='1' context='menu'>
|
||||
</panel>
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ function on_open()
|
|||
create_trackbar_setting("chunks.load-speed", "Load Speed", 1)
|
||||
create_trackbar_setting("graphics.fog-curve", "Fog Curve", 0.1)
|
||||
|
||||
create_checkbox("graphics.enable-fog", "Fog", "graphics.enable-fog.tooltip")
|
||||
create_checkbox("graphics.backlight", "Backlight", "graphics.backlight.tooltip")
|
||||
create_checkbox("graphics.soft-lighting", "Soft lighting", "graphics.soft-lighting.tooltip")
|
||||
create_checkbox("graphics.dense-render", "Dense blocks render", "graphics.dense-render.tooltip")
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ local function bezier_interpolation(k0, k1, t)
|
|||
local u = t
|
||||
|
||||
for i=1,8 do
|
||||
local x = bezier(k0.frame, k0.rx, k1.lx, k1.frame, u)
|
||||
local dx = bezier_derivative(k0.frame, k0.rx, k1.lx, k1.frame, u)
|
||||
local x = bezier(
|
||||
k0.frame, k0.rx + k0.frame, k1.lx + k1.frame, k1.frame, u)
|
||||
local dx = bezier_derivative(
|
||||
k0.frame, k0.rx + k0.frame, k1.lx + k1.frame, k1.frame, u)
|
||||
|
||||
if math.abs(dx) < 1e-8 then
|
||||
break
|
||||
|
|
@ -34,7 +36,7 @@ local function bezier_interpolation(k0, k1, t)
|
|||
if u > 1 then u = 1 end
|
||||
end
|
||||
|
||||
return bezier(k0.value, k0.ry, k1.ly, k1.value, u)
|
||||
return bezier(k0.value, k0.ry + k0.value, k1.ly + k1.value, k1.value, u)
|
||||
end
|
||||
|
||||
local this = {
|
||||
|
|
@ -42,11 +44,14 @@ local this = {
|
|||
CH_ROTATE = 2,
|
||||
CH_SCALE = 3,
|
||||
CH_ZOOM = 4,
|
||||
CH_TEXTURE = 5,
|
||||
|
||||
INT_CONST = 1,
|
||||
INT_LINEAR = 2,
|
||||
INT_BEZIER = 3,
|
||||
INT_CUSTOM = 4,
|
||||
MAX_DURATION = 1e9,
|
||||
MAX_FRAMES = 1e9,
|
||||
|
||||
TRACE_CODEGEN = false,
|
||||
|
||||
|
|
@ -94,6 +99,9 @@ local PlayingTrack = {
|
|||
}
|
||||
|
||||
function this.play(name, target)
|
||||
if target and target.reset_pose then
|
||||
target:reset_pose()
|
||||
end
|
||||
local track = setmetatable({
|
||||
name = name,
|
||||
target = target,
|
||||
|
|
@ -127,6 +135,9 @@ function internals.on_animation_frame()
|
|||
if track_info.__timer > track.duration then
|
||||
table.remove(playing_tracks, i)
|
||||
else
|
||||
if track_info.target.reset_pose then
|
||||
track_info.target:reset_pose()
|
||||
end
|
||||
track.func(track_info.target, track_info.__timer)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,10 +15,15 @@ local exclude_patters = {
|
|||
}
|
||||
|
||||
-- TODO: replace with actual expression -> lua translator
|
||||
local function process_expression(src, memoised)
|
||||
local function process_expression(src, memoised, mode)
|
||||
if mode == 'mul' then
|
||||
src = string.format("(%s) * intensity + (1.0 - intensity)", src)
|
||||
elseif mode == "add" then
|
||||
src = string.format("(%s) * intensity", src)
|
||||
end
|
||||
|
||||
for i, pattern in ipairs(exclude_patters) do
|
||||
if src:find(pattern) then
|
||||
debug.print(exclude_patters)
|
||||
error("invalid syntax "..string.escape(src))
|
||||
end
|
||||
end
|
||||
|
|
@ -60,6 +65,11 @@ local env = {
|
|||
Y = {0, 1, 0},
|
||||
Z = {0, 0, 1},
|
||||
DST = mat4.idt(),
|
||||
string_at = function(keys, frame)
|
||||
local left, _ = key_neighbors(keys, frame)
|
||||
left = keys[left]
|
||||
return left.value
|
||||
end,
|
||||
value_at = function(keys, frame, interp)
|
||||
local left, right = key_neighbors(keys, frame)
|
||||
if left == right then
|
||||
|
|
@ -116,12 +126,17 @@ local env = {
|
|||
|
||||
local math_funcs = {
|
||||
"sqrt", "min", "max", "deg", "rad", "log", "log10", "floor", "ceil", "sin",
|
||||
"tan", "noise", "noise2", "sign", "round", "exp", "pi", "e"
|
||||
"cos", "tan", "abs", "noise", "noise2", "sign", "round", "exp", "pi", "e"
|
||||
}
|
||||
for _, name in ipairs(math_funcs) do
|
||||
env[name] = math[name]
|
||||
end
|
||||
|
||||
local is_multiplier = {
|
||||
[animation.CH_SCALE] = true,
|
||||
[animation.CH_ZOOM] = true,
|
||||
}
|
||||
|
||||
local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
||||
local lines = lineset.lines
|
||||
local code = ""
|
||||
|
|
@ -132,7 +147,8 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
|||
for i, line in ipairs(lines) do
|
||||
if line.expression then
|
||||
code = code .. "\n local l" .. i .. " = (" ..
|
||||
process_expression(line.expression, memoised) .. ")"
|
||||
process_expression(line.expression, memoised,
|
||||
is_multiplier[line.channel] and "mul" or "add") .. ")"
|
||||
elseif line.keys then
|
||||
local target_keysets = keysets[lineset.target_name]
|
||||
if not target_keysets then
|
||||
|
|
@ -145,12 +161,16 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
|||
local valueat = string.format("curves[%s]", string.escape(line.curve_func))
|
||||
|
||||
code = code .. string.format(
|
||||
"\n local l%d = value_at_custom(keysets['%s'][%d], t * %s, %s)",
|
||||
i, lineset.target_name, i, raw_track.fps, valueat)
|
||||
"\n local l%d = value_at_custom(keysets['%s'][%d], t * %s %% %s, %s)",
|
||||
i, lineset.target_name, i, raw_track.fps, line.period, valueat)
|
||||
elseif line.channel == animation.CH_TEXTURE then
|
||||
code = code .. string.format(
|
||||
"\n local l%d = string_at(keysets['%s'][%d], t * %s %% %s)",
|
||||
i, lineset.target_name, i, raw_track.fps, line.period)
|
||||
else
|
||||
code = code .. string.format(
|
||||
"\n local l%d = value_at(keysets['%s'][%d], t * %s, %s)",
|
||||
i, lineset.target_name, i, raw_track.fps, line.interp)
|
||||
"\n local l%d = value_at(keysets['%s'][%d], t * %s %% %s, %s)",
|
||||
i, lineset.target_name, i, raw_track.fps, line.period, line.interp)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -164,7 +184,9 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
|||
scale[line.axis] = i
|
||||
has_tsf = true
|
||||
elseif line.channel == animation.CH_ZOOM then
|
||||
code = code .. "\n zoom = l" .. i
|
||||
code = code .. "\n zoom = l" .. i
|
||||
elseif line.channel == animation.CH_TEXTURE then
|
||||
code = code .. string.format("\n target:set_texture(%s, %s)", lineset.target_name:escape(), "l"..i)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -172,7 +194,6 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
|||
return code
|
||||
end
|
||||
|
||||
code = code .. "\n mat4.idt(dst)"
|
||||
if translation[1] or translation[2] or translation[3] then
|
||||
code = code .. "\n mat4.translate(dst, {" ..
|
||||
(translation[1] and ("l" .. translation[1]) or '0').. ", " ..
|
||||
|
|
@ -204,16 +225,21 @@ end
|
|||
|
||||
local function codegen_rig_target(raw_track, context)
|
||||
local code = "\n if target.set_matrix and target.index then\n"
|
||||
code = code .. " local dst = DST\n"
|
||||
for bone, lineset in pairs(raw_track.linesets) do
|
||||
if lineset.target_type ~= "bone" then
|
||||
if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then
|
||||
goto continue
|
||||
end
|
||||
local lineset_code = codegen_track(
|
||||
raw_track, lineset, context.memoised, context.keysets, true)
|
||||
|
||||
code = code .. "\n do" .. lineset_code .. "\n end\n" ..
|
||||
" target:set_matrix(target:index(" .. string.escape(bone) .. "), dst)\n"
|
||||
code = code
|
||||
.. string.format("\n local bone_index = target:index(%s)"
|
||||
.. "\n local dst = target:get_matrix(bone_index)", string.escape(bone))
|
||||
.. "\n do" .. lineset_code .. "\n end\n"
|
||||
if lineset.target_type == "bone" then
|
||||
code = code ..
|
||||
" target:set_matrix(bone_index, dst)\n"
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
return code .. " end"
|
||||
|
|
@ -221,7 +247,7 @@ end
|
|||
|
||||
local function codegen_object_target(raw_track, context)
|
||||
local code = "\n if target.set_pos then\n"
|
||||
code = code .. " local dst = DST\n"
|
||||
code = code .. " local dst = mat4.idt()\n"
|
||||
local lineset = raw_track.linesets[""]
|
||||
if not lineset then
|
||||
return ""
|
||||
|
|
@ -258,7 +284,7 @@ function internals.compile_animation_track(raw_track, track_name)
|
|||
for name, curve in pairs(raw_track.curves) do
|
||||
context.curves[name] = load(string.format(
|
||||
"return function(kl, kr, t) return %s end",
|
||||
process_expression(curve.func, context.memoised)
|
||||
process_expression(curve.func, context.memoised, "curve")
|
||||
), "<curve>", "t", env)()
|
||||
end
|
||||
|
||||
|
|
@ -276,7 +302,7 @@ function internals.compile_animation_track(raw_track, track_name)
|
|||
code = memoised_code .. "\n" .. code
|
||||
end
|
||||
|
||||
local src = "return function(target, t, m)\n"
|
||||
local src = "return function(target, t, intensity, m)\n m = m or 1\n intensity = intensity or 1.0\n"
|
||||
.. code .. "\nend"
|
||||
|
||||
if animation.TRACE_CODEGEN then
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ function file.stem(path)
|
|||
end
|
||||
|
||||
function file.ext(path)
|
||||
return path:match("%.([^:/\\]+)$")
|
||||
return path:match("[^:/\\.]%.([^.:/\\]+)$")
|
||||
end
|
||||
|
||||
function file.prefix(path)
|
||||
|
|
@ -24,7 +24,11 @@ function file.parent(path)
|
|||
end
|
||||
|
||||
function file.remove_ext(path)
|
||||
return string.format("%s/%s", file.parent(path), file.stem(path))
|
||||
local ext = file.ext(path)
|
||||
if not ext then
|
||||
return path
|
||||
end
|
||||
return path:sub(1, -#ext - 2)
|
||||
end
|
||||
|
||||
function file.path(path)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ local action_to_channel = {
|
|||
rotate = animation.CH_ROTATE,
|
||||
scale = animation.CH_SCALE,
|
||||
zoom = animation.CH_ZOOM,
|
||||
texture = animation.CH_TEXTURE,
|
||||
}
|
||||
|
||||
local curve_to_interp = {
|
||||
|
|
@ -17,12 +18,12 @@ local curve_to_interp = {
|
|||
|
||||
local function parse_configure(raw_track, node)
|
||||
if node.fps then
|
||||
raw_track.fps = node.fps
|
||||
raw_track.fps = tonumber(node.fps)
|
||||
end
|
||||
if node.frames then
|
||||
raw_track.duration = node.frames / (node.fps or DEFAULT_FPS)
|
||||
raw_track.duration = tonumber(node.frames) / (tonumber(raw_track.fps) or DEFAULT_FPS)
|
||||
elseif node.duration then
|
||||
raw_track.duration = node.duration
|
||||
raw_track.duration = tonumber(node.duration)
|
||||
end
|
||||
raw_track.rotation_order = string.upper(node["rotation-order"] or "XYZ")
|
||||
end
|
||||
|
|
@ -50,6 +51,17 @@ local function parse_curve(line, node)
|
|||
end
|
||||
end
|
||||
|
||||
local function parse_simple_frames(line, node)
|
||||
line.keys = {}
|
||||
for j, key_node in ipairs(node) do
|
||||
local keyframe = {
|
||||
frame = tonumber(key_node.frame),
|
||||
value = key_node.value,
|
||||
}
|
||||
table.insert(line.keys, keyframe)
|
||||
end
|
||||
end
|
||||
|
||||
local function parse_track(root)
|
||||
local raw_track = {
|
||||
duration = math.huge,
|
||||
|
|
@ -74,8 +86,10 @@ local function parse_track(root)
|
|||
local target_type = nil
|
||||
if node.bone then
|
||||
target_type = "bone"
|
||||
elseif tag == "texture" then
|
||||
target_type = "texture"
|
||||
end
|
||||
local target_name = node.bone or ""
|
||||
local target_name = node.bone or node.name or ""
|
||||
local lineset = linesets[target_name]
|
||||
if not lineset then
|
||||
lineset = {
|
||||
|
|
@ -86,16 +100,21 @@ local function parse_track(root)
|
|||
linesets[target_name] = lineset
|
||||
end
|
||||
|
||||
local channel = action_to_channel[tag]
|
||||
if not channel then
|
||||
error("unknown directive " .. tag:escape())
|
||||
end
|
||||
local line = {
|
||||
axis = node.by and ("xyz"):find(node.by) or "",
|
||||
channel = action_to_channel[tag]
|
||||
channel = channel,
|
||||
period = node.period or animation.MAX_FRAMES
|
||||
}
|
||||
if node.func then
|
||||
line.expression = node.func
|
||||
elseif node.curve then
|
||||
parse_curve(line, node)
|
||||
else
|
||||
error("not implemented")
|
||||
parse_simple_frames(line, node)
|
||||
end
|
||||
|
||||
table.insert(lineset.lines, line)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local ALMOST_HUGE = 1e9
|
||||
local MAX_DURATION = animation.MAX_DURATION
|
||||
|
||||
local rig = entity.skeleton
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ function create_state(name, track_id, max_intencity)
|
|||
fade_time = 0.0,
|
||||
fade_timer = 0.0,
|
||||
fade_in = false,
|
||||
max_intencity = max_intencity,
|
||||
max_intencity = max_intencity or 1.0,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -25,19 +25,20 @@ function set_state(name, fade_time)
|
|||
end
|
||||
if current_state then
|
||||
current_state.fade_in = false
|
||||
current_state.fade_time = fade_time
|
||||
current_state.fade_time = fade_time or 0.0
|
||||
current_state.fade_timer = 0.0
|
||||
end
|
||||
current_state = state
|
||||
if state then
|
||||
state.timer = 0.0
|
||||
state.fade_in = true
|
||||
state.fade_time = fade_time
|
||||
state.fade_time = fade_time or 0.0
|
||||
state.fade_timer = 0.0
|
||||
end
|
||||
end
|
||||
|
||||
local function update(delta)
|
||||
rig:reset_pose()
|
||||
for _, state in pairs(states) do
|
||||
state.timer = state.timer + delta
|
||||
|
||||
|
|
@ -51,10 +52,10 @@ local function update(delta)
|
|||
end
|
||||
|
||||
state.track = state.track or animation.get_track(state.track_id)
|
||||
if state.track and intensity > 0.0 then
|
||||
if state.track then
|
||||
state.track.func(
|
||||
rig,
|
||||
state.timer % math.min(ALMOST_HUGE, state.track.duration),
|
||||
state.timer % math.min(MAX_DURATION, state.track.duration),
|
||||
intensity * state.max_intencity
|
||||
)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -183,6 +183,12 @@ function on_deprecated_call(name, alternatives)
|
|||
end
|
||||
end
|
||||
|
||||
local __pack_envs = __vc__pack_envs
|
||||
function __vc_internals.get_pack_env(packid)
|
||||
return __pack_envs[packid]
|
||||
end
|
||||
__vc__pack_envs = nil
|
||||
|
||||
function reload_module(name)
|
||||
local prefix, name = parse_path(name)
|
||||
local path = prefix..":modules/"..name..".lua"
|
||||
|
|
@ -196,6 +202,10 @@ function reload_module(name)
|
|||
if script == nil then
|
||||
error(err)
|
||||
end
|
||||
local env = __pack_envs[prefix]
|
||||
if env then
|
||||
script = setfenv(script, env)
|
||||
end
|
||||
local result = script()
|
||||
if not result then
|
||||
return
|
||||
|
|
@ -270,12 +280,6 @@ function __vc_lock_internal_modules()
|
|||
__internal_locked = true
|
||||
end
|
||||
|
||||
local __pack_envs = __vc__pack_envs
|
||||
function __vc_internals.get_pack_env(packid)
|
||||
return __pack_envs[packid]
|
||||
end
|
||||
__vc__pack_envs = nil
|
||||
|
||||
function require(path)
|
||||
if not string.find(path, ':') then
|
||||
local prefix, _ = parse_path(_debug_getinfo(2).source)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ void main() {
|
|||
|
||||
vec3 pos3d = a_modelpos.xyz - u_cameraPos;
|
||||
|
||||
a_realnormal = v_normal.xyz * 2.0 - 1.0;
|
||||
a_realnormal = vec3(0.0, 1.0, 0.0);
|
||||
a_normal = calc_screen_normal(a_realnormal);
|
||||
|
||||
a_torchLight = vec4(calc_torch_light(
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#define CLOUDS_FOG_FACTOR_MUL 0.3f
|
||||
#define CLOUDS_FOG_CURVE_MUL 0.4f
|
||||
#define COLOR_TEMPERATURE_COMPENSATION 1.12f
|
||||
|
||||
vec4 effect() {
|
||||
vec4 pos = texture(u_position, v_uv);
|
||||
|
|
@ -26,8 +27,12 @@ vec4 effect() {
|
|||
|
||||
float emission = texture(u_emission, v_uv).r;
|
||||
|
||||
float rg = 1.0;
|
||||
#ifdef ENABLE_SHADOWS
|
||||
light *= calc_shadow(modelpos, normal, length(pos));
|
||||
float shadow_mul = calc_shadow(modelpos, normal, length(pos));
|
||||
light *= shadow_mul;
|
||||
rg *= min(1.0, shadow_mul + emission) * COLOR_TEMPERATURE_COMPENSATION;
|
||||
light *= 2.0;
|
||||
#endif
|
||||
|
||||
light = max(light, emission);
|
||||
|
|
@ -40,5 +45,5 @@ vec4 effect() {
|
|||
mix(1.0, CLOUDS_FOG_FACTOR_MUL, emission),
|
||||
mix(1.0, CLOUDS_FOG_CURVE_MUL, emission)
|
||||
);
|
||||
return vec4(mix(texture(u_screen, v_uv).rgb * mix(1.0, light, 1.0), fogColor, fog), 1.0);
|
||||
return vec4(mix(texture(u_screen, v_uv).rgb * mix(1.0, light, 1.0) * vec3(rg, 0.5 + rg * 0.5, 1.0), fogColor, fog), 1.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,16 @@ uniform float u_weatherFogDencity;
|
|||
uniform float u_weatherFogCurve;
|
||||
|
||||
float calc_fog(float depth, float fogFactor, float fogCurve) {
|
||||
#ifdef ENABLE_FOG
|
||||
return min(
|
||||
1.0,
|
||||
max(pow(depth * u_fogFactor * fogFactor, u_fogCurve * fogCurve),
|
||||
min(pow(depth * u_weatherFogDencity, u_weatherFogCurve),
|
||||
u_weatherFogOpacity))
|
||||
);
|
||||
#else
|
||||
return 0.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
float calc_fog(float depth) {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ devtools.output=Output
|
|||
# Tooltips
|
||||
audio.acoustic-effects.tooltip=Acoustic effects may not be supported by your system
|
||||
audio.recording-enabled.tooltip=Enables audio recording features
|
||||
graphics.enable-fog.tooltip=Enables fog
|
||||
graphics.gamma.tooltip=Lighting brightness curve
|
||||
graphics.backlight.tooltip=Backlight to prevent total darkness
|
||||
graphics.dense-render.tooltip=Enables transparency in blocks like leaves
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ pack.remove-confirm=Удалить весь поставляемый паком/
|
|||
# Подсказки
|
||||
audio.acoustic-effects.tooltip=Акустические эффекты могут не поддерживаться системой
|
||||
audio.recording-enabled.tooltip=Включает функции записи звука
|
||||
graphics.enable-fog.tooltip=Отображать туман / дымку
|
||||
graphics.gamma.tooltip=Кривая яркости освещения
|
||||
graphics.backlight.tooltip=Подсветка, предотвращающая полную темноту
|
||||
graphics.dense-render.tooltip=Включает прозрачность блоков, таких как листья
|
||||
|
|
@ -89,6 +90,7 @@ settings.Soft lighting=Мягкое освещение
|
|||
settings.Camera Shaking=Тряска Камеры
|
||||
settings.Camera Inertia=Инерция Камеры
|
||||
settings.Camera FOV Effects=Эффекты поля зрения
|
||||
settings.Fog=Туман
|
||||
settings.Fog Curve=Кривая Тумана
|
||||
settings.FOV=Поле Зрения
|
||||
settings.Fullscreen=Полный экран
|
||||
|
|
|
|||
17
run.sh
17
run.sh
|
|
@ -31,6 +31,17 @@ function norun {
|
|||
}
|
||||
|
||||
|
||||
function test {
|
||||
echo "[RUN SCRIPT] Run tests"
|
||||
cd build
|
||||
rm -rf ./vctest-run
|
||||
mkdir ./vctest-run
|
||||
./vctest/vctest --exe ./VoxelCore --res res --user ./vctest-run --tests ../dev/tests --memchecker valgrind
|
||||
cd ..
|
||||
run=
|
||||
}
|
||||
|
||||
|
||||
function help {
|
||||
echo "[RUN SCRIPT] Usage: ./run [ARGUMENT]..."
|
||||
echo "[RUN SCRIPT] Arguments:"
|
||||
|
|
@ -38,6 +49,7 @@ function help {
|
|||
echo "[RUN SCRIPT] -b, --build Build project"
|
||||
echo "[RUN SCRIPT] -r, --rebuild Rebuild project"
|
||||
echo "[RUN SCRIPT] -R, --norun Build without run"
|
||||
echo "[RUN SCRIPT] -t, --test Run tests (without run)"
|
||||
echo "[RUN SCRIPT] -h, --help Print this page"
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +60,7 @@ while [ -n "$1" ]; do
|
|||
-b | --build) build ;;
|
||||
-r | --rebuild) rebuild ;;
|
||||
-R | --norun) norun ;;
|
||||
-t | --test) test ;;
|
||||
-h | --help) help
|
||||
norun
|
||||
break ;;
|
||||
|
|
@ -62,5 +75,5 @@ done
|
|||
|
||||
if [[ $run ]]; then
|
||||
echo "[RUN SCRIPT] Run project"
|
||||
./build/VoxelEngine
|
||||
fi
|
||||
./build/VoxelCore
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
project(VoxelEngineSrc)
|
||||
project(VoxelCoreSrc)
|
||||
|
||||
file(GLOB_RECURSE headers ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
||||
file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
|
||||
|
||||
add_library(VoxelEngineSrc STATIC ${sources} ${headers})
|
||||
add_library(VoxelCoreSrc STATIC ${sources} ${headers})
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
|
|
@ -34,23 +34,23 @@ endif()
|
|||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
find_package(vorbis REQUIRED)
|
||||
|
||||
set(LUAJIT_PACKAGE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}")
|
||||
if(VCPKG_TARGET_TRIPLET MATCHES "static")
|
||||
add_library(luajit STATIC IMPORTED)
|
||||
set_target_properties(
|
||||
luajit
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION
|
||||
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/lib/libluajit-5.1.a"
|
||||
"${LUAJIT_PACKAGE_DIR}/lib/libluajit-5.1.a"
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/"
|
||||
"${LUAJIT_PACKAGE_DIR}/include/"
|
||||
)
|
||||
else()
|
||||
set(LUAJIT_PACKAGE_DIR "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}")
|
||||
|
||||
if(EXISTS "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit-2.1")
|
||||
set(LUAJIT_INCLUDE_DIR "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit-2.1")
|
||||
if(EXISTS "${LUAJIT_PACKAGE_DIR}/include/luajit-2.1")
|
||||
set(LUAJIT_INCLUDE_DIR "${LUAJIT_PACKAGE_DIR}/include/luajit-2.1")
|
||||
else()
|
||||
set(LUAJIT_INCLUDE_DIR "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit")
|
||||
set(LUAJIT_INCLUDE_DIR "${LUAJIT_PACKAGE_DIR}/include/luajit")
|
||||
endif()
|
||||
|
||||
add_library(luajit SHARED IMPORTED)
|
||||
|
|
@ -58,9 +58,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|||
luajit
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION
|
||||
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/bin/lua51.dll"
|
||||
"${LUAJIT_PACKAGE_DIR}/bin/lua51.dll"
|
||||
IMPORTED_IMPLIB
|
||||
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/lib/lua51.lib"
|
||||
"${LUAJIT_PACKAGE_DIR}/lib/lua51.lib"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LUAJIT_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
|
@ -77,10 +77,10 @@ else()
|
|||
add_library(luajit::luajit ALIAS PkgConfig::luajit)
|
||||
endif()
|
||||
|
||||
target_include_directories(VoxelEngineSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(VoxelCoreSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(
|
||||
VoxelEngineSrc
|
||||
VoxelCoreSrc
|
||||
PRIVATE glfw
|
||||
OpenGL::GL
|
||||
GLEW::GLEW
|
||||
|
|
@ -98,7 +98,7 @@ target_link_libraries(
|
|||
)
|
||||
|
||||
target_compile_options(
|
||||
VoxelEngineSrc
|
||||
VoxelCoreSrc
|
||||
PUBLIC $<$<CXX_COMPILER_ID:MSVC>:
|
||||
/utf-8
|
||||
/MP
|
||||
|
|
@ -136,7 +136,7 @@ target_compile_options(
|
|||
>)
|
||||
|
||||
target_link_options(
|
||||
VoxelEngineSrc
|
||||
VoxelCoreSrc
|
||||
PUBLIC
|
||||
$<$<CXX_COMPILER_ID:GNU>:
|
||||
-no-pie
|
||||
|
|
|
|||
|
|
@ -198,6 +198,31 @@ static void perform_rect(const xmlelement& root, ModelBuilder& builder) {
|
|||
} else {
|
||||
normal = glm::cross(glm::normalize(right), glm::normalize(up));
|
||||
}
|
||||
|
||||
auto cullFace = root.attr("cull-face", "back").getText();
|
||||
if (cullFace == "front") {
|
||||
normal *= -1.0f;
|
||||
} else if (cullFace == "off") {
|
||||
builder.addRect(
|
||||
texture,
|
||||
shading,
|
||||
from + right * 0.5f + up * 0.5f,
|
||||
right * 0.5f,
|
||||
up * 0.5f,
|
||||
normal,
|
||||
region
|
||||
);
|
||||
builder.addRect(
|
||||
texture,
|
||||
shading,
|
||||
from + right * 0.5f + up * 0.5f,
|
||||
right * -0.5f,
|
||||
up * -0.5f,
|
||||
-normal,
|
||||
region
|
||||
);
|
||||
return;
|
||||
}
|
||||
builder.addRect(
|
||||
texture,
|
||||
shading,
|
||||
|
|
@ -246,6 +271,17 @@ static void perform_triangle(const xmlelement& root, ModelBuilder& builder) {
|
|||
}
|
||||
|
||||
std::string texture = root.attr("texture", "$0").getText();
|
||||
|
||||
auto cullFace = root.attr("cull-face", "back").getText();
|
||||
if (cullFace == "front") {
|
||||
std::swap(pointB, pointC);
|
||||
std::swap(uvs[1], uvs[2]);
|
||||
normal *= -1.0f;
|
||||
} else if (cullFace == "off") {
|
||||
builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]);
|
||||
builder.addTriangle(texture, shading, pointA, pointC, pointB, -normal, uvs[0], uvs[2], uvs[1]);
|
||||
return;
|
||||
}
|
||||
builder.addTriangle(texture, shading, pointA, pointB, pointC, normal, uvs[0], uvs[1], uvs[2]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,6 +133,9 @@ static model::Mesh load_mesh(
|
|||
if (flags == FLAG_ZLIB) {
|
||||
throw std::runtime_error("compression is not supported yet");
|
||||
}
|
||||
if (attributeCount <= 0) {
|
||||
throw std::runtime_error("mesh must have at least one attribute");
|
||||
}
|
||||
std::vector<VertexAttribute> attributes;
|
||||
for (int i = 0; i < attributeCount; i++) {
|
||||
attributes.push_back(load_attribute(reader));
|
||||
|
|
|
|||
|
|
@ -122,10 +122,16 @@ namespace {
|
|||
std::vector<Glyph>& glyphs
|
||||
) {
|
||||
int size = canvas.getWidth() / 16;
|
||||
|
||||
const size_t end = (pageid + 1) * 256;
|
||||
if (glyphs.size() < end) {
|
||||
glyphs.resize(end);
|
||||
}
|
||||
|
||||
for (int c = 0; c < 256; c++) {
|
||||
int codepoint = pageid << 8 | c;
|
||||
if (!renderGlyph(codepoint, bitmapDst)) {
|
||||
glyphs.push_back(Glyph {0, size / 2});
|
||||
glyphs[codepoint] = Glyph {0, size / 2};
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -133,13 +139,10 @@ namespace {
|
|||
|
||||
Glyph glyph {
|
||||
face->glyph->bitmap_top - size,
|
||||
static_cast<int>(face->glyph->advance.x >> 6)
|
||||
static_cast<int>(face->glyph->advance.x >> 6),
|
||||
face->glyph->bitmap_left
|
||||
};
|
||||
if (codepoint < glyphs.size()) {
|
||||
glyphs[codepoint] = std::move(glyph);
|
||||
} else {
|
||||
glyphs.push_back(std::move(glyph));
|
||||
}
|
||||
glyphs[codepoint] = glyph;
|
||||
}
|
||||
canvas.flipY();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,3 +86,4 @@ inline const std::string SOUNDS_FOLDER = "sounds";
|
|||
inline const std::string TEXTURES_FOLDER = "textures";
|
||||
|
||||
inline const std::string FONT_DEFAULT = "normal";
|
||||
inline const std::string DEFAULT_PROJECT_PATH = "project";
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using runnable = std::function<void()>;
|
|||
template<class T> using supplier = std::function<T()>;
|
||||
template<class T> using consumer = std::function<void(T)>;
|
||||
|
||||
using KeyCallback = std::function<bool()>;
|
||||
using InputCallback = std::function<bool()>;
|
||||
|
||||
// data sources
|
||||
using wstringsupplier = std::function<std::wstring()>;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,17 @@ void Engine::initialize(CoreParameters coreParameters) {
|
|||
logger.info() << "engine runs in headless mode";
|
||||
}
|
||||
if (params.projectFolder.empty()) {
|
||||
params.projectFolder = params.resFolder;
|
||||
auto userDefProjectPath =
|
||||
params.userFolder / std::filesystem::u8path(DEFAULT_PROJECT_PATH);
|
||||
auto resDefProjectPath =
|
||||
params.resFolder / std::filesystem::u8path(DEFAULT_PROJECT_PATH);
|
||||
if (std::filesystem::is_directory(userDefProjectPath)) {
|
||||
params.projectFolder = userDefProjectPath;
|
||||
} else if (std::filesystem::is_directory(resDefProjectPath)) {
|
||||
params.projectFolder = resDefProjectPath;
|
||||
} else {
|
||||
params.projectFolder = params.resFolder;
|
||||
}
|
||||
}
|
||||
paths = std::make_unique<EnginePaths>(params);
|
||||
loadProject();
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ class Time {
|
|||
uint64_t frame = 0;
|
||||
double lastTime = 0.0;
|
||||
double delta = 0.0;
|
||||
double timeMultiplier = 1.0;
|
||||
public:
|
||||
Time() {}
|
||||
|
||||
void update(double currentTime) {
|
||||
frame++;
|
||||
delta = currentTime - lastTime;
|
||||
delta = (currentTime - lastTime) * timeMultiplier;
|
||||
lastTime = currentTime;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -271,11 +271,9 @@ void LevelScreen::draw(float delta) {
|
|||
|
||||
if (!hud->isPause()) {
|
||||
scripting::on_entities_render(engine.getTime().getDelta());
|
||||
}
|
||||
renderer->renderFrame(ctx, camera, hudVisible, *postProcessing);
|
||||
if (!hud->isPause()) {
|
||||
scripting::on_frontend_render();
|
||||
}
|
||||
renderer->renderFrame(ctx, camera, hudVisible, *postProcessing);
|
||||
|
||||
if (hudVisible) {
|
||||
hud->draw(ctx);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@ MenuScreen::~MenuScreen() = default;
|
|||
void MenuScreen::onOpen() {
|
||||
engine.getContentControl().resetContent({});
|
||||
|
||||
auto menu = engine.getGUI().getMenu();
|
||||
auto& gui = engine.getGUI();
|
||||
gui.setActiveFrame(gui::GUI::CORE_MAIN);
|
||||
|
||||
auto menu = gui.getMenu();
|
||||
menu->reset();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ Font::Font(
|
|||
if (this->fontFile.has_value()) {
|
||||
if (auto fontPtr = this->fontFile->lock()) {
|
||||
monospace = fontPtr->isMonospace();
|
||||
if (monospace && this->glyphs.size() > '0' &&
|
||||
this->glyphs['0'].xAdvance > 0) {
|
||||
glyphInterval = this->glyphs['0'].xAdvance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -62,21 +66,13 @@ bool Font::isPrintableChar(uint codepoint) const {
|
|||
|
||||
int FontMetrics::calcWidth(std::wstring_view text, size_t offset, size_t length) const {
|
||||
auto font = this->font.has_value() ? this->font->lock() : nullptr;
|
||||
if (font == nullptr || font->isMonospace()) {
|
||||
return std::min(text.length() - offset, length) * _glyphInterval;
|
||||
if (font != nullptr) {
|
||||
return font->calcWidth(text, offset, length);
|
||||
}
|
||||
int totalWidth = 0;
|
||||
for (int i = offset; i < offset + length && i < text.length(); i++) {
|
||||
auto codepoint = text[i];
|
||||
if (!font->isPrintableChar(codepoint)) {
|
||||
totalWidth += _glyphInterval;
|
||||
} else if (auto glyph = font->getGlyph(codepoint)) {
|
||||
totalWidth += glyph->xAdvance;
|
||||
} else {
|
||||
totalWidth += _glyphInterval;
|
||||
}
|
||||
if (offset >= text.length()) {
|
||||
return 0;
|
||||
}
|
||||
return totalWidth;
|
||||
return std::min(text.length() - offset, length) * _glyphInterval;
|
||||
}
|
||||
|
||||
int Font::calcWidth(std::wstring_view text, size_t length) const {
|
||||
|
|
@ -84,7 +80,24 @@ int Font::calcWidth(std::wstring_view text, size_t length) const {
|
|||
}
|
||||
|
||||
int Font::calcWidth(std::wstring_view text, size_t offset, size_t length) const {
|
||||
return std::min(text.length()-offset, length) * glyphInterval;
|
||||
if (offset >= text.length()) {
|
||||
return 0;
|
||||
}
|
||||
size_t end = offset + std::min(text.length() - offset, length);
|
||||
int width = 0;
|
||||
for (size_t i = offset; i < end; i++) {
|
||||
width += getAdvance(text[i]);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
int Font::getAdvance(uint codepoint) const {
|
||||
if (isPrintableChar(codepoint)) {
|
||||
if (auto glyph = getGlyph(codepoint)) {
|
||||
return glyph->xAdvance;
|
||||
}
|
||||
}
|
||||
return glyphInterval;
|
||||
}
|
||||
|
||||
static inline void draw_glyph(
|
||||
|
|
@ -176,7 +189,7 @@ static inline void draw_text(
|
|||
int y = 0;
|
||||
bool hasLines = false;
|
||||
|
||||
float baseAdvance = glm::length(right);
|
||||
const float cellAdvance = interval * font.getLineHeight();
|
||||
|
||||
do {
|
||||
for (size_t i = 0; i < text.length(); i++) {
|
||||
|
|
@ -193,12 +206,11 @@ static inline void draw_text(
|
|||
continue;
|
||||
}
|
||||
int yOffset = 0;
|
||||
float advance = baseAdvance;
|
||||
int xOffset = 0;
|
||||
float advance = font.getAdvance(c) / cellAdvance;
|
||||
if (auto glyph = font.getGlyph(c)) {
|
||||
yOffset = glyph->yOffset;
|
||||
advance = glyph->xAdvance /
|
||||
static_cast<float>(font.getLineHeight()) * 2.0f *
|
||||
baseAdvance;
|
||||
xOffset = glyph->xOffset;
|
||||
}
|
||||
uint charpage = c >> 8;
|
||||
if (charpage == page){
|
||||
|
|
@ -207,7 +219,7 @@ static inline void draw_text(
|
|||
batch,
|
||||
pos,
|
||||
glm::vec2(
|
||||
x,
|
||||
x + xOffset / cellAdvance,
|
||||
y - yOffset * (is3d ? -1 : 1) /
|
||||
static_cast<float>(font.getLineHeight())
|
||||
),
|
||||
|
|
@ -221,7 +233,7 @@ static inline void draw_text(
|
|||
else if (charpage > page && charpage < next){
|
||||
next = charpage;
|
||||
}
|
||||
x += advance / baseAdvance;
|
||||
x += advance;
|
||||
}
|
||||
page = next;
|
||||
next = MAX_CODEPAGES;
|
||||
|
|
@ -325,27 +337,26 @@ std::unique_ptr<Font> Font::createBitmapFont(
|
|||
return std::make_unique<Font>(std::move(textures), std::move(glyphs), res, 4);
|
||||
}
|
||||
|
||||
const Glyph* Font::getGlyph(int codepoint) {
|
||||
const Glyph* Font::getGlyph(int codepoint) const {
|
||||
if (codepoint < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
if (codepoint < glyphs.size()) {
|
||||
const int codepage = codepoint >> 8;
|
||||
if (codepoint < glyphs.size() &&
|
||||
(!fontFile.has_value() ||
|
||||
(codepage < pages.size() && pages[codepage]))) {
|
||||
return &glyphs.at(codepoint);
|
||||
}
|
||||
if (!this->fontFile.has_value() || this->fontFile->expired()) {
|
||||
return nullptr;
|
||||
}
|
||||
int codepage = codepoint >> 8;
|
||||
if (codepage >= 1024) {
|
||||
return nullptr;
|
||||
}
|
||||
if (glyphs.size() < (codepage << 8)) {
|
||||
glyphs.resize(codepage << 8);
|
||||
}
|
||||
auto fontFile = this->fontFile->lock();
|
||||
if (pages.size() <= codepage) {
|
||||
pages.resize(codepage);
|
||||
pages.resize(codepage + 1);
|
||||
}
|
||||
pages.push_back(fontFile->renderPage(codepage, glyphs, lineHeight));
|
||||
pages[codepage] = fontFile->renderPage(codepage, glyphs, lineHeight);
|
||||
return &glyphs.at(codepoint);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ namespace vector_fonts {
|
|||
struct Glyph {
|
||||
int yOffset;
|
||||
int xAdvance;
|
||||
int xOffset = 0;
|
||||
};
|
||||
|
||||
class Font {
|
||||
|
|
@ -56,6 +57,10 @@ public:
|
|||
/// @return pixel width of the substring
|
||||
int calcWidth(std::wstring_view text, size_t offset, size_t length) const;
|
||||
|
||||
/// @brief Get the horizontal advance of a character in pixels
|
||||
/// @param codepoint character unicode codepoint
|
||||
int getAdvance(uint codepoint) const;
|
||||
|
||||
/// @brief Check if character is visible (non-whitespace)
|
||||
/// @param codepoint character unicode codepoint
|
||||
bool isPrintableChar(uint codepoint) const;
|
||||
|
|
@ -86,7 +91,7 @@ public:
|
|||
return {std::nullopt, lineHeight, yoffset, glyphInterval};
|
||||
}
|
||||
|
||||
const Glyph* getGlyph(int codepoint);
|
||||
const Glyph* getGlyph(int codepoint) const;
|
||||
|
||||
static std::unique_ptr<Font> createBitmapFont(
|
||||
std::vector<std::unique_ptr<ImageData>> pages
|
||||
|
|
@ -96,7 +101,7 @@ private:
|
|||
int yoffset;
|
||||
int glyphInterval;
|
||||
bool monospace = true;
|
||||
std::vector<std::unique_ptr<Texture>> pages;
|
||||
std::vector<Glyph> glyphs;
|
||||
mutable std::vector<std::unique_ptr<Texture>> pages;
|
||||
mutable std::vector<Glyph> glyphs;
|
||||
std::optional<std::weak_ptr<vector_fonts::FontFile>> fontFile;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -113,8 +113,6 @@ static inline auto shader_deleter = [](GLuint* shader) {
|
|||
delete shader;
|
||||
};
|
||||
|
||||
inline const uint GL_LOG_LEN = 512;
|
||||
|
||||
// shader should be deleted after shader program linking
|
||||
using glshader = std::unique_ptr<GLuint, decltype(shader_deleter)>;
|
||||
|
||||
|
|
@ -125,12 +123,14 @@ glshader compile_shader(GLenum type, const GLchar* source, const std::string& fi
|
|||
glCompileShader(shader);
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
|
||||
if (!success) {
|
||||
GLchar infoLog[GL_LOG_LEN];
|
||||
glGetShaderInfoLog(shader, GL_LOG_LEN, nullptr, infoLog);
|
||||
GLint infoLogLength;
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
auto infoLog = std::make_unique<GLchar[]>(infoLogLength);
|
||||
glGetShaderInfoLog(shader, infoLogLength, nullptr, infoLog.get());
|
||||
glDeleteShader(shader);
|
||||
throw std::runtime_error(
|
||||
"vertex shader compilation failed (" + file + "):\n" +
|
||||
std::string(infoLog)
|
||||
std::string(infoLog.get(), infoLogLength)
|
||||
);
|
||||
}
|
||||
return glshader(new GLuint(shader), shader_deleter); //-V508
|
||||
|
|
@ -172,10 +172,14 @@ static GLuint compile_program(
|
|||
glGetProgramiv(program, GL_LINK_STATUS, &success);
|
||||
|
||||
if (!success) {
|
||||
GLchar infoLog[GL_LOG_LEN];
|
||||
glGetProgramInfoLog(program, GL_LOG_LEN, nullptr, infoLog);
|
||||
GLint infoLogLength;
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
auto infoLog = std::make_unique<GLchar[]>(infoLogLength);
|
||||
glGetProgramInfoLog(program, infoLogLength, nullptr, infoLog.get());
|
||||
glDeleteProgram(program);
|
||||
throw std::runtime_error(
|
||||
"shader program linking failed:\n" + std::string(infoLog)
|
||||
"shader program linking failed:\n" +
|
||||
std::string(infoLog.get(), infoLogLength)
|
||||
);
|
||||
}
|
||||
return program;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ static debug::Logger logger("chunks-render");
|
|||
|
||||
size_t ChunksRenderer::visibleChunks = 0;
|
||||
|
||||
static constexpr inline size_t MAX_CHUNKS_ENQUEUED_IN_FRAME = 4;
|
||||
static constexpr inline size_t MAX_CHUNKS_ENQUEUED_IN_FRAME = 64;
|
||||
|
||||
class RendererWorker : public util::Worker<RendererJob, RendererResult> {
|
||||
BlocksRenderer renderer;
|
||||
|
|
@ -197,8 +197,7 @@ void ChunksRenderer::update() {
|
|||
|
||||
int loadDistance = settings.chunks.loadDistance.get();
|
||||
|
||||
const int topN = 10;
|
||||
int top = std::min<int>(meshBuildQueue.size(), topN);
|
||||
int top = std::min<int>(meshBuildQueue.size(), MAX_CHUNKS_ENQUEUED_IN_FRAME);
|
||||
for (int i = 0; i < top; i++) {
|
||||
glm::ivec2 offset = meshBuildQueue[i];
|
||||
size_t index =
|
||||
|
|
|
|||
|
|
@ -8,6 +8,22 @@
|
|||
#include "debug/Logger.hpp"
|
||||
#include "core_defs.hpp"
|
||||
|
||||
inline constexpr uint FACE_WEST = FACE_MX;
|
||||
inline constexpr uint FACE_EAST = FACE_PX;
|
||||
inline constexpr uint FACE_BOTTOM = FACE_MY;
|
||||
inline constexpr uint FACE_TOP = FACE_PY;
|
||||
inline constexpr uint FACE_SOUTH = FACE_MZ;
|
||||
inline constexpr uint FACE_NORTH = FACE_PZ;
|
||||
|
||||
inline constexpr std::array<uint8_t, 6> LEGACY_CUSTOM_MODEL_TEXTURE_ORDER = {
|
||||
FACE_WEST,
|
||||
FACE_EAST,
|
||||
FACE_BOTTOM,
|
||||
FACE_TOP,
|
||||
FACE_SOUTH,
|
||||
FACE_NORTH,
|
||||
};
|
||||
|
||||
static debug::Logger logger("models-generator");
|
||||
|
||||
static void configure_textures(
|
||||
|
|
@ -49,6 +65,21 @@ static inline UVRegion get_region_for(
|
|||
return texreg.region;
|
||||
}
|
||||
|
||||
static inline void map_legacy_box_textures(
|
||||
const std::vector<std::string>& modelTextures,
|
||||
size_t offset,
|
||||
UVRegion (&boxtexfaces)[6],
|
||||
const Assets& assets
|
||||
) {
|
||||
for (size_t i = 0; i < 6; ++i) {
|
||||
const auto legacyFace = LEGACY_CUSTOM_MODEL_TEXTURE_ORDER[i];
|
||||
boxtexfaces[legacyFace] = get_region_for(modelTextures[offset + i], assets);
|
||||
}
|
||||
boxtexfaces[FACE_TOP].scale(glm::vec2(-1, 1));
|
||||
boxtexfaces[FACE_EAST].scale(glm::vec2(-1, 1));
|
||||
boxtexfaces[FACE_NORTH].scale(glm::vec2(-1, 1));
|
||||
}
|
||||
|
||||
void ModelsGenerator::prepareModel(
|
||||
Assets& assets, const Block& def, Variant& variant, uint8_t variantId
|
||||
) {
|
||||
|
|
@ -120,16 +151,8 @@ model::Model ModelsGenerator::fromCustom(
|
|||
for (size_t i = 0; i < modelBoxes.size(); i++) {
|
||||
auto& mesh = model.addMesh("blocks:");
|
||||
mesh.shading = lighting;
|
||||
UVRegion boxtexfaces[6] = {
|
||||
get_region_for(modelTextures[i * 6 + 5], assets),
|
||||
get_region_for(modelTextures[i * 6 + 4], assets),
|
||||
get_region_for(modelTextures[i * 6 + 3], assets),
|
||||
get_region_for(modelTextures[i * 6 + 2], assets),
|
||||
get_region_for(modelTextures[i * 6 + 1], assets),
|
||||
get_region_for(modelTextures[i * 6 + 0], assets)
|
||||
};
|
||||
boxtexfaces[2].scale(glm::vec2(-1));
|
||||
boxtexfaces[5].scale(glm::vec2(-1, 1));
|
||||
UVRegion boxtexfaces[6] = {};
|
||||
map_legacy_box_textures(modelTextures, i * 6, boxtexfaces, assets);
|
||||
|
||||
bool enabled[6] {1,1,1,1,1,1};
|
||||
mesh.addBox(
|
||||
|
|
@ -232,17 +255,14 @@ model::Model ModelsGenerator::loadCustomBlockModel(
|
|||
modelBoxes.push_back(modelbox);
|
||||
|
||||
if (boxarr.size() == 7) {
|
||||
for (uint j = 6; j < 12; j++) {
|
||||
modelTextures.emplace_back(boxarr[6].asString());
|
||||
}
|
||||
const auto texture = boxarr[6].asString();
|
||||
modelTextures.insert(modelTextures.end(), 6, texture);
|
||||
} else if (boxarr.size() == 12) {
|
||||
for (uint j = 6; j < 12; j++) {
|
||||
modelTextures.emplace_back(boxarr[j].asString());
|
||||
}
|
||||
} else {
|
||||
for (uint j = 6; j < 12; j++) {
|
||||
modelTextures.emplace_back("notfound");
|
||||
}
|
||||
modelTextures.insert(modelTextures.end(), 6, "notfound");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ WorldRenderer::WorldRenderer(
|
|||
debugLines = std::make_unique<DebugLinesRenderer>(level);
|
||||
cloudsRenderer = std::make_unique<CloudsRenderer>();
|
||||
|
||||
keepAlive(observe_setting(settings.graphics.enableFog, dirtySettings));
|
||||
keepAlive(observe_setting(settings.graphics.advancedRender, dirtySettings));
|
||||
keepAlive(observe_setting(settings.graphics.shadowsQuality, dirtySettings));
|
||||
keepAlive(observe_setting(settings.graphics.ssao, dirtySettings));
|
||||
|
|
@ -156,10 +157,12 @@ void WorldRenderer::refreshSettings() {
|
|||
gbufferPipeline = graphics.advancedRender.get();
|
||||
|
||||
int shadowsQuality = graphics.shadowsQuality.get() * gbufferPipeline;
|
||||
bool enableFog = graphics.enableFog.get();
|
||||
shadowMapping->setQuality(shadowsQuality);
|
||||
|
||||
std::vector<std::string> defines;
|
||||
if (shadowsQuality != 0) defines.emplace_back("ENABLE_SHADOWS");
|
||||
if (enableFog) defines.emplace_back("ENABLE_FOG");
|
||||
if (graphics.ssao.get()) defines.emplace_back("ENABLE_SSAO");
|
||||
if (gbufferPipeline) defines.emplace_back("ADVANCED_RENDER");
|
||||
|
||||
|
|
|
|||
|
|
@ -25,14 +25,25 @@ void InlineFrame::setDocument(const std::shared_ptr<UiDocument>& document) {
|
|||
if (document == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto newRoot = document->getRoot();
|
||||
if (newRoot->hasParent()) {
|
||||
return;
|
||||
}
|
||||
this->document = document;
|
||||
this->root = document->getRoot();
|
||||
this->root = std::move(newRoot);
|
||||
add(root);
|
||||
|
||||
root->setSize(size);
|
||||
|
||||
gui.postRunnable([this]() {
|
||||
scripting::on_ui_open(*this->document, {});
|
||||
gui.postRunnable([weak = weak_from_this(), document]() {
|
||||
auto node = weak.lock();
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (static_cast<InlineFrame&>(*node).document != document) {
|
||||
return;
|
||||
}
|
||||
scripting::on_ui_open(*document, {});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
if (size.x <= 0 || size.y <= 0) {
|
||||
return;
|
||||
}
|
||||
fbo = std::make_unique<Framebuffer>(size.x, size.y);
|
||||
fbo = std::make_unique<Framebuffer>(size.x, size.y, true);
|
||||
}
|
||||
fbo->resize(size.x, size.y);
|
||||
{
|
||||
|
|
@ -130,7 +130,13 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
ctx.setViewport({size.x, size.y});
|
||||
ctx.setDepthTest(true);
|
||||
ctx.setCullFace(true);
|
||||
GLfloat clearColor[4];
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
display::clear();
|
||||
glClearColor(
|
||||
clearColor[0], clearColor[1], clearColor[2], clearColor[3]
|
||||
);
|
||||
|
||||
auto& ui3dShader = assets.require<Shader>("ui3d");
|
||||
ui3dShader.use();
|
||||
|
|
|
|||
|
|
@ -255,9 +255,9 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
// drawing caret here
|
||||
if (isFocused() && editable && static_cast<int>((time - caretLastMove) * 2) % 2 == 0) {
|
||||
uint line = label->getLineByTextIndex(caret);
|
||||
auto linestart = label->getTextLineOffset(line);
|
||||
uint lcaret = caret - label->getTextLineOffset(line);
|
||||
int width = rawTextCache.metrics.calcWidth(input.substr(linestart), 0, lcaret);
|
||||
size_t lineStart = label->getTextLineOffset(line);
|
||||
size_t lineCaret = caret - lineStart;
|
||||
int width = rawTextCache.metrics.calcWidth(input, lineStart, lineCaret);
|
||||
|
||||
batch->rect(
|
||||
lcoord.x + width,
|
||||
|
|
@ -275,11 +275,13 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
uint endLine = label->getLineByTextIndex(selectionEnd);
|
||||
|
||||
batch->setColor(glm::vec4(0.8f, 0.9f, 1.0f, 0.25f));
|
||||
size_t startLineOffset = label->getTextLineOffset(startLine);
|
||||
size_t endLineOffset = label->getTextLineOffset(endLine);
|
||||
int start = rawTextCache.metrics.calcWidth(
|
||||
labelText, 0, selectionStart - label->getTextLineOffset(startLine)
|
||||
labelText, startLineOffset, selectionStart - startLineOffset
|
||||
);
|
||||
int end = rawTextCache.metrics.calcWidth(
|
||||
labelText, 0, selectionEnd - label->getTextLineOffset(endLine)
|
||||
labelText, endLineOffset, selectionEnd - endLineOffset
|
||||
);
|
||||
int lineY = label->getLineYOffset(startLine);
|
||||
|
||||
|
|
@ -352,6 +354,11 @@ void TextBox::draw(const DrawContext& pctx, const Assets& assets) {
|
|||
}
|
||||
|
||||
void TextBox::drawBackground(const DrawContext& pctx, const Assets& assets) {
|
||||
if (lineNumbersLabel->getFontName() != label->getFontName()) {
|
||||
lineNumbersLabel->setFontName(label->getFontName());
|
||||
}
|
||||
lineNumbersLabel->setLineInterval(label->getLineInterval());
|
||||
|
||||
auto font = assets.getShared<Font>(label->getFontName());
|
||||
if (font != nullptr) {
|
||||
rawTextCache.prepare(font, font->getMetrics(), label->getSize().x);
|
||||
|
|
@ -681,13 +688,19 @@ int TextBox::calcIndexAt(int x, int y) const {
|
|||
uint line = label->getLineByYOffset(y - lcoord.y);
|
||||
line = std::min(line, label->getLinesNumber() - 1);
|
||||
size_t lineLength = getLineLength(line);
|
||||
size_t lineStart = label->getTextLineOffset(line);
|
||||
uint offset = 0;
|
||||
while (lcoord.x + rawTextCache.metrics.calcWidth(labelText, 0, offset) < x &&
|
||||
offset < lineLength - 1) {
|
||||
while (offset < lineLength - 1) {
|
||||
int width = rawTextCache.metrics.calcWidth(
|
||||
labelText, lineStart, offset
|
||||
);
|
||||
if (lcoord.x + width >= x) {
|
||||
break;
|
||||
}
|
||||
offset++;
|
||||
}
|
||||
return std::min(
|
||||
offset + label->getTextLineOffset(line), labelText.length()
|
||||
offset + lineStart, labelText.length()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1224,9 +1237,12 @@ void TextBox::setCaret(size_t position) {
|
|||
offset -= getSize().y;
|
||||
scrolled(-glm::ceil(offset / static_cast<double>(scrollStep) + 0.5f));
|
||||
}
|
||||
int lcaret = caret - rawTextCache.getTextLineOffset(line);
|
||||
int realoffset = rawTextCache.metrics.calcWidth(labelText, 0, lcaret) -
|
||||
static_cast<int>(textOffset);
|
||||
size_t lineStart = rawTextCache.getTextLineOffset(line);
|
||||
size_t lineCaret = caret - lineStart;
|
||||
int caretWidth = rawTextCache.metrics.calcWidth(
|
||||
labelText, lineStart, lineCaret
|
||||
);
|
||||
int realoffset = caretWidth - static_cast<int>(textOffset);
|
||||
|
||||
if (realoffset - width > 0) {
|
||||
setTextOffset(textOffset + realoffset - width);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ bool UINode::isHover() const {
|
|||
return hover;
|
||||
}
|
||||
|
||||
bool UINode::hasParent() const {
|
||||
return parent != nullptr;
|
||||
}
|
||||
|
||||
void UINode::setParent(UINode* node) {
|
||||
parent = node;
|
||||
}
|
||||
|
|
@ -376,14 +380,14 @@ void UINode::setGravity(Gravity gravity) {
|
|||
}
|
||||
}
|
||||
|
||||
bool UINode::isSubnodeOf(const UINode* node) {
|
||||
bool UINode::isDescendantOf(const UINode* node) {
|
||||
if (parent == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (parent == node) {
|
||||
return true;
|
||||
}
|
||||
return parent->isSubnodeOf(node);
|
||||
return parent->isDescendantOf(node);
|
||||
}
|
||||
|
||||
void UINode::getIndices(
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ namespace gui {
|
|||
void setMouseOver(bool flag);
|
||||
|
||||
virtual void setParent(UINode* node);
|
||||
bool hasParent() const;
|
||||
UINode* getParent() const;
|
||||
std::shared_ptr<UINode> getParentShared() const;
|
||||
|
||||
|
|
@ -290,7 +291,7 @@ namespace gui {
|
|||
|
||||
virtual void setGravity(Gravity gravity);
|
||||
|
||||
bool isSubnodeOf(const UINode* node);
|
||||
bool isDescendantOf(const UINode* node);
|
||||
|
||||
/// @brief collect all nodes having id
|
||||
static void getIndices(
|
||||
|
|
|
|||
|
|
@ -180,6 +180,10 @@ std::unique_ptr<io::PathsGenerator> io::MemoryDevice::list(std::string_view path
|
|||
}
|
||||
|
||||
io::MemoryDevice::Dir* io::MemoryDevice::createDir(std::string path) {
|
||||
const auto& found = nodes.find(path);
|
||||
if (found != nodes.end()) {
|
||||
return found->second.get_if<Dir>();
|
||||
}
|
||||
io::path filePath = path;
|
||||
io::path parent = filePath.parent();
|
||||
auto parentDir = getDir(parent.string());
|
||||
|
|
@ -195,6 +199,15 @@ io::MemoryDevice::Dir* io::MemoryDevice::createDir(std::string path) {
|
|||
io::MemoryDevice::Node* io::MemoryDevice::createFile(
|
||||
std::string path, util::Buffer<char>&& content
|
||||
) {
|
||||
const auto& found = nodes.find(path);
|
||||
if (found != nodes.end()) {
|
||||
auto& node = found->second;
|
||||
if (!node.holds_alternative<File>()) {
|
||||
return nullptr;
|
||||
}
|
||||
node.data = File {std::move(content)};
|
||||
return &node;
|
||||
}
|
||||
io::path filePath = path;
|
||||
io::path parent = filePath.parent();
|
||||
auto dir = getDir(parent.string());
|
||||
|
|
|
|||
|
|
@ -20,10 +20,29 @@ StdfsDevice::StdfsDevice(fs::path root, bool createDirectory)
|
|||
<< ": " << ec.message();
|
||||
}
|
||||
}
|
||||
absoluteRoot = fs::absolute(this->root).lexically_normal();
|
||||
if (!absoluteRoot.has_filename() && absoluteRoot.has_relative_path()) {
|
||||
absoluteRoot = absoluteRoot.parent_path();
|
||||
}
|
||||
}
|
||||
|
||||
fs::path StdfsDevice::resolve(std::string_view path) {
|
||||
return root / fs::u8path(io::path(std::string(path)).normalized().string());
|
||||
if (path.find_first_of(std::string_view("\0\\:", 3)) != std::string_view::npos) {
|
||||
throw std::runtime_error("invalid path");
|
||||
}
|
||||
fs::path rel = fs::u8path(io::path(std::string(path)).normalized().string());
|
||||
if (rel.has_root_name() || rel.has_root_directory()) {
|
||||
throw std::runtime_error("absolute paths are not allowed");
|
||||
}
|
||||
fs::path full = (absoluteRoot / rel).lexically_normal();
|
||||
fs::path inside = full.lexically_relative(absoluteRoot);
|
||||
if (inside.empty() || *inside.begin() == "..") {
|
||||
throw std::runtime_error("path escapes device root");
|
||||
}
|
||||
if (inside == ".") {
|
||||
return absoluteRoot;
|
||||
}
|
||||
return full;
|
||||
}
|
||||
|
||||
std::unique_ptr<std::ostream> StdfsDevice::write(std::string_view path) {
|
||||
|
|
@ -90,17 +109,32 @@ bool StdfsDevice::mkdirs(std::string_view path) {
|
|||
|
||||
bool StdfsDevice::remove(std::string_view path) {
|
||||
auto resolved = resolve(path);
|
||||
return fs::remove(resolved);
|
||||
if (resolved == absoluteRoot) {
|
||||
throw std::runtime_error("unable to remove device root");
|
||||
}
|
||||
std::error_code ec;
|
||||
bool removed = fs::remove(resolved, ec);
|
||||
if (ec) {
|
||||
logger.error() << "error removing " << resolved << ": " << ec.message();
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
uint64_t StdfsDevice::removeAll(std::string_view path) {
|
||||
auto resolved = resolve(path);
|
||||
if (fs::exists(resolved)) {
|
||||
logger.info() << "removeAll " << resolved;
|
||||
return fs::remove_all(resolved);
|
||||
} else {
|
||||
if (resolved == absoluteRoot) {
|
||||
throw std::runtime_error("unable to remove device root");
|
||||
}
|
||||
std::error_code ec;
|
||||
auto removed = fs::remove_all(resolved, ec);
|
||||
if (ec) {
|
||||
logger.error() << "error removing " << resolved << ": " << ec.message();
|
||||
return 0;
|
||||
}
|
||||
if (removed > 0) {
|
||||
logger.info() << "removeAll " << resolved << ": " << removed;
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
class StdfsPathsGenerator : public PathsGenerator {
|
||||
|
|
|
|||
|
|
@ -23,5 +23,6 @@ namespace io {
|
|||
std::unique_ptr<PathsGenerator> list(std::string_view path) override;
|
||||
private:
|
||||
std::filesystem::path root;
|
||||
std::filesystem::path absoluteRoot;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,11 +58,20 @@ namespace {
|
|||
}
|
||||
|
||||
uint32_t to_ms_dos_timestamp(const file_time_type& fileTime) {
|
||||
// 1980-01-01 00:00, the earliest MS-DOS date
|
||||
constexpr uint32_t DOS_EPOCH = (0 << 9 | 1 << 5 | 1) << 16;
|
||||
if (fileTime == file_time_type::min()) {
|
||||
return DOS_EPOCH;
|
||||
}
|
||||
auto timePoint = time_point_cast<system_clock::duration>(
|
||||
fileTime - file_time_type::clock::now() + system_clock::now()
|
||||
);
|
||||
std::time_t timeT = system_clock::to_time_t(timePoint);
|
||||
std::tm tm = *std::localtime(&timeT);
|
||||
const std::tm* tmPtr = std::localtime(&timeT);
|
||||
if (tmPtr == nullptr || tmPtr->tm_year < 80) {
|
||||
return DOS_EPOCH;
|
||||
}
|
||||
const std::tm& tm = *tmPtr;
|
||||
uint16_t date = (tm.tm_year - 80) << 9 | (tm.tm_mon + 1) << 5 | tm.tm_mday;
|
||||
uint16_t time = (tm.tm_hour << 11) | (tm.tm_min << 5) | (tm.tm_sec / 2);
|
||||
return (date << 16) | time;
|
||||
|
|
@ -173,7 +182,12 @@ ZipFileDevice::ZipFileDevice(
|
|||
entries[entry.fileName] = std::move(entry);
|
||||
}
|
||||
|
||||
for (auto& [name, _] : entries) {
|
||||
std::vector<std::string> names;
|
||||
names.reserve(entries.size());
|
||||
for (const auto& [name, _] : entries) {
|
||||
names.push_back(name);
|
||||
}
|
||||
for (const auto& name : names) {
|
||||
io::path path = name;
|
||||
|
||||
while (!(path = path.parent()).pathPart().empty()) {
|
||||
|
|
@ -184,7 +198,6 @@ ZipFileDevice::ZipFileDevice(
|
|||
entry.isDirectory = true;
|
||||
entries[path.pathPart()] = entry;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (auto& [_, entry] : entries) {
|
||||
|
|
@ -253,6 +266,9 @@ file_time_type ZipFileDevice::lastWriteTime(std::string_view path) {
|
|||
}
|
||||
|
||||
bool ZipFileDevice::exists(std::string_view path) {
|
||||
if (path.empty()) {
|
||||
return true;
|
||||
}
|
||||
return entries.find(std::string(path)) != entries.end();
|
||||
}
|
||||
|
||||
|
|
@ -441,7 +457,11 @@ static size_t write_zip(
|
|||
void io::write_zip(const path& folder, const path& file) {
|
||||
ByteBuilder central_dir;
|
||||
auto out = io::write(file);
|
||||
size_t entries = write_zip(folder.pathPart(), folder, *out, central_dir);
|
||||
auto root = folder.pathPart();
|
||||
if (!root.empty() && root.back() != '/') {
|
||||
root += '/';
|
||||
}
|
||||
size_t entries = write_zip(root, folder, *out, central_dir);
|
||||
|
||||
size_t central_dir_offset = out->tellp();
|
||||
out->write(reinterpret_cast<const char*>(central_dir.data()), central_dir.size());
|
||||
|
|
|
|||
|
|
@ -152,6 +152,9 @@ std::vector<ubyte> io::read_bytes(const path& filename) {
|
|||
std::string io::read_string(const path& filename) {
|
||||
size_t size;
|
||||
auto bytes = read_bytes(filename, size);
|
||||
if (bytes == nullptr) {
|
||||
throw std::runtime_error("could not read file " + filename.string());
|
||||
}
|
||||
return std::string((const char*)bytes.get(), size);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,19 @@ protected:
|
|||
return c;
|
||||
}
|
||||
|
||||
pos_type seekoff(
|
||||
off_type off,
|
||||
std::ios_base::seekdir way,
|
||||
std::ios_base::openmode mode = std::ios_base::out
|
||||
) override {
|
||||
// only position query (tellp) is supported
|
||||
if (off == 0 && way == std::ios_base::cur &&
|
||||
(mode & std::ios_base::out)) {
|
||||
return pos_type(off_type(size()));
|
||||
}
|
||||
return pos_type(off_type(-1));
|
||||
}
|
||||
|
||||
std::streamsize xsputn(const char* s, std::streamsize count) override {
|
||||
const std::streamsize avail = epptr() - pptr();
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) {
|
|||
builder.add("padding", &settings.chunks.padding);
|
||||
|
||||
builder.addSection("graphics");
|
||||
builder.add("enable-fog", &settings.graphics.enableFog);
|
||||
builder.add("fog-curve", &settings.graphics.fogCurve);
|
||||
builder.add("backlight", &settings.graphics.backlight);
|
||||
builder.add("dense-render", &settings.graphics.denseRender);
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ void CameraControl::updateMouse(PlayerInput& input, int windowHeight) {
|
|||
glm::vec3 CameraControl::updateCameraShaking(
|
||||
const Hitbox& hitbox, float delta
|
||||
) {
|
||||
delta = glm::min(delta, 0.1f);
|
||||
|
||||
glm::vec3 offset {};
|
||||
const float k = CAM_SHAKE_DELTA_K;
|
||||
const float ov = CAM_SHAKE_OFFSET_Y;
|
||||
|
|
|
|||
|
|
@ -165,6 +165,13 @@ static int l_container_set_interval(lua::State* L) {
|
|||
static int l_move_into(lua::State* L) {
|
||||
auto node = get_document_node(L, 1);
|
||||
auto dest = get_document_node(L, 2);
|
||||
if (dest.node == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (dest.node->isDescendantOf(node.node.get())) {
|
||||
luaL_error(L, "unable to move element to its descendant");
|
||||
return 0;
|
||||
}
|
||||
UINode::moveInto(
|
||||
node.node, std::dynamic_pointer_cast<Container>(dest.node)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -44,10 +44,13 @@ static int l_add_callback(lua::State* L) {
|
|||
auto& input = engine->getInput();
|
||||
|
||||
if (pos != std::string::npos) {
|
||||
std::string prefix = bindname.substr(0, pos);
|
||||
auto prefix = std::string_view(bindname).substr(0, pos);
|
||||
if (prefix == "key") {
|
||||
auto key = input_util::keycode_from(bindname.substr(pos + 1));
|
||||
handler = input.addKeyCallback(key, actual_callback);
|
||||
} else if (prefix == "mouse") {
|
||||
auto mouse = input_util::mousecode_from(bindname.substr(pos + 1));
|
||||
handler = input.addMouseCallback(mouse, actual_callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -266,8 +266,10 @@ static int l_peek(lua::State* L, network::Network& network) {
|
|||
static int l_available(lua::State* L, network::Network& network) {
|
||||
u64id_t id = lua::tointeger(L, 1);
|
||||
|
||||
if (auto connection = network.getConnection(id, false)) {
|
||||
return lua::pushinteger(L, dynamic_cast<network::TcpConnection*>(connection)->available());
|
||||
if (auto connection = dynamic_cast<network::ReadableConnection*>(
|
||||
network.getConnection(id, false)
|
||||
)) {
|
||||
return lua::pushinteger(L, connection->available());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static int push_xml(lua::State* L, const xml::xmlelement& elem) {
|
|||
}
|
||||
|
||||
static std::unique_ptr<xml::xmlelement> toxml(lua::State* L) {
|
||||
lua::getfield(L, TAG_ATTR);
|
||||
lua::requirefield(L, TAG_ATTR);
|
||||
auto tag = lua::require_lstring(L, -1);
|
||||
lua::pop(L);
|
||||
|
||||
|
|
@ -39,6 +39,13 @@ static std::unique_ptr<xml::xmlelement> toxml(lua::State* L) {
|
|||
|
||||
for (int i = 0; i < length; i++) {
|
||||
lua::rawgeti(L, i + 1);
|
||||
if (lua::isstring(L, -1)) {
|
||||
auto textElement = std::make_unique<xml::xmlelement>("#");
|
||||
textElement->set("#", std::string(lua::require_lstring(L, -1)));
|
||||
elem->add(std::move(textElement));
|
||||
lua::pop(L);
|
||||
continue;
|
||||
}
|
||||
elem->add(toxml(L));
|
||||
lua::pop(L);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,6 +196,10 @@ void lua::init_state(State* L, StateType stateType) {
|
|||
if (stateType == StateType::GENERATOR) {
|
||||
pushnil(L);
|
||||
setglobal(L, "ffi");
|
||||
|
||||
static const char* removed_debug[] {
|
||||
"getregistry", "getupvalue", "setupvalue", "getinfo", nullptr};
|
||||
remove_lib_funcs(L, "debug", removed_debug);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ runnable lua::create_runnable(State* L) {
|
|||
};
|
||||
}
|
||||
|
||||
KeyCallback lua::create_simple_handler(State* L) {
|
||||
InputCallback lua::create_simple_handler(State* L) {
|
||||
auto funcptr = create_lambda_handler(L);
|
||||
return [=]() -> bool {
|
||||
if (!get_from_registry(L, LAMBDAS_TABLE, *funcptr, false)) {
|
||||
|
|
|
|||
|
|
@ -665,7 +665,7 @@ namespace lua {
|
|||
}
|
||||
|
||||
runnable create_runnable(lua::State*);
|
||||
KeyCallback create_simple_handler(lua::State*);
|
||||
InputCallback create_simple_handler(lua::State*);
|
||||
scripting::common_func create_lambda(lua::State*);
|
||||
scripting::common_func create_lambda_nothrow(lua::State*);
|
||||
|
||||
|
|
|
|||
|
|
@ -99,14 +99,21 @@ template <typename T, T(tovalueFunc)(lua::State*, int)>
|
|||
std::function<T()> create_supplier(
|
||||
const scriptenv& env, const std::string& src, const std::string& file
|
||||
) {
|
||||
return [=]() {
|
||||
return [=, errorLogged = false]() mutable {
|
||||
lua::stackguard guard(lua::get_main_state());
|
||||
if (auto L = process_callback(env, src, file)) {
|
||||
if (lua::isfunction(L, -1)) {
|
||||
lua::call_nothrow(L, 0);
|
||||
if (lua::isfunction(L, -1) && !lua::call_nothrow(L, 0)) {
|
||||
return T {};
|
||||
}
|
||||
try {
|
||||
return tovalueFunc(L, -1);
|
||||
} catch (const std::exception& err) {
|
||||
if (!errorLogged) {
|
||||
logger.error() << "supplier " << util::quote(src) << ": "
|
||||
<< err.what();
|
||||
errorLogged = true;
|
||||
}
|
||||
}
|
||||
auto str = tovalueFunc(L, -1);
|
||||
lua::pop(L);
|
||||
return str;
|
||||
}
|
||||
return T {};
|
||||
};
|
||||
|
|
@ -158,16 +165,33 @@ int_array_consumer scripting::create_int_array_consumer(
|
|||
vec2supplier scripting::create_vec2_supplier(
|
||||
const scriptenv& env, const std::string& src, const std::string& file
|
||||
) {
|
||||
return [=]() {
|
||||
if (auto L = process_callback(env, src, file)) {
|
||||
if (lua::isfunction(L, -1)) {
|
||||
lua::call_nothrow(L, 0);
|
||||
return [=, errorLogged = false]() mutable {
|
||||
auto L = lua::get_main_state();
|
||||
lua::stackguard guard(L);
|
||||
int top = lua::gettop(L);
|
||||
if (process_callback(env, src, file)) {
|
||||
if (lua::isfunction(L, -1) && !lua::call_nothrow(L, 0)) {
|
||||
return glm::vec2(0, 0);
|
||||
}
|
||||
if (lua::gettop(L) - top < 2) {
|
||||
if (!errorLogged) {
|
||||
logger.error() << "supplier " << util::quote(src)
|
||||
<< ": two numbers expected";
|
||||
errorLogged = true;
|
||||
}
|
||||
return glm::vec2(0, 0);
|
||||
}
|
||||
try {
|
||||
auto y = lua::tonumber(L, -1);
|
||||
auto x = lua::tonumber(L, -2);
|
||||
return glm::vec2(x, y);
|
||||
} catch (const std::exception& err) {
|
||||
if (!errorLogged) {
|
||||
logger.error() << "supplier " << util::quote(src) << ": "
|
||||
<< err.what();
|
||||
errorLogged = true;
|
||||
}
|
||||
}
|
||||
auto y = lua::tonumber(L, -1);
|
||||
lua::pop(L);
|
||||
auto x = lua::tonumber(L, -1);
|
||||
lua::pop(L);
|
||||
return glm::vec2(x, y);
|
||||
}
|
||||
return glm::vec2(0, 0);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -113,6 +113,14 @@ public:
|
|||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, request.url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, request.method.c_str());
|
||||
|
||||
#if LIBCURL_VERSION_NUM >= 0x075500
|
||||
curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "http,https");
|
||||
curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https");
|
||||
#else
|
||||
curl_easy_setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
|
||||
curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
|
||||
#endif
|
||||
|
||||
curl_slist* hs = nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -328,14 +328,17 @@ void Entities::preparePhysics(float delta) {
|
|||
auto view = registry->view<EntityId, Rigidbody>();
|
||||
for (auto [entity, eid, rigidbody] : view.each()) {
|
||||
auto bodyType = rigidbody.hitbox.type;
|
||||
if (eid.destroyFlag || !rigidbody.enabled || bodyType == BodyType::STATIC) {
|
||||
if (eid.destroyFlag || !rigidbody.enabled) {
|
||||
continue;
|
||||
}
|
||||
rigidbody.hitbox.selectable = rigidbody.selectable;
|
||||
rigidbody.hitbox.mass = bodyType == BodyType::DYNAMIC
|
||||
? rigidbody.mass
|
||||
: std::numeric_limits<float>::infinity();
|
||||
rigidbody.hitbox.elasticity = rigidbody.elasticity;
|
||||
rigidbody.hitbox.selectable = rigidbody.selectable;
|
||||
if (bodyType == BodyType::STATIC) {
|
||||
continue;
|
||||
}
|
||||
hitboxes.emplace_back(&rigidbody.hitbox);
|
||||
if (!eid.def.solid) {
|
||||
continue;
|
||||
|
|
@ -480,15 +483,17 @@ void Entities::render(
|
|||
const Frustum* frustum,
|
||||
entityid_t fpsEntity
|
||||
) {
|
||||
auto view = registry->view<EntityId, Transform, rigging::Skeleton>();
|
||||
for (auto [entity, eid, transform, skeleton] : view.each()) {
|
||||
auto view = registry->view<EntityId, Transform, rigging::Skeleton, Rigidbody>();
|
||||
for (auto [entity, eid, transform, skeleton, rigidbody] : view.each()) {
|
||||
if (eid.uid == fpsEntity) {
|
||||
continue;
|
||||
}
|
||||
const auto& def = eid.def;
|
||||
const auto& pos = transform.pos;
|
||||
const auto& size = transform.size;
|
||||
if (frustum && !frustum->isBoxVisible(pos - size, pos + size)) {
|
||||
const auto& halfSize = rigidbody.hitbox.getHalfSize();
|
||||
// todo: more correct frustum culling
|
||||
if (frustum && !frustum->isBoxVisible(pos - halfSize, pos + halfSize)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ void Player::deserialize(const dv::value& src) {
|
|||
src.at("loading-chunks").get(loadingChunks);
|
||||
|
||||
setChosenSlot(src["chosen-slot"].asInteger());
|
||||
eid = src["entity"].asNumber();
|
||||
eid = src["entity"].asInteger();
|
||||
|
||||
if (src.has("inventory")) {
|
||||
getInventory()->deserialize(src["inventory"]);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
inline constexpr float E = 0.03f;
|
||||
inline constexpr float MAX_FIX = 0.1f;
|
||||
inline constexpr int MAX_NEARBY_REBUILDS = 4;
|
||||
|
||||
static debug::Logger logger("physics-solver");
|
||||
|
||||
|
|
@ -141,12 +142,15 @@ static void calc_collision(
|
|||
}
|
||||
|
||||
bool PhysicsSolver::calcCollisionNegY(
|
||||
Hitbox& hitbox, const glm::vec3& half, float dt
|
||||
Hitbox& hitbox,
|
||||
const glm::vec3& half,
|
||||
float dt,
|
||||
const std::vector<Hitbox*>& solids
|
||||
) {
|
||||
auto& pos = hitbox.position;
|
||||
auto& vel = hitbox.velocity;
|
||||
|
||||
for (auto box : solidHitboxes) {
|
||||
for (auto box : solids) {
|
||||
if (glm::distance2(box->position, pos) < E) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -215,23 +219,24 @@ void PhysicsSolver::calcCollisions(
|
|||
glm::vec3& pos,
|
||||
const glm::vec3& half,
|
||||
float stepHeight,
|
||||
float dt
|
||||
float dt,
|
||||
const std::vector<Hitbox*>& solids
|
||||
) {
|
||||
stepHeight = calc_step_height(chunks, pos, half, stepHeight);
|
||||
|
||||
auto prevPos = pos;
|
||||
|
||||
calc_collision<0, 1, 2, -1>(hitbox, chunks, solidHitboxes, half, stepHeight);
|
||||
calc_collision<0, 1, 2, 1>(hitbox, chunks, solidHitboxes, half, stepHeight);
|
||||
calc_collision<0, 1, 2, -1>(hitbox, chunks, solids, half, stepHeight);
|
||||
calc_collision<0, 1, 2, 1>(hitbox, chunks, solids, half, stepHeight);
|
||||
|
||||
float xpos = pos.x;
|
||||
pos.x = prevPos.x;
|
||||
|
||||
calc_collision<2, 1, 0, -1>(hitbox, chunks, solidHitboxes, half, stepHeight);
|
||||
calc_collision<2, 1, 0, 1>(hitbox, chunks, solidHitboxes, half, stepHeight);
|
||||
calc_collision<2, 1, 0, -1>(hitbox, chunks, solids, half, stepHeight);
|
||||
calc_collision<2, 1, 0, 1>(hitbox, chunks, solids, half, stepHeight);
|
||||
pos.x = xpos;
|
||||
|
||||
if (calcCollisionNegY(hitbox, half, dt)) {
|
||||
if (calcCollisionNegY(hitbox, half, dt, solids)) {
|
||||
hitbox.grounded = true;
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +260,7 @@ void PhysicsSolver::calcCollisions(
|
|||
}
|
||||
}
|
||||
}
|
||||
for (auto box : solidHitboxes) {
|
||||
for (auto box : solids) {
|
||||
if (glm::distance2(box->position, pos) < E) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -297,7 +302,7 @@ void PhysicsSolver::calcCollisions(
|
|||
}
|
||||
}
|
||||
}
|
||||
for (auto box : solidHitboxes) {
|
||||
for (auto box : solids) {
|
||||
if (glm::distance2(box->position, pos) < E) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -314,7 +319,11 @@ void PhysicsSolver::calcCollisions(
|
|||
}
|
||||
|
||||
void PhysicsSolver::calcSubstep(
|
||||
Hitbox& hitbox, glm::vec3& vel, glm::vec3& pos, float dt
|
||||
Hitbox& hitbox,
|
||||
glm::vec3& vel,
|
||||
glm::vec3& pos,
|
||||
float dt,
|
||||
const std::vector<Hitbox*>& solids
|
||||
) {
|
||||
auto initpos = pos;
|
||||
auto half = hitbox.getHalfSize();
|
||||
|
|
@ -328,7 +337,8 @@ void PhysicsSolver::calcSubstep(
|
|||
half,
|
||||
(hitbox.prevGrounded && gravityScale > 0.0f) ? hitbox.stepHeight
|
||||
: 0.0f,
|
||||
dt
|
||||
dt,
|
||||
solids
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -359,7 +369,7 @@ void PhysicsSolver::calcSubstep(
|
|||
}
|
||||
}
|
||||
}
|
||||
for (auto box : solidHitboxes) {
|
||||
for (auto box : solids) {
|
||||
if (glm::distance2(box->position, pos) < E) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -376,6 +386,58 @@ void PhysicsSolver::calcSubstep(
|
|||
hitbox.grounded = true;
|
||||
}
|
||||
|
||||
static float calc_move_budget(
|
||||
const Hitbox& hitbox, const glm::vec3& gravity, float time
|
||||
) {
|
||||
float speed = glm::length(hitbox.velocity) * 1.25f +
|
||||
glm::length(gravity) * glm::abs(hitbox.gravityScale) * time;
|
||||
return speed * time + 0.05f;
|
||||
}
|
||||
|
||||
static glm::vec3 calc_extents(const Hitbox& hitbox) {
|
||||
return glm::max(hitbox.halfsize, hitbox.getHalfSize());
|
||||
}
|
||||
|
||||
void PhysicsSolver::findNearbySolids(float time) {
|
||||
size_t count = hitboxes.size();
|
||||
nearbySolids.resize(count);
|
||||
nearbyOrigins.resize(count);
|
||||
nearbyBudgets.resize(count);
|
||||
solidBudgets.resize(solidHitboxes.size());
|
||||
|
||||
float maxSolidHalfY = 0.0f;
|
||||
for (size_t j = 0; j < solidHitboxes.size(); j++) {
|
||||
const auto& box = *solidHitboxes[j];
|
||||
solidBudgets[j] = calc_move_budget(box, gravity, time);
|
||||
maxSolidHalfY = glm::max(maxSolidHalfY, calc_extents(box).y);
|
||||
}
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
const auto& hitbox = *hitboxes[i];
|
||||
auto& solids = nearbySolids[i];
|
||||
solids.clear();
|
||||
nearbyOrigins[i] = hitbox.position;
|
||||
nearbyBudgets[i] = calc_move_budget(hitbox, gravity, time);
|
||||
|
||||
auto ext = calc_extents(hitbox);
|
||||
|
||||
glm::vec3 reach(
|
||||
0.5f,
|
||||
hitbox.stepHeight * 2.0f + E * 8.0f + ext.y * 0.5f +
|
||||
maxSolidHalfY + 0.5f + MAX_FIX * 2.0f,
|
||||
0.5f
|
||||
);
|
||||
reach += ext + nearbyBudgets[i];
|
||||
for (size_t j = 0; j < solidHitboxes.size(); j++) {
|
||||
const auto& box = *solidHitboxes[j];
|
||||
auto limit = reach + calc_extents(box) + solidBudgets[j];
|
||||
auto diff = glm::abs(box.position - hitbox.position);
|
||||
if (diff.x <= limit.x && diff.y <= limit.y && diff.z <= limit.z) {
|
||||
solids.push_back(solidHitboxes[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsSolver::step(
|
||||
const GlobalChunks& chunks, float delta, uint substeps
|
||||
) {
|
||||
|
|
@ -387,11 +449,32 @@ void PhysicsSolver::step(
|
|||
}
|
||||
|
||||
float dt = delta / static_cast<float>(substeps);
|
||||
findNearbySolids(delta);
|
||||
|
||||
int rebuildsLeft = MAX_NEARBY_REBUILDS;
|
||||
for (uint i = 0; i < substeps; i++) {
|
||||
for (auto hitbox : hitboxes) {
|
||||
for (size_t j = 0; j < hitboxes.size(); j++) {
|
||||
auto hitbox = hitboxes[j];
|
||||
glm::vec3& pos = hitbox->position;
|
||||
hitbox->prevPosition = hitbox->position;
|
||||
calcSubstep(*hitbox, hitbox->velocity, pos, dt);
|
||||
calcSubstep(
|
||||
*hitbox,
|
||||
hitbox->velocity,
|
||||
pos,
|
||||
dt,
|
||||
rebuildsLeft >= 0 ? nearbySolids[j] : solidHitboxes
|
||||
);
|
||||
if (rebuildsLeft < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto moved = glm::abs(pos - nearbyOrigins[j]);
|
||||
if (glm::max(moved.x, glm::max(moved.y, moved.z)) >
|
||||
nearbyBudgets[j]) {
|
||||
if (--rebuildsLeft >= 0) {
|
||||
findNearbySolids(dt * static_cast<float>(substeps - i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,12 @@ private:
|
|||
std::vector<Sensor*> sensors;
|
||||
std::vector<Hitbox*> solidHitboxes;
|
||||
std::vector<Hitbox*> hitboxes;
|
||||
std::vector<std::vector<Hitbox*>> nearbySolids;
|
||||
std::vector<glm::vec3> nearbyOrigins;
|
||||
std::vector<float> nearbyBudgets;
|
||||
std::vector<float> solidBudgets;
|
||||
|
||||
void findNearbySolids(float time);
|
||||
|
||||
void calcCollisions(
|
||||
Hitbox& hitbox,
|
||||
|
|
@ -45,12 +51,24 @@ private:
|
|||
glm::vec3& pos,
|
||||
const glm::vec3& half,
|
||||
float stepHeight,
|
||||
float dt
|
||||
float dt,
|
||||
const std::vector<Hitbox*>& solids
|
||||
);
|
||||
|
||||
void calcSubstep(Hitbox& hitbox, glm::vec3& vel, glm::vec3& pos, float dt);
|
||||
void calcSubstep(
|
||||
Hitbox& hitbox,
|
||||
glm::vec3& vel,
|
||||
glm::vec3& pos,
|
||||
float dt,
|
||||
const std::vector<Hitbox*>& solids
|
||||
);
|
||||
|
||||
bool calcCollisionNegY(Hitbox& hitbox, const glm::vec3& half, float dt);
|
||||
bool calcCollisionNegY(
|
||||
Hitbox& hitbox,
|
||||
const glm::vec3& half,
|
||||
float dt,
|
||||
const std::vector<Hitbox*>& solids
|
||||
);
|
||||
|
||||
void updateSensors(Hitbox& hitbox);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ struct CameraSettings {
|
|||
};
|
||||
|
||||
struct GraphicsSettings {
|
||||
/// @brief Enable fog
|
||||
FlagSetting enableFog {true};
|
||||
/// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
|
||||
/// 1.0 is linear, 2.0 is quadratic
|
||||
NumberSetting fogCurve {1.0f, 1.0f, 6.0f};
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue