Compare commits

...

3 commits

Author SHA1 Message Date
forgejo-actions
fc34fa49ff Sync to upstream Jecs 0.5.5-nightly.20250312T202956Z 2025-03-13 00:11:34 +00:00
marked
dfc887561e -tools 2025-03-12 21:34:03 +01:00
005b7bcfbb Sync to released Jecs 0.5.5-nightly.20250312T202956Z (#19)
Reviewed-on: #19
2025-03-12 21:30:20 +01:00
10 changed files with 101 additions and 56 deletions

View file

@ -1,8 +1,9 @@
{
"aliases": {
"jecs": "jecs",
"testkit": "test/testkit",
"mirror": "mirror"
"testkit": "tools/testkit",
"mirror": "mirror",
"tools": "tools",
},
"languageMode": "strict"
}

View file

@ -1,2 +1,2 @@
modified = ["jecs.luau"]
version = "0.5.5-nightly.20250308T001059Z"
modified = [".luaurc", "jecs.luau"]
version = "0.5.5-nightly.20250312T202956Z"

View file

@ -46,7 +46,7 @@ export type Record = {
}
type IdRecord = {
columns: { number },
cache: { number },
counts: { number },
flags: number,
size: number,
@ -480,7 +480,7 @@ local function world_target(world: World, entity: i53, relation: i24, index: num
nth = nth + count + 1
end
local tr = idr.columns[archetype_id]
local tr = idr.cache[archetype_id]
nth = archetype.types[nth + tr]
@ -537,7 +537,7 @@ local function id_record_ensure(world: World, id: number): IdRecord
idr = {
size = 0,
columns = {},
cache = {},
counts = {},
flags = flags,
hooks = {
@ -562,7 +562,7 @@ local function archetype_append_to_records(
local archetype_id = archetype.id
local archetype_records = archetype.records
local archetype_counts = archetype.counts
local idr_columns = idr.columns
local idr_columns = idr.cache
local idr_counts = idr.counts
local tr = idr_columns[archetype_id]
if not tr then
@ -1063,7 +1063,7 @@ local function archetype_destroy(world: World, archetype: Archetype)
for id in records do
local idr = component_index[id]
idr.columns[archetype_id] = nil :: any
idr.cache[archetype_id] = nil :: any
idr.counts[archetype_id] = nil
idr.size -= 1
records[id] = nil :: any
@ -1122,7 +1122,7 @@ do
if idr then
local flags = idr.flags
if bit32.band(flags, ECS_ID_DELETE) ~= 0 then
for archetype_id in idr.columns do
for archetype_id in idr.cache do
local idr_archetype = archetypes[archetype_id]
local entities = idr_archetype.entities
@ -1134,7 +1134,7 @@ do
archetype_destroy(world, idr_archetype)
end
else
for archetype_id in idr.columns do
for archetype_id in idr.cache do
local idr_archetype = archetypes[archetype_id]
local entities = idr_archetype.entities
local n = #entities
@ -1147,55 +1147,66 @@ do
end
end
local sparse_array = entity_index.sparse_array
local dense_array = entity_index.dense_array
if idr_t then
for archetype_id in idr_t.columns do
local children = {}
local children
local ids
local count = 0
local archetype_ids = idr_t.cache
for archetype_id in archetype_ids do
local idr_t_archetype = archetypes[archetype_id]
local idr_t_types = idr_t_archetype.types
for _, child in idr_t_archetype.entities do
table.insert(children, child)
end
local n = #children
local entities = idr_t_archetype.entities
local removal_queued = false
for _, id in idr_t_types do
if not ECS_IS_PAIR(id) then
continue
end
local object = ecs_pair_second(world, id)
if object == delete then
local id_record = component_index[id]
local flags = id_record.flags
local flags_delete_mask: number = bit32.band(flags, ECS_ID_DELETE)
if flags_delete_mask ~= 0 then
for i = n, 1, -1 do
world_delete(world, children[i])
end
break
else
local on_remove = id_record.hooks.on_remove
local to = archetype_traverse_remove(world, id, idr_t_archetype)
local empty = #to.types == 0
for i = n, 1, -1 do
local child = children[i]
if on_remove then
on_remove(child)
end
local r = sparse_array[ECS_ENTITY_T_LO(child)]
if not empty then
entity_move(entity_index, child, r, to)
end
end
if object ~= delete then
continue
end
local id_record = component_index[id]
local flags = id_record.flags
local flags_delete_mask: number = bit32.band(flags, ECS_ID_DELETE)
if flags_delete_mask ~= 0 then
for i = #entities, 1, -1 do
local child = entities[i]
world_delete(world, child)
end
break
else
if not ids then
ids = {}
end
ids[id] = true
removal_queued = true
end
end
archetype_destroy(world, idr_t_archetype)
if not removal_queued then
continue
end
if not children then
children = {}
end
local n = #entities
table.move(entities, 1, n, count + 1, children)
count += n
end
if ids then
for id in ids do
for _, child in children do
world_remove(world, child, id)
end
end
end
for archetype_id in archetype_ids do
archetype_destroy(world, archetypes[archetype_id])
end
end
@ -2096,7 +2107,7 @@ local function world_query(world: World, ...)
return q
end
for archetype_id in idr.columns do
for archetype_id in idr.cache do
local compatibleArchetype = archetypes[archetype_id]
if #compatibleArchetype.entities == 0 then
continue
@ -2130,9 +2141,9 @@ local function world_each(world: World, id): () -> ()
return NOOP
end
local idr_columns = idr.columns
local idr_cache = idr.cache
local archetypes = world.archetypes
local archetype_id = next(idr_columns, nil) :: number
local archetype_id = next(idr_cache, nil) :: number
local archetype = archetypes[archetype_id]
if not archetype then
return NOOP
@ -2144,7 +2155,7 @@ local function world_each(world: World, id): () -> ()
return function(): any
local entity = entities[row]
while not entity do
archetype_id = next(idr_columns, archetype_id) :: number
archetype_id = next(idr_cache, archetype_id) :: number
if not archetype_id then
return
end
@ -2477,6 +2488,7 @@ export type World = {
return {
World = World :: { new: () -> World },
world = World.new :: () -> World,
OnAdd = EcsOnAdd :: Entity<(entity: Entity) -> ()>,
OnRemove = EcsOnRemove :: Entity<(entity: Entity) -> ()>,
@ -2500,6 +2512,8 @@ return {
ECS_GENERATION = ECS_GENERATION,
ECS_ID_IS_WILDCARD = ECS_ID_IS_WILDCARD,
ECS_ID_DELETE = ECS_ID_DELETE,
IS_PAIR = ECS_IS_PAIR,
pair_first = ecs_pair_first,
pair_second = ecs_pair_second,

14
jecs/pesde-rbx.toml Normal file
View file

@ -0,0 +1,14 @@
authors = ["jecs authors"]
includes = ["init.luau", "pesde.toml", "README.md", "CHANGELOG.md", "LICENSE", ".luaurc"]
license = "MIT"
name = "marked/jecs_nightly"
repository = "https://git.devmarked.win/marked/jecs-nightly"
version = "0.5.5-nightly.20250312T202956Z"
[indices]
default = "https://github.com/pesde-pkg/index"
[target]
build_files = ["jecs.luau"]
environment = "roblox"
lib = "jecs.luau"

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.20250308T001059Z"
version = "0.5.5-nightly.20250312T202956Z"
[indices]
default = "https://github.com/pesde-pkg/index"

View file

@ -1,2 +1,2 @@
passed = true
timestamp = "20250312T001101Z"
timestamp = "20250313T001123Z"

View file

@ -1,7 +1,18 @@
8.2 us  3 kB│ delete children of entity
9.4 us  1 kB│ remove friends of entity
339 ns  0  B│ simple deletion of entity
271 272 273
---------------- delete e2 ---------------
"268439800_268439816_536875256_536875272"
"268439800_268439816_536875256"
"268439816_536875272"
"268439816"
-----------------------------
{}
7.3 us  2 kB│ delete children of entity
 10 us  2 kB│ remove friends of entity
328 ns  0  B│ simple deletion of entity
removing
#repro
NONE│ 
archetype
PASS│ 
@ -110,5 +121,5 @@ removing
PASS│ #2
PASS│ #3
68/68 test cases passed in 31.914 ms.
69/69 test cases passed in 33.365 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.20250308T001059Z"
version = "0.5.5-nightly.20250312T202956Z"

View file

@ -177,6 +177,10 @@ local function release(origin: string, scopes: { wally: string?, pesde: string?
print(`-- Pesde out:\nstdout\n{res_pesde.stdout}\nstderr\n{res_pesde.stderr}`)
end
if res_pesde_rbx then
print(`-- Pesde rbx out:\nstdout\n{res_pesde.stdout}\nstderr\n{res_pesde.stderr}`)
end
if res_wally then
print(`-- Wally out:\nstdout\n{res_wally.stdout}\nstderr\n{res_wally.stderr}`)
end

View file

@ -82,6 +82,7 @@ local function test(origin: string): result.Identity<boolean>
progress:nextStage() -- cleanup
fs.removeDir(`{origin}/test`)
fs.removeDir(`{origin}/tools`)
progress:nextStage() -- metadata