[Bf-blender-cvs] [a3277ae] blender2.8: OpenGL: simple mesh edit mode for new viewport
Mike Erwin
noreply at git.blender.org
Tue Nov 8 05:41:14 CET 2016
Commit: a3277ae38443a63ff079cf0a73240153b08d21d8
Author: Mike Erwin
Date: Mon Nov 7 20:24:03 2016 +0100
Branches: blender2.8
https://developer.blender.org/rBa3277ae38443a63ff079cf0a73240153b08d21d8
OpenGL: simple mesh edit mode for new viewport
Very very simple. Needs a lot of work to reach "legacy viewport" capabilities.
===================================================================
M source/blender/editors/space_view3d/drawobject.c
===================================================================
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 1983731..c316057 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -4253,7 +4253,60 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
static void draw_em_fancy_new(Scene *scene, ARegion *ar, View3D *v3d,
Object *ob, BMEditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, const char dt)
{
- /* for now... nothing! */
+ /* for now... something simple! */
+
+ Batch *surface = MBC_get_all_triangles(cageDM);
+
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LEQUAL);
+
+ glEnable(GL_BLEND);
+
+ /* disable depth writes for transparent surface, so it doesn't interfere with itself */
+ glDepthMask(GL_FALSE);
+
+ Batch_set_builtin_program(surface, GPU_SHADER_3D_UNIFORM_COLOR);
+ Batch_Uniform4f(surface, "color", 1.0f, 0.5f, 0.0f, 0.5f);
+ Batch_draw(surface);
+
+#if 0 /* until I understand finalDM better */
+ if (finalDM != cageDM) {
+ puts("finalDM != cageDM");
+ Batch *finalSurface = MBC_get_all_triangles(finalDM);
+ Batch_set_builtin_program(finalSurface, GPU_SHADER_3D_UNIFORM_COLOR);
+ Batch_Uniform4f(finalSurface, "color", 0.0f, 0.0f, 0.0f, 0.05f);
+ Batch_draw(finalSurface);
+ }
+#endif
+
+ glDepthMask(GL_TRUE);
+
+ /* now write surface depth so other objects won't poke through
+ * NOTE: does not help as much as desired
+ * TODO: draw edit object last to avoid this mess
+ */
+ Batch_set_builtin_program(surface, GPU_SHADER_3D_DEPTH_ONLY);
+ Batch_draw(surface);
+
+ Batch *edges = MBC_get_all_edges(cageDM);
+ Batch_set_builtin_program(edges, GPU_SHADER_3D_UNIFORM_COLOR);
+ Batch_Uniform4f(edges, "color", 0.0f, 0.0f, 0.0f, 1.0f);
+ glEnable(GL_LINE_SMOOTH);
+ glLineWidth(1.5f);
+ Batch_draw(edges);
+ glDisable(GL_LINE_SMOOTH);
+
+#if 0 /* looks good even without points */
+ Batch *verts = MBC_get_all_verts(cageDM);
+ glEnable(GL_BLEND);
+
+ Batch_set_builtin_program(verts, GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_SMOOTH);
+ Batch_Uniform4f(verts, "color", 0.0f, 0.0f, 0.0f, 1.0f);
+ Batch_Uniform1f(verts, "size", UI_GetThemeValuef(TH_VERTEX_SIZE) * 1.5f);
+ Batch_draw(verts);
+
+ glDisable(GL_BLEND);
+#endif
}
/* Mesh drawing routines */
More information about the Bf-blender-cvs
mailing list