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:
authorHans Goudey <h.goudey@me.com>2021-09-11 21:54:40 +0300
committerHans Goudey <h.goudey@me.com>2021-09-11 21:54:40 +0300
commitb9febb54a492ac6c93802fb0aa189d4c3fd99b0b (patch)
treea2f3b1d773d3a2424d7db0c8d9a0a0899da17747 /source/blender/draw/intern/draw_cache.c
parentc946fdb2e5fc1eab139f70f01ea4e673435455bd (diff)
Geometry Nodes: Support modifier on curve objects
With this commit, curve objects support the geometry nodes modifier. Curves objects now evaluate to `CurveEval` unless there was a previous implicit conversion (tessellating modifiers, mesh modifiers, or the settings in the curve "Geometry" panel). In the new code, curves are only considered to be the wire edges-- any generated surface is a mesh instead, stored in the evaluated geometry set. The consolidation of concepts mentioned above allows remove a lot of code that had to do with maintaining the `DispList` type temporarily for modifiers and rendering. Instead, render engines see a separate object for the mesh from the mesh geometry component, and when the curve object evaluates to a curve, the `CurveEval` is always used for drawing wire edges. However, currently the `DispList` type is still maintained and used as an intermediate step in implicit mesh conversion. In the future, more uses of it could be changed to use `CurveEval` and `Mesh` instead. This is mostly not changed behavior, it is just a formalization of existing logic after recent fixes for 2.8 versions last year and two years ago. Also, in the future more functionality can be converted to nodes, removing cases of implicit conversions. For more discussion on that topic, see T89676. The `use_fill_deform` option is removed. It has not worked properly since 2.62, and the choice for filling a curve before or after deformation will work much better and be clearer with a node system. Applying the geometry nodes modifier to generate a curve is not implemented with this commit, so applying the modifier won't work at all. This is a separate technical challenge, and should be solved in a separate step. Differential Revision: https://developer.blender.org/D11597
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);