Blender V4.5
transform_convert_object_texspace.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "MEM_guardedalloc.h"
10
11#include "BLI_math_matrix.h"
12#include "BLI_math_vector.h"
13
14#include "BKE_layer.hh"
15#include "BKE_object.hh"
16#include "BKE_report.hh"
17
18#include "DNA_mesh_types.h"
19
20#include "transform.hh"
21#include "transform_snap.hh"
22
23/* Own include. */
24#include "transform_convert.hh"
25
26namespace blender::ed::transform {
27
28/* -------------------------------------------------------------------- */
34
35static void createTransTexspace(bContext * /*C*/, TransInfo *t)
36{
37 ViewLayer *view_layer = t->view_layer;
38 TransData *td;
39 Object *ob;
40 ID *id;
41 char *texspace_flag;
42
44 ob = BKE_view_layer_active_object_get(view_layer);
45
46 if (ob == nullptr) { /* Shouldn't logically happen, but still. */
47 return;
48 }
49
50 id = static_cast<ID *>(ob->data);
51 if (id == nullptr || !ELEM(GS(id->name), ID_ME, ID_CU_LEGACY, ID_MB)) {
52 BKE_report(t->reports, RPT_ERROR, "Unsupported object type for text-space transform");
53 return;
54 }
55
57 BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform");
58 return;
59 }
60
61 {
64 tc->data_len = 1;
65 td = tc->data = MEM_callocN<TransData>("TransTexspace");
66 td->ext = tc->data_ext = MEM_callocN<TransDataExtension>("TransTexspace");
67 }
68
69 td->flag = TD_SELECTED;
70 td->extra = ob;
71
72 copy_m3_m4(td->mtx, ob->object_to_world().ptr());
73 copy_m3_m4(td->axismtx, ob->object_to_world().ptr());
76
77 if (BKE_object_obdata_texspace_get(ob, &texspace_flag, &td->loc, &td->ext->scale)) {
78 ob->dtx |= OB_TEXSPACE;
79 *texspace_flag &= ~ME_TEXSPACE_FLAG_AUTO;
80 }
81
82 copy_v3_v3(td->iloc, td->loc);
83 copy_v3_v3(td->center, td->loc);
84 copy_v3_v3(td->ext->iscale, td->ext->scale);
85}
86
88
89/* -------------------------------------------------------------------- */
92
94{
95
96 if (t->state != TRANS_CANCEL) {
98 }
99
101 TransData *td = tc->data;
102
103 for (int i = 0; i < tc->data_len; i++, td++) {
104 if (td->flag & TD_SKIP) {
105 continue;
106 }
107 Object *ob = static_cast<Object *>(td->extra);
109 }
110 }
111}
112
114
116 /*flags*/ 0,
117 /*create_trans_data*/ createTransTexspace,
118 /*recalc_data*/ recalcData_texspace,
119 /*special_aftertrans_update*/ nullptr,
120};
121
122} // namespace blender::ed::transform
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
General operations, lookup, etc. for blender objects.
bool BKE_object_obdata_texspace_get(Object *ob, char **r_texspace_flag, float **r_texspace_location, float **r_texspace_size)
bool BKE_object_obdata_is_libdata(const Object *ob)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
#define BLI_assert(a)
Definition BLI_assert.h:46
void pseudoinverse_m3_m3(float inverse[3][3], const float mat[3][3], float epsilon)
void copy_m3_m4(float m1[3][3], const float m2[4][4])
#define PSEUDOINVERSE_EPSILON
void normalize_m3(float R[3][3]) ATTR_NONNULL()
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define ELEM(...)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:982
@ ID_CU_LEGACY
@ ID_ME
@ ID_MB
@ ME_TEXSPACE_FLAG_AUTO
@ OB_TEXSPACE
Read Guarded memory(de)allocation.
#define GS(a)
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
static void createTransTexspace(bContext *, TransInfo *t)
void transform_snap_project_individual_apply(TransInfo *t)
static void recalcData_texspace(TransInfo *t)
Definition DNA_ID.h:404
char name[66]
Definition DNA_ID.h:415
TransDataContainer * data_container
Definition transform.hh:797
i
Definition text_draw.cc:230
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:42
conversion and adaptation of different datablocks to a common struct.