Fix #131596: Grease Pencil: "Reproject to View" is wrong
Previous method of doing the projection from the spot of the camera was not reliable (depending on where the view/camera was located). Instead, use the same ray origin for all methods and define the plane at the placement location (with the view direction). This is also easier to read I think. Pull Request: https://projects.blender.org/blender/blender/pulls/131790
This commit is contained in:
committed by
Philipp Oeser
parent
9ec5a0cb02
commit
ed1baf0091
@@ -388,26 +388,24 @@ float3 DrawingPlacement::reproject(const float3 pos) const
|
||||
/* Reproject the point onto the `placement_plane_` from the current view. */
|
||||
RegionView3D *rv3d = static_cast<RegionView3D *>(region_->regiondata);
|
||||
|
||||
float3 ray_co, ray_no;
|
||||
float3 ray_no;
|
||||
if (rv3d->is_persp) {
|
||||
ray_co = float3(rv3d->viewinv[3]);
|
||||
ray_no = math::normalize(ray_co - world_pos);
|
||||
ray_no = math::normalize(world_pos - float3(rv3d->viewinv[3]));
|
||||
}
|
||||
else {
|
||||
ray_co = world_pos;
|
||||
ray_no = -float3(rv3d->viewinv[2]);
|
||||
}
|
||||
float4 plane;
|
||||
if (plane_ == DrawingPlacementPlane::View) {
|
||||
plane = float4(rv3d->viewinv[2]);
|
||||
plane_from_point_normal_v3(plane, placement_loc_, rv3d->viewinv[2]);
|
||||
}
|
||||
else {
|
||||
plane = placement_plane_;
|
||||
}
|
||||
|
||||
float lambda;
|
||||
if (isect_ray_plane_v3(ray_co, ray_no, plane, &lambda, false)) {
|
||||
proj_point = ray_co + ray_no * lambda;
|
||||
if (isect_ray_plane_v3(world_pos, ray_no, plane, &lambda, false)) {
|
||||
proj_point = world_pos + ray_no * lambda;
|
||||
}
|
||||
else {
|
||||
return pos;
|
||||
|
||||
Reference in New Issue
Block a user