Commit: d4e9c27e4edc4f6771e0fff35f2c5aaa1cc0842f Author: Dalai Felinto Date: Mon Feb 13 12:37:11 2017 +0100 Branches: blender2.8 https://developer.blender.org/rBd4e9c27e4edc4f6771e0fff35f2c5aaa1cc0842f
Immediate Mode: curve draw stroke How to test this drawing: create and edit a curve and press shift + drag your mouse (or tablet). The Curve needs a Bevel Depth > 0.0. Note: The ideal solution would be to use a different shader, that takes no lighting. However according to Clément Foucault there is an assert preventing the same batch to me used with different attributes (or something like that). Il wait until the end of such resolution before revisiting this. That said, it is working fine. Part of T49043 Differential Revision: https://developer.blender.org/D2501 =================================================================== M source/blender/editors/curve/editcurve_paint.c =================================================================== diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 4720b76342..01d9167cdb 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -48,7 +48,9 @@ #include "BIF_gl.h" #include "BIF_glutil.h" +#include "GPU_batch.h" #include "GPU_immediate.h" +#include "GPU_matrix.h" #include "curve_intern.h" @@ -467,39 +469,48 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS Object *obedit = cdd->vc.obedit; Curve *cu = obedit->data; - UI_ThemeColor(TH_WIRE); - if (cu->ext2 > 0.0f) { - GLUquadricObj *qobj = gluNewQuadric(); - - gluQuadricDrawStyle(qobj, GLU_FILL); - BLI_mempool_iter iter; const struct StrokeElem *selem; const float location_zero[3] = {0}; const float *location_prev = location_zero; + float color[3]; + UI_GetThemeColor3fv(TH_WIRE, color); + + /* silly light-less shader, non-critical task, so it's fine */ + float light[3] = {0.0f, 0.0f, 0.0f}; + + Batch *sphere = Batch_get_sphere(0); + Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING); + Batch_Uniform3fv(sphere, "color", color); + Batch_Uniform3fv(sphere, "light", light); + /* scale to edit-mode space */ - glPushMatrix(); - glMultMatrixf(obedit->obmat); + gpuMatrixBegin3D_legacy(); + gpuPushMatrix(); + gpuMultMatrix3D(obedit->obmat); BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); for (selem = BLI_mempool_iterstep(&iter); selem; selem = BLI_mempool_iterstep(&iter)) { - glTranslatef( + gpuTranslate3f( selem->location_local[0] - location_prev[0], selem->location_local[1] - location_prev[1], selem->location_local[2] - location_prev[2]); location_prev = selem->location_local; + const float radius = stroke_elem_radius(cdd, selem); - gluSphere(qobj, radius, 12, 8); + + gpuScaleUniform(radius); + Batch_draw(sphere); + gpuScaleUniform(1.0f / radius); location_prev = selem->location_local; } - glPopMatrix(); - - gluDeleteQuadric(qobj); + gpuPopMatrix(); + gpuMatrixEnd(); } if (stroke_len > 1) { _______________________________________________ Bf-blender-cvs mailing list [email protected] https://lists.blender.org/mailman/listinfo/bf-blender-cvs
