[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39289] branches/soc-2011-onion/source/ blender: Revision: 30906
Jason Wilkins
Jason.A.Wilkins at gmail.com
Thu Aug 11 07:41:48 CEST 2011
Revision: 39289
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39289
Author: jwilkins
Date: 2011-08-11 05:41:47 +0000 (Thu, 11 Aug 2011)
Log Message:
-----------
Revision: 30906
Author: nicholasbishop
Date: 10:20:07 AM, Friday, July 30, 2010
Message:
== Paint ==
* Refactored paint mask undo to support any customdata type
* Automatically make layer multires when adding vcols to a multires mesh in vpaint mode
* Fixed vcol multires toggle so that it updates the dm
TODO:
* Add paint undo for vcol layers
----
Modified : /branches/soc-2010-nicolasbishop/source/blender/blenkernel/BKE_customdata.h
Modified : /branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/customdata.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/multires.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/include/ED_sculpt.h
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/mesh/mesh_data.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_mask.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_undo.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_utils.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/pbvh_undo.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
--
jwilkins:
vertex paint undo is still broken, but I'm pressing ahead since it has to be something minor
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h
branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c
branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c
branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h
branches/soc-2011-onion/source/blender/editors/mesh/mesh_data.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_mask.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_meshcache.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_undo.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/pbvh_undo.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
Modified: branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h 2011-08-11 05:04:01 UTC (rev 39288)
+++ branches/soc-2011-onion/source/blender/blenkernel/BKE_customdata.h 2011-08-11 05:41:47 UTC (rev 39289)
@@ -244,8 +244,6 @@
int CustomData_get_clone_layer(const struct CustomData *data, int type);
int CustomData_get_stencil_layer(const struct CustomData *data, int type);
-char *CustomData_get_layer_name_at_offset(const struct CustomData *data, int type, int offset);
-
/* copies the data from source to the data element at index in the first
* layer of type
* no effect if there is no layer of type
@@ -341,18 +339,23 @@
/* if layer matching type and name exists, free and replace its griddata
otherwise create the layer and set its griddata */
-void CustomData_multires_assign_data(struct CustomDataMultires *cdm, int type,
- char *name, float *data);
+void CustomData_multires_sync_layer(struct CustomDataMultires *cdm, int type,
+ char *name);
-/* insert a multires layer of the specified type */
-void CustomData_multires_add_layer(struct CustomDataMultires *cdm, int type,
- char *name, float *data);
+/* insert a multires layer of the specified type and assign griddata */
+void CustomData_multires_add_layer_data(struct CustomDataMultires *cdm, int type,
+ char *name, float *griddata);
-/* remove the multires layer with matching source name
- returns 1 if succesful, 0 otherwise */
-int CustomData_multires_remove_layer(struct CustomDataMultires *cdm, int type,
- char *name);
+/* insert a multires layer of the specified type int each
+ cdm in the array of length count */
+void CustomData_multires_add_layers(struct CustomDataMultires *cdm, int count,
+ int type, char *name);
+/* remove the multires layer with matching source name from the cdm
+ array of length count, returns 1 if succesful, 0 otherwise */
+int CustomData_multires_remove_layers(struct CustomDataMultires *cdm, int count,
+ int type, char *name);
+
/* rename a layer matching type and old_name */
void CustomData_multires_rename(struct CustomDataMultires *cdm, int type,
char *old_name, char *name);
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c 2011-08-11 05:04:01 UTC (rev 39288)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/customdata.c 2011-08-11 05:41:47 UTC (rev 39289)
@@ -2573,24 +2573,32 @@
return cdm->layers[layer].griddata;
}
-void CustomData_multires_assign_data(CustomDataMultires *cdm, int type,
- char *name, float *data)
+static float *customdata_multires_alloc_griddata(int type, int totelem)
{
+ return MEM_callocN(sizeof(float) * totelem *
+ CustomData_multires_type_totfloat(type),
+ "CustomDataMultiresLayer.griddata");
+}
+
+void CustomData_multires_sync_layer(CustomDataMultires *cdm, int type,
+ char *name)
+{
int layer;
layer = customdata_multires_find_named_layer_index(cdm, type, name);
if(layer == -1)
- CustomData_multires_add_layer(cdm, type, name, data);
+ CustomData_multires_add_layer_data(cdm, type, name, NULL);
else {
if(cdm->layers[layer].griddata)
MEM_freeN(cdm->layers[layer].griddata);
- cdm->layers[layer].griddata = data;
+ cdm->layers[layer].griddata =
+ customdata_multires_alloc_griddata(type, cdm->totelem);
}
}
-void CustomData_multires_add_layer(CustomDataMultires *cdm, int type,
- char *name, float *data)
+void CustomData_multires_add_layer_data(CustomDataMultires *cdm, int type,
+ char *name, float *griddata)
{
CustomDataMultiresLayer *old = cdm->layers;
int first, layer, i;
@@ -2608,11 +2616,17 @@
else
layer = first;
+ /* create griddata if none given */
+ if(!griddata) {
+ griddata =
+ customdata_multires_alloc_griddata(type, cdm->totelem);
+ }
+
for(i = 0; i <= cdm->totlayer; ++i) {
if(i < layer)
cdm->layers[i] = old[i];
else if(i == layer) {
- cdm->layers[i].griddata = data;
+ cdm->layers[i].griddata = griddata;
cdm->layers[i].type = type;
BLI_strncpy(cdm->layers[i].name, name,
sizeof(cdm->layers[i].name));
@@ -2625,9 +2639,21 @@
if(old) MEM_freeN(old);
}
-int CustomData_multires_remove_layer(CustomDataMultires *cdm, int type,
- char *name)
+void CustomData_multires_add_layers(CustomDataMultires *cdm, int count,
+ int type, char *name)
{
+ int i;
+
+ if(!cdm)
+ return;
+
+ for(i = 0; i < count; ++i, ++cdm)
+ CustomData_multires_add_layer_data(cdm, type, name, NULL);
+}
+
+static int CustomData_multires_layer_delete(CustomDataMultires *cdm, int type,
+ char *name)
+{
CustomDataMultiresLayer *old = cdm->layers;
int layer, i;
@@ -2656,6 +2682,22 @@
return 1;
}
+int CustomData_multires_remove_layers(CustomDataMultires *cdm, int count,
+ int type, char *name)
+{
+ int i;
+
+ if(!cdm)
+ return 0;
+
+ for(i = 0; i < count; ++i, ++cdm) {
+ if(!CustomData_multires_layer_delete(cdm, type, name))
+ return 0;
+ }
+
+ return 1;
+}
+
void CustomData_multires_rename(CustomDataMultires *cdm, int type,
char *old_name, char *name)
{
Modified: branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c 2011-08-11 05:04:01 UTC (rev 39288)
+++ branches/soc-2011-onion/source/blender/blenkernel/intern/multires.c 2011-08-11 05:41:47 UTC (rev 39289)
@@ -323,20 +323,6 @@
}
}
-static void multires_sync_customdata_layer(CustomDataMultires *cdm,
- char *name, int type, int totelem)
-{
- float *griddata;
- int totfloat;
-
- totfloat = CustomData_multires_type_totfloat(type);
-
- griddata = MEM_callocN(sizeof(float) * totfloat * totelem,
- "sync layer griddata");
-
- CustomData_multires_assign_data(cdm, type, name, griddata);
-}
-
/* ensure all the layers needed by the gridkey have
a matching multires layer
@@ -357,19 +343,19 @@
int nvert = (me->mface[i].v4)? 4: 3;
int totelem = multires_grid_tot[lvl]*nvert;
+ cd_grids[i].totelem = totelem;
+
for(j = 0; j < gridkey->color; ++j) {
- multires_sync_customdata_layer(cd_grids+i,
- gridkey->color_names[j],
- CD_MCOL, totelem);
+ CustomData_multires_sync_layer(cd_grids+i,
+ CD_MCOL,
+ gridkey->color_names[j]);
}
for(j = 0; j < gridkey->mask; ++j) {
- multires_sync_customdata_layer(cd_grids+i,
- gridkey->mask_names[j],
- CD_PAINTMASK, totelem);
+ CustomData_multires_sync_layer(cd_grids+i,
+ CD_PAINTMASK,
+ gridkey->mask_names[j]);
}
-
- cd_grids[i].totelem = totelem;
}
}
Modified: branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h 2011-08-11 05:04:01 UTC (rev 39288)
+++ branches/soc-2011-onion/source/blender/editors/include/ED_sculpt.h 2011-08-11 05:41:47 UTC (rev 39289)
@@ -32,14 +32,6 @@
#ifndef ED_SCULPT_H
#define ED_SCULPT_H
-struct ARegion;
-struct bContext;
-struct Object;
-struct RegionView3D;
-struct wmKeyConfig;
-struct wmWindowManager;
-struct ViewContext;
-
/* sculpt.c */
void ED_operatortypes_sculpt(void);
@@ -70,4 +62,17 @@
float *ED_paint_get_last_stroke(struct Object *ob);
+struct PaintLayerUndoNode *paint_layer_undo_push(int type, char *description);
+void paint_layer_undo_set_add(struct PaintLayerUndoNode *unode, char *name);
+
+void paint_layer_undo_set_remove(
+ struct PaintLayerUndoNode *unode,
+ char *name,
+ struct CustomData *data,
+ struct CustomData *fdata,
+ int totvert,
+ int totface);
+
+struct MultiresModifierData *ED_paint_mesh_get_active_multires(const struct bContext *C);
+
#endif
Modified: branches/soc-2011-onion/source/blender/editors/mesh/mesh_data.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/mesh/mesh_data.c 2011-08-11 05:04:01 UTC (rev 39288)
+++ branches/soc-2011-onion/source/blender/editors/mesh/mesh_data.c 2011-08-11 05:41:47 UTC (rev 39289)
@@ -55,6 +55,7 @@
#include "BKE_library.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
+#include "BKE_multires.h"
#include "BKE_report.h"
#include "RNA_access.h"
@@ -65,6 +66,7 @@
#include "ED_mesh.h"
#include "ED_object.h"
+#include "ED_sculpt.h"
#include "ED_uvedit.h"
#include "ED_view3d.h"
@@ -445,6 +447,37 @@
/*********************** vertex color operators ************************/
+static int vertex_color_multires_toggle(Object *ob)
+{
+ Mesh *me= ob->data;
+ CustomDataMultires *cdm;
+ CustomDataLayer *cdl;
+ int active;
+
+ /* so that dm is recalculated correctly after */
+ multires_force_update(ob);
+
+ active = CustomData_get_active_layer_index(&me->fdata, CD_MCOL);
+ cdm = CustomData_get_layer(&me->fdata, CD_GRIDS);
+
+ if(active == -1)
+ return 1;
+
+ cdl = &me->fdata.layers[active];
+
+ if(cdm) {
+ if(cdl->flag & CD_FLAG_MULTIRES)
+ CustomData_multires_remove_layers(cdm, me->totface, CD_MCOL, cdl->name);
+ else
+ CustomData_multires_add_layers(cdm, me->totface, CD_MCOL, cdl->name);
+ }
+
+ /* note - if there's no griddata, it can still be synced up later */
+ cdl->flag ^= CD_FLAG_MULTIRES;
+
+ return 1;
+}
+
static int vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
@@ -454,6 +487,12 @@
if(!ED_mesh_color_add(C, scene, ob, me, NULL, TRUE))
return OPERATOR_CANCELLED;
+ if ((ob->mode & OB_MODE_VERTEX_PAINT) &&
+ ED_paint_mesh_get_active_multires(C))
+ {
+ vertex_color_multires_toggle(ob);
+ }
+
return OPERATOR_FINISHED;
}
@@ -500,42 +539,10 @@
static int vertex_color_multires_toggle_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_active_object(C);
- Mesh *me= ob->data;
- CustomDataMultires *cdm;
- CustomDataLayer *cdl;
- int active, i;
-
- active = CustomData_get_active_layer_index(&me->fdata, CD_MCOL);
- cdm = CustomData_get_layer(&me->fdata, CD_GRIDS);
-
- if(active == -1)
+ if(vertex_color_multires_toggle(CTX_data_active_object(C)))
return OPERATOR_FINISHED;
-
- cdl = &me->fdata.layers[active];
-
- if(cdm) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list