27#define DNA_DEPRECATED_ALLOW
69 std::optional<Library *> owner_library,
74 Tex *texture_dst = id_cast<Tex *>(id_dst);
75 const Tex *texture_src = id_cast<const Tex *>(id_src);
84 texture_dst->
ima =
nullptr;
87 if (texture_dst->
coba) {
88 texture_dst->
coba = MEM_dupalloc(texture_dst->
coba);
103 reinterpret_cast<ID **
>(&texture_dst->
nodetree),
104 flag_embedded_id_data);
112 texture_dst->
preview =
nullptr;
127 MEM_SAFE_DELETE(
texture->coba);
147 Tex *tex = id_cast<Tex *>(
id);
173 Tex *tex = id_cast<Tex *>(
id);
186 .id_code = Tex::id_type,
190 .struct_size =
sizeof(
Tex),
192 .name_plural =
N_(
"textures"),
195 .asset_type_info =
nullptr,
200 .make_local =
nullptr,
202 .foreach_cache =
nullptr,
203 .foreach_path =
nullptr,
204 .foreach_working_space_color =
nullptr,
205 .foreach_asset_weak_reference =
nullptr,
206 .owner_pointer_get =
nullptr,
210 .blend_read_after_liblink =
nullptr,
212 .blend_read_undo_preserve =
nullptr,
214 .lib_override_apply_post =
nullptr,
227 TexMapping *texmap = MEM_new<TexMapping>(
"TexMapping");
238 texmap->
size[0] = texmap->
size[1] = texmap->
size[2] = 1.0f;
239 texmap->
max[0] = texmap->
max[1] = texmap->
max[2] = 1.0f;
251 float smat[4][4], rmat[4][4], tmat[4][4], proj[4][4], size[3];
266 proj[texmap->
projx - 1][0] = 1.0f;
269 proj[texmap->
projy - 1][1] = 1.0f;
272 proj[texmap->
projz - 1][2] = 1.0f;
280 if (
fabsf(size[0]) < 1e-5f) {
281 size[0] =
signf(size[0]) * 1e-5f;
283 if (
fabsf(size[1]) < 1e-5f) {
284 size[1] =
signf(size[1]) * 1e-5f;
286 if (
fabsf(size[2]) < 1e-5f) {
287 size[2] =
signf(size[2]) * 1e-5f;
330 ColorMapping *colormap = MEM_new<ColorMapping>(
"ColorMapping");
392 mtex = MEM_new<MTex>(
"BKE_texture_mtex_add");
406 if (mtex_ar ==
nullptr) {
431 id_us_min(id_cast<ID *>(mtex_ar[slot]->tex));
432 MEM_delete(mtex_ar[slot]);
433 mtex_ar[slot] =
nullptr;
438 return mtex_ar[slot];
445 MTex *mtex =
nullptr;
449 mtex = linestyle->
mtex[int(linestyle->
texact)];
460 int act = linestyle->
texact;
462 if (linestyle->
mtex[act] && linestyle->
mtex[act]->
tex) {
467 if (!linestyle->
mtex[act]) {
472 linestyle->
mtex[act]->
tex = newtex;
476 MEM_SAFE_DELETE(linestyle->
mtex[act]);
482 switch (
GS(
id->name)) {
484 *mtex_ar = (id_cast<FreestyleLineStyle *>(
id))->mtex;
486 *act = ((id_cast<FreestyleLineStyle *>(
id))->texact);
490 *mtex_ar = (id_cast<ParticleSettings *>(
id))->mtex;
492 *act = ((id_cast<ParticleSettings *>(
id))->texact);
515 switch (
GS(
id->name)) {
517 (id_cast<FreestyleLineStyle *>(
id))->texact = act;
520 (id_cast<ParticleSettings *>(
id))->texact = act;
547 MTex *mtex =
nullptr;
571 if (!part->
mtex[act]) {
581 MEM_SAFE_DELETE(part->
mtex[act]);
622 bool use_color_management)
626 texture, tex_co, texres, pool, use_color_management,
false);
633 texres->
tin = (1.0f / 3.0f) * (texres->
trgba[0] + texres->
trgba[1] + texres->
trgba[2]);
643 bool use_color_management)
655 else if (
node->is_group() &&
node->id !=
nullptr) {
665 if (
texture->nodetree !=
nullptr) {
#define BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data_, func_call_)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
#define SH_NODE_TEX_IMAGE
#define mul_m4_series(...)
#define BLO_read_struct(reader, struct_name, ptr_p)
#define BLT_I18NCONTEXT_ID_TEXTURE
Read Blender memory allocation and freeing.
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
void node_tree_blend_write(BlendWriter *writer, bNodeTree *ntree)
bNodeTree * node_tree_localize(bNodeTree *ntree, std::optional< ID * > new_owner_id)
void node_tree_free_embedded_tree(bNodeTree *ntree)
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
void BKE_icon_id_delete(ID *id)
bool BKE_image_is_animated(Image *image)
void BKE_previewimg_id_free(ID *id)
void BKE_colorband_init(ColorBand *coba, bool rangetype)
struct Tex * give_current_particle_texture(struct ParticleSettings *part)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BKE_previewimg_blend_read(BlendDataReader *reader, PreviewImage *prv)
struct MTex * BKE_texture_mtex_add()
void set_current_particle_texture(struct ParticleSettings *part, struct Tex *tex)
void BKE_previewimg_blend_write(BlendWriter *writer, const PreviewImage *prv)
static void texture_nodes_fetch_images_for_pool(Tex *texture, bNodeTree *ntree, ImagePool *pool)
struct TexMapping * BKE_texture_mapping_add(int type)
bool BKE_texture_is_image_user(const struct Tex *tex)
static void texture_copy_data(Main *bmain, std::optional< Library * > owner_library, ID *id_dst, const ID *id_src, const int flag)
void BKE_texture_get_value_ex(struct Tex *texture, const float *tex_co, struct TexResult *texres, struct ImagePool *pool, bool use_color_management)
struct MTex * BKE_texture_mtex_add_id(struct ID *id, int slot)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
bool invert_m4(float mat[4][4])
void BKE_texture_mapping_init(struct TexMapping *texmap)
void BKE_texture_fetch_images_for_pool(struct Tex *texture, struct ImagePool *pool)
void BKE_id_blend_write(BlendWriter *writer, ID *id)
static void texture_free_data(ID *id)
void set_current_brush_texture(struct Brush *br, struct Tex *tex)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
@ LIB_ID_CREATE_NO_ALLOCATE
void BKE_brush_tag_unsaved_changes(Brush *brush)
void size_to_mat4(float R[4][4], const float size[3])
bool give_active_mtex(struct ID *id, struct MTex ***mtex_ar, short *act)
BMesh const char void * data
MINLINE float signf(float f)
struct Tex * give_current_linestyle_texture(struct FreestyleLineStyle *linestyle)
void BKE_library_foreach_ID_embedded(LibraryForeachIDData *data, ID **id_pp)
void BKE_texture_mtex_default(struct MTex *mtex)
void BKE_texture_default(struct Tex *tex)
void ntreeTexEndExecTree(struct bNodeTreeExec *exec)
void unit_m4(float m[4][4])
MINLINE bool is_one_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
struct ColorMapping * BKE_texture_colormapping_add()
void set_current_linestyle_texture(struct FreestyleLineStyle *linestyle, struct Tex *tex)
struct Tex * give_current_brush_texture(struct Brush *br)
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
static void texture_blend_read_data(BlendDataReader *reader, ID *id)
void BKE_texture_type_set(struct Tex *tex, eTex_Type type)
void BKE_texture_get_value(struct Tex *texture, const float *tex_co, struct TexResult *texres, bool use_color_management)
static void texture_foreach_id(ID *id, LibraryForeachIDData *data)
static void texture_init_data(ID *id)
void BKE_previewimg_id_copy(ID *new_id, const ID *old_id)
void eul_to_mat4(float mat[4][4], const float eul[3])
void transpose_m4(float R[4][4])
MINLINE void copy_v3_fl(float r[3], float f)
void set_active_mtex(struct ID *id, short act)
int multitex_ext_safe(Tex *tex, const float texvec[3], TexResult *texres, ImagePool *pool, bool scene_color_manage, const bool skip_load_image)
ID_Type GS(const char *name)
void BKE_texture_mtex_foreach_id(struct LibraryForeachIDData *data, struct MTex *mtex)
struct Tex * BKE_texture_add(struct Main *bmain, const char *name)
static void texture_blend_write(BlendWriter *writer, ID *id, const void *id_address)
void zero_m4(float m[4][4])
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
bool BKE_texture_dependsOnTime(const struct Tex *texture)
ImBuf * BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool)
void BKE_imageuser_default(ImageUser *iuser)
void * BKE_id_new(Main *bmain, short type, const char *name)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
struct ID * BKE_id_copy_in_lib(Main *bmain, std::optional< Library * > owner_library, const ID *id, std::optional< const ID * > new_owner_id, ID **new_id_p, int flag)
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
void write_embedded_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
eMTex_BlendType blendtype
struct PreviewImage * preview
struct bNodeTree * nodetree
bke::bNodeTreeRuntime * runtime