2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup draw
|
2017-02-07 11:20:15 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_curve_types.h"
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
#include "DNA_curves_types.h"
|
2023-05-30 11:14:16 +02:00
|
|
|
#include "DNA_grease_pencil_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_lattice_types.h"
|
2017-02-07 11:20:15 +01:00
|
|
|
#include "DNA_mesh_types.h"
|
2017-06-22 19:19:55 +02:00
|
|
|
#include "DNA_modifier_types.h"
|
2020-03-17 16:27:08 +01:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_particle_types.h"
|
|
|
|
|
#include "DNA_pointcloud_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_scene_types.h"
|
2020-03-17 16:27:08 +01:00
|
|
|
#include "DNA_volume_types.h"
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2025-01-22 19:37:38 +01:00
|
|
|
#include "BLI_ghash.h"
|
2025-02-11 16:59:42 +01:00
|
|
|
#include "BLI_listbase.h"
|
2025-01-22 19:37:38 +01:00
|
|
|
#include "BLI_string.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2018-09-23 20:41:10 +03:00
|
|
|
|
2025-07-01 22:14:26 +02:00
|
|
|
#include "BKE_attribute.hh"
|
2025-01-22 19:37:38 +01:00
|
|
|
#include "BKE_context.hh"
|
2025-03-13 00:03:38 +01:00
|
|
|
#include "BKE_mesh_wrapper.hh"
|
2023-10-09 23:41:53 +02:00
|
|
|
#include "BKE_object.hh"
|
2025-03-13 00:03:38 +01:00
|
|
|
#include "BKE_subdiv_modifier.hh"
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2025-03-13 00:03:38 +01:00
|
|
|
#include "DRW_render.hh"
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_batch.hh"
|
|
|
|
|
#include "GPU_batch_utils.hh"
|
|
|
|
|
#include "GPU_capabilities.hh"
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2024-01-05 11:16:57 -05:00
|
|
|
#include "draw_cache.hh"
|
2023-08-03 20:04:50 -04:00
|
|
|
#include "draw_cache_impl.hh"
|
2025-03-13 13:47:02 +01:00
|
|
|
#include "draw_context_private.hh"
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2021-12-14 15:49:31 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Internal Defines
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2019-12-02 01:40:58 +01:00
|
|
|
#define VCLASS_LIGHT_AREA_SHAPE (1 << 0)
|
|
|
|
|
#define VCLASS_LIGHT_SPOT_SHAPE (1 << 1)
|
|
|
|
|
#define VCLASS_LIGHT_SPOT_BLEND (1 << 2)
|
|
|
|
|
#define VCLASS_LIGHT_SPOT_CONE (1 << 3)
|
|
|
|
|
#define VCLASS_LIGHT_DIST (1 << 4)
|
|
|
|
|
|
|
|
|
|
#define VCLASS_CAMERA_FRAME (1 << 5)
|
|
|
|
|
#define VCLASS_CAMERA_DIST (1 << 6)
|
|
|
|
|
#define VCLASS_CAMERA_VOLUME (1 << 7)
|
|
|
|
|
|
|
|
|
|
#define VCLASS_SCREENSPACE (1 << 8)
|
|
|
|
|
#define VCLASS_SCREENALIGNED (1 << 9)
|
|
|
|
|
|
|
|
|
|
#define VCLASS_EMPTY_SCALED (1 << 10)
|
|
|
|
|
#define VCLASS_EMPTY_AXES (1 << 11)
|
|
|
|
|
#define VCLASS_EMPTY_AXES_NAME (1 << 12)
|
|
|
|
|
#define VCLASS_EMPTY_AXES_SHADOW (1 << 13)
|
|
|
|
|
#define VCLASS_EMPTY_SIZE (1 << 14)
|
|
|
|
|
|
2021-12-14 15:49:31 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
2025-02-12 16:50:21 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Common
|
|
|
|
|
* \{ */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-02-12 16:50:21 +01:00
|
|
|
namespace blender::draw {
|
2018-10-03 15:42:05 +02:00
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
void DRW_vertbuf_create_wiredata(gpu::VertBuf *vbo, const int vert_len)
|
2018-10-03 15:42:05 +02:00
|
|
|
{
|
2025-06-10 17:20:45 +02:00
|
|
|
static const GPUVertFormat format = GPU_vertformat_from_attribute("wd",
|
|
|
|
|
gpu::VertAttrType::SFLOAT_32);
|
2025-02-12 16:50:21 +01:00
|
|
|
GPU_vertbuf_init_with_format(*vbo, format);
|
|
|
|
|
GPU_vertbuf_data_alloc(*vbo, vert_len);
|
2025-05-13 19:07:01 +02:00
|
|
|
vbo->data<float>().fill(1.0f);
|
2018-10-03 15:42:05 +02:00
|
|
|
}
|
|
|
|
|
|
2017-04-15 14:24:30 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2025-02-12 16:50:21 +01:00
|
|
|
/** \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).
|
2017-04-15 14:24:30 +10:00
|
|
|
* \{ */
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_object_all_edges_get(Object *ob)
|
2019-12-02 01:40:58 +01:00
|
|
|
{
|
2025-02-12 16:50:21 +01:00
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
|
|
|
|
return DRW_cache_mesh_all_edges_get(ob);
|
|
|
|
|
/* TODO: should match #DRW_cache_object_surface_get. */
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
2018-01-22 11:26:32 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
|
2018-01-22 11:26:32 +11:00
|
|
|
{
|
2025-02-12 16:50:21 +01:00
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
|
|
|
|
return DRW_cache_mesh_edge_detection_get(ob, r_is_manifold);
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
2018-01-22 11:26:32 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_object_face_wireframe_get(const Scene *scene, Object *ob)
|
2017-03-04 00:09:22 +01:00
|
|
|
{
|
2025-02-12 16:50:21 +01:00
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
|
|
|
|
return DRW_cache_mesh_face_wireframe_get(ob);
|
|
|
|
|
case OB_POINTCLOUD:
|
|
|
|
|
return DRW_pointcloud_batch_cache_get_dots(ob);
|
|
|
|
|
case OB_VOLUME:
|
|
|
|
|
return DRW_cache_volume_face_wireframe_get(ob);
|
|
|
|
|
case OB_GREASE_PENCIL:
|
|
|
|
|
return DRW_cache_grease_pencil_face_wireframe_get(scene, ob);
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
2017-03-04 00:09:22 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_object_loose_edges_get(Object *ob)
|
2018-01-22 00:14:28 +01:00
|
|
|
{
|
2025-02-12 16:50:21 +01:00
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
|
|
|
|
return DRW_cache_mesh_loose_edges_get(ob);
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
2018-01-22 00:14:28 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_object_surface_get(Object *ob)
|
2017-03-04 00:09:22 +01:00
|
|
|
{
|
2025-02-12 16:50:21 +01:00
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
|
|
|
|
return DRW_cache_mesh_surface_get(ob);
|
|
|
|
|
default:
|
|
|
|
|
return nullptr;
|
2017-03-04 00:09:22 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
Span<gpu::Batch *> DRW_cache_object_surface_material_get(Object *ob,
|
|
|
|
|
const Span<const GPUMaterial *> materials)
|
2025-02-12 16:50:21 +01:00
|
|
|
{
|
|
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
|
|
|
|
return DRW_cache_mesh_surface_shaded_get(ob, materials);
|
|
|
|
|
default:
|
|
|
|
|
return {};
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-15 14:24:30 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Meshes
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_all_verts_get(Object *ob)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_all_verts(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
|
2025-06-13 16:08:46 +02:00
|
|
|
gpu::Batch *DRW_cache_mesh_paint_overlay_verts_get(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
|
|
|
|
return DRW_mesh_batch_cache_get_paint_overlay_verts(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_all_edges_get(Object *ob)
|
2018-12-17 17:01:06 +01:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_all_edges(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2018-12-17 17:01:06 +01:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_loose_edges_get(Object *ob)
|
2018-11-23 16:44:16 +01:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_loose_edges(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2018-11-23 16:44:16 +01:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
|
2018-06-01 11:35:51 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_edge_detection(DRW_object_get_data_for_drawing<Mesh>(*ob),
|
|
|
|
|
r_is_manifold);
|
2018-06-01 11:35:51 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_surface_get(Object *ob)
|
2017-05-03 18:55:40 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_surface(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2017-05-03 18:55:40 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-13 16:08:46 +02:00
|
|
|
gpu::Batch *DRW_cache_mesh_paint_overlay_surface_get(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
|
|
|
|
return DRW_mesh_batch_cache_get_paint_overlay_surface(
|
|
|
|
|
DRW_object_get_data_for_drawing<Mesh>(*ob));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gpu::Batch *DRW_cache_mesh_paint_overlay_edges_get(Object *ob)
|
2017-05-04 19:59:27 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-06-13 16:08:46 +02:00
|
|
|
return DRW_mesh_batch_cache_get_paint_overlay_edges(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2017-05-04 19:59:27 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
Span<gpu::Batch *> DRW_cache_mesh_surface_shaded_get(Object *ob,
|
|
|
|
|
const Span<const GPUMaterial *> materials)
|
2017-04-25 18:46:59 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_surface_shaded(
|
|
|
|
|
*ob, DRW_object_get_data_for_drawing<Mesh>(*ob), materials);
|
2017-04-25 18:46:59 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
Span<gpu::Batch *> DRW_cache_mesh_surface_texpaint_get(Object *ob)
|
2017-05-22 23:31:46 +10:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_surface_texpaint(*ob,
|
|
|
|
|
DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2017-05-22 23:31:46 +10:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
|
2017-05-22 23:31:46 +10:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_surface_texpaint_single(
|
|
|
|
|
*ob, DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2017-05-22 23:31:46 +10:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_surface_vertpaint_get(Object *ob)
|
2017-03-09 01:29:58 +01:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_surface_vertpaint(*ob,
|
|
|
|
|
DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2017-03-09 01:29:58 +01:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_surface_sculptcolors_get(Object *ob)
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_surface_sculpt(*ob, DRW_object_get_data_for_drawing<Mesh>(*ob));
|
Sculpt Vertex Colors: Initial implementation
Sculpt Vertex Colors is a painting system that runs inside sculpt mode, reusing all its tools and optimizations. This provides much better performance, easier to maintain code and more advanced features (new brush engine, filters, symmetry options, masks and face sets compatibility...). This is also the initial step for future features like vertex painting in Multires and brushes that can sculpt and paint at the same time.
This commit includes:
- SCULPT_UNDO_COLOR for undo support in sculpt mode
- SCULPT_UPDATE_COLOR and PBVH flags and rendering
- Sculpt Color API functions
- Sculpt capability for sculpt tools (only enabled in the Paint Brush for now)
- Rendering support in workbench (default to Sculpt Vertex Colors except in Vertex Paint)
- Conversion operator between MPropCol (Sculpt Vertex Colors) and MLoopCol (Vertex Paint)
- Remesher reprojection in the Voxel Remehser
- Paint Brush and Smear Brush with color smoothing in alt-smooth mode
- Parameters for the new brush engine (density, opacity, flow, wet paint mixing, tip scale) implemented in Sculpt Vertex Colors
- Color Filter
- Color picker (uses S shortcut, replaces smooth)
- Color selector in the top bar
Reviewed By: brecht
Maniphest Tasks: T72866
Differential Revision: https://developer.blender.org/D5975
2020-06-22 20:05:28 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_surface_weights_get(Object *ob)
|
2017-04-28 22:30:21 +10:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_surface_weights(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2017-04-28 22:30:21 +10:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_face_wireframe_get(Object *ob)
|
2017-03-09 01:29:58 +01:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_wireframes_face(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2017-03-09 01:29:58 +01:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
|
2019-04-18 08:00:59 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_edit_mesh_analysis(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2019-04-18 08:00:59 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_mesh_surface_viewer_attribute_get(Object *ob)
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_MESH);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_mesh_batch_cache_get_surface_viewer_attribute(
|
|
|
|
|
DRW_object_get_data_for_drawing<Mesh>(*ob));
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
}
|
|
|
|
|
|
2017-04-15 14:24:30 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2017-04-15 16:46:17 +10:00
|
|
|
/** \name Curve
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_curve_edge_wire_get(Object *ob)
|
2017-04-15 16:46:17 +10:00
|
|
|
{
|
2022-02-18 09:50:29 -06:00
|
|
|
BLI_assert(ob->type == OB_CURVES_LEGACY);
|
2025-03-13 00:03:38 +01:00
|
|
|
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
|
|
|
|
return DRW_curve_batch_cache_get_wire_edge(&cu);
|
2017-04-15 16:46:17 +10:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_curve_edge_wire_viewer_attribute_get(Object *ob)
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_CURVES_LEGACY);
|
2025-03-13 00:03:38 +01:00
|
|
|
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
|
|
|
|
return DRW_curve_batch_cache_get_wire_edge_viewer_attribute(&cu);
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_curve_edge_normal_get(Object *ob)
|
2017-04-20 05:23:48 +10:00
|
|
|
{
|
2022-02-18 09:50:29 -06:00
|
|
|
BLI_assert(ob->type == OB_CURVES_LEGACY);
|
2025-03-13 00:03:38 +01:00
|
|
|
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
|
|
|
|
return DRW_curve_batch_cache_get_normal_edge(&cu);
|
2017-04-20 05:23:48 +10:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_curve_edge_overlay_get(Object *ob)
|
2017-04-15 16:46:17 +10:00
|
|
|
{
|
2022-02-18 09:50:29 -06:00
|
|
|
BLI_assert(ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF));
|
2017-04-15 16:46:17 +10:00
|
|
|
|
2025-03-13 00:03:38 +01:00
|
|
|
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
|
|
|
|
return DRW_curve_batch_cache_get_edit_edges(&cu);
|
2017-04-15 16:46:17 +10:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_curve_vert_overlay_get(Object *ob)
|
2017-04-15 16:46:17 +10:00
|
|
|
{
|
2022-02-18 09:50:29 -06:00
|
|
|
BLI_assert(ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF));
|
2017-04-15 16:46:17 +10:00
|
|
|
|
2025-03-13 00:03:38 +01:00
|
|
|
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
|
|
|
|
return DRW_curve_batch_cache_get_edit_verts(&cu);
|
2017-04-15 16:46:17 +10:00
|
|
|
}
|
|
|
|
|
|
2017-04-21 02:18:14 +10:00
|
|
|
/** \} */
|
|
|
|
|
|
2017-11-16 15:12:32 -02:00
|
|
|
/* -------------------------------------------------------------------- */
|
2017-04-21 02:18:14 +10:00
|
|
|
/** \name Font
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_text_edge_wire_get(Object *ob)
|
2017-04-21 02:18:14 +10:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_FONT);
|
2025-03-13 00:03:38 +01:00
|
|
|
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
|
|
|
|
return DRW_curve_batch_cache_get_wire_edge(&cu);
|
2017-04-21 02:18:14 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Surface
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_surf_edge_wire_get(Object *ob)
|
2018-12-14 15:23:13 +01:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_SURF);
|
2025-03-13 00:03:38 +01:00
|
|
|
Curve &cu = DRW_object_get_data_for_drawing<Curve>(*ob);
|
|
|
|
|
return DRW_curve_batch_cache_get_wire_edge(&cu);
|
2017-04-21 02:18:14 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \} */
|
|
|
|
|
|
2017-04-15 16:46:17 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
2017-04-15 14:24:30 +10:00
|
|
|
/** \name Lattice
|
|
|
|
|
* \{ */
|
2017-04-13 22:09:59 +10:00
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_lattice_verts_get(Object *ob)
|
2017-04-13 22:09:59 +10:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_LATTICE);
|
|
|
|
|
|
2025-03-13 00:03:38 +01:00
|
|
|
Lattice < = DRW_object_get_data_for_drawing<Lattice>(*ob);
|
|
|
|
|
return DRW_lattice_batch_cache_get_all_verts(<);
|
2017-04-13 22:09:59 +10:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
|
2017-04-13 22:09:59 +10:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_LATTICE);
|
|
|
|
|
|
2025-03-13 00:03:38 +01:00
|
|
|
Lattice < = DRW_object_get_data_for_drawing<Lattice>(*ob);
|
2017-06-27 15:59:13 +02:00
|
|
|
int actdef = -1;
|
|
|
|
|
|
2025-04-25 13:07:54 +02:00
|
|
|
if (use_weight && !BLI_listbase_is_empty(<.vertex_group_names) && lt.editlatt &&
|
|
|
|
|
lt.editlatt->latt->dvert)
|
|
|
|
|
{
|
2025-03-13 00:03:38 +01:00
|
|
|
actdef = lt.vertex_group_active_index - 1;
|
2017-06-27 15:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_lattice_batch_cache_get_all_edges(<, use_weight, actdef);
|
2017-04-13 22:09:59 +10:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_lattice_vert_overlay_get(Object *ob)
|
2017-04-13 23:29:45 +10:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_LATTICE);
|
|
|
|
|
|
2025-03-13 00:03:38 +01:00
|
|
|
Lattice < = DRW_object_get_data_for_drawing<Lattice>(*ob);
|
|
|
|
|
return DRW_lattice_batch_cache_get_edit_verts(<);
|
2017-04-13 23:29:45 +10:00
|
|
|
}
|
|
|
|
|
|
2017-05-03 08:34:24 +02:00
|
|
|
/** \} */
|
2017-05-09 16:23:47 +02:00
|
|
|
|
2020-03-17 16:27:08 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name PointCloud
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_pointcloud_vert_overlay_get(Object *ob)
|
2025-02-25 15:20:52 +01:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_POINTCLOUD);
|
|
|
|
|
|
2025-03-13 00:03:38 +01:00
|
|
|
PointCloud &pointcloud = DRW_object_get_data_for_drawing<PointCloud>(*ob);
|
|
|
|
|
return DRW_pointcloud_batch_cache_get_edit_dots(&pointcloud);
|
2025-02-25 15:20:52 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-14 15:49:31 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
2020-03-17 16:27:08 +01:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Volume
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_volume_face_wireframe_get(Object *ob)
|
2020-03-17 16:27:08 +01:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_VOLUME);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_volume_batch_cache_get_wireframes_face(&DRW_object_get_data_for_drawing<Volume>(*ob));
|
2020-03-17 16:27:08 +01:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_volume_selection_surface_get(Object *ob)
|
2020-09-29 12:39:41 +02:00
|
|
|
{
|
|
|
|
|
BLI_assert(ob->type == OB_VOLUME);
|
2025-03-13 00:03:38 +01:00
|
|
|
return DRW_volume_batch_cache_get_selection_surface(
|
|
|
|
|
&DRW_object_get_data_for_drawing<Volume>(*ob));
|
2020-09-29 12:39:41 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-17 16:27:08 +01:00
|
|
|
/** \} */
|
|
|
|
|
|
2017-05-09 16:23:47 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Particles
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md)
|
2017-05-09 16:23:47 +02:00
|
|
|
{
|
2018-05-15 12:38:49 +02:00
|
|
|
return DRW_particles_batch_cache_get_hair(object, psys, md);
|
2017-05-09 16:23:47 +02:00
|
|
|
}
|
2017-05-19 17:13:48 +02:00
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys)
|
2017-05-19 17:13:48 +02:00
|
|
|
{
|
2018-03-29 12:30:20 +02:00
|
|
|
return DRW_particles_batch_cache_get_dots(object, psys);
|
2017-05-19 17:13:48 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_particles_get_edit_strands(Object *object,
|
|
|
|
|
ParticleSystem *psys,
|
|
|
|
|
PTCacheEdit *edit,
|
|
|
|
|
bool use_weight)
|
2018-05-09 11:14:27 +02:00
|
|
|
{
|
2018-11-27 13:49:00 +01:00
|
|
|
return DRW_particles_batch_cache_get_edit_strands(object, psys, edit, use_weight);
|
2018-05-09 11:14:27 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_particles_get_edit_inner_points(Object *object,
|
|
|
|
|
ParticleSystem *psys,
|
|
|
|
|
PTCacheEdit *edit)
|
2018-05-09 14:08:44 +02:00
|
|
|
{
|
2018-05-11 14:54:50 +02:00
|
|
|
return DRW_particles_batch_cache_get_edit_inner_points(object, psys, edit);
|
2018-05-09 14:59:29 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-03 10:15:23 -04:00
|
|
|
gpu::Batch *DRW_cache_particles_get_edit_tip_points(Object *object,
|
|
|
|
|
ParticleSystem *psys,
|
|
|
|
|
PTCacheEdit *edit)
|
2018-05-09 14:59:29 +02:00
|
|
|
{
|
2018-05-11 14:54:50 +02:00
|
|
|
return DRW_particles_batch_cache_get_edit_tip_points(object, psys, edit);
|
2018-05-09 14:08:44 +02:00
|
|
|
}
|
|
|
|
|
|
2018-12-08 20:10:20 +01:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2019-08-17 00:54:22 +10:00
|
|
|
/** \name Batch Cache Implementation (common)
|
2018-12-08 20:10:20 +01:00
|
|
|
* \{ */
|
|
|
|
|
|
2019-05-07 23:21:16 +02:00
|
|
|
void drw_batch_cache_validate(Object *ob)
|
|
|
|
|
{
|
|
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_mesh_batch_cache_validate(DRW_object_get_data_for_drawing<Mesh>(*ob));
|
2019-05-07 23:21:16 +02:00
|
|
|
break;
|
2022-02-18 09:50:29 -06:00
|
|
|
case OB_CURVES_LEGACY:
|
2019-05-07 23:21:16 +02:00
|
|
|
case OB_FONT:
|
|
|
|
|
case OB_SURF:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_curve_batch_cache_validate(&DRW_object_get_data_for_drawing<Curve>(*ob));
|
2019-05-07 23:21:16 +02:00
|
|
|
break;
|
|
|
|
|
case OB_LATTICE:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_lattice_batch_cache_validate(&DRW_object_get_data_for_drawing<Lattice>(*ob));
|
2019-05-07 23:21:16 +02:00
|
|
|
break;
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
case OB_CURVES:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_curves_batch_cache_validate(&DRW_object_get_data_for_drawing<Curves>(*ob));
|
2020-03-17 16:27:08 +01:00
|
|
|
break;
|
|
|
|
|
case OB_POINTCLOUD:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_pointcloud_batch_cache_validate(&DRW_object_get_data_for_drawing<PointCloud>(*ob));
|
2020-03-17 16:27:08 +01:00
|
|
|
break;
|
|
|
|
|
case OB_VOLUME:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_volume_batch_cache_validate(&DRW_object_get_data_for_drawing<Volume>(*ob));
|
2020-03-17 16:27:08 +01:00
|
|
|
break;
|
2023-05-30 11:14:16 +02:00
|
|
|
case OB_GREASE_PENCIL:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_grease_pencil_batch_cache_validate(&DRW_object_get_data_for_drawing<GreasePencil>(*ob));
|
2019-05-07 23:21:16 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-13 13:47:02 +01:00
|
|
|
void drw_batch_cache_generate_requested(Object *ob, TaskGraph &task_graph)
|
2018-12-08 20:10:20 +01:00
|
|
|
{
|
2025-03-13 13:47:02 +01:00
|
|
|
const DRWContext *draw_ctx = DRW_context_get();
|
2019-07-14 16:49:44 +02:00
|
|
|
const Scene *scene = draw_ctx->scene;
|
2019-03-19 13:42:54 +11:00
|
|
|
const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
|
|
|
|
|
draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
|
2018-12-22 21:00:23 +01:00
|
|
|
const bool is_paint_mode = ELEM(
|
2019-07-10 13:23:47 +02:00
|
|
|
mode, CTX_MODE_SCULPT, CTX_MODE_PAINT_TEXTURE, CTX_MODE_PAINT_VERTEX, CTX_MODE_PAINT_WEIGHT);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-23 08:46:26 +11:00
|
|
|
const bool use_hide = ((ob->type == OB_MESH) &&
|
|
|
|
|
((is_paint_mode && (ob == draw_ctx->obact) &&
|
2019-04-10 09:49:02 +02:00
|
|
|
DRW_object_use_hide_faces(ob)) ||
|
2024-11-21 16:42:00 +01:00
|
|
|
((mode == CTX_MODE_EDIT_MESH) && (ob->mode == OB_MODE_EDIT))));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-08 20:10:20 +01:00
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_mesh_batch_cache_create_requested(task_graph,
|
|
|
|
|
*ob,
|
|
|
|
|
DRW_object_get_data_for_drawing<Mesh>(*ob),
|
|
|
|
|
*scene,
|
|
|
|
|
is_paint_mode,
|
|
|
|
|
use_hide);
|
2018-12-08 20:10:20 +01:00
|
|
|
break;
|
2022-02-18 09:50:29 -06:00
|
|
|
case OB_CURVES_LEGACY:
|
2018-12-13 01:26:07 +01:00
|
|
|
case OB_FONT:
|
|
|
|
|
case OB_SURF:
|
2020-12-18 16:06:26 +01:00
|
|
|
DRW_curve_batch_cache_create_requested(ob, scene);
|
2018-12-13 01:26:07 +01:00
|
|
|
break;
|
2022-04-08 18:23:40 +02:00
|
|
|
case OB_CURVES:
|
|
|
|
|
DRW_curves_batch_cache_create_requested(ob);
|
|
|
|
|
break;
|
2022-10-25 10:43:47 +02:00
|
|
|
case OB_POINTCLOUD:
|
|
|
|
|
DRW_pointcloud_batch_cache_create_requested(ob);
|
|
|
|
|
break;
|
2021-07-03 23:08:40 +10:00
|
|
|
/* TODO: all cases. */
|
2018-12-08 20:10:20 +01:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-13 13:47:02 +01:00
|
|
|
void drw_batch_cache_generate_requested_evaluated_mesh_or_curve(Object *ob, TaskGraph &task_graph)
|
2021-12-01 21:16:18 -05:00
|
|
|
{
|
2021-12-08 20:29:39 +11:00
|
|
|
/* NOTE: Logic here is duplicated from #drw_batch_cache_generate_requested. */
|
|
|
|
|
|
2025-03-13 13:47:02 +01:00
|
|
|
const DRWContext *draw_ctx = DRW_context_get();
|
2021-12-01 21:16:18 -05:00
|
|
|
const Scene *scene = draw_ctx->scene;
|
|
|
|
|
const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
|
|
|
|
|
draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
|
|
|
|
|
const bool is_paint_mode = ELEM(
|
|
|
|
|
mode, CTX_MODE_SCULPT, CTX_MODE_PAINT_TEXTURE, CTX_MODE_PAINT_VERTEX, CTX_MODE_PAINT_WEIGHT);
|
|
|
|
|
|
|
|
|
|
const bool use_hide = ((ob->type == OB_MESH) &&
|
|
|
|
|
((is_paint_mode && (ob == draw_ctx->obact) &&
|
|
|
|
|
DRW_object_use_hide_faces(ob)) ||
|
2024-11-21 16:42:00 +01:00
|
|
|
((mode == CTX_MODE_EDIT_MESH) && (ob->mode == OB_MODE_EDIT))));
|
2021-12-01 21:16:18 -05:00
|
|
|
|
2024-08-17 00:41:31 +02:00
|
|
|
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf_unchecked(ob);
|
2022-04-29 18:20:54 +02:00
|
|
|
/* Try getting the mesh first and if that fails, try getting the curve data.
|
2025-08-01 11:35:51 +00:00
|
|
|
* If the curves are surfaces or have certain modifiers applied to them,
|
|
|
|
|
* they will have mesh data of the final result. */
|
2023-07-27 14:16:58 +02:00
|
|
|
if (mesh != nullptr) {
|
2025-03-13 13:47:02 +01:00
|
|
|
DRW_mesh_batch_cache_create_requested(task_graph, *ob, *mesh, *scene, is_paint_mode, use_hide);
|
2022-04-29 18:20:54 +02:00
|
|
|
}
|
|
|
|
|
else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) {
|
|
|
|
|
DRW_curve_batch_cache_create_requested(ob, scene);
|
|
|
|
|
}
|
2021-12-01 21:16:18 -05:00
|
|
|
}
|
|
|
|
|
|
2020-06-15 15:22:40 +02:00
|
|
|
void drw_batch_cache_generate_requested_delayed(Object *ob)
|
|
|
|
|
{
|
2025-03-13 13:47:02 +01:00
|
|
|
DRWContext &draw_ctx = drw_get();
|
|
|
|
|
if (draw_ctx.delayed_extraction == nullptr) {
|
|
|
|
|
draw_ctx.delayed_extraction = BLI_gset_ptr_new(__func__);
|
|
|
|
|
}
|
|
|
|
|
BLI_gset_add(draw_ctx.delayed_extraction, ob);
|
2020-06-15 15:22:40 +02:00
|
|
|
}
|
|
|
|
|
|
2019-04-19 02:22:22 +02:00
|
|
|
void DRW_batch_cache_free_old(Object *ob, int ctime)
|
|
|
|
|
{
|
|
|
|
|
switch (ob->type) {
|
|
|
|
|
case OB_MESH:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_mesh_batch_cache_free_old(&DRW_object_get_data_for_drawing<Mesh>(*ob), ctime);
|
2019-04-19 02:22:22 +02:00
|
|
|
break;
|
EEVEE: support Curves attributes rendering
This adds support to render Curves attributes in EEVEE.
Each attribute is stored in a texture derived from a VBO. As the
shading group needs the textures to be valid upon creation, the
attributes are created and setup during its very creation, instead
of doing it lazily via create_requested which we cannot rely on
anyway as contrary to the mesh batch, we do cannot really tell if
attributes need to be updated or else via some `DRW_batch_requested`.
Since point attributes need refinement, and since attributes are all
cast to vec4/float4 to account for differences in type conversions
between Blender and OpenGL, the refinement shader for points is
used as is. The point attributes are stored for each subdivision level
in CurvesEvalFinalCache. Each subdivision level also keeps track of the
attributes already in use so they are properly updated when needed.
Some basic garbage collection was added similar to what is done
for meshes: if the attributes used over time have been different
from the currently used attributes for too long, then the buffers
are freed, ensuring that stale attributesare removed.
This adds `CurvesInfos` to the shader creation info, which stores
the scope in which the attributes are defined. Scopes are stored
as booleans, in an array indexed by attribute loading order which
is also the order in which the attributes were added to the material.
A mapping is necessary between the indices used for the scoping, and
the ones used in the Curves cache, as this may contain stale
attributes which have not been garbage collected yet.
Common utilities with the mesh code for handling requested
attributes were moved to a separate file.
Differential Revision: https://developer.blender.org/D14916
2022-05-24 05:02:57 +02:00
|
|
|
case OB_CURVES:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_curves_batch_cache_free_old(&DRW_object_get_data_for_drawing<Curves>(*ob), ctime);
|
EEVEE: support Curves attributes rendering
This adds support to render Curves attributes in EEVEE.
Each attribute is stored in a texture derived from a VBO. As the
shading group needs the textures to be valid upon creation, the
attributes are created and setup during its very creation, instead
of doing it lazily via create_requested which we cannot rely on
anyway as contrary to the mesh batch, we do cannot really tell if
attributes need to be updated or else via some `DRW_batch_requested`.
Since point attributes need refinement, and since attributes are all
cast to vec4/float4 to account for differences in type conversions
between Blender and OpenGL, the refinement shader for points is
used as is. The point attributes are stored for each subdivision level
in CurvesEvalFinalCache. Each subdivision level also keeps track of the
attributes already in use so they are properly updated when needed.
Some basic garbage collection was added similar to what is done
for meshes: if the attributes used over time have been different
from the currently used attributes for too long, then the buffers
are freed, ensuring that stale attributesare removed.
This adds `CurvesInfos` to the shader creation info, which stores
the scope in which the attributes are defined. Scopes are stored
as booleans, in an array indexed by attribute loading order which
is also the order in which the attributes were added to the material.
A mapping is necessary between the indices used for the scoping, and
the ones used in the Curves cache, as this may contain stale
attributes which have not been garbage collected yet.
Common utilities with the mesh code for handling requested
attributes were moved to a separate file.
Differential Revision: https://developer.blender.org/D14916
2022-05-24 05:02:57 +02:00
|
|
|
break;
|
2022-10-25 10:43:47 +02:00
|
|
|
case OB_POINTCLOUD:
|
2025-03-13 00:03:38 +01:00
|
|
|
DRW_pointcloud_batch_cache_free_old(&DRW_object_get_data_for_drawing<PointCloud>(*ob),
|
|
|
|
|
ctime);
|
2022-10-25 10:43:47 +02:00
|
|
|
break;
|
2019-04-19 02:22:22 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-08 20:10:20 +01:00
|
|
|
/** \} */
|
2022-06-08 12:30:01 -07:00
|
|
|
|
|
|
|
|
void DRW_cdlayer_attr_aliases_add(GPUVertFormat *format,
|
2022-06-09 09:48:37 +10:00
|
|
|
const char *base_name,
|
2025-07-01 22:14:26 +02:00
|
|
|
const bke::AttrType data_type,
|
2025-06-03 10:15:23 -04:00
|
|
|
const StringRef layer_name,
|
2022-06-08 12:30:01 -07:00
|
|
|
bool is_active_render,
|
|
|
|
|
bool is_active_layer)
|
|
|
|
|
{
|
|
|
|
|
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
|
|
|
|
|
GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
|
|
|
|
|
|
|
|
|
|
/* Attribute layer name. */
|
2023-05-09 12:50:37 +10:00
|
|
|
SNPRINTF(attr_name, "%s%s", base_name, attr_safe_name);
|
2022-06-08 12:30:01 -07:00
|
|
|
GPU_vertformat_alias_add(format, attr_name);
|
|
|
|
|
|
|
|
|
|
/* Auto layer name. */
|
2023-05-09 12:50:37 +10:00
|
|
|
SNPRINTF(attr_name, "a%s", attr_safe_name);
|
2022-06-08 12:30:01 -07:00
|
|
|
GPU_vertformat_alias_add(format, attr_name);
|
|
|
|
|
|
|
|
|
|
/* Active render layer name. */
|
|
|
|
|
if (is_active_render) {
|
2025-07-01 22:14:26 +02:00
|
|
|
GPU_vertformat_alias_add(format, data_type == bke::AttrType::Float2 ? "a" : base_name);
|
2022-06-08 12:30:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Active display layer name. */
|
|
|
|
|
if (is_active_layer) {
|
2023-05-09 12:50:37 +10:00
|
|
|
SNPRINTF(attr_name, "a%s", base_name);
|
2022-06-08 12:30:01 -07:00
|
|
|
GPU_vertformat_alias_add(format, attr_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-03 10:15:23 -04:00
|
|
|
|
|
|
|
|
} // namespace blender::draw
|