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
diff options
context:
space:
mode:
authorMaxime Curioni <maxime.curioni@gmail.com>2009-09-28 07:56:31 +0400
committerMaxime Curioni <maxime.curioni@gmail.com>2009-09-28 07:56:31 +0400
commit002ac28643a4dcadc63b8723e964107e06043cd0 (patch)
treedd26feed82935e3257e673445990ac9239ac2da1 /source/blender/freestyle
parent1ff038397fd3256c45899667bf1c3cba83947fa3 (diff)
Migration of Freestyle to Blender 2.5 codebase (continued):
- proper Freestyle initialization, with support for undo/redo - re-added FreestyleStyleConfig data structure - Freestyle Python interpreter updated This commit should compile without errors. More work is necessary to complete the migration: - add Freestyle in the UI - set up RNA support
Diffstat (limited to 'source/blender/freestyle')
-rw-r--r--source/blender/freestyle/FRS_freestyle.h6
-rw-r--r--source/blender/freestyle/SConscript4
-rwxr-xr-xsource/blender/freestyle/intern/app_blender/AppConfig.cpp4
-rwxr-xr-xsource/blender/freestyle/intern/app_blender/Controller.cpp2
-rw-r--r--source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp16
-rw-r--r--source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp16
-rw-r--r--source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h3
-rw-r--r--source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp47
-rw-r--r--source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.h4
-rwxr-xr-xsource/blender/freestyle/intern/stroke/StyleModule.h6
-rwxr-xr-xsource/blender/freestyle/intern/system/Interpreter.h2
-rwxr-xr-xsource/blender/freestyle/intern/system/PythonInterpreter.h53
12 files changed, 78 insertions, 85 deletions
diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h
index fe6a4426583..9d20c2c4763 100644
--- a/source/blender/freestyle/FRS_freestyle.h
+++ b/source/blender/freestyle/FRS_freestyle.h
@@ -11,6 +11,8 @@ extern "C" {
#include "DNA_listBase.h"
#include "DNA_scene_types.h"
+ #include "BKE_context.h"
+
extern short freestyle_is_initialized;
extern float freestyle_viewpoint[3];
@@ -26,8 +28,8 @@ extern "C" {
extern float* freestyle_dkr_epsilon;
// Rendering
- void FRS_initialize();
- void FRS_add_Freestyle(struct Render* re);
+ void FRS_initialize(bContext* C);
+ void FRS_add_Freestyle( struct Render* re);
void FRS_exit();
// Panel configuration
diff --git a/source/blender/freestyle/SConscript b/source/blender/freestyle/SConscript
index e83736551a7..4cff11f4b4c 100644
--- a/source/blender/freestyle/SConscript
+++ b/source/blender/freestyle/SConscript
@@ -6,7 +6,7 @@ sources = []
defs = []
incs = ''
-incs += '../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../python '
+incs += '../blenkernel ../blenloader ../blenlib ../imbuf ../makesdna ../makesrna ../python '
incs += '../render/extern/include ../render/intern/include ../include ../src'
incs += ' #/extern/glew/include #/intern/guardedalloc'
incs += ' ' + env['BF_PYTHON_INC']
@@ -67,7 +67,7 @@ env.BlenderLib (libname="bf_freestyle",
sources=sources,
includes=Split(incs),
defines=defs,
- libtype=['blender'],
+ libtype=['core'],
priority = [25]
)
diff --git a/source/blender/freestyle/intern/app_blender/AppConfig.cpp b/source/blender/freestyle/intern/app_blender/AppConfig.cpp
index 049eccb54a0..9d31d4660d4 100755
--- a/source/blender/freestyle/intern/app_blender/AppConfig.cpp
+++ b/source/blender/freestyle/intern/app_blender/AppConfig.cpp
@@ -25,7 +25,7 @@
using namespace std;
extern "C" {
- #include "api2_2x/EXPP_interface.h"
+ #include "BLI_util.h"
}
namespace Config {
@@ -33,7 +33,7 @@ Path* Path::_pInstance = 0;
Path::Path() {
// get the root directory
//soc
- setRootDir( bpy_gethome(1) );
+ setRootDir( BLI_gethome_folder("scripts") );
_pInstance = this;
}
diff --git a/source/blender/freestyle/intern/app_blender/Controller.cpp b/source/blender/freestyle/intern/app_blender/Controller.cpp
index bbd313ba989..b1ea43befef 100755
--- a/source/blender/freestyle/intern/app_blender/Controller.cpp
+++ b/source/blender/freestyle/intern/app_blender/Controller.cpp
@@ -656,7 +656,7 @@ void Controller::DrawStrokes()
}
Render* Controller::RenderStrokes(Render *re) {
- BlenderStrokeRenderer* blenderRenderer = new BlenderStrokeRenderer;
+ BlenderStrokeRenderer* blenderRenderer = new BlenderStrokeRenderer(re);
_Canvas->Render( blenderRenderer );
Render* freestyle_render = blenderRenderer->RenderScene(re);
delete blenderRenderer;
diff --git a/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp b/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
index 4483fb1e22d..b88e750687e 100644
--- a/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/app_blender/FRS_freestyle.cpp
@@ -17,9 +17,8 @@ extern "C" {
#include "DNA_camera_types.h"
#include "DNA_freestyle_types.h"
-#include "BKE_global.h"
+#include "BKE_main.h"
#include "BLI_blenlib.h"
-#include "BIF_renderwin.h"
#include "BPY_extern.h"
#include "renderpipeline.h"
@@ -33,6 +32,7 @@ extern "C" {
static Config::Path *pathconfig = NULL;
static Controller *controller = NULL;
static AppView *view = NULL;
+ static Scene *current_scene = NULL;
// camera information
float freestyle_viewpoint[3];
@@ -55,7 +55,7 @@ extern "C" {
// Initialization
//=======================================================
- void FRS_initialize(){
+ void FRS_initialize(bContext* C){
if( !freestyle_is_initialized ) {
@@ -69,7 +69,11 @@ extern "C" {
freestyle_is_initialized = 1;
}
- FRS_select_layer( (SceneRenderLayer*) BLI_findlink(&G.scene->r.layers, G.scene->r.actlay) );
+ current_scene = CTX_data_scene(C);
+ if( !current_scene )
+ current_scene = (Scene*) CTX_data_main(C)->scene.first;
+
+ FRS_select_layer( (SceneRenderLayer*) BLI_findlink(&current_scene->r.layers, current_scene->r.actlay) );
}
@@ -212,7 +216,7 @@ extern "C" {
init_view(re);
init_camera(re);
- for(srl= (SceneRenderLayer *)G.scene->r.layers.first; srl; srl= srl->next) {
+ for(srl= (SceneRenderLayer *)current_scene->r.layers.first; srl; srl= srl->next) {
if( !(srl->layflag & SCE_LAY_DISABLE) &&
srl->layflag & SCE_LAY_FRS &&
displayed_layer_count(srl) > 0 )
@@ -277,7 +281,7 @@ extern "C" {
freestyle_dkr_epsilon = &config->dkr_epsilon;
freestyle_current_layer = srl;
- G.scene->freestyle_current_layer_number = BLI_findindex(&G.scene->r.layers, freestyle_current_layer);
+ current_scene->freestyle_current_layer_number = BLI_findindex(&current_scene->r.layers, freestyle_current_layer);
}
void FRS_add_module()
diff --git a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp
index 4dc92755ad9..f70cdaf8720 100644
--- a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.cpp
@@ -66,7 +66,7 @@ void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
// M allows to recover world coordinates from camera coordinates
// M => obr->ob->imat * obr->obmat (multiplication from left to right)
float M[4][4];
- MTC_Mat4MulMat4(M, obr->ob->imat, obr->ob->obmat);
+ Mat4MulMat4(M, obr->ob->imat, obr->ob->obmat);
// We compute a normal per vertex and manages the smoothing of the shape:
// Lib3dsVector *normalL=(Lib3dsVector*)malloc(3*sizeof(Lib3dsVector)*mesh->faces);
@@ -128,7 +128,7 @@ void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
pvtmp[1] = obr->vertnodes[0].vert->co[1];
pvtmp[2] = obr->vertnodes[0].vert->co[2];
- MTC_Mat4MulVecfl( M, pvtmp);
+ Mat4MulVecfl( M, pvtmp);
minBBox[0] = pvtmp[0];
maxBBox[0] = pvtmp[0];
@@ -197,7 +197,7 @@ void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
//lib3ds_vector_transform(pv, M, mesh->pointL[f->points[i]].pos); //fills the cells of the pv array
for(j=0; j<3; j++)
pv[j] = fv[i]->co[j];
- MTC_Mat4MulVecfl( M, pv);
+ Mat4MulVecfl( M, pv);
for(j=0; j<3; j++) // we parse the xyz coordinates of the vertex i
{
@@ -234,8 +234,8 @@ void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
vec02[2] = pv_ptr[2][2] - pv_ptr[0][2];
float n[3];
- MTC_cross3Float(n, vec01, vec02);
- MTC_normalize3DF(n);
+ Crossf(n, vec01, vec02);
+ Normalize(n);
for(i=0; i<3; ++i) {
for(j=0; j<3; ++j) {
@@ -277,7 +277,7 @@ void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
//lib3ds_vector_transform(pv, M, mesh->pointL[f->points[i]].pos); //fills the cells of the pv array
for(j=0; j<3; j++)
pv[j] = fv[i]->co[j];
- MTC_Mat4MulVecfl( M, pv);
+ Mat4MulVecfl( M, pv);
for(j=0; j<3; j++) // we parse the xyz coordinates of the vertex i
{
@@ -314,8 +314,8 @@ void BlenderFileLoader::insertShapeNode(ObjectRen *obr, int id)
vec02[2] = pv_ptr[2][2] - pv_ptr[0][2];
float n[3];
- MTC_cross3Float(n, vec01, vec02);
- MTC_normalize3DF(n);
+ Crossf(n, vec01, vec02);
+ Normalize(n);
for(i=0; i<3; ++i) {
for(j=0; j<3; ++j) {
diff --git a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h
index ea5d9cb1a52..b17cde50443 100644
--- a/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h
+++ b/source/blender/freestyle/intern/scene_graph/BlenderFileLoader.h
@@ -24,8 +24,7 @@ extern "C" {
#include "BKE_mesh.h"
#include "BKE_scene.h"
- #include "MTC_matrixops.h"
- #include "MTC_vectorops.h"
+ #include "BLI_arithb.h"
#ifdef __cplusplus
}
diff --git a/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp
index 58d2bc5f77f..0be4fce4467 100644
--- a/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.cpp
@@ -17,10 +17,6 @@ extern "C" {
#include "DNA_meshdata_types.h"
#include "DNA_screen_types.h"
-#include "BIF_drawscene.h"
-#include "BIF_renderwin.h"
-#include "BIF_writeimage.h"
-
#include "BKE_customdata.h"
#include "BKE_global.h"
#include "BKE_library.h" /* free_libblock */
@@ -28,9 +24,6 @@ extern "C" {
#include "BKE_main.h" /* struct Main */
#include "BKE_object.h"
#include "BKE_scene.h"
-#include "BSE_sequence.h" /* to clear_scene_in_allseqs */
-#include "BSE_node.h" /* to clear_scene_in_nodes */
-#include "BSE_edit.h" /* countall */
#include "RE_pipeline.h"
@@ -39,9 +32,7 @@ extern "C" {
#endif
-
-
-BlenderStrokeRenderer::BlenderStrokeRenderer()
+BlenderStrokeRenderer::BlenderStrokeRenderer(Render* re)
:StrokeRenderer(){
// TEMPORARY - need a texture manager
@@ -49,23 +40,23 @@ BlenderStrokeRenderer::BlenderStrokeRenderer()
_textureManager->load();
// Scene.New("FreestyleStrokes")
- old_scene = G.scene;
+ old_scene = re->scene;
objects.first = objects.last = NULL;
ListBase lb;
- scene = add_scene("freestyle_strokes");
- lb = scene->r.layers;
- scene->r= old_scene->r;
- scene->r.layers= lb;
- set_scene_bg( scene );
+ freestyle_scene = add_scene("freestyle_strokes");
+ lb = freestyle_scene->r.layers;
+ freestyle_scene->r= old_scene->r;
+ freestyle_scene->r.layers= lb;
+ set_scene_bg( freestyle_scene );
// image dimensions
- float width = scene->r.xsch;
- float height = scene->r.ysch;
+ float width = freestyle_scene->r.xsch;
+ float height = freestyle_scene->r.ysch;
// Camera
- Object* object_camera = add_object(OB_CAMERA);
+ Object* object_camera = add_object(freestyle_scene, OB_CAMERA);
Camera* camera = (Camera *) object_camera->data;
camera->type = CAM_ORTHO;
@@ -75,7 +66,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer()
object_camera->loc[1] = 0.5 * height;
object_camera->loc[2] = 1.0;
- scene->camera = object_camera;
+ freestyle_scene->camera = object_camera;
store_object(object_camera);
@@ -94,7 +85,7 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer(){
}
// release scene
- free_libblock( &G.main->scene, scene );
+ free_libblock( &G.main->scene, freestyle_scene );
// release objects and data blocks
LinkData *link = (LinkData *)objects.first;
@@ -154,7 +145,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const{
++s){
// me = Mesh.New()
- Object* object_mesh = add_object(OB_MESH);
+ Object* object_mesh = add_object(freestyle_scene, OB_MESH);
Mesh* mesh = (Mesh *) object_mesh->data;
MEM_freeN(mesh->bb);
mesh->bb= NULL;
@@ -270,13 +261,13 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const{
}
Render* BlenderStrokeRenderer::RenderScene( Render *re ) {
- scene->r.mode &= ~( R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR );
- scene->r.scemode &= ~( R_SINGLE_LAYER );
- scene->r.planes = R_PLANES32;
- scene->r.imtype = R_PNG;
+ freestyle_scene->r.mode &= ~( R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR );
+ freestyle_scene->r.scemode &= ~( R_SINGLE_LAYER );
+ freestyle_scene->r.planes = R_PLANES32;
+ freestyle_scene->r.imtype = R_PNG;
- Render* freestyle_render = RE_NewRender(scene->id.name);
+ Render* freestyle_render = RE_NewRender(freestyle_scene->id.name);
- RE_BlenderFrame( freestyle_render, scene, 1);
+ RE_BlenderFrame( freestyle_render, freestyle_scene, 1);
return freestyle_render;
}
diff --git a/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.h b/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.h
index 2f7e192df5f..eafd58e0bab 100644
--- a/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.h
+++ b/source/blender/freestyle/intern/stroke/BlenderStrokeRenderer.h
@@ -23,7 +23,7 @@ extern "C" {
class LIB_STROKE_EXPORT BlenderStrokeRenderer : public StrokeRenderer
{
public:
- BlenderStrokeRenderer();
+ BlenderStrokeRenderer(Render *re);
virtual ~BlenderStrokeRenderer();
/*! Renders a stroke rep */
@@ -33,8 +33,8 @@ public:
Render* RenderScene(Render *re);
protected:
- Scene* scene;
Scene* old_scene;
+ Scene* freestyle_scene;
Material* material;
ListBase objects;
diff --git a/source/blender/freestyle/intern/stroke/StyleModule.h b/source/blender/freestyle/intern/stroke/StyleModule.h
index 53eb107ad00..c023ad7517b 100755
--- a/source/blender/freestyle/intern/stroke/StyleModule.h
+++ b/source/blender/freestyle/intern/stroke/StyleModule.h
@@ -68,9 +68,9 @@ public:
}
Operators::reset();
- int errorCode;
- if( (errorCode = _inter->interpretFile(_file_name)) ) {
- cerr << "Error: interpretation failed with code " << errorCode << endl;
+
+ if( _inter->interpretFile(_file_name) ) {
+ cerr << "Error: interpretation failed" << endl;
return NULL;
}
diff --git a/source/blender/freestyle/intern/system/Interpreter.h b/source/blender/freestyle/intern/system/Interpreter.h
index 45cb7793cfd..75aaa2ccd18 100755
--- a/source/blender/freestyle/intern/system/Interpreter.h
+++ b/source/blender/freestyle/intern/system/Interpreter.h
@@ -42,8 +42,6 @@ class LIB_SYSTEM_EXPORT Interpreter
virtual ~Interpreter() {}; //soc
- virtual int interpretCmd(const string& cmd) = 0;
-
virtual int interpretFile(const string& filename) = 0;
virtual string getLanguage() const { return _language; }
diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h
index fa796630b9a..810825e68cf 100755
--- a/source/blender/freestyle/intern/system/PythonInterpreter.h
+++ b/source/blender/freestyle/intern/system/PythonInterpreter.h
@@ -37,12 +37,14 @@
//soc
extern "C" {
+#include "MEM_guardedalloc.h"
#include "BKE_main.h"
+#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_report.h"
#include "BKE_text.h"
#include "BKE_library.h"
#include "BPY_extern.h"
-#include "BIF_drawtext.h"
}
class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter
@@ -58,35 +60,32 @@ class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter
//Py_Finalize();
}
- int interpretCmd(const string& cmd) {
- initPath();
- char* c_cmd = strdup(cmd.c_str());
- int err = PyRun_SimpleString(c_cmd);
- free(c_cmd);
- return err;
- }
-
int interpretFile(const string& filename) {
- initPath();
- char *fn = const_cast<char*>(filename.c_str());
- struct Text *text = add_text( fn );
+ bContext* C = CTX_create();
+ ReportList* reports = (ReportList*) MEM_mallocN(sizeof(ReportList), "freestyleExecutionReportList");
- if (text == NULL) {
- cout << "\nError in PythonInterpreter::interpretFile:" << endl;
- cout << "couldn't create Blender text from" << fn << endl;
- }
+ initPath(C);
+
+ BKE_reports_init(reports, RPT_ERROR);
+ char *fn = const_cast<char*>(filename.c_str());
- int status = BPY_txt_do_python_Text(text);
+ int status = BPY_run_python_script( C, fn, NULL, reports);
- // cleaning up
- unlink_text(text);
- free_libblock(&G.main->text, text);
-
if (status != 1) {
- cout << "\nError executing Python script from PythonInterpreter::interpretFile:" << endl;
- cout << fn << " (at line " << BPY_Err_getLinenumber() << ")" << endl;
- return BPY_Err_getLinenumber();
+ cout << "\nError executing Python script from PythonInterpreter::interpretFile" << endl;
+ cout << "File: " << fn << endl;
+ cout << "Errors: " << endl;
+ BKE_reports_print(reports, RPT_ERROR);
+ return 1;
+ }
+
+ // cleaning up
+ CTX_free( C );
+ BKE_reports_clear(reports);
+ if ((reports->flag & RPT_FREE) == 0)
+ {
+ MEM_freeN(reports);
}
return 0;
@@ -111,7 +110,7 @@ class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter
private:
- static void initPath() {
+ static void initPath(bContext* C) {
if (_initialized)
return;
@@ -130,10 +129,10 @@ private:
}
}
- BPY_txt_do_python_Text(text);
+ BPY_run_python_script( C, NULL, text, NULL);
// cleaning up
- unlink_text(text);
+ unlink_text(G.main, text);
free_libblock(&G.main->text, text);
//PyRun_SimpleString("from Freestyle import *");