[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20347] branches/soc-2009-yukishiro/source : the cube shows up on the screen using coeffs now, but still needs some fixing and code clean up

Jingyuan Huang jingyuan.huang at gmail.com
Fri May 22 23:23:25 CEST 2009


Revision: 20347
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20347
Author:   yukishiro
Date:     2009-05-22 23:23:22 +0200 (Fri, 22 May 2009)

Log Message:
-----------
the cube shows up on the screen using coeffs now, but still needs some fixing and code clean up

Modified Paths:
--------------
    branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_main.h
    branches/soc-2009-yukishiro/source/blender/blenkernel/CMakeLists.txt
    branches/soc-2009-yukishiro/source/blender/blenkernel/SConscript
    branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.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/space_view3d/view3d_draw.c
    branches/soc-2009-yukishiro/source/blender/makesdna/DNA_ID.h
    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/makesdna/DNA_world_types.h
    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/CMakeLists.txt
    branches/soc-2009-yukishiro/source/blender/windowmanager/SConscript
    branches/soc-2009-yukishiro/source/blender/windowmanager/intern/wm_init_exit.c
    branches/soc-2009-yukishiro/source/creator/CMakeLists.txt

Added Paths:
-----------
    branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h
    branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
    branches/soc-2009-yukishiro/source/blender/makesdna/DNA_lightenv_types.h

Added: branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h	                        (rev 0)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_lightenv.h	2009-05-22 21:23:22 UTC (rev 20347)
@@ -0,0 +1,51 @@
+/**
+ * $Id: BKE_lightenv.h 18313 2009-01-04 14:14:06Z ton $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * General operations, lookup, etc. for materials.
+ */
+
+#ifndef BKE_LIGHTENV_H
+#define BKE_LIGHTENV_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct LightEnv;
+struct Scene;
+
+void init_def_lightenv(void);
+void free_lightenv(struct LightEnv *env); 
+LightEnv* add_lightenv(char *name);
+
+LightEnv* get_scene_lightenv(struct Scene *scene);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_main.h
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_main.h	2009-05-22 17:01:32 UTC (rev 20346)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/BKE_main.h	2009-05-22 21:23:22 UTC (rev 20347)
@@ -78,6 +78,7 @@
 	ListBase particle;
 	ListBase wm;
 	ListBase gpencil;
+        ListBase lightenv;
 } Main;
 
 

Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/CMakeLists.txt
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/CMakeLists.txt	2009-05-22 17:01:32 UTC (rev 20346)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/CMakeLists.txt	2009-05-22 21:23:22 UTC (rev 20347)
@@ -33,7 +33,7 @@
   ../../../intern/iksolver/extern ../blenloader ../quicktime
   ../../../extern/bullet2/src
   ../nodes ../../../extern/glew/include ../gpu ../makesrna
-  ../../../intern/bsp/extern
+  ../../../intern/bsp/extern ../sh
   ${SDL_INC}
   ${ZLIB_INC}
 )

Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/SConscript
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/SConscript	2009-05-22 17:01:32 UTC (rev 20346)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/SConscript	2009-05-22 21:23:22 UTC (rev 20347)
@@ -9,7 +9,7 @@
 incs += ' #/intern/iksolver/extern ../blenloader'
 incs += ' #/extern/bullet2/src'
 incs += ' #/intern/opennl/extern #/intern/bsp/extern'
-incs += ' ../gpu #/extern/glew/include'
+incs += ' ../gpu #/extern/glew/include ../sh'
 
 incs += ' ' + env['BF_OPENGL_INC']
 incs += ' ' + env['BF_ZLIB_INC']

Modified: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c	2009-05-22 17:01:32 UTC (rev 20346)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/DerivedMesh.c	2009-05-22 21:23:22 UTC (rev 20347)
@@ -38,8 +38,8 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_effect_types.h"
+#include "DNA_key_types.h"
 #include "DNA_mesh_types.h"
-#include "DNA_key_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
@@ -1559,6 +1559,7 @@
 	stored_cb= coba;
 }
 
+
 static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm)
 {
 	Mesh *me = ob->data;
@@ -1581,6 +1582,16 @@
 	CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, dm->numFaceData);
 }
 
+
+static void add_sh_mcol_dm(Scene *scene, Object *ob, DerivedMesh *dm)
+{
+        Mesh *me = ob->data;
+        unsigned char *shcol;
+
+        shcol = MEM_callocN (sizeof (unsigned char) * me->totface * 4 * 4, "sh color");
+        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,
@@ -1821,6 +1832,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);
+        }
+
 	*final_r = finaldm;
 
 	if(orcodm)

Added: branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c
===================================================================
--- branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c	                        (rev 0)
+++ branches/soc-2009-yukishiro/source/blender/blenkernel/intern/lightenv.c	2009-05-22 21:23:22 UTC (rev 20347)
@@ -0,0 +1,102 @@
+/*  lightenv.c
+ *
+ * 
+ * $Id: material.c 18559 2009-01-18 10:41:45Z aligorith $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <string.h>
+#include <math.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_blender.h"
+#include "BKE_displist.h"
+#include "BKE_global.h"
+//#include "BKE_icons.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+
+#include "DNA_lightenv_types.h"
+#include "DNA_world_types.h"
+#include "DNA_scene_types.h"
+
+#include "SH_api.h"
+
+LightEnv deflightenv;
+
+void def_synthetic(float theta, float phi, float *val)
+{
+        if (theta < M_PI / 3) {
+                val[0] = val[1] = val[2] = 255;
+        }
+        else {
+                val[0] = val[1] = val[2] = 0;
+        }
+}
+
+static void init_lightenv(LightEnv *env)
+{
+        env->mtex = NULL;
+        env->preview = NULL;
+        
+        SH_ComputeLightCoefficients(env);
+}
+
+/* called on startup, in SH_init() */
+void init_def_lightenv(void)
+{
+        deflightenv.func = def_synthetic;
+        init_lightenv(&deflightenv);
+}
+
+void free_lightenv(LightEnv *env)
+{
+        // free texture
+
+//	BKE_previewimg_free(&env->preview);
+}
+
+
+LightEnv* add_lightenv(char *name)
+{
+        LightEnv *env;
+
+	env= alloc_libblock(&G.main->lightenv, ID_LE, name);
+        init_lightenv(env);
+
+        return env;
+}
+
+
+LightEnv* get_scene_lightenv(Scene *scene)
+{
+        World *world = scene->world;
+
+        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-05-22 17:01:32 UTC (rev 20346)
+++ branches/soc-2009-yukishiro/source/blender/editors/sculpt_paint/paint_light.c	2009-05-22 21:23:22 UTC (rev 20347)
@@ -52,7 +52,7 @@
 #include "IMB_imbuf_types.h"
 
 #include "DNA_brush_types.h"
-#include "DNA_image_types.h"
+#include "DNA_lightenv_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_node_types.h"
@@ -60,9 +60,9 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
-#include "DNA_userdef_types.h"
 #include "DNA_view3d_types.h"
 #include "DNA_windowmanager_types.h"
+#include "DNA_world_types.h"
 
 #include "BKE_context.h"
 #include "BKE_brush.h"
@@ -120,10 +120,7 @@
 	sj->stop= stop;
 	sj->do_update= do_update;
 	
-        //TODO: call routines in SH
-        SH_ComputeCoefficients(sj->scene);
-
-        printf("done\n");
+        SH_ComputeSceneCoefficients(sj->scene);
 }
 
 static void toggle_paint_cursor(bContext *C, int enable)
@@ -139,7 +136,7 @@
 }
 
 // TODO: problem with using a job for the scene is that info header would display a render button....
-static void initial_computation(bContext *C, wmOperator *op)
+static void initial_computation(bContext *C)
 {
         Scene *scene= CTX_data_scene(C);
         wmJob *job;
@@ -162,14 +159,9 @@
 	WM_jobs_timer(job, 0.2, NC_SCENE|ND_SH_RESULT, 0);
 	WM_jobs_callbacks(job, sh_startjob, NULL, NULL);
 
-	/* setup sh computation */
-	//sh= SH_NewShCompute(scene->id.name);
-	//SH_test_break_cb(sh, sj, sh_breakjob);
-
 	WM_jobs_start(job);
 
 	WM_cursor_wait(0);
-	WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
 }
 
 
@@ -185,12 +177,14 @@
                 G.f |= G_LIGHTPAINT;
 
                 if (!(scene->flag & SCE_SH_COMPUTED)) {
-                        initial_computation(C, op);
+                        initial_computation(C);
                         scene->flag |= SCE_SH_COMPUTED;
                 }
                 toggle_paint_cursor(C, 1);
         }
 
+        WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
+	ED_area_tag_redraw(CTX_wm_area(C));
 	return OPERATOR_FINISHED;
 }
 


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list