From 5e9ad8065a19219f63ff9af86b920f181cf3bac2 Mon Sep 17 00:00:00 2001 From: Luca Rood Date: Wed, 5 Jul 2017 16:16:57 +0200 Subject: [PATCH 1/4] Code comments regarding last commit (forgotten to add before) Using an arbitrary face as the source of the UV data is mostly fine, as vertices on seams will generally map to different parts of the texture that have the same color. This is regarding fed853ea782211298c902759ec8cd8e455d8b41d --- source/blender/blenkernel/intern/particle.c | 3 +++ source/blender/blenkernel/intern/particle_distribute.c | 4 ++++ source/blender/makesrna/intern/rna_particle.c | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e101bd64931..416d63cfefb 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3410,6 +3410,9 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int index, const f if (from_vert) { mf = dm->getTessFaceDataArray(dm, CD_MFACE); + /* This finds the first face to contain the emitting vertex, + * this is not ideal, but is mostly fine as UV seams generally + * map to equal-colored parts of a texture */ for (int j = 0; j < dm->getNumTessFaces(dm); j++, mf++) { if (ELEM(i, mf->v1, mf->v2, mf->v3, mf->v4)) { i = j; diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c index 09da5fe7245..4f758bde7f9 100644 --- a/source/blender/blenkernel/intern/particle_distribute.c +++ b/source/blender/blenkernel/intern/particle_distribute.c @@ -440,6 +440,10 @@ static void distribute_from_verts_exec(ParticleTask *thread, ParticleData *pa, i zero_v4(pa->fuv); if (pa->num != DMCACHE_NOTFOUND && pa->num < ctx->dm->getNumVerts(ctx->dm)) { + + /* This finds the first face to contain the emitting vertex, + * this is not ideal, but is mostly fine as UV seams generally + * map to equal-colored parts of a texture */ for (int i = 0; i < ctx->dm->getNumTessFaces(ctx->dm); i++, mface++) { if (ELEM(pa->num, mface->v1, mface->v2, mface->v3, mface->v4)) { unsigned int *vert = &mface->v1; diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 0dac797824d..00104b8667d 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -492,6 +492,9 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys *r_fuv = &particle->fuv; + /* This finds the first face to contain the emitting vertex, + * this is not ideal, but is mostly fine as UV seams generally + * map to equal-colored parts of a texture */ for (int i = 0; i < totface; i++, mface++) { if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) { return i; @@ -531,6 +534,9 @@ static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesys *r_fuv = &parent->fuv; + /* This finds the first face to contain the emitting vertex, + * this is not ideal, but is mostly fine as UV seams generally + * map to equal-colored parts of a texture */ for (int i = 0; i < totface; i++, mface++) { if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) { return i; From d2f748a222ad19f1b81a27e0fa46de4570264432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 5 Jul 2017 20:22:28 +0200 Subject: [PATCH 2/4] Sequencer: Prevent crash when text strip doesn't have effect data. --- source/blender/blenloader/intern/versioning_270.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index d2f43a2d79e..87ccfedcff3 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1238,7 +1238,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) { if (seq->type == SEQ_TYPE_TEXT) { TextVars *data = seq->effectdata; - if (data->color[3] == 0.0f) { + if (data != NULL && data->color[3] == 0.0f) { copy_v4_fl(data->color, 1.0f); data->shadow_color[3] = 1.0f; } From 31f8ca503495e5900a4ec5f7361b3c20bf365f37 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 5 Jul 2017 20:39:34 +0200 Subject: [PATCH 3/4] Cycles: Fix compilation error after recent logging changes This file uses std::ostream for helper << operators, so need to make sure corresponding header is included. --- intern/cycles/util/util_logging.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intern/cycles/util/util_logging.h b/intern/cycles/util/util_logging.h index 6380cb13a9b..492f830e67c 100644 --- a/intern/cycles/util/util_logging.h +++ b/intern/cycles/util/util_logging.h @@ -21,6 +21,8 @@ # include #endif +#include + CCL_NAMESPACE_BEGIN #if !defined(WITH_CYCLES_LOGGING) || defined(__KERNEL_GPU__) From aea44561017ccfba58bd97741dde1508aa826a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 5 Jul 2017 22:18:36 +0200 Subject: [PATCH 4/4] Better fix for sequencer crash when text strip doesn't have effect data. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This situation happens when a file with a text effect sequencer strip is loaded in Blender < 2.76 and saved. This destroys the effect data, causing a crash in Blender ≥ 2.76. d2f748a222ad19f prevented the crash when opening such a file, but accessing the strip still caused a crash. This commit fixes that by actually initialising the invalid strip. Of course this still causes data loss, but that already happened by opening & overwriting the file in Blender < 2.76. --- .../blenloader/intern/versioning_270.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 87ccfedcff3..94d335870ca 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1236,12 +1236,19 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) SEQ_BEGIN (scene->ed, seq) { - if (seq->type == SEQ_TYPE_TEXT) { - TextVars *data = seq->effectdata; - if (data != NULL && data->color[3] == 0.0f) { - copy_v4_fl(data->color, 1.0f); - data->shadow_color[3] = 1.0f; - } + if (seq->type != SEQ_TYPE_TEXT) { + continue; + } + + if (seq->effectdata == NULL) { + struct SeqEffectHandle effect_handle = BKE_sequence_get_effect(seq); + effect_handle.init(seq); + } + + TextVars *data = seq->effectdata; + if (data->color[3] == 0.0f) { + copy_v4_fl(data->color, 1.0f); + data->shadow_color[3] = 1.0f; } } SEQ_END