[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43616] branches/bmesh/blender: Merged with trunk (-r43609:43611): updated modifier preview.
Bastien Montagne
montagne29 at wanadoo.fr
Sun Jan 22 21:05:32 CET 2012
Revision: 43616
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43616
Author: mont29
Date: 2012-01-22 20:05:26 +0000 (Sun, 22 Jan 2012)
Log Message:
-----------
Merged with trunk (-r43609:43611): updated modifier preview.
Noted preview code for DynamicPaint is currently disabled, will see if I can re-enable it?\226?\128?\166
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43609
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/BKE_DerivedMesh.h
branches/bmesh/blender/source/blender/blenkernel/BKE_modifier.h
branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/dynamicpaint.c
branches/bmesh/blender/source/blender/blenkernel/intern/modifier.c
branches/bmesh/blender/source/blender/editors/space_view3d/drawmesh.c
branches/bmesh/blender/source/blender/editors/space_view3d/drawobject.c
branches/bmesh/blender/source/blender/editors/space_view3d/view3d_intern.h
branches/bmesh/blender/source/blender/makesdna/DNA_dynamicpaint_types.h
branches/bmesh/blender/source/blender/modifiers/intern/MOD_dynamicpaint.c
branches/bmesh/blender/source/blender/modifiers/intern/MOD_weightvgedit.c
branches/bmesh/blender/source/blender/modifiers/intern/MOD_weightvgmix.c
branches/bmesh/blender/source/blender/modifiers/intern/MOD_weightvgproximity.c
Property Changed:
----------------
branches/bmesh/blender/
branches/bmesh/blender/release/
branches/bmesh/blender/source/blender/editors/space_outliner/
Property changes on: branches/bmesh/blender
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801
/trunk/blender:39992-43609
+ /branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801
/trunk/blender:39992-43611
Property changes on: branches/bmesh/blender/release
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/blender/release:31524-42516,42522-42548,42551-42585,42587-42655,42681-42757,42779-42870,42921-42927,42954-42957,42974-43085,43093-43278,43295-43435,43462-43554,43565-43609
+ /trunk/blender/release:31524-42516,42522-42548,42551-42585,42587-42655,42681-42757,42779-42870,42921-42927,42954-42957,42974-43085,43093-43278,43295-43435,43462-43554,43565-43611
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_DerivedMesh.h 2012-01-22 20:01:33 UTC (rev 43615)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_DerivedMesh.h 2012-01-22 20:05:26 UTC (rev 43616)
@@ -627,6 +627,15 @@
float (**deformmats)[3][3], float (**deformcos)[3]);
void weight_to_rgb(float r_rgb[3], const float weight);
+/* Update the weight MCOL preview layer.
+ * If weights are NULL, use object's active vgroup(s).
+ * Else, weights must be an array of weight float values.
+ * If indices is NULL, it must be of numVerts length.
+ * Else, it must be of num length, as indices, which contains vertices' idx to apply weights to.
+ * (other vertices are assumed zero weight).
+ */
+void DM_update_weight_mcol(struct Object *ob, struct DerivedMesh *dm, int const draw_flag,
+ float *weights, int num, const int *indices);
/* convert layers requested by a GLSL material to actually available layers in
* the DerivedMesh, with both a pointer for arrays and an offset for editmesh */
Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_modifier.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_modifier.h 2012-01-22 20:01:33 UTC (rev 43615)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_modifier.h 2012-01-22 20:05:26 UTC (rev 43616)
@@ -100,7 +100,10 @@
eModifierTypeFlag_Single = (1<<7),
/* Some modifier can't be added manually by user */
- eModifierTypeFlag_NoUserAdd = (1<<8)
+ eModifierTypeFlag_NoUserAdd = (1<<8),
+
+ /* For modifiers that use CD_WEIGHT_MCOL for preview. */
+ eModifierTypeFlag_UsesPreview = (1<<9)
} ModifierTypeFlag;
typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object **obpoin);
@@ -324,6 +327,7 @@
__attribute__ ((format (printf, 2, 3)))
#endif
;
+int modifier_isPreview(struct ModifierData *md);
void modifiers_foreachObjectLink(struct Object *ob,
ObjectWalkFunc walk,
@@ -350,6 +354,7 @@
int modifiers_usesArmature(struct Object *ob, struct bArmature *arm);
int modifiers_isCorrectableDeformed(struct Object *ob);
void modifier_freeTemporaryData(struct ModifierData *md);
+int modifiers_isPreview(struct Object *ob);
int modifiers_indexInObject(struct Object *ob, struct ModifierData *md);
@@ -363,6 +368,9 @@
struct ModifierData *md,
CustomDataMask dataMask,
int required_mode);
+struct ModifierData *modifiers_getLastPreview(struct Scene *scene,
+ struct ModifierData *md,
+ int required_mode);
struct ModifierData *modifiers_getVirtualModifierList(struct Object *ob);
/* ensure modifier correctness when changing ob->data */
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2012-01-22 20:01:33 UTC (rev 43615)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2012-01-22 20:05:26 UTC (rev 43616)
@@ -986,24 +986,23 @@
* note that we could save some memory and allocate RGB only but then we'd need to
* re-arrange the colors when copying to the face since MCol has odd ordering,
* so leave this as is - campbell */
-static unsigned char *calc_weightpaint_vert_array(Object *ob, int const draw_flag, ColorBand *coba)
+static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, ColorBand *coba)
{
- Mesh *me = ob->data;
- unsigned char *wtcol_v = MEM_mallocN (sizeof(unsigned char) * me->totvert * 4, "weightmap_v");
+ MDeformVert *dv = DM_get_vert_data_layer(dm, CD_MDEFORMVERT);
+ int numVerts = dm->getNumVerts(dm);
+ unsigned char *wtcol_v = MEM_mallocN (sizeof(unsigned char) * numVerts * 4, "weightmap_v");
- if (me->dvert) {
+ if (dv) {
unsigned char *wc = wtcol_v;
- MDeformVert *dv= me->dvert;
unsigned int i;
- /* varisbles for multipaint */
+ /* variables for multipaint */
const int defbase_tot = BLI_countlist(&ob->defbase);
const int defbase_act = ob->actdef-1;
char *dg_flags = MEM_mallocN(defbase_tot * sizeof(char), __func__);
const int selected = get_selected_defgroups(ob, dg_flags, defbase_tot);
- /* const int unselected = defbase_tot - selected; */ /* UNUSED */
- for (i = me->totvert; i != 0; i--, wc += 4, dv++) {
+ for (i = numVerts; i != 0; i--, wc += 4, dv++) {
calc_weightpaint_vert_color(wc, dv, coba, defbase_tot, defbase_act, dg_flags, selected, draw_flag);
}
@@ -1012,69 +1011,128 @@
else {
int col_i;
weightpaint_color((unsigned char *)&col_i, coba, 0.0f);
- fill_vn_i((int *)wtcol_v, me->totvert, col_i);
+ fill_vn_i((int *)wtcol_v, numVerts, col_i);
}
return wtcol_v;
}
-static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm, int const draw_flag)
+/* return an array of vertex weight colors from given weights, caller must free.
+ *
+ * note that we could save some memory and allocate RGB only but then we'd need to
+ * re-arrange the colors when copying to the face since MCol has odd ordering,
+ * so leave this as is - campbell */
+static unsigned char *calc_colors_from_weights_array(const int num, float *weights)
{
+ unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * num * 4, "weightmap_v");
+ unsigned char *wc = wtcol_v;
+ int i;
+
+ for (i = 0; i < num; i++, wc += 4, weights++)
+ weightpaint_color((unsigned char *) wc, NULL, *weights);
+
+ return wtcol_v;
+}
+
+void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
+ float *weights, int num, const int *indices)
+{
ColorBand *coba= stored_cb; /* warning, not a local var */
- unsigned char *wtcol_v = calc_weightpaint_vert_array(ob, draw_flag, coba);
- unsigned char *wtcol_f;
- unsigned char(*wtcol_l)[4] = NULL;
- BLI_array_declare(wtcol_l);
+
+ unsigned char *wtcol_v;
+ unsigned char *wtcol_f = dm->getTessFaceDataArray(dm, CD_WEIGHT_MCOL);
+ unsigned char(*wtcol_l)[4] = CustomData_get_layer(dm->getLoopDataLayout(dm), CD_WEIGHT_MLOOPCOL);
MFace *mf = dm->getTessFaceArray(dm);
MLoop *mloop = dm->getLoopArray(dm), *ml;
MPoly *mp = dm->getPolyArray(dm);
- int i, j, totface=dm->getNumTessFaces(dm), totloop;
- int *origIndex = dm->getVertDataArray(dm, CD_ORIGINDEX);
- unsigned char *wtcol_f_step;
+ int numFaces = dm->getNumTessFaces(dm);
+ int numVerts = dm->getNumVerts(dm);
+ int totloop;
+ int i, j;
- wtcol_f = MEM_mallocN(sizeof (unsigned char) * totface*4*4, "weightmap_f");
- wtcol_f_step = wtcol_f;
+ /* If no CD_WEIGHT_MCOL existed yet, add a new one! */
+ if (!wtcol_f)
+ wtcol_f = CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numFaces);
- /*first add colors to the tesselation faces*/
- for (i=0; i<totface; i++, mf++, wtcol_f_step += (4 * 4)) {
- /*origindex being NULL means we're operating on original mesh data*/
+ if (wtcol_f) {
+ unsigned char *wtcol_f_step = wtcol_f;
+
+ /* Weights are given by caller. */
+ if (weights) {
+ float *w = weights;
+ /* If indices is not NULL, it means we do not have weights for all vertices,
+ * so we must create them (and set them to zero)... */
+ if(indices) {
+ w = MEM_callocN(sizeof(float)*numVerts, "Temp weight array DM_update_weight_mcol");
+ i = num;
+ while(i--)
+ w[indices[i]] = weights[i];
+ }
+
+ /* Convert float weights to colors. */
+ wtcol_v = calc_colors_from_weights_array(numVerts, w);
+
+ if(indices)
+ MEM_freeN(w);
+ }
+
+ /* No weights given, take them from active vgroup(s). */
+ else
+ wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, coba);
+
+ /* Now copy colors in all face verts. */
+ /*first add colors to the tesselation faces*/
+ for (i = 0; i < numFaces; i++, mf++, wtcol_f_step += (4 * 4)) {
+ /*origindex being NULL means we're operating on original mesh data*/
#if 0
- unsigned int fidx= mf->v4 ? 3:2;
+ unsigned int fidx= mf->v4 ? 3:2;
#else /* better zero out triangles 4th component. else valgrind complains when the buffer's copied */
- unsigned int fidx;
- if (mf->v4) {
- fidx = 3;
- }
- else {
- fidx = 2;
- *(int *)(&wtcol_f_step[3 * 4]) = 0;
- }
+ unsigned int fidx;
+ if (mf->v4) {
+ fidx = 3;
+ }
+ else {
+ fidx = 2;
+ *(int *)(&wtcol_f_step[3 * 4]) = 0;
+ }
#endif
- do {
- copy_v4_v4_char((char *)&wtcol_f_step[fidx * 4],
- (char *)&wtcol_v[4 * (*(&mf->v1 + fidx))]);
- } while (fidx--);
- }
+ do {
+ copy_v4_v4_char((char *)&wtcol_f_step[fidx * 4],
+ (char *)&wtcol_v[4 * (*(&mf->v1 + fidx))]);
+ } while (fidx--);
+ }
- CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol_f, totface);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list