mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
feature/json-registry
19 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1baa2d6672 |
feature: screenshot (#39)
* build: add stb image write lib * feat(renderer): add screenshot capture with F2 * feat(screenshot): add screenshot viewer scene Add SCREENSHOT scene and UI to browse screenshots from the main menu, with localization for English and Chinese. Also allow image loading by full path and replace scene-operation asserts with error logs. * feat(ui): handle window resize in ScreenshotUI * feat(ui): add ScrollView widget and dynamic layout on resize Introduces a ScrollView widget with mouse wheel support and viewport clipping. Credits and screenshot screens now use it and recompute layout on window resize. Offset storage switched from ivec2 to vec2 with new accessors. * feat(ui): add lightbox viewer for screenshots Add a lightbox to preview screenshots on click. Introduce Button::set_texture for image-backed buttons, add widget getters for window size and visibility, and block background input while the lightbox is open. Close the lightbox with Escape or a left-click. * feat(ui): add screenshot button to pause menu Add a button to open the screenshot scene from the pause menu. Also enable linear filtering on screenshot textures for smoother scaling. * feat(ui): add show in file manager button to screenshot view - Add Tools::open_file_manager helper with Windows and Linux support. - Ensure screenshot directory is created before scanning. - Add localization keys for en_US and zh_CN. * feat(screenshot-ui): add newest/oldest sort selector Add a combo button to the screenshot gallery to sort files by modification time (newest or oldest first). Store timestamp per image and rebuild layout when sort order changes. Include translations for en_US and zh_CN. * fix: correct argument typo and path/error handling Fix --enable-consolelog flag, screenshot filter bug, paths to C APIs, add includes and gitignore entries, and improve ShellExecuteW failure detection. * fix(audio): improve source management and OpenAL diagnostics Fix null deref when source pool is full, initialize m_using, and improve source state handling. Add OpenAL vendor/version/renderer logging and correct voice PCM span type. * fix(client_entity_manager): store find result before assert * fix(tools): switch datetime format to underscore-separated Use %Y-%m-%d_%H-%M-%S instead of %F %T to avoid colons and spaces, making output suitable for file names. * fix: initialize uninitialized member variables Add default member initializers across various classes to prevent undefined behavior from uninitialized fields, and initialize the neighbor biome array in the chunk generator. * feat(texture_manager): add check_exist option for image loading Add a `check_exist` parameter to `get_image_texture` and `load_image_texture`, enabling callers to skip file existence checks. Log an error and return nullptr when image data fails to load. Update screenshot UI to support uppercase image extensions and gracefully ignore unreadable images. |
||
|
|
236e7c0433 |
feature: creature (#38)
* build(deps): add assimp library as dependency * feat(render): add model loading and rendering pipeline * refactor(render): rename depth player shaders to depth model and clean up * build: add EnTT library * feat(entity): add ECS-based entity rendering * feat(render): add shadow pass for entity models * refactor(render): unify model and player rendering with single shader pipeline * refactor(collision): convert AABB to center-half representation and migrate player data to ECS * refactor(gameplay): add base classes Chunk and World for shared logic * feat(gameplay): implement entity movement system with collision detection - Add Velocity and HitBoxes components to entity - Introduce HitboxManager for loading per-entity collision AABBs from JSON - Create MoveSystem with per-axis collision handling - Move get_block_aabb to base World class and add virtual get_per_tick_time - Remove static get_block_aabb from ClientWorld; use member m_per_tick_time for tick duration * fix(gameplay): correct hitbox insertion in HitboxManager::load * build: remove entt library * refactor(gameplay): replace entt components with SparseVector for player data Refactor client world to use a custom SparseVector for player data instead of entt registry. Consolidate Transform, ViewAngles, and related structs into Position, Orientation, WalkPose. Introduce PlayerData and PlayerRenderData. Remove the unused move_system.cpp. Unify player render and shadow render into a single function. * feat(render): add model ID system with concurrent lookup and namespace-based loading - Extract `ModelID` and `Model` struct to new `model.hpp` - Replace `std::unordered_map` with `tbb::concurrent_hash_map` for thread safety - Add `get_model(ModelID)`, `get_model_id`, `get_model_name` methods - Parse model names in `namespace:name` format to construct asset paths - Update `load_model` to accept `string_view` and use ID-based management * refactor(gameplay): extract movement, gravity, orientation, and walk pose into structs * refactor(gameplay): extract Entity base class from ClientPlayer Move position, walk pose, velocity, orientation, movement, and gravity fields and their accessors into a new Entity base class. ClientPlayer now inherits from Entity, removing duplicated members. Also update velocity handling to use 3D vector per axis and adjust related logic. * feat(player): split max speed into horizontal/vertical, set spawn pos * refactor: move movement logic into SpeedSystem and Entity components * refactor(gameplay): extract physics and collision from ClientPlayer into PhysicalSystem Move per-axis collision detection and move distance calculation to new PhysicalSystem. Move SpeedSystem implementation from inline header to separate .cpp file. Add const accessors to Entity. Replace inline AABB helper with HitboxManager registration of player hitbox using new PLAYER_SIZE constant. Remove obsolete members and functions from ClientPlayer. * refactor(gameplay): integrate model and hitbox ID system into Entity - Introduce HitboxID, EntityID, and ModelID types for safer ID-based lookups - Replace AABB struct with Hitbox (includes HitboxID) - Convert ModelManager and HitboxManager to singletons with Handle structs - Update Entity to store IDs for model and hitbox, removing direct references - Reorganize creature model assets into subdirectories per entity type - Add player model (player.glb) and collision data for pig - Remove ModelManager dependency from App and Renderer - Add namespace parsing utility for asset paths - Mark sparse_vector::insert() with [[nodiscard]] * build: add entt library * refactor(gameplay): rename ClientPlayer to LocalPlayer * refactor(gameplay): separate player logic into manager and ECS components * feat(gameplay): add entity managers and refactor to ECS components * refactor(gameplay): replace client thread with timer-based system and add entity manager * feat(gameplay): implement entity system with concurrent task handling and fix model loading * feat(gameplay): add entity destruction support * feat(entity): add client-to-server entity creation and destruction requests Extend the network protocol with `C2SEntityCreateRequest` and `C2SEntityDestoryRequest` packets. Refactor entity managers to split public client-facing create/destroy methods that send requests over the network, from internal handlers that process received packets. Add utility functions for converting protobuf Vec3 to glm::vec3. * feat(gameplay): implement entity update packets Add S2CEntityUpdate to sync entity positions from server to client, including update handling in the client entity manager and server-side AI updates. * feat(ai): add wander AI system with move boost Add AIBase and WanderAITag components, a WanderAISystem, and a MoveBoost component to control wandering behavior. Replace the old MoveState with MoveBoost and include a horizontal random direction helper. * refactor(ecs): move entity physics to tick-based systems Update PhysicalSystem and SpeedSystem to operate on entt::registry instead of individual components. Add TickVelocity for server creatures so movement is calculated per tick without frame delta time. LocalPlayer now implements its own client-side physics with collision detection. * feat(gameplay): add server-side entity movement and AI Refactor LocalPlayer::update_physical to operate on a passed position, and run speed, physical, and wander AI systems in ServerEntityManager. * feat(gameplay): add pig wander AI and refine speed physics * feat(server): send entity position updates to all sessions * fix: correct velocity clamping and hitbox loading Preserve sign when clamping velocity; negative velocities now clamp to zero instead of flipping direction. Support loading hitbox definitions from JSON arrays and objects. Tune pig entity movement, spawn height, and wander probabilities. * feat(creatures): refine pig movement physics Add movement constants for pigs and switch deceleration to per-axis friction so creatures stop naturally. Extend wander boost duration for smoother behavior. * feat(physics): implement step-up for horizontal collisions * feat: sync entity direction and rotate models accordingly Move direction into the transform component and include it in server-to-client entity updates. Client now sets transform direction from the network message and uses it to compute yaw for model rotation, so entities visually face their movement direction. Refactor net_utils to support arbitrary Vec3 fields. * feat(render): interpolate entity transforms for rendering Add RenderTransform component to smooth position/direction updates and use it in entity and shadow passes. * fix(server_world): send time before entity updates * build: replace nlohmann json with rapidjson * refactor(json): migrate from nlohmann to rapidjson Replace nlohmann::json with rapidjson across localization, hitbox manager, server world, and sensitive filter. Add json_utils helper for converting rapidjson documents to maps, and improve parse error handling. * feat(item): add item manager with JSON asset loading Implement ItemManager to load and query item definitions from assets/item JSON files. Add ItemData struct, item asset metadata, CMake source registration, and initialize the manager during app startup. Also add AGENTS.md repository guidelines. * refactor(item): decouple items from block types The item system now supports an ItemKind and property, allowing item JSON to declare a type instead of assuming every item is a block. BlockManager was moved to its own header, redesigned around concurrent hash maps, and exposes id_from_name(). Texture and UI code now key items by ItemID, while block placement resolves the block type from the item registry. * fix(gameplay): use inline const for static EMPTY members Use inline const for static EMPTY members to avoid ODR and linker issues. Add missing block_manager.hpp includes in gameplay sources. * fix: stabilize block item registration and display Store item names as owned strings in ItemManager, set block type property for block items, validate item kind before placement, and handle items without textures gracefully in inventory UI. * feat: add pig spawn egg item Add pig spawn egg asset and texture, parse spawn egg item kind and creature property, and spawn the configured entity when used on an empty block. Also fix item texture loading to use actual image dimensions and update selected item UI sizing. * refactor(gameplay): update systems per entity with chunk check Refactor server entity update flow to process entities individually, skipping those whose chunk is not loaded. System update methods now accept a single entity instead of iterating the full registry view, and `ServerWorld::get_chunk_ref_count` is added to determine if an entity's chunk is active. * perf(render): skip entities outside loaded chunks * feat: add --direct-enter option to skip to world scene Support a new CLI flag that launches the app directly into the world scene. If no IP is provided, it starts a local server on the specified port and connects to 127.0.0.1; otherwise it connects to the given IP. With this flag enabled, a port must be specified via -p. Also expose SceneManager::push as public so scenes can be pushed immediately when bypassing the normal menu flow. * refactor(localization): switch block translations to item naming Remove the `name_key` field from block definitions and use item-based localization keys (`item.*.name`) for inventory display. Item data now stores the localized name at load time. * feat(gameplay): spawn creatures during chunk generation Add creature spawning to chunk generation with a configurable SpawnConfig, including a default pig spawn. Spawning occurs in the final generation phase and registers entities through the server world's entity manager. Also destroy entities when their chunk is unloaded to prevent orphaned entities and expose the entity manager from ServerWorld. * feat(gameplay): add run mode based thread pool config Introduce RunMode enum and thread pool sizing helpers for client, server, and hybrid modes. Add compute pool to server world and pass mode through server/client initialization. * perf(server): parallelize entity update loop Use parallel_do to process entities concurrently via the compute pool. Switch get_all_session to a thread-safe tbb::concurrent_vector and make ChunkEntity's ref_count atomic to avoid data races. Also remove the debug pig spawn from world init. * feat(creatures): animate creature walk cycles Add a Gait component synchronized over the network and procedural animation for model nodes. Load animation parameters from assets/model/creature/pig/animation.json and apply leg swing, body bob, and head motion based on gait. Refactor Gait into its own header for reuse. * fix(gameplay): make entity interpolation frame-rate independent * perf(render): batch model rendering with instancing Replaces per-entity draw calls with instanced rendering for both main and shadow passes. Each model's node hierarchy is flattened once and instance matrices are updated per frame, reducing draw calls and CPU overhead. * refactor(render): build entity instance buffers once per frame Move instance matrix upload into build_vertices and use a precomputed instance data map for both shadow and color passes, avoiding duplicate GPU buffer updates. * perf(gameplay): batch entity updates into single packet Aggregate per-entity update messages into S2CEntityUpdateBatch and broadcast once per tick. Reuse serialized packets in several broadcast loops to avoid repeated make_packet calls. * fix: correct thread count and shadow projection uniform - Add reserved client thread count to client threads in server generation calculation. - Set projection matrix uniform only for non-shadow rendering. * feat(ecs): add entity type separation and creature limits Replace generic entity creation with typed creatures and items. Rename `add_entity` to `add_creature`, enforce per-player creature cap, and track entity/creature totals for metrics. Expose run mode to dev panel and show new counts. * perf(render): frustum cull entities before instance building Add frustum culling to entity instance data collection using AABB vs camera frustum planes. Pass renderer into get_instances_data_map to compute MVP and extract planes. Also add "Rendered Entities" debug counter for visibility. * feat(audio): add ambient pig sounds Add pig call audio with randomized timing, triggered by proximity to the player as 3D positional sound. * feat(client-entity): use snapshot history for entity interpolation Replace exponential smoothing with a buffered snapshot system. Each entity keeps a deque of position/direction snapshots with timestamps; the render transform is interpolated at a fixed 100 ms render delay to hide network jitter. Snapshots are capped to 16 entries. * refactor(hitbox): move player hitbox definition to JSON asset * feat(client_player): use snapshot interpolation for remote players Replace exponential position smoothing with snapshot interpolation. Remote player transforms are rendered from a delayed snapshot history, using linear interpolation for position and shortest-path interpolation for yaw/pitch. A 100 ms render delay compensates for network tick rate. |
||
|
|
cc2df5e4ec |
feature: UI (#31)
* refactor(ui): replace Text with Label/Widget component system Replace the old `Text` class with a new component-based UI system consisting of `Widget` and `Label` classes. Key changes: - Remove `Text` class and its GPU upload logic; introduce `Label` as a `Widget` subclass with dirty-flag vertex update. - Add `UIVertexData` struct to manage per-label vertex buffer/array and memory. - Refactor `DebugCollector` to store labels in a `Widget` tree, removing hash-based lookup. - Simplify `Font::vertices()` signature by removing position/scale parameters; scaling is now applied in the renderer’s model matrix. - Update `Renderer` with `render_label()` and move UI rendering to a `render_ui()` that renders the widget tree. - Add new source files `label.cpp`, `widget.cpp`, `ui_vertex_data.cpp` and update CMakeLists. * refactor(render): replace UI shaders with image shaders and Image widget * refactor(core): add event system and scene management - Introduce Event variant and Overloaded helper for input handling - Move game state (camera, client_world, dev_panel) from App to WorldScene - Add SceneManager with push/pop/change operations for scene stack - Refactor input callbacks to dispatch events through scene hierarchy - Extract Argument struct to separate header - Update Renderer and WorldRenderer to accept world reference - Replace global input state with event-driven processing in ClientPlayer, Camera, etc. * refactor: add framebuffer resize event and separate UI management * fix(font): use correct texture format and clamp to edge for font atlas * feat(input): add KeyAction::REPEAT for key repeat events Add a new REPEAT value to the KeyAction enum and update the input callbacks to map GLFW_REPEAT actions to the new value instead of treating them as press. * feat(client-player): add block cooldown and track mouse state Introduce a time-based cooldown for block placement (PLACE_BLOCK_INTERVAL) to prevent rapid clicking. Replace the global InputState with per-player MouseState tracking in ClientPlayer. Rename place_block() to get_current_block() for clarity. Remove the old src/input.cpp and the Cubed/input.hpp header, moving input structures to Cubed/input/input.hpp. * ui: add main menu scene and interactive button widget - Implement MainMenuScene with a "Start Game" button that pushes the WorldScene. - Extend Button class with background/foreground, hover detection, and size queries. - Add virtual width/height and event handlers to Widget base class. - Update WorldUIManager to propagate mouse move events. - Adjust Window mouse mode based on game running state. * feat(ui): add button scaling and change square vertices to top-left origin * refactor(font): return TextMesh from Font::vertices to include bounding box Replace the plain vertex vector with a TextMesh struct that carries width, height, and min coordinates. Update Label to compute and store these values immediately on text change (removing lazy dirty update). Fix Button's width/height to factor in scale and use concrete widget types for background and foreground. * feat(ui): support scaling of labels and images Modify width() and height() methods to multiply by m_scale for both Label and Image. Rename internal dimensions to m_real_width and m_real_height for clarity. Adjust Button foreground position to vertically center when label is scaled. * refactor(ui): move scale property to subclasses and fix resize event handling Remove scale from base Widget class and add per-type set_scale/scale methods to Button, Image, and Label. Dispatch separate WindowResizeEvent alongside existing FrameBufferResizeEvent. Correct centering calculations from `+` to `-` in main menu and world UI managers. * fix(render): remove duplicate scaling in render_image model matrix * feat(ui): introduce anchor-based widget positioning system Replace set_position with anchor and offset for relative positioning. Add parent pointer to widget hierarchy. Remove manual resize logic in UI managers. * feat(ui): introduce ColumnLayout widget and refactor widget parenting - Add ColumnLayout widget that arranges children vertically with spacing. - Refactor Widget::add_child to automatically pass `this` as parent. - Update DebugCollector to use ColumnLayout for consistent spacing. - Expose children() accessor in Widget for layout management. * feat(main_menu): add exit button and refactor layout with ColumnLayout - Add `should_close_window()` method to force window close from UI. - Replace standalone button with ColumnLayout for proper centering. - Add "Exit" button that calls `should_close_window()`. - Update ESC key handling to only close window when game is not running. - Fix ColumnLayout to respect parent's anchor instead of hardcoded TOP_LEFT. - Remove unused parameter name in Image::update for consistency. * feat(ui): add Rect widget with fill, color, and parent-relative sizing * refactor(ui): extract common UI manager logic into base class * refactor: move server logic to WorldScene and refactor UI methods * feat(scene): implement pause menu with UI manager and escape key toggling Add PauseMenuUIManager class and integrate pause state into WorldScene. Escape key toggles pause in ClientPlayer and PauseMenuUIManager. Refactor Window mouse and imgui control to support pause state. * refactor(scene): dispatch events via typed handlers and move pause toggle to WorldScene * feat(ui): add HUD visibility toggle and image fill features * refactor(app): remove redundant ImGui WantCaptureMouse check in cursor callback * feat(scene): add credits scene and UI * feat(credits): add ESC key handling; remove about tab from dev panel * feat(ui): add Slider widget for value selection * refactor(ui/slider): improve track/thumb initialization and validation Rename track/thumb accessors from set_track/set_thumb to get_track/get_thumb. Add private init methods and a constant THUMB_WIDTH. Add validation to set_width with log and assert. Modify set_height to assume non-null m_thumb. * refactor(ui): simplify Button API with property setters * feat(ui): add label and image support to slider - Add `set_text()`, `set_track_image()`, `set_thumb_image()` methods. - Include label rendering and auto-scaling based on slider dimensions. - Replace static `THUMB_WIDTH` with dynamic thumb sizing. - Add slider thumb and track texture assets. * feat(ui): add int slider support and fix update_text_scale calls * refactor(config): rename hot_reload to reload_config and add settings scene * feat(ui): add auto-scaling option for button and slider text * feat(ui): add button enable/disable and reset on re-enter Prevent double-clicking on buttons that push new scenes by disabling them on click and re-enabling when the UI manager's on_re_enter is called. * fix(input): reset key status on pause * feat(ui): add ComboButton widget and integrate into settings Introduce ComboButton, a button that cycles through options on click. Used in SettingsUI for fullscreen, V-Sync, and anisotropic filtering. Adds texture reload support in SettingsScene and makes Button methods virtual to allow overriding. Also fixes default mouse_enable to true. * feat(ui): add child anchor and content sizing to column layout * feat(ui): add TextField widget with UTF-8 text input support * feat(scene): add host game scene and world parameter handling * feat(scene): add join game scene and UI * feat(ui): add clipboard paste to TextField * feat(ui): add blinking cursor to text field * feat(ui): add error UI for connection failures and network errors Introduce ErrorUI to display error messages in-world when the client encounters connection failures or network errors. The network client now stores error strings thread-safely and exposes them via `get_error_string()`. The world scene suspends normal update/render when an error is active and shows the error overlay, allowing the user to return to the previous scene. Additionally, the client world checks for connection errors during exit to avoid hanging, and the join game UI is fixed to correctly default to client mode. * refactor: move connect error check to WorldScene and add UI titles * feat(ui): add error display in host and join game screens * feat(ui): add configurable child traversal order for event handling Add TraversalOrder enum to Widget, allowing event handlers to iterate children in back-to-front (default) or front-to-back order. Set ColumnLayout to front-to-back order. Change TextField mouse button handler to return false, enabling event propagation. * fix: window build fail * style(ui): remove extra blank line |
||
|
|
30f843ba6b |
feature: multiplayer (#25)
* build: add asio library * feat(dev_panel): add Asio to about table * refactor(gameplay): split Chunk into server/client variants and add networking * feat(gameplay): add Session class and UUID generation utility * feat(network): integrate protobuf for player sync and session management Add Protobuf dependency, define proto messages for player requests, positions, and chunk data. Refactor Session to use strand and async write. Implement player join/exit and position sync in ServerWorld. * refactor(proto): restructure protobuf definitions and update build system * feat(protocol): add packet serialization and login handling Introduce packet header and ID mapping for protobuf messages. Refactor session and server_world to use new packet wrapper. Fix missing semicolons in proto files. * refactor(packet): serialize directly into packet buffer with ByteSizeLong * feat(world): add player-based chunk loading and UUID support Restructure world generation to trigger chunk loading based on player movement. Replace player name with UUID for identification. Implement chunk request/response protocol. Improve thread management for gen thread. * feat(server): add block change packet handling and increase reserved threads * refactor(server): enhance thread safety and session management * fix(session): catch std::exception in read_loop and log error * fix(network-server): stop accept loop on shutdown flag * fix(gameplay): correct unknown error log condition and missing chunk pos update * feat(client): add client-side chunk, player, world and network classes * feat(client-chunk): add greedy meshing, receive_chunk, and biome field * feat(client_player): add name constructor param, remove chunk transition * feat(gameplay): integrate network client and thread-safe player pos * feat(gameplay): add block change sync and coordinate utils * refactor(server): replace Chunk with ServerChunk * refactor(gameplay): split world into client and server Remove monolithic World, Player, Chunk classes. Introduce ClientWorld, ServerWorld, ClientPlayer, and related networked components. Add Abseil dependency for logging and checks. Rename old files to pre_remove_* and update all includes and references accordingly. * feat(gameplay): add time sync and network improvements * fix: correct neighbor block indexing and add time update support * feat(gameplay): optimize chunk request with player chunk tracking Add `update_player_chunk()` method to `ClientPlayer` that triggers a chunk request when the player moves more than 2 chunks away from the last recorded chunk. Introduce an atomic `m_requesting_chunk` flag in `ClientWorld` to prevent concurrent requests. Rename `m_player_chunk_pos` to `m_last_chunk_pos` for clarity. * refactor(client_world): split pending queue into data and upload queues * feat(client): add center-based chunk loading priority * feat(app): add client/server CLI arguments and init guards * feat(multiplayer): add rendering of other players as colored cubes * feat(gameplay): add thread pool for asynchronous chunk data processing * feat(gameplay): add player logout and disconnect handling * fix(dev_panel): add protobuf to about table libraries * build: add ZLIB dependency * refactor(packet): replace zlib with zstd compression and restructure header Increase header length to 12 bytes, add CompressType and PacketHeader struct, and implement decode_packet_header. Update CMake to find zstd and link against it, adding Findzstd module. * refactor(network): extract packet header decoding into function * feat(packet): implement zstd compression and refactor packet decoding * perf(gameplay): optimize protobuf message allocation with Arena and limit thread pool size Switch to Arena allocation for protobuf messages to reduce heap allocations. Pass ChunkDataRsp by value to enable move semantics. Cap thread pool size to hardware concurrency with max 4 threads. * refactor(gameplay): use steady clock and sleep_until for tick loop timing * refactor(gameplay): rename remote player types and add interpolation * refactor(server_world): use thread pool for chunk request handling * refactor(packet): replace if-constexpr chain with explicit template specializations Refactor `get_packet_id()` by removing the if-constexpr chain and instead providing explicit specializations for each packet type. This simplifies the primary template (which now only contains a static assertion) and improves compile-time dispatch clarity. The `always_false` helper is no longer needed in the primary template. * feat(gameplay): add packet to clear all chunks on server rebuild Add new packet S2C_ClearAllChunks (ID 3005) to notify clients when the server rebuilds its world. Clients respond by clearing their chunk cache and requesting fresh chunks. Shift UPDATE_TIME packet ID to 3006 to accommodate. * feat(dev_panel): split world tab; add chunk request logging and fix flag reset * feat(tools): add RecentQueue to replace std::deque in server_world * feat(gameplay): add task ID to chunk requests to discard stale responses * refactor(block): move block source to gameplay directory * feat(toml): add shared TOML utilities and handle ip.toml * feat: add player name configuration and rename config file - Add --player command-line argument and 'player' field in Arguments struct - Rename ip.toml to server.toml and corresponding internal variable to 'server' - Fix block.cpp source path in CMakeLists.txt * build(cmake): modularize build configuration * fix: build fail on windows * refactor(renderer): rename Logger level enum value DEBUG to L_DEBUG * refactor(world): rework chunk state machine and player chunk tracking Introduce ChunkState enum and ChunkEntity struct to manage chunk lifecycle. Store chunks as shared_ptr to avoid move operations during generation. Add clear_unused_chunks to remove chunks not referenced by any player. Implement deferred chunk request queue for safe processing after generation completes. Update player chunk set during required chunk computation. Improve thread safety with mutexes on chunk and player maps. Fix m_gening flag not reset after generation and add assertions for correctness. Change need_gen to require a player UUID, removing std::optional. Add chunk_size query method for debugging. * fix(server): ensure chunk is ready before sending or setting block * refactor(server_world): separate gen and net thread pools Introduce a second thread pool for network operations and a `ThreadPoolKind` enum to distinguish between gen and net pools. Rename `pool_threads()` to `gen_pool_threads()`, add `change_pool_threads()` overload that accepts the pool kind, and update the dev panel to use the gen pool. Adjust logging and initialization to handle both pools. * feat(client_world): implement server exit acknowledgment with timeout * feat(gameplay): implement server stop and client exit handling Add server_stop flag to LogoutRsp protocol. Modify client_world to check for server stop or own logout to set exit flag. Add ServerWorld::stop() to broadcast stop and cleanly shut down. Refactor chunk ownership to unique_ptr. Remove name parameter from get_look_block_pos. * fix(app): correct port validation and remove redundant TOML helper * fix: address unused parameter warnings and missing port assignment * refactor(gameplay): remove old pre_remove chunk, player, and world files * refactor(server): replace chunk set with flat_hash_set and add ref count - Replace std::unordered_set with absl::flat_hash_set for chunk position sets. - Add ref_count field to ChunkEntity and implement update_ref_count(). - Remove clear_unused_chunks() and use ref counting for chunk lifetime. - Add get_chunk_pos_set() accessors to ServerPlayer. * fix(client-world): delay chunk request to wait for server central chunk generation * refactor(gameplay): migrate chunk storage to tbb::concurrent_hash_map * refactor(server_world): replace future-based chunk generation with queue Remove `std::future` per-chunk tracking and poll_finished_chunks(). Instead, generation tasks push completed chunks to a concurrent queue consumed during update. This eliminates wait_all_chunk_tasks() and simplifies synchronization. * refactor(client_world): use concurrent data structures for chunk management Replace std::shared_mutex and std::unordered_set with tbb::concurrent_hash_map for chunk storage, tbb::concurrent_queue for pending uploads, and absl::flat_hash_set for player chunk positions. This improves thread safety and reduces locking overhead. Refactor receive_chunk and request_chunk to work with the new concurrent model. * build(windows): add Nvidia and AMD GPU high performance exports * fix(ci): update header file pattern in clang-format check * style(clang-format): comment out AlignPPAndNotPP option * chore: enable AlignPPAndNotPP in clang-format and pin clang version in CI * ci(workflow): update format check to use LLVM 22 * ci(format-check): install clang-format-22 * perf(world): cull distant players from updates and rendering Add distance2 utility function. On client, skip rendering other players if distance squared exceeds rendering distance. On server, only send player position and block change updates to players in relevant chunks. * refactor(math_tools): convert free functions to inline in header * refactor(dev_panel): remove seed editing and server rebuild world, move client rebuild - Remove text editing for perlin seed and filter function - Remove ServerWorld::rebuild_world() method and its atomic flag - Move 'Rebuild World' button to client world tab - Remove unused perlin_noise_input_buffer * fix(server_world): floor block position coordinates in handle_block_change * refactor(gameplay): pass new_chunks vector as parameter instead of member variable * perf(client): improve chunk rendering performance with snapshots and threaded generation * feat(tools): add PriorityThreadPool with priority scheduling Implement PriorityThreadPool supporting task priorities and FIFO ordering for same priority. Update ClientWorld to use the new pool with explicit priority for chunk operations. Fix ThreadPool stop logic with atomic exchange and remove unnecessary lambda capture. * feat(networking): add priority and sequence ordering to packet send queues * feat(server-world): use priority thread pool for chunk generation Introduce PriorityThreadPool to process chunk generation tasks with priorities based on their distance from the player. Closer chunks receive higher priority, improving responsiveness. * refactor(client): extract AABB creation and add collision check on block place Make ClientPlayer::get_aabb and ClientWorld::get_block_aabb static. Change player size to static constexpr M_SIZE. Use shared_mutex for concurrent reads of other players. Check for collision with other players before placing a block. * feat(build): add build-time version system via CMake configure_file * ci(release): add release build workflow for windows |
||
|
|
7ecdab08fc |
refactor: cave and river (#22)
* refactor(chunk): add ChunkInfo and switch to shared_mutex for chunk access Introduced ChunkInfo struct to expose chunk metadata (position, seed, biome). Replaced std::mutex with std::shared_mutex for chunk map to allow concurrent read access. Added World::get_chunk_info() method. Temporarily disabled cave/river cleanup and debug biome reporting. * refactor(cave,river,chunk): use ChunkPos as key for paths and track cave existence * refactor(gameplay): use deterministic origin-based cave and river generation Compute cave and river paths on-the-fly per chunk from a deterministic origin instead of storing them globally. Remove concurrent hash map storage, shared mutexes, and related cleanup methods. This simplifies concurrency and reduces memory overhead. * refactor(world): remove unused chunk generation progress tracking |
||
|
|
7ffc349eb3 |
refactor: chunk load (#21)
* feat(renderer): add fog effect based on render distance * refactor(gameplay): remove dead code and simplify chunk neighbor context Remove the large commented-out `init_chunks()` function, and eliminate the `affected_neighbor` tracking in `gen_chunks_internal()`. This simplifies the neighbor context building and removes unused vertex data regeneration for affected neighbors. * refactor(gameplay): move chunk generation phases into gen_chunk method Consolidate multiple phase generation calls into a single gen_chunk() method on Chunk, which handles neighbor generation and ensures thread safety. Simplify World::gen_chunks_internal by using gen_chunk() instead of manual phase orchestration. * fix(gameplay): use gen_phase_one to get seed * feat(world): integrate thread pool and async chunk generation * fix(renderer): correct shader uniform name and remove unused uniform * feat(gameplay): add temporary chunk flag to prevent path clearing * fix: add thread safety for cave and river path mutexes * refactor: remove unused uniforms and set cameraPos uniform outside lambda * feat(world): add dynamic thread pool resizing * feat(world): add thread pool size management and UI controls * feat(world): add ChunkLoadStyle enum and rename chunk_pos to get_chunk_pos * feat(player): add configurable fly Y speed * refactor(world): add thread pool start/stop and auto-detect threads Extract thread pool starting and stopping into dedicated methods. Set default pool threads to 0 to enable automatic detection of available cores, and ensure thread pool is properly managed during world rebuild. * fix: include shared_mutex header * fix(gameplay): simplify set_chunk_load_style switch and fix fallthrough bug * fix(world): add missing include for <utility> |
||
|
|
f4114c2699 |
refactor: world generation (#17)
* refactor: use TBB for concurrent hash maps and parallelize chunk processing * fix: tbb link fail * refactor(chunk): remove biome check for caves in rivers and oceans * refactor(random): replace std distributions with custom implementations Avoid overhead and platform-dependent behavior of `<random>` distributions by using direct engine operations and integer arithmetic. This ensures deterministic, cross-platform results and improves performance. * refactor(generation): use chunk seed for cave and river paths - Use per-chunk seed instead of global path_id for cave and river generation. - Remove unused m_sum variables and m_path_id members. - Clamp river yaw within 10 degrees of initial direction. - Fix river radius interpolation (use t instead of 1-t). - Lower sea level from 64 to 63. |
||
|
|
932463663f |
feat: ocean (#16)
* feat(gameplay): add Ocean biome with water generation and heightmap adjustments - Introduce Ocean biome enum, builder, and detection logic. - Add ocean water building to all existing biomes and modify heightmap thresholds for low mountainous areas. - Skip cave and river generation in Ocean (and River) biomes; avoid carving water blocks. - Comment out border blending call and update block fill logic. * fix(gameplay): re-enable border blending and protect water in cave gen * refactor(generation): move ocean water build to later phase * feat(block): add is_transitional property and refine border blending * fix(block): set stone block as transitional * fix(world): generate temporary chunks for surface blend neighbor data * fix(gameplay): simplify block fill logic in blend_surface_blocks_borders * refactor(tree): remove debug logging and unused include |
||
|
|
5901ab7cd9 |
feat: grass (#11)
* feat: add grass texture and update grass_block texture * feat: add block data * feat: add blocks_tool * feat: add sync info and change function in blocks_tools * feat: add check and new function * refactor: make block texture loading data-driven * feat: add rendering for grass * feat: passable grass * feat: random grass place * fix: memory leak in TextureManager::load_cross_plane_texture |
||
|
|
bbf8b4e969 |
refactor: river (#10)
* fix: correct snowy grass block texture * refactor: river generation * fix: water placement error due to interpolation * perf: improve river naturalness * feat: add river tab item * fix: path truncation |
||
|
|
a54e87dbc6 |
refactor: terrain generation (#9)
* feat: add BlockType * refactor: use fBM for heightmap generation * feat: improve mountain realism * refactor: adjust mountain spawn probability * feat: add biome boundary blending * refactor: remove resolve_biome_adjacency_conflict function * feat: add snowy plain * perf: speed up world generation * refactor: lower overall terrain height |
||
|
|
1a26474a05 |
feat: add cave (#8)
* feat: add cave generate * fix: incorrect blocks on cave surface * fix: non-deterministic cave generator * refactor: move all chunk generation to dedicated generation thread * refactor: remove inital cave * feat: add cave parameter adjustment * refactor: adjust cave probability |
||
|
|
9d200f31be |
refactor: chunk interpolate (#6)
* refactor: rewrite blend_heightmap_boundaries * refactor: init_world * fix: unnatural biome boundary transition |
||
|
|
a02bfad639 |
refactor: biome build (#5)
* refactor: rename Biome to BiomeType * feat: add biome builder |
||
|
|
a63dfa7f47 |
feat: add river biome (#4)
* feat: add river biome * fix: duplicate mountain terrain generation * fix: safe_int_to_biome not include river |
||
| 611a795481 | chore: add clang-format and pre-commit configuration | |||
| 932c11a646 | fix: chunk conflict resolution not taking effort | |||
| bd5665c935 | fix: can't find iota | |||
| c5a78185ba | feat: add ChunkGenerator |