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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2020-02-03 16:07:48 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-02-03 16:07:48 +0300
commitf037244e2cbd9dec7d423cdd1f966678156a374a (patch)
tree954150431b04e83358603bc033f8ac3ee9d00aa3 /source
parentaea125fe9d2db2eaff640e0fc42724f00413a49c (diff)
parentbc3d7faab73165de8a7a7a9f8b19dcdfc046a51b (diff)
Merge branch 'blender-v2.82-release'
Diffstat (limited to 'source')
-rw-r--r--source/blender/gpu/intern/gpu_draw.c138
-rw-r--r--source/blender/makesrna/intern/rna_particle.c8
2 files changed, 75 insertions, 71 deletions
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index cfeb7f6bedb..cac3ba37b0a 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -363,86 +363,86 @@ static uint gpu_texture_create_tile_array(Image *ima, ImBuf *main_ibuf)
BKE_imageuser_default(&iuser);
iuser.tile = tile->tile_number;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
- BLI_assert(ibuf != NULL);
- bool needs_scale = (ibuf->x != tilesize[0] || ibuf->y != tilesize[1]);
-
- ImBuf *scale_ibuf = NULL;
- if (ibuf->rect_float) {
- float *rect_float = ibuf->rect_float;
+ if (ibuf) {
+ bool needs_scale = (ibuf->x != tilesize[0] || ibuf->y != tilesize[1]);
- const bool store_premultiplied = ima->alpha_mode != IMA_ALPHA_STRAIGHT;
- if (ibuf->channels != 4 || !store_premultiplied) {
- rect_float = MEM_mallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, __func__);
- IMB_colormanagement_imbuf_to_float_texture(
- rect_float, 0, 0, ibuf->x, ibuf->y, ibuf, store_premultiplied);
- }
+ ImBuf *scale_ibuf = NULL;
+ if (ibuf->rect_float) {
+ float *rect_float = ibuf->rect_float;
- float *pixeldata = rect_float;
- if (needs_scale) {
- scale_ibuf = IMB_allocFromBuffer(NULL, rect_float, ibuf->x, ibuf->y, 4);
- IMB_scaleImBuf(scale_ibuf, tilesize[0], tilesize[1]);
- pixeldata = scale_ibuf->rect_float;
- }
+ const bool store_premultiplied = ima->alpha_mode != IMA_ALPHA_STRAIGHT;
+ if (ibuf->channels != 4 || !store_premultiplied) {
+ rect_float = MEM_mallocN(sizeof(float) * 4 * ibuf->x * ibuf->y, __func__);
+ IMB_colormanagement_imbuf_to_float_texture(
+ rect_float, 0, 0, ibuf->x, ibuf->y, ibuf, store_premultiplied);
+ }
- glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
- 0,
- tileoffset[0],
- tileoffset[1],
- tilelayer,
- tilesize[0],
- tilesize[1],
- 1,
- GL_RGBA,
- GL_FLOAT,
- pixeldata);
+ float *pixeldata = rect_float;
+ if (needs_scale) {
+ scale_ibuf = IMB_allocFromBuffer(NULL, rect_float, ibuf->x, ibuf->y, 4);
+ IMB_scaleImBuf(scale_ibuf, tilesize[0], tilesize[1]);
+ pixeldata = scale_ibuf->rect_float;
+ }
- if (rect_float != ibuf->rect_float) {
- MEM_freeN(rect_float);
- }
- }
- else {
- unsigned int *rect = ibuf->rect;
-
- if (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) {
- rect = MEM_mallocN(sizeof(uchar) * 4 * ibuf->x * ibuf->y, __func__);
- IMB_colormanagement_imbuf_to_byte_texture((uchar *)rect,
- 0,
- 0,
- ibuf->x,
- ibuf->y,
- ibuf,
- internal_format == GL_SRGB8_ALPHA8,
- ima->alpha_mode == IMA_ALPHA_PREMUL);
+ glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
+ 0,
+ tileoffset[0],
+ tileoffset[1],
+ tilelayer,
+ tilesize[0],
+ tilesize[1],
+ 1,
+ GL_RGBA,
+ GL_FLOAT,
+ pixeldata);
+
+ if (rect_float != ibuf->rect_float) {
+ MEM_freeN(rect_float);
+ }
}
+ else {
+ unsigned int *rect = ibuf->rect;
+
+ if (!IMB_colormanagement_space_is_data(ibuf->rect_colorspace)) {
+ rect = MEM_mallocN(sizeof(uchar) * 4 * ibuf->x * ibuf->y, __func__);
+ IMB_colormanagement_imbuf_to_byte_texture((uchar *)rect,
+ 0,
+ 0,
+ ibuf->x,
+ ibuf->y,
+ ibuf,
+ internal_format == GL_SRGB8_ALPHA8,
+ ima->alpha_mode == IMA_ALPHA_PREMUL);
+ }
- unsigned int *pixeldata = rect;
- if (needs_scale) {
- scale_ibuf = IMB_allocFromBuffer(rect, NULL, ibuf->x, ibuf->y, 4);
- IMB_scaleImBuf(scale_ibuf, tilesize[0], tilesize[1]);
- pixeldata = scale_ibuf->rect;
+ unsigned int *pixeldata = rect;
+ if (needs_scale) {
+ scale_ibuf = IMB_allocFromBuffer(rect, NULL, ibuf->x, ibuf->y, 4);
+ IMB_scaleImBuf(scale_ibuf, tilesize[0], tilesize[1]);
+ pixeldata = scale_ibuf->rect;
+ }
+ glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
+ 0,
+ tileoffset[0],
+ tileoffset[1],
+ tilelayer,
+ tilesize[0],
+ tilesize[1],
+ 1,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ pixeldata);
+
+ if (rect != ibuf->rect) {
+ MEM_freeN(rect);
+ }
}
- glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
- 0,
- tileoffset[0],
- tileoffset[1],
- tilelayer,
- tilesize[0],
- tilesize[1],
- 1,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- pixeldata);
-
- if (rect != ibuf->rect) {
- MEM_freeN(rect);
+ if (scale_ibuf != NULL) {
+ IMB_freeImBuf(scale_ibuf);
}
}
- if (scale_ibuf != NULL) {
- IMB_freeImBuf(scale_ibuf);
- }
-
BKE_image_release_ibuf(ima, ibuf, NULL);
}
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 4155c453440..90658784b9a 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -385,11 +385,11 @@ static void rna_ParticleSystem_co_hair(
totchild = 0;
}
- if (particle_no < totpart) {
+ if (particle_no < totpart && particlesystem->pathcache) {
cache = particlesystem->pathcache[particle_no];
max_k = (int)cache->segments;
}
- else if (particle_no < totpart + totchild) {
+ else if (particle_no < totpart + totchild && particlesystem->childcache) {
cache = particlesystem->childcache[particle_no - totpart];
if (cache->segments < 0) {
@@ -400,6 +400,7 @@ static void rna_ParticleSystem_co_hair(
}
}
else {
+ zero_v3(n_co);
return;
}
@@ -409,6 +410,9 @@ static void rna_ParticleSystem_co_hair(
mul_m4_v3(particlesystem->imat, n_co);
mul_m4_v3(object->obmat, n_co);
}
+ else {
+ zero_v3(n_co);
+ }
}
static const EnumPropertyItem *rna_Particle_Material_itemf(bContext *C,