[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20947] branches/soc-2009-yukishiro/source /blender: slightly improve listeners for sh jobs
Jingyuan Huang
jingyuan.huang at gmail.com
Wed Jun 17 05:13:49 CEST 2009
Revision: 20947
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20947
Author: yukishiro
Date: 2009-06-17 05:13:48 +0200 (Wed, 17 Jun 2009)
Log Message:
-----------
slightly improve listeners for sh jobs
Modified Paths:
--------------
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_intern.h
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_ops.c
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c
branches/soc-2009-yukishiro/source/blender/makesdna/DNA_lightenv_types.h
branches/soc-2009-yukishiro/source/blender/makesdna/DNA_scene_types.h
branches/soc-2009-yukishiro/source/blender/makesdna/DNA_view3d_types.h
branches/soc-2009-yukishiro/source/blender/makesrna/intern/rna_lightenv.c
branches/soc-2009-yukishiro/source/blender/sh/SH_api.h
branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c
branches/soc-2009-yukishiro/source/blender/windowmanager/WM_types.h
Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c 2009-06-17 00:01:27 UTC (rev 20946)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c 2009-06-17 03:13:48 UTC (rev 20947)
@@ -1834,12 +1834,6 @@
add_orco_dm(ob, NULL, *deform_r, NULL);
}
- ///* add a sh color layer if needed */
- //if((dataMask & CD_MASK_SH_MCOL) && (scene->flag & SCE_SH_COMPUTED)) {
- // printf("add? %d %d\n", dataMask & CD_MASK_SH_MCOL, scene->flag & SCE_SH_COMPUTED);
- // add_sh_mcol_dm(scene, ob, finaldm);
- //}
-
*final_r = finaldm;
if(orcodm)
Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-06-17 00:01:27 UTC (rev 20946)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c 2009-06-17 03:13:48 UTC (rev 20947)
@@ -109,6 +109,8 @@
env= alloc_libblock(&G.main->lightenv, ID_LE, name);
env->type = LE_DEFAULT;
env->light_func = def_synthetic;
+ env->degree = 2;
+ env->num_samples = 10;
SH_ComputeLightCoefficients(env);
scene->lightenv = env;
Modified: branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_intern.h 2009-06-17 00:01:27 UTC (rev 20946)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_intern.h 2009-06-17 03:13:48 UTC (rev 20947)
@@ -60,6 +60,7 @@
void PAINT_OT_light_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_light_paint(struct wmOperatorType *ot);
void PAINT_OT_light_paint_radial_control(struct wmOperatorType *ot);
+void PAINT_OT_light_paint_recompute(struct wmOperatorType *ot);
/* paint_utils.c */
int imapaint_pick_face(struct ViewContext *vc, struct Mesh *me, int *mval, unsigned int *index);
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-17 00:01:27 UTC (rev 20946)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c 2009-06-17 03:13:48 UTC (rev 20947)
@@ -83,6 +83,7 @@
typedef struct ShJob {
Scene *scene;
View3D *v3d;
+ short recompute;
short *stop;
short *do_update;
} ShJob;
@@ -102,22 +103,24 @@
sj->stop= stop;
sj->do_update= do_update;
- add_lightenv(sj->scene, "LightEnv");
- SH_ComputeSceneCoefficients(sj->scene, sj->v3d);
- sj->scene->flag |= SCE_SH_COMPUTED;
+ if (sj->scene->lightenv == NULL)
+ add_lightenv(sj->scene, "LightEnv");
+
+ SH_ComputeSceneCoefficients(sj->scene, sj->v3d, sj->recompute);
}
// TODO: problem with using a job for the scene is that info header would display a render button....
-// TODO: view3d display should wait till this job finishes.
-static void initial_computation(bContext *C)
+static void light_paint_compute(bContext *C, short recompute)
{
Scene *scene= CTX_data_scene(C);
wmJob *job;
ShJob *sj;
/* only one job at a time */
- if(WM_jobs_test(CTX_wm_manager(C), scene)) return;
+ if (WM_jobs_test(CTX_wm_manager(C), scene)) {
+ return OPERATOR_CANCELLED;
+ }
/* handle UI stuff */
WM_cursor_wait(1);
@@ -126,17 +129,21 @@
sj= MEM_callocN(sizeof(ShJob), "SH job");
sj->scene= scene;
sj->v3d= CTX_wm_view3d(C);
+ sj->recompute= recompute;
/* setup job */
job= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene);
WM_jobs_customdata(job, sj, sh_freejob);
- WM_jobs_timer(job, 0.2, NC_SCENE|ND_SH_RESULT, 0);
+ WM_jobs_timer(job, 0.1, NC_LIGHTENV|ND_SH_UPDATE, NC_LIGHTENV|ND_SH_RESULT);
WM_jobs_callbacks(job, sh_startjob, NULL, NULL);
/* start job */
WM_jobs_start(CTX_wm_manager(C), job);
+
WM_cursor_wait(0);
+ /* add modal handler for ESC */
+ //WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
}
/*************************** undo and redo *********************************/
@@ -372,9 +379,8 @@
else {
G.f |= G_LIGHTPAINT;
- if (!(scene->flag & SCE_SH_COMPUTED)) {
- initial_computation(C);
- }
+ light_paint_compute(C, 0);
+
if(lp==NULL)
lp= scene->toolsettings->lpaint= new_lpaint();
@@ -385,7 +391,6 @@
// TODO: add to depsgraph?
ED_area_tag_redraw(CTX_wm_area(C));
- WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
return OPERATOR_FINISHED;
}
@@ -555,7 +560,7 @@
lpaint_exit(C, op);
undo_lightpaint_push(scene);
- WM_event_add_notifier(C, NC_LIGHTENV, NULL);
+ WM_event_add_notifier(C, NC_LIGHTENV|ND_SH_RESULT, NULL);
return OPERATOR_FINISHED;
}
/* pass on, first press gets painted too */
@@ -595,7 +600,7 @@
*mcol = pop->paintcol;
*(mcol+1) = pop->paintcol;
*(mcol+2) = pop->paintcol;
- if(mface->v4) {
+ if(mf->v4) {
*(mcol+3) = pop->paintcol;
}
}
@@ -662,6 +667,12 @@
}
+static int light_paint_recompute(bContext *C, wmOperator *op)
+{
+ light_paint_compute(C, 1);
+}
+
+
void PAINT_OT_light_paint_toggle(wmOperatorType *ot)
{
/* identifiers */
@@ -693,7 +704,6 @@
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* properties */
- //RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
}
void PAINT_OT_light_paint_radial_control(wmOperatorType *ot)
@@ -711,3 +721,15 @@
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
+
+
+void PAINT_OT_light_paint_recompute(struct wmOperatorType *ot)
+{
+ ot->name= "Light Paint Recompute";
+ ot->idname = "PAINT_OT_light_paint_recompute";
+
+ ot->exec= light_paint_recompute;
+ //ot->poll= light_paint_poll;
+
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
Modified: branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_ops.c 2009-06-17 00:01:27 UTC (rev 20946)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_ops.c 2009-06-17 03:13:48 UTC (rev 20947)
@@ -33,5 +33,6 @@
WM_operatortype_append(PAINT_OT_light_paint_toggle);
WM_operatortype_append(PAINT_OT_light_paint);
WM_operatortype_append(PAINT_OT_light_paint_radial_control);
+ WM_operatortype_append(PAINT_OT_light_paint_recompute);
}
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-17 00:01:27 UTC (rev 20946)
+++ branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c 2009-06-17 03:13:48 UTC (rev 20947)
@@ -2489,7 +2489,7 @@
if(G.f & G_LIGHTPAINT) {
- if (scene->flag & SCE_SH_COMPUTED) {
+ if (rv3d->rflag & RV3D_SHRESULT) {
unsigned char *shcol= DM_get_face_data_layer(dm, CD_SH_MCOL);
if (shcol == NULL) shcol = add_sh_mcol_dm(scene, ob, dm);
@@ -2507,6 +2507,7 @@
GPU_disable_material();
}
else {
+ printf("in progress\n");
// progress bar
}
}
Modified: branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c 2009-06-17 00:01:27 UTC (rev 20946)
+++ branches/soc-2009-yukishiro/source/blender/editors/space_view3d/space_view3d.c 2009-06-17 03:13:48 UTC (rev 20947)
@@ -425,7 +425,16 @@
break;
case NC_LIGHTENV:
rv3d = ar->regiondata;
- rv3d->rflag |= RV3D_RECALCMCOL;
+
+ switch(wmn->data) {
+ case ND_SH_RESULT:
+ rv3d->rflag |= RV3D_SHRESULT;
+ rv3d->rflag |= RV3D_RECALCMCOL;
+ break;
+ case ND_SH_UPDATE:
+ rv3d->rflag &= ~RV3D_SHRESULT;
+ break;
+ }
ED_region_tag_redraw(ar);
break;
}
Modified: branches/soc-2009-yukishiro/source/blender/makesdna/DNA_lightenv_types.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesdna/DNA_lightenv_types.h 2009-06-17 00:01:27 UTC (rev 20946)
+++ branches/soc-2009-yukishiro/source/blender/makesdna/DNA_lightenv_types.h 2009-06-17 03:13:48 UTC (rev 20947)
@@ -42,6 +42,7 @@
ID id;
short flag, type;
+ int degree, num_samples;
float shcoeffs[25][3];
//light_func func;
Modified: branches/soc-2009-yukishiro/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesdna/DNA_scene_types.h 2009-06-17 00:01:27 UTC (rev 20946)
+++ branches/soc-2009-yukishiro/source/blender/makesdna/DNA_scene_types.h 2009-06-17 03:13:48 UTC (rev 20947)
@@ -846,7 +846,6 @@
/* sce->flag */
#define SCE_DS_SELECTED (1<<0)
#define SCE_DS_COLLAPSED (1<<1)
-#define SCE_SH_COMPUTED (1<<2)
/* return flag next_object function */
#define F_ERROR -1
Modified: branches/soc-2009-yukishiro/source/blender/makesdna/DNA_view3d_types.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/makesdna/DNA_view3d_types.h 2009-06-17 00:01:27 UTC (rev 20946)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list