Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/intern/draw_cache.c')
-rw-r--r--source/blender/draw/intern/draw_cache.c199
1 files changed, 21 insertions, 178 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 000ab540813..a3a5d6b065a 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -794,6 +794,10 @@ GPUBatch *DRW_gpencil_dummy_buffer_get(void)
/* -------------------------------------------------------------------- */
/** \name Common Object API
+ *
+ * \note Curve and text objects evaluate to the evaluated geometry set's mesh component if
+ * they have a surface, so curve objects themselves do not have a surface (the mesh component
+ * is presented to render engines as a separate object).
* \{ */
GPUBatch *DRW_cache_object_all_edges_get(Object *ob)
@@ -814,11 +818,11 @@ GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
case OB_MESH:
return DRW_cache_mesh_edge_detection_get(ob, r_is_manifold);
case OB_CURVE:
- return DRW_cache_curve_edge_detection_get(ob, r_is_manifold);
+ return NULL;
case OB_SURF:
return DRW_cache_surf_edge_detection_get(ob, r_is_manifold);
case OB_FONT:
- return DRW_cache_text_edge_detection_get(ob, r_is_manifold);
+ return NULL;
case OB_MBALL:
return DRW_cache_mball_edge_detection_get(ob, r_is_manifold);
case OB_HAIR:
@@ -838,11 +842,11 @@ GPUBatch *DRW_cache_object_face_wireframe_get(Object *ob)
case OB_MESH:
return DRW_cache_mesh_face_wireframe_get(ob);
case OB_CURVE:
- return DRW_cache_curve_face_wireframe_get(ob);
+ return NULL;
case OB_SURF:
return DRW_cache_surf_face_wireframe_get(ob);
case OB_FONT:
- return DRW_cache_text_face_wireframe_get(ob);
+ return NULL;
case OB_MBALL:
return DRW_cache_mball_face_wireframe_get(ob);
case OB_HAIR:
@@ -865,11 +869,11 @@ GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob)
case OB_MESH:
return DRW_cache_mesh_loose_edges_get(ob);
case OB_CURVE:
- return DRW_cache_curve_loose_edges_get(ob);
+ return NULL;
case OB_SURF:
return DRW_cache_surf_loose_edges_get(ob);
case OB_FONT:
- return DRW_cache_text_loose_edges_get(ob);
+ return NULL;
case OB_MBALL:
return NULL;
case OB_HAIR:
@@ -889,11 +893,11 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob)
case OB_MESH:
return DRW_cache_mesh_surface_get(ob);
case OB_CURVE:
- return DRW_cache_curve_surface_get(ob);
+ return NULL;
case OB_SURF:
return DRW_cache_surf_surface_get(ob);
case OB_FONT:
- return DRW_cache_text_surface_get(ob);
+ return NULL;
case OB_MBALL:
return DRW_cache_mball_surface_get(ob);
case OB_HAIR:
@@ -939,9 +943,9 @@ int DRW_cache_object_material_count_get(struct Object *ob)
Mesh *me = BKE_object_get_evaluated_mesh(ob);
if (me != NULL && type != OB_POINTCLOUD) {
- /* Some object types (e.g. curves) can have a Curve in ob->data, but will be rendered as mesh.
- * For point clouds this never happens. Ideally this check would happen at another level and we
- * would just have to care about ob->data here. */
+ /* Some object types can have one data type in ob->data, but will be rendered as mesh.
+ * For point clouds this never happens. Ideally this check would happen at another level
+ * and we would just have to care about ob->data here. */
type = OB_MESH;
}
@@ -974,11 +978,11 @@ GPUBatch **DRW_cache_object_surface_material_get(struct Object *ob,
case OB_MESH:
return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
case OB_CURVE:
- return DRW_cache_curve_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
+ return NULL;
case OB_SURF:
return DRW_cache_surf_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
case OB_FONT:
- return DRW_cache_text_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
+ return NULL;
case OB_MBALL:
return DRW_cache_mball_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
case OB_HAIR:
@@ -2929,20 +2933,13 @@ GPUBatch *DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
{
BLI_assert(ob->type == OB_CURVE);
-
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
- }
-
return DRW_curve_batch_cache_get_wire_edge(cu);
}
GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob)
{
BLI_assert(ob->type == OB_CURVE);
-
struct Curve *cu = ob->data;
return DRW_curve_batch_cache_get_normal_edge(cu);
}
@@ -2963,75 +2960,6 @@ GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob)
return DRW_curve_batch_cache_get_edit_verts(cu);
}
-GPUBatch *DRW_cache_curve_surface_get(Object *ob)
-{
- BLI_assert(ob->type == OB_CURVE);
-
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_surface(mesh_eval);
- }
-
- return DRW_curve_batch_cache_get_triangles_with_normals(cu);
-}
-
-GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob)
-{
- BLI_assert(ob->type == OB_CURVE);
-
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
- }
-
- /* TODO */
- UNUSED_VARS(cu);
- return NULL;
-}
-
-GPUBatch *DRW_cache_curve_face_wireframe_get(Object *ob)
-{
- BLI_assert(ob->type == OB_CURVE);
-
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
- }
-
- return DRW_curve_batch_cache_get_wireframes_face(cu);
-}
-
-GPUBatch *DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold)
-{
- BLI_assert(ob->type == OB_CURVE);
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
- }
-
- return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
-}
-
-/* Return list of batches */
-GPUBatch **DRW_cache_curve_surface_shaded_get(Object *ob,
- struct GPUMaterial **gpumat_array,
- uint gpumat_array_len)
-{
- BLI_assert(ob->type == OB_CURVE);
-
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
- }
-
- return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
-}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -3075,96 +3003,9 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
{
BLI_assert(ob->type == OB_FONT);
struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- const bool has_surface = (cu->flag & (CU_FRONT | CU_BACK)) || cu->ext1 != 0.0f ||
- cu->ext2 != 0.0f;
- if (!has_surface) {
- return NULL;
- }
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
- }
-
- return DRW_curve_batch_cache_get_wire_edge(cu);
-}
-
-GPUBatch *DRW_cache_text_surface_get(Object *ob)
-{
- BLI_assert(ob->type == OB_FONT);
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (cu->editfont && (cu->flag & CU_FAST)) {
- return NULL;
- }
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_surface(mesh_eval);
- }
-
- return DRW_curve_batch_cache_get_triangles_with_normals(cu);
-}
-
-GPUBatch *DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold)
-{
- BLI_assert(ob->type == OB_FONT);
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (cu->editfont && (cu->flag & CU_FAST)) {
- return NULL;
- }
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
- }
-
- return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
-}
-
-GPUBatch *DRW_cache_text_loose_edges_get(Object *ob)
-{
- BLI_assert(ob->type == OB_FONT);
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (cu->editfont && (cu->flag & CU_FAST)) {
- return NULL;
- }
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
- }
-
return DRW_curve_batch_cache_get_wire_edge(cu);
}
-GPUBatch *DRW_cache_text_face_wireframe_get(Object *ob)
-{
- BLI_assert(ob->type == OB_FONT);
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (cu->editfont && (cu->flag & CU_FAST)) {
- return NULL;
- }
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
- }
-
- return DRW_curve_batch_cache_get_wireframes_face(cu);
-}
-
-GPUBatch **DRW_cache_text_surface_shaded_get(Object *ob,
- struct GPUMaterial **gpumat_array,
- uint gpumat_array_len)
-{
- BLI_assert(ob->type == OB_FONT);
- struct Curve *cu = ob->data;
- struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
- if (cu->editfont && (cu->flag & CU_FAST)) {
- return NULL;
- }
- if (mesh_eval != NULL) {
- return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
- }
-
- return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
-}
-
/** \} */
/* -------------------------------------------------------------------- */
@@ -3544,6 +3385,8 @@ void drw_batch_cache_validate(Object *ob)
break;
case OB_CURVE:
case OB_FONT:
+ DRW_curve_batch_cache_validate((Curve *)ob->data);
+ break;
case OB_SURF:
if (mesh_eval != NULL) {
DRW_mesh_batch_cache_validate(mesh_eval);
@@ -3592,6 +3435,8 @@ void drw_batch_cache_generate_requested(Object *ob)
break;
case OB_CURVE:
case OB_FONT:
+ DRW_curve_batch_cache_create_requested(ob, scene);
+ break;
case OB_SURF:
if (mesh_eval) {
DRW_mesh_batch_cache_create_requested(
@@ -3618,8 +3463,6 @@ void DRW_batch_cache_free_old(Object *ob, int ctime)
case OB_MESH:
DRW_mesh_batch_cache_free_old((Mesh *)ob->data, ctime);
break;
- case OB_CURVE:
- case OB_FONT:
case OB_SURF:
if (mesh_eval) {
DRW_mesh_batch_cache_free_old(mesh_eval, ctime);