Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2012-01-23 20:32:11 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-01-23 20:32:11 +0400
commit6c9438ea8a34054c66690a8c5d49162d0fd9379a (patch)
treef3ab2569a90ebeeebcf8527a5aebe5f51f6c360b
parent76f03a2ee4f80b5158ffc92f7a85c4401affe6a4 (diff)
BMesh: Fix (re-enable) DynamicPaint previews in Object mode.
Also simplifies DM_update_weight_mcol: no need to update CD_WEIGHT_MCOL here, as it is anyway recreated from CD_WEIGHT_MLOOPCOL at tesselation time. Only commented out code for now.
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c23
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c8
-rw-r--r--source/blender/editors/space_view3d/drawobject.c2
3 files changed, 23 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 67a4d6657c9..509cb40f014 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1040,9 +1040,13 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
ColorBand *coba= stored_cb; /* warning, not a local var */
unsigned char *wtcol_v;
+#if 0 /* See coment below. */
unsigned char *wtcol_f = dm->getTessFaceDataArray(dm, CD_WEIGHT_MCOL);
+#endif
unsigned char(*wtcol_l)[4] = CustomData_get_layer(dm->getLoopDataLayout(dm), CD_WEIGHT_MLOOPCOL);
+#if 0 /* See coment below. */
MFace *mf = dm->getTessFaceArray(dm);
+#endif
MLoop *mloop = dm->getLoopArray(dm), *ml;
MPoly *mp = dm->getPolyArray(dm);
int numFaces = dm->getNumTessFaces(dm);
@@ -1050,12 +1054,21 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
int totloop;
int i, j;
+#if 0 /* See comment below */
/* 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);
if (wtcol_f) {
unsigned char *wtcol_f_step = wtcol_f;
+# else
+ /* XXX Seems we still need to create a CD_WEIGHT_MCOL, else it sigsev...
+ * Strange that we do not have that problem with DPaint VCol preview? */
+ if(!dm->getTessFaceDataArray(dm, CD_WEIGHT_MCOL))
+ CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numFaces);
+
+ {
+#endif
/* Weights are given by caller. */
if (weights) {
@@ -1082,6 +1095,10 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
/* Now copy colors in all face verts. */
/*first add colors to the tesselation faces*/
+ /* XXX Why update that layer? We have to update WEIGHT_MLOOPCOL anyway,
+ * and tesselation recreates mface layers from mloop/mpoly ones, so no
+ * need to fill WEIGHT_MCOL here. */
+#if 0
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
@@ -1103,7 +1120,7 @@ void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag,
(char *)&wtcol_v[4 * (*(&mf->v1 + fidx))]);
} while (fidx--);
}
-
+#endif
/*now add to loops, so the data can be passed through the modifier stack*/
/* If no CD_WEIGHT_MLOOPCOL existed yet, we have to add a new one! */
if (!wtcol_l) {
@@ -1470,10 +1487,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
range_vn_i(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0);
range_vn_i(DM_get_poly_data_layer(dm, CD_ORIGINDEX), dm->numPolyData, 0);
}
-
-/* if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT))*/
-/* add_weight_mcol_dm(ob, dm, draw_flag);*/
-
}
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 0a3e928c2f6..9e30003f9c7 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1604,14 +1604,14 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
}
/* viewport preview */
- if (0 && surface->flags & MOD_DPAINT_PREVIEW) {
+ if (surface->flags & MOD_DPAINT_PREVIEW) {
MPoly *mp = CDDM_get_polys(result);
int totpoly = result->numPolyData;
/* Save preview results to weight layer to be
* able to share same drawing methods */
- col = CustomData_get_layer(&dm->loopData, CD_WEIGHT_MLOOPCOL);
- if (!col) col = CustomData_add_layer(&dm->loopData, CD_WEIGHT_MLOOPCOL, CD_CALLOC, NULL, totloop);
+ col = CustomData_get_layer(&result->loopData, CD_WEIGHT_MLOOPCOL);
+ if (!col) col = CustomData_add_layer(&result->loopData, CD_WEIGHT_MLOOPCOL, CD_CALLOC, NULL, totloop);
if (col) {
#pragma omp parallel for schedule(static)
@@ -1703,7 +1703,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData
float *weight = (float*)sData->type_data;
/* viewport preview */
- if (0 && surface->flags & MOD_DPAINT_PREVIEW) {
+ if (surface->flags & MOD_DPAINT_PREVIEW) {
/* Save preview results to weight layer to be
* able to share same drawing methods */
DM_update_weight_mcol(ob, result, 0, weight, 0, NULL);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index bcfa57a2687..d4b496e45b7 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -3158,7 +3158,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
/* Check to draw dynamic paint colors (or weights from WeightVG modifiers).
* Note: Last "preview-active" modifier in stack will win! */
- if(DM_get_poly_data_layer(dm, CD_WEIGHT_MCOL) && modifiers_isPreview(ob))
+ if(DM_get_tessface_data_layer(dm, CD_WEIGHT_MCOL) && modifiers_isPreview(ob))
draw_flags |= DRAW_MODIFIERS_PREVIEW;
/* Unwanted combination */