Просмотр исходного кода

Add explicit error message on ModelLibrary.hx atlasing error.

clementlandrin 10 месяцев назад
Родитель
Сommit
319ff1551b
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      hrt/prefab/l3d/ModelLibrary.hx

+ 7 - 1
hrt/prefab/l3d/ModelLibrary.hx

@@ -536,6 +536,11 @@ class ModelLibrary extends Prefab {
 					pos = b.add(mipLevelImage);
 					posTex = b;
 				}
+				inline function atlasError(path : String, image : hxd.res.Image) {
+					throw 'Could not atlas ${sourcePath}. ${image.getInfo().width}x${image.getInfo().height} does not fit atlas size ${atlasResolution}x${atlasResolution}';
+				}
+				if ( pos == null )
+					atlasError(sourcePath, mipLevelImage);
 				if ( mipLevel == 0) {
 					t = {
 						pos : pos,
@@ -582,7 +587,8 @@ class ModelLibrary extends Prefab {
 					resizedTex.dispose();
 					texture.dispose();
 					var submiplevelImage = hxd.res.Any.fromBytes(tmp.name+"_"+mipLevel, texBytes).toImage();
-					t.add(submiplevelImage);
+					if ( t.add(submiplevelImage) == null )
+						atlasError(isSpec ? specMap : normalMap, realTex);
 				}
 
 				packSub(normalMaps, ntex, false);