Updating attributes is now done specifically for each attribute, and topology and visibility updates tag the draw cache data explicitly too. That makes checking for updates with these tags unnecessary.
95 lines
2.5 KiB
C++
95 lines
2.5 KiB
C++
/* SPDX-FileCopyrightText: 2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup draw
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <variant>
|
|
|
|
#include "BLI_index_mask_fwd.hh"
|
|
#include "BLI_string_ref.hh"
|
|
#include "BLI_struct_equality_utils.hh"
|
|
#include "BLI_vector.hh"
|
|
|
|
#include "BKE_pbvh_api.hh"
|
|
|
|
#include "DNA_customdata_types.h"
|
|
|
|
namespace blender::gpu {
|
|
class Batch;
|
|
class IndexBuf;
|
|
class VertBuf;
|
|
} // namespace blender::gpu
|
|
struct Object;
|
|
namespace blender::bke {
|
|
enum class AttrDomain : int8_t;
|
|
namespace pbvh {
|
|
class Node;
|
|
class DrawCache;
|
|
class Tree;
|
|
} // namespace pbvh
|
|
} // namespace blender::bke
|
|
|
|
namespace blender::draw::pbvh {
|
|
|
|
class GenericRequest {
|
|
public:
|
|
std::string name;
|
|
eCustomDataType type;
|
|
bke::AttrDomain domain;
|
|
GenericRequest(const StringRef name, const eCustomDataType type, const bke::AttrDomain domain)
|
|
: name(name), type(type), domain(domain)
|
|
{
|
|
}
|
|
BLI_STRUCT_EQUALITY_OPERATORS_3(GenericRequest, type, domain, name);
|
|
};
|
|
|
|
enum class CustomRequest : int8_t {
|
|
Position,
|
|
Normal,
|
|
Mask,
|
|
FaceSet,
|
|
};
|
|
|
|
using AttributeRequest = std::variant<CustomRequest, GenericRequest>;
|
|
|
|
struct ViewportRequest {
|
|
Vector<AttributeRequest> attributes;
|
|
bool use_coarse_grids;
|
|
BLI_STRUCT_EQUALITY_OPERATORS_2(ViewportRequest, attributes, use_coarse_grids);
|
|
uint64_t hash() const;
|
|
};
|
|
|
|
class DrawCache : public bke::pbvh::DrawCache {
|
|
public:
|
|
virtual ~DrawCache() = default;
|
|
/**
|
|
* Recalculate and copy data as necessary to prepare batches for drawing triangles for a
|
|
* specific combination of attributes.
|
|
*/
|
|
virtual Span<gpu::Batch *> ensure_tris_batches(const Object &object,
|
|
const ViewportRequest &request,
|
|
const IndexMask &nodes_to_update) = 0;
|
|
/**
|
|
* Recalculate and copy data as necessary to prepare batches for drawing wireframe geometry for a
|
|
* specific combination of attributes.
|
|
*/
|
|
virtual Span<gpu::Batch *> ensure_lines_batches(const Object &object,
|
|
const ViewportRequest &request,
|
|
const IndexMask &nodes_to_update) = 0;
|
|
|
|
/**
|
|
* Return the material index for each node (all faces in a node should have the same material
|
|
* index, as ensured by the BVH building process).
|
|
*/
|
|
virtual Span<int> ensure_material_indices(const Object &object) = 0;
|
|
};
|
|
|
|
DrawCache &ensure_draw_data(std::unique_ptr<bke::pbvh::DrawCache> &ptr);
|
|
|
|
} // namespace blender::draw::pbvh
|