Revision: 20595
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20595
Author:   yukishiro
Date:     2009-06-03 04:06:45 +0200 (Wed, 03 Jun 2009)

Log Message:
-----------
need a better way to signal when the sh job is done

Modified Paths:
--------------
    branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_DerivedMesh.h
    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_light.c
    branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2009-yukishiro/source/blender/sh/intern/compute.c

Modified: 
branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_DerivedMesh.h     
2009-06-03 00:40:38 UTC (rev 20594)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_DerivedMesh.h     
2009-06-03 02:06:45 UTC (rev 20595)
@@ -461,8 +461,6 @@
 
 void weight_to_rgb(float input, float *fr, float *fg, float *fb);
 
-void calc_sh_color(struct Scene *scene, struct Object *ob, DerivedMesh *dm, 
unsigned char *shcol);
-
 /* 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 
*/
 typedef struct DMVertexAttribs {

Modified: 
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c  
2009-06-03 00:40:38 UTC (rev 20594)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c  
2009-06-03 02:06:45 UTC (rev 20595)
@@ -1585,69 +1585,8 @@
        CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, 
dm->numFaceData);
 }
 
-static void calc_sh_vert_color(Object *ob, int index, MShCoeffs *mco, float 
(*lco)[3], unsigned char *col)
-{
-        Mesh *me = ob->data;
-        Material * mat;
-        float color[3];
-        float brightness[3];
-        int k;
 
-        // TODO: get face material colour
-        if (me->mat) mat = me->mat[0];
 
-        if (mat != NULL) {
-                color[0] = mat->r;
-                color[1] = mat->g;
-                color[2] = mat->b;
-        } else {
-              color[0] = color[1] = color[2] = 0.8;
-        }
-
-        brightness[0] = brightness[1] = brightness[2] = 0;
-        for (k = 0; k < 9; k++) {
-                brightness[0] += mco[index].val[k] * lco[k][0];
-                brightness[1] += mco[index].val[k] * lco[k][1];
-                brightness[2] += mco[index].val[k] * lco[k][2];
-        }
-       color[0] *= brightness[0];
-       color[1] *= brightness[1];
-       color[2] *= brightness[2];
-
-       col[0] = FTOCHAR(color[0]);
-       col[1] = FTOCHAR(color[1]);
-       col[2] = FTOCHAR(color[2]);
-       col[3] = 255;
-}
-
-void calc_sh_color(Scene *scene, Object *ob, DerivedMesh *dm, unsigned char 
*shcol)
-{
-        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);
-        LightEnv *env= get_scene_lightenv(scene);
-
-        for (i=0; i<totface; i++, mf++) {
-                calc_sh_vert_color(ob, mf->v1, mco, env->shcoeffs, &shcol[(i*4 
+ 0) * 4]);
-                calc_sh_vert_color(ob, mf->v1, mco, env->shcoeffs, &shcol[(i*4 
+ 1) * 4]);
-                calc_sh_vert_color(ob, mf->v1, mco, env->shcoeffs, &shcol[(i*4 
+ 2) * 4]);
-                if (mf->v4)
-                        calc_sh_vert_color(ob, mf->v1, mco, env->shcoeffs, 
&shcol[(i*4 + 3) * 4]);
-        }
-}
-
-
-static void add_sh_mcol_dm(Scene *scene, Object *ob, DerivedMesh *dm)
-{
-        unsigned char *shcol;
-        int totface= dm->getNumFaces(dm);
-
-        shcol = MEM_callocN (sizeof (unsigned char) * totface * 4 * 4, "sh 
color");
-        calc_sh_color(scene, ob, dm, shcol);
-        CustomData_add_layer(&dm->faceData, CD_SH_MCOL, CD_ASSIGN, shcol, 
dm->numFaceData);
-}
-
 static void mesh_calc_modifiers(Scene *scene, Object *ob, float 
(*inputVertexCos)[3],
                                 DerivedMesh **deform_r, DerivedMesh **final_r,
                                 int useRenderParams, int useDeform,
@@ -1888,10 +1827,11 @@
                        add_orco_dm(ob, NULL, *deform_r, NULL);
        }
 
-        /* add a sh color layer if needed */
-        if(dataMask & CD_MASK_SH_MCOL) {
-                add_sh_mcol_dm(scene, ob, finaldm);
-        }
+        ///* 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;
 

Modified: 
branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c     
2009-06-03 00:40:38 UTC (rev 20594)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c     
2009-06-03 02:06:45 UTC (rev 20595)
@@ -120,6 +120,7 @@
 {
         World *world = scene->world;
 
+        if (world == NULL) return &deflightenv;
         if (world->lightenv == NULL) return &deflightenv;
         return world->lightenv;
 }

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-03 00:40:38 UTC (rev 20594)
+++ 
branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c   
    2009-06-03 02:06:45 UTC (rev 20595)
@@ -103,6 +103,7 @@
        sj->do_update= do_update;
        
         SH_ComputeSceneCoefficients(sj->scene, sj->v3d);
+        sj->scene->flag |= SCE_SH_COMPUTED;
 }
 
 
@@ -111,30 +112,30 @@
 static void initial_computation(bContext *C)
 {
         Scene *scene= CTX_data_scene(C);
-        SH_ComputeSceneCoefficients(scene, CTX_wm_view3d(C));
-//        wmJob *job;
-//        ShJob *sj;
-//
-//     /* only one job at a time */
-//     if(WM_jobs_test(CTX_wm_manager(C), scene)) return;
-//
-//     /* handle UI stuff */
-//     WM_cursor_wait(1);
-//
-//     /* job custom data */
-//     sj= MEM_callocN(sizeof(ShJob), "SH job");
-//     sj->scene= scene;
-//     sj->v3d= CTX_wm_view3d(C);
-//
-//     /* 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_callbacks(job, sh_startjob, NULL, NULL);
-//
-//        /* start job */
-//     WM_jobs_start(job);
-//     WM_cursor_wait(0);
+        wmJob *job;
+        ShJob *sj;
+
+       /* only one job at a time */
+       if(WM_jobs_test(CTX_wm_manager(C), scene)) return;
+
+       /* handle UI stuff */
+       WM_cursor_wait(1);
+
+       /* job custom data */
+       sj= MEM_callocN(sizeof(ShJob), "SH job");
+       sj->scene= scene;
+       sj->v3d= CTX_wm_view3d(C);
+
+       /* 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_callbacks(job, sh_startjob, NULL, NULL);
+
+        /* start job */
+       WM_jobs_start(job);
+       WM_cursor_wait(0);
+
 }
 
 static int *get_indexarray(void)
@@ -263,7 +264,6 @@
 
                 if (!(scene->flag & SCE_SH_COMPUTED)) {
                         initial_computation(C);
-                        scene->flag |= SCE_SH_COMPUTED;
                 }
                if(lp==NULL)
                        lp= scene->toolsettings->lpaint= new_lpaint();

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-03 00:40:38 UTC (rev 20594)
+++ 
branches/soc-2009-yukishiro/source/blender/editors/space_view3d/drawobject.c    
    2009-06-03 02:06:45 UTC (rev 20595)
@@ -2277,7 +2277,71 @@
        return 1;
 }
 
+static void calc_sh_vert_color(Object *ob, int index, MShCoeffs *mco, float 
(*lco)[3], unsigned char *col)
+{
+        Mesh *me = ob->data;
+        Material * mat;
+        float color[3];
+        float brightness[3];
+        int k;
 
+        // TODO: get face material colour
+        if (me->mat) mat = me->mat[0];
+
+        if (mat != NULL) {
+                color[0] = mat->r;
+                color[1] = mat->g;
+                color[2] = mat->b;
+        } else {
+              color[0] = color[1] = color[2] = 0.8;
+        }
+
+        brightness[0] = brightness[1] = brightness[2] = 0;
+        for (k = 0; k < 9; k++) {
+                brightness[0] += mco[index].val[k] * lco[k][0];
+                brightness[1] += mco[index].val[k] * lco[k][1];
+                brightness[2] += mco[index].val[k] * lco[k][2];
+        }
+       color[0] *= brightness[0];
+       color[1] *= brightness[1];
+       color[2] *= brightness[2];
+
+       col[0] = FTOCHAR(color[0]);
+       col[1] = FTOCHAR(color[1]);
+       col[2] = FTOCHAR(color[2]);
+       col[3] = 255;
+}
+
+
+static void calc_sh_color(Scene *scene, Object *ob, DerivedMesh *dm, unsigned 
char *shcol)
+{
+        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);
+        LightEnv *env= get_scene_lightenv(scene);
+
+        for (i=0; i<totface; i++, mf++) {
+                calc_sh_vert_color(ob, mf->v1, mco, env->shcoeffs, &shcol[(i*4 
+ 0) * 4]);
+                calc_sh_vert_color(ob, mf->v1, mco, env->shcoeffs, &shcol[(i*4 
+ 1) * 4]);
+                calc_sh_vert_color(ob, mf->v1, mco, env->shcoeffs, &shcol[(i*4 
+ 2) * 4]);
+                if (mf->v4)
+                        calc_sh_vert_color(ob, mf->v1, mco, env->shcoeffs, 
&shcol[(i*4 + 3) * 4]);
+        }
+}
+
+
+static void* add_sh_mcol_dm(Scene *scene, Object *ob, DerivedMesh *dm)
+{
+        unsigned char *shcol;
+        int totface= dm->getNumFaces(dm);
+
+        shcol = MEM_callocN (sizeof (unsigned char) * totface * 4 * 4, "sh 
color");
+        calc_sh_color(scene, ob, dm, shcol);
+        return CustomData_add_layer(&dm->faceData, CD_SH_MCOL, CD_ASSIGN, 
shcol, dm->numFaceData);
+}
+
+
 static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, 
Base *base, int dt, int flag)
 {
        Object *ob= base->object;
@@ -2404,23 +2468,6 @@
                                glColor3f(1.0f, 1.0f, 1.0f);
                                dm->drawMappedFaces(dm, 
wpaint__setSolidDrawOptions, NULL, 0);
                        }
-                        else if(G.f & G_LIGHTPAINT) {
-
-                                glDisable(GL_LIGHTING);
-                                
glColorMaterial(GL_FRONT,GL_AMBIENT_AND_DIFFUSE);
-                                glEnable(GL_COLOR_MATERIAL); 
-                                glShadeModel(GL_SMOOTH);
-
-                                unsigned char *shcol= 
DM_get_face_data_layer(dm, CD_SH_MCOL);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to