Commit: a16d835f7ba05ce53ba798c7db0c01abb2f12032
Author: Clément Foucault
Date: Thu Jun 7 14:49:54 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBa16d835f7ba05ce53ba798c7db0c01abb2f12032
Wireframe: Frustum cull them.
===================================================================
M source/blender/draw/intern/DRW_render.h
M source/blender/draw/intern/draw_manager_data.c
M source/blender/draw/modes/overlay_mode.c
===================================================================
diff --git a/source/blender/draw/intern/DRW_render.h
b/source/blender/draw/intern/DRW_render.h
index 9f1bfa6ee33..b74e6ba9204 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -349,6 +349,7 @@ void DRW_shgroup_call_range_add(
void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, unsigned
int point_count, float (*obmat)[4]);
void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, unsigned
int line_count, float (*obmat)[4]);
void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup,
unsigned int tria_count, float (*obmat)[4]);
+void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup
*shgroup, uint tria_count, struct Object *ob);
void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup, struct Gwn_Batch
*geom, struct Object *ob, bool bypass_culling);
#define DRW_shgroup_call_object_add(shgroup, geom, ob)
DRW_shgroup_call_object_add_ex(shgroup, geom, ob, false)
#define DRW_shgroup_call_object_add_no_cull(shgroup, geom, ob)
DRW_shgroup_call_object_add_ex(shgroup, geom, ob, true)
diff --git a/source/blender/draw/intern/draw_manager_data.c
b/source/blender/draw/intern/draw_manager_data.c
index dab3336b3ed..09890107fa3 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -391,12 +391,17 @@ void DRW_shgroup_call_range_add(DRWShadingGroup *shgroup,
Gwn_Batch *geom, float
}
static void drw_shgroup_call_procedural_add_ex(
- DRWShadingGroup *shgroup, Gwn_PrimType prim_type, uint vert_count,
float (*obmat)[4])
+ DRWShadingGroup *shgroup, Gwn_PrimType prim_type, uint vert_count,
float (*obmat)[4], Object *ob)
{
BLI_assert(ELEM(shgroup->type, DRW_SHG_NORMAL,
DRW_SHG_FEEDBACK_TRANSFORM));
DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
- call->state = drw_call_state_create(shgroup, obmat, NULL);
+ if (ob) {
+ call->state = drw_call_state_object(shgroup, ob->obmat, ob);
+ }
+ else {
+ call->state = drw_call_state_create(shgroup, obmat, NULL);
+ }
call->type = DRW_CALL_PROCEDURAL;
call->procedural.prim_type = prim_type;
call->procedural.vert_count = vert_count;
@@ -409,17 +414,24 @@ static void drw_shgroup_call_procedural_add_ex(
void DRW_shgroup_call_procedural_points_add(DRWShadingGroup *shgroup, uint
point_count, float (*obmat)[4])
{
- drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS,
point_count, obmat);
+ drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_POINTS,
point_count, obmat, NULL);
}
void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup, uint
line_count, float (*obmat)[4])
{
- drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_LINES, line_count
* 2, obmat);
+ drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_LINES, line_count
* 2, obmat, NULL);
}
void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup, uint
tria_count, float (*obmat)[4])
{
- drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count *
3, obmat);
+ drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count *
3, obmat, NULL);
+}
+
+/* TODO (fclem): this is a sign that the api is starting to be limiting.
+ * Maybe add special function that general purpose for special cases. */
+void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup
*shgroup, uint tria_count, Object *ob)
+{
+ drw_shgroup_call_procedural_add_ex(shgroup, GWN_PRIM_TRIS, tria_count *
3, NULL, ob);
}
/* These calls can be culled and are optimized for redraw */
diff --git a/source/blender/draw/modes/overlay_mode.c
b/source/blender/draw/modes/overlay_mode.c
index 107d6347c76..721f659f253 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -202,7 +202,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
DRW_shgroup_uniform_texture(shgrp, "faceIds",
faceids);
DRW_shgroup_uniform_vec3(shgrp, "wireColor",
ts.colorWire, 1);
DRW_shgroup_uniform_vec3(shgrp, "rimColor",
rim_col, 1);
-
DRW_shgroup_call_procedural_triangles_add(shgrp, tri_count, ob->obmat);
+
DRW_shgroup_call_object_procedural_triangles_culled_add(shgrp, tri_count, ob);
}
}
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs