Skip to content

Commit

Permalink
fix: fixes loading presets with textures referencing groups (#591)
Browse files Browse the repository at this point in the history
* fix: fixes loading presets with textures referencing groups

Updates groups and outputContexts to share the same ID on creation. This fixes bad references when
loading presets with texture types saved with a group reference

fixes #590

* fix(texture): adds group texture type

the group texture type is identical to the canvas type, but it signals to the UI to show it as a
group instead.

re #590
  • Loading branch information
2xAA authored Jun 29, 2021
1 parent 32585cc commit 9dfeff5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/application/worker/store/modules/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const state = {
textureDefinition.id = id;
}

if (type === "canvas") {
if (type === "canvas" || type == "group") {
const { id } = options;
textureDefinition.location = "outputs/auxillaryCanvas";
textureDefinition.id = id;
Expand Down
9 changes: 6 additions & 3 deletions src/application/worker/store/modules/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ const actions = {
return writeTo.groups[existingGroupIndex];
}

const id = args.id || uuidv4();

const group = {
...args,
name,
id,
clearing: args.clearing || false,
enabled: args.enabled || false,
hidden: args.hidden || false,
Expand All @@ -121,9 +124,9 @@ const actions = {
compositeOperation: args.compositeOperation || "normal",
context: await store.dispatch("outputs/getAuxillaryOutput", {
name,
group: "group"
}),
id: args.id || uuidv4()
group: "group",
id
})
};

const alphaInputBind = await store.dispatch("inputs/addInput", {
Expand Down
6 changes: 4 additions & 2 deletions src/application/worker/store/modules/outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const actions = {
type = "2d",
options = {},
group = "",
id = "",
reactToResize = true,
width = state.main ? state.main.canvas.width : 300,
height = state.main ? state.main.canvas.height : 300
Expand All @@ -70,14 +71,15 @@ const actions = {
name,
context,
reactToResize,
group
group,
id
});

return outputContext;
},

addAuxillaryOutput({ commit }, outputContext) {
outputContext.id = uuidv4();
outputContext.id = outputContext.id || uuidv4();
commit("ADD_AUXILLARY", outputContext);
return outputContext;
},
Expand Down
7 changes: 4 additions & 3 deletions src/components/Controls/TextureControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</select>

<div v-if="type === 'group'">
<select v-model="modelCanvasId" @change="setTexture('canvas')">
<select v-model="modelCanvasId" @change="setTexture('group')">
<option v-for="group in groupOutputs" :value="group.id" :key="group.id">
{{ group.name }}
</option>
Expand Down Expand Up @@ -68,7 +68,8 @@ export default {
this.value.type && this.value.type.length
? this.value.type
: this.textureTypes[0];
this.modelImagePath = this.value.options.path;
this.modelImagePath = this.value.options.path || "";
this.modelCanvasId = this.value.options.id || "";
},
computed: {
Expand Down Expand Up @@ -117,7 +118,7 @@ export default {
textureDefinition.options.path = this.modelImagePath;
}
if (type === "canvas") {
if (type === "canvas" || type === "group") {
if (!this.modelCanvasId) {
return;
}
Expand Down

0 comments on commit 9dfeff5

Please sign in to comment.