mirror of
https://github.com/Ukendio/jecs.git
synced 2025-08-04 03:09:18 +00:00
Fix benchmark of remove
This commit is contained in:
parent
8b7ddf5c46
commit
d40bcd0c72
4 changed files with 35 additions and 10 deletions
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -2,6 +2,20 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `jecs.Exclusive` trait for making exclusive relationships.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- `jecs.Child` to be an exclusive relationship, which means you can only have one `ChildOf` pair on an entity.
|
||||||
|
|
||||||
|
## 0.7.2
|
||||||
|
### Added
|
||||||
|
- `jecs.entity_index_try_get_fast` back as to not break the observer addon.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- A linting problem with the types for `quer:with` and `query:without`.
|
||||||
|
|
||||||
|
|
||||||
## 0.7.0
|
## 0.7.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -35,16 +35,17 @@ return {
|
||||||
Mirror = function()
|
Mirror = function()
|
||||||
local m = mcs:entity()
|
local m = mcs:entity()
|
||||||
for i = 1, 100 do
|
for i = 1, 100 do
|
||||||
mcs:add(m, pair(E4, E4))
|
mcs:add(m, pair(E2, E3))
|
||||||
mcs:add(m, pair(E4, E4))
|
mcs:remove(m, pair(E2, E3))
|
||||||
|
mcs:add(m, pair(E2, E4))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
Jecs = function()
|
Jecs = function()
|
||||||
local j = ecs:entity()
|
local j = ecs:entity()
|
||||||
for i = 1, 100 do
|
for i = 1, 100 do
|
||||||
ecs:add(j, pair(C4, C4))
|
ecs:add(j, pair(C2, C3))
|
||||||
ecs:add(j, pair(C4, C4))
|
ecs:add(j, pair(C2, C4))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
18
jecs.luau
18
jecs.luau
|
@ -311,9 +311,9 @@ end
|
||||||
|
|
||||||
local function entity_index_try_get_any(
|
local function entity_index_try_get_any(
|
||||||
entity_index: EntityIndex,
|
entity_index: EntityIndex,
|
||||||
entity: number
|
entity: Entity
|
||||||
): Record?
|
): Record?
|
||||||
local r = entity_index.sparse_array[ECS_ENTITY_T_LO(entity)]
|
local r = entity_index.sparse_array[ECS_ENTITY_T_LO(entity::number)]
|
||||||
|
|
||||||
if not r or r.dense == 0 then
|
if not r or r.dense == 0 then
|
||||||
return nil
|
return nil
|
||||||
|
@ -336,6 +336,20 @@ local function entity_index_try_get(entity_index: EntityIndex, entity: Entity):
|
||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function entity_index_try_get_fast(entity_index: EntityIndex, entity: Entity): Record?
|
||||||
|
local r = entity_index_try_get_any(entity_index, entity)
|
||||||
|
if r then
|
||||||
|
local r_dense = r.dense
|
||||||
|
-- if r_dense > entity_index.alive_count then
|
||||||
|
-- return nil
|
||||||
|
-- end
|
||||||
|
if entity_index.dense_array[r_dense] ~= entity then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return r
|
||||||
|
end
|
||||||
|
|
||||||
local function entity_index_is_alive<T>(entity_index: EntityIndex, entity: Entity<T>): boolean
|
local function entity_index_is_alive<T>(entity_index: EntityIndex, entity: Entity<T>): boolean
|
||||||
return entity_index_try_get(entity_index, entity) ~= nil
|
return entity_index_try_get(entity_index, entity) ~= nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,10 +24,6 @@ type Id<T=unknown> = jecs.Id<T>
|
||||||
local entity_visualiser = require("@tools/entity_visualiser")
|
local entity_visualiser = require("@tools/entity_visualiser")
|
||||||
local dwi = entity_visualiser.stringify
|
local dwi = entity_visualiser.stringify
|
||||||
|
|
||||||
TEST("exclusive", function()
|
|
||||||
-- print(jecs.entity_index_try_get(world.entity_index, e).archetype.type)
|
|
||||||
end)
|
|
||||||
|
|
||||||
TEST("bulk", function()
|
TEST("bulk", function()
|
||||||
local world = jecs.world()
|
local world = jecs.world()
|
||||||
local A = world:component()
|
local A = world:component()
|
||||||
|
|
Loading…
Reference in a new issue