[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21258] branches/soc-2009-yukishiro/source /blender: do undo/redo properly, but there is still a problem for undo the initial compuation in light paint toggle
Jingyuan Huang
jingyuan.huang at gmail.com
Tue Jun 30 06:37:01 CEST 2009
Revision: 21258
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21258
Author: yukishiro
Date: 2009-06-30 06:37:00 +0200 (Tue, 30 Jun 2009)
Log Message:
-----------
do undo/redo properly, but there is still a problem for undo the initial compuation in light paint toggle
Modified Paths:
--------------
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/customdata.c
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/mesh.c
branches/soc-2009-yukishiro/source/blender/blenloader/intern/readfile.c
branches/soc-2009-yukishiro/source/blender/blenloader/intern/writefile.c
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c
branches/soc-2009-yukishiro/source/blender/editors/util/ed_util.c
branches/soc-2009-yukishiro/source/blender/editors/util/undo.c
branches/soc-2009-yukishiro/source/blender/makesdna/DNA_customdata_types.h
branches/soc-2009-yukishiro/source/blender/makesdna/DNA_mesh_types.h
branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/customdata.c 2009-06-30 02:49:10 UTC (rev 21257)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/customdata.c 2009-06-30 04:37:00 UTC (rev 21258)
@@ -831,8 +831,6 @@
{
const LayerTypeInfo *typeInfo;
- if (layer->type == CD_MSHCOEFFS) totelem = layer->totelem;
-
if(!(layer->flag & CD_FLAG_NOFREE) && layer->data) {
typeInfo = layerType_getInfo(layer->type);
@@ -1128,7 +1126,6 @@
data->layers[index].type = type;
data->layers[index].flag = flag;
- data->layers[index].totelem = totelem;
data->layers[index].data = newlayerdata;
if(name) {
Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-06-30 02:49:10 UTC (rev 21257)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-06-30 04:37:00 UTC (rev 21258)
@@ -54,7 +54,7 @@
// TODO: simple function to return value for 3 channels. needs improvement
void def_synthetic(float phi, float theta, float val[3], void *data)
{
- if (theta < M_PI / 12) {
+ if (theta < M_PI / 6) {
val[0] = val[1] = val[2] = 1.0;
}
else {
Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/mesh.c 2009-06-30 02:49:10 UTC (rev 21257)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/mesh.c 2009-06-30 04:37:00 UTC (rev 21258)
@@ -141,6 +141,7 @@
CustomData_free(&me->vdata, me->totvert);
CustomData_free(&me->edata, me->totedge);
CustomData_free(&me->fdata, me->totface);
+ CustomData_free(&me->ddata, me->totderived);
if(me->mat) MEM_freeN(me->mat);
@@ -218,6 +219,7 @@
CustomData_copy(&me->vdata, &men->vdata, CD_MASK_MESH, CD_DUPLICATE, men->totvert);
CustomData_copy(&me->edata, &men->edata, CD_MASK_MESH, CD_DUPLICATE, men->totedge);
CustomData_copy(&me->fdata, &men->fdata, CD_MASK_MESH, CD_DUPLICATE, men->totface);
+ CustomData_copy(&me->ddata, &men->ddata, CD_MASK_MESH, CD_DUPLICATE, men->totderived);
mesh_update_customdata_pointers(men);
/* ensure indirect linked data becomes lib-extern */
Modified: branches/soc-2009-yukishiro/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenloader/intern/readfile.c 2009-06-30 02:49:10 UTC (rev 21257)
+++ branches/soc-2009-yukishiro/source/blender/blenloader/intern/readfile.c 2009-06-30 04:37:00 UTC (rev 21258)
@@ -3053,6 +3053,7 @@
}
+
static void lib_link_mesh(FileData *fd, Main *main)
{
Mesh *me;
@@ -3165,6 +3166,9 @@
direct_link_customdata(fd, &mesh->edata, mesh->pv ? mesh->pv->totedge : mesh->totedge);
direct_link_customdata(fd, &mesh->fdata, mesh->pv ? mesh->pv->totface : mesh->totface);
+ // XXX
+ direct_link_customdata(fd, &mesh->ddata, mesh->totderived);
+
mesh->bb= NULL;
mesh->mselect = NULL;
mesh->edit_mesh= NULL;
Modified: branches/soc-2009-yukishiro/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenloader/intern/writefile.c 2009-06-30 02:49:10 UTC (rev 21257)
+++ branches/soc-2009-yukishiro/source/blender/blenloader/intern/writefile.c 2009-06-30 04:37:00 UTC (rev 21258)
@@ -1318,12 +1318,10 @@
else {
CustomData_file_write_info(layer->type, &structname, &structnum);
if (structnum) {
- /* number of elements is decided by the derived mesh, not mesh */
- if (layer->type == CD_MSHCOEFFS) count = layer->totelem;
/* when using partial visibility, the MEdge and MFace layers
are smaller than the original, so their type and count is
passed to make this work */
- else if (layer->type == partial_type) count = partial_count;
+ if (layer->type == partial_type) count = partial_count;
datasize= structnum*count;
writestruct(wd, DATA, structname, datasize, layer->data);
@@ -1360,6 +1358,7 @@
write_customdata(wd, mesh->totvert, &mesh->vdata, -1, 0);
write_customdata(wd, mesh->totedge, &mesh->edata, -1, 0);
write_customdata(wd, mesh->totface, &mesh->fdata, -1, 0);
+ write_customdata(wd, mesh->totderived, &mesh->ddata, -1, 0);
}
/* PMV data */
Modified: branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c 2009-06-30 02:49:10 UTC (rev 21257)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c 2009-06-30 04:37:00 UTC (rev 21258)
@@ -152,124 +152,7 @@
return OPERATOR_FINISHED;
}
-/*************************** undo and redo *********************************/
-typedef struct UndoCoeffs {
- void *next, *prev;
- float coeffs[25][3];
-} UndoCoeffs;
-
-static ListBase strokes;
-static ListBase undo_coeffs;
-static ListBase redo_coeffs;
-static float init_coeffs[25][3];
-
-static void undo_lightpaint_push(Scene *scene)
-{
- int i, j;
- LightEnv *env = scene->lightenv;
- UndoCoeffs *uc = MEM_callocN(sizeof(UndoCoeffs), "UndoCoeffs");
-
- for (i = 0; i < 25; i++) {
- for (j = 0; j < 3; j++) {
- uc->coeffs[i][j] = env->shcoeffs[i][j];
- }
- }
-
- BLI_addtail(&undo_coeffs, uc);
- BLI_freelistN(&redo_coeffs);
-}
-
-static void undo_lightpaint_init(Scene *scene)
-{
- int i, j;
- LightEnv *env;
-
- if (undo_coeffs.first == NULL) {
- env = scene->lightenv;
- for (i = 0; i < 25; i++) {
- for (j = 0; j < 3; j++) {
- init_coeffs[i][j] = env->shcoeffs[i][j];
- }
- }
- }
-}
-
-void undo_lightpaint_step(bContext *C, int step)
-{
- VPaint *lp = CTX_data_tool_settings(C)->lpaint;
- Scene *scene = CTX_data_scene(C);
- LightEnv *env = scene->lightenv;
- PaintStroke *ps;
- UndoCoeffs *uc;
- int i, j;
-
- if (step == 1) {
- ps = (PaintStroke*)lp->lpaint_data.last;
- uc = (UndoCoeffs*)undo_coeffs.last;
-
- if (ps && uc) {
- BLI_remlink(&lp->lpaint_data, ps);
- BLI_addtail(&strokes, ps);
-
- BLI_remlink(&undo_coeffs, uc);
- BLI_addtail(&redo_coeffs, uc);
- uc = (UndoCoeffs*)undo_coeffs.last;
-
- if (uc != NULL) {
- for (i = 0; i < 25; i++) {
- for (j = 0; j < 3; j++) {
- env->shcoeffs[i][j] = uc->coeffs[i][j];
- }
- }
- }
- else {
- for (i = 0; i < 25; i++) {
- for (j = 0; j < 3; j++) {
- env->shcoeffs[i][j] = init_coeffs[i][j];
- }
- }
- }
- }
- }
- else if (step == -1) {
- ps = (PaintStroke*)strokes.last;
- uc = (UndoCoeffs*)redo_coeffs.last;
-
- if (ps && uc) {
- BLI_remlink(&strokes, ps);
- BLI_addtail(&lp->lpaint_data, ps);
-
- for (i = 0; i < 25; i++) {
- for (j = 0; j < 3; j++) {
- env->shcoeffs[i][j] = uc->coeffs[i][j];
- }
- }
- BLI_remlink(&redo_coeffs, uc);
- BLI_addtail(&undo_coeffs, uc);
- }
- }
-
- WM_event_add_notifier(C, NC_LIGHTENV|ND_SH_RESULT, NULL);
-}
-
-
-void undo_lightpaint_clear(void)
-{
- PaintStroke *ps, *next;
-
- ps = strokes.first;
- while (ps) {
- MEM_freeN(ps->v_index);
- next = ps->next;
- MEM_freeN(ps);
- ps = next;
- }
-
- BLI_freelistN(&undo_coeffs);
- BLI_freelistN(&redo_coeffs);
-}
-
/************************ light paint poll ************************/
static int light_paint_rotate_poll(bContext *C)
{
@@ -520,7 +403,7 @@
cur_ps = ps;
while (cur_ps) {
me = get_mesh(cur_ps->ob);
- coeffs= CustomData_get_layer(&me->vdata, CD_MSHCOEFFS);
+ coeffs= CustomData_get_layer(&me->ddata, CD_MSHCOEFFS);
// set P, I
for (i = 0; i < cur_ps->size; i++) {
@@ -580,7 +463,6 @@
PaintStroke *ps = (PaintStroke*)lp->lpaint_data.first;
compute_color(scene, ps);
lpaint_exit(C, op);
- undo_lightpaint_push(scene);
WM_event_add_notifier(C, NC_LIGHTENV|ND_SH_RESULT, NULL);
return OPERATOR_FINISHED;
@@ -656,8 +538,6 @@
ps->b = lp->brush->rgb[2];
BLI_addtail(&lp->lpaint_data, ps);
- undo_lightpaint_init(CTX_data_scene(C));
-
/* some old cruft to sort out later */
Mat4MulMat4(mat, ob->obmat, pop->vc.rv3d->viewmat);
Mat4Invert(imat, mat);
@@ -881,7 +761,6 @@
ot->invoke= light_paint_save_invoke;
ot->exec= light_paint_save_exec;
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of the output image.");
}
Modified: branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c 2009-06-30 02:49:10 UTC (rev 21257)
+++ branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c 2009-06-30 04:37:00 UTC (rev 21258)
@@ -2326,10 +2326,14 @@
int i, totface= dm->getNumFaces(dm);
MFace *mf= dm->getFaceArray(dm);
Mesh *me= get_mesh(ob);
- MShCoeffs *mco= CustomData_get_layer(&me->vdata, CD_MSHCOEFFS);
+ MShCoeffs *mco= CustomData_get_layer(&me->ddata, CD_MSHCOEFFS);
LightEnv *env= scene->lightenv;
int num_sh = (env->degree + 1) * (env->degree + 1);
+ if (mco == NULL) {
+ printf("WRONG!\N");
+ return;
+ }
if (env == NULL) add_lightenv(scene, "LightEnv");
for (i=0; i<totface; i++, mf++) {
Modified: branches/soc-2009-yukishiro/source/blender/editors/util/ed_util.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/util/ed_util.c 2009-06-30 02:49:10 UTC (rev 21257)
+++ branches/soc-2009-yukishiro/source/blender/editors/util/ed_util.c 2009-06-30 04:37:00 UTC (rev 21258)
@@ -61,7 +61,6 @@
/* frees all editmode undos */
undo_editmode_clear();
undo_imagepaint_clear();
- undo_lightpaint_clear();
for(sce=G.main->scene.first; sce; sce= sce->id.next) {
if(sce->obedit) {
Modified: branches/soc-2009-yukishiro/source/blender/editors/util/undo.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/util/undo.c 2009-06-30 02:49:10 UTC (rev 21257)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list