From a8aba3f8f40f87ccf447f77735f4783340ab0a6d Mon Sep 17 00:00:00 2001 From: Jaume Bellet Date: Wed, 22 Nov 2023 22:50:16 +0100 Subject: [PATCH] Ok --- source/blender/editors/object/CMakeLists.txt | 1 + source/blender/editors/object/object_add.cc | 23 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index d3d1fe4da90..0afbadc6de4 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -21,6 +21,7 @@ set(INC ../../render ../../shader_fx ../../windowmanager + ../transform ../../../../intern/clog # RNA_prototypes.h diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 0a1e40b1a16..a591a68c2e5 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -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 */