74 if (dl->type == type) {
83 const DispList *dl,
int a,
int *
b,
int *p1,
int *p2,
int *p3,
int *p4)
91 (*p2) = (*p1) + dl->
nr - 1;
92 (*p3) = (*p1) + dl->
nr;
93 (*p4) = (*p2) + dl->
nr;
99 (*p4) = (*p2) + dl->
nr;
100 (*p3) = (*p1) + dl->
nr;
112#ifdef __INTEL_COMPILER
114# pragma intel optimization_level 1
119 const bool for_render,
125 if (nu->hide != 0 && editmode) {
136 const BezTriple *bezt_first = &nu->bezt[0];
137 const BezTriple *bezt_last = &nu->bezt[nu->pntsu - 1];
139 for (
int i = 1; i < nu->pntsu; i++) {
140 const BezTriple *prevbezt = &nu->bezt[i - 1];
146 samples_len += resolution;
155 samples_len += resolution;
166 const bool use_cyclic_sample =
is_cyclic && (samples_len != 2);
168 DispList *dl = MEM_cnew<DispList>(__func__);
170 dl->verts = (
float *)
MEM_mallocN(
sizeof(
float[3]) * (samples_len + 1), __func__);
173 dl->nr = samples_len;
174 dl->col = nu->mat_nr;
175 dl->charidx = nu->charidx;
179 float *data = dl->verts;
180 for (
int i = 1; i < nu->pntsu; i++) {
181 const BezTriple *prevbezt = &nu->bezt[i - 1];
189 for (
int j = 0; j < 3; j++) {
198 data += 3 * resolution;
206 for (
int j = 0; j < 3; j++) {
208 bezt_last->
vec[2][j],
209 bezt_first->
vec[0][j],
210 bezt_first->
vec[1][j],
223 DispList *dl = MEM_cnew<DispList>(__func__);
228 dl->
col = nu->mat_nr;
234 else if (nu->type ==
CU_POLY) {
235 const int len = nu->pntsu;
236 DispList *dl = MEM_cnew<DispList>(__func__);
241 dl->
col = nu->mat_nr;
246 for (
int i = 0; i <
len; i++) {
247 const BPoint *bp = &nu->bp[i];
256 const float normal_proj[3],
257 const bool flip_normal)
259 if (dispbase ==
nullptr) {
273 bool should_continue =
true;
274 while (should_continue) {
275 should_continue =
false;
276 bool nextcol =
false;
282 short dl_flag_accum = 0;
283 short dl_rt_accum = 0;
286 if (charidx < dl->charidx) {
287 should_continue =
true;
289 else if (charidx == dl->charidx) {
290 if (colnr == dl->col) {
298 for (
int i = 0; i < dl->nr; i++) {
299 sf_vert_last = sf_vert;
302 if (sf_vert_last ==
nullptr) {
303 sf_vert_new = sf_vert;
310 if (sf_vert !=
nullptr && sf_vert_new !=
nullptr) {
314 else if (colnr < dl->
col) {
316 should_continue =
true;
320 dl_flag_accum |= dl->flag;
321 dl_rt_accum |= dl->rt;
326 if (totvert != 0 && triangles_len != 0) {
327 DispList *dlnew = MEM_cnew<DispList>(__func__);
333 dlnew->
parts = triangles_len;
335 dlnew->
index = (
int *)
MEM_mallocN(
sizeof(
int[3]) * triangles_len, __func__);
346 int *index = dlnew->
index;
348 index[0] = sf_tri->v1->tmp.i;
349 index[1] = flip_normal ? sf_tri->v3->tmp.i : sf_tri->v2->tmp.i;
350 index[2] = flip_normal ? sf_tri->v2->tmp.i : sf_tri->v3->tmp.i;
375 ListBase front = {
nullptr,
nullptr};
382 DispList *dlnew = MEM_cnew<DispList>(__func__);
384 dlnew->
verts = (
float *)
MEM_mallocN(
sizeof(
float[3]) * dl->parts, __func__);
385 dlnew->
nr = dl->parts;
389 dlnew->
col = dl->col;
392 const float *old_verts = dl->verts;
393 float *new_verts = dlnew->
verts;
394 for (
int i = 0; i < dl->parts; i++) {
397 old_verts += 3 * dl->nr;
401 DispList *dlnew = MEM_cnew<DispList>(__func__);
403 dlnew->
verts = (
float *)
MEM_mallocN(
sizeof(
float[3]) * dl->parts, __func__);
404 dlnew->
nr = dl->parts;
408 dlnew->
col = dl->col;
411 const float *old_verts = dl->verts + 3 * (dl->nr - 1);
412 float *new_verts = dlnew->
verts;
413 for (
int i = 0; i < dl->parts; i++) {
416 old_verts += 3 * dl->nr;
423 const float z_up[3] = {0.0f, 0.0f, -1.0f};
443 const float z_up[3] = {0.0f, 0.0f, -1.0f};
475 dx = dl->
verts[3 * (dl->
nr - 1)] - minx;
478 for (a = 0; a < dl->
nr; a++, fp += 3) {
479 if ((fp[0] - minx) / dx >= fac) {
482 float fac1 = (fp[-3] - minx) / dx;
483 float fac2 = (fp[0] - minx) / dx;
485 return fp[1] * (fac1 - fac) / (fac1 - fac2) + fp[-2] * (fac - fac2) / (fac1 - fac2);
501 const float fac =
float(cur) /
float(tot - 1);
508 const bool for_render,
520 for (; md; md = md->
next) {
527 return pretessellatePoint;
533 md->
mode &= ~eModifierMode_ApplyOnSpline;
534 return pretessellatePoint;
537 pretessellatePoint = md;
545 pretessellatePoint = md;
549 return pretessellatePoint;
557 const bool for_render)
577 float *keyVerts =
nullptr;
578 float(*deformedVerts)[3] =
nullptr;
598 if (pretessellatePoint) {
614 if (!deformedVerts) {
619 md, &mectx,
nullptr, {
reinterpret_cast<blender::float3 *
>(deformedVerts), numVerts});
621 if (md == pretessellatePoint) {
665 if (curve->extrude != 0.0f || curve->bevel_radius != 0.0f) {
672 for (; md; md = md->
next) {
688 const bool for_render)
692 const bool use_cache = !for_render;
710 pretessellatePoint->
next;
722 for (; md; md = md->
next) {
741 mti->
deform_verts(md, &mectx_deform, mesh, mesh->vert_positions_for_write());
742 mesh->tag_positions_changed();
746 if (mesh != output_mesh) {
763 int b, p1, p2, p3, p4;
770 for (
int a = 0; a < dl->
parts; a++) {
776 for (;
b < dl->
nr;
b++, index += 4) {
795 const bool for_render,
820 if (nu->pntsv == 1) {
823 DispList *dl = MEM_cnew<DispList>(__func__);
829 dl->
col = nu->mat_nr;
833 float *data = dl->
verts;
844 const int len = (nu->pntsu * resolu) * (nu->pntsv * resolv);
846 DispList *dl = MEM_cnew<DispList>(__func__);
850 dl->
col = nu->mat_nr;
854 float *data = dl->
verts;
857 dl->
parts = (nu->pntsu * resolu);
858 dl->
nr = (nu->pntsv * resolv);
875 depsgraph, scene, ob, r_dispbase, for_render);
886 const float bev_blend,
888 const float radius_factor,
891 float *data = *r_data;
892 const float *fp = dlb->
verts;
893 for (
int b = 0;
b < dlb->
nr;
b++, fp += 3, data += 3) {
895 float vec[3], quat[4];
897 vec[0] = fp[1] + widfac;
901 if (nbevp ==
nullptr) {
912 data[0] += radius_factor * vec[0];
913 data[1] += radius_factor * vec[1];
914 data[2] += radius_factor * vec[2];
919 if (nbevp ==
nullptr) {
930 sina = nbevp->
sina * bev_blend + bevp->
sina * (1.0f - bev_blend);
931 cosa = nbevp->
cosa * bev_blend + bevp->
cosa * (1.0f - bev_blend);
934 data[0] += radius_factor * (widfac + fp[1]) * sina;
935 data[1] += radius_factor * (widfac + fp[1]) * cosa;
936 data[2] += radius_factor * fp[2];
945 const float *prev_fp,
948 DispList *dl = MEM_cnew<DispList>(__func__);
950 memcpy(dl->
verts, prev_fp,
sizeof(
float[3]) * dlb->
nr);
964 const BevList *bl,
float bevfac,
float spline_length,
int *r_bev,
float *r_blend)
966 float normsum = 0.0f;
967 float *seglen = bl->
seglen;
969 int bevcount = 0, nr = bl->
nr;
971 float bev_fl = bevfac * (bl->
nr - 1);
972 *r_bev =
int(bev_fl);
974 while (bevcount < nr - 1) {
975 float normlen = *seglen / spline_length;
976 if (normsum + normlen > bevfac) {
977 bev_fl = bevcount + (bevfac - normsum) / normlen * *segbevcount;
978 *r_bev =
int(bev_fl);
979 *r_blend = bev_fl - *r_bev;
983 bevcount += *segbevcount;
990 const BevList *bl,
float bevfac,
float spline_length,
int *r_bev,
float *r_blend)
992 const float len_target = bevfac * spline_length;
994 float len_next = 0.0f,
len = 0.0f;
995 int i = 0, nr = bl->
nr;
1000 if (len_next > len_target) {
1008 *r_blend = (len_target -
len) / bevp->
offset;
1012 const BevList *bl,
int *r_start,
float *r_firstblend,
int *r_steps,
float *r_lastblend)
1016 *r_firstblend = 1.0f;
1017 *r_lastblend = 1.0f;
1024 float *r_firstblend,
1028 float tmpf, total_length = 0.0f;
1043 total_length += bl->
seglen[i];
1049 const float start_fl = cu->
bevfac1 * (bl->
nr - 1);
1050 *r_start =
int(start_fl);
1051 *r_firstblend = 1.0f - (start_fl - (*r_start));
1056 *r_firstblend = 1.0f - *r_firstblend;
1061 *r_firstblend = 1.0f - *r_firstblend;
1068 const float end_fl = cu->
bevfac2 * (bl->
nr - 1);
1071 *r_steps = 2 + end - *r_start;
1072 *r_lastblend = end_fl - end;
1077 *r_steps = end - *r_start + 2;
1082 *r_steps = end - *r_start + 2;
1087 if (end < *r_start || (end == *r_start && *r_lastblend < 1.0f - *r_firstblend)) {
1088 std::swap(*r_start, end);
1089 tmpf = *r_lastblend;
1090 *r_lastblend = 1.0f - *r_firstblend;
1091 *r_firstblend = 1.0f - tmpf;
1092 *r_steps = end - *r_start + 2;
1095 if (*r_start + *r_steps > bl->
nr) {
1096 *r_steps = bl->
nr - *r_start;
1097 *r_lastblend = 1.0f;
1104 const bool for_render,
1137 const float widfac = cu->
offset - 1.0f;
1141 for (; bl && nu; bl = bl->
next, nu = nu->
next) {
1150 DispList *dl = MEM_cnew<DispList>(
"makeDispListbev");
1154 if (bl->
poly != -1) {
1172 data[0] = bevp->
vec[0] + widfac * bevp->
sina;
1173 data[1] = bevp->
vec[1] + widfac * bevp->
cosa;
1174 data[2] = bevp->
vec[2];
1180 ListBase bottom_capbase = {
nullptr,
nullptr};
1181 ListBase top_capbase = {
nullptr,
nullptr};
1182 float bottom_no[3] = {0.0f};
1183 float top_no[3] = {0.0f};
1184 float first_blend = 0.0f, last_blend = 0.0f;
1185 int start,
steps = 0;
1200 DispList *dl = MEM_cnew<DispList>(__func__);
1224 for (
int i = start, a = 0; a <
steps; i++, bevp++, a++) {
1225 float radius_factor = 1.0;
1226 float *cur_data =
data;
1229 radius_factor = bevp->
radius;
1234 float len = (
steps - 3) + first_blend + last_blend;
1237 taper_factor = 0.0f;
1239 else if (a ==
steps - 1) {
1240 taper_factor = 1.0f;
1243 taper_factor = (
float(a) - (1.0f - first_blend)) /
len;
1247 float len = bl->
nr - 1;
1251 taper_factor += (1.0f - first_blend) /
len;
1253 else if (a ==
steps - 1) {
1254 taper_factor -= (1.0f - last_blend) /
len;
1261 radius_factor *= bevp->
radius;
1264 radius_factor += bevp->
radius;
1269 if ((a == 0) && (bevp != bevp_last)) {
1271 cu, bevp, bevp + 1, dlb, 1.0f - first_blend, widfac, radius_factor, &data);
1273 else if ((a ==
steps - 1) && (bevp != bevp_first)) {
1275 cu, bevp, bevp - 1, dlb, 1.0f - last_blend, widfac, radius_factor, &data);
1278 rotateBevelPiece(cu, bevp,
nullptr, dlb, 0.0f, widfac, radius_factor, &data);
1283 fillBevelCap(nu, dlb, cur_data - 3 * dlb->nr, &bottom_capbase);
1286 if (a ==
steps - 1) {
1297 if (bottom_capbase.
first) {
1316 const bool for_render)
1324 const Curve &original_curve = *
static_cast<const Curve *
>(ob->
data);
1326 ob->
runtime->curve_cache = MEM_cnew<CurveCache>(__func__);
1331 depsgraph, scene, ob, for_render, dispbase);
1336 depsgraph, scene, ob, for_render, dispbase);
1338 if (geometry.has_curves()) {
1352 Curve &cow_curve = *
reinterpret_cast<Curve *
>(
1354 cow_curve.
curve_eval = geometry.get_curves();
1371 const int tot = dl->type ==
DL_INDEX3 ? dl->nr : dl->nr * dl->parts;
void BKE_anim_path_calc_data(struct Object *ob)
const ListBase * BKE_curve_editNurbs_get_for_read(const Curve *cu)
void BKE_nurb_makeFaces(const Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv)
const ListBase * BKE_curve_nurbs_get_for_read(const Curve *cu)
bool BKE_nurb_check_valid_uv(const Nurb *nu)
void BKE_nurb_makeCurve(const Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride)
void BKE_curve_nurbs_key_vert_tilts_apply(ListBase *lb, const float *key)
void BKE_nurbList_duplicate(ListBase *lb1, const ListBase *lb2)
ListBase BKE_curve_bevel_make(const Curve *curve)
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
void BKE_curve_nurbs_vert_coords_apply(ListBase *lb, const float(*vert_coords)[3], bool constrain_2d)
bool BKE_nurb_check_valid_u(const Nurb *nu)
float(* BKE_curve_nurbs_key_vert_coords_alloc(const ListBase *lb, float *key, int *r_vert_len))[3]
void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, bool for_render)
float(* BKE_curve_nurbs_vert_coords_alloc(const ListBase *lb, int *r_vert_len))[3]
display list (or rather multi purpose list) stuff.
int BKE_keyblock_curve_element_count(const ListBase *nurb)
float * BKE_key_evaluate_object(Object *ob, int *r_totelem)
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
Mesh * BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *dispbase)
void BKE_modifiers_clear_errors(Object *ob)
bool BKE_modifier_is_enabled(const Scene *scene, ModifierData *md, int required_mode)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
General operations, lookup, etc. for blender objects.
void BKE_object_eval_assign_data(Object *object, ID *data, bool is_owned)
void BKE_object_free_derived_caches(Object *ob)
bool BKE_vfont_to_curve_nubase(Object *ob, eEditFontMode mode, ListBase *r_nubase)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
void mul_qt_v3(const float q[4], float r[3])
void copy_qt_qt(float q[4], const float a[4])
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void zero_v3(float r[3])
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
struct MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
@ BLI_SCANFILL_CALC_POLYS
@ BLI_SCANFILL_CALC_HOLES
@ BLI_SCANFILL_CALC_REMOVE_DOUBLES
struct ScanFillVert * BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3])
struct ScanFillEdge * BLI_scanfill_edge_add(ScanFillContext *sf_ctx, struct ScanFillVert *v1, struct ScanFillVert *v2)
void BLI_scanfill_begin_arena(ScanFillContext *sf_ctx, struct MemArena *arena)
unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, int flag, const float nor_proj[3])
#define BLI_SCANFILL_ARENA_SIZE
void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, struct MemArena *arena)
#define STRNCPY(dst, src)
@ DAG_EVAL_NEED_CURVE_PATH
uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, const ID *id)
@ CU_TAPER_RADIUS_MULTIPLY
@ eModifierMode_ApplyOnSpline
@ eModifierType_MeshDeform
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
local_group_size(16, 16) .push_constant(Type b
const Depsgraph * depsgraph
static void displist_surf_indices(DispList *dl)
static bool do_curve_implicit_mesh_conversion(const Curve *curve, ModifierData *first_modifier, const Scene *scene, const ModifierMode required_mode)
static void curve_to_filledpoly(const Curve *cu, ListBase *dispbase)
static void bevels_to_filledpoly(const Curve *cu, ListBase *dispbase)
float BKE_displist_calc_taper(Depsgraph *depsgraph, const Scene *scene, Object *taperobj, int cur, int tot)
static float displist_calc_taper(Depsgraph *depsgraph, const Scene *scene, Object *taperobj, float fac)
void BKE_displist_make_curveTypes(Depsgraph *depsgraph, const Scene *scene, Object *ob, const bool for_render)
void BKE_displist_fill(const ListBase *dispbase, ListBase *to, const float normal_proj[3], const bool flip_normal)
static void calc_bevfac_mapping_default(const BevList *bl, int *r_start, float *r_firstblend, int *r_steps, float *r_lastblend)
static void calc_bevfac_spline_mapping(const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
static void rotateBevelPiece(const Curve *cu, const BevPoint *bevp, const BevPoint *nbevp, const DispList *dlb, const float bev_blend, const float widfac, const float radius_factor, float **r_data)
static void calc_bevfac_mapping(const Curve *cu, const BevList *bl, const Nurb *nu, int *r_start, float *r_firstblend, int *r_steps, float *r_lastblend)
static ModifierData * curve_get_tessellate_point(const Scene *scene, const Object *ob, const bool for_render, const bool editmode)
static void displist_elem_free(DispList *dl)
bool BKE_displist_surfindex_get(const DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
static void fillBevelCap(const Nurb *nu, const DispList *dlb, const float *prev_fp, ListBase *dispbase)
static blender::bke::GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph, const Scene *scene, Object *ob, const ListBase *dispbase, const bool for_render)
void BKE_displist_free(ListBase *lb)
DispList * BKE_displist_find(ListBase *lb, int type)
void BKE_curve_calc_modifiers_pre(Depsgraph *depsgraph, const Scene *scene, Object *ob, ListBase *source_nurb, ListBase *target_nurb, const bool for_render)
static void calc_bevfac_segment_mapping(const BevList *bl, float bevfac, float spline_length, int *r_bev, float *r_blend)
static blender::bke::GeometrySet evaluate_curve_type_object(Depsgraph *depsgraph, const Scene *scene, Object *ob, const bool for_render, ListBase *r_dispbase)
static blender::bke::GeometrySet evaluate_surface_object(Depsgraph *depsgraph, const Scene *scene, Object *ob, const bool for_render, ListBase *r_dispbase)
static void curve_to_displist(const Curve *cu, const ListBase *nubase, const bool for_render, ListBase *r_dispbase)
void BKE_displist_minmax(const ListBase *dispbase, float min[3], float max[3])
static bool is_cyclic(const Nurb *nu)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
Curves * curve_legacy_to_curves(const Curve &curve_legacy)
char edit_data_from_original
const struct Curves * curve_eval
struct EditFont * editfont
struct ModifierData * next
void(* modify_geometry_set)(ModifierData *md, const ModifierEvalContext *ctx, blender::bke::GeometrySet *geometry_set)
void(* deform_verts)(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, blender::MutableSpan< blender::float3 > positions)
Mesh *(* modify_mesh)(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
ObjectRuntimeHandle * runtime
void replace_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
Mesh * get_mesh_for_write()