[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25240] branches/sculpt25: Sculpt Branch:
Brecht Van Lommel
brecht at blender.org
Wed Dec 9 14:37:19 CET 2009
Revision: 25240
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25240
Author: blendix
Date: 2009-12-09 14:37:19 +0100 (Wed, 09 Dec 2009)
Log Message:
-----------
Sculpt Branch:
* Smooth brush works again for multires.
* Optimal Display option for multires modifier, same as subsurf.
Modified Paths:
--------------
branches/sculpt25/release/scripts/ui/properties_data_modifier.py
branches/sculpt25/source/blender/blenkernel/BKE_multires.h
branches/sculpt25/source/blender/blenkernel/intern/CCGSubSurf.c
branches/sculpt25/source/blender/blenkernel/intern/multires.c
branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c
branches/sculpt25/source/blender/blenlib/BLI_pbvh.h
branches/sculpt25/source/blender/blenlib/intern/pbvh.c
branches/sculpt25/source/blender/editors/sculpt_paint/sculpt.c
branches/sculpt25/source/blender/makesdna/DNA_modifier_types.h
branches/sculpt25/source/blender/makesrna/intern/rna_modifier.c
Modified: branches/sculpt25/release/scripts/ui/properties_data_modifier.py
===================================================================
--- branches/sculpt25/release/scripts/ui/properties_data_modifier.py 2009-12-09 12:36:13 UTC (rev 25239)
+++ branches/sculpt25/release/scripts/ui/properties_data_modifier.py 2009-12-09 13:37:19 UTC (rev 25240)
@@ -438,6 +438,7 @@
col.prop(md, "levels", text="Preview")
col.prop(md, "sculpt_levels", text="Sculpt")
col.prop(md, "render_levels", text="Render")
+ col.prop(md, "optimal_display")
if wide_ui:
col = split.column()
@@ -604,7 +605,7 @@
if wide_ui:
col = split.column()
col.label(text="Options:")
- col.prop(md, "optimal_draw", text="Optimal Display")
+ col.prop(md, "optimal_display")
def SURFACE(self, layout, ob, md, wide_ui):
layout.label(text="See Fields panel.")
Modified: branches/sculpt25/source/blender/blenkernel/BKE_multires.h
===================================================================
--- branches/sculpt25/source/blender/blenkernel/BKE_multires.h 2009-12-09 12:36:13 UTC (rev 25239)
+++ branches/sculpt25/source/blender/blenkernel/BKE_multires.h 2009-12-09 13:37:19 UTC (rev 25240)
@@ -27,24 +27,22 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#ifndef BKE_MULTIRES_H
+#define BKE_MULTIRES_H
+
struct DerivedMesh;
struct Mesh;
struct MFace;
+struct Multires;
struct MultiresModifierData;
struct Object;
-typedef struct MultiresSubsurf {
- struct MultiresModifierData *mmd;
- struct Object *ob;
- int local_mmd;
-} MultiresSubsurf;
-
void multires_mark_as_modified(struct Object *ob);
void multires_force_update(struct Object *ob);
-struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, int local_mmd, struct DerivedMesh*,
- struct Object *, int, int);
+struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*,
+ int local_mmd, struct DerivedMesh*, struct Object *, int, int);
struct MultiresModifierData *find_multires_modifier(struct Object *ob);
void multiresModifier_join(struct Object *);
@@ -53,7 +51,11 @@
int updateblock, int simple);
int multiresModifier_reshape(struct MultiresModifierData *mmd, struct Object *dst, struct Object *src);
+void multires_stitch_grids(struct Object *);
+
/* Related to the old multires */
-struct Multires;
void multires_load_old(struct DerivedMesh *, struct Multires *);
void multires_free(struct Multires*);
+
+#endif
+
Modified: branches/sculpt25/source/blender/blenkernel/intern/CCGSubSurf.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/CCGSubSurf.c 2009-12-09 12:36:13 UTC (rev 25239)
+++ branches/sculpt25/source/blender/blenkernel/intern/CCGSubSurf.c 2009-12-09 13:37:19 UTC (rev 25240)
@@ -2228,8 +2228,9 @@
VertDataZero(FACE_getCenterData(f));
for (S=0; S<f->numVerts; S++)
- for (x=0; x<gridSize; x++)
- VertDataZero(FACE_getIECo(f, lvl, S, x));
+ if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
+ for (x=0; x<gridSize; x++)
+ VertDataZero(FACE_getIECo(f, lvl, S, x));
for (S=0; S<f->numVerts; S++) {
int prevS = (S+f->numVerts-1)%f->numVerts;
@@ -2237,18 +2238,23 @@
CCGEdge *prevE = FACE_getEdges(f)[prevS];
VertDataAdd(FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0));
- VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx));
+ if (FACE_getVerts(f)[S]->flags&Vert_eEffected)
+ VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx));
for (x=1; x<gridSize-1; x++) {
- VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0));
- VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x));
+ if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
+ VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0));
+ if (FACE_getEdges(f)[prevS]->flags&Edge_eEffected)
+ VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x));
}
for (x=0; x<gridSize-1; x++) {
int eI = gridSize-1-x;
- VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
- if(x != 0)
- VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
+ if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
+ VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x));
+ if (FACE_getEdges(f)[prevS]->flags&Edge_eEffected)
+ if(x != 0)
+ VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI,vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx));
}
}
}
@@ -2276,8 +2282,9 @@
VertDataMulN(FACE_getCenterData(f), 1.0f/f->numVerts);
for (S=0; S<f->numVerts; S++)
- for (x=1; x<gridSize-1; x++)
- VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f);
+ if (FACE_getEdges(f)[S]->flags&Edge_eEffected)
+ for (x=1; x<gridSize-1; x++)
+ VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f);
for (S=0; S<f->numVerts; S++) {
int prevS = (S+f->numVerts-1)%f->numVerts;
Modified: branches/sculpt25/source/blender/blenkernel/intern/multires.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/multires.c 2009-12-09 12:36:13 UTC (rev 25239)
+++ branches/sculpt25/source/blender/blenkernel/intern/multires.c 2009-12-09 13:37:19 UTC (rev 25240)
@@ -39,6 +39,7 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
+#include "BLI_pbvh.h"
#include "BKE_btex.h"
#include "BKE_cdderivedmesh.h"
@@ -60,8 +61,8 @@
/* MULTIRES MODIFIER */
static const int multires_max_levels = 13;
-static const int multires_grid_tot[] = {1, 4, 9, 25, 81, 289, 1089, 4225, 16641, 66049, 263169, 1050625, 4198401, 16785409};
-static const int multires_side_tot[] = {1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097};
+static const int multires_grid_tot[] = {0, 4, 9, 25, 81, 289, 1089, 4225, 16641, 66049, 263169, 1050625, 4198401, 16785409};
+static const int multires_side_tot[] = {0, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097};
static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int add, DMGridData **oldGridData, int totlvl);
@@ -307,7 +308,7 @@
return multires_dm_create_from_derived(&mmd, 1, dm, ob, 0, 0);
}
-static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple)
+static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal)
{
SubsurfModifierData smd;
@@ -316,6 +317,8 @@
smd.flags |= eSubsurfModifierFlag_SubsurfUv;
if(simple)
smd.subdivType = ME_SIMPLE_SUBSURF;
+ if(optimal)
+ smd.flags |= eSubsurfModifierFlag_ControlEdges;
return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0);
}
@@ -363,7 +366,7 @@
/* create subsurf DM from original mesh at high level */
cddm = CDDM_from_mesh(me, NULL);
- highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple);
+ highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0);
/* create multires DM from original mesh at low level */
lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple);
@@ -551,7 +554,7 @@
/* create subsurf DM from original mesh at high level */
cddm = CDDM_from_mesh(me, NULL);
- highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple);
+ highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0);
/* create multires DM from original mesh and displacements */
lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple);
@@ -602,7 +605,7 @@
DerivedMesh *cddm, *subdm;
cddm = CDDM_from_mesh(me, NULL);
- subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple);
+ subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0);
cddm->release(cddm);
multiresModifier_disp_run(dm, me, 1, 0, subdm->getGridData(subdm), mmd->totlvl);
@@ -629,6 +632,25 @@
}
}
+void multires_stitch_grids(Object *ob)
+{
+ /* utility for smooth brush */
+ if(ob && ob->derivedFinal) {
+ CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)ob->derivedFinal;
+ CCGFace **faces;
+ int totface;
+
+ if(ccgdm->pbvh) {
+ BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void***)&faces, &totface);
+
+ if(totface) {
+ ccgSubSurf_stitchFaces(ccgdm->ss, 0, faces, totface);
+ MEM_freeN(faces);
+ }
+ }
+ }
+}
+
struct DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int local_mmd, DerivedMesh *dm, Object *ob,
int useRenderParams, int isFinalCalc)
{
@@ -642,7 +664,8 @@
if(lvl == 0)
return dm;
- result = subsurf_dm_create_local(ob, dm, lvl, 0);
+ result = subsurf_dm_create_local(ob, dm, lvl,
+ mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges);
if(!local_mmd) {
ccgdm = (CCGDerivedMesh*)result;
@@ -680,6 +703,36 @@
/**** Old Multires code ****
***************************/
+#if 0
+static void mdisp_copy_grid(float (*new)[3], int newstride, float (*old)[3], int oldstride, int xoff, int yoff, int xsize, int ysize)
+{
+ int x, y;
+
+ for(y = 0; y < ysize; ++y)
+ for(x = 0; x < xsize; ++x)
+ copy_v3_v3(disps[x + y*side], mdisp->disps[(x + xoffs) + (y + yoffs)*oldside]);
+
+}
+
+static void mdisps_convert(MFace *mface, MDisps *mdisp, int lvl)
+{
+ int side = multires_side_tot[lvl];
+ int nvert = (mface->v4)? 4: 3;
+ int totdisp = multires_grid_tot[lvl]*nvert;
+ int x, y;
+ float (*disps)[3];
+
+ disps = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disps");
+
+
+
+static const int multires_max_levels = 13;
+static const int multires_grid_tot[] = {1, 4, 9, 25, 81, 289, 1089, 4225, 16641, 66049, 263169, 1050625, 4198401, 16785409};
+static const int multires_side_tot[] = {1, 2, 3, 5, 9, 17, 33, 65, 129, 257, 513, 1025, 2049, 4097};
+
+}
+#endif
+
/* Does not actually free lvl itself */
static void multires_free_level(MultiresLevel *lvl)
{
Modified: branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/sculpt25/source/blender/blenkernel/intern/subsurf_ccg.c 2009-12-09 12:36:13 UTC (rev 25239)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list