[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22199] branches/soc-2008-mxcurioni/source /blender: SUMMARY:

Maxime Curioni maxime.curioni at gmail.com
Tue Aug 4 02:40:36 CEST 2009


Revision: 22199
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22199
Author:   mxcurioni
Date:     2009-08-04 02:40:36 +0200 (Tue, 04 Aug 2009)

Log Message:
-----------
SUMMARY:
The main contribution of this commit is the possibility to save Freestyle configuration information inside .blend files. It required an extensive refactoring of the previous interface code.

The code has been tested and does not crash on my machine. If you encounter issues, please let me know (and if possible, sending me an sample .blend file).

DETAILS:
- refactored code to notify Freestyle when adding/removing render layers  (FRS_freestyle_config.{h,cpp})
- corrected the freeing of style modules when files are read from / written to disk
- moved Freestyle configuration information into scene renderlayers, to allow loading / saving .blend files (DNA_scene_types.h DNA_freestyle_types.h FRS_freestyle.cpp)
- inserted temporary trick to prevent crashes when orthographic camera is used (SilhouetteGeomEngine.cpp), but outputting incorrect feature line calculations

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/blenkernel/SConscript
    branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/scene.c
    branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c
    branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c
    branches/soc-2008-mxcurioni/source/blender/freestyle/CMakeLists.txt
    branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/GeomUtils.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2008-mxcurioni/source/blender/makesdna/intern/makesdna.c
    branches/soc-2008-mxcurioni/source/blender/render/intern/source/pipeline.c
    branches/soc-2008-mxcurioni/source/blender/src/buttons_scene.c
    branches/soc-2008-mxcurioni/source/blender/src/usiblender.c

Added Paths:
-----------
    branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle_config.h
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h

Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/SConscript
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/SConscript	2009-08-04 00:00:05 UTC (rev 22198)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/SConscript	2009-08-04 00:40:36 UTC (rev 22199)
@@ -11,6 +11,7 @@
 incs += ' #/intern/bmfont'
 incs += ' #/intern/opennl/extern'
 incs += ' ../gpu #/extern/glew/include'
+incs += ' ../freestyle'
 
 incs += ' ' + env['BF_OPENGL_INC']
 incs += ' ' + env['BF_ZLIB_INC']

Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/scene.c	2009-08-04 00:00:05 UTC (rev 22198)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/scene.c	2009-08-04 00:40:36 UTC (rev 22199)
@@ -96,6 +96,8 @@
 #include <sys/time.h>
 #endif
 
+#include "FRS_freestyle_config.h"
+
 void free_avicodecdata(AviCodecData *acd)
 {
 	if (acd) {
@@ -162,6 +164,11 @@
 		sce->r.ffcodecdata.properties = NULL;
 	}
 	
+	SceneRenderLayer *srl;
+	for(srl= sce->r.layers.first; srl; srl= srl->next) {
+		BLI_freelistN( &srl->freestyleConfig.modules);
+	}
+	
 	BLI_freelistN(&sce->markers);
 	BLI_freelistN(&sce->transform_spaces);
 	BLI_freelistN(&sce->r.layers);
@@ -195,7 +202,7 @@
 	sce->selectmode= SCE_SELECT_VERTEX;
 	sce->editbutsize= 0.1;
 	sce->autokey_mode= U.autokey_mode;
-	
+
 	sce->r.mode= R_GAMMA;
 	sce->r.cfra= 1;
 	sce->r.sfra= 1;
@@ -615,6 +622,8 @@
 	srl->lay= (1<<20) -1;
 	srl->layflag= 0x7FFF;	/* solid ztra halo edge strand */
 	srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z;
+	FRS_add_freestyle_config( srl );
+	
 }
 
 /* Initialize 'permanent' sculpt data that is saved with file kept after

Modified: branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c	2009-08-04 00:00:05 UTC (rev 22198)
+++ branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c	2009-08-04 00:40:36 UTC (rev 22199)
@@ -3682,6 +3682,11 @@
 	link_list(fd, &(sce->transform_spaces));
 	link_list(fd, &(sce->r.layers));
 	
+	SceneRenderLayer *srl;
+	for(srl= sce->r.layers.first; srl; srl= srl->next) {
+		link_list(fd, &(srl->freestyleConfig.modules));
+	}
+
 	sce->nodetree= newdataadr(fd, sce->nodetree);
 	if(sce->nodetree)
 		direct_link_nodetree(fd, sce->nodetree);
@@ -8776,7 +8781,7 @@
 	
 	for(srl= sce->r.layers.first; srl; srl= srl->next) {
 		expand_doit(fd, mainvar, srl->mat_override);
-		expand_doit(fd, mainvar, srl->light_override);
+		expand_doit(fd, mainvar, srl->light_override);		
 	}
 				
 }

Modified: branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c	2009-08-04 00:00:05 UTC (rev 22198)
+++ branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c	2009-08-04 00:40:36 UTC (rev 22199)
@@ -1449,6 +1449,7 @@
 	TimeMarker *marker;
 	TransformOrientation *ts;
 	SceneRenderLayer *srl;
+	FreestyleModuleConfig *fmc;
 	int a;
 	
 	sce= scebase->first;
@@ -1525,7 +1526,7 @@
 					if(seq->type==SEQ_IMAGE)
 						writestruct(wd, DATA, "StripElem", MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem), strip->stripdata);
 					else if(seq->type==SEQ_MOVIE || seq->type==SEQ_RAM_SOUND || seq->type == SEQ_HD_SOUND)
-						writestruct(wd, DATA, "StripElem", 1, strip->stripdata);
+						writestruct(wd, DATA, "StripElem", 1, strip->stripdata);					
 
 					strip->done= 1;
 				}
@@ -1562,8 +1563,13 @@
 		for(ts = sce->transform_spaces.first; ts; ts = ts->next)
 			writestruct(wd, DATA, "TransformOrientation", 1, ts);
 		
-		for(srl= sce->r.layers.first; srl; srl= srl->next)
+		for(srl= sce->r.layers.first; srl; srl= srl->next) {
 			writestruct(wd, DATA, "SceneRenderLayer", 1, srl);
+			
+			for(fmc= srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) {
+				writestruct(wd, DATA, "FreestyleModuleConfig", 1, fmc);
+			}
+		}
 		
 		if(sce->nodetree) {
 			writestruct(wd, DATA, "bNodeTree", 1, sce->nodetree);

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/CMakeLists.txt
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/CMakeLists.txt	2009-08-04 00:00:05 UTC (rev 22198)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/CMakeLists.txt	2009-08-04 00:40:36 UTC (rev 22199)
@@ -29,7 +29,7 @@
 SET(INC 
   ../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../python
   ../render/extern/include ../render/intern/include ../include ../src
-  ../../../extern/glew/include ../../../intern/guardedalloc
+  ../../../extern/glew/include ../../../intern/guardedalloc ../freestyle
   ${PYTHON_INC}
   ${PNG_INC}
 )

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2009-08-04 00:00:05 UTC (rev 22198)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h	2009-08-04 00:40:36 UTC (rev 22199)
@@ -8,22 +8,16 @@
 extern "C" {
 #endif	
 	
-	typedef struct StyleModuleConf {
-		struct StyleModuleConf *next, *prev;
-		
-		char module_path[255];
-		short is_displayed;
-	} StyleModuleConf;
+	#include "DNA_listBase.h"
+	#include "DNA_scene_types.h"
 	
-	
 	extern short freestyle_is_initialized;
 	
 	extern float freestyle_viewpoint[3];
 	extern float freestyle_mv[4][4];
 	extern float freestyle_proj[4][4];
 	extern int freestyle_viewport[4];
-	
-	extern short freestyle_current_layer_number;
+
 	extern char* freestyle_current_module_path;
 	extern SceneRenderLayer* freestyle_current_layer;
 	extern ListBase* freestyle_modules;
@@ -32,13 +26,12 @@
 	extern float* freestyle_dkr_epsilon;
 	
 	// Rendering
-	void FRS_initialize();
+	void FRS_initialize( short select_layer );
 	void FRS_add_Freestyle(Render* re);
 	void FRS_exit();
 	
 	// Panel configuration
 	void FRS_select_layer( SceneRenderLayer* srl );
-	void FRS_delete_layer( SceneRenderLayer* srl, short isDestructor );
 	void FRS_add_module();
 	void FRS_delete_module(void *module_index_ptr, void *unused);
 	void FRS_move_up_module(void *module_index_ptr, void *unused);

Added: branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle_config.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle_config.h	                        (rev 0)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle_config.h	2009-08-04 00:40:36 UTC (rev 22199)
@@ -0,0 +1,17 @@
+#ifndef FRS_FREESTYLE_CONFIG_H
+#define FRS_FREESTYLE_CONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif	
+	
+	#include "DNA_scene_types.h"
+
+	void FRS_add_freestyle_config( SceneRenderLayer* srl );
+	void FRS_free_freestyle_config( SceneRenderLayer* srl );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp	2009-08-04 00:00:05 UTC (rev 22198)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp	2009-08-04 00:40:36 UTC (rev 22199)
@@ -15,19 +15,18 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_camera_types.h"
-#include "DNA_listBase.h"
-#include "DNA_scene_types.h"
+#include "DNA_freestyle_types.h"
 
 #include "BKE_global.h"
 #include "BLI_blenlib.h"
 #include "BIF_renderwin.h"
 #include "BPY_extern.h"
 
-#include "render_types.h"
 #include "renderpipeline.h"
 #include "pixelblending.h"
 
 #include "../../FRS_freestyle.h"
+#include "../../FRS_freestyle_config.h"
 
 	// Freestyle configuration
 	short freestyle_is_initialized = 0;
@@ -42,7 +41,6 @@
 	int freestyle_viewport[4];
 	
 	// Panel configuration
-	short freestyle_current_layer_number = 0;
 	char* freestyle_current_module_path = NULL;
 	SceneRenderLayer* freestyle_current_layer = NULL;
 
@@ -51,31 +49,13 @@
 	float* freestyle_sphere_radius;
 	float* freestyle_dkr_epsilon;
 	
-	class FreestylePanelConfigurationData {
-	public:
-		set<SceneRenderLayer*> layers;
-		map<SceneRenderLayer*, ListBase*> modules;
-		map<SceneRenderLayer*, int*> flags;
-		map<SceneRenderLayer*, float*> sphere_radius;
-		map<SceneRenderLayer*, float*> dkr_epsilon;
-		
-		FreestylePanelConfigurationData() {}
-		~FreestylePanelConfigurationData() {
-			set<SceneRenderLayer*>::iterator it;
-			
-			for( it=layers.begin(); it!=layers.end(); it++)
-				FRS_delete_layer( *it, 1 );
-		}
-	};
-	static FreestylePanelConfigurationData* panelConfig;
-	
 	string default_module_path;
 
 	//=======================================================
 	//   Initialization 
 	//=======================================================
 
-	void FRS_initialize(){
+	void FRS_initialize( short select_layer ){
 		
 		if( !freestyle_is_initialized ) {
 
@@ -83,27 +63,21 @@
 			controller = new Controller;
 			view = new AppView;
 			controller->setView(view);
-
-		} else {
-
-			delete panelConfig;
-
-		}
-
-		panelConfig = new FreestylePanelConfigurationData;
 			
-		default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py";
-		FRS_select_layer( (SceneRenderLayer*) BLI_findlink(&G.scene->r.layers, G.scene->r.actlay) );
+			default_module_path = pathconfig->getProjectDir() + Config::DIR_SEP + "style_modules" + Config::DIR_SEP + "contour.py";
 			
-		freestyle_is_initialized = 1;
+			freestyle_is_initialized = 1;
+		}
 		
+		if( select_layer )
+			FRS_select_layer( (SceneRenderLayer*) BLI_findlink(&G.scene->r.layers, G.scene->r.actlay) );
+		
 	}
-
+	
 	void FRS_exit() {
 		delete pathconfig;
 		delete controller;
 		delete view;
-		delete panelConfig;
 	}
 
 	//=======================================================
@@ -130,26 +104,6 @@
 		freestyle_viewpoint[1] = maincam_obj->obmat[3][1];
 		freestyle_viewpoint[2] = maincam_obj->obmat[3][2];
 		
-		// freestyle_mv[0][0] = maincam_obj->obmat[0][0];
-		// freestyle_mv[0][1] = maincam_obj->obmat[1][0];

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list