mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-02-23 16:31:20 +08:00
Fixed soft brush snapping to texels
This commit is contained in:
parent
acd924c2cc
commit
cae5c5c7be
@ -52,10 +52,12 @@ class CubeFace extends Face {
|
|||||||
case 'down': return [7, 2, 3, 6];
|
case 'down': return [7, 2, 3, 6];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
texelToLocalMatrix(uv, truncate_offset = [0, 0], truncate_factor = [1, 1]) {
|
texelToLocalMatrix(uv, truncate_offset = [0, 0], truncate_factor = [1, 1], truncate) {
|
||||||
uv = [...uv];
|
uv = [...uv];
|
||||||
uv[0] = Math.round(uv[0] + truncate_offset) - truncate_offset;
|
if (truncate) {
|
||||||
uv[1] = Math.round(uv[1] + truncate_offset) - truncate_offset;
|
uv[0] = Math.round(uv[0] + truncate_offset) - truncate_offset;
|
||||||
|
uv[1] = Math.round(uv[1] + truncate_offset) - truncate_offset;
|
||||||
|
}
|
||||||
uv[0] *= truncate_factor[0];
|
uv[0] *= truncate_factor[0];
|
||||||
uv[1] *= truncate_factor[1];
|
uv[1] *= truncate_factor[1];
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ class MeshFace extends Face {
|
|||||||
if (this.mesh.faces[fkey] == this) return fkey;
|
if (this.mesh.faces[fkey] == this) return fkey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
texelToLocalMatrix(uv, truncate_offset = [0, 0], truncate_factor = [1, 1], vertices = this.getSortedVertices()) {
|
texelToLocalMatrix(uv, truncate_offset = [0, 0], truncate_factor = [1, 1], truncate, vertices = this.getSortedVertices()) {
|
||||||
let vert_a = vertices[0];
|
let vert_a = vertices[0];
|
||||||
let vert_b = vertices[1];
|
let vert_b = vertices[1];
|
||||||
let vert_c = vertices[2];
|
let vert_c = vertices[2];
|
||||||
@ -314,8 +314,10 @@ class MeshFace extends Face {
|
|||||||
let vertexc = this.mesh.vertices[vert_c];
|
let vertexc = this.mesh.vertices[vert_c];
|
||||||
|
|
||||||
uv = [...uv];
|
uv = [...uv];
|
||||||
uv[0] = Math.round(uv[0] + truncate_offset) - truncate_offset;
|
if (truncate) {
|
||||||
uv[1] = Math.round(uv[1] + truncate_offset) - truncate_offset;
|
uv[0] = Math.round(uv[0] + truncate_offset) - truncate_offset;
|
||||||
|
uv[1] = Math.round(uv[1] + truncate_offset) - truncate_offset;
|
||||||
|
}
|
||||||
uv[0] *= truncate_factor[0];
|
uv[0] *= truncate_factor[0];
|
||||||
uv[1] *= truncate_factor[1];
|
uv[1] *= truncate_factor[1];
|
||||||
|
|
||||||
|
@ -1085,7 +1085,8 @@ class Preview {
|
|||||||
let offset = 0;
|
let offset = 0;
|
||||||
let x = intersect.uv.x * texture.width;
|
let x = intersect.uv.x * texture.width;
|
||||||
let y = (1-intersect.uv.y) * texture.height;
|
let y = (1-intersect.uv.y) * texture.height;
|
||||||
if (Condition(Toolbox.selected.brush.floor_coordinates)) {
|
let floor_coordinates = Condition(Toolbox.selected.brush.floor_coordinates);
|
||||||
|
if (floor_coordinates) {
|
||||||
offset = BarItems.slider_brush_size.get()%2 == 0 && Toolbox.selected.brush?.offset_even_radius ? 0 : 0.5;
|
offset = BarItems.slider_brush_size.get()%2 == 0 && Toolbox.selected.brush?.offset_even_radius ? 0 : 0.5;
|
||||||
}
|
}
|
||||||
if (texture.currentFrame) {
|
if (texture.currentFrame) {
|
||||||
@ -1093,7 +1094,7 @@ class Preview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Position
|
// Position
|
||||||
let brush_matrix = face.texelToLocalMatrix([x, y], offset, [uv_factor_x, uv_factor_y]);
|
let brush_matrix = face.texelToLocalMatrix([x, y], offset, [uv_factor_x, uv_factor_y], floor_coordinates);
|
||||||
let brush_coord = new THREE.Vector3().setFromMatrixPosition(brush_matrix);
|
let brush_coord = new THREE.Vector3().setFromMatrixPosition(brush_matrix);
|
||||||
intersect.object.localToWorld(brush_coord);
|
intersect.object.localToWorld(brush_coord);
|
||||||
if (!Format.centered_grid) {
|
if (!Format.centered_grid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user