[Bf-blender-cvs] [5e8c4ae] blender2.8: Barebones for viewport code apart from 2.7x drawing code

Dalai Felinto noreply at git.blender.org
Wed Oct 5 00:06:42 CEST 2016


Commit: 5e8c4ae75b20cd2e3e1ad7fc3f1437a2ca395b9c
Author: Dalai Felinto
Date:   Tue Oct 4 20:00:46 2016 +0000
Branches: blender2.8
https://developer.blender.org/rB5e8c4ae75b20cd2e3e1ad7fc3f1437a2ca395b9c

Barebones for viewport code apart from 2.7x drawing code

A new option (set in the properties region) allows the user to pick the
"new viewport" for the rendering  (in the UI: Modern Viewport).

For now we have a semi-blank file (view3d_draw.c) that can starts to take
over the drawing pipeline.

I can't guarantee we will be able to keep both drawing systems working
through the entire 2.8 development, but it should do for now.

also, we can use branches for some of the viewport development, but it's
better to keep things in 2.8 whenever we can, so people can test it.

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/space_view3d/CMakeLists.txt
M	source/blender/editors/space_view3d/view3d_draw.c
A	source/blender/editors/space_view3d/view3d_draw_legacy.c
M	source/blender/editors/space_view3d/view3d_header.c
M	source/blender/editors/space_view3d/view3d_intern.h
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 8501141..3b379df 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3090,7 +3090,7 @@ class VIEW3D_PT_view3d_display(Panel):
     @classmethod
     def poll(cls, context):
         view = context.space_data
-        return (view)
+        return (view) and not view.use_modern_viewport
 
     def draw(self, context):
         layout = self.layout
@@ -3188,6 +3188,11 @@ class VIEW3D_PT_view3d_shading(Panel):
     bl_region_type = 'UI'
     bl_label = "Shading"
 
+    @classmethod
+    def poll(cls, context):
+        view = context.space_data
+        return (view) and not view.use_modern_viewport
+
     def draw(self, context):
         layout = self.layout
 
@@ -3629,6 +3634,31 @@ class VIEW3D_PT_context_properties(Panel):
             rna_prop_ui.draw(self.layout, context, member, object, False)
 
 
+class VIEW3D_PT_viewport_debug(Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'UI'
+    bl_label = "..."
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        view = context.space_data
+        return (view)
+
+    def draw_header(self, context):
+        view = context.space_data
+        self.layout.prop(view, "use_modern_viewport")
+
+    def draw(self, context):
+        layout = self.layout
+        view = context.space_data
+
+        layout.active = view.use_modern_viewport
+
+        col = layout.column()
+        col.label(text="Placeholder for debugging options")
+
+
 def register():
     bpy.utils.register_module(__name__)
 
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index a5c6024..8fca2ed 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -52,6 +52,7 @@ set(SRC
 	view3d_buttons.c
 	view3d_camera_control.c
 	view3d_draw.c
+	view3d_draw_legacy.c
 	view3d_edit.c
 	view3d_fly.c
 	view3d_walk.c
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 422e0a9..559c0e7 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -28,4335 +28,25 @@
  *  \ingroup spview3d
  */
 
-#include <string.h>
-#include <stdio.h>
-#include <math.h>
-
-#include "DNA_armature_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_customdata_types.h"
-#include "DNA_object_types.h"
-#include "DNA_group_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_key_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_world_types.h"
-#include "DNA_brush_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
-#include "BLI_jitter.h"
-#include "BLI_utildefines.h"
-#include "BLI_endian_switch.h"
-#include "BLI_threads.h"
-
-#include "BKE_anim.h"
-#include "BKE_camera.h"
-#include "BKE_context.h"
-#include "BKE_customdata.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_image.h"
-#include "BKE_key.h"
-#include "BKE_main.h"
-#include "BKE_object.h"
-#include "BKE_global.h"
-#include "BKE_paint.h"
-#include "BKE_scene.h"
-#include "BKE_screen.h"
-#include "BKE_unit.h"
-#include "BKE_movieclip.h"
-
-#include "RE_engine.h"
-
-#include "IMB_imbuf_types.h"
-#include "IMB_imbuf.h"
-#include "IMB_colormanagement.h"
-
 #include "BIF_gl.h"
-#include "BIF_glutil.h"
 
-#include "WM_api.h"
-
-#include "BLF_api.h"
-#include "BLT_translation.h"
-
-#include "ED_armature.h"
-#include "ED_keyframing.h"
-#include "ED_gpencil.h"
 #include "ED_screen.h"
-#include "ED_space_api.h"
-#include "ED_screen_types.h"
-#include "ED_transform.h"
 
-#include "UI_interface.h"
-#include "UI_interface_icons.h"
-#include "UI_resources.h"
-
-#include "GPU_draw.h"
-#include "GPU_framebuffer.h"
-#include "GPU_material.h"
-#include "GPU_compositing.h"
-#include "GPU_extensions.h"
-#include "GPU_immediate.h"
+#include "BKE_context.h"
 
 #include "view3d_intern.h"  /* own include */
 
-/* prototypes */
-static void view3d_stereo3d_setup(Scene *scene, View3D *v3d, ARegion *ar);
-static void view3d_stereo3d_setup_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
-                                            float winmat[4][4], const char *viewname);
-
-/* handy utility for drawing shapes in the viewport for arbitrary code.
- * could add lines and points too */
-// #define DEBUG_DRAW
-#ifdef DEBUG_DRAW
-static void bl_debug_draw(void);
-/* add these locally when using these functions for testing */
-extern void bl_debug_draw_quad_clear(void);
-extern void bl_debug_draw_quad_add(const float v0[3], const float v1[3], const float v2[3], const float v3[3]);
-extern void bl_debug_draw_edge_add(const float v0[3], const float v1[3]);
-extern void bl_debug_color_set(const unsigned int col);
-#endif
-
-void circ(float x, float y, float rad)
-{
-	glBegin(GL_LINE_LOOP);
-	const int segments = 32;
-	for (int i = 0; i < segments; ++i) {
-		float angle = 2 * M_PI * ((float)i / (float)segments);
-		glVertex2f(x + rad * cosf(angle),
-		           y + rad * sinf(angle));
-	}
-	glEnd();
-}
-
-
-/* ********* custom clipping *********** */
-
-static void view3d_draw_clipping(RegionView3D *rv3d)
-{
-	BoundBox *bb = rv3d->clipbb;
-
-	if (bb) {
-		const unsigned int clipping_index[6][4] = {
-			{0, 1, 2, 3},
-			{0, 4, 5, 1},
-			{4, 7, 6, 5},
-			{7, 3, 2, 6},
-			{1, 5, 6, 2},
-			{7, 4, 0, 3}
-		};
-
-		/* fill in zero alpha for rendering & re-projection [#31530] */
-		unsigned char col[4];
-		UI_GetThemeColor4ubv(TH_V3D_CLIPPING_BORDER, col);
-		glColor4ubv(col);
-
-		glEnable(GL_BLEND);
-		glEnableClientState(GL_VERTEX_ARRAY);
-		glVertexPointer(3, GL_FLOAT, 0, bb->vec);
-		glDrawElements(GL_QUADS, sizeof(clipping_index) / sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index);
-		glDisableClientState(GL_VERTEX_ARRAY);
-		glDisable(GL_BLEND);
-	}
-}
-
-void ED_view3d_clipping_set(RegionView3D *rv3d)
-{
-	double plane[4];
-	const unsigned int tot = (rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6;
-	unsigned int a;
-
-	for (a = 0; a < tot; a++) {
-		copy_v4db_v4fl(plane, rv3d->clip[a]);
-		glClipPlane(GL_CLIP_PLANE0 + a, plane);
-		glEnable(GL_CLIP_PLANE0 + a);
-	}
-}
-
-/* use these to temp disable/enable clipping when 'rv3d->rflag & RV3D_CLIPPING' is set */
-void ED_view3d_clipping_disable(void)
-{
-	unsigned int a;
-
-	for (a = 0; a < 6; a++) {
-		glDisable(GL_CLIP_PLANE0 + a);
-	}
-}
-void ED_view3d_clipping_enable(void)
-{
-	unsigned int a;
-
-	for (a = 0; a < 6; a++) {
-		glEnable(GL_CLIP_PLANE0 + a);
-	}
-}
-
-static bool view3d_clipping_test(const float co[3], const float clip[6][4])
-{
-	if (plane_point_side_v3(clip[0], co) > 0.0f)
-		if (plane_point_side_v3(clip[1], co) > 0.0f)
-			if (plane_point_side_v3(clip[2], co) > 0.0f)
-				if (plane_point_side_v3(clip[3], co) > 0.0f)
-					return false;
-
-	return true;
-}
-
-/* for 'local' ED_view3d_clipping_local must run first
- * then all comparisons can be done in localspace */
-bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], const bool is_local)
-{
-	return view3d_clipping_test(co, is_local ? rv3d->clip_local : rv3d->clip);
-}
-
-/* ********* end custom clipping *********** */
-
-#define DEBUG_GRID 0
-
-static void gridline_range(double x0, double dx, double max, int* first_out, int* count_out)
-{
-	/* determine range of gridlines that appear in this Area -- similar calc but separate ranges for x & y
-	 * x0 is gridline 0, the axis in screen space
-	 * Area covers [0 .. max) pixels */
-
-	int first = (int)ceil(-x0 / dx);
-	int last = (int)floor((max - x0) / dx);
-
-	if (first <= last) {
-		*first_out = first;
-		*count_out = last - first + 1;
-	}
-	else {
-		*first_out = 0;
-		*count_out = 0;
-	}
-
-#if DEBUG_GRID
-	printf("   first %d * dx = %f\n", first, x0 + first * dx);
-	printf("   last %d * dx = %f\n", last, x0 + last * dx);
-	printf("   count = %d\n", *count_out);
-#endif
-}
-
-static int gridline_count(ARegion *ar, double x0, double y0, double dx)
-{
-	/* x0 & y0 establish the "phase" of the grid within this 2D region
-	 * dx is the frequency, shared by x & y directions
-	 * pass in dx of smallest (highest precision) grid we want to draw */
-
-#if DEBUG_GRID
-	printf("  %s(%f, %f, dx:%f)\n", __FUNCTION__, x0, y0, dx);
-#endif
-
-	int first, x_ct, y_ct;
-
-	gridline_range(x0, dx, ar->winx, &first, &x_ct);
-	gridline_range(y0, dx, ar->winy, &first, &y_ct);
-
-	int total_ct = x_ct + y_ct;
-
-#if DEBUG_GRID
-	printf("   %d + %d = %d gridlines\n", x_ct, y_ct, total_ct);
-#endif
-
-	return total_ct;
-}
-
-static bool drawgrid_draw(ARegion *ar, double x0, double y0, double dx, int skip_mod, unsigned pos, unsigned col, GLubyte col_value[3])
-{
-	/* skip every skip_mod lines relative to each axis; they will be overlaid by another drawgrid_draw
-	 * always skip exact x0 & y0 axes; they will be drawn later in color
-	 *
-	 * set grid color once, just before the first line is drawn
-	 * it's harmless to set same color for every line, or every vertex
-	 * but if no lines are drawn, color must not be set! */
-
-#if DEBUG_GRID
-	printf("  %s(%f, %f, dx:%f, skip_mod:%d)\n", __FUNCTION__, x0, y0, dx, skip_mod);
-#endif
-
-	const float x_max = (float)ar->winx;
-	const float y_max = (float)ar->winy;
-
-	int first, ct;
-	int x_ct = 0, y_ct = 0; /* count of lines actually drawn */
-	int lines_skipped_for_next_unit = 0;
-
-	/* draw vertical lines */
-	gridline_range(x0, dx, x_max, &first, &ct);
-
-	for (int i = first; i < first + ct; ++i) {
-		if (i == 0)
-			continue;
-		else if (skip_mod && (i % skip_mod) == 0) {
-			++lines_skipped_for_next_unit;
-			continue;
-		}
-
-		if (x_ct == 0)
-			immAttrib3ub(col, col_value[0], col_value[1], col_value[2]);
-
-		float x = (float)(x0 + i * dx);
-		immVertex2f(pos, x, 0.0f);
-		immVertex2f(pos, x, y_max);
-		++x_ct;
-	}
-
-	/* draw horizontal lines */
-	gridline_range(y0, dx, y_max, &first, &ct);
-
-	for (int i = first; i < first + ct; ++i) {
-		if (i == 0)
-			continue;
-		else if (skip_mod && (i % skip_mod) == 0) {
-			++lines_skipped_for_next_unit;
-			continue;
-		}
-


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list