The COG Factory / COG Factory Experiments

Entity Pool

2026-09-22
DOWNLOAD ZIP · 190 KBBUILD 12026-09-22
Entity Pool

A long bare hall with five hundred and fifty crates and consoles that are not in the level file at all. A drag-and-drop page strips them out of the editor's JKL and writes a runtime that brings each one back when you are near it and takes it away behind you, never keeping more than a cap you set per kind. Walk east and the decoration arrives a few units ahead; turn round and the far end has gone. The pooled things stand exactly where the editor put them, in the sectors it put them in, and the ten crates that were left in the file never move.

A generated COG pair can keep a level's decoration under a per-template cap with no engine change, and a single HTML file can produce it from the editor's own JKL. Retail Jedi Knight has 640 thing slots in total (SITH_MAX_THINGS, a fixed free-list array), shared by weapons, debris, corpses, enemies and every crate; that is the wall. The tool lays a three-dimensional cell grid over the pooled things and sorts them by cell; the runtime reads the player's cell once per pulse and does nothing unless it changed. On a change it destroys what no longer reaches the new cell's box and creates what does, ring by ring from the player's own cell outward, until each template's cap is spent. The engine's own thing dump at six stations shows, per template, exactly min(cap, things within radius) alive, every one at its authored position in its authored sector; with tight caps every station reads exactly the cap; and two one-line patches of the generated runtime — the cap test, the reach test — each turn the checker red.

What it cost. JK1's SetThingPos writes the position and never the sector, so the pool creates and destroys rather than teleports. CreateThingAtPos adds the model's rotated INSERT OFFSET to the position it is given while a THINGS row is placed as written, so every re-created crate floated by its offset until the tool learned to subtract it (425 of the 477 stock 3DOs carry one; the page ships the table and reads a dropped 3DO for custom models). A HeapGet of a heap slot nothing had written killed the process on the first empty cell the scan touched: HeapNew's memset zero is value type POINTER, not int 0, and three bisection runs blamed the loop before a print in the callee found it. A verb with a return value called as a bare statement leaks one COG stack entry per call, and retail's stack is 64 deep, so every data row assigns. And World things above 640 overruns retail's free list, which this fork's 32000 never shows. Gate 6 of 6, GOB standalone; retail JKDF2 has not seen it.
projectp57-entitypool
date2026-09-22
packageP57.GOB, readme.txt, screenshot.jpg
build1 — 2026-09-22
sha256f0d14dc66c1016ede2d7f89f794e681cc6f6a315049e4e677a39fb6ea7fa5190

Installing it

  1. Unzip it.
  2. Drop the .GOB into the episode folder of a Jedi Knight install — the one that already has JK1.GOB in it.
  3. Pick it from the episode list. On a libretro frontend, load the .GOB itself as content.

The GOB carries its own level, cogs, and materials. Everything else is read from the stock resource/, and there is no retail game data in the zip.

These are living projects, not finished releases. A level is rebuilt whenever something is learned — a lighting rule, a texture orientation, a whole detail pass — and it keeps its filename through all of it. The build number is how to tell which one you have: it is printed in the readme inside every zip, and it only moves when the level's bytes actually change.

Screenshots

The readme that ships with it

========================================================================
 Jedi Knight Level

 P57.GOB

 A long hall with 550 crates and consoles that are not in the level: a
 COG creates the ones near you and destroys the ones behind you, never
 more than a cap per kind.

 [cogfactory / p57-entitypool]

 BUILD 1  --  2026-09-22
 sha256 f0d14dc66c1016ede2d7f89f794e681c

 This level is not made or distributed by LucasArts
 Entertainment Co.
========================================================================

THIS PACKAGE
------------------------------------------------------------------------
  P57.GOB          the level
  readme.txt       this file
  screenshot.jpg   what it looks like

INSTALLATION
------------------------------------------------------------------------
Drop P57.GOB into the `episode` folder of a Jedi Knight install (the one
that already has JK1.GOB in it) and pick it from the episode list.
Nothing else needs to change: the GOB carries its own level, cogs and
materials, and reads the stock resource/ for everything else.

On a libretro frontend such as RetroArch, unzip first and put P57.GOB in
the episode folder of your Jedi Knight folder, then load it from there.
The core treats the folder above the GOB's folder as the game folder,
reads the episode from episode/P57.GOB inside it, and will not start
unless that folder also holds resource/ (Res2.gob) from a real install.

CONTROLS
------------------------------------------------------------------------
  Walk east and back. Decoration appears a few units ahead and vanishes behind; the big consoles from further off than the small crates.

NOTES
------------------------------------------------------------------------
  experiment for the entitypool tool (tools/entitypool); the level is
  deliberately bare apart from the pooled things

  the dev log prints ENTPOOL CELL n ACT a FAIL f GONE g on every cell
  change; FAIL must stay 0

WHAT IS IN THE GOB
------------------------------------------------------------------------
        81  episode.jk
     58361  jkl\hall.jkl
     10781  cog\entpool.cog
     25110  cog\entpool0.cog
     21239  cog\entpool1.cog
      2188  mat\p57ceil.mat
      2188  mat\p57floor.mat
      2188  mat\p57wall.mat

    122136  bytes in 8 entries

CREDITS
------------------------------------------------------------------------
  Generated by tools/cogfactory in the openjkdf2_libretro tree.

  The readme format is styled after SM Sith Lord's cog headers,
  because his are the ones everybody read.

========================================================================