Make freestyle use local Main for temporary objects
This means main database is no longer pollutes with temporary scene and objects needed for freestyle render. Actually, there're few of separated temporary mains now. Ideally it's better to use single one, but it's not so much trivial to pass it to all classes. Not so big deal actually. Required some changes to blender kernel, to make it possible to add object to a given main, also to check on mesh materials for objects in given main. This is all straightforward changes. As an additional, solved issue with main database being infinitely polluted with text blocks created by create_lineset_handler function. This fixes: - #35003: Freestyle crashes if user expands objects in FRS1_Scene - #35012: ctrl+f12 rendering crashes when using Freestyle
This commit is contained in:
@@ -49,7 +49,7 @@ struct Scene;
|
||||
void init_def_material(void);
|
||||
void BKE_material_free(struct Material *sc);
|
||||
void BKE_material_free_ex(struct Material *ma, int do_id_user);
|
||||
void test_object_materials(struct ID *id);
|
||||
void test_object_materials(struct Main *bmain, struct ID *id);
|
||||
void resize_object_material(struct Object *ob, const short totcol);
|
||||
void init_material(struct Material *ma);
|
||||
struct Material *BKE_material_add(struct Main *bmain, const char *name);
|
||||
|
||||
@@ -81,8 +81,8 @@ bool BKE_object_exists_check(struct Object *obtest);
|
||||
bool BKE_object_is_in_editmode(struct Object *ob);
|
||||
|
||||
struct Object *BKE_object_add_only_object(struct Main *bmain, int type, const char *name);
|
||||
struct Object *BKE_object_add(struct Scene *scene, int type);
|
||||
void *BKE_object_obdata_add_from_type(int type);
|
||||
struct Object *BKE_object_add(struct Main *bmain, struct Scene *scene, int type);
|
||||
void *BKE_object_obdata_add_from_type(struct Main *bmain, int type);
|
||||
|
||||
struct Object *BKE_object_copy_ex(struct Main *bmain, struct Object *ob, int copy_caches);
|
||||
struct Object *BKE_object_copy(struct Object *ob);
|
||||
|
||||
@@ -568,7 +568,7 @@ void material_append_id(ID *id, Material *ma)
|
||||
(*matar)[(*totcol)++] = ma;
|
||||
|
||||
id_us_plus((ID *)ma);
|
||||
test_object_materials(id);
|
||||
test_object_materials(G.main, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@ Material *material_pop_id(ID *id, int index_i, int remove_material_slot)
|
||||
MEM_freeN(*matar);
|
||||
|
||||
*matar = mat;
|
||||
test_object_materials(id);
|
||||
test_object_materials(G.main, id);
|
||||
}
|
||||
|
||||
/* decrease mat_nr index */
|
||||
@@ -712,7 +712,7 @@ void resize_object_material(Object *ob, const short totcol)
|
||||
if (ob->actcol > ob->totcol) ob->actcol = ob->totcol;
|
||||
}
|
||||
|
||||
void test_object_materials(ID *id)
|
||||
void test_object_materials(Main *bmain, ID *id)
|
||||
{
|
||||
/* make the ob mat-array same size as 'ob->data' mat-array */
|
||||
Object *ob;
|
||||
@@ -722,7 +722,7 @@ void test_object_materials(ID *id)
|
||||
return;
|
||||
}
|
||||
|
||||
for (ob = G.main->object.first; ob; ob = ob->id.next) {
|
||||
for (ob = bmain->object.first; ob; ob = ob->id.next) {
|
||||
if (ob->data == id) {
|
||||
resize_object_material(ob, *totcol);
|
||||
}
|
||||
@@ -768,7 +768,7 @@ void assign_material_id(ID *id, Material *ma, short act)
|
||||
if (ma)
|
||||
id_us_plus((ID *)ma);
|
||||
|
||||
test_object_materials(id);
|
||||
test_object_materials(G.main, id);
|
||||
}
|
||||
|
||||
void assign_material(Object *ob, Material *ma, short act, int assign_type)
|
||||
@@ -855,7 +855,7 @@ void assign_material(Object *ob, Material *ma, short act, int assign_type)
|
||||
|
||||
if (ma)
|
||||
id_us_plus((ID *)ma);
|
||||
test_object_materials(ob->data);
|
||||
test_object_materials(G.main, ob->data);
|
||||
}
|
||||
|
||||
/* XXX - this calls many more update calls per object then are needed, could be optimized */
|
||||
|
||||
@@ -841,7 +841,7 @@ void BKE_mesh_assign_object(Object *ob, Mesh *me)
|
||||
id_us_plus((ID *)me);
|
||||
}
|
||||
|
||||
test_object_materials((ID *)me);
|
||||
test_object_materials(G.main, (ID *)me);
|
||||
|
||||
test_object_modifiers(ob);
|
||||
}
|
||||
|
||||
@@ -845,19 +845,19 @@ bool BKE_object_exists_check(Object *obtest)
|
||||
|
||||
/* *************************************************** */
|
||||
|
||||
void *BKE_object_obdata_add_from_type(int type)
|
||||
void *BKE_object_obdata_add_from_type(Main *bmain, int type)
|
||||
{
|
||||
switch (type) {
|
||||
case OB_MESH: return BKE_mesh_add(G.main, "Mesh");
|
||||
case OB_CURVE: return BKE_curve_add(G.main, "Curve", OB_CURVE);
|
||||
case OB_SURF: return BKE_curve_add(G.main, "Surf", OB_SURF);
|
||||
case OB_FONT: return BKE_curve_add(G.main, "Text", OB_FONT);
|
||||
case OB_MBALL: return BKE_mball_add(G.main, "Meta");
|
||||
case OB_CAMERA: return BKE_camera_add(G.main, "Camera");
|
||||
case OB_LAMP: return BKE_lamp_add(G.main, "Lamp");
|
||||
case OB_LATTICE: return BKE_lattice_add(G.main, "Lattice");
|
||||
case OB_ARMATURE: return BKE_armature_add(G.main, "Armature");
|
||||
case OB_SPEAKER: return BKE_speaker_add(G.main, "Speaker");
|
||||
case OB_MESH: return BKE_mesh_add(bmain, "Mesh");
|
||||
case OB_CURVE: return BKE_curve_add(bmain, "Curve", OB_CURVE);
|
||||
case OB_SURF: return BKE_curve_add(bmain, "Surf", OB_SURF);
|
||||
case OB_FONT: return BKE_curve_add(bmain, "Text", OB_FONT);
|
||||
case OB_MBALL: return BKE_mball_add(bmain, "Meta");
|
||||
case OB_CAMERA: return BKE_camera_add(bmain, "Camera");
|
||||
case OB_LAMP: return BKE_lamp_add(bmain, "Lamp");
|
||||
case OB_LATTICE: return BKE_lattice_add(bmain, "Lattice");
|
||||
case OB_ARMATURE: return BKE_armature_add(bmain, "Armature");
|
||||
case OB_SPEAKER: return BKE_speaker_add(bmain, "Speaker");
|
||||
case OB_EMPTY: return NULL;
|
||||
default:
|
||||
printf("BKE_object_obdata_add_from_type: Internal error, bad type: %d\n", type);
|
||||
@@ -972,16 +972,16 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
|
||||
|
||||
/* general add: to scene, with layer from area and default name */
|
||||
/* creates minimum required data, but without vertices etc. */
|
||||
Object *BKE_object_add(struct Scene *scene, int type)
|
||||
Object *BKE_object_add(Main *bmain, Scene *scene, int type)
|
||||
{
|
||||
Object *ob;
|
||||
Base *base;
|
||||
char name[MAX_ID_NAME];
|
||||
|
||||
BLI_strncpy(name, get_obdata_defname(type), sizeof(name));
|
||||
ob = BKE_object_add_only_object(G.main, type, name);
|
||||
ob = BKE_object_add_only_object(bmain, type, name);
|
||||
|
||||
ob->data = BKE_object_obdata_add_from_type(type);
|
||||
ob->data = BKE_object_obdata_add_from_type(bmain, type);
|
||||
|
||||
ob->lay = scene->lay;
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ Object *bc_add_object(Scene *scene, int type, const char *name)
|
||||
{
|
||||
Object *ob = BKE_object_add_only_object(G.main, type, name);
|
||||
|
||||
ob->data = BKE_object_obdata_add_from_type(type);
|
||||
ob->data = BKE_object_obdata_add_from_type(G.main, type);
|
||||
ob->lay = scene->lay;
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_font.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_report.h"
|
||||
|
||||
@@ -439,6 +440,7 @@ void FONT_OT_file_paste(wmOperatorType *ot)
|
||||
|
||||
static void txt_add_object(bContext *C, TextLine *firstline, int totline, float offset[3])
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Curve *cu;
|
||||
Object *obedit;
|
||||
@@ -447,7 +449,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float
|
||||
int nchars = 0, a;
|
||||
float rot[3] = {0.f, 0.f, 0.f};
|
||||
|
||||
obedit = BKE_object_add(scene, OB_FONT);
|
||||
obedit = BKE_object_add(bmain, scene, OB_FONT);
|
||||
base = scene->basact;
|
||||
|
||||
/* seems to assume view align ? TODO - look into this, could be an operator option */
|
||||
|
||||
@@ -537,7 +537,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
|
||||
if (matmap) MEM_freeN(matmap);
|
||||
|
||||
/* other mesh users */
|
||||
test_object_materials((ID *)me);
|
||||
test_object_materials(bmain, (ID *)me);
|
||||
|
||||
/* free temp copy of destination shapekeys (if applicable) */
|
||||
if (nkey) {
|
||||
|
||||
@@ -376,7 +376,7 @@ Object *ED_object_add_type(bContext *C, int type, const float loc[3], const floa
|
||||
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */
|
||||
|
||||
/* deselects all, sets scene->basact */
|
||||
ob = BKE_object_add(scene, type);
|
||||
ob = BKE_object_add(bmain, scene, type);
|
||||
BASACT->lay = ob->lay = layer;
|
||||
/* editor level activate, notifiers */
|
||||
ED_base_object_activate(C, BASACT);
|
||||
|
||||
@@ -1572,12 +1572,13 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o
|
||||
|
||||
/* if still not found, add a new empty to act as a target (if allowed) */
|
||||
if ((found == 0) && (add)) {
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Base *base = BASACT, *newbase = NULL;
|
||||
Object *obt;
|
||||
|
||||
/* add new target object */
|
||||
obt = BKE_object_add(scene, OB_EMPTY);
|
||||
obt = BKE_object_add(bmain, scene, OB_EMPTY);
|
||||
|
||||
/* set layers OK */
|
||||
newbase = BASACT;
|
||||
|
||||
@@ -438,12 +438,12 @@ static int hook_op_edit_poll(bContext *C)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Object *add_hook_object_new(Scene *scene, Object *obedit)
|
||||
static Object *add_hook_object_new(Main *bmain, Scene *scene, Object *obedit)
|
||||
{
|
||||
Base *base, *basedit;
|
||||
Object *ob;
|
||||
|
||||
ob = BKE_object_add(scene, OB_EMPTY);
|
||||
ob = BKE_object_add(bmain, scene, OB_EMPTY);
|
||||
|
||||
basedit = BKE_scene_base_find(scene, obedit);
|
||||
base = BKE_scene_base_find(scene, ob);
|
||||
@@ -473,7 +473,7 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob
|
||||
|
||||
if (mode == OBJECT_ADDHOOK_NEWOB && !ob) {
|
||||
|
||||
ob = add_hook_object_new(scene, obedit);
|
||||
ob = add_hook_object_new(bmain, scene, obedit);
|
||||
|
||||
/* transform cent to global coords for loc */
|
||||
mul_v3_m4v3(ob->loc, obedit->obmat, cent);
|
||||
|
||||
@@ -464,7 +464,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *
|
||||
if (totvert == 0) return 0;
|
||||
|
||||
/* add new mesh */
|
||||
obn = BKE_object_add(scene, OB_MESH);
|
||||
obn = BKE_object_add(bmain, scene, OB_MESH);
|
||||
me = obn->data;
|
||||
|
||||
me->totvert = totvert;
|
||||
@@ -1721,8 +1721,7 @@ static void skin_armature_bone_create(Object *skin_ob,
|
||||
}
|
||||
}
|
||||
|
||||
static Object *modifier_skin_armature_create(struct Scene *scene,
|
||||
Object *skin_ob)
|
||||
static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object *skin_ob)
|
||||
{
|
||||
BLI_bitmap edges_visited;
|
||||
DerivedMesh *deform_dm;
|
||||
@@ -1745,7 +1744,7 @@ static Object *modifier_skin_armature_create(struct Scene *scene,
|
||||
NULL,
|
||||
me->totvert);
|
||||
|
||||
arm_ob = BKE_object_add(scene, OB_ARMATURE);
|
||||
arm_ob = BKE_object_add(bmain, scene, OB_ARMATURE);
|
||||
BKE_object_transform_copy(arm_ob, skin_ob);
|
||||
arm = arm_ob->data;
|
||||
arm->layer = 1;
|
||||
@@ -1815,7 +1814,7 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* create new armature */
|
||||
arm_ob = modifier_skin_armature_create(scene, ob);
|
||||
arm_ob = modifier_skin_armature_create(bmain, scene, ob);
|
||||
|
||||
/* add a modifier to connect the new armature to the mesh */
|
||||
arm_md = (ArmatureModifierData *)modifier_new(eModifierType_Armature);
|
||||
|
||||
@@ -344,7 +344,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op)
|
||||
char name[MAX_ID_NAME + 4];
|
||||
|
||||
/* Add new object for the proxy */
|
||||
newob = BKE_object_add(scene, OB_EMPTY);
|
||||
newob = BKE_object_add(bmain, scene, OB_EMPTY);
|
||||
|
||||
BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2);
|
||||
|
||||
@@ -1459,7 +1459,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
|
||||
ob_dst->data = id;
|
||||
|
||||
/* if amount of material indices changed: */
|
||||
test_object_materials(ob_dst->data);
|
||||
test_object_materials(bmain, ob_dst->data);
|
||||
|
||||
DAG_id_tag_update(&ob_dst->id, OB_RECALC_DATA);
|
||||
break;
|
||||
|
||||
@@ -64,6 +64,8 @@ namespace Freestyle {
|
||||
|
||||
BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : StrokeRenderer()
|
||||
{
|
||||
memset(&_freestyle_bmain, 0, sizeof(Main));
|
||||
|
||||
// TEMPORARY - need a texture manager
|
||||
_textureManager = new BlenderTextureManager;
|
||||
_textureManager->load();
|
||||
@@ -77,7 +79,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
|
||||
|
||||
char name[22];
|
||||
BLI_snprintf(name, sizeof(name), "FRS%d_%s", render_count, re->scene->id.name + 2);
|
||||
freestyle_scene = BKE_scene_add(G.main, name);
|
||||
freestyle_scene = BKE_scene_add(&_freestyle_bmain, name);
|
||||
freestyle_scene->r.cfra = old_scene->r.cfra;
|
||||
freestyle_scene->r.mode = old_scene->r.mode &
|
||||
~(R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR | R_BORDER);
|
||||
@@ -120,10 +122,10 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
|
||||
SceneRenderLayer *srl = (SceneRenderLayer *)freestyle_scene->r.layers.first;
|
||||
srl->layflag = SCE_LAY_SOLID | SCE_LAY_ZTRA;
|
||||
|
||||
BKE_scene_set_background(G.main, freestyle_scene);
|
||||
BKE_scene_set_background(&_freestyle_bmain, freestyle_scene);
|
||||
|
||||
// Camera
|
||||
Object *object_camera = BKE_object_add(freestyle_scene, OB_CAMERA);
|
||||
Object *object_camera = BKE_object_add(&_freestyle_bmain, freestyle_scene, OB_CAMERA);
|
||||
|
||||
Camera *camera = (Camera *)object_camera->data;
|
||||
camera->type = CAM_ORTHO;
|
||||
@@ -144,7 +146,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) : Str
|
||||
freestyle_scene->camera = object_camera;
|
||||
|
||||
// Material
|
||||
material = BKE_material_add(G.main, "stroke_material");
|
||||
material = BKE_material_add(&_freestyle_bmain, "stroke_material");
|
||||
material->mode |= MA_VERTEXCOLP;
|
||||
material->mode |= MA_TRANSP;
|
||||
material->mode |= MA_SHLESS;
|
||||
@@ -178,12 +180,12 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer()
|
||||
#endif
|
||||
switch (ob->type) {
|
||||
case OB_MESH:
|
||||
BKE_libblock_free(&G.main->object, ob);
|
||||
BKE_libblock_free(&G.main->mesh, data);
|
||||
BKE_libblock_free(&_freestyle_bmain.object, ob);
|
||||
BKE_libblock_free(&_freestyle_bmain.mesh, data);
|
||||
break;
|
||||
case OB_CAMERA:
|
||||
BKE_libblock_free(&G.main->object, ob);
|
||||
BKE_libblock_free(&G.main->camera, data);
|
||||
BKE_libblock_free(&_freestyle_bmain.object, ob);
|
||||
BKE_libblock_free(&_freestyle_bmain.camera, data);
|
||||
freestyle_scene->camera = NULL;
|
||||
break;
|
||||
default:
|
||||
@@ -193,9 +195,11 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer()
|
||||
BLI_freelistN(&freestyle_scene->base);
|
||||
|
||||
// release material
|
||||
BKE_libblock_free(&G.main->mat, material);
|
||||
BKE_libblock_free(&_freestyle_bmain.mat, material);
|
||||
|
||||
BKE_scene_set_background(G.main, old_scene);
|
||||
//BKE_scene_set_background(&_freestyle_bmain, old_scene);
|
||||
|
||||
BKE_scene_unlink(&_freestyle_bmain, freestyle_scene, NULL);
|
||||
}
|
||||
|
||||
float BlenderStrokeRenderer::get_stroke_vertex_z(void) const
|
||||
@@ -279,7 +283,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
|
||||
|
||||
//me = Mesh.New()
|
||||
#if 0
|
||||
Object *object_mesh = BKE_object_add(freestyle_scene, OB_MESH);
|
||||
Object *object_mesh = BKE_object_add(&_freestyle_bmain, freestyle_scene, OB_MESH);
|
||||
#else
|
||||
Object *object_mesh = NewMesh();
|
||||
#endif
|
||||
@@ -294,7 +298,7 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
|
||||
mesh->mat = (Material **)MEM_mallocN(1 * sizeof(Material *), "MaterialList");
|
||||
mesh->mat[0] = material;
|
||||
mesh->totcol = 1;
|
||||
test_object_materials((ID *)mesh);
|
||||
test_object_materials((Main *) &_freestyle_bmain, (ID *)mesh);
|
||||
#else
|
||||
assign_material(object_mesh, material, object_mesh->totcol + 1);
|
||||
object_mesh->actcol = object_mesh->totcol;
|
||||
@@ -481,9 +485,9 @@ Object *BlenderStrokeRenderer::NewMesh() const
|
||||
/* XXX this is for later review, for now we start names with 27 (DEL)
|
||||
to allow ignoring them in DAG_ids_check_recalc() */
|
||||
BLI_snprintf(name, MAX_ID_NAME, "%c0%08xOB", 27, mesh_id);
|
||||
ob = BKE_object_add_only_object(G.main, OB_MESH, name);
|
||||
ob = BKE_object_add_only_object((Main *) &_freestyle_bmain, OB_MESH, name);
|
||||
BLI_snprintf(name, MAX_ID_NAME, "%c0%08xME", 27, mesh_id);
|
||||
ob->data = BKE_mesh_add(G.main, name);
|
||||
ob->data = BKE_mesh_add((Main *) &_freestyle_bmain, name);
|
||||
ob->lay = 1;
|
||||
|
||||
base = BKE_scene_base_add(freestyle_scene, ob);
|
||||
@@ -511,7 +515,7 @@ Render *BlenderStrokeRenderer::RenderScene(Render *re)
|
||||
|
||||
Render *freestyle_render = RE_NewRender(freestyle_scene->id.name);
|
||||
|
||||
RE_RenderFreestyleStrokes(freestyle_render, G.main, freestyle_scene);
|
||||
RE_RenderFreestyleStrokes(freestyle_render, &_freestyle_bmain, freestyle_scene);
|
||||
return freestyle_render;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ extern "C" {
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BKE_main.h"
|
||||
|
||||
#include "render_types.h"
|
||||
}
|
||||
|
||||
@@ -52,6 +54,7 @@ public:
|
||||
Render *RenderScene(Render *re);
|
||||
|
||||
protected:
|
||||
Main _freestyle_bmain;
|
||||
Scene *old_scene;
|
||||
Scene *freestyle_scene;
|
||||
Material *material;
|
||||
|
||||
@@ -212,11 +212,11 @@ static char *escape_quotes(char *name)
|
||||
return s;
|
||||
}
|
||||
|
||||
static Text *create_lineset_handler(char *layer_name, char *lineset_name)
|
||||
static Text *create_lineset_handler(Main *bmain, char *layer_name, char *lineset_name)
|
||||
{
|
||||
char *s1 = escape_quotes(layer_name);
|
||||
char *s2 = escape_quotes(lineset_name);
|
||||
Text *text = BKE_text_add(G.main, lineset_name);
|
||||
Text *text = BKE_text_add(bmain, lineset_name);
|
||||
BKE_text_write(text, "import parameter_editor; parameter_editor.process('");
|
||||
BKE_text_write(text, s1);
|
||||
BKE_text_write(text, "', '");
|
||||
@@ -294,7 +294,7 @@ static bool test_edge_type_conditions(struct edge_type_condition *conditions,
|
||||
return true;
|
||||
}
|
||||
|
||||
static void prepare(Render *re, SceneRenderLayer *srl)
|
||||
static void prepare(Main *bmain, Render *re, SceneRenderLayer *srl)
|
||||
{
|
||||
// load mesh
|
||||
re->i.infostr = "Freestyle: Mesh loading";
|
||||
@@ -370,7 +370,7 @@ static void prepare(Render *re, SceneRenderLayer *srl)
|
||||
cout << " " << layer_count+1 << ": " << lineset->name << " - " <<
|
||||
lineset->linestyle->id.name + 2 << endl;
|
||||
}
|
||||
Text *text = create_lineset_handler(srl->name, lineset->name);
|
||||
Text *text = create_lineset_handler(bmain, srl->name, lineset->name);
|
||||
controller->InsertStyleModule(layer_count, lineset->name, text);
|
||||
controller->toggleLayer(layer_count, true);
|
||||
if (!(lineset->selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset->edge_types) {
|
||||
@@ -581,7 +581,9 @@ void FRS_init_stroke_rendering(Render *re)
|
||||
|
||||
Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl)
|
||||
{
|
||||
Main bmain = {0};
|
||||
Render *freestyle_render = NULL;
|
||||
Text *text, *next_text;
|
||||
|
||||
RenderMonitor monitor(re);
|
||||
controller->setRenderMonitor(&monitor);
|
||||
@@ -598,7 +600,7 @@ Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl)
|
||||
// - add style modules
|
||||
// - set parameters
|
||||
// - compute view map
|
||||
prepare(re, srl);
|
||||
prepare(&bmain, re, srl);
|
||||
|
||||
if (re->test_break(re->tbh)) {
|
||||
controller->CloseFile();
|
||||
@@ -626,6 +628,14 @@ Render *FRS_do_stroke_rendering(Render *re, SceneRenderLayer *srl)
|
||||
freestyle_render->result = NULL;
|
||||
}
|
||||
|
||||
// Free temp main (currently only text blocks are stored there)
|
||||
for (text = (Text *) bmain.text.first; text; text = next_text) {
|
||||
next_text = (Text *) text->id.next;
|
||||
|
||||
BKE_text_unlink(&bmain, text);
|
||||
BKE_libblock_free(&bmain.text, text);
|
||||
}
|
||||
|
||||
return freestyle_render;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,11 +83,11 @@ public:
|
||||
int status = BPY_filepath_exec(_context, fn, reports);
|
||||
#else
|
||||
int status;
|
||||
Text *text = BKE_text_load(G.main, fn, G.main->name);
|
||||
Text *text = BKE_text_load(&_freestyle_bmain, fn, G.main->name);
|
||||
if (text) {
|
||||
status = BPY_text_exec(_context, text, reports, false);
|
||||
BKE_text_unlink(G.main, text);
|
||||
BKE_libblock_free(&G.main->text, text);
|
||||
BKE_text_unlink(&_freestyle_bmain, text);
|
||||
BKE_libblock_free(&_freestyle_bmain.text, text);
|
||||
}
|
||||
else {
|
||||
BKE_reportf(reports, RPT_ERROR, "Cannot open file: %s", fn);
|
||||
@@ -151,6 +151,7 @@ public:
|
||||
|
||||
private:
|
||||
bContext *_context;
|
||||
Main _freestyle_bmain;
|
||||
|
||||
void initPath()
|
||||
{
|
||||
@@ -160,7 +161,7 @@ private:
|
||||
vector<string> pathnames;
|
||||
StringUtils::getPathName(_path, "", pathnames);
|
||||
|
||||
struct Text *text = BKE_text_add(G.main, "tmp_freestyle_initpath.txt");
|
||||
struct Text *text = BKE_text_add(&_freestyle_bmain, "tmp_freestyle_initpath.txt");
|
||||
string cmd = "import sys\n";
|
||||
txt_insert_buf(text, const_cast<char*>(cmd.c_str()));
|
||||
|
||||
@@ -177,8 +178,8 @@ private:
|
||||
BPY_text_exec(_context, text, NULL, false);
|
||||
|
||||
// cleaning up
|
||||
BKE_text_unlink(G.main, text);
|
||||
BKE_libblock_free(&G.main->text, text);
|
||||
BKE_text_unlink(&_freestyle_bmain, text);
|
||||
BKE_libblock_free(&_freestyle_bmain.text, text);
|
||||
|
||||
//PyRun_SimpleString("from Freestyle import *");
|
||||
_initialized = true;
|
||||
|
||||
@@ -198,7 +198,7 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char
|
||||
id_us_min(&ob->id);
|
||||
|
||||
ob->data = data;
|
||||
test_object_materials(ob->data);
|
||||
test_object_materials(bmain, ob->data);
|
||||
|
||||
return ob;
|
||||
}
|
||||
@@ -465,7 +465,7 @@ Mesh *rna_Main_meshes_new_from_object(
|
||||
}
|
||||
|
||||
/* make sure materials get updated in objects */
|
||||
test_object_materials(&tmpmesh->id);
|
||||
test_object_materials(bmain, &tmpmesh->id);
|
||||
|
||||
return tmpmesh;
|
||||
}
|
||||
|
||||
@@ -181,6 +181,7 @@ EnumPropertyItem object_axis_items[] = {
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_effect.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_material.h"
|
||||
@@ -396,7 +397,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value)
|
||||
}
|
||||
|
||||
ob->data = id;
|
||||
test_object_materials(id);
|
||||
test_object_materials(G.main, id);
|
||||
|
||||
if (GS(id->name) == ID_CU)
|
||||
BKE_curve_type_test(ob);
|
||||
|
||||
@@ -1058,7 +1058,7 @@ static void threaded_tile_processor(Render *re)
|
||||
|
||||
#ifdef WITH_FREESTYLE
|
||||
static void add_freestyle(Render *re);
|
||||
static void free_all_freestyle_renders(Scene *scene);
|
||||
static void free_all_freestyle_renders(void);
|
||||
#endif
|
||||
|
||||
/* currently only called by preview renders and envmap */
|
||||
@@ -1075,7 +1075,7 @@ void RE_TileProcessor(Render *re)
|
||||
if (!re->test_break(re->tbh)) {
|
||||
add_freestyle(re);
|
||||
|
||||
free_all_freestyle_renders(re->scene);
|
||||
free_all_freestyle_renders();
|
||||
|
||||
re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime;
|
||||
re->stats_draw(re->sdh, &re->i);
|
||||
@@ -1653,7 +1653,7 @@ static void composite_freestyle_renders(Render *re, int sample)
|
||||
}
|
||||
|
||||
/* releases temporary scenes and renders for Freestyle stroke rendering */
|
||||
static void free_all_freestyle_renders(Scene *scene)
|
||||
static void free_all_freestyle_renders(void)
|
||||
{
|
||||
Render *re1, *freestyle_render;
|
||||
LinkData *link;
|
||||
@@ -1662,7 +1662,6 @@ static void free_all_freestyle_renders(Scene *scene)
|
||||
for (link = (LinkData *)re1->freestyle_renders.first; link; link = link->next) {
|
||||
if (link->data) {
|
||||
freestyle_render = (Render *)link->data;
|
||||
BKE_scene_unlink(G.main, freestyle_render->scene, scene);
|
||||
RE_FreeRender(freestyle_render);
|
||||
}
|
||||
}
|
||||
@@ -1918,7 +1917,7 @@ static void do_render_composite_fields_blur_3d(Render *re)
|
||||
}
|
||||
|
||||
#ifdef WITH_FREESTYLE
|
||||
free_all_freestyle_renders(re->scene);
|
||||
free_all_freestyle_renders();
|
||||
#endif
|
||||
|
||||
/* weak... the display callback wants an active renderlayer pointer... */
|
||||
|
||||
Reference in New Issue
Block a user