[Bf-blender-cvs] [229d30587bf] curve-nodes-modifier: Merge branch 'master' into curve-nodes-modifier
Hans Goudey
noreply at git.blender.org
Tue Jul 13 01:40:44 CEST 2021
Commit: 229d30587bf57e4653e55ef0244eb88167b94a9d
Author: Hans Goudey
Date: Mon Jun 28 17:50:10 2021 -0500
Branches: curve-nodes-modifier
https://developer.blender.org/rB229d30587bf57e4653e55ef0244eb88167b94a9d
Merge branch 'master' into curve-nodes-modifier
===================================================================
===================================================================
diff --cc source/blender/blenkernel/intern/displist.cc
index 9c301962f86,757c86681e0..80d77f062de
--- a/source/blender/blenkernel/intern/displist.cc
+++ b/source/blender/blenkernel/intern/displist.cc
@@@ -915,32 -997,70 +915,21 @@@ static GeometrySet curve_calc_modifiers
}
}
- if (vertCos) {
- if (modified) {
- Mesh *temp_mesh = (Mesh *)BKE_id_copy_ex(
- nullptr, &modified->id, nullptr, LIB_ID_COPY_LOCALIZE);
- BKE_id_free(nullptr, modified);
- modified = temp_mesh;
+ if (geometry_set.has_mesh()) {
+ Mesh *final_mesh = geometry_set.get_mesh_for_write();
- BKE_mesh_vert_coords_apply(modified, vertCos);
- BKE_mesh_calc_normals_mapping_simple(modified);
+ /* XXX2.8(Sybren): make sure the face normals are recalculated as well */
+ BKE_mesh_ensure_normals(final_mesh);
- MEM_freeN(vertCos);
- }
- else {
- displist_vert_coords_apply(dispbase, vertCos);
- MEM_freeN(vertCos);
- vertCos = nullptr;
- }
+ /* Set flag which makes it easier to see what's going on in a debugger. */
+ final_mesh->id.tag |= LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT;
+ BLI_strncpy(final_mesh->id.name, cu->id.name, sizeof(final_mesh->id.name));
+ *((short *)final_mesh->id.name) = ID_ME;
}
- if (r_final) {
- if (force_mesh_conversion && !modified) {
- /* XXX 2.8 : This is a workaround for by some deeper technical debts:
- * - DRW Batch cache is stored inside the ob->data.
- * - Curve data is not COWed for instances that use different modifiers.
- * This can causes the modifiers to be applied on all user of the same data-block
- * (see T71055)
- *
- * The easy workaround is to force to generate a Mesh that will be used for display data
- * since a Mesh output is already used for generative modifiers.
- * However it does not fix problems with actual edit data still being shared.
- *
- * The right solution would be to COW the Curve data block at the input of the modifier
- * stack just like what the mesh modifier does.
- */
- modified = BKE_mesh_new_nomain_from_curve_displist(ob, dispbase);
- }
-
- if (modified) {
-
- /* XXX2.8(Sybren): make sure the face normals are recalculated as well */
- BKE_mesh_ensure_normals(modified);
-
- /* Special tweaks, needed since neither BKE_mesh_new_nomain_from_template() nor
- * BKE_mesh_new_nomain_from_curve_displist() properly duplicate mat info... */
- BLI_strncpy(modified->id.name, cu->id.name, sizeof(modified->id.name));
- *((short *)modified->id.name) = ID_ME;
- MEM_SAFE_FREE(modified->mat);
- /* Set flag which makes it easier to see what's going on in a debugger. */
- modified->id.tag |= LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT;
- modified->mat = (Material **)MEM_dupallocN(cu->mat);
- modified->totcol = cu->totcol;
-
- (*r_final) = modified;
- }
- else {
- (*r_final) = nullptr;
- }
- }
- else if (modified != nullptr) {
- /* Pretty stupid to generate that whole mesh if it's unused, yet we have to free it. */
- BKE_id_free(nullptr, modified);
- }
+ return geometry_set;
}
- static Mesh *curve_calc_modifiers_post_for_mesh(Depsgraph *depsgraph,
- const Scene *scene,
- Object *ob,
- ListBase *dispbase,
- const bool for_render)
- {
- GeometrySet geometry_set = curve_calc_modifiers_post(depsgraph, scene, ob, dispbase, for_render);
- MeshComponent &mesh_component = geometry_set.get_component_for_write<MeshComponent>();
- return mesh_component.release();
- }
-
static void displist_surf_indices(DispList *dl)
{
int b, p1, p2, p3, p4;
@@@ -979,19 -1099,20 +968,20 @@@ static void displist_make_surf(Depsgrap
Mesh **r_final,
const bool for_render)
{
-- ListBase nubase = {nullptr, nullptr};
const Curve *cu = (const Curve *)ob->data;
++ ListBase *nubase = &ob->runtime.curve_cache->deformed_nurbs;
++
if (!for_render && cu->editnurb) {
-- BKE_nurbList_duplicate(&nubase, BKE_curve_editNurbs_get(const_cast<Curve *>(cu)));
++ BKE_nurbList_duplicate(nubase, BKE_curve_editNurbs_get_for_read(cu));
}
else {
-- BKE_nurbList_duplicate(&nubase, &cu->nurb);
++ BKE_nurbList_duplicate(nubase, &cu->nurb);
}
- BKE_curve_calc_modifiers_pre(depsgraph, scene, ob, &nubase, &nubase, for_render);
- bool force_mesh_conversion = BKE_curve_calc_modifiers_pre(
- depsgraph, scene, ob, &nubase, &nubase, for_render);
++ BKE_curve_calc_modifiers_pre(depsgraph, scene, ob, nubase, nubase, for_render);
-- LISTBASE_FOREACH (Nurb *, nu, &nubase) {
++ LISTBASE_FOREACH (Nurb *, nu, nubase) {
if (!(for_render || nu->hide == 0) || !BKE_nurb_check_valid_uv(nu)) {
continue;
}
@@@ -1052,13 -1173,11 +1042,9 @@@
}
}
-- BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
-
- if (r_final) {
- *r_final = curve_calc_modifiers_post_for_mesh(depsgraph, scene, ob, dispbase, for_render);
- }
- curve_calc_modifiers_post(
- depsgraph, scene, ob, dispbase, for_render, force_mesh_conversion, r_final);
--
-- BKE_nurbList_free(&nubase);
++ GeometrySet geometry_set = curve_calc_modifiers_post(depsgraph, scene, ob, dispbase, for_render);
++ MeshComponent &mesh_component = geometry_set.get_component_for_write<MeshComponent>();
++ *r_final = mesh_component.release();
}
static void rotateBevelPiece(const Curve *cu,
@@@ -1278,35 -1397,45 +1264,28 @@@ static void calc_bevfac_mapping(const C
}
}
-static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
- const Scene *scene,
- Object *ob,
- ListBase *dispbase,
- const bool for_render,
- Mesh **r_final)
+static void evaluate_curve_type_object(Depsgraph *depsgraph,
+ const Scene *scene,
+ Object *ob,
+ ListBase *dispbase,
+ const bool for_render,
+ GeometrySet *r_geometry_set)
{
const Curve *cu = (const Curve *)ob->data;
+ BLI_assert(ELEM(ob->type, OB_CURVE, OB_FONT));
- /* we do allow duplis... this is only displist on curve level */
- if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) {
- return;
- }
-
- if (ob->type == OB_SURF) {
- displist_make_surf(depsgraph, scene, ob, dispbase, r_final, for_render);
- return;
- }
-
- ListBase nubase = {nullptr, nullptr};
-
-- BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
--
-- if (ob->runtime.curve_cache->anim_path_accum_length) {
-- MEM_freeN((void *)ob->runtime.curve_cache->anim_path_accum_length);
-- }
-- ob->runtime.curve_cache->anim_path_accum_length = nullptr;
-
+ ListBase *nubase = &ob->runtime.curve_cache->deformed_nurbs;
if (ob->type == OB_FONT) {
- BKE_vfont_to_curve_nubase(ob, FO_EDIT, &nubase);
+ BKE_vfont_to_curve_nubase(ob, FO_EDIT, nubase);
}
else {
- BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(const_cast<Curve *>(cu)));
+ BKE_nurbList_duplicate(nubase, BKE_curve_nurbs_get(const_cast<Curve *>(cu)));
}
- bool force_mesh_conversion = BKE_curve_calc_modifiers_pre(
- depsgraph, scene, ob, &nubase, &nubase, for_render);
+ BKE_curve_calc_modifiers_pre(depsgraph, scene, ob, nubase, nubase, for_render);
- BKE_curve_bevelList_make(ob, &nubase, for_render);
+ BKE_curve_bevelList_make(ob, nubase, for_render);
/* If curve has no bevel will return nothing */
ListBase dlbev = BKE_curve_bevel_make(cu);
More information about the Bf-blender-cvs
mailing list