Skip to content

Commit 6ba260f

Browse files
committed
Fixed problem with asset files during model converting.
1 parent dd0f016 commit 6ba260f

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ dependencies {
5858
compile 'org.controlsfx:controlsfx:8.40.13'
5959

6060
compile 'com.github.JavaSaBr:RlibFX:4.1.3'
61-
compile 'com.github.JavaSaBr:RLib:6.5.1'
61+
compile 'com.github.JavaSaBr:RLib:6.5.2'
6262
compile 'com.github.JavaSaBr:JME3-JFX:1.6.1'
6363

6464
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3

src/main/java/com/ss/editor/file/converter/impl/AbstractModelFileConverter.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.ss.editor.file.converter.impl;
22

33
import static com.ss.editor.extension.property.EditablePropertyType.*;
4-
import static com.ss.editor.util.EditorUtil.getAssetFile;
5-
import static com.ss.editor.util.EditorUtil.getRealFile;
6-
import static com.ss.editor.util.EditorUtil.toAssetPath;
4+
import static com.ss.editor.util.EditorUtil.*;
75
import static com.ss.rlib.util.FileUtils.containsExtensions;
6+
import static com.ss.rlib.util.FileUtils.normalizeName;
87
import static com.ss.rlib.util.ObjectUtils.notNull;
98
import static java.nio.file.StandardOpenOption.*;
109
import com.jme3.asset.AssetKey;
@@ -187,7 +186,14 @@ private void convertImpl(@NotNull final Path source, @NotNull final VarTable var
187186
private void storeMaterials(@NotNull final Path materialsFolder, final boolean canOverwrite,
188187
@NotNull final String materialName, @NotNull final Geometry geometry) {
189188

190-
final Path resultFile = materialsFolder.resolve(materialName + "." + FileExtensions.JME_MATERIAL);
189+
final Path resultFile = materialsFolder.resolve(normalizeName(materialName) + "." + FileExtensions.JME_MATERIAL);
190+
final Path assetFile = getAssetFile(resultFile);
191+
192+
if (assetFile == null) {
193+
LOGGER.warning("Can't get asset file for the file " + resultFile);
194+
return;
195+
}
196+
191197
final Material currentMaterial = geometry.getMaterial();
192198

193199
if (!Files.exists(resultFile) || canOverwrite) {
@@ -198,7 +204,6 @@ private void storeMaterials(@NotNull final Path materialsFolder, final boolean c
198204
}
199205
}
200206

201-
final Path assetFile = notNull(getAssetFile(resultFile));
202207
final String assetPath = toAssetPath(assetFile);
203208

204209
final AssetManager assetManager = EDITOR.getAssetManager();

src/main/java/com/ss/editor/util/EditorUtil.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,20 @@ public static void movePoint(@NotNull final Vector3f first, @NotNull final Vecto
288288
*/
289289
@FromAnyThread
290290
public static @Nullable Path getAssetFile(@NotNull final Path file) {
291+
291292
final EditorConfig editorConfig = EditorConfig.getInstance();
292293
final Path currentAsset = editorConfig.getCurrentAsset();
293-
if (currentAsset == null) return null;
294-
return currentAsset.relativize(file);
294+
if (currentAsset == null) {
295+
return null;
296+
}
297+
298+
try {
299+
return currentAsset.relativize(file);
300+
} catch (final IllegalArgumentException e) {
301+
LOGGER.warning("Can't create asset file of the " + file + " for asset folder " + currentAsset);
302+
LOGGER.warning(e);
303+
return null;
304+
}
295305
}
296306

297307
/**

0 commit comments

Comments
 (0)