Compare commits

...

2 commits

Author SHA1 Message Date
forgejo-actions
209ec0c2bf Sync to upstream Jecs 0.5.5-nightly.20250428T001101Z 2025-04-28 00:11:19 +00:00
5acca197e0 Sync to released Jecs 0.5.5-nightly.20250427T001102Z (#46)
Reviewed-on: #46
2025-04-27 02:11:22 +02:00
7 changed files with 45 additions and 51 deletions

View file

@ -1,2 +1,2 @@
modified = ["addons/observers.luau", "CHANGELOG.md", "jecs.luau"]
version = "0.5.5-nightly.20250426T001101Z"
modified = ["jecs.luau"]
version = "0.5.5-nightly.20250428T001101Z"

View file

@ -772,38 +772,26 @@ local function world_entity(world: ecs_world_t, entity: i53?): i53
local r = sparse_array[index]
if r then
local dense = r.dense
if not dense or dense == 0 then
if not dense or r.dense == 0 then
r.dense = index
dense = index
end
local any = dense_array[dense]
if any == entity then
if alive_count > dense then
r.dense = dense
return entity
end
local e_swap = dense_array[alive_count]
local r_swap = sparse_array[alive_count]
r_swap.dense = dense
r.dense = alive_count
dense_array[alive_count] = entity
dense_array[dense] = e_swap
return entity
end
-- assert(any ~= 0) should never happen
local e_swap = dense_array[alive_count]
local r_swap = sparse_array[alive_count]
if dense <= alive_count then
alive_count += 1
entity_index.alive_count = alive_count
return any
end
local e_swap = dense_array[dense]
local r_swap = entity_index_try_get_any(entity_index, e_swap) :: ecs_record_t
alive_count += 1
entity_index.alive_count = alive_count
r_swap.dense = dense
r.dense = alive_count
dense_array[alive_count] = any
dense_array[dense] = e_swap
dense_array[alive_count] = any
return any
else
for i = max_id + 1, index do
@ -1437,19 +1425,24 @@ local function world_delete(world: ecs_world_t, entity: i53)
end
local dense_array = entity_index.dense_array
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 dense = record.dense
local i_swap = entity_index.alive_count
entity_index.alive_count = i_swap - 1
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
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
record.archetype = nil :: any
record.row = nil :: any
record.dense = index_of_last_alive_entity
record.dense = i_swap
dense_array[index_of_deleted_entity] = last_alive_entity
dense_array[index_of_last_alive_entity] = ECS_GENERATION_INC(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
end
local function world_contains(world: ecs_world_t, entity): boolean
@ -2443,6 +2436,7 @@ 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
@ -2482,12 +2476,6 @@ 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,6 +2498,10 @@ 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
@ -2612,6 +2604,9 @@ 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: <T>(self: World, id: Id<T>) -> () -> Entity,
children: <T>(self: World, id: Id<T>) -> () -> Entity,

View file

@ -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.20250426T001101Z"
version = "0.5.5-nightly.20250428T001101Z"
[indices]
default = "https://github.com/pesde-pkg/index"

View file

@ -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.20250426T001101Z"
version = "0.5.5-nightly.20250428T001101Z"
[indices]
default = "https://github.com/pesde-pkg/index"

View file

@ -1,2 +1,2 @@
passed = true
timestamp = "20250426T001103Z"
timestamp = "20250428T001103Z"

View file

@ -1,8 +1,6 @@
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
7.6 us  2 kB│ delete children of entity
9.1 us  1 kB│ remove friends of entity
346 ns  0  B│ simple deletion of entity
world:add()
PASS│ idempotent
PASS│ archetype move
@ -40,7 +38,8 @@ hm... 271
PASS│ 
world:range()
PASS│ 
PASS│ under range start
PASS│ over range start
world:entity()
PASS│ desired id
@ -119,5 +118,5 @@ hm... 271
PASS│ #2
PASS│ #3
72/72 test cases passed in 31.076 ms.
73/73 test cases passed in 33.504 ms.
0 fails

View file

@ -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.20250426T001101Z"
version = "0.5.5-nightly.20250428T001101Z"