diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-01-27 13:18:16 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-01-27 13:18:16 +0300 |
commit | efa401b086fe558ab100309a727c6d04e7387f10 (patch) | |
tree | 6f0bd4de156f412dd155e96e404f913391cb7c46 | |
parent | 4c416aea3bd2d4b5e05c33b90f7b79e04f4da318 (diff) |
Introduce Dynamic Batches + Relationship lines + Clear some matrix warnings
-rw-r--r-- | source/blender/draw/engines/clay/clay.c | 10 | ||||
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 42 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 212 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_mode_pass.c | 64 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_mode_pass.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 2 |
6 files changed, 222 insertions, 109 deletions
diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index ffdad41bef5..f741cb54b9c 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -534,8 +534,8 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) geom = DRW_cache_surface_get(ob); /* Add everything for now */ - DRW_shgroup_call_add(depthbatch, geom, &ob->obmat); - DRW_shgroup_call_add(default_shgrp, geom, &ob->obmat); + DRW_shgroup_call_add(depthbatch, geom, ob->obmat); + DRW_shgroup_call_add(default_shgrp, geom, ob->obmat); /* When encountering a new material : * - Create new Batch @@ -554,14 +554,10 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C) break; } - /* Add all object center for now */ DRW_shgroup_object_center(passes->ob_center_pass, ob); + DRW_shgroup_relationship_lines(passes->non_meshes_pass, ob); } FOREACH_OBJECT_END - - /* Optimization */ - // DRWShadingGroup *shgrp = DRW_pass_nth_shgroup_get(passes->ob_center_pass, 0); - // DRW_shgroup_batch_calls_object_center(shgrp); } static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext *context) diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 419e5248bdf..8daf97875b5 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -149,29 +149,35 @@ typedef enum { DRW_STATE_WIRE = (1 << 6), DRW_STATE_WIRE_LARGE = (1 << 7), DRW_STATE_POINT = (1 << 8), - DRW_STATE_BLEND = (1 << 9) + DRW_STATE_STIPPLE_2 = (1 << 9), + DRW_STATE_STIPPLE_3 = (1 << 10), + DRW_STATE_STIPPLE_4 = (1 << 11), + DRW_STATE_BLEND = (1 << 12), } DRWState; +/* Used by DRWShadingGroup.dyntype */ +#define DRW_DYN_POINTS 1 +#define DRW_DYN_LINES 2 + DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass); -void DRW_shgroup_free(struct DRWShadingGroup *batch); -void DRW_shgroup_call_add(DRWShadingGroup *batch, struct Batch *geom, const float **obmat); -void DRW_shgroup_state_set(DRWShadingGroup *batch, DRWState state); +void DRW_shgroup_free(struct DRWShadingGroup *shgroup); +void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Batch *geom, float (*obmat)[4]); +void DRW_shgroup_state_set(DRWShadingGroup *shgroup, DRWState state); +void DRW_shgroup_dyntype_set(DRWShadingGroup *shgroup, int type); -void DRW_shgroup_uniform_texture(DRWShadingGroup *batch, const char *name, const struct GPUTexture *tex, int loc); +void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const struct GPUTexture *tex, int loc); void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const struct GPUUniformBuffer *ubo, int loc); -void DRW_shgroup_uniform_buffer(DRWShadingGroup *batch, const char *name, const int value, int loc); -void DRW_shgroup_uniform_bool(DRWShadingGroup *batch, const char *name, const bool *value, int arraysize); -void DRW_shgroup_uniform_float(DRWShadingGroup *batch, const char *name, const float *value, int arraysize); -void DRW_shgroup_uniform_vec2(DRWShadingGroup *batch, const char *name, const float *value, int arraysize); -void DRW_shgroup_uniform_vec3(DRWShadingGroup *batch, const char *name, const float *value, int arraysize); -void DRW_shgroup_uniform_vec4(DRWShadingGroup *batch, const char *name, const float *value, int arraysize); -void DRW_shgroup_uniform_int(DRWShadingGroup *batch, const char *name, const int *value, int arraysize); -void DRW_shgroup_uniform_ivec2(DRWShadingGroup *batch, const char *name, const int *value, int arraysize); -void DRW_shgroup_uniform_ivec3(DRWShadingGroup *batch, const char *name, const int *value, int arraysize); -void DRW_shgroup_uniform_mat3(DRWShadingGroup *batch, const char *name, const float *value); -void DRW_shgroup_uniform_mat4(DRWShadingGroup *batch, const char *name, const float *value); - -void DRW_shgroup_batch_calls_object_center(DRWShadingGroup *shgroup); +void DRW_shgroup_uniform_buffer(DRWShadingGroup *shgroup, const char *name, const int value, int loc); +void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const bool *value, int arraysize); +void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize); +void DRW_shgroup_uniform_vec2(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize); +void DRW_shgroup_uniform_vec3(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize); +void DRW_shgroup_uniform_vec4(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize); +void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize); +void DRW_shgroup_uniform_ivec2(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize); +void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize); +void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float *value); +void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float *value); /* Passes */ DRWPass *DRW_pass_create(const char *name, DRWState state); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index db7b5f8223a..a2ddf070799 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -29,10 +29,12 @@ #include "BLI_rect.h" #include "BLI_string.h" -#include "BLT_translation.h" +#include "BIF_glutil.h" #include "BKE_global.h" +#include "BLT_translation.h" + #include "DRW_engine.h" #include "DRW_render.h" @@ -101,7 +103,7 @@ struct DRWPass { typedef struct DRWCall { struct DRWCall *next, *prev; Batch *geometry; - float **obmat; + float(*obmat)[4]; } DRWCall; struct DRWShadingGroup { @@ -110,6 +112,8 @@ struct DRWShadingGroup { struct DRWInterface *interface; /* Uniforms pointers */ ListBase calls; /* List with all geometry and transforms */ int state; /* State changes for this batch only */ + short dyntype; /* Dynamic Batch type, 0 is normal */ + Batch *dyngeom; /* Dynamic batch */ }; /* Render State */ @@ -325,6 +329,8 @@ DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass) shgroup->shader = shader; shgroup->interface = DRW_interface_create(shader); shgroup->state = 0; + shgroup->dyntype = 0; + shgroup->dyngeom = NULL; BLI_listbase_clear(&shgroup->interface->uniforms); @@ -338,10 +344,13 @@ void DRW_shgroup_free(struct DRWShadingGroup *shgroup) BLI_freelistN(&shgroup->calls); BLI_freelistN(&shgroup->interface->uniforms); MEM_freeN(shgroup->interface); + + if (shgroup->dyngeom) + Batch_discard(shgroup->dyngeom); } /* Later use VBO */ -void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Batch *geom, const float **obmat) +void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Batch *geom, float (*obmat)[4]) { if (geom) { DRWCall *call = MEM_callocN(sizeof(DRWCall), "DRWCall"); @@ -360,6 +369,11 @@ void DRW_shgroup_state_set(DRWShadingGroup *shgroup, DRWState state) shgroup->state = state; } +void DRW_shgroup_dyntype_set(DRWShadingGroup *shgroup, int type) +{ + shgroup->dyntype = type; +} + void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex, int loc) { DRW_interface_uniform(shgroup, name, DRW_UNIFORM_TEXTURE, tex, 0, 0, loc); @@ -426,23 +440,27 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const DRW_interface_uniform(shgroup, name, DRW_UNIFORM_MAT4, value, 16, 1, 0); } -/* TODO move it to GPUViewport */ -static Batch *obj_centers = NULL; - -void DRW_shgroup_batch_calls_object_center(DRWShadingGroup *shgroup) +static void shgroup_dynamic_batch_from_calls(DRWShadingGroup *shgroup) { + int i = 0; int nbr = BLI_listbase_count(&shgroup->calls); + GLenum type; + + if (nbr == 0) { + if (shgroup->dyngeom) { + Batch_discard(shgroup->dyngeom); + shgroup->dyngeom = NULL; + } + return; + } + /* Gather Data */ float *data = MEM_mallocN(sizeof(float) * 3 * nbr , "Object Center Batch data"); - // int i = 0; - // /* TODO do something more generic usable for other things than obj center */ - // for (DRWCall *call = shgroup->calls.first; call; call = call->next) { - // float *v = data + i*3; - // float ob[3] = {0.0f,0.0f,0.0f}; - // copy_v3_v3(v, ob); - // i++; - // } + /* TODO do something more generic usable for other things than obj center */ + for (DRWCall *call = shgroup->calls.first; call; call = call->next, i++) { + copy_v3_v3(&data[i*3], call->obmat[3]); + } /* Upload Data */ static VertexFormat format = { 0 }; @@ -456,21 +474,20 @@ void DRW_shgroup_batch_calls_object_center(DRWShadingGroup *shgroup) fillAttrib(vbo, pos_id, data); - if (obj_centers) - Batch_discard(obj_centers); + if (shgroup->dyntype == DRW_DYN_POINTS) + type = GL_POINTS; + else + type = GL_LINES; + + /* TODO make the batch dynamic instead of freeing it every times */ + if (shgroup->dyngeom) + Batch_discard(shgroup->dyngeom); - obj_centers = Batch_create(GL_POINTS, vbo, NULL); + shgroup->dyngeom = Batch_create(type, vbo, NULL); MEM_freeN(data); - - /* Replacing multiple calls with only one */ - BLI_freelistN(&shgroup->calls); - static float obmat[4][4]; - unit_m4(obmat); - DRW_shgroup_call_add(shgroup, obj_centers, &obmat); } - /* ***************************************** PASSES ******************************************/ DRWPass *DRW_pass_create(const char *name, DRWState state) @@ -542,15 +559,28 @@ void DRW_draw_background(void) } } +/* Only alter the state (does not reset it like set_state() ) */ static void shgroup_set_state(DRWShadingGroup *shgroup) { if (shgroup->state) { + /* Wire width */ if (shgroup->state & DRW_STATE_WIRE) { glLineWidth(1.0f); } else if (shgroup->state & DRW_STATE_WIRE_LARGE) { glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); } + + /* Line Stipple */ + if (shgroup->state & DRW_STATE_STIPPLE_2) { + setlinestyle(2); + } + else if (shgroup->state & DRW_STATE_STIPPLE_3) { + setlinestyle(3); + } + else if (shgroup->state & DRW_STATE_STIPPLE_4) { + setlinestyle(4); + } } } @@ -559,12 +589,65 @@ typedef struct DRWBoundTexture { GPUTexture *tex; } DRWBoundTexture; +static void draw_geometry(DRWShadingGroup *shgroup, DRWInterface *interface, Batch *geom, const float (*obmat)[4]) +{ + RegionView3D *rv3d = CTX_wm_region_view3d(DST.context); + + float mvp[4][4], mv[4][4], n[3][3]; + float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */ + + bool do_mvp = (interface->modelviewprojection != -1); + bool do_mv = (interface->modelview != -1); + bool do_n = (interface->normal != -1); + bool do_eye = (interface->eye != -1); + + if (do_mvp) { + mul_m4_m4m4(mvp, rv3d->persmat, obmat); + } + if (do_mv || do_n || do_eye) { + mul_m4_m4m4(mv, rv3d->viewmat, obmat); + } + if (do_n || do_eye) { + copy_m3_m4(n, mv); + invert_m3(n); + transpose_m3(n); + } + if (do_eye) { + /* Used by orthographic wires */ + float tmp[3][3]; + invert_m3_m3(tmp, n); + /* set eye vector, transformed to object coords */ + mul_m3_v3(tmp, eye); + } + + /* Should be really simple */ + /* step 1 : bind object dependent matrices */ + if (interface->modelviewprojection != -1) { + GPU_shader_uniform_vector(shgroup->shader, interface->modelviewprojection, 16, 1, (float *)mvp); + } + if (interface->projection != -1) { + GPU_shader_uniform_vector(shgroup->shader, interface->projection, 16, 1, (float *)rv3d->winmat); + } + if (interface->modelview != -1) { + GPU_shader_uniform_vector(shgroup->shader, interface->modelview, 16, 1, (float *)mv); + } + if (interface->normal != -1) { + GPU_shader_uniform_vector(shgroup->shader, interface->normal, 9, 1, (float *)n); + } + if (interface->eye != -1) { + GPU_shader_uniform_vector(shgroup->shader, interface->eye, 3, 1, (float *)eye); + } + + /* step 2 : bind vertex array & draw */ + Batch_set_program(geom, GPU_shader_get_program(shgroup->shader)); + Batch_draw_stupid(geom); +} + static void draw_shgroup(DRWShadingGroup *shgroup) { BLI_assert(shgroup->shader); BLI_assert(shgroup->interface); - RegionView3D *rv3d = CTX_wm_region_view3d(DST.context); DRWInterface *interface = shgroup->interface; if (DST.shader != shgroup->shader) { @@ -573,6 +656,10 @@ static void draw_shgroup(DRWShadingGroup *shgroup) DST.shader = shgroup->shader; } + if (shgroup->dyntype != 0) { + shgroup_dynamic_batch_from_calls(shgroup); + } + shgroup_set_state(shgroup); /* Binding Uniform */ @@ -619,55 +706,18 @@ static void draw_shgroup(DRWShadingGroup *shgroup) } /* Rendering Calls */ - for (DRWCall *call = shgroup->calls.first; call; call = call->next) { - float mvp[4][4], mv[4][4], n[3][3]; - float eye[3] = { 0.0f, 0.0f, 1.0f }; /* looking into the screen */ - - bool do_mvp = (interface->modelviewprojection != -1); - bool do_mv = (interface->modelview != -1); - bool do_n = (interface->normal != -1); - bool do_eye = (interface->eye != -1); - - if (do_mvp) { - mul_m4_m4m4(mvp, rv3d->persmat, call->obmat); - } - if (do_mv || do_n || do_eye) { - mul_m4_m4m4(mv, rv3d->viewmat, call->obmat); - } - if (do_n || do_eye) { - copy_m3_m4(n, mv); - invert_m3(n); - transpose_m3(n); - } - if (do_eye) { - /* Used by orthographic wires */ - float tmp[3][3]; - invert_m3_m3(tmp, n); - /* set eye vector, transformed to object coords */ - mul_m3_v3(tmp, eye); - } - - /* Should be really simple */ - /* step 1 : bind object dependent matrices */ - if (interface->modelviewprojection != -1) { - GPU_shader_uniform_vector(shgroup->shader, interface->modelviewprojection, 16, 1, (float *)mvp); - } - if (interface->projection != -1) { - GPU_shader_uniform_vector(shgroup->shader, interface->projection, 16, 1, (float *)rv3d->winmat); - } - if (interface->modelview != -1) { - GPU_shader_uniform_vector(shgroup->shader, interface->modelview, 16, 1, (float *)mv); - } - if (interface->normal != -1) { - GPU_shader_uniform_vector(shgroup->shader, interface->normal, 9, 1, (float *)n); - } - if (interface->eye != -1) { - GPU_shader_uniform_vector(shgroup->shader, interface->eye, 3, 1, (float *)eye); + if (shgroup->dyntype != 0) { + /* Replacing multiple calls with only one */ + float obmat[4][4]; + unit_m4(obmat); + /* Some dynamic batch can have no geom (no call to aggregate) */ + if (shgroup->dyngeom) + draw_geometry(shgroup, interface, shgroup->dyngeom, obmat); + } + else { + for (DRWCall *call = shgroup->calls.first; call; call = call->next) { + draw_geometry(shgroup, interface, call->geometry, call->obmat); } - - /* step 2 : bind vertex array & draw */ - Batch_set_program(call->geometry, GPU_shader_get_program(shgroup->shader)); - Batch_draw_stupid(call->geometry); } } @@ -741,6 +791,20 @@ static void set_state(short flag) else { glDisable(GL_BLEND); } + + /* Line Stipple */ + if (flag & DRW_STATE_STIPPLE_2) { + setlinestyle(2); + } + else if (flag & DRW_STATE_STIPPLE_3) { + setlinestyle(3); + } + else if (flag & DRW_STATE_STIPPLE_4) { + setlinestyle(4); + } + else { + setlinestyle(0); + } } void DRW_draw_pass(DRWPass *pass) diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c index 942e58e4522..202921437c0 100644 --- a/source/blender/draw/intern/draw_mode_pass.c +++ b/source/blender/draw/intern/draw_mode_pass.c @@ -53,11 +53,34 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa if (non_meshes) { /* Non Meshes Pass (Camera, empties, lamps ...) */ + DRWShadingGroup *grp; + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_BLEND; state |= DRW_STATE_WIRE ;//| DRW_STATE_LINE_SMOOTH; *non_meshes = DRW_pass_create("Non Meshes Pass", state); - /* TODO Define all groups here */ + GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR); + + /* Solid Wires */ + grp = DRW_shgroup_create(sh, *non_meshes); + + /* Points */ + grp = DRW_shgroup_create(sh, *non_meshes); + + /* Stipple Wires */ + grp = DRW_shgroup_create(sh, *non_meshes); + DRW_shgroup_state_set(grp, DRW_STATE_STIPPLE_2); + + grp = DRW_shgroup_create(sh, *non_meshes); + DRW_shgroup_state_set(grp, DRW_STATE_STIPPLE_3); + + grp = DRW_shgroup_create(sh, *non_meshes); + DRW_shgroup_state_set(grp, DRW_STATE_STIPPLE_4); + + /* Relationship Lines */ + grp = DRW_shgroup_create(sh, *non_meshes); + DRW_shgroup_state_set(grp, DRW_STATE_STIPPLE_3); + DRW_shgroup_dyntype_set(grp, DRW_DYN_LINES); } if (ob_center) { @@ -80,6 +103,7 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa /* Active */ grp = DRW_shgroup_create(sh, *ob_center); + DRW_shgroup_dyntype_set(grp, DRW_DYN_POINTS); DRW_shgroup_uniform_float(grp, "size", &size, 1); DRW_shgroup_uniform_float(grp, "outlineWidth", &outlineWidth, 1); DRW_shgroup_uniform_vec4(grp, "color", colorActive, 1); @@ -87,10 +111,12 @@ void DRW_pass_setup_common(DRWPass **wire_overlay, DRWPass **wire_outline, DRWPa /* Select */ grp = DRW_shgroup_create(sh, *ob_center); + DRW_shgroup_dyntype_set(grp, DRW_DYN_POINTS); DRW_shgroup_uniform_vec4(grp, "color", colorSelect, 1); /* Deselect */ grp = DRW_shgroup_create(sh, *ob_center); + DRW_shgroup_dyntype_set(grp, DRW_DYN_POINTS); DRW_shgroup_uniform_vec4(grp, "color", colorDeselect, 1); } } @@ -105,7 +131,7 @@ void DRW_shgroup_wire_overlay(DRWPass *wire_overlay, Object *ob) DRWShadingGroup *grp = DRW_shgroup_create(sh, wire_overlay); DRW_shgroup_uniform_vec2(grp, "viewportSize", DRW_viewport_size_get(), 1); - DRW_shgroup_call_add(grp, geom, &ob->obmat); + DRW_shgroup_call_add(grp, geom, ob->obmat); } void DRW_shgroup_wire_outline(DRWPass *wire_outline, Object *ob, @@ -152,7 +178,7 @@ void DRW_shgroup_wire_outline(DRWPass *wire_outline, Object *ob, DRW_shgroup_uniform_bool(grp, "drawBack", &bFalse, 1); DRW_shgroup_uniform_bool(grp, "drawSilhouette", &bFalse, 1); - DRW_shgroup_call_add(grp, geom, &ob->obmat); + DRW_shgroup_call_add(grp, geom, ob->obmat); } if (do_outline) { @@ -163,7 +189,7 @@ void DRW_shgroup_wire_outline(DRWPass *wire_outline, Object *ob, DRW_shgroup_uniform_bool(grp, "drawBack", &bFalse, 1); DRW_shgroup_uniform_bool(grp, "drawSilhouette", &bTrue, 1); - DRW_shgroup_call_add(grp, geom, &ob->obmat); + DRW_shgroup_call_add(grp, geom, ob->obmat); } #else /* Old (flat) wire */ @@ -173,13 +199,18 @@ void DRW_shgroup_wire_outline(DRWPass *wire_outline, Object *ob, DRW_shgroup_state_set(grp, DRW_STATE_WIRE_LARGE); DRW_shgroup_uniform_vec4(grp, "color", frontcol, 1); - DRW_shgroup_call_add(grp, geom, &ob->obmat); + DRW_shgroup_call_add(grp, geom, ob->obmat); #endif } /* ***************************** NON MESHES ********************** */ +void DRW_draw_lamp(DRWPass *non_meshes, Object *ob) +{ + /* TODO */ +} + void DRW_shgroup_non_meshes(DRWPass *non_meshes, Object *ob) { struct Batch *geom; @@ -192,16 +223,31 @@ void DRW_shgroup_non_meshes(DRWPass *non_meshes, Object *ob) case OB_EMPTY: default: geom = DRW_cache_plain_axes_get(); - DRWShadingGroup *grp = DRW_shgroup_create(sh, non_meshes); + DRWShadingGroup *grp = DRW_pass_nth_shgroup_get(non_meshes, 0); DRW_shgroup_uniform_vec4(grp, "color", frontcol, 1); - DRW_shgroup_call_add(grp, geom, &ob->obmat); + DRW_shgroup_call_add(grp, geom, ob->obmat); break; } } +void DRW_shgroup_relationship_lines(DRWPass *non_meshes, Object *ob) +{ + if (ob->parent) { + struct Batch *geom = DRW_cache_single_vert_get(); + DRWShadingGroup *grp = DRW_pass_nth_shgroup_get(non_meshes, 5); + DRW_shgroup_call_add(grp, geom, ob->obmat); + DRW_shgroup_call_add(grp, geom, ob->parent->obmat); + } +} + +/* ***************************** COMMON **************************** */ + void DRW_shgroup_object_center(DRWPass *ob_center, Object *ob) { struct Batch *geom = DRW_cache_single_vert_get(); + DRWShadingGroup *grp = DRW_pass_nth_shgroup_get(ob_center, 0); - DRW_shgroup_call_add(grp, geom, &ob->obmat); -} + + /* Add all object center for now */ + DRW_shgroup_call_add(grp, geom, ob->obmat); +}
\ No newline at end of file diff --git a/source/blender/draw/intern/draw_mode_pass.h b/source/blender/draw/intern/draw_mode_pass.h index 17e841dc467..85f3da1afed 100644 --- a/source/blender/draw/intern/draw_mode_pass.h +++ b/source/blender/draw/intern/draw_mode_pass.h @@ -38,6 +38,7 @@ void DRW_shgroup_wire_outline( struct DRWPass *wire_outline, Object *ob, const bool do_front, const bool do_back, const bool do_outline); void DRW_shgroup_non_meshes(struct DRWPass *non_meshes, Object *ob); +void DRW_shgroup_relationship_lines(struct DRWPass *non_meshes, Object *ob); void DRW_shgroup_object_center(struct DRWPass *ob_center, Object *ob); #endif /* __DRAW_MODE_PASS_H__ */
\ No newline at end of file diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 5737f02ba4a..c8f0a4e3256 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2131,7 +2131,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar) /* TODO layers - In the future we should get RE from Layers */ RenderEngineType *type = RE_engines_find(scene->r.engine); - if (IS_VIEWPORT_LEGACY(v3d) && !(type->flag & RE_USE_OGL_PIPELINE)) { + if (IS_VIEWPORT_LEGACY(v3d) && ((type->flag & RE_USE_OGL_PIPELINE) == 0)) { view3d_main_region_draw_legacy(C, ar); return; } |