From 2e3433c1f7b86cabf4a6d84b5ccfa72d658c4b0a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 28 Jan 2019 12:17:54 +0100 Subject: Fix T60127: Particles texture mapping coordinates objects Part of the issue was a missing relation. Other part wes aboud object's inverse matrix never being updated. --- source/blender/blenkernel/intern/object_update.c | 4 +++- source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 8 ++++++++ source/blender/makesrna/intern/rna_particle.c | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index c44a45e67eb..5a25880a7d1 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -145,7 +145,9 @@ void BKE_object_eval_constraints(Depsgraph *depsgraph, void BKE_object_eval_transform_final(Depsgraph *depsgraph, Object *ob) { DEG_debug_print_eval(depsgraph, __func__, ob->id.name, ob); - + /* Make sure inverse matrix is always up to date. This way users of it + * do not need to worry about relcalculating it. */ + invert_m4_m4(ob->imat, ob->obmat); /* Set negative scale flag in object. */ if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE; else ob->transflag &= ~OB_NEG_SCALE; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 1cb9385c848..27d8a414b37 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1868,6 +1868,14 @@ void DepsgraphRelationBuilder::build_particle_settings(ParticleSettings *part) particle_settings_reset_key, "Particle Texture", DEPSREL_FLAG_FLUSH_USER_EDIT_ONLY); + /* TODO(sergey): Consider moving texture space handling to an own + * function. */ + if (mtex->texco == TEXCO_OBJECT && mtex->object != NULL) { + ComponentKey object_key(&mtex->object->id, DEG_NODE_TYPE_TRANSFORM); + add_relation(object_key, + particle_settings_eval_key, + "Particle Texture Space"); + } } if (check_id_has_anim_component(&part->id)) { ComponentKey animation_key(&part->id, DEG_NODE_TYPE_ANIMATION); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index c5ace465cba..e75802c656a 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -1793,14 +1793,14 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna) RNA_def_property_enum_items(prop, texco_items); RNA_def_property_ui_text(prop, "Texture Coordinates", "Texture coordinates used to map the texture onto the background"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency"); prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "object"); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency"); prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "uvname"); -- cgit v1.2.3