[Bf-blender-cvs] [f4eae17] multiview: Multiview Base Commit 4/10: Everything else - integrating multiview in render pipeline

Dalai Felinto noreply at git.blender.org
Sat May 10 20:18:09 CEST 2014


Commit: f4eae173c25f478137cf52e63a999ea06f3fdc00
Author: Dalai Felinto
Date:   Sat May 10 14:58:10 2014 -0300
https://developer.blender.org/rBf4eae173c25f478137cf52e63a999ea06f3fdc00

Multiview Base Commit 4/10: Everything else - integrating multiview in
render pipeline

This is part of the multiview rebase from a github to git.blender.org
repository. The rebase was made based on file areas, so build is likely
broken in some of those parts, but it bulds fine in the end.

The documentation and sample files were removed and now live in:
https://github.com/dfelinto/multiview-samples

The original git history can be found in:
https://github.com/dfelinto/blender/tree/multiview-pre-b3d

Code contributors of the original branch in github:
* Alexey Akishin
* Gabriel Caraballo

Original design made in contribution with Francesco Siddi
Original branch and design partially reviewed by Brecht Van Lommel

===================================================================

M	source/blender/blenkernel/BKE_scene.h
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenkernel/intern/ocean.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/blenlib/BLI_path_util.h
M	source/blender/blenlib/intern/path_util.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/object/object_bake_api.c
M	source/blender/editors/render/render_intern.h
M	source/blender/editors/render/render_internal.c
M	source/blender/editors/render/render_opengl.c
M	source/blender/editors/render/render_ops.c
M	source/blender/editors/render/render_preview.c
M	source/blender/editors/render/render_shading.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/screen/screen_edit.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/screen/screendump.c
M	source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesdna/DNA_screen_types.h
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_render.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_scene_api.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/render/extern/include/RE_engine.h
M	source/blender/render/extern/include/RE_pipeline.h
M	source/blender/render/intern/include/render_result.h
M	source/blender/render/intern/include/render_types.h
M	source/blender/render/intern/source/convertblender.c
M	source/blender/render/intern/source/envmap.c
M	source/blender/render/intern/source/external_engine.c
M	source/blender/render/intern/source/initrender.c
M	source/blender/render/intern/source/pipeline.c
M	source/blender/render/intern/source/render_result.c
M	source/blender/render/intern/source/rendercore.c
M	source/blender/render/intern/source/zbuf.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index a10a3f3..a5cb359 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -122,6 +122,9 @@ void BKE_scene_update_for_newframe_ex(struct EvaluationContext *eval_ctx, struct
 struct SceneRenderLayer *BKE_scene_add_render_layer(struct Scene *sce, const char *name);
 bool BKE_scene_remove_render_layer(struct Main *main, struct Scene *scene, struct SceneRenderLayer *srl);
 
+struct SceneRenderView *BKE_scene_add_render_view(struct Scene *sce, const char *name);
+bool BKE_scene_remove_render_view(struct Scene *scene, struct SceneRenderView *srv);
+
 /* render profile */
 int get_render_subsurf_level(struct RenderData *r, int level);
 int get_render_child_particle_number(struct RenderData *r, int num);
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index ce1e34d..b97139f 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -3453,6 +3453,7 @@ static void registerCompositNodes(void)
 	register_node_type_cmp_bokehimage();
 	register_node_type_cmp_bokehblur();
 	register_node_type_cmp_switch();
+	register_node_type_cmp_switch_view();
 	register_node_type_cmp_pixelate();
 
 	register_node_type_cmp_mask();
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 373ad34..7a58ab4 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -1002,7 +1002,7 @@ static void cache_filename(char *string, const char *path, const char *relbase,
 
 	BLI_join_dirfile(cachepath, sizeof(cachepath), path, fname);
 
-	BKE_makepicstring_from_type(string, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, true, true);
+	BKE_makepicstring_from_type(string, cachepath, relbase, frame, R_IMF_IMTYPE_OPENEXR, true, true, "");
 }
 
 /* silly functions but useful to inline when the args do a lot of indirections */
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 0e95cf1..97890e9 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -147,14 +147,16 @@ Scene *BKE_scene_copy(Scene *sce, int type)
 	Base *base, *obase;
 	
 	if (type == SCE_COPY_EMPTY) {
-		ListBase lb;
+		ListBase rl, rv;
 		/* XXX. main should become an arg */
 		scen = BKE_scene_add(G.main, sce->id.name + 2);
 		
-		lb = scen->r.layers;
+		rl = scen->r.layers;
+		rv = scen->r.views;
 		scen->r = sce->r;
-		scen->r.layers = lb;
+		scen->r.layers = rl;
 		scen->r.actlay = 0;
+		scen->r.views = rv;
 		scen->unit = sce->unit;
 		scen->physics_settings = sce->physics_settings;
 		scen->gm = sce->gm;
@@ -187,6 +189,7 @@ Scene *BKE_scene_copy(Scene *sce, int type)
 		BLI_duplicatelist(&(scen->markers), &(sce->markers));
 		BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces));
 		BLI_duplicatelist(&(scen->r.layers), &(sce->r.layers));
+		BLI_duplicatelist(&(scen->r.views), &(sce->r.views));
 		BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets));
 
 		if (sce->nodetree) {
@@ -366,6 +369,7 @@ void BKE_scene_free(Scene *sce)
 	BLI_freelistN(&sce->markers);
 	BLI_freelistN(&sce->transform_spaces);
 	BLI_freelistN(&sce->r.layers);
+	BLI_freelistN(&sce->r.views);
 	
 	if (sce->toolsettings) {
 		if (sce->toolsettings->vpaint) {
@@ -413,6 +417,7 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
 	ParticleEditSettings *pset;
 	int a;
 	const char *colorspace_name;
+	SceneRenderView *srv;
 
 	sce = BKE_libblock_alloc(bmain, ID_SCE, name);
 	sce->lay = sce->layact = 1;
@@ -597,7 +602,16 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
 
 	/* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */
 	BKE_scene_add_render_layer(sce, NULL);
-	
+
+	/* multiview - stereo */
+	BKE_scene_add_render_view(sce, STEREO_LEFT_NAME);
+	srv = (SceneRenderView *)sce->r.views.first;
+	BLI_strncpy(srv->suffix, "_L", sizeof(srv->suffix));
+
+	BKE_scene_add_render_view(sce, STEREO_RIGHT_NAME);
+	srv = (SceneRenderView *)sce->r.views.last;
+	BLI_strncpy(srv->suffix, "_R", sizeof(srv->suffix));
+
 	/* game data */
 	sce->gm.stereoflag = STEREO_NOSTEREO;
 	sce->gm.stereomode = STEREO_ANAGLYPH;
@@ -1755,6 +1769,43 @@ bool BKE_scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *
 	return 1;
 }
 
+/* return default view */
+SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name)
+{
+	SceneRenderView *srv;
+
+	if (!name)
+		name = DATA_("RenderView");
+
+	srv = MEM_callocN(sizeof(SceneRenderView), "new render view");
+	BLI_strncpy(srv->name, name, sizeof(srv->name));
+	BLI_uniquename(&sce->r.views, srv, DATA_("RenderView"), '.', offsetof(SceneRenderView, name), sizeof(srv->name));
+	BLI_addtail(&sce->r.views, srv);
+
+	return srv;
+}
+
+bool BKE_scene_remove_render_view(Scene *scene, SceneRenderView *srv)
+{
+	const int act = BLI_findindex(&scene->r.views, srv);
+
+	if (act == -1) {
+		return false;
+	}
+	else if (scene->r.views.first == scene->r.views.last)
+	{
+		/* ensure 1 view is kept */
+		return false;
+	}
+
+	BLI_remlink(&scene->r.views, srv);
+	MEM_freeN(srv);
+
+	scene->r.actview = 0;
+
+	return true;
+}
+
 /* render simplification */
 
 int get_render_subsurf_level(RenderData *r, int lvl)
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index cf15b23..28d8828 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -2593,7 +2593,8 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
 			G.is_rendering = is_rendering;
 		}
 		
-		RE_AcquireResultImage(re, &rres);
+		/* XXX MV SEQ */
+		RE_AcquireResultImage(re, &rres, 0);
 		
 		if (rres.rectf) {
 			ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat);
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h
index 3e98e2c..54d865e 100644
--- a/source/blender/blenlib/BLI_path_util.h
+++ b/source/blender/blenlib/BLI_path_util.h
@@ -158,6 +158,7 @@ bool BLI_parent_dir(char *path) ATTR_NONNULL();
  * \retval Returns true if the path was relative (started with "//").
  */
 bool BLI_path_abs(char *path, const char *basepath)  ATTR_NONNULL();
+bool BLI_path_view(char *path, const char *view) ATTR_NONNULL();
 bool BLI_path_frame(char *path, int frame, int digits) ATTR_NONNULL();
 bool BLI_path_frame_range(char *path, int sta, int end, int digits) ATTR_NONNULL();
 bool BLI_path_frame_check_chars(const char *path) ATTR_NONNULL();
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 4226a04..b59d187 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -764,11 +764,11 @@ bool BLI_parent_dir(char *path)
 }
 
 /**
- * Looks for a sequence of "#" characters in the last slash-separated component of *path,
+ * Looks for a sequence of special characters (e.g., #, %) in the last slash-separated component of *path,
  * returning the indexes of the first and one past the last character in the sequence in
  * *char_start and *char_end respectively. Returns true if such a sequence was found.
  */
-static bool stringframe_chars(const char *path, int *char_start, int *char_end)
+static bool stringspecial_chars(const char *path, int *char_start, int *char_end, const char chr)
 {
 	unsigned int ch_sta, ch_end, i;
 	/* Insert current frame: file### -> file001 */
@@ -777,10 +777,10 @@ static bool stringframe_chars(const char *path, int *char_start, int *char_end)
 		if (path[i] == '\\' || path[i] == '/') {
 			ch_end = 0; /* this is a directory name, don't use any hashes we found */
 		}
-		else if (path[i] == '#') {
+		else if (path[i] == chr) {
 			ch_sta = i;
 			ch_end = ch_sta + 1;
-			while (path[ch_end] == '#') {
+			while (path[ch_end] == chr) {
 				ch_end++;
 			}
 			i = ch_end - 1; /* keep searching */
@@ -833,7 +833,7 @@ bool BLI_path_frame(char *path, int frame, int digits)
 	if (digits)
 		ensure_digits(path, digits);
 
-	if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
+	if (stringspecial_chars(path, &ch_sta, &ch_end, '#')) { /* warning, ch_end is the last # +1 */
 		char tmp[FILE_MAX];
 		BLI_snprintf(tmp, sizeof(tmp),
 		             "%.*s%.*d%s",
@@ -856,7 +856,7 @@ bool BLI_path_frame_range(char *path, int sta, int end, int digits)
 	if (digits)
 		ensure_digits(path, digits);
 
-	if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
+	if (stringspecial_chars(path, &ch_sta, &ch_end, '#')) { /* warning, ch_end is the last # +1 */
 		char tmp[FILE_MAX];
 		BLI_snprintf(tmp, sizeof(tmp),
 		             "%.*s%.*d-%.*d%s",
@@ -867,13 +867,88 @@ bool BLI_path_frame_range(char *path, int sta, int end, int digits)
 	return false;
 }
 
+/********************* multiview utils ********************/
+
+/**
+ * Ensure *path contains at least one "%" character in its last slash-separated
+ * component, appending one digits long if not.
+ */
+static void ensure_view(char *path)
+{
+	char *file = (char *)BLI_last_slash(path);
+
+	if (file == NULL)
+		file = path;
+
+	/* if there is no '%' try to add one before the '.' if any */
+	if (strrchr(file, '%') == NULL) {
+		int len = strlen(file);
+		char *period = strrchr(file, '.');
+
+		/* found a period */
+		if (period && period > file) {
+			char *p = file;
+			for (p=file+len+1; p > period; p--) {
+				*p = *(p-1);
+			}
+			*p = '%';
+		}
+		/* no period, just add it to the end*/
+		else {
+			file[len++] = '%';
+			file[len] = '\0';
+		}
+	}
+}
+
+/**
+ * Removes any  "%" character from path.
+ */
+static void strip_view_char(char *path)
+{
+	int i, j;
+
+	for (i = 0, j = 0; i < strlen(path); i++, j++) {
+		if (path[i] != '%')
+			path[j] = path[i];
+		else
+			j--;
+	}
+
+	path[j] = '\0';
+}
+
+/**
+ * Replaces "%" character sequence in last slash-separated component of *path
+ * with view name.
+ */
+bool BLI_path_view(char *path, const char *view)
+{
+	int ch_sta, ch_

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list