[Bf-blender-cvs] [56c1388ee49] hair_guides: Material pointer in hair systems.
Lukas Tönne
noreply at git.blender.org
Sat Nov 25 15:58:14 CET 2017
Commit: 56c1388ee494d776733c3d79c4359c1523bfcacf
Author: Lukas Tönne
Date: Sat Nov 25 14:58:01 2017 +0000
Branches: hair_guides
https://developer.blender.org/rB56c1388ee494d776733c3d79c4359c1523bfcacf
Material pointer in hair systems.
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/blenkernel/intern/hair.c
M source/blender/draw/engines/eevee/eevee_materials.c
M source/blender/makesdna/DNA_hair_types.h
M source/blender/makesrna/intern/rna_hair.c
M source/blender/modifiers/intern/MOD_fur.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 5b208d495a7..2758fea6c55 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1543,6 +1543,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
layout.operator("object.correctivesmooth_bind", text="Unbind" if is_bind else "Bind")
def FUR(self, layout, ob, md):
+ hsys = md.hair_system
+
split = layout.split()
col = split.column()
@@ -1559,6 +1561,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col.separator()
+ col.prop(hsys, "material", text="")
+
col = layout.column()
col.label("Drawing:")
ds = md.draw_settings
diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c
index 41ec76ab242..d438e7bb8e2 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -34,9 +34,9 @@
#include "MEM_guardedalloc.h"
-#include "BLI_math.h"
#include "BLI_kdtree.h"
#include "BLI_listbase.h"
+#include "BLI_math.h"
#include "BLI_rand.h"
#include "BLI_sort.h"
#include "BLI_string_utf8.h"
@@ -47,6 +47,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_hair.h"
+#include "BKE_library.h"
#include "BKE_mesh.h"
#include "BKE_mesh_sample.h"
@@ -80,6 +81,10 @@ HairSystem* BKE_hair_copy(HairSystem *hsys)
nhsys->verts = MEM_dupallocN(hsys->verts);
}
+ if (nhsys->mat) {
+ id_us_plus((ID *)nhsys->mat);
+ }
+
nhsys->draw_batch_cache = NULL;
nhsys->draw_texture_cache = NULL;
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 57551703bc0..8b497681853 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -1365,8 +1365,7 @@ static void material_hair(
}
GPUTexture **fiber_texture = (GPUTexture **)(&hsys->draw_texture_cache);
- // TODO
- Material *ma = NULL;/*give_current_material(ob, omat);*/
+ Material *ma = hsys->mat;
if (ma == NULL) {
ma = &defmaterial;
}
diff --git a/source/blender/makesdna/DNA_hair_types.h b/source/blender/makesdna/DNA_hair_types.h
index 661fe0de05c..83a367826bf 100644
--- a/source/blender/makesdna/DNA_hair_types.h
+++ b/source/blender/makesdna/DNA_hair_types.h
@@ -84,6 +84,9 @@ typedef struct HairSystem {
/* Number of guide curve vertices */
int totverts;
+ /* Material used for drawing and rendering hair fibers */
+ struct Material *mat;
+
/* Data buffers for drawing */
void *draw_batch_cache;
/* Texture buffer for drawing */
diff --git a/source/blender/makesrna/intern/rna_hair.c b/source/blender/makesrna/intern/rna_hair.c
index 55b4a1d9c32..b697f46d68e 100644
--- a/source/blender/makesrna/intern/rna_hair.c
+++ b/source/blender/makesrna/intern/rna_hair.c
@@ -55,6 +55,11 @@
#include "WM_api.h"
#include "WM_types.h"
+static void rna_HairSystem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
+{
+ DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+}
+
static void rna_HairSystem_generate_follicles(
HairSystem *hsys,
struct bContext *C,
@@ -123,6 +128,12 @@ static void rna_def_hair_system(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "HairPattern");
RNA_def_property_ui_text(prop, "Pattern", "Hair pattern");
+ prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "mat");
+ RNA_def_property_ui_text(prop, "Material", "Material used for drawing and rendering hair fibers");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_HairSystem_update");
+
func = RNA_def_function(srna, "generate_follicles", "rna_HairSystem_generate_follicles");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
parm = RNA_def_pointer(func, "scalp", "Object", "Scalp", "Scalp object on which to place hair follicles");
diff --git a/source/blender/modifiers/intern/MOD_fur.c b/source/blender/modifiers/intern/MOD_fur.c
index 8b5c20b671f..90bc3b85e1d 100644
--- a/source/blender/modifiers/intern/MOD_fur.c
+++ b/source/blender/modifiers/intern/MOD_fur.c
@@ -122,6 +122,22 @@ static void foreachObjectLink(
UNUSED_VARS(ob, walk, userData, fmd);
}
+static void foreachIDLink(
+ ModifierData *md,
+ Object *ob,
+ IDWalkFunc walk,
+ void *userData)
+{
+ FurModifierData *fmd = (FurModifierData *) md;
+
+ if (fmd->hair_system)
+ {
+ walk(userData, ob, (ID **)&fmd->hair_system->mat, IDWALK_CB_USER);
+ }
+
+ foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
+}
+
ModifierTypeInfo modifierType_Fur = {
/* name */ "Fur",
/* structName */ "FurModifierData",
@@ -145,6 +161,6 @@ ModifierTypeInfo modifierType_Fur = {
/* dependsOnTime */ NULL,
/* dependsOnNormals */ NULL,
/* foreachObjectLink */ foreachObjectLink,
- /* foreachIDLink */ NULL,
+ /* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
};
More information about the Bf-blender-cvs
mailing list