Techs ENABLE_SEAMS_USING_MODELS and ENABLE_SEAMS_USING_BATCHED_MODELS - Fixed seams (and other options) zs to match toolpaths zs in preview

This commit is contained in:
enricoturri1966 2021-09-08 13:04:43 +02:00
parent c12e5bb4ed
commit 9abebe5fbe
2 changed files with 6 additions and 4 deletions

View file

@ -34,7 +34,9 @@ void main()
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
vec4 world_position = vec4(v_position * vec3(vec2(i_scales.x), i_scales.y) + i_offset, 1.0);
float width = 1.5 * i_scales.x;
float height = 1.5 * i_scales.y;
vec4 world_position = vec4(v_position * vec3(vec2(width), height) + i_offset - vec3(0.0, 0.0, 0.5 * i_scales.y), 1.0);
vec3 eye_position = (gl_ModelViewMatrix * world_position).xyz;
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(eye_position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);

View file

@ -1414,9 +1414,9 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
instances.push_back(curr.position.y());
instances.push_back(curr.position.z());
// append width
instances.push_back(1.5f * curr.width);
instances.push_back(curr.width);
// append height
instances.push_back(1.5f * curr.height);
instances.push_back(curr.height);
// append id
instances_ids.push_back(move_id);
@ -1428,7 +1428,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result)
const double width = static_cast<double>(1.5f * curr.width);
const double height = static_cast<double>(1.5f * curr.height);
const Transform3d trafo = Geometry::assemble_transform(curr.position.cast<double>(), Vec3d::Zero(), { width, width, height });
const Transform3d trafo = Geometry::assemble_transform((curr.position - 0.5f * curr.height * Vec3f::UnitZ()).cast<double>(), Vec3d::Zero(), { width, width, height });
const Eigen::Matrix<double, 3, 3, Eigen::DontAlign> normal_matrix = trafo.matrix().template block<3, 3>(0, 0).inverse().transpose();
for (const auto& entity : data.entities) {