Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMaxime Curioni <maxime.curioni@gmail.com>2009-08-04 04:40:36 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2009-08-04 04:40:36 +0400
commitbd92aea926d66cdb2548fbdd7e8d8b28208fad6d (patch)
treea146154c1310427608a393d6325dcc3c1929765f /source
parentff110c17f705976435ee14f2cde9c85f7334a56c (diff)
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
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/SConscript1
-rw-r--r--source/blender/blenkernel/intern/scene.c11
-rw-r--r--source/blender/blenloader/intern/readfile.c7
-rw-r--r--source/blender/blenloader/intern/writefile.c10
-rw-r--r--source/blender/freestyle/CMakeLists.txt2
-rw-r--r--source/blender/freestyle/FRS_freestyle.h15
-rw-r--r--source/blender/freestyle/FRS_freestyle_config.h17
-rw-r--r--source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp155
-rwxr-xr-xsource/blender/freestyle/intern/geometry/GeomUtils.cpp18
-rwxr-xr-xsource/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp9
-rwxr-xr-xsource/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h1
-rw-r--r--source/blender/makesdna/DNA_freestyle_types.h28
-rw-r--r--source/blender/makesdna/DNA_scene_types.h14
-rw-r--r--source/blender/makesdna/intern/makesdna.c2
-rw-r--r--source/blender/render/intern/source/pipeline.c3
-rw-r--r--source/blender/src/buttons_scene.c14
-rw-r--r--source/blender/src/usiblender.c4
17 files changed, 172 insertions, 139 deletions
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index 4c5cd51b836..e5344cb2e07 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -11,6 +11,7 @@ incs += ' #/extern/bullet2/src'
incs += ' #/intern/bmfont'
incs += ' #/intern/opennl/extern'
incs += ' ../gpu #/extern/glew/include'
+incs += ' ../freestyle'
incs += ' ' + env['BF_OPENGL_INC']
incs += ' ' + env['BF_ZLIB_INC']
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 1727edc10fc..ffb3a7f5e4a 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -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 @@ void free_scene(Scene *sce)
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 @@ Scene *add_scene(char *name)
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 @@ void scene_add_render_layer(Scene *sce)
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
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3a9d0a6ae6a..f656f791f5d 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3682,6 +3682,11 @@ static void direct_link_scene(FileData *fd, Scene *sce)
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 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
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);
}
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 3c2ca92f3fc..f913656dd5f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1449,6 +1449,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
TimeMarker *marker;
TransformOrientation *ts;
SceneRenderLayer *srl;
+ FreestyleModuleConfig *fmc;
int a;
sce= scebase->first;
@@ -1525,7 +1526,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
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 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
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);
diff --git a/source/blender/freestyle/CMakeLists.txt b/source/blender/freestyle/CMakeLists.txt
index 0b78a4b7726..eb2569c4649 100644
--- a/source/blender/freestyle/CMakeLists.txt
+++ b/source/blender/freestyle/CMakeLists.txt
@@ -29,7 +29,7 @@ FILE(GLOB_RECURSE SRC *.cpp)
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}
)
diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h
index d3ab042f84b..cc52685663c 100644
--- a/source/blender/freestyle/FRS_freestyle.h
+++ b/source/blender/freestyle/FRS_freestyle.h
@@ -8,13 +8,8 @@
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;
@@ -22,8 +17,7 @@ extern "C" {
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 "C" {
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);
diff --git a/source/blender/freestyle/FRS_freestyle_config.h b/source/blender/freestyle/FRS_freestyle_config.h
new file mode 100644
index 00000000000..22ccd320e7e
--- /dev/null
+++ b/source/blender/freestyle/FRS_freestyle_config.h
@@ -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
diff --git a/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp b/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
index 34e6e31a177..cb0182850cb 100644
--- a/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
@@ -15,19 +15,18 @@ extern "C" {
#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 @@ extern "C" {
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 @@ extern "C" {
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 @@ extern "C" {
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 @@ extern "C" {
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];
- // freestyle_mv[0][2] = maincam_obj->obmat[2][0];
- // freestyle_mv[0][3] = 0.0;
- //
- // freestyle_mv[1][0] = maincam_obj->obmat[0][1];
- // freestyle_mv[1][1] = maincam_obj->obmat[1][1];
- // freestyle_mv[1][2] = maincam_obj->obmat[2][1];
- // freestyle_mv[1][3] = 0.0;
- //
- // freestyle_mv[2][0] = re->viewmat[2][0];
- // freestyle_mv[2][1] = re->viewmat[2][1];
- // freestyle_mv[2][2] = re->viewmat[2][2];
- // freestyle_mv[2][3] = 0.0;
- //
- // freestyle_mv[3][0] = re->viewmat[3][0];
- // freestyle_mv[3][1] = re->viewmat[3][1];
- // freestyle_mv[3][2] = re->viewmat[3][2];
- // freestyle_mv[3][3] = 1.0;
-
for( int i = 0; i < 4; i++ )
for( int j = 0; j < 4; j++ )
freestyle_mv[i][j] = re->viewmat[i][j];
@@ -157,13 +111,11 @@ extern "C" {
for( int i = 0; i < 4; i++ )
for( int j = 0; j < 4; j++ )
freestyle_proj[i][j] = re->winmat[i][j];
-
- //f(cam && (re->r.mode & R_ORTHO)) {
}
void prepare(Render* re, SceneRenderLayer* srl ) {
-
+
// clear canvas
controller->Clear();
@@ -172,10 +124,14 @@ extern "C" {
return;
// add style modules
+ FreestyleConfig* config = &srl->freestyleConfig;
+
cout << "\n=== Rendering options ===" << endl;
cout << "Modules :"<< endl;
int layer_count = 0;
- for( StyleModuleConf* module_conf = (StyleModuleConf *)panelConfig->modules[srl]->first; module_conf; module_conf = module_conf->next ) {
+
+
+ for( FreestyleModuleConfig* module_conf = (FreestyleModuleConfig *)config->modules.first; module_conf; module_conf = module_conf->next ) {
if( module_conf->is_displayed ) {
cout << " " << layer_count+1 << ": " << module_conf->module_path << endl;
controller->InsertStyleModule( layer_count, module_conf->module_path );
@@ -186,10 +142,10 @@ extern "C" {
cout << endl;
// set parameters
- controller->setSphereRadius(*panelConfig->sphere_radius[srl]);
- controller->setComputeRidgesAndValleysFlag((*panelConfig->flags[srl] & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
- controller->setComputeSuggestiveContoursFlag((*panelConfig->flags[srl] & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false);
- controller->setSuggestiveContourKrDerivativeEpsilon(*panelConfig->dkr_epsilon[srl]);
+ controller->setSphereRadius( config->sphere_radius );
+ controller->setComputeRidgesAndValleysFlag( (config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
+ controller->setComputeSuggestiveContoursFlag( (config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false);
+ controller->setSuggestiveContourKrDerivativeEpsilon( config->dkr_epsilon ) ;
cout << "Sphere radius : " << controller->getSphereRadius() << endl;
cout << "Redges and valleys : " << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled") << endl;
@@ -236,11 +192,8 @@ extern "C" {
int displayed_layer_count( SceneRenderLayer* srl ) {
int count = 0;
-
- if( panelConfig->layers.find(srl) == panelConfig->layers.end() )
- return 0;
- for( StyleModuleConf* module_conf = (StyleModuleConf *)panelConfig->modules[srl]->first; module_conf; module_conf = module_conf->next ) {
+ for( FreestyleModuleConfig* module_conf = (FreestyleModuleConfig *)srl->freestyleConfig.modules.first; module_conf; module_conf = module_conf->next ) {
if( module_conf->is_displayed )
count++;
}
@@ -257,6 +210,7 @@ extern "C" {
cout << "# Freestyle" << endl;
cout << "#===============================================================" << endl;
+ FRS_initialize( 0 );
init_view(re);
init_camera(re);
@@ -300,50 +254,37 @@ extern "C" {
// Freestyle Panel Configuration
//=======================================================
- void FRS_select_layer( SceneRenderLayer* srl )
- {
- if( panelConfig->layers.find(srl) == panelConfig->layers.end() )
- {
- panelConfig->layers.insert(srl);
-
- panelConfig->modules[srl] = new ListBase;
- panelConfig->modules[srl]->first = panelConfig->modules[srl]->last = NULL;
-
- panelConfig->flags[srl] = new int(0);
- panelConfig->sphere_radius[srl] = new float(1.0);
- panelConfig->dkr_epsilon[srl] = new float(0.001);
- }
+ void FRS_add_freestyle_config( SceneRenderLayer* srl )
+ {
+ FreestyleConfig* config = &srl->freestyleConfig;
- freestyle_modules = panelConfig->modules[srl];
- freestyle_flags = panelConfig->flags[srl];
- freestyle_sphere_radius = panelConfig->sphere_radius[srl];
- freestyle_dkr_epsilon = panelConfig->dkr_epsilon[srl];
-
- freestyle_current_layer = srl;
- freestyle_current_layer_number = BLI_findindex(&G.scene->r.layers, freestyle_current_layer);
+ config->modules.first = config->modules.last = NULL;
+ config->flags = 0;
+ config->sphere_radius = 1.0;
+ config->dkr_epsilon = 0.001;
+ }
+
+ void FRS_free_freestyle_config( SceneRenderLayer* srl )
+ {
+ BLI_freelistN( &srl->freestyleConfig.modules );
}
- void FRS_delete_layer( SceneRenderLayer* srl, short isDestructor )
- {
- BLI_freelistN( panelConfig->modules[srl] );
- delete panelConfig->modules[srl];
-
- delete panelConfig->flags[srl];
- delete panelConfig->sphere_radius[srl];
- delete panelConfig->dkr_epsilon[srl];
+ void FRS_select_layer( SceneRenderLayer* srl )
+ {
+ FreestyleConfig* config = &srl->freestyleConfig;
- panelConfig->modules.erase(srl);
- panelConfig->flags.erase(srl);
- panelConfig->sphere_radius.erase(srl);
- panelConfig->dkr_epsilon.erase(srl);
+ freestyle_modules = &config->modules;
+ freestyle_flags = &config->flags;
+ freestyle_sphere_radius = &config->sphere_radius;
+ freestyle_dkr_epsilon = &config->dkr_epsilon;
- if( !isDestructor )
- panelConfig->layers.erase(srl);
+ freestyle_current_layer = srl;
+ G.scene->freestyle_current_layer_number = BLI_findindex(&G.scene->r.layers, freestyle_current_layer);
}
void FRS_add_module()
{
- StyleModuleConf* module_conf = (StyleModuleConf*) MEM_callocN( sizeof(StyleModuleConf), "style module configuration");
+ FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) MEM_callocN( sizeof(FreestyleModuleConfig), "style module configuration");
BLI_addtail(freestyle_modules, (void*) module_conf);
strcpy( module_conf->module_path, default_module_path.c_str() );
@@ -352,14 +293,14 @@ extern "C" {
void FRS_delete_module(void *module_index_ptr, void *unused)
{
- StyleModuleConf* module_conf = (StyleModuleConf*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
+ FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
BLI_freelinkN( freestyle_modules, module_conf);
}
void FRS_move_up_module(void *module_index_ptr, void *unused)
{
- StyleModuleConf* module_conf = (StyleModuleConf*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
+ FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
BLI_remlink(freestyle_modules, module_conf);
BLI_insertlink(freestyle_modules, module_conf->prev->prev, module_conf);
@@ -367,7 +308,7 @@ extern "C" {
void FRS_move_down_module(void *module_index_ptr, void *unused)
{
- StyleModuleConf* module_conf = (StyleModuleConf*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
+ FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
BLI_remlink(freestyle_modules, module_conf);
BLI_insertlink(freestyle_modules, module_conf->next, module_conf);
@@ -375,7 +316,7 @@ extern "C" {
void FRS_set_module_path(void *module_index_ptr, void *unused)
{
- StyleModuleConf* module_conf = (StyleModuleConf*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
+ FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr);
freestyle_current_module_path = module_conf->module_path;
}
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
index fd36e81ca77..88aafeed598 100755
--- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp
+++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp
@@ -619,11 +619,21 @@ namespace GeomUtils {
void fromRetinaToCamera(const Vec3r& p,
Vec3r& q,
- real z,
+ real focal,
const real projection_matrix[4][4]) {
- q[0] = (-p[0] * z) / projection_matrix[0][0];
- q[1] = (-p[1] * z) / projection_matrix[1][1];
- q[2] = z;
+
+ if( projection_matrix[3][3] == 0.0 ) // perspective
+ {
+ q[0] = (-p[0] * focal) / projection_matrix[0][0];
+ q[1] = (-p[1] * focal) / projection_matrix[1][1];
+ q[2] = focal;
+ }
+ else // orthogonal
+ {
+ q[0] = p[0] / projection_matrix[0][0];
+ q[1] = p[1] / projection_matrix[1][1];
+ q[2] = focal;
+ }
}
void fromCameraToWorld(const Vec3r& p,
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
index 33c1115e94f..ecb0a4979f0 100755
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.cpp
@@ -52,7 +52,8 @@ real SilhouetteGeomEngine::_glModelViewMatrix[4][4] = {{1,0,0,0},
{0,0,0,1}};
real SilhouetteGeomEngine::_znear = 0.0;
real SilhouetteGeomEngine::_zfar = 100.0;
-
+bool SilhouetteGeomEngine::_isOrthographicProjection = false;
+
SilhouetteGeomEngine * SilhouetteGeomEngine::_pInstance = 0;
void SilhouetteGeomEngine::setTransform(const real iModelViewMatrix[4][4], const real iProjectionMatrix[4][4], const int iViewport[4], real iFocal)
@@ -91,6 +92,8 @@ void SilhouetteGeomEngine::setTransform(const real iModelViewMatrix[4][4], const
_viewport[i] = iViewport[i];
}
_Focal = iFocal;
+
+ _isOrthographicProjection = (iProjectionMatrix[3][3] != 0.0);
}
void SilhouetteGeomEngine::setFrustum(real iZNear, real iZFar)
@@ -146,6 +149,10 @@ void SilhouetteGeomEngine::ProjectSilhouette(SVertex* ioVertex)
real SilhouetteGeomEngine::ImageToWorldParameter(FEdge *fe, real t)
{
+
+ if( _isOrthographicProjection )
+ return t;
+
// we need to compute for each parameter t the corresponding
// parameter T which gives the intersection in 3D.
//currentEdge = (*fe);
diff --git a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
index 9638d26986f..5bd89f8a162 100755
--- a/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
+++ b/source/blender/freestyle/intern/view_map/SilhouetteGeomEngine.h
@@ -59,6 +59,7 @@ private:
static real _glProjectionMatrix[4][4]; // GL style (column major) projection matrix
static real _glModelViewMatrix[4][4]; // GL style (column major) model view matrix
+static bool _isOrthographicProjection;
static SilhouetteGeomEngine *_pInstance;
diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h
new file mode 100644
index 00000000000..14c59d5adb2
--- /dev/null
+++ b/source/blender/makesdna/DNA_freestyle_types.h
@@ -0,0 +1,28 @@
+#ifndef DNA_FREESTYLE_TYPES_H
+#define DNA_FREESTYLE_TYPES_H
+
+#include "DNA_listBase.h"
+
+typedef struct FreestyleModuleConfig {
+ struct FreestyleModuleConfig *next, *prev;
+
+ char module_path[256];
+ short is_displayed;
+ short pad[3];
+
+} FreestyleModuleConfig;
+
+typedef struct FreestyleConfig {
+ ListBase modules;
+
+ int flags;
+ float sphere_radius;
+ float dkr_epsilon;
+ int pad;
+
+} FreestyleConfig;
+
+
+
+#endif
+
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 266340c9101..a1f911eeffd 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -38,6 +38,7 @@ extern "C" {
#include "DNA_scriptlink_types.h"
#include "DNA_ID.h"
#include "DNA_scriptlink_types.h"
+#include "DNA_freestyle_types.h"
struct Radio;
struct Object;
@@ -47,6 +48,7 @@ struct Image;
struct Group;
struct bNodeTree;
+
typedef struct Base {
struct Base *next, *prev;
unsigned int lay, selcol;
@@ -125,6 +127,9 @@ typedef struct SceneRenderLayer {
int passflag; /* pass_xor has to be after passflag */
int pass_xor;
+
+ struct FreestyleConfig freestyleConfig;
+
} SceneRenderLayer;
/* srl->layflag */
@@ -448,7 +453,8 @@ typedef struct ToolSettings {
/* Alt+RMB option */
char edge_mode;
-} ToolSettings;
+
+} ToolSettings;
/* Used by all brushes to store their properties, which can be directly set
by the interface code. Note that not all properties are actually used by
@@ -565,7 +571,11 @@ typedef struct Scene {
/* frame step. */
int frame_step;
- int pad;
+
+ /* Freestyle */
+ short freestyle_current_layer_number;
+ short pad;
+
} Scene;
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index b4deb1f2b60..beb680ec8b9 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -129,6 +129,7 @@ char *includefiles[] = {
"DNA_particle_types.h",
"DNA_cloth_types.h",
"DNA_gpencil_types.h",
+ "DNA_freestyle_types.h",
// if you add files here, please add them at the end
// of makesdna.c (this file) as well
@@ -1151,4 +1152,5 @@ int main(int argc, char ** argv)
#include "DNA_particle_types.h"
#include "DNA_cloth_types.h"
#include "DNA_gpencil_types.h"
+#include "DNA_freestyle_types.h"
/* end of list */
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 12dcd812a04..298cf30fa5a 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -72,7 +72,7 @@
#endif /* disable yafray */
#include "FRS_freestyle.h"
-
+#include "FRS_freestyle_config.h"
/* internal */
#include "render_types.h"
@@ -592,6 +592,7 @@ static RenderResult *new_render_result(Render *re, rcti *partrct, int crop, int
rl->lay= (1<<20) -1;
rl->layflag= 0x7FFF; /* solid ztra halo strand */
rl->passflag= SCE_PASS_COMBINED;
+ FRS_add_freestyle_config( srl );
re->r.actlay= 0;
}
diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c
index 9d4ff9db960..f8889827f95 100644
--- a/source/blender/src/buttons_scene.c
+++ b/source/blender/src/buttons_scene.c
@@ -122,6 +122,8 @@ extern void makeffmpegstring(char* string);
#endif
#include "FRS_freestyle.h"
+#include "FRS_freestyle_config.h"
+#include "DNA_freestyle_types.h"
/* here the calls for scene buttons
- render
@@ -1744,7 +1746,7 @@ void do_render_panels(unsigned short event)
#endif
case B_FRS_SELECT_RENDER_LAYER:
- FRS_select_layer( BLI_findlink(&G.scene->r.layers, freestyle_current_layer_number ) );
+ FRS_select_layer( BLI_findlink(&G.scene->r.layers, G.scene->freestyle_current_layer_number ) );
allqueue(REDRAWBUTSSCENE, 0);
break;
@@ -3314,7 +3316,7 @@ static void render_panel_freestyle()
uiBut *bt;
int module_list_y;
- StyleModuleConf* module_conf;
+ FreestyleModuleConfig* module_conf;
int module_number, last_module_number;
// block
@@ -3331,7 +3333,7 @@ static void render_panel_freestyle()
}
uiDefBut(block, LABEL, 0, "Render Layer:", 10,210,100,20, NULL, 0, 0, 0, 0, "");
- uiDefButS(block, MENU, B_FRS_SELECT_RENDER_LAYER, str, 110,210,200,20, &freestyle_current_layer_number, 0, 0, 0, 0, "Settings for current Render Layer");
+ uiDefButS(block, MENU, B_FRS_SELECT_RENDER_LAYER, str, 110,210,200,20, &G.scene->freestyle_current_layer_number, 0, 0, 0, 0, "Settings for current Render Layer");
MEM_freeN(str);
// label to force a boundbox for buttons not to be centered
@@ -3398,16 +3400,16 @@ static void delete_scene_layer_func(void *srl_v, void *act_i)
intptr_t act= (intptr_t)act_i;
int deleted_layer = G.scene->r.actlay;
- FRS_delete_layer( BLI_findlink(&G.scene->r.layers, deleted_layer), 0 );
+ FRS_free_freestyle_config( BLI_findlink(&G.scene->r.layers, deleted_layer) );
BLI_remlink(&G.scene->r.layers, srl_v);
MEM_freeN(srl_v);
G.scene->r.actlay = 0;
- if( deleted_layer == freestyle_current_layer_number ) {
+ if( deleted_layer == G.scene->freestyle_current_layer_number ) {
FRS_select_layer( BLI_findlink(&G.scene->r.layers, G.scene->r.actlay) );
} else {
- freestyle_current_layer_number = BLI_findindex(&G.scene->r.layers, freestyle_current_layer);
+ G.scene->freestyle_current_layer_number = BLI_findindex(&G.scene->r.layers, freestyle_current_layer);
}
if(G.scene->nodetree) {
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index 5cd369ea937..7a7a601c01d 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -605,7 +605,7 @@ void BIF_read_file(char *name)
if (retval!=0) G.relbase_valid = 1;
- FRS_initialize();
+ FRS_initialize( 1 );
undo_editmode_clear();
undo_imagepaint_clear();
@@ -681,7 +681,7 @@ int BIF_read_homefile(int from_memory)
init_userdef_file();
- FRS_initialize();
+ FRS_initialize( 1 );
undo_editmode_clear();
undo_imagepaint_clear();