Compare commits
3 commits
74b7959cfb
...
fc34fa49ff
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fc34fa49ff | ||
![]() |
dfc887561e | ||
005b7bcfbb |
10 changed files with 101 additions and 56 deletions
|
@ -1,8 +1,9 @@
|
||||||
{
|
{
|
||||||
"aliases": {
|
"aliases": {
|
||||||
"jecs": "jecs",
|
"jecs": "jecs",
|
||||||
"testkit": "test/testkit",
|
"testkit": "tools/testkit",
|
||||||
"mirror": "mirror"
|
"mirror": "mirror",
|
||||||
|
"tools": "tools",
|
||||||
},
|
},
|
||||||
"languageMode": "strict"
|
"languageMode": "strict"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
modified = ["jecs.luau"]
|
modified = [".luaurc", "jecs.luau"]
|
||||||
version = "0.5.5-nightly.20250308T001059Z"
|
version = "0.5.5-nightly.20250312T202956Z"
|
||||||
|
|
104
jecs/jecs.luau
104
jecs/jecs.luau
|
@ -46,7 +46,7 @@ export type Record = {
|
||||||
}
|
}
|
||||||
|
|
||||||
type IdRecord = {
|
type IdRecord = {
|
||||||
columns: { number },
|
cache: { number },
|
||||||
counts: { number },
|
counts: { number },
|
||||||
flags: number,
|
flags: number,
|
||||||
size: number,
|
size: number,
|
||||||
|
@ -480,7 +480,7 @@ local function world_target(world: World, entity: i53, relation: i24, index: num
|
||||||
nth = nth + count + 1
|
nth = nth + count + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local tr = idr.columns[archetype_id]
|
local tr = idr.cache[archetype_id]
|
||||||
|
|
||||||
nth = archetype.types[nth + tr]
|
nth = archetype.types[nth + tr]
|
||||||
|
|
||||||
|
@ -537,7 +537,7 @@ local function id_record_ensure(world: World, id: number): IdRecord
|
||||||
|
|
||||||
idr = {
|
idr = {
|
||||||
size = 0,
|
size = 0,
|
||||||
columns = {},
|
cache = {},
|
||||||
counts = {},
|
counts = {},
|
||||||
flags = flags,
|
flags = flags,
|
||||||
hooks = {
|
hooks = {
|
||||||
|
@ -562,7 +562,7 @@ local function archetype_append_to_records(
|
||||||
local archetype_id = archetype.id
|
local archetype_id = archetype.id
|
||||||
local archetype_records = archetype.records
|
local archetype_records = archetype.records
|
||||||
local archetype_counts = archetype.counts
|
local archetype_counts = archetype.counts
|
||||||
local idr_columns = idr.columns
|
local idr_columns = idr.cache
|
||||||
local idr_counts = idr.counts
|
local idr_counts = idr.counts
|
||||||
local tr = idr_columns[archetype_id]
|
local tr = idr_columns[archetype_id]
|
||||||
if not tr then
|
if not tr then
|
||||||
|
@ -1063,7 +1063,7 @@ local function archetype_destroy(world: World, archetype: Archetype)
|
||||||
|
|
||||||
for id in records do
|
for id in records do
|
||||||
local idr = component_index[id]
|
local idr = component_index[id]
|
||||||
idr.columns[archetype_id] = nil :: any
|
idr.cache[archetype_id] = nil :: any
|
||||||
idr.counts[archetype_id] = nil
|
idr.counts[archetype_id] = nil
|
||||||
idr.size -= 1
|
idr.size -= 1
|
||||||
records[id] = nil :: any
|
records[id] = nil :: any
|
||||||
|
@ -1122,7 +1122,7 @@ do
|
||||||
if idr then
|
if idr then
|
||||||
local flags = idr.flags
|
local flags = idr.flags
|
||||||
if bit32.band(flags, ECS_ID_DELETE) ~= 0 then
|
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 idr_archetype = archetypes[archetype_id]
|
||||||
|
|
||||||
local entities = idr_archetype.entities
|
local entities = idr_archetype.entities
|
||||||
|
@ -1134,7 +1134,7 @@ do
|
||||||
archetype_destroy(world, idr_archetype)
|
archetype_destroy(world, idr_archetype)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for archetype_id in idr.columns do
|
for archetype_id in idr.cache do
|
||||||
local idr_archetype = archetypes[archetype_id]
|
local idr_archetype = archetypes[archetype_id]
|
||||||
local entities = idr_archetype.entities
|
local entities = idr_archetype.entities
|
||||||
local n = #entities
|
local n = #entities
|
||||||
|
@ -1147,55 +1147,66 @@ do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local sparse_array = entity_index.sparse_array
|
|
||||||
local dense_array = entity_index.dense_array
|
local dense_array = entity_index.dense_array
|
||||||
|
|
||||||
if idr_t then
|
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_archetype = archetypes[archetype_id]
|
||||||
|
|
||||||
local idr_t_types = idr_t_archetype.types
|
local idr_t_types = idr_t_archetype.types
|
||||||
|
local entities = idr_t_archetype.entities
|
||||||
for _, child in idr_t_archetype.entities do
|
local removal_queued = false
|
||||||
table.insert(children, child)
|
|
||||||
end
|
|
||||||
|
|
||||||
local n = #children
|
|
||||||
|
|
||||||
for _, id in idr_t_types do
|
for _, id in idr_t_types do
|
||||||
if not ECS_IS_PAIR(id) then
|
if not ECS_IS_PAIR(id) then
|
||||||
continue
|
continue
|
||||||
end
|
end
|
||||||
local object = ecs_pair_second(world, id)
|
local object = ecs_pair_second(world, id)
|
||||||
if object == delete then
|
if object ~= delete then
|
||||||
local id_record = component_index[id]
|
continue
|
||||||
local flags = id_record.flags
|
end
|
||||||
local flags_delete_mask: number = bit32.band(flags, ECS_ID_DELETE)
|
local id_record = component_index[id]
|
||||||
if flags_delete_mask ~= 0 then
|
local flags = id_record.flags
|
||||||
for i = n, 1, -1 do
|
local flags_delete_mask: number = bit32.band(flags, ECS_ID_DELETE)
|
||||||
world_delete(world, children[i])
|
if flags_delete_mask ~= 0 then
|
||||||
end
|
for i = #entities, 1, -1 do
|
||||||
break
|
local child = entities[i]
|
||||||
else
|
world_delete(world, child)
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
break
|
||||||
|
else
|
||||||
|
if not ids then
|
||||||
|
ids = {}
|
||||||
|
end
|
||||||
|
ids[id] = true
|
||||||
|
removal_queued = true
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2096,7 +2107,7 @@ local function world_query(world: World, ...)
|
||||||
return q
|
return q
|
||||||
end
|
end
|
||||||
|
|
||||||
for archetype_id in idr.columns do
|
for archetype_id in idr.cache do
|
||||||
local compatibleArchetype = archetypes[archetype_id]
|
local compatibleArchetype = archetypes[archetype_id]
|
||||||
if #compatibleArchetype.entities == 0 then
|
if #compatibleArchetype.entities == 0 then
|
||||||
continue
|
continue
|
||||||
|
@ -2130,9 +2141,9 @@ local function world_each(world: World, id): () -> ()
|
||||||
return NOOP
|
return NOOP
|
||||||
end
|
end
|
||||||
|
|
||||||
local idr_columns = idr.columns
|
local idr_cache = idr.cache
|
||||||
local archetypes = world.archetypes
|
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]
|
local archetype = archetypes[archetype_id]
|
||||||
if not archetype then
|
if not archetype then
|
||||||
return NOOP
|
return NOOP
|
||||||
|
@ -2144,7 +2155,7 @@ local function world_each(world: World, id): () -> ()
|
||||||
return function(): any
|
return function(): any
|
||||||
local entity = entities[row]
|
local entity = entities[row]
|
||||||
while not entity do
|
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
|
if not archetype_id then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -2477,6 +2488,7 @@ export type World = {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
World = World :: { new: () -> World },
|
World = World :: { new: () -> World },
|
||||||
|
world = World.new :: () -> World,
|
||||||
|
|
||||||
OnAdd = EcsOnAdd :: Entity<(entity: Entity) -> ()>,
|
OnAdd = EcsOnAdd :: Entity<(entity: Entity) -> ()>,
|
||||||
OnRemove = EcsOnRemove :: Entity<(entity: Entity) -> ()>,
|
OnRemove = EcsOnRemove :: Entity<(entity: Entity) -> ()>,
|
||||||
|
@ -2500,6 +2512,8 @@ return {
|
||||||
ECS_GENERATION = ECS_GENERATION,
|
ECS_GENERATION = ECS_GENERATION,
|
||||||
ECS_ID_IS_WILDCARD = ECS_ID_IS_WILDCARD,
|
ECS_ID_IS_WILDCARD = ECS_ID_IS_WILDCARD,
|
||||||
|
|
||||||
|
ECS_ID_DELETE = ECS_ID_DELETE,
|
||||||
|
|
||||||
IS_PAIR = ECS_IS_PAIR,
|
IS_PAIR = ECS_IS_PAIR,
|
||||||
pair_first = ecs_pair_first,
|
pair_first = ecs_pair_first,
|
||||||
pair_second = ecs_pair_second,
|
pair_second = ecs_pair_second,
|
||||||
|
|
14
jecs/pesde-rbx.toml
Normal file
14
jecs/pesde-rbx.toml
Normal 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"
|
|
@ -3,7 +3,7 @@ includes = ["init.luau", "pesde.toml", "README.md", "CHANGELOG.md", "LICENSE", "
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "marked/jecs_nightly"
|
name = "marked/jecs_nightly"
|
||||||
repository = "https://git.devmarked.win/marked/jecs-nightly"
|
repository = "https://git.devmarked.win/marked/jecs-nightly"
|
||||||
version = "0.5.5-nightly.20250308T001059Z"
|
version = "0.5.5-nightly.20250312T202956Z"
|
||||||
|
|
||||||
[indices]
|
[indices]
|
||||||
default = "https://github.com/pesde-pkg/index"
|
default = "https://github.com/pesde-pkg/index"
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
passed = true
|
passed = true
|
||||||
timestamp = "20250312T001101Z"
|
timestamp = "20250313T001123Z"
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
[38;1m8.2[0m [33;1mus[0m [38;1m 3[0m [33;1mkB[0m[38;1m│[0m [38;1mdelete children of entity[0m
|
271 272 273
|
||||||
[38;1m9.4[0m [33;1mus[0m [38;1m 1[0m [33;1mkB[0m[38;1m│[0m [38;1mremove friends of entity[0m
|
---------------- delete e2 ---------------
|
||||||
[38;1m339[0m [32;1mns[0m [38;1m 0[0m [32;1m B[0m[38;1m│[0m [38;1msimple deletion of entity[0m
|
"268439800_268439816_536875256_536875272"
|
||||||
|
"268439800_268439816_536875256"
|
||||||
|
"268439816_536875272"
|
||||||
|
"268439816"
|
||||||
|
-----------------------------
|
||||||
|
{}
|
||||||
|
[38;1m7.3[0m [33;1mus[0m [38;1m 2[0m [33;1mkB[0m[38;1m│[0m [38;1mdelete children of entity[0m
|
||||||
|
[38;1m 10[0m [33;1mus[0m [38;1m 2[0m [33;1mkB[0m[38;1m│[0m [38;1mremove friends of entity[0m
|
||||||
|
[38;1m328[0m [32;1mns[0m [38;1m 0[0m [32;1m B[0m[38;1m│[0m [38;1msimple deletion of entity[0m
|
||||||
removing
|
removing
|
||||||
|
[37;1m#repro[0m
|
||||||
|
[38;5;208mNONE[0m[38;1m│[0m [38;1m[0m
|
||||||
|
|
||||||
[37;1marchetype[0m
|
[37;1marchetype[0m
|
||||||
[32;1mPASS[0m[38;1m│[0m [38;1m[0m
|
[32;1mPASS[0m[38;1m│[0m [38;1m[0m
|
||||||
|
|
||||||
|
@ -110,5 +121,5 @@ removing
|
||||||
[32;1mPASS[0m[38;1m│[0m [38;1m#2[0m
|
[32;1mPASS[0m[38;1m│[0m [38;1m#2[0m
|
||||||
[32;1mPASS[0m[38;1m│[0m [38;1m#3[0m
|
[32;1mPASS[0m[38;1m│[0m [38;1m#3[0m
|
||||||
|
|
||||||
[38;1m68/68 test cases passed in 31.914 ms.[0m
|
[38;1m69/69 test cases passed in 33.365 ms.[0m
|
||||||
[32;1m0 fails[0m
|
[32;1m0 fails[0m
|
||||||
|
|
|
@ -5,4 +5,4 @@ license = "MIT"
|
||||||
name = "mark-marks/jecs-nightly"
|
name = "mark-marks/jecs-nightly"
|
||||||
realm = "shared"
|
realm = "shared"
|
||||||
registry = "https://github.com/UpliftGames/wally-index"
|
registry = "https://github.com/UpliftGames/wally-index"
|
||||||
version = "0.5.5-nightly.20250308T001059Z"
|
version = "0.5.5-nightly.20250312T202956Z"
|
||||||
|
|
|
@ -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}`)
|
print(`-- Pesde out:\nstdout\n{res_pesde.stdout}\nstderr\n{res_pesde.stderr}`)
|
||||||
end
|
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
|
if res_wally then
|
||||||
print(`-- Wally out:\nstdout\n{res_wally.stdout}\nstderr\n{res_wally.stderr}`)
|
print(`-- Wally out:\nstdout\n{res_wally.stdout}\nstderr\n{res_wally.stderr}`)
|
||||||
end
|
end
|
||||||
|
|
|
@ -82,6 +82,7 @@ local function test(origin: string): result.Identity<boolean>
|
||||||
progress:nextStage() -- cleanup
|
progress:nextStage() -- cleanup
|
||||||
|
|
||||||
fs.removeDir(`{origin}/test`)
|
fs.removeDir(`{origin}/test`)
|
||||||
|
fs.removeDir(`{origin}/tools`)
|
||||||
|
|
||||||
progress:nextStage() -- metadata
|
progress:nextStage() -- metadata
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue