Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_texture.h1
-rw-r--r--source/blender/blenkernel/intern/texture.c31
2 files changed, 30 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 4ad84dceb53..ebf85ff51d1 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -132,6 +132,7 @@ struct OceanTex *BKE_add_oceantex(void);
struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot);
bool BKE_texture_dependsOnTime(const struct Tex *texture);
+bool BKE_texture_is_image_user(const struct Tex *tex);
void BKE_texture_get_value(struct Scene *scene, struct Tex *texture, float *tex_co, struct TexResult *texres, bool use_color_management);
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 6c4cbcf9316..3293cca76fe 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -832,8 +832,12 @@ Tex *BKE_texture_copy(Tex *tex)
Tex *texn;
texn = BKE_libblock_copy(&tex->id);
- if (texn->type == TEX_IMAGE) id_us_plus((ID *)texn->ima);
- else texn->ima = NULL;
+ if (BKE_texture_is_image_user(tex)) {
+ id_us_plus((ID *)texn->ima);
+ }
+ else {
+ texn->ima = NULL;
+ }
if (texn->coba) texn->coba = MEM_dupallocN(texn->coba);
if (texn->env) texn->env = BKE_copy_envmap(texn->env);
@@ -1604,6 +1608,29 @@ void BKE_free_oceantex(struct OceanTex *ot)
MEM_freeN(ot);
}
+/**
+ * \returns true if this texture can use its #Texture.ima (even if its NULL)
+ */
+bool BKE_texture_is_image_user(const struct Tex *tex)
+{
+ switch (tex->type) {
+ case TEX_IMAGE:
+ {
+ return true;
+ }
+ case TEX_ENVMAP:
+ {
+ if (tex->env) {
+ if (tex->env->stype == ENV_LOAD) {
+ return true;
+ }
+ }
+ break;
+ }
+ }
+
+ return false;
+}
/* ------------------------------------------------------------------------- */
bool BKE_texture_dependsOnTime(const struct Tex *texture)