entity bvh with exact old tie order and allocation-free entity/element intersectors, entity benchmark harness and perf test scenes

This commit is contained in:
MineTec committed 2026-11-04 16:42:08 +01:00
1 parent 2d56a1910c
commit b5baffebbd
6 files changed
+910 -161

No files matched your search

+34
View File
@@ -136,6 +136,38 @@ public class PPTest extends JavaPlugin {
scenes.put("frames_side", new Scene("frames_side", this::frames, -1.5, 3.2, -1.0, 4.5, 2.6, 3.6));
scenes.put("frames_dirs_ne", new Scene("frames_dirs_ne", this::framesDirs, 16, 7.5, -4, 8, 4, 3.5));
scenes.put("frames_dirs_sw", new Scene("frames_dirs_sw", this::framesDirs, 0, 1.2, 10, 8, 4, 3.5));
// Performance (entity BVH): a 15x18 animal farm (270 mobs, randomizeData=false, fixed body yaw) and 300
// item displays from a seeded RNG -> deterministic, pixel-diffable; the render time is logged.
scenes.put("perf_farm", new Scene("perf_farm", this::perfFarm, -6, 9, -13, 4, 0, 0));
scenes.put("perf_farm_close", new Scene("perf_farm_close", this::perfFarm, 0.5, 3, -11.5, 5, 0.5, -4));
scenes.put("perf_items", new Scene("perf_items", this::perfItems, 0.5, 5, -10, 5, 0, -2));
}
private void perfFarm(Location o) {
Random r = new Random(42);
Class<?>[] types = {Cow.class, Sheep.class, Chicken.class, Pig.class};
for (int i = 0; i < 15; i++)
for (int j = 0; j < 18; j++) {
@SuppressWarnings("unchecked")
Class<? extends LivingEntity> type = (Class<? extends LivingEntity>) types[r.nextInt(types.length)];
LivingEntity e = rfSpawn(o, -5 + i * 1.2, 0, -10 + j * 1.2, 0, type);
if (r.nextInt(5) == 0 && e instanceof Ageable a) a.setBaby();
e.setBodyYaw(r.nextInt(8) * 45);
}
}
private void perfItems(Location o) {
Random r = new Random(7);
Material[] mats = {Material.WHEAT, Material.CARROT, Material.EGG, Material.BONE, Material.ROTTEN_FLESH,
Material.STRING, Material.GUNPOWDER, Material.IRON_INGOT, Material.COBBLESTONE, Material.OAK_LOG,
Material.PUMPKIN};
for (int i = 0; i < 300; i++) {
ItemDisplay d = spawn(o, -4 + r.nextDouble() * 16, 0.15 + r.nextDouble() * 0.2, -10 + r.nextDouble() * 16,
r.nextInt(360), ItemDisplay.class);
d.setItemStack(it(mats[r.nextInt(mats.length)]));
d.setTransformation(new Transformation(new Vector3f(), new AxisAngle4f((float) (Math.PI / 2), 1, 0, 0),
new Vector3f(0.4f), new AxisAngle4f()));
}
}
@Override
@@ -223,7 +255,9 @@ public class PPTest extends JavaPlugin {
+ " objects, " + job.blockEntities().size() + " block entities");
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
try {
long t0 = System.nanoTime();
BufferedImage img = r.execute(job);
getLogger().info(String.format("TIME %s %.1f ms", sc.name, (System.nanoTime() - t0) / 1e6));
File f = new File(getDataFolder(), sc.name + ".png");
f.getParentFile().mkdirs();
ImageIO.write(img, "png", f);