Skip to content

Commit 108e4dc

Browse files
committed
Fix template generator issues when using mirror modeling
1 parent b8a98fb commit 108e4dc

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

js/modeling/mirror_modeling.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,11 @@ Blockbench.on('finish_edit', ({aspects}) => {
354354
aspects.elements.remove(mirror_element);
355355
}
356356
} else {
357-
// Construct clone at other side of model
357+
if (cached_data?.counterpart?.selected && cached_data.is_copy) {
358+
// When both sides are selected, and this one is the copy, don't update
359+
return;
360+
}
361+
// Construct or update clone at other side of model
358362
MirrorModeling.createClone(element, aspects);
359363
}
360364
}

js/texturing/texture_generator.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,10 @@ export const TextureGenerator = {
507507
uv_mode: true
508508
})
509509

510+
// MARK: Compute UV requirements from elements
510511
element_list.forEach(element => {
511512
let mirror_modeling_duplicate = BarItems.mirror_modeling.value && MirrorModeling.cached_elements[element.uuid] && MirrorModeling.cached_elements[element.uuid].is_copy;
513+
if (options.disable_mirror_uv == true || BarItems.mirror_modeling.tool_config.options.mirror_uv == false) mirror_modeling_duplicate = false;
512514
if (mirror_modeling_duplicate) return;
513515
if (element.getTypeBehavior('cube_faces')) {
514516
if ((element.box_uv || options.box_uv) && element.getTypeBehavior('support_box_uv')) {
@@ -518,8 +520,6 @@ export const TextureGenerator = {
518520
}
519521

520522
let template = new TextureGenerator.boxUVCubeTemplate(element, element.box_uv ? 0 : 1);
521-
let mirror_modeling_duplicate = BarItems.mirror_modeling.value && MirrorModeling.cached_elements[element.uuid] && MirrorModeling.cached_elements[element.uuid].is_copy;
522-
if (mirror_modeling_duplicate) return;
523523

524524
if (options.double_use && Texture.all.length) {
525525
let double_key = [...element.uv_offset, ...element.size(undefined, true), ].join('_')
@@ -954,6 +954,7 @@ export const TextureGenerator = {
954954
return b.template_size - a.template_size;
955955
})
956956

957+
// MARK: Rearrange UVs into template
957958
if (options.rearrange_uv) {
958959

959960
let extend_x = 0;
@@ -1172,6 +1173,7 @@ export const TextureGenerator = {
11721173

11731174
await setProgress(1);
11741175

1176+
// MARK: Create Texture
11751177
if (background_color) {
11761178
background_color = background_color.toRgbString()
11771179
}
@@ -1192,6 +1194,8 @@ export const TextureGenerator = {
11921194

11931195
TextureGenerator.old_project_resolution = [Project.texture_width, Project.texture_height]
11941196

1197+
1198+
// MARK: Draw Utility
11951199
function getPolygonOccupationMatrix(vertex_uv_faces, width, height) {
11961200
let matrix = {};
11971201
function vSub(a, b) {
@@ -1254,7 +1258,6 @@ export const TextureGenerator = {
12541258
return matrix;
12551259
}
12561260

1257-
12581261
function drawTemplateRectangle(border_color, color, coords) {
12591262
if (typeof background_color === 'string') {
12601263
border_color = background_color
@@ -1466,7 +1469,7 @@ export const TextureGenerator = {
14661469
return true;
14671470
}
14681471

1469-
//Drawing
1472+
// MARK: Place UVs and fill texture
14701473
face_list.forEach(function(ftemp) {
14711474
var pos = {
14721475
x: ftemp.posx,

0 commit comments

Comments
 (0)