Cleanup: Use C++ math types and functions for multires_reshape_util.cc
This commit does not change lines that access the `ReshapeGridElement` or `ReshapeConstGridElement`, that cleanup will follow in a later commit. Pull Request: https://projects.blender.org/blender/blender/pulls/140783
This commit is contained in:
@@ -227,8 +227,8 @@ GridCoord multires_reshape_ptex_coord_to_grid(const MultiresReshapeContext *resh
|
||||
void multires_reshape_tangent_matrix_for_corner(const MultiresReshapeContext *reshape_context,
|
||||
int face_index,
|
||||
int corner,
|
||||
const float dPdu[3],
|
||||
const float dPdv[3],
|
||||
const blender::float3 &dPdu,
|
||||
const blender::float3 &dPdv,
|
||||
blender::float3x3 &r_tangent_matrix);
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_task.h"
|
||||
|
||||
@@ -459,8 +460,8 @@ GridCoord multires_reshape_ptex_coord_to_grid(const MultiresReshapeContext *resh
|
||||
void multires_reshape_tangent_matrix_for_corner(const MultiresReshapeContext *reshape_context,
|
||||
const int face_index,
|
||||
const int corner,
|
||||
const float dPdu[3],
|
||||
const float dPdv[3],
|
||||
const blender::float3 &dPdu,
|
||||
const blender::float3 &dPdv,
|
||||
blender::float3x3 &r_tangent_matrix)
|
||||
{
|
||||
/* For a quad faces we would need to flip the tangent, since they will use
|
||||
@@ -742,17 +743,15 @@ static void object_grid_element_to_tangent_displacement(
|
||||
blender::float3x3 tangent_matrix;
|
||||
multires_reshape_evaluate_limit_at_grid(reshape_context, grid_coord, P, tangent_matrix);
|
||||
|
||||
float inv_tangent_matrix[3][3];
|
||||
invert_m3_m3(inv_tangent_matrix, tangent_matrix.ptr());
|
||||
const blender::float3x3 inv_tangent_matrix = blender::math::invert(tangent_matrix);
|
||||
|
||||
ReshapeGridElement grid_element = multires_reshape_grid_element_for_grid_coord(reshape_context,
|
||||
grid_coord);
|
||||
|
||||
float D[3];
|
||||
blender::float3 D;
|
||||
sub_v3_v3v3(D, grid_element.displacement, P);
|
||||
|
||||
float tangent_D[3];
|
||||
mul_v3_m3v3(tangent_D, inv_tangent_matrix, D);
|
||||
blender::float3 tangent_D = blender::math::transform_direction(inv_tangent_matrix, D);
|
||||
|
||||
copy_v3_v3(grid_element.displacement, tangent_D);
|
||||
}
|
||||
@@ -785,7 +784,7 @@ static void assign_final_coords_from_mdisps(const MultiresReshapeContext *reshap
|
||||
|
||||
ReshapeGridElement grid_element = multires_reshape_grid_element_for_grid_coord(reshape_context,
|
||||
grid_coord);
|
||||
float D[3];
|
||||
blender::float3 D;
|
||||
mul_v3_m3v3(D, tangent_matrix.ptr(), grid_element.displacement);
|
||||
|
||||
add_v3_v3v3(grid_element.displacement, P, D);
|
||||
@@ -809,7 +808,7 @@ static void assign_final_elements_from_orig_mdisps(const MultiresReshapeContext
|
||||
const ReshapeConstGridElement orig_grid_element =
|
||||
multires_reshape_orig_grid_element_for_grid_coord(reshape_context, grid_coord);
|
||||
|
||||
float D[3];
|
||||
blender::float3 D;
|
||||
mul_v3_m3v3(D, tangent_matrix.ptr(), orig_grid_element.displacement);
|
||||
|
||||
ReshapeGridElement grid_element = multires_reshape_grid_element_for_grid_coord(reshape_context,
|
||||
|
||||
Reference in New Issue
Block a user