Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ protected static String uuidToString(@NotNull RTTIReference uuid) {
}
}

@NotNull
protected static String uuidToString(@NotNull RTTIObject uuid) {
return RTTIUtils.uuidToString(uuid);
}
Comment thread
REDxEYE marked this conversation as resolved.
Outdated

protected record DrawFlags(
@NotNull String renderType,
@NotNull String shadowCullMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,20 @@ private DMFSceneFile export(
@NotNull RTTIObject object,
@NotNull String resourceName
) throws IOException {
scene = new DMFSceneFile(1);
scene = new DMFSceneFile(2);
collectionStack.push(scene.createCollection(resourceName));
exportResource(monitor, core, object, resourceName);
collectionStack.pop();
return scene;
}

private int toInstanceSource(@NotNull String uuid, @NotNull DMFNode node) {
DMFInstanceSource instanceSource = new DMFInstanceSource(uuid, node);
scene.instances.add(instanceSource);
return scene.instances.indexOf(instanceSource);
}


private void exportResource(
@NotNull ProgressMonitor monitor,
@NotNull CoreBinary core,
Expand Down Expand Up @@ -741,8 +748,7 @@ private DMFNode prefabInstanceToModel(
instanceData = toModel(task.split(1), prefabResource.binary(), prefabObject, nameFromReference(prefab, resourceName));
}
if (instanceData != null) {
scene.instances.add(instanceData);
instanceId = scene.instances.indexOf(instanceData);
instanceId = toInstanceSource(uuidToString(prefabObject.obj("ObjectUUID")), instanceData);
instances.put(prefabObject.obj("ObjectUUID"), instanceId);
}
}
Expand All @@ -766,17 +772,17 @@ private DMFNode staticMeshInstanceToModel(
final RTTIObject meshResourceObject = meshResource.object();
int instanceId = -1;

if (instances.containsKey(meshResourceObject.obj("ObjectUUID"))) {
instanceId = instances.get(meshResourceObject.obj("ObjectUUID"));
final RTTIObject objectUUID = meshResourceObject.obj("ObjectUUID");
if (instances.containsKey(objectUUID)) {
instanceId = instances.get(objectUUID);
} else {
final DMFNode instanceData;
try (ProgressMonitor.Task task = monitor.begin("Exporting StaticMeshInstance Resource", 1)) {
instanceData = toModel(task.split(1), meshResource.binary(), meshResourceObject, nameFromReference(resource, resourceName));
}
if (instanceData != null) {
scene.instances.add(instanceData);
instanceId = scene.instances.indexOf(instanceData);
instances.put(meshResourceObject.obj("ObjectUUID"), instanceId);
instanceId = toInstanceSource(uuidToString(objectUUID), instanceData);
instances.put(objectUUID, instanceId);
}
}

Expand Down Expand Up @@ -1016,8 +1022,7 @@ private DMFNode regularSkinnedMeshResourceToModel(
}
model.addToCollection(collectionStack.peek(), scene);
if (options.contains(ModelExporterProvider.Option.USE_INSTANCING)) {
scene.instances.add(model);
int instanceId = scene.instances.indexOf(model);
int instanceId = toInstanceSource(uuidToString(object.obj("ObjectUUID")),model);
instances.put(object.obj("ObjectUUID"), instanceId);
return new DMFInstance(resourceName, instanceId);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.shade.decima.ui.data.viewer.model.dmf;

import com.shade.decima.ui.data.viewer.model.dmf.nodes.DMFNode;

public record DMFInstanceSource(String uuid, DMFNode rootNode) {
Comment thread
REDxEYE marked this conversation as resolved.
Outdated
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class DMFSceneFile {
public final List<DMFBuffer> buffers;
public final List<DMFMaterial> materials;
public final List<DMFTexture> textures;
public final List<DMFNode> instances;
public final List<DMFInstanceSource> instances;

public DMFSceneFile(int version) {
metadata = new DMFSceneMetaData("%s (%s, %s)".formatted(APP_TITLE, APP_VERSION, BUILD_COMMIT), version);
Expand Down