Commit: 08cdc98b54496d7681753e1e815c0b6b014ed6d9
Author: Lukas Tönne
Date:   Sat Jun 9 10:16:01 2018 +0100
Branches: hair_guides hair_guides_grooming
https://developer.blender.org/rB08cdc98b54496d7681753e1e815c0b6b014ed6d9

Backport a few changes from the grooming branch.

material_index in hair system has been removed. The material/shader
for hair should be defined externally it doesn't make sense to rely
on the scalp object material slots for this.

===================================================================

M       intern/cycles/blender/blender_curves.cpp
M       source/blender/blenkernel/BKE_hair.h
M       source/blender/blenkernel/BKE_mesh_sample.h
M       source/blender/blenkernel/intern/hair.c
M       source/blender/blenkernel/intern/mesh_sample.c
M       source/blender/makesrna/intern/rna_hair.c

===================================================================

diff --git a/intern/cycles/blender/blender_curves.cpp 
b/intern/cycles/blender/blender_curves.cpp
index 558657d61d2..8792f9d2d81 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -296,20 +296,20 @@ static void ObtainCacheVColFromParticleSystem(BL::Mesh 
*b_mesh,
        }
 }
 
-static void ObtainCacheDataFromHairSystem(Mesh *mesh,
-                                          BL::Object *b_ob,
+static void ObtainCacheDataFromHairSystem(BL::Object *b_ob,
                                           BL::HairSystem *b_hsys,
-                                          ParticleCurveData *CData,
+                                          BL::Mesh *b_scalp,
+                                          int shader,
                                           bool /*background*/,
+                                          ParticleCurveData *CData,
                                           int *curvenum,
                                           int *keyno)
 {
        Transform tfm = get_transform(b_ob->matrix_world());
        Transform itfm = transform_quick_inverse(tfm);
        
-       BL::Mesh b_mesh(b_ob->data());
        void *hair_cache = BKE_hair_export_cache_new();
-       BKE_hair_export_cache_update(hair_cache, b_hsys->ptr.data, 0, 
b_mesh.ptr.data, 0xFFFFFFFF);
+       BKE_hair_export_cache_update(hair_cache, b_hsys->ptr.data, 0, 
b_scalp->ptr.data, 0xFFFFFFFF);
        
        int totcurves, totverts;
        BKE_hair_render_get_buffer_size(hair_cache, &totcurves, &totverts);
@@ -323,11 +323,8 @@ static void ObtainCacheDataFromHairSystem(Mesh *mesh,
        CData->psys_firstcurve.push_back_slow(*curvenum);
        CData->psys_curvenum.push_back_slow(totcurves);
        
-       {
-               // Material
-               int shader = clamp(b_hsys->material_index()-1, 0, 
mesh->used_shaders.size()-1);
-               CData->psys_shader.push_back_slow(shader);
-       }
+       // Material
+       CData->psys_shader.push_back_slow(shader);
        
        {
                // Cycles settings
@@ -408,7 +405,6 @@ static void ObtainCacheDataFromHairSystem(Mesh *mesh,
 }
 
 static bool ObtainCacheDataFromObject(Mesh *mesh,
-                                      BL::Mesh *b_mesh,
                                       BL::Object *b_ob,
                                       ParticleCurveData *CData,
                                       bool background)
@@ -416,7 +412,7 @@ static bool ObtainCacheDataFromObject(Mesh *mesh,
        int curvenum = 0;
        int keyno = 0;
 
-       if(!(mesh && b_mesh && b_ob && CData))
+       if(!(mesh && b_ob && CData))
                return false;
 
        BL::Object::modifiers_iterator b_mod;
@@ -436,11 +432,18 @@ static bool ObtainCacheDataFromObject(Mesh *mesh,
                        if((b_mod->type() == b_mod->type_FUR)) {
                                BL::FurModifier b_fmd((const 
PointerRNA)b_mod->ptr);
                                BL::HairSystem b_hsys = b_fmd.hair_system();
-                               ObtainCacheDataFromHairSystem(mesh,
-                                                             b_ob,
+                               
+                               const int material_index = 1; /* TODO */
+                               int shader = clamp(material_index - 1, 0, 
mesh->used_shaders.size()-1);
+                               
+                               BL::Mesh b_scalp(b_ob->data());
+                               
+                               ObtainCacheDataFromHairSystem(b_ob,
                                                              &b_hsys,
-                                                             CData,
+                                                             &b_scalp,
+                                                             shader,
                                                              background,
+                                                             CData,
                                                              &curvenum,
                                                              &keyno);
                        }
@@ -1084,7 +1087,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
 
        ParticleCurveData CData;
 
-       ObtainCacheDataFromObject(mesh, &b_mesh, &b_ob, &CData, !preview);
+       ObtainCacheDataFromObject(mesh, &b_ob, &CData, !preview);
 
        /* add hair geometry to mesh */
        if(primitive == CURVE_TRIANGLES) {
@@ -1120,7 +1123,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
 
        /* generated coordinates from first key. we should ideally get this from
         * blender to handle deforming objects */
-       if(!motion) {
+       if(b_mesh && !motion) {
                if(mesh->need_attribute(scene, ATTR_STD_GENERATED)) {
                        float3 loc, size;
                        mesh_texture_space(b_mesh, loc, size);
@@ -1145,7 +1148,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
        }
 
        /* create vertex color attributes */
-       if(!motion) {
+       if(b_mesh && !motion) {
                BL::Mesh::tessface_vertex_colors_iterator l;
                int vcol_num = 0;
 
@@ -1181,7 +1184,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
        }
 
        /* create UV attributes */
-       if(!motion) {
+       if(b_mesh && !motion) {
                BL::Mesh::tessface_uv_textures_iterator l;
                int uv_num = 0;
 
diff --git a/source/blender/blenkernel/BKE_hair.h 
b/source/blender/blenkernel/BKE_hair.h
index ec9f0601485..cad25348e43 100644
--- a/source/blender/blenkernel/BKE_hair.h
+++ b/source/blender/blenkernel/BKE_hair.h
@@ -117,7 +117,7 @@ void BKE_hair_generate_follicles_ex(
         int count,
         const float *loop_weights);
 
-bool BKE_hair_bind_follicles(struct HairSystem *hsys, struct Mesh *scalp);
+bool BKE_hair_bind_follicles(struct HairSystem *hsys, const struct Mesh 
*scalp);
 
 /* === Draw Settings === */
 
diff --git a/source/blender/blenkernel/BKE_mesh_sample.h 
b/source/blender/blenkernel/BKE_mesh_sample.h
index 8f8b8939bae..8599b5a38ad 100644
--- a/source/blender/blenkernel/BKE_mesh_sample.h
+++ b/source/blender/blenkernel/BKE_mesh_sample.h
@@ -55,7 +55,7 @@ bool BKE_mesh_sample_is_valid(const struct MeshSample 
*sample);
 bool BKE_mesh_sample_is_volume_sample(const struct MeshSample *sample);
 
 /* Evaluate position and normal on the given mesh */
-bool BKE_mesh_sample_eval(struct Mesh *mesh, const struct MeshSample *sample, 
float loc[3], float nor[3], float tang[3]);
+bool BKE_mesh_sample_eval(const struct Mesh *mesh, const struct MeshSample 
*sample, float loc[3], float nor[3], float tang[3]);
 
 /* Evaluate position for the given shapekey */
 bool BKE_mesh_sample_shapekey(struct Key *key, struct KeyBlock *kb, const 
struct MeshSample *sample, float loc[3]);
diff --git a/source/blender/blenkernel/intern/hair.c 
b/source/blender/blenkernel/intern/hair.c
index c007ae3a325..cca003142da 100644
--- a/source/blender/blenkernel/intern/hair.c
+++ b/source/blender/blenkernel/intern/hair.c
@@ -60,8 +60,6 @@ HairSystem* BKE_hair_new(void)
        
        hair->pattern = MEM_callocN(sizeof(HairPattern), "hair pattern");
        
-       hair->material_index = 1;
-       
        return hair;
 }
 
@@ -413,7 +411,7 @@ static void hair_fiber_find_closest_strand(
        hair_fiber_sort_weights(follicle);
 }
 
-bool BKE_hair_bind_follicles(HairSystem *hsys, Mesh *scalp)
+bool BKE_hair_bind_follicles(HairSystem *hsys, const Mesh *scalp)
 {
        if (!(hsys->flag & HAIR_SYSTEM_UPDATE_FOLLICLE_BINDING))
        {
diff --git a/source/blender/blenkernel/intern/mesh_sample.c 
b/source/blender/blenkernel/intern/mesh_sample.c
index 065c4f38601..4071adbb679 100644
--- a/source/blender/blenkernel/intern/mesh_sample.c
+++ b/source/blender/blenkernel/intern/mesh_sample.c
@@ -197,7 +197,7 @@ bool BKE_mesh_sample_is_volume_sample(const MeshSample 
*sample)
 
 /* Evaluate position and normal on the given mesh */
 
-bool BKE_mesh_sample_eval(Mesh *mesh, const MeshSample *sample, float loc[3], 
float nor[3], float tang[3])
+bool BKE_mesh_sample_eval(const Mesh *mesh, const MeshSample *sample, float 
loc[3], float nor[3], float tang[3])
 {
        const MVert *mverts = mesh->mvert;
        const unsigned int totverts = (unsigned int)mesh->totvert;
diff --git a/source/blender/makesrna/intern/rna_hair.c 
b/source/blender/makesrna/intern/rna_hair.c
index dd7dbd3d5be..7ae9dd7e01e 100644
--- a/source/blender/makesrna/intern/rna_hair.c
+++ b/source/blender/makesrna/intern/rna_hair.c
@@ -47,7 +47,6 @@
 #include "BKE_context.h"
 #include "BKE_hair.h"
 #include "BKE_main.h"
-#include "BKE_material.h"
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_query.h"
@@ -57,7 +56,7 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
-static void rna_HairSystem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), 
PointerRNA *ptr)
+static void UNUSED_FUNCTION(rna_HairSystem_update)(Main *UNUSED(bmain), Scene 
*UNUSED(scene), PointerRNA *ptr)
 {
        DEG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
 }
@@ -82,49 +81,6 @@ static void rna_HairSystem_generate_follicles(
        BKE_hair_generate_follicles(hsys, scalp_mesh, (unsigned int)seed, 
count);
 }
 
-static const EnumPropertyItem *rna_HairSystem_material_slot_itemf(
-        bContext *C,
-        PointerRNA *UNUSED(ptr),
-        PropertyRNA *UNUSED(prop),
-        bool *r_free)
-{
-       Object *ob = CTX_data_pointer_get(C, "object").data;
-       Material *ma;
-       EnumPropertyItem *item = NULL;
-       EnumPropertyItem tmp = {0, "", 0, "", ""};
-       int totitem = 0;
-       int i;
-
-       if (ob && 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);
-       *r_free = true;
-
-       return item;
-}
-
 #else
 
 static void rna_def_hair_follicle(BlenderRNA *brna)
@@ -162,11 +118,6 @@ static void rna_def_hair_system(BlenderRNA *brna)
        FunctionRNA *func;
        PropertyRNA *prop, *parm;
        
-       static const EnumPropertyItem material_slot_items[] = {
-               {0, "DUMMY", 0, "Dummy", ""},
-               {0, NULL, 0, NULL, NULL}
-       };
-       
        srna = RNA_def_struct(brna, "HairSystem", NULL);
        RNA_def_struct_ui_text(srna, "Hair System", "Hair rendering and 
deformation data");
        RNA_def_struct_sdna(srna, "HairSystem");
@@ -176,19 +127,6 @@ 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_index", PROP_INT, PROP_NONE);
-       RNA_def_property_int_sdna(prop, NULL, "material_index");
-       RNA_def_property_range(prop, 1, 32767);
-       RNA_def_property_ui_text(prop, "Material Index", "Index of material 
slot used for rendering hair fibers");
-       RNA_def_property_update(prop, 0, "rna_HairSystem_update");
-
-       prop = RNA_def_property(srna, "material_s

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to