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": {
|
||||
"jecs": "jecs",
|
||||
"testkit": "test/testkit",
|
||||
"mirror": "mirror"
|
||||
"testkit": "tools/testkit",
|
||||
"mirror": "mirror",
|
||||
"tools": "tools",
|
||||
},
|
||||
"languageMode": "strict"
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
modified = ["jecs.luau"]
|
||||
version = "0.5.5-nightly.20250308T001059Z"
|
||||
modified = [".luaurc", "jecs.luau"]
|
||||
version = "0.5.5-nightly.20250312T202956Z"
|
||||
|
|
104
jecs/jecs.luau
104
jecs/jecs.luau
|
@ -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
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"
|
||||
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"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
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
|
||||
[38;1m9.4[0m [33;1mus[0m [38;1m 1[0m [33;1mkB[0m[38;1m│[0m [38;1mremove friends of entity[0m
|
||||
[38;1m339[0m [32;1mns[0m [38;1m 0[0m [32;1m B[0m[38;1m│[0m [38;1msimple deletion of entity[0m
|
||||
271 272 273
|
||||
---------------- delete e2 ---------------
|
||||
"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
|
||||
[37;1m#repro[0m
|
||||
[38;5;208mNONE[0m[38;1m│[0m [38;1m[0m
|
||||
|
||||
[37;1marchetype[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#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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue