This commit is contained in:
Jaume Bellet 2023-11-22 22:50:16 +01:00
parent c93c5ec921
commit a8aba3f8f4
2 changed files with 24 additions and 0 deletions

View File

@ -21,6 +21,7 @@ set(INC
../../render
../../shader_fx
../../windowmanager
../transform
../../../../intern/clog
# RNA_prototypes.h

View File

@ -89,6 +89,7 @@
#include "BKE_speaker.h"
#include "BKE_vfont.h"
#include "BKE_volume.hh"
#include "BKE_scene.h"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_build.hh"
@ -126,6 +127,8 @@
#include "object_intern.h"
#include "transform_orientations.hh"
using blender::float3;
using blender::float4x4;
using blender::Vector;
@ -347,15 +350,35 @@ float ED_object_new_primitive_matrix(bContext *C,
View3D *v3d = CTX_wm_view3d(C);
float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3];
float ts_mat[3][3];
char ts_name[MAX_NAME];
//int orientation_index = v3d->twmode - V3D_MANIP_CUSTOM;
TransformOrientation *custom_orientation = nullptr;
if (scene->orientation_slots->type >= V3D_ORIENT_CUSTOM &&
scene->orientation_slots->index_custom != -1)
{
custom_orientation = BKE_scene_transform_orientation_find(
scene, scene->orientation_slots->index_custom);
}
unit_m4(r_primmat);
eul_to_mat3(rmat, rot);
invert_m3(rmat);
if (custom_orientation) {
applyTransformOrientation(custom_orientation, ts_mat, ts_name);
invert_m3(ts_mat);
mul_m3_m3m3(mat, rmat, ts_mat);
copy_m3_m3(rmat, mat);
}
/* inverse transform for initial rotation and object */
copy_m3_m4(mat, obedit->object_to_world);
mul_m3_m3m3(cmat, rmat, mat);
invert_m3_m3(imat, cmat);
copy_m4_m3(r_primmat, imat);
/* center */