Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-05-15 12:25:42 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-05-15 12:25:42 +0400
commit4fcd44d3897403e6c87abf5a6020153c0d220d2d (patch)
tree8f752616508f1645fb79627df86c8bdbf62ab935 /source/blender/blenkernel/intern/object.c
parentcd089ea321666817336e5bb7b3eba7d4ecc74479 (diff)
Fix #35362: using dyntopo gives wrong render results
Made it so dynamic topology will flush changes from SculptSession->bm to Object->me. Used the same approach as sculptsession_bm_to_me does, but instead of using DAG_id_tag_update used in-place DerivedMesh release. Otherwise this lead to some update issues resulting in missed object after render. Also fixed multires modifier not being applied for render when rendering from dyntopo sculpt mode. P.S. Apparently sculpsession_bm_to_me was declared in BKE_paint.h but implemented in object.c. Rather confusing and better make it so this functions are declared and implemented in consistent files. But will solve this in a separate commit.
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c63
1 files changed, 49 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 04ff1b4d3c2..a3fa17ceb86 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -272,30 +272,65 @@ void free_sculptsession_deformMats(SculptSession *ss)
}
/* Write out the sculpt dynamic-topology BMesh to the Mesh */
-void sculptsession_bm_to_me(struct Object *ob, int reorder)
+static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder)
{
- if (ob && ob->sculpt) {
- SculptSession *ss = ob->sculpt;
+ SculptSession *ss = ob->sculpt;
- if (ss->bm) {
- if (ob->data) {
- BMIter iter;
- BMFace *efa;
- BM_ITER_MESH (efa, &iter, ss->bm, BM_FACES_OF_MESH) {
- BM_elem_flag_set(efa, BM_ELEM_SMOOTH,
- ss->bm_smooth_shading);
- }
- if (reorder)
- BM_log_mesh_elems_reorder(ss->bm, ss->bm_log);
- BM_mesh_bm_to_me(ss->bm, ob->data, FALSE);
+ if (ss->bm) {
+ if (ob->data) {
+ BMIter iter;
+ BMFace *efa;
+ BM_ITER_MESH (efa, &iter, ss->bm, BM_FACES_OF_MESH) {
+ BM_elem_flag_set(efa, BM_ELEM_SMOOTH,
+ ss->bm_smooth_shading);
}
+ if (reorder)
+ BM_log_mesh_elems_reorder(ss->bm, ss->bm_log);
+ BM_mesh_bm_to_me(ss->bm, ob->data, FALSE);
}
+ }
+}
+
+void sculptsession_bm_to_me(Object *ob, int reorder)
+{
+ if (ob && ob->sculpt) {
+ sculptsession_bm_to_me_update_data_only(ob, reorder);
/* ensure the objects DerivedMesh mesh doesn't hold onto arrays now realloc'd in the mesh [#34473] */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
}
+void sculptsession_bm_to_me_for_render(Object *object)
+{
+ if (object && object->sculpt) {
+ if (object->sculpt->bm) {
+ /* Ensure no points to old arrays are stored in DM
+ *
+ * Apparently, we could not use DAG_id_tag_update
+ * here because this will lead to the while object
+ * surface to disappear, so we'll release DM in place.
+ */
+ if (object->derivedFinal) {
+ object->derivedFinal->needsFree = 1;
+ object->derivedFinal->release(object->derivedFinal);
+ object->derivedFinal = NULL;
+ }
+ if (object->sculpt->pbvh) {
+ BKE_pbvh_free(object->sculpt->pbvh);
+ object->sculpt->pbvh = NULL;
+ }
+
+ sculptsession_bm_to_me_update_data_only(object, false);
+
+ /* In contrast with sculptsession_bm_to_me no need in
+ * DAG tag update here - derived mesh was freed and
+ * old pointers are nowhere stored.
+ */
+ }
+ }
+}
+
void free_sculptsession(Object *ob)
{
if (ob && ob->sculpt) {