
DysonShellOptimizer
加快戴森壳蓝图粘贴并降低峰值内存。DysonShellOptimizer — 戴森壳几何优化
大型戴森球蓝图粘贴时,原版会在主线程串行计算所有壳面的网格、顶点和节点归属。壳面数量达到数千时,粘贴可能持续卡顿数分钟,内存峰值也会达到数GB以上。
本模组用并行实现替换戴森壳几何生成,并采用分批流水线:生成一批、建立模型、立即释放临时数据。最终蓝图数据与原版一致,只缩短总耗时并降低峰值内存。
前置
- 游戏:Dyson Sphere Program
0.10.35.29151 - BepInEx:
5.4.17 - LossyCompression:
0.3.8
本模组硬依赖 LossyCompression。用 r2modman / Thunderstore Mod Manager 安装时会自动补装依赖。
功能
- 并行化
DysonShell.GenerateGeometry的网格扫描、最近边和最近节点计算。 - 跨戴森壳并行执行蓝图导入,再在主线程统一创建 Unity 模型。
- 几何输出顺序与原版一致:顶点、邻接表、节点归属、
vertsq和朝向都不改变。 - 分批建模并释放顶点、Mesh 和 Material,避免等全部壳完成才回收。
- 蓝图导入期间合并戴森节点 GPU 缓冲上传。
- 可选的粘贴后释放:再次查看戴森球时按需重建。
内存说明
本模组负责蓝图粘贴路径:
- 粘贴过程中不再同时持有全部壳的完整几何。
- 每批生成完立即建模并释放临时数据。
FreeGeometryAfterPaste=true时,粘贴结束后继续保留最小重建数据,不保留全部顶点与模型。
LossyCompression 负责读档路径:
- 重进游戏后,已加载的戴森壳由 LossyCompression 的
LazyLoad延迟构建。 - 如果关闭 LossyCompression 的
LazyLoad,读档后内存仍会回到原版高位。
配置
配置文件:BepInEx/config/sinthome358.dsp.dysonshelloptimizer.cfg
| 配置 | 默认 | 说明 |
|---|---|---|
General.Enabled |
true | 总开关;关闭后完全走原版逻辑 |
General.MaxDegreeOfParallelism |
0 | 并行线程数;0 使用 CPU 核心数 |
General.ParallelAcrossShells |
true | 跨壳并行生成几何 |
General.FreeGeometryAfterPaste |
true | 粘贴后释放几何与模型,查看时按需重建 |
General.GeometryBatchMultiplier |
4 | 每批壳数 = CPU 核数 × 该值 |
General.BatchNodeBufferUpload |
true | 每层只上传一次节点缓冲 |
General.LogTimings |
false | 输出每批耗时与堆内存日志 |
较大的 GeometryBatchMultiplier 会减少批次数和调度开销,但提高峰值内存;较小的值更省内存。MaxDegreeOfParallelism=0 适合大多数机器。
安装
推荐使用 r2modman 或 Thunderstore Mod Manager 安装。手动安装时,把 DysonShellOptimizer.dll 放到:
BepInEx/plugins/DysonShellOptimizer/
并确认已安装 BepInEx 5.4.17 和 LossyCompression 0.3.8。
兼容性
- 不修改发电量、细胞点数、结构点数、配方或科技。
- 不写入自定义存档字段,不改变原版蓝图与存档格式。
- 与其它重写
DysonShell.GenerateGeometry、DysonSphereLayer.ImportFromBlueprint或DrawModels的模组可能冲突。 - 与 LossyCompression 的分工是:本模组处理粘贴,LossyCompression 处理读档。
验证
建议粘贴大型蓝图后核对:
- 结构点数、细胞点数和壳面数量与原版一致。
- 壳面渲染朝向正常。
- 保存、退出、重进后数据一致。
- 打开银河系上传记录时,发电量上传结果不受影响。
DysonShellOptimizer
Pasting a very large Dyson sphere blueprint is CPU-bound in vanilla DSP. DysonShell.GenerateGeometry scans the shell grid and builds vertex adjacency and node ownership serially on the main thread. With thousands of shells, paste operations can stutter for minutes and peak memory can exceed several GB.
DysonShellOptimizer replaces the geometry path with a parallel implementation and processes shells in batches. Geometry output remains byte-for-byte equivalent to the vanilla ordering, while total paste time and peak RAM are substantially reduced.
Requirements
- Dyson Sphere Program
0.10.35.29151 - BepInEx
5.4.17 - LossyCompression
0.3.8
LossyCompression is a hard dependency and is installed automatically by r2modman / Thunderstore Mod Manager.
Features
- Parallel grid scan, nearest-edge search, and nearest-node assignment.
- Parallel blueprint import across Dyson shells, followed by main-thread Unity model creation.
- Deterministic output: vertex order, adjacency, node ownership,
vertsq, and winding remain unchanged. - Batched modeling and immediate release of temporary geometry, meshes, and materials.
- Batched Dyson node GPU buffer upload during blueprint import.
- Optional post-paste release; models are regenerated when the sphere is viewed again.
Memory behavior
This mod optimizes the blueprint paste path. It avoids keeping full geometry for every shell at once and releases temporary data after each batch.
LossyCompression optimizes the save-load path. On reload, LazyLoad builds shell models only when needed. If LazyLoad is disabled, RAM can return to vanilla levels after loading a save.
Installation
r2modman or Thunderstore Mod Manager is recommended. For manual installation, place DysonShellOptimizer.dll in:
BepInEx/plugins/DysonShellOptimizer/
Make sure BepInEx 5.4.17 and LossyCompression 0.3.8 are installed.
Configuration
Config file: BepInEx/config/sinthome358.dsp.dysonshelloptimizer.cfg
| Key | Default | Description |
|---|---|---|
General.Enabled |
true | Master switch; when disabled, the vanilla path is used |
General.MaxDegreeOfParallelism |
0 | Worker threads; 0 uses the CPU core count |
General.ParallelAcrossShells |
true | Generate geometry across shells in parallel |
General.FreeGeometryAfterPaste |
true | Release geometry and models after paste; rebuild on view |
General.GeometryBatchMultiplier |
4 | Shells per batch = CPU cores × this value |
General.BatchNodeBufferUpload |
true | Upload the node buffer once per layer |
General.LogTimings |
false | Log per-batch timing and managed heap usage |
A larger GeometryBatchMultiplier reduces batch count and scheduling overhead but raises peak memory. A smaller value uses less memory. MaxDegreeOfParallelism=0 is suitable for most systems.
Compatibility
- The mod does not modify power generation, cell points, structure points, recipes, or tech.
- It does not write custom save fields or change vanilla blueprint and save formats.
- It may conflict with other mods that rewrite
DysonShell.GenerateGeometry,DysonSphereLayer.ImportFromBlueprint, orDrawModels. - LossyCompression handles save loading; this mod handles blueprint paste.
Verification
After pasting a large blueprint, check:
- Structure points, cell points, and shell count match vanilla.
- Shell face winding and rendering remain normal.
- Saving, quitting, and reloading preserve the same data.
- Milky Way power upload results are unaffected.