Skip to content

Flecs v4.1.6

Latest

Choose a tag to compare

@SanderMertens SanderMertens released this 29 Jun 02:09
fb55f3c

Highlights

// NEW: include statements
include assets.flecs

// NEW: functions
fn color(x: i32, z: i32) -> Rgba {
    {x, 0, z, 1.0}
}

for x in 0..10 {
    for z in 0..10 {
        "e_{x}_{z}" {
            // NEW: assign expressions to components directly
            Rgb: color(x, z).rgb // NEW: swizzle operators
        }
    }
}
  • Multiple inspector panels in the explorer:
Screenshot 2026-06-28 at 7 38 12 PM
  • New entities can now be created from the explorer:
Screenshot 2026-06-28 at 7 40 22 PM
  • New dialog for adding components:
Screenshot 2026-06-28 at 7 41 25 PM

Release notes

This version includes the following improvements:

  • [core] Add optimized function for moving small component values across tables
  • [core] Improve performance of reparenting for non-fragmenting hierarchies
  • [core] Throw error when changing children of already instantiated prefab
  • [core] Create default range for already created entities when calling ecs_entity_range_new()
  • [core] Throw INVALID_OPERATION assert when parenting to not-alive parent
  • [core] Allow for overriding component hooks to support hot reloading
  • [core] Reduce the size of ecs_ref_t
  • [core] Introduce new update() API for modifying existing systems/observers
  • [core] Do not assert when entities have non-unique names
  • [core] Always run exclusive access checks when feature is enabled
  • [core] Implement new range API that correctly handles recycling
  • [core] Allow for specifying offset for ecs_delete_empty_tables() function
  • [core] Improve error message when using ecs_field for sparse component
  • [cpp] Replace usage of NULL with nullptr in C++ API headers
  • [cpp] Replace deprecated std::is_trivial
  • [cpp] Implement query group iterator for C++ API
  • [cpp] Add support for query::has() methods in C++ API
  • [cpp] Add auto-reflection (ECS_STRUCT) support to C++
  • [cpp] Make builder::build const (#2033) (thanks @Cobryis!)
  • [queries] Allocate iterator vars and written arrays in a single block
  • [queries] Skip allocations for fully cached queries
  • [queries] Throw error when != is mixed with with || in query expressions
  • [queries] Throw error when change detection is enabled on queries with sorting
  • [queries] Skip down-traversal leaf check for non-traversable tables
  • [queries] Resolve top-level up target without the traversal cache map
  • [queries] Improve up traversal performance by reusing down cache buffer
  • [queries] Improve performance of iterator creation
  • [queries] Refactor query cache to store column indices directly
  • [queries] Make group_by unordered by default
  • [queries] Make EcsPredMatch query terms case insensitive
  • [observers] Add names to singleton constraint observers (thanks @suleymanlaarabi!)
  • [observers] Add fast trivial query check for multi-term observers
  • [observers] Don't eat observer table locking overhead in release mode
  • [pipelines] Remove unused iters and iter_count members from pipeline state
  • [pipelines] Prevent setting time scale on stage/readonly world
  • [script] Add support for swizzle member expressions
  • [script] Allow for direct assigning of expressions to components
  • [script] Add support for UUID annotation to flecs script
  • [script] Implement script functions
  • [script] Add support for include statements to flecs script
  • [json] Serialize DontFragment components to JSON
  • [json] Refactor type_info serialization to always be a top-level JSON field
  • [json] Add support for deserializing array element expressions
  • [rest] Add REST parameters for world endpoint
  • [os api] Add fopen/fclose hooks to OS API
  • [ci] Fix new VS2026 warnings
  • [ci] Fix -Wzero-as-null-pointer-constant warnings in C++ headers
  • [docs] Add link to Data Oriented Hierarchies blog
  • [docs] Fix incorrect doc comment for ecs_new_w_id()
  • [docs] Add Appulse to README
  • [docs] Extend documentation of CanToggle trait
  • [docs] Improve source code comments

This version includes the following bugfixes:

  • [core] Fix missing OnAdd event for dont-fragment component on prefab instantiation
  • [core] Fix issue where prefab already in use assert would trigger during world cleanup
  • [core] Fix issue in hashmap iterator
  • [core] Get prefab child name at spawn time instead of caching it
  • [core] Fix off-by-one in prefab instance child bounds check
  • [core] Map toggle bitset columns without assuming contiguous ids
  • [core] Skip non-entity ids when enabling/disabling a prefab
  • [core] Return NULL when getting an inherited tag through IsA
  • [core] Batch deferred delete commands so adds after delete are not applied
  • [core] Refetch component pointer after on_replace hook in batched command flush
  • [core] Fix sparse storage not zeroing memory on remove when size param is 0
  • [core] Fix ecs_value_move_ctor invoking move instead of move_ctor
  • [core] Fix ecs_add_path_w_sep adding ChildOf self pair when path is null
  • [core] Fix integer overflow in strbuf float serializer for values >= 2^63
  • [core] Don't destroy source toggle bitset when moving single entity that removes a toggle
  • [core] Clear toggle bitset bits when clearing table entities without deallocating
  • [core] Apply ChildOf side effects when replacing exclusive pair in table graph
  • [core] Fix childof base index when prefab child has auto override pair sorting before ChildOf
  • [core] Fix ecs_clone using wrong type info when cloning pair components from named entity
  • [core] Don't force empty ChildOf reparent diff for non-fragmenting pair tables
  • [core] Don't delete prefab tables and dangling pairs during delete_with/remove_all
  • [core] Update prefab-children flag on ChildOf record when parent promoted to prefab
  • [core] Gate ChildOf unparent cleanup on diff flags to avoid spurious depth recompute
  • [core] Skip already-deleted ordered children during fini depth propagation
  • [core] Propagate ordered-children tracking flag to pre-existing child tables
  • [core] Cleanup prefab tree spawners at fini before deleting entities
  • [core] Fix stale EcsIdMarkedForDelete flag on non-fragmenting ChildOf after delete_with
  • [core] Fix issue with stale entity in traversal cache when using non-fragmenting hierarchies
  • [core] Fix issue where observer invoked during non-fragmenting ChildOf cleanup can see not-alive children
  • [core] Fix issue with generating deterministic entity ids for prefab children
  • [core] Fix issue where delete_with(*, parent) leaves non-fragmenting children orphaned
  • [core] Prevent DontFragment components from being added to table types
  • [core] Fix issue with deferred setting of DontFragment component
  • [core] Fix issue with deferred cloning of a deleted entity
  • [core] Fix issue with removing sparse overridden component while deferred
  • [core] Fix issue where ctor is not called correctly when using With trait and emplace()
  • [core] Fix issue where Parent component was not assigned before invoking observers
  • [core] Fix issue where Parent.value was not always assigned when on_replace hook is called
  • [core] Fix issue where alignment macro could cause ASAN false positives
  • [core] Fix issue where hooks provided access to uninitialized components
  • [core] Fix issues with value pairs that have a 0 target
  • [cpp] Fix unreachable code warning for MSVC
  • [queries] Fix issue where component wildcard term doesn't match DontFragment component for entities without fragmenting components
  • [queries] Fix issue where component wildcard term doesn't match DontFragment components
  • [queries] Rebuild sorted table slices when shared order_by component changes
  • [queries] Fix crash when equality predicate with wildcard is in OR chain
  • [queries] Don't decrement cacheable term count for non-cacheable scope terms
  • [queries] Skip (ChildOf, 0) when matching ChildOf with wildcard target
  • [queries] Match all rows of non-fragmenting child tables in written sparse up
  • [queries] Reset cache iteration cursor when cache op is re-entered
  • [queries] Truncate wildcard match vector when rematch yields fewer matches
  • [queries] Fix optional up termination bound for ranges with offset
  • [queries] Detect multi-level up matches for sparse and non-fragmenting components
  • [queries] Continue scanning sibling targets when building up cache
  • [queries] Clamp slice to the source range when predicate matching
  • [queries] Use field index instead of term index for toggle instruction masks
  • [queries] Use field index of order_by term when checking change detection during sort
  • [queries] Widen query tokens_len to 32 bits to support expressions longer than 16kb
  • [queries] Fix crash when constrained pair target variable has no component record
  • [queries] Fix 32-bit shift overflow when constraining iterator variable with id >= 31
  • [queries] Use field index instead of term index for sparse row_fields bitmask
  • [queries] Map iterator set_fields to cache fields when checking change detection for partially cached queries
  • [queries] Sync wildcard match monitors when skipping empty tables during iteration
  • [queries] Fix neq predicate slice clamping and stale redo state for written sources
  • [queries] Fix issue where cached query for parent hierarchy could go out of sync after a shrink()
  • [queries] Fix change detection for fixed-source writes with tag before component
  • [queries] Fix issue with dynamic component queries for Any source
  • [queries] Fix assert when cascade source loses component with change detection
  • [queries] Fix query cache issue with up traversal and recycled entities
  • [queries] Fix issue with calling ecs_field_w_size on OR field
  • [queries] Fix issue with sparse wildcard pair term with not operator if pair was not yet created
  • [observers] Fix issue where observer for variable component is not always invoked
  • [observers] Fix issue where observers with non-this sources can return invalid references during world fini
  • [observers] Fix issue with yield_existing OnRemove observers where component is deleted before observer
  • [observers] Advance component record when forwarding multiple IsA pairs with dirty reachable cache
  • [observers] Don't forward Parent component as ChildOf pair twice when wildcard event observer exists
  • [observers] Invalidate reachable-id cache when target deleted via non-fragmenting cleanup
  • [observers] Fix duplicate OnSet for sparse overrides during prefab instantiation
  • [observers] Fix issue where filter terms would not correctly forward table events
  • [observers] Fix stale trs/sizes during observer event forwarding
  • [observers] Fix issue where code read relationship from id without making sure id is a pair (2)
  • [observers] Fix observer up-traversal matching non-pair ids with colliding generation
  • [observers] Fix issue where event deduping wasn't working correctly for observer propagation
  • [observers] Fix issue where observers would lock the wrong table
  • [observers] Fix issues with variables in triggered term of observer
  • [commands] Fix removal of dont-fragment component on entity deleted by batched command flush
  • [commands] Fix spurious unparent when add/remove of ChildOf is batched on dont-fragment entity
  • [commands] Don't transfer parent table records twice for batched remove+add
  • [commands] Don't drop batched ensure on non-fragmenting components
  • [pipelines] Fix issue where .write() on singleton component doesn't trigger sync point
  • [meta] Accept NaN and Inf when deserializing floating point values
  • [meta] Parse unsigned 64-bit values without signed overflow in set_string
  • [meta] Compare all elements of array members in RTT cmp/equals hooks
  • [meta] Serialize uintptr values as full 64-bit unsigned
  • [meta] Read enum underlying type in ecs_meta_set_value
  • [meta] Fix ecs_meta_get_char returning boolean instead of char value
  • [meta] Free all serializer value contexts when serializing table to JSON
  • [meta] Add bounds check to flecs_parse_digit to reject too-long number literals
  • [meta] Reject single-character string literals in ecs_meta_set_string_literal
  • [meta] Fix rtt vector equals returning true for vectors of different length
  • [json] Limit control character escaping to component value strings
  • [json] Handle invalid escape sequences when parsing JSON strings
  • [json] Escape control characters in serialized JSON strings
  • [json] Sign-extend signed enum values when serializing to JSON
  • [json] Fix issue with deserializing DontFragment components from JSON
  • [json] Fix issue where sparse tags aren't serialized to JSON
  • [json] Fix issues with escaping characters in JSON
  • [http] Fix idle HTTP connection purge and the stale-fd race (thanks @pogeyoji!)
  • [script] Fix issue where 'using' wasn't taken into account inside of script function bodies
  • [script] Fix template preprocessing of new expression in const
  • [script] Fix issues with reporting line numbers for script errors
  • [script] Fix issue with partial updates and expression folding
  • [script] Fix default child component resolution in nested scopes
  • [script] Return error instead of aborting on float equality comparison
  • [script] Fail script evaluation when annotation cannot be applied
  • [script] Add bounds check to expression element access
  • [script] Fix component assignment with match expression
  • [script] Fix template preprocessing of component pairs and entity names with vars
  • [script] Extend iterator field name array to support up to 32 fields
  • [script] Skip stale deferred template instantiation events
  • [script] Allow newlines in scripts between with expressions and with scope
  • [script] Fix issue where statements after if-else block would not be evaluated
  • [script] Ensure that script eval errors are always logged to the console
  • [script] Fix issue with deserializing vectors from script
  • [parser] Fix buffer overflow from double-parse in flecs_term_parse
  • [parser] Fix out of bounds read when string ends with backslash
  • [parser] Size token buffer to input in flecs_id_parse to prevent overflow
  • [parser] Fix null pointer deref when parsing id with too many pair args
  • [parser] Fix query parser bugs
  • [modules] Fix issue with loading module from dynamic library
  • [log] Fix issue with calling ecs_log_start_capture() twice without ecs_log_stop_capture()

Breaking changes

  • [core] New entity ranges API that replaces the ecs_set_entity_range() API
  • [queries] Query groups are no longer iterated in order by default
  • [build] Changes to how the flecs source code amalgamation works

New Contributors

Full Changelog: v4.1.5...v4.1.6