diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-07 21:56:55 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-08 18:52:48 +0300 |
commit | 9bfdc4826a79bd3b0f3a6e1c4dd037f4a07ae87f (patch) | |
tree | dc89e2ee3c8641943ed18e8afc9a1d3c342dc94a /source/blender/draw | |
parent | b6b3a57c2241ea61e9df5505cfa33c8760dfd46c (diff) |
Wireframe: Create dupli fast path using DRW_duplidata_get
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/modes/overlay_mode.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c index 90fac136f73..fe4bb2db18e 100644 --- a/source/blender/draw/modes/overlay_mode.c +++ b/source/blender/draw/modes/overlay_mode.c @@ -46,6 +46,11 @@ /* Structures */ +typedef struct OVERLAY_DupliData { + DRWShadingGroup *shgrp; + struct GPUBatch *geom; +} OVERLAY_DupliData; + typedef struct OVERLAY_StorageList { struct OVERLAY_PrivateData *g_data; } OVERLAY_StorageList; @@ -337,12 +342,25 @@ static void overlay_cache_populate(void *vedata, Object *ob) if (DRW_object_is_renderable(ob) && pd->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) { struct GPUBatch *geom = DRW_cache_object_surface_get(ob); if (geom) { - DRW_shgroup_call_add(pd->face_orientation_shgrp, geom, ob->obmat); + DRW_shgroup_call_object_add(pd->face_orientation_shgrp, geom, ob); } } if ((pd->overlay.flag & V3D_OVERLAY_WIREFRAMES) || (v3d->shading.type == OB_WIRE) || (ob->dtx & OB_DRAWWIRE) || (ob->dt == OB_WIRE)) { + + /* Fast path for duplis. */ + OVERLAY_DupliData **dupli_data = (OVERLAY_DupliData **)DRW_duplidata_get(vedata); + if (dupli_data) { + if (*dupli_data == NULL) { + *dupli_data = MEM_callocN(sizeof(OVERLAY_DupliData), "OVERLAY_DupliData"); + } + else { + DRW_shgroup_call_object_add((*dupli_data)->shgrp, (*dupli_data)->geom, ob); + return; + } + } + const bool is_edit_mode = BKE_object_is_in_editmode(ob); bool has_edit_mesh_cage = false; if (ob->type == OB_MESH) { @@ -392,9 +410,15 @@ static void overlay_cache_populate(void *vedata, Object *ob) DRW_shgroup_call_sculpt_add(shgrp, ob, true, false, false); } else { - DRW_shgroup_call_add(shgrp, geom, ob->obmat); + DRW_shgroup_call_object_add(shgrp, geom, ob); } } + + if (dupli_data) { + (*dupli_data)->shgrp = shgrp; + (*dupli_data)->geom = geom; + } + if (is_wire && shgrp != NULL) { /* If object is wireframe, don't try to use stencil test. */ DRW_shgroup_state_disable(shgrp, DRW_STATE_STENCIL_EQUAL); |