diff --git a/jecs/build.txt b/jecs/build.txt index f754d8c..e3fde5a 100644 --- a/jecs/build.txt +++ b/jecs/build.txt @@ -1,2 +1,2 @@ -modified = ["jecs.luau"] -version = "0.5.5-nightly.20250427T001102Z" +modified = ["addons/observers.luau", "CHANGELOG.md", "jecs.luau"] +version = "0.5.5-nightly.20250426T001101Z" diff --git a/jecs/jecs.luau b/jecs/jecs.luau index 7bfeb68..94415af 100644 --- a/jecs/jecs.luau +++ b/jecs/jecs.luau @@ -1437,24 +1437,19 @@ local function world_delete(world: ecs_world_t, entity: i53) end local dense_array = entity_index.dense_array - local dense = record.dense - local i_swap = entity_index.alive_count - entity_index.alive_count = i_swap - 1 + local index_of_deleted_entity = record.dense + local index_of_last_alive_entity = entity_index.alive_count + entity_index.alive_count = index_of_last_alive_entity - 1 - local e_swap = dense_array[i_swap] - local r_swap = entity_index_try_get_any(entity_index, e_swap) :: ecs_record_t - - r_swap.dense = dense + local last_alive_entity = dense_array[index_of_last_alive_entity] + local r_swap = entity_index_try_get_any(entity_index, last_alive_entity) :: ecs_record_t + r_swap.dense = index_of_deleted_entity record.archetype = nil :: any record.row = nil :: any - record.dense = i_swap + record.dense = index_of_last_alive_entity - dense_array[dense] = e_swap - dense_array[i_swap] = ECS_GENERATION_INC(entity) -end - -local function world_exists(world: ecs_world_t, entity): boolean - return entity_index_try_get_any(world.entity_index, entity) ~= nil + dense_array[index_of_deleted_entity] = last_alive_entity + dense_array[index_of_last_alive_entity] = ECS_GENERATION_INC(entity) end local function world_contains(world: ecs_world_t, entity): boolean @@ -2448,7 +2443,6 @@ World.has = world_has World.target = world_target World.parent = world_parent World.contains = world_contains -World.exists = world_exists World.cleanup = world_cleanup World.each = world_each World.children = world_children @@ -2488,6 +2482,12 @@ local function world_new() entity_index_new_id(entity_index) end + for i = EcsRest + 1, ecs_max_tag_id do + -- Initialize built-in components + entity_index_new_id(entity_index) + print("hm...", i) + end + world_add(self, EcsName, EcsComponent) world_add(self, EcsOnChange, EcsComponent) world_add(self, EcsOnAdd, EcsComponent) @@ -2510,10 +2510,6 @@ local function world_new() world_add(self, EcsChildOf, ECS_PAIR(EcsOnDeleteTarget, EcsDelete)) - for i = EcsRest + 1, ecs_max_tag_id do - entity_index_new_id(entity_index) - end - for i, bundle in ecs_metadata do for ty, value in bundle do if value == NULL then @@ -2616,9 +2612,6 @@ export type World = { --- Checks if the world contains the given entity contains:(self: World, entity: Entity) -> boolean, - --- Checks if the entity exists - exists: (self: World, entity: Entity) -> boolean, - each: (self: World, id: Id) -> () -> Entity, children: (self: World, id: Id) -> () -> Entity, diff --git a/jecs/pesde-rbx.toml b/jecs/pesde-rbx.toml index 3b3b005..e575978 100644 --- a/jecs/pesde-rbx.toml +++ b/jecs/pesde-rbx.toml @@ -3,7 +3,7 @@ includes = ["init.luau", "pesde.toml", "README.md", "CHANGELOG.md", "LICENSE", " license = "MIT" name = "marked/jecs_nightly" repository = "https://git.devmarked.win/marked/jecs-nightly" -version = "0.5.5-nightly.20250427T001102Z" +version = "0.5.5-nightly.20250426T001101Z" [indices] default = "https://github.com/pesde-pkg/index" diff --git a/jecs/pesde.toml b/jecs/pesde.toml index 6c79fa2..cba3853 100644 --- a/jecs/pesde.toml +++ b/jecs/pesde.toml @@ -3,7 +3,7 @@ includes = ["init.luau", "pesde.toml", "README.md", "CHANGELOG.md", "LICENSE", " license = "MIT" name = "marked/jecs_nightly" repository = "https://git.devmarked.win/marked/jecs-nightly" -version = "0.5.5-nightly.20250427T001102Z" +version = "0.5.5-nightly.20250426T001101Z" [indices] default = "https://github.com/pesde-pkg/index" diff --git a/jecs/test.txt b/jecs/test.txt index 05f27df..67f4934 100644 --- a/jecs/test.txt +++ b/jecs/test.txt @@ -1,2 +1,2 @@ passed = true -timestamp = "20250427T001104Z" +timestamp = "20250426T001103Z" diff --git a/jecs/test_fulllog.txt b/jecs/test_fulllog.txt index d10e2fa..89c1324 100644 --- a/jecs/test_fulllog.txt +++ b/jecs/test_fulllog.txt @@ -1,5 +1,6 @@ -7.2 us  2 kB│ delete children of entity -9.2 us  1 kB│ remove friends of entity +hm... 271 +7.7 us  3 kB│ delete children of entity +9.3 us  1 kB│ remove friends of entity 349 ns  0  B│ simple deletion of entity *created e1000v0 world:add() @@ -118,5 +119,5 @@ PASS│ #2 PASS│ #3 -72/72 test cases passed in 32.525 ms. +72/72 test cases passed in 31.076 ms. 0 fails diff --git a/jecs/wally.toml b/jecs/wally.toml index 2ebd701..d23c40e 100644 --- a/jecs/wally.toml +++ b/jecs/wally.toml @@ -5,4 +5,4 @@ license = "MIT" name = "mark-marks/jecs-nightly" realm = "shared" registry = "https://github.com/UpliftGames/wally-index" -version = "0.5.5-nightly.20250427T001102Z" +version = "0.5.5-nightly.20250426T001101Z"