Blender V5.3
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_c.hh"
12#include "BLI_math_vector_c.hh"
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 TransDataExtension *td_ext;
40 Object *ob;
41 ID *id;
42 char *texspace_flag;
43
45 ob = BKE_view_layer_active_object_get(view_layer);
46
47 if (ob == nullptr) { /* Shouldn't logically happen, but still. */
48 return;
49 }
50
51 id = ob->data;
52 if (id == nullptr || !ELEM(GS(id->name), ID_ME, ID_CU_LEGACY, ID_MB)) {
53 BKE_report(t->reports, RPT_ERROR, "Unsupported object type for texture space transform");
54 return;
55 }
56
58 BKE_report(t->reports, RPT_ERROR, "Cannot create transform on linked data");
59 return;
60 }
61
62 {
65 tc->data_len = 1;
66 td = tc->data = MEM_new_zeroed<TransData>("TransTexspace");
67 td_ext = tc->data_ext = MEM_new_zeroed<TransDataExtension>("TransTexspace");
68 }
69
70 td->flag = TD_SELECTED;
71 td->extra = ob;
72
73 copy_m3_m4(td->mtx, ob->object_to_world().ptr());
74 copy_m3_m4(td->axismtx, ob->object_to_world().ptr());
77
78 if (BKE_object_obdata_texspace_get(ob, &texspace_flag, &td->loc, &td_ext->scale)) {
79 ob->dtx |= OB_TEXSPACE;
80 *texspace_flag &= ~ME_TEXSPACE_FLAG_AUTO;
81 }
82
83 copy_v3_v3(td->iloc, td->loc);
84 copy_v3_v3(td->center, td->loc);
85 copy_v3_v3(td_ext->iscale, td_ext->scale);
86}
87
89
90/* -------------------------------------------------------------------- */
93
95{
96
97 if (t->state != TRANS_CANCEL) {
99 }
100
102 TransData *td = tc->data;
103
104 for (int i = 0; i < tc->data_len; i++, td++) {
105 if (td->flag & TD_SKIP) {
106 continue;
107 }
108 Object *ob = static_cast<Object *>(td->extra);
110 }
111 }
112}
113
115
117 /*flags*/ 0,
118 /*create_trans_data*/ createTransTexspace,
119 /*recalc_data*/ recalcData_texspace,
120 /*special_aftertrans_update*/ nullptr,
121};
122
123} // namespace blender::ed::transform
General operations, lookup, etc. for blender objects.
#define PSEUDOINVERSE_EPSILON
Read Blender memory allocation and freeing.
#define ELEM(...)
static void createTransTexspace(bContext *, TransInfo *t)
void transform_snap_project_individual_apply(TransInfo *t)
static void recalcData_texspace(TransInfo *t)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void normalize_m3(float R[3][3]) ATTR_NONNULL()
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
@ ME_TEXSPACE_FLAG_AUTO
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
bool BKE_object_obdata_texspace_get(Object *ob, char **r_texspace_flag, float **r_texspace_location, float **r_texspace_size)
Definition object.cc:4344
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
ID_Type GS(const char *name)
Definition DNA_ID.h:410
void pseudoinverse_m3_m3(float inverse[3][3], const float mat[3][3], float epsilon)
bool BKE_object_obdata_is_libdata(const Object *ob)
Definition object.cc:2845
eObject_DrawExtraFlag dtx
TransDataContainer * data_container
Definition transform.hh:828
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:48
conversion and adaptation of different datablocks to a common struct.