Solidify modifier for Durian (allow cloth sim on single layer and make solid after)
authorCampbell Barton <ideasman42@gmail.com>
Mon, 21 Dec 2009 01:02:08 +0000 (01:02 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 21 Dec 2009 01:02:08 +0000 (01:02 +0000)
Mostly the same as the recently added editmode tool with some extras.

* Options to disable filling in the rim between inner and outer surface, since its faster not to detect this in cases where its not needed.
* Option to disable high quality normal calculation, mostly noticable when operating on building walls, not needed for cloth or more organic shapes.
* Option to disable 'even thickness', again, not needed in some cases.

Also options for creasing inner/outer and rim edges, need this for makign Sintels cloths solid since zero crease looks far too soft.

note:
* UVs and VCols etc are copied to the new skin however rim faces dont get the UVs or vcols set from the faces they are created from yet.
* Normals are assumed to be pointing outwards
* used patch from Uncle Entity as a template since it added the DNA and RNA entries but the actual modifier from the patch wasnt used.

release/scripts/ui/properties_data_modifier.py
source/blender/blenkernel/intern/modifier.c
source/blender/editors/mesh/editmesh_lib.c
source/blender/makesdna/DNA_meshdata_types.h
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_modifier.c

index 97c8f60327321bba2d980442eb35afd5ea3ec05f..97237c26191d6c1e293e7972d042804278438f61 100644 (file)
@@ -600,6 +600,20 @@ class DATA_PT_modifiers(DataButtonsPanel):
     def SOFT_BODY(self, layout, ob, md, wide_ui):
         layout.label(text="See Soft Body panel.")
 
+    def SOLIDIFY(self, layout, ob, md, wide_ui):
+        split = layout.split()
+
+        col = split.column()
+        col.prop(md, "offset")
+        col.prop(md, "use_rim")
+        col.prop(md, "use_even_offset")
+        col.prop(md, "use_quality_normals")
+        col.prop(md, "edge_crease_inner")
+        col.prop(md, "edge_crease_outer")
+        col.prop(md, "edge_crease_rim")
+        # col.label(text="Vertex Group:")
+        # col.prop_object(md, "vertex_group", ob, "vertex_groups", text="")
+
     def SUBSURF(self, layout, ob, md, wide_ui):
         if wide_ui:
             layout.row().prop(md, "subdivision_type", expand=True)
index e75203c6cdef11c5ed872a5da0efbd47bec9e534..732ba2a651e03bca8c0d65d32d485fa29630965c 100644 (file)
@@ -5807,6 +5807,432 @@ static int softbodyModifier_dependsOnTime(ModifierData *md)
        return 1;
 }
 
+/* Solidify */
+
+
+typedef struct EdgeFaceRef {
+       int f1; /* init as -1 */
+       int f2;
+} EdgeFaceRef;
+
+static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
+{
+       int i, numVerts, numEdges, numFaces;
+       MFace *mface, *mf;
+       MVert *mvert, *mv;
+
+       float (*face_nors)[3];
+       float *f_no;
+       int calc_face_nors= 0;
+
+       numVerts = dm->getNumVerts(dm);
+       numEdges = dm->getNumEdges(dm);
+       numFaces = dm->getNumFaces(dm);
+       mface = dm->getFaceArray(dm);
+       mvert = dm->getVertArray(dm);
+
+       /* we don't want to overwrite any referenced layers */
+
+       /*
+       Dosnt work here!
+       mv = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT);
+       cddm->mvert = mv;
+       */
+
+       face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
+       if(!face_nors) {
+               calc_face_nors = 1;
+               face_nors = CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_CALLOC, NULL, numFaces);
+       }
+
+       mv = mvert;
+       mf = mface;
+
+       {
+               EdgeHash *edge_hash = BLI_edgehash_new();
+               EdgeHashIterator *edge_iter;
+               int edge_ref_count = 0;
+               int ed_v1, ed_v2; /* use when getting the key */
+               EdgeFaceRef *edge_ref_array = MEM_callocN(numEdges * sizeof(EdgeFaceRef), "Edge Connectivity");
+               EdgeFaceRef *edge_ref;
+               float edge_normal[3];
+
+               /* This function adds an edge hash if its not there, and adds the face index */
+#define NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(EDV1, EDV2); \
+                               edge_ref = (EdgeFaceRef *)BLI_edgehash_lookup(edge_hash, EDV1, EDV2); \
+                               if (!edge_ref) { \
+                                       edge_ref = &edge_ref_array[edge_ref_count]; edge_ref_count++; \
+                                       edge_ref->f1=i; \
+                                       edge_ref->f2=-1; \
+                                       BLI_edgehash_insert(edge_hash, EDV1, EDV2, edge_ref); \
+                               } else { \
+                                       edge_ref->f2=i; \
+                               }
+
+               for(i = 0; i < numFaces; i++, mf++) {
+                       f_no = face_nors[i];
+
+                       if(mf->v4) {
+                               if(calc_face_nors)
+                                       normal_quad_v3(f_no, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co, mv[mf->v4].co);
+
+                               NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v1, mf->v2);
+                               NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v2, mf->v3);
+                               NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v3, mf->v4);
+                               NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v4, mf->v1);
+                       } else {
+                               if(calc_face_nors)
+                                       normal_tri_v3(f_no, mv[mf->v1].co, mv[mf->v2].co, mv[mf->v3].co);
+
+                               NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v1, mf->v2);
+                               NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v2, mf->v3);
+                               NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(mf->v3, mf->v1);
+                       }
+               }
+
+               for(edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) {
+                       /* Get the edge vert indicies, and edge value (the face indicies that use it)*/
+                       BLI_edgehashIterator_getKey(edge_iter, (int*)&ed_v1, (int*)&ed_v2);
+                       edge_ref = BLI_edgehashIterator_getValue(edge_iter);
+
+                       if (edge_ref->f2 != -1) {
+                               /* We have 2 faces using this edge, calculate the edges normal
+                                * using the angle between the 2 faces as a weighting */
+                               add_v3_v3v3(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
+                               normalize_v3(edge_normal);
+                               mul_v3_fl(edge_normal, angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
+                       } else {
+                               /* only one face attached to that edge */
+                               /* an edge without another attached- the weight on this is
+                                * undefined, M_PI/2 is 90d in radians and that seems good enough */
+                               VECCOPY(edge_normal, face_nors[edge_ref->f1])
+                               mul_v3_fl(edge_normal, M_PI/2);
+                       }
+                       add_v3_v3(temp_nors[ed_v1], edge_normal);
+                       add_v3_v3(temp_nors[ed_v2], edge_normal);
+               }
+               BLI_edgehashIterator_free(edge_iter);
+               BLI_edgehash_free(edge_hash, NULL);
+               MEM_freeN(edge_ref_array);
+       }
+
+       /* normalize vertex normals and assign */
+       for(i = 0; i < numVerts; i++, mv++) {
+               if(normalize_v3(temp_nors[i]) == 0.0f) {
+                       normal_short_to_float_v3(temp_nors[i], mv->no);
+               }
+       }
+}
+static void solidifyModifier_initData(ModifierData *md)
+{
+       SolidifyModifierData *smd = (SolidifyModifierData*) md;
+       smd->offset = 0.01f;
+       smd->flag = MOD_SOLIDIFY_EVEN | MOD_SOLIDIFY_RIM | MOD_SOLIDIFY_NORMAL_CALC;
+}
+static void solidifyModifier_copyData(ModifierData *md, ModifierData *target)
+{
+       SolidifyModifierData *smd = (SolidifyModifierData*) md;
+       SolidifyModifierData *tsmd = (SolidifyModifierData*) target;
+       tsmd->offset = smd->offset;
+       tsmd->crease_inner = smd->crease_inner;
+       tsmd->crease_outer = smd->crease_outer;
+       tsmd->crease_rim = smd->crease_rim;
+       strcpy(tsmd->vgroup, smd->vgroup);
+}
+
+static DerivedMesh *solidifyModifier_applyModifier(ModifierData *md,
+                                                  Object *ob, 
+                                                  DerivedMesh *dm,
+                                                  int useRenderParams,
+                                                  int isFinalCalc)
+{
+       int i;
+       DerivedMesh *result;
+       SolidifyModifierData *smd = (SolidifyModifierData*) md;
+
+       MFace *mf, *mface, *orig_mface;
+       MEdge *ed, *medge, *orig_medge;
+       MVert *mv, *mvert, *orig_mvert;
+
+       int numVerts = dm->getNumVerts(dm);
+       int numEdges = dm->getNumEdges(dm);
+       int numFaces = dm->getNumFaces(dm);
+
+       /* use for edges */
+       int *new_vert_arr= NULL;
+       int newFaces = 0;
+
+       int *new_edge_arr= NULL;
+       int newEdges = 0;
+
+       float (*vert_nors)[3]= NULL;
+
+       orig_mface = dm->getFaceArray(dm);
+       orig_medge = dm->getEdgeArray(dm);
+       orig_mvert = dm->getVertArray(dm);
+
+       if(smd->flag & MOD_SOLIDIFY_RIM) {
+               EdgeHash *edgehash = BLI_edgehash_new();
+               EdgeHashIterator *ehi;
+               int v1, v2;
+               int *edge_users;
+
+               for(i=0, mv=orig_mvert; i<numVerts; i++, mv++) {
+                       mv->flag &= ~ME_VERT_TMP_TAG;
+               }
+
+               for(i=0, ed=orig_medge; i<numEdges; i++, ed++) {
+                       BLI_edgehash_insert(edgehash, ed->v1, ed->v2, (void *)i);
+               }
+
+               edge_users= MEM_callocN(sizeof(int) * numEdges, "solid_mod edges");
+
+/* will be incorrect if an edge happens to have this many face users (very unlikely) */
+#define LARGE_NUM 1000000
+
+               for(i=0, mf=orig_mface; i<numFaces; i++, mf++) {
+                       if(mf->v4) {
+                               edge_users[(int)BLI_edgehash_lookup(edgehash, mf->v1, mf->v2)] += mf->v1 < mf->v2 ? 1:LARGE_NUM;
+                               edge_users[(int)BLI_edgehash_lookup(edgehash, mf->v2, mf->v3)] += mf->v2 < mf->v3 ? 1:LARGE_NUM;
+                               edge_users[(int)BLI_edgehash_lookup(edgehash, mf->v3, mf->v4)] += mf->v3 < mf->v4 ? 1:LARGE_NUM;
+                               edge_users[(int)BLI_edgehash_lookup(edgehash, mf->v4, mf->v1)] += mf->v4 < mf->v1 ? 1:LARGE_NUM;
+                       }
+                       else {
+                               edge_users[(int)BLI_edgehash_lookup(edgehash, mf->v1, mf->v2)] += mf->v1 < mf->v2 ? 1:LARGE_NUM;
+                               edge_users[(int)BLI_edgehash_lookup(edgehash, mf->v2, mf->v3)] += mf->v2 < mf->v3 ? 1:LARGE_NUM;
+                               edge_users[(int)BLI_edgehash_lookup(edgehash, mf->v3, mf->v1)] += mf->v3 < mf->v1 ? 1:LARGE_NUM;
+                       }
+               }
+
+               new_edge_arr= MEM_callocN(sizeof(int) * numEdges, "solid_mod arr");
+
+               ehi= BLI_edgehashIterator_new(edgehash);
+               for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
+                       int eidx= (int)BLI_edgehashIterator_getValue(ehi);
+                       if(edge_users[eidx] == 1 || edge_users[eidx] == LARGE_NUM) {
+                               BLI_edgehashIterator_getKey(ehi, &v1, &v2);
+
+                               /* we need to order the edge */
+                               if(edge_users[eidx] == LARGE_NUM) {
+                                       eidx= -(eidx + 1);
+                               }
+
+                               orig_mvert[v1].flag |= ME_VERT_TMP_TAG;
+                               orig_mvert[v2].flag |= ME_VERT_TMP_TAG;
+                               new_edge_arr[newFaces]= eidx;
+                               newFaces++;
+                       }
+               }
+               BLI_edgehashIterator_free(ehi);
+               MEM_freeN(edge_users);
+
+#undef LARGE_NUM
+
+               new_vert_arr= MEM_callocN(sizeof(int) * numVerts, "solid_mod new_varr");
+               for(i=0, mv=orig_mvert; i<numVerts; i++, mv++) {
+                       if(mv->flag & ME_VERT_TMP_TAG) {
+                               new_vert_arr[newEdges] = i;
+                               newEdges++;
+
+                               mv->flag &= ~ME_VERT_TMP_TAG;
+                       }
+               }
+
+               BLI_edgehash_free(edgehash, NULL);
+       }
+
+       if(smd->flag & MOD_SOLIDIFY_NORMAL_CALC) {
+               vert_nors= MEM_callocN(sizeof(float) * numVerts * 3, "mod_solid_vno_hq");
+               dm_calc_normal(dm, vert_nors);
+       }
+
+       result = CDDM_from_template(dm, numVerts * 2, (numEdges * 2) + newEdges, (numFaces * 2) + newFaces);
+
+       mface = result->getFaceArray(result);
+       medge = result->getEdgeArray(result);
+       mvert = result->getVertArray(result);
+
+       DM_copy_face_data(dm, result, 0, 0, numFaces);
+       DM_copy_face_data(dm, result, 0, numFaces, numFaces);
+
+       DM_copy_edge_data(dm, result, 0, 0, numEdges);
+       DM_copy_edge_data(dm, result, 0, numEdges, numEdges);
+
+       DM_copy_vert_data(dm, result, 0, 0, numVerts);
+       DM_copy_vert_data(dm, result, 0, numVerts, numVerts);
+
+       {
+               static int corner_indices[4] = {2, 1, 0, 3};
+               int is_quad;
+
+               for(i=0, mf=mface+numFaces; i<numFaces; i++, mf++) {
+                       mf->v1 += numVerts;
+                       mf->v2 += numVerts;
+                       mf->v3 += numVerts;
+                       if(mf->v4)
+                               mf->v4 += numVerts;
+
+                       /* Flip face normal */
+                       {
+                               is_quad = mf->v4;
+                               SWAP(int, mf->v1, mf->v3);
+                               DM_swap_face_data(result, i+numFaces, corner_indices);
+                               test_index_face(mf, &result->faceData, numFaces, is_quad ? 4:3);
+                       }
+               }
+       }
+
+       for(i=0, ed=medge+numEdges; i<numEdges; i++, ed++) {
+               ed->v1 += numVerts;
+               ed->v2 += numVerts;
+       }
+
+       if((smd->flag & MOD_SOLIDIFY_EVEN) == 0) {
+               /* no even thickness, very simple */
+               float scalar_short = smd->offset / 32767.0f;
+
+               if(smd->offset < 0.0f)  mv= mvert+numVerts;
+               else                                    mv= mvert;
+
+               for(i=0; i<numVerts; i++, mv++) {
+                       mv->co[0] += mv->no[0] * scalar_short;
+                       mv->co[1] += mv->no[1] * scalar_short;
+                       mv->co[2] += mv->no[2] * scalar_short;
+               }
+       }
+       else {
+               /* make a face normal layer if not present */
+               float (*face_nors)[3];
+               int face_nors_calc= 0;
+
+               /* same as EM_solidify() in editmesh_lib.c */
+               float *vert_angles= MEM_callocN(sizeof(float) * numVerts * 2, "mod_solid_pair"); /* 2 in 1 */
+               float *vert_accum= vert_angles + numVerts;
+               float face_angles[4];
+               int i, j, vidx;
+
+               face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL);
+               if(!face_nors) {
+                       face_nors = CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_CALLOC, NULL, dm->numFaceData);
+                       face_nors_calc= 1;
+               }
+
+               if(vert_nors==NULL) {
+                       vert_nors= MEM_mallocN(sizeof(float) * numVerts * 3, "mod_solid_vno");
+                       for(i=0, mv=mvert; i<numVerts; i++, mv++) {
+                               normal_short_to_float_v3(vert_nors[i], mv->no);
+                       }
+               }
+
+               for(i=0, mf=mface; i<numFaces; i++, mf++) {
+
+                       /* just added, calc the normal */
+                       if(face_nors_calc) {
+                               if(mf->v4)
+                                       normal_quad_v3(face_nors[i], mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co);
+                               else
+                                       normal_tri_v3(face_nors[i] , mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co);
+                       }
+
+                       if(mf->v4) {
+                               angle_quad_v3(face_angles, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co);
+                               j= 3;
+                       }
+                       else {
+                               angle_tri_v3(face_angles, mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co);
+                               j= 2;
+                       }
+
+                       for(; j>=0; j--) {
+                               vidx = *(&mf->v1 + j);
+                               vert_accum[vidx] += face_angles[j];
+                               vert_angles[vidx]+= shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * face_angles[j];
+                       }
+               }
+
+               if(smd->offset < 0.0f)  mv= mvert+numVerts;
+               else                                    mv= mvert;
+
+               for(i=0; i<numVerts; i++, mv++) {
+                       if(vert_accum[i]) { /* zero if unselected */
+                               madd_v3_v3fl(mv->co, vert_nors[i], smd->offset * (vert_angles[i] / vert_accum[i]));
+                       }
+               }
+
+               MEM_freeN(vert_angles);
+       }
+
+       if(vert_nors)
+               MEM_freeN(vert_nors);
+
+       if(smd->flag & MOD_SOLIDIFY_RIM) {
+               /* add faces & edges */
+               ed= medge + (numEdges * 2);
+               for(i=0; i<newEdges; i++, ed++) {
+                       ed->v1= new_vert_arr[i];
+                       ed->v2= new_vert_arr[i] + numVerts;
+                       ed->flag |= ME_EDGEDRAW;
+
+                       if(smd->crease_rim)
+                               ed->crease= smd->crease_rim * 255.0f;
+               }
+
+               /* faces */
+               mf= mface + (numFaces * 2);
+               for(i=0; i<newFaces; i++, mf++) {
+                       /* TODO, get UV's and VCols from the faces we're extruded from */
+                       int eidx= new_edge_arr[i];
+                       int flip;
+
+                       if(eidx < 0) {
+                               eidx= (-eidx) -1;
+                               flip= 1;
+                       }
+                       else {
+                               flip= 0;
+                       }
+
+                       ed= medge + eidx;
+
+                       if(flip) {
+                               mf->v1= ed->v1;
+                               mf->v2= ed->v2;
+                               mf->v3= ed->v2 + numVerts;
+                               mf->v4= ed->v1 + numVerts;
+                       }
+                       else {
+                               mf->v1= ed->v2;
+                               mf->v2= ed->v1;
+                               mf->v3= ed->v1 + numVerts;
+                               mf->v4= ed->v2 + numVerts;
+                       }
+
+                       if(smd->crease_outer > 0.0f)
+                               ed->crease= smd->crease_outer * 255.0f;
+
+                       if(smd->crease_inner > 0.0f) {
+                               ed= medge + (numEdges + eidx);
+                               ed->crease= smd->crease_inner * 255.0f;
+                       }
+               }
+
+               MEM_freeN(new_vert_arr);
+               MEM_freeN(new_edge_arr);
+       }
+
+       return result;
+}
+
+static DerivedMesh *solidifyModifier_applyModifierEM(ModifierData *md,
+                                                    Object *ob,
+                                                    EditMesh *editData,
+                                                    DerivedMesh *derivedData)
+{
+       return solidifyModifier_applyModifier(md, ob, derivedData, 0, 1);
+}
+
 /* Smoke */
 
 static void smokeModifier_initData(ModifierData *md) 
@@ -8788,6 +9214,16 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
                mti->deformVertsEM = shapekeyModifier_deformVertsEM;
                mti->deformMatricesEM = shapekeyModifier_deformMatricesEM;
 
+               mti = INIT_TYPE(Solidify);
+               mti->type = eModifierTypeType_Constructive;
+               mti->flags = eModifierTypeFlag_AcceptsMesh
+                               //| eModifierTypeFlag_SupportsMapping
+                               | eModifierTypeFlag_SupportsEditmode
+                               | eModifierTypeFlag_EnableInEditmode;
+               mti->initData = solidifyModifier_initData;
+               mti->copyData = solidifyModifier_copyData;
+               mti->applyModifier = solidifyModifier_applyModifier;
+               mti->applyModifierEM = solidifyModifier_applyModifierEM;
                typeArrInit = 0;
 #undef INIT_TYPE
        }
index 452444079097cd54f3767c2cfe81fdb90546f2db..1b90dbc3902ae40ac0b5de0eeb15bb6ef893735b 100644 (file)
@@ -2409,7 +2409,7 @@ void EM_solidify(EditMesh *em, float dist)
        EditFace *efa;
        EditVert *eve;
        float *vert_angles= MEM_callocN(sizeof(float) * em->totvert * 2, "EM_solidify"); /* 2 in 1 */
-       float *vert_accum= vert_accum= vert_angles + em->totvert;
+       float *vert_accum= vert_angles + em->totvert;
        float face_angles[4];
        int i, j;
 
index 48e361afdaeb047cf7bf54ed2a825d140e23f899..ca5093ec09da6fb4b7457693db945d500ae7e6af 100644 (file)
@@ -183,7 +183,7 @@ typedef struct PartialVisibility {
 
 /* mvert->flag (1=SELECT) */
 #define ME_SPHERETEST          2
-#define ME_SPHERETEMP          4
+#define ME_VERT_TMP_TAG                4
 #define ME_HIDE                                16
 #define ME_VERT_MERGED         (1<<6)
 #define ME_VERT_PBVH_UPDATE    (1<<7)
index c599c8a7e0f3bf46351cc7dd33eb35f89d00dc5e..2491e58f176a823470b727771521ffc81039a292 100644 (file)
@@ -64,6 +64,7 @@ typedef enum ModifierType {
        eModifierType_Surface,
        eModifierType_Smoke,
        eModifierType_ShapeKey,
+       eModifierType_Solidify,
        NUM_MODIFIER_TYPES
 } ModifierType;
 
@@ -675,4 +676,20 @@ typedef struct ShapeKeyModifierData {
        ModifierData modifier;
 } ShapeKeyModifierData;
 
+typedef struct SolidifyModifierData {
+       ModifierData modifier;
+
+       char vgroup[32];                /* name of vertex group to use */
+       float offset;                   /* new surface offset level*/
+       float crease_inner;
+       float crease_outer;
+       float crease_rim;
+       int flag;
+       char pad[4];
+} SolidifyModifierData;
+
+#define MOD_SOLIDIFY_RIM                       (1<<0)
+#define MOD_SOLIDIFY_EVEN                      (1<<1)
+#define MOD_SOLIDIFY_NORMAL_CALC       (1<<2)
+
 #endif
index c3f23e799d5c671265a67f12866a67582afb22c5..96921ba2f48e864d53888fc6616a7462e2b07ba1 100644 (file)
@@ -417,6 +417,7 @@ extern StructRNA RNA_SmokeModifier;
 extern StructRNA RNA_SmoothModifier;
 extern StructRNA RNA_SoftBodyModifier;
 extern StructRNA RNA_SoftBodySettings;
+extern StructRNA RNA_SolidifyModifier;
 extern StructRNA RNA_Sound;
 extern StructRNA RNA_SoundSequence;
 extern StructRNA RNA_Space;
index dcbc2672bcb70f318e6b1cb9d757498cacc88488..c6aef8df407d80379d742e758e7c9186eb24abd1 100644 (file)
@@ -57,6 +57,7 @@ EnumPropertyItem modifier_type_items[] ={
        {eModifierType_Multires, "MULTIRES", ICON_MOD_MULTIRES, "Multiresolution", ""},
        {eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""},
        {eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""},
+       {eModifierType_Solidify, "SOLIDIFY", ICON_MOD_DISPLACE, "Solidify", ""},
        {0, "", 0, "Deform", ""},
        {eModifierType_Armature, "ARMATURE", ICON_MOD_ARMATURE, "Armature", ""},
        {eModifierType_Cast, "CAST", ICON_MOD_CAST, "Cast", ""},
@@ -161,6 +162,8 @@ static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr)
                        return &RNA_SurfaceModifier;
                case eModifierType_Smoke:
                        return &RNA_SmokeModifier;
+               case eModifierType_Solidify:
+                       return &RNA_SolidifyModifier;
                default:
                        return &RNA_Modifier;
        }
@@ -322,6 +325,12 @@ static void rna_CastModifier_vgroup_set(PointerRNA *ptr, const char *value)
        rna_object_vgroup_name_set(ptr, value, lmd->defgrp_name, sizeof(lmd->defgrp_name));
 }
 
+static void rna_SolidifyModifier_vgroup_set(PointerRNA *ptr, const char *value)
+{
+       SolidifyModifierData *smd= (SolidifyModifierData*)ptr->data;
+       rna_object_vgroup_name_set(ptr, value, smd->vgroup, sizeof(smd->vgroup));
+}
+
 static void rna_DisplaceModifier_uvlayer_set(PointerRNA *ptr, const char *value)
 {
        DisplaceModifierData *smd= (DisplaceModifierData*)ptr->data;
@@ -2000,6 +2009,67 @@ static void rna_def_modifier_surface(BlenderRNA *brna)
        RNA_def_struct_sdna(srna, "SurfaceModifierData");
        RNA_def_struct_ui_icon(srna, ICON_MOD_PHYSICS);
 }
+
+static void rna_def_modifier_solidify(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+
+       srna= RNA_def_struct(brna, "SolidifyModifier", "Modifier");
+       RNA_def_struct_ui_text(srna, "Solidify Modifier", "Create a solid skin by extruding, compensating for sharp angles.");
+       RNA_def_struct_sdna(srna, "SolidifyModifierData");
+       RNA_def_struct_ui_icon(srna, ICON_MOD_DISPLACE);
+
+       prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "offset");
+       RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
+       RNA_def_property_ui_range(prop, -10, 10, 0.1, 4);
+       RNA_def_property_ui_text(prop, "Thickness", "Thickness of the shell.");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+       prop= RNA_def_property(srna, "edge_crease_inner", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "crease_inner");
+       RNA_def_property_range(prop, 0, 1);
+       RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
+       RNA_def_property_ui_text(prop, "Inner Crease", "Assign a crease to inner edges.");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+       prop= RNA_def_property(srna, "edge_crease_outer", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "crease_outer");
+       RNA_def_property_range(prop, 0, 1);
+       RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
+       RNA_def_property_ui_text(prop, "Outer Crease", "Assign a crease to outer edges.");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+       prop= RNA_def_property(srna, "edge_crease_rim", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "crease_rim");
+       RNA_def_property_range(prop, 0, 1);
+       RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
+       RNA_def_property_ui_text(prop, "Rim Crease", "Assign a crease to the edges making up the rim.");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+       prop= RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
+       RNA_def_property_string_sdna(prop, NULL, "vgroup");
+       RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name.");
+       RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SolidifyModifier_vgroup_set");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+       prop= RNA_def_property(srna, "use_rim", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_RIM);
+       RNA_def_property_ui_text(prop, "Fill Rim", "Create edge loops between the inner and outer surfaces on face edges (slow, disable when not needed)");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+       prop= RNA_def_property(srna, "use_even_offset", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_EVEN);
+       RNA_def_property_ui_text(prop, "Even Thickness", "Maintain thickness by adjusting for sharp corners (slow, disable when not needed)");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+       prop= RNA_def_property(srna, "use_quality_normals", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_NORMAL_CALC);
+       RNA_def_property_ui_text(prop, "High Quality Normals", "Calculate normals which result in more even thickness (slow, disable when not needed)");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
 void RNA_def_modifier(BlenderRNA *brna)
 {
        StructRNA *srna;
@@ -2087,6 +2157,7 @@ void RNA_def_modifier(BlenderRNA *brna)
        rna_def_modifier_multires(brna);
        rna_def_modifier_surface(brna);
        rna_def_modifier_smoke(brna);
+       rna_def_modifier_solidify(brna);
 }
 
 #endif