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:
authorGeoffroy Krantz <kgeogeo@hotmail.com>2013-12-07 04:51:44 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2013-12-07 15:26:58 +0400
commit9174f22b3c51b601e6c399bba2b32303f008630d (patch)
treec83995440d0b54f1a5dcddf475cbc92f8c0545a0
parent85a0c5d4e1030a5fa95ad7450958a1b0fa033381 (diff)
Particles: change material picking from index number in UI to menu with materials.
Also fix material slot index not being properly initialized to 1, this got clamped from zero only on drawing the UI. Reviewed By: brecht Differential Revision: http://developer.blender.org/D55
-rw-r--r--release/scripts/startup/bl_ui/properties_particle.py2
-rw-r--r--source/blender/blenkernel/intern/particle.c1
-rw-r--r--source/blender/makesrna/intern/rna_particle.c56
3 files changed, 57 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py
index c5997ebd514..206a208eac3 100644
--- a/release/scripts/startup/bl_ui/properties_particle.py
+++ b/release/scripts/startup/bl_ui/properties_particle.py
@@ -797,7 +797,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel):
part = particle_get_settings(context)
row = layout.row()
- row.prop(part, "material")
+ row.prop(part, "material_slot", text="")
if psys:
row.prop(psys, "parent")
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index a819b73ca3c..a76b60fa93a 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3652,6 +3652,7 @@ static void default_particle_settings(ParticleSettings *part)
if (!part->effector_weights)
part->effector_weights = BKE_add_effector_weights(NULL);
+ part->omat = 1;
part->use_modifier_stack = false;
}
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index 5151310cd64..92c567e9a67 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -136,6 +136,7 @@ static EnumPropertyItem part_hair_ren_as_items[] = {
#include "BKE_DerivedMesh.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_effect.h"
+#include "BKE_material.h"
#include "BKE_modifier.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
@@ -390,6 +391,47 @@ static void rna_ParticleSystem_co_hair(ParticleSystem *particlesystem, Object *o
}
+
+static EnumPropertyItem *rna_Particule_Material_itemf(bContext *C, PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop), int *free)
+{
+ Object *ob = CTX_data_active_object(C);
+ Material *ma;
+ EnumPropertyItem *item = NULL;
+ EnumPropertyItem tmp = {0, "", 0, "", ""};
+ int totitem = 0;
+ int i;
+
+ if (ob->totcol > 0){
+ for (i = 1; i<=ob->totcol; i++) {
+ ma = give_current_material(ob, i);
+ tmp.value = i;
+ tmp.icon = ICON_MATERIAL_DATA;
+ if (ma) {
+ tmp.name = ma->id.name + 2;
+ tmp.identifier = tmp.name;
+ }
+ else {
+ tmp.name = "Default Material";
+ tmp.identifier = tmp.name;
+ }
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+ }
+ else {
+ tmp.value = 1;
+ tmp.icon = ICON_MATERIAL_DATA;
+ tmp.name = "Default Material";
+ tmp.identifier = tmp.name;
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+ *free = 1;
+
+ return item;
+}
+
static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem, ReportList *reports,
ParticleSystemModifierData *modifier, ParticleData *particle,
int particle_no, int uv_no,
@@ -2018,6 +2060,11 @@ static void rna_def_particle_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem part_mat_items[] = {
+ {0, "DUMMY", 0, "Dummy", ""},
+ {0, NULL, 0, NULL, NULL}
+ };
+
srna = RNA_def_struct(brna, "ParticleSettings", "ID");
RNA_def_struct_ui_text(srna, "Particle Settings", "Particle settings, reusable by multiple particle systems");
RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA);
@@ -2360,7 +2407,14 @@ static void rna_def_particle_settings(BlenderRNA *brna)
prop = RNA_def_property(srna, "material", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "omat");
RNA_def_property_range(prop, 1, 32767);
- RNA_def_property_ui_text(prop, "Material", "Material used for the particles");
+ RNA_def_property_ui_text(prop, "Material Index", "Index of material slot used for rendering particles");
+ RNA_def_property_update(prop, 0, "rna_Particle_redo");
+
+ prop = RNA_def_property(srna, "material_slot", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "omat");
+ RNA_def_property_enum_items(prop, part_mat_items);
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particule_Material_itemf");
+ RNA_def_property_ui_text(prop, "Material Slot", "Material slot used for rendering particles");
RNA_def_property_update(prop, 0, "rna_Particle_redo");
prop = RNA_def_property(srna, "integrator", PROP_ENUM, PROP_NONE);