From 953c59bd1dc0431a630b9b30e6205b6798045614 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 11 Apr 2026 16:31:56 +0200 Subject: [PATCH] Update version checks and id generation in migration and collider scripts --- src/document/migrate-scene-document.ts | 3 +-- src/geometry/model-instance-collider-generation.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/document/migrate-scene-document.ts b/src/document/migrate-scene-document.ts index abafee0c..c479e84c 100644 --- a/src/document/migrate-scene-document.ts +++ b/src/document/migrate-scene-document.ts @@ -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( diff --git a/src/geometry/model-instance-collider-generation.ts b/src/geometry/model-instance-collider-generation.ts index c3605585..86656d29 100644 --- a/src/geometry/model-instance-collider-generation.ts +++ b/src/geometry/model-instance-collider-generation.ts @@ -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(