47#define ACTIVE_NURB (1 << 2)
48#define BEZIER_HANDLE (1 << 3)
49#define EVEN_U_BIT (1 << 4)
78 for (
Nurb &nu : *lb) {
80 vert_len += nu.pntsu * 3;
82 edge_len += 2 * nu.pntsu;
85 vert_len += nu.pntsu * nu.pntsv;
87 edge_len += (nu.pntsu - 1) * nu.pntsv;
88 edge_len += (nu.pntsv - 1) * nu.pntsu;
92 *r_vert_len = vert_len;
95 *r_edge_len = edge_len;
107 *r_curve_len =
curves.curves_num();
110 for (
const int i :
curves.curves_range()) {
120 for (bl = ob_curve_cache->
bev.first(), nu = lb->first(); nu && bl; bl = bl->
next, nu = nu->
next)
123 int skip = nu->
resolu / 16;
131 normal_len += (nr / (skip + 1)) + ((nr % (skip + 1)) != 0);
201 rdata->
types = types;
202 ListBaseT<Nurb> *nurbs;
214 &rdata->
wire.curve_len,
215 &rdata->
wire.vert_len,
216 &rdata->
wire.edge_len);
222 nurbs = &editnurb->
nurbs;
239 rdata->
nurbs = nurbs;
249 if (rdata->loose_verts) {
250 MEM_delete(rdata->loose_verts);
259 return rdata->
overlay.vert_len;
265 return rdata->
overlay.edge_len;
271 return rdata->
wire.vert_len;
277 return rdata->
wire.edge_len;
283 return rdata->
wire.curve_len;
335 if (cache ==
nullptr) {
365 memset(cache, 0,
sizeof(*cache));
369 ListBaseT<Nurb> *nurbs;
372 nurbs = &editnurb->
nurbs;
400 if (cache ==
nullptr) {
425 for (
int i = 0; i <
sizeof(cache->
ordered) /
sizeof(
void *); i++) {
429 for (
int i = 0; i <
sizeof(cache->
edit) /
sizeof(
void *); i++) {
433 for (
int i = 0; i <
sizeof(cache->
ibo) /
sizeof(
void *); i++) {
437 for (
int i = 0; i <
sizeof(cache->
batch) /
sizeof(
void *); i++) {
438 gpu::Batch **batch =
reinterpret_cast<gpu::Batch **
>(&cache->
batch);
496 curves.ensure_can_interpolate_to_evaluated();
512 const int index_len = edge_len + curve_len * 2;
521 for (
const int i :
curves.curves_range()) {
523 if (cyclic[i] && points.
size() > 1) {
526 for (
const int i_point : points) {
544 uint pos_hq, nor_hq, tan_hq, rad_hq;
562 &format,
"tangent", gpu::VertAttrType::SNORM_16_16_16_16);
566 const GPUVertFormat &format_ptr = do_hq_normals ? format_hq : format;
569 int vbo_len_used = 0;
577 const uint pos_id = do_hq_normals ? attr_id.pos_hq : attr_id.pos;
578 const uint nor_id = do_hq_normals ? attr_id.nor_hq : attr_id.nor;
579 const uint tan_id = do_hq_normals ? attr_id.tan_hq : attr_id.tan;
580 const uint rad_id = do_hq_normals ? attr_id.rad_hq : attr_id.rad;
587 int skip = nu->
resolu / 16;
590 float nor[3] = {1.0f, 0.0f, 0.0f};
618 BLI_assert(vbo_len_used == verts_len_capacity);
627 const bool handle_selected)
679 int vbo_len_used = 0;
681#define DRW_TEST_ASSIGN_VBO(v) (v = (DRW_vbo_requested(v) ? (v) : nullptr))
682#define DRW_TEST_ASSIGN_IBO(v) (v = (DRW_ibo_requested(v) ? (v) : nullptr))
696 elbp_verts = &elb_verts;
700 elbp_lines = &elb_lines;
704#undef DRW_TEST_ASSIGN_VBO
705#undef DRW_TEST_ASSIGN_IBO
708 for (
Nurb *nu = rdata->
nurbs->first(); nu; nu = nu->next, nu_id++) {
710 const BPoint *bp = nu->bp;
713 for (
int a = 0; a < nu->pntsu; a++, bezt++) {
714 if (bezt->
hide != 0) {
734 for (
int j = 0; j < 3; j++) {
739 for (
int j = 0; j < 3; j++) {
747 int pt_len = nu->pntsu * nu->pntsv;
748 for (
int a = 0; a < pt_len; a++, bp++, vbo_len_used += 1) {
752 int u = (a % nu->pntsu);
753 int v = (a / nu->pntsu);
760 const BPoint *bp_next_u = (u < (nu->pntsu - 1)) ? &nu->bp[a + 1] :
nullptr;
761 const BPoint *bp_next_v = (
v < (nu->pntsv - 1)) ? &nu->bp[a + nu->pntsu] :
nullptr;
762 if (bp_next_u && (bp_next_u->
hide ==
false)) {
765 if (bp_next_v && (bp_next_v->
hide ==
false)) {
781 if (elbp_verts !=
nullptr) {
784 if (elbp_lines !=
nullptr) {
787 if (vbo_len_used != verts_len_capacity) {
788 if (vbo_pos !=
nullptr) {
791 if (vbo_data !=
nullptr) {
872#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
889#ifdef DRW_DEBUG_MESH_CACHE_REQUEST
890 printf(
" mr_flag %d\n\n", mr_flag);
909 rdata, cache->
edit.pos, cache->
edit.data, cache->
ibo.edit_verts, cache->
ibo.edit_lines);
919 for (
int i = 0; i <
sizeof(cache->
batch) /
sizeof(
void *); i++) {
Low-level operations for curves.
#define BEZT_ISSEL_ANY(bezt)
Object is a sort of wrapper for general info.
#define GPU_BATCH_DISCARD_SAFE(batch)
#define GPU_INDEXBUF_DISCARD_SAFE(elem)
#define GPU_vertbuf_init_with_format(verts, format)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
Read Blender memory allocation and freeing.
#define SET_FLAG_FROM_TEST(value, test, flag)
constexpr int64_t last(const int64_t n=0) const
constexpr int64_t size() const
constexpr const T * data() const
#define DRW_TEST_ASSIGN_VBO(v)
#define DRW_TEST_ASSIGN_IBO(v)
#define DRW_ADD_FLAG_FROM_IBO_REQUEST(flag, ibo, value)
#define DRW_ADD_FLAG_FROM_VBO_REQUEST(flag, vbo, value)
int segments_num(const int points_num, const bool cyclic)
static int curve_render_normal_len_get(const ListBaseT< Nurb > *lb, const CurveCache *ob_curve_cache)
static void curve_batch_cache_init(Curve *cu)
static void curve_create_curves_lines(CurveRenderData *rdata, gpu::IndexBuf *ibo_curve_lines)
static uint8_t beztriple_vflag_get(CurveRenderData *rdata, uint8_t flag, uint8_t col_id, int v_idx, int nu_id, bool handle_point, const bool handle_selected)
gpu::Batch * DRW_curve_batch_cache_get_wire_edge(Curve *cu)
gpu::Batch * DRW_curve_batch_cache_get_edit_verts(Curve *cu)
static int curve_render_data_wire_verts_len_get(const CurveRenderData *rdata)
static int curve_render_data_normal_len_get(const CurveRenderData *rdata)
gpu::Batch * DRW_curve_batch_cache_get_edit_edges(Curve *cu)
void DRW_curve_batch_cache_validate(Curve *cu)
static void curve_create_curves_pos(CurveRenderData *rdata, gpu::VertBuf *vbo_curves_pos)
void DRW_curve_batch_cache_create_requested(Object *ob, const Scene *scene)
static int curve_render_data_overlay_edges_len_get(const CurveRenderData *rdata)
gpu::Batch * DRW_curve_batch_cache_get_normal_edge(Curve *cu)
static int curve_render_data_overlay_verts_len_get(const CurveRenderData *rdata)
static void curve_batch_cache_clear(Curve *cu)
void DRW_curve_batch_cache_free(Curve *cu)
static CurveRenderData * curve_render_data_create(Curve *cu, CurveCache *ob_curve_cache, const int types)
static void curve_create_edit_data_and_handles(CurveRenderData *rdata, gpu::VertBuf *vbo_pos, gpu::VertBuf *vbo_data, gpu::IndexBuf *ibo_edit_verts_points, gpu::IndexBuf *ibo_edit_lines)
static void curve_render_data_free(CurveRenderData *rdata)
static void curve_create_edit_curves_nor(CurveRenderData *rdata, gpu::VertBuf &vbo_curves_nor, const Scene *scene)
static void curve_eval_render_wire_verts_edges_len_get(const bke::CurvesGeometry &curves, int *r_curve_len, int *r_vert_len, int *r_edge_len)
@ CU_DATATYPE_TEXT_SELECT
static CurveBatchCache * curve_batch_cache_get(Curve *cu)
static int curve_render_data_wire_edges_len_get(const CurveRenderData *rdata)
@ VFLAG_VERT_SELECTED_BEZT_HANDLE
static void curve_create_attribute(CurveRenderData *rdata, gpu::VertBuf &vbo_attr)
static bool curve_batch_cache_valid(Curve *cu)
static uint8_t bpoint_vflag_get(CurveRenderData *rdata, uint8_t flag, int v_idx, int nu_id, int u)
static void curve_render_overlay_verts_edges_len_get(ListBaseT< Nurb > *lb, int *r_vert_len, int *r_edge_len)
static int curve_render_data_wire_curve_len_get(const CurveRenderData *rdata)
gpu::Batch * DRW_curve_batch_cache_get_wire_edge_viewer_attribute(Curve *cu)
void DRW_curve_batch_cache_dirty_tag(Curve *cu, int mode)
GPUType convert_normal(const float3 &src)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool DRW_vbo_requested(gpu::VertBuf *vbo)
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
void GPU_indexbuf_init_ex(GPUIndexBufBuilder *, GPUPrimType, uint index_len, uint vertex_len)
void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder *, uint v1, uint v2)
@ BKE_CURVE_BATCH_DIRTY_SELECT
@ BKE_CURVE_BATCH_DIRTY_ALL
bool DRW_batch_requested(gpu::Batch *batch, GPUPrimType prim_type)
NormalizedIntVecBase< int32_t, 4, 10, 10, 10, 2 > int1010102_norm
void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void mul_qt_v3(const float q[4], float r[3])
void GPU_indexbuf_add_point_vert(GPUIndexBufBuilder *, uint v)
bool GPU_use_hq_normals_workaround()
void DRW_ibo_request(gpu::Batch *batch, gpu::IndexBuf **ibo)
VecBase< int16_t, 4 > short4
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
BMesh const char void * data
void GPU_vertbuf_attr_set(gpu::VertBuf *, uint a_idx, uint v_idx, const void *data)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
gpu::Batch * DRW_batch_request(gpu::Batch **batch)
void GPU_indexbuf_build_in_place(GPUIndexBufBuilder *, gpu::IndexBuf *)
void GPU_vertbuf_attr_fill(gpu::VertBuf *, uint a_idx, const void *data)
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_data_resize(gpu::VertBuf &verts, uint v_len)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *, uint v)
void DRW_vbo_request(gpu::Batch *batch, gpu::VertBuf **vbo)
bool DRW_ibo_requested(gpu::IndexBuf *ibo)
draw::CurveBatchCache * batch_cache
struct EditFont * editfont
const struct Curves * curve_eval
bke::ObjectRuntime * runtime
gpu::Batch * curves_viewer_attribute
gpu::Batch * edit_normals
gpu::VertBuf * curves_nor
gpu::IndexBuf * edit_lines
gpu::IndexBuf * curves_lines
gpu::IndexBuf * edit_verts
gpu::VertBuf * attr_viewer
gpu::VertBuf * curves_pos
struct blender::draw::CurveBatchCache::@117233340275271205236250237042040155364224105215 batch
struct blender::draw::CurveBatchCache::@040107133132046031343153272054144012243140154177 ordered
struct blender::draw::CurveBatchCache::@355071361272372030321231073334204212050152124174 edit
struct blender::draw::CurveBatchCache::@260144065074011242340067260211121017253277205337 ibo
struct blender::draw::CurveRenderData::@337107320215060062110314175061257367143143163165 text
ListBaseT< Nurb > * nurbs
struct blender::draw::CurveRenderData::@124206200031341362373017142205366153206353154353 overlay
struct blender::draw::CurveRenderData::@211171046232016311055316251124002356125250256323 normal
CurveCache * ob_curve_cache
struct blender::draw::CurveRenderData::@075216234255024276045273253146004311125135140117 wire
const Curves * curve_eval