mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-27 04:21:46 +08:00
Fix Mesh UV issues:
Fix UV position sliders not displaying correct vertex coords when multiple faces selected Fix small faces not connecting Center UV islands in template generator that don't face left or right Fix merge vertices typo
This commit is contained in:
parent
5d4b65df92
commit
61dcce891c
@ -855,6 +855,7 @@ const TextureGenerator = {
|
||||
let perimeter = {};
|
||||
for (let fkey in faces) {
|
||||
let face = faces[fkey];
|
||||
let face_connection_count = 0;
|
||||
processed_faces.push(face);
|
||||
[2, 0, 3, 1].forEach(i => {
|
||||
if (!face.vertices[i]) return;
|
||||
@ -872,7 +873,7 @@ const TextureGenerator = {
|
||||
let angle_total = face_group.faces[0].getAngleTo(other_face);
|
||||
if (angle_total > (options.max_island_angle||45)) return;
|
||||
let edge_length = getEdgeLength(other_face_match.edge);
|
||||
if (edge_length < 2.2) return;
|
||||
if (edge_length < 2.2 && face_connection_count >= 2) return;
|
||||
}
|
||||
let projection_success = projectFace(other_face, other_face_match.key, face_group, {face, fkey, edge});
|
||||
if (!projection_success) return;
|
||||
@ -881,6 +882,7 @@ const TextureGenerator = {
|
||||
face_group.keys.push(other_face_match.key);
|
||||
face_groups.remove(other_face_group);
|
||||
perimeter[other_face_match.key] = other_face;
|
||||
face_connection_count++;
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -1003,8 +1005,17 @@ const TextureGenerator = {
|
||||
max_z = Math.max(max_z, vertex_uvs[fkey][vkey][1]);
|
||||
}
|
||||
}
|
||||
// Align right if face points to right side of model
|
||||
if ((face_group.normal[0] > 0) != (face_group.normal[2] < 0)) {
|
||||
// Center island if it faces front of back
|
||||
if (Math.epsilon(face_group.normal[0], 0, 0.08)) {
|
||||
let offset_x = (Math.ceil(max_x) - max_x) / 2;
|
||||
for (let fkey in vertex_uvs) {
|
||||
for (let vkey in vertex_uvs[fkey]) {
|
||||
vertex_uvs[fkey][vkey][0] += offset_x;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Or align right if face points to right side of model
|
||||
else if ((face_group.normal[0] > 0) != (face_group.normal[2] < 0)) {
|
||||
for (let fkey in vertex_uvs) {
|
||||
for (let vkey in vertex_uvs[fkey]) {
|
||||
vertex_uvs[fkey][vkey][0] += Math.ceil(max_x) - max_x;
|
||||
|
@ -3551,13 +3551,28 @@ Interface.definePanels(function() {
|
||||
return trimFloatNumber(face.uv[axis])
|
||||
}
|
||||
} else if (elements[0] instanceof Mesh) {
|
||||
var face = UVEditor.getReferenceFace();
|
||||
if (face) {
|
||||
let selected_vertices = elements[0].getSelectedVertices();
|
||||
let has_selected_vertices = selected_vertices && face.vertices.find(vkey => selected_vertices.includes(vkey))
|
||||
let selected_vertices = elements[0].getSelectedVertices();
|
||||
|
||||
if (selected_vertices.length) {
|
||||
let min = Infinity;
|
||||
UVEditor.vue.selected_faces.forEach(fkey => {
|
||||
let face = elements[0].faces[fkey];
|
||||
if (!face) return;
|
||||
face.vertices.forEach(vkey => {
|
||||
if (selected_vertices.includes(vkey) && face.uv[vkey]) {
|
||||
min = Math.min(min, face.uv[vkey][axis]);
|
||||
}
|
||||
})
|
||||
})
|
||||
if (min == Infinity) min = 0;
|
||||
return trimFloatNumber(min);
|
||||
|
||||
} else {
|
||||
let face = UVEditor.getReferenceFace();
|
||||
if (!face) return 0;
|
||||
let min = Infinity;
|
||||
face.vertices.forEach(vkey => {
|
||||
if ((!has_selected_vertices || selected_vertices.includes(vkey)) && face.uv[vkey]) {
|
||||
if (face.uv[vkey]) {
|
||||
min = Math.min(min, face.uv[vkey][axis]);
|
||||
}
|
||||
})
|
||||
|
@ -1348,7 +1348,7 @@
|
||||
"action.split_mesh": "Split Mesh",
|
||||
"action.split_mesh.desc": "Split the selected faces of the mesh into a new mesh",
|
||||
"action.merge_vertices": "Merge Vertices",
|
||||
"action.merge_vertices.desc": "Merge the selected vertices into the position of the first selected verted",
|
||||
"action.merge_vertices.desc": "Merge the selected vertices into the position of the first selected vertex",
|
||||
"action.merge_vertices.merge_all": "Merge All",
|
||||
"action.merge_vertices.merge_all_in_center": "Merge All in Center",
|
||||
"action.merge_vertices.merge_by_distance": "Merge by Distance",
|
||||
|
Loading…
Reference in New Issue
Block a user