Update version checks and id generation in migration and collider scripts

This commit is contained in:
2026-04-11 16:31:56 +02:00
parent f4150ea4a8
commit 953c59bd1d
2 changed files with 7 additions and 6 deletions

View File

@@ -77,7 +77,6 @@ import {
DEFAULT_PROJECT_NAME,
DEFAULT_PROJECT_SCENE_ID,
SCENE_EDITOR_PREFERENCES_SCENE_DOCUMENT_VERSION,
STATIC_SIMPLE_MODEL_COLLIDERS_SCENE_DOCUMENT_VERSION,
ENTITY_NAMES_SCENE_DOCUMENT_VERSION,
ENTITY_SYSTEM_FOUNDATION_SCENE_DOCUMENT_VERSION,
FACE_MATERIALS_SCENE_DOCUMENT_VERSION,
@@ -2749,7 +2748,7 @@ export function migrateProjectDocument(source: unknown): ProjectDocument {
const allowMissingProjectName =
source.version < PROJECT_NAME_SCENE_DOCUMENT_VERSION;
const allowMissingEditorPreferences =
source.version < STATIC_SIMPLE_MODEL_COLLIDERS_SCENE_DOCUMENT_VERSION;
source.version < SCENE_EDITOR_PREFERENCES_SCENE_DOCUMENT_VERSION;
for (const [sceneKey, sceneValue] of Object.entries(source.scenes)) {
scenes[sceneKey] = readProjectScene(

View File

@@ -787,7 +787,7 @@ function packStaticSimpleVoxelBoxes(grid: StaticSimpleVoxelGrid): StaticSimpleVo
return boxes;
}
function collectStaticSimpleBoxPieces(triangles: LocalTriangle[], modelInstanceId: string): GeneratedModelCompoundBoxColliderPiece[] {
function collectStaticSimpleBoxPieces(triangles: LocalTriangle[], pieceIdPrefix: string): GeneratedModelCompoundBoxColliderPiece[] {
const bounds = getTriangleBounds(triangles);
let targetLongestAxis = STATIC_SIMPLE_VOXEL_LONGEST_AXIS_TARGET;
let bestPieces: GeneratedModelCompoundBoxColliderPiece[] = [];
@@ -802,7 +802,7 @@ function collectStaticSimpleBoxPieces(triangles: LocalTriangle[], modelInstanceI
const { center, size } = voxelBoxToCenterAndSize(grid, box);
return {
id: `${modelInstanceId}-box-piece-${index + 1}`,
id: `${pieceIdPrefix}-box-piece-${index + 1}`,
kind: "box" as const,
center,
size,
@@ -831,7 +831,7 @@ function collectStaticSimpleBoxPieces(triangles: LocalTriangle[], modelInstanceI
if (bestPieces.length === 0) {
throw new ModelColliderGenerationError(
"unsupported-static-simple-model-collider",
`Model instance ${modelInstanceId} could not derive any voxel-box pieces for static-simple collision.`
`Model instance ${pieceIdPrefix} could not derive any voxel-box pieces for static-simple collision.`
);
}
@@ -1094,7 +1094,9 @@ function buildStaticSimpleCollider(
);
}
const pieces = triangleClusters.flatMap((cluster) => collectStaticSimpleBoxPieces(cluster.triangles, modelInstance.id));
const pieces = triangleClusters.flatMap((cluster, index) =>
collectStaticSimpleBoxPieces(cluster.triangles, `${modelInstance.id}-cluster-${index + 1}`)
);
if (pieces.length === 0) {
throw new ModelColliderGenerationError(