[Bf-blender-cvs] [f30225725db] temp_bmesh_multires: Some multires stuff
Joseph Eagar
noreply at git.blender.org
Tue Dec 8 22:39:18 CET 2020
Commit: f30225725dbcadb4f9b774f5c90fbe3df3af3eb4
Author: Joseph Eagar
Date: Wed Nov 18 18:34:08 2020 -0800
Branches: temp_bmesh_multires
https://developer.blender.org/rBf30225725dbcadb4f9b774f5c90fbe3df3af3eb4
Some multires stuff
===================================================================
M source/blender/blenkernel/intern/multires_reshape_smooth.c
M source/blender/bmesh/intern/bmesh_interp.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
===================================================================
diff --git a/source/blender/blenkernel/intern/multires_reshape_smooth.c b/source/blender/blenkernel/intern/multires_reshape_smooth.c
index e12e692ea23..fe45b721d94 100644
--- a/source/blender/blenkernel/intern/multires_reshape_smooth.c
+++ b/source/blender/blenkernel/intern/multires_reshape_smooth.c
@@ -48,6 +48,39 @@
#include "atomic_ops.h"
#include "subdiv_converter.h"
+
+bool debug_invert_m3_m3(float m1[3][3], const float m2[3][3], const char *func, int line)
+{
+ float det;
+ int a, b;
+ bool success;
+
+ /* calc adjoint */
+ adjoint_m3_m3(m1, m2);
+
+ /* then determinant old matrix! */
+ det = determinant_m3_array(m2);
+
+ if (det > -0.0001 && det < 0.0001) {
+ fprintf(stderr, "matrix inverse error %s:%i\n\n", func, line);
+ }
+
+ success = (det != 0.0f);
+
+ if (LIKELY(det != 0.0f)) {
+ det = 1.0f / det;
+ for (a = 0; a < 3; a++) {
+ for (b = 0; b < 3; b++) {
+ m1[a][b] *= det;
+ }
+ }
+ }
+
+ return success;
+}
+
+//#define invert_m3_m3(m1, m2) debug_invert_m3_m3(m1, m2, __func__, __LINE__)
+
/* -------------------------------------------------------------------- */
/** \name Local Structs
* \{ */
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index 599daad60b3..a2718977c82 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -326,8 +326,8 @@ static bool quad_co(const float v1[3],
}
// expand quad a bit
-#if 1
- float eps = FLT_EPSILON * 400000;
+#if 0
+ float eps = FLT_EPSILON * 40000;
float c[3];
mid_v3_v3v3v3v3(c, projverts[0], projverts[1], projverts[2], projverts[3]);
@@ -352,9 +352,12 @@ static bool quad_co(const float v1[3],
resolve_quad_uv_v2(r_uv, origin, projverts[0], projverts[3], projverts[2], projverts[1]);
- // if (r_uv[0] < -eps || r_uv[1] < -eps || r_uv[0] > 1.0+eps || r_uv[1] > 1.0+eps) {
- // return false;
- //}
+#if 0
+ float eps2 = FLT_EPSILON * 4000;
+ if (r_uv[0] < -eps2 || r_uv[1] < -eps2 || r_uv[0] > 1.0 + eps2 || r_uv[1] > 1.0 + eps2) {
+ return false;
+ }
+#endif
CLAMP(r_uv[0], 0.0f, 0.99999f);
CLAMP(r_uv[1], 0.0f, 0.99999f);
@@ -943,12 +946,12 @@ void bmo_test_mres_smooth_exec(BMesh *bm, BMOperator *op)
continue;
}
- //bm_multires_smooth(bm, f, true);
+ // bm_multires_smooth(bm, f, true);
// BM_multires_smooth(bm, f, false);
// BM_multires_smooth(bm, f, false);
- //for (int i=0; i<5; i++) {
+ // for (int i=0; i<5; i++) {
BM_face_multires_bounds_smooth(bm, f);
- // }
+ // }
}
multires_dump_grids_bmesh(NULL, bm);
@@ -960,9 +963,8 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f)
if (bm->multiresSpace == MULTIRES_SPACE_ABSOLUTE) {
BM_face_multires_stitch(bm, f);
-
- //for (int i=0; i<5; i++) {
- //bm_multires_smooth(bm, f, true);
+ // for (int i=0; i<5; i++) {
+ // bm_multires_smooth(bm, f, true);
//}
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index caf802977cc..277d7b3c396 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -6936,6 +6936,8 @@ static const char *sculpt_tool_name(Sculpt *sd)
return "Paint Brush";
case SCULPT_TOOL_SMEAR:
return "Smear Brush";
+ case SCULPT_TOOL_VCOL_BOUNDARY:
+ return "Color Boundary";
}
return "Sculpting";
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index a8d50665e78..9502bee62ec 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -183,14 +183,14 @@ static bool sculpt_undo_restore_deformed(
return false;
}
-static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, SculptUndoNode *unode)
+__attribute__((optnone)) static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, SculptUndoNode *unode)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
SculptSession *ss = ob->sculpt;
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
MVert *mvert;
- int *index;
+ SculptVertRef *index;
if (unode->maxvert) {
/* Regular mesh restore. */
@@ -224,18 +224,18 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
if (unode->orig_co) {
if (ss->deform_modifiers_active) {
for (int i = 0; i < unode->totvert; i++) {
- sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]);
+ sculpt_undo_restore_deformed(ss, unode, i, index[i].i, vertCos[index[i].i]);
}
}
else {
for (int i = 0; i < unode->totvert; i++) {
- swap_v3_v3(vertCos[index[i]], unode->orig_co[i]);
+ swap_v3_v3(vertCos[index[i].i], unode->orig_co[i]);
}
}
}
else {
for (int i = 0; i < unode->totvert; i++) {
- swap_v3_v3(vertCos[index[i]], unode->co[i]);
+ swap_v3_v3(vertCos[index[i].i], unode->co[i]);
}
}
@@ -252,21 +252,21 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
if (unode->orig_co) {
if (ss->deform_modifiers_active) {
for (int i = 0; i < unode->totvert; i++) {
- sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co);
- mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
+ sculpt_undo_restore_deformed(ss, unode, i, index[i].i, mvert[index[i].i].co);
+ mvert[index[i].i].flag |= ME_VERT_PBVH_UPDATE;
}
}
else {
for (int i = 0; i < unode->totvert; i++) {
- swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]);
- mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
+ swap_v3_v3(mvert[index[i].i].co, unode->orig_co[i]);
+ mvert[index[i].i].flag |= ME_VERT_PBVH_UPDATE;
}
}
}
else {
for (int i = 0; i < unode->totvert; i++) {
- swap_v3_v3(mvert[index[i]].co, unode->co[i]);
- mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE;
+ swap_v3_v3(mvert[index[i].i].co, unode->co[i]);
+ mvert[index[i].i].flag |= ME_VERT_PBVH_UPDATE;
}
}
}
@@ -1072,7 +1072,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
else {
/* Regular mesh. */
unode->maxvert = ss->totvert;
- unode->index = MEM_callocN(sizeof(int) * allvert, "SculptUndoNode.index");
+ unode->index = MEM_callocN(sizeof(SculptVertRef) * allvert, "SculptUndoNode.index");
}
if (ss->deform_modifiers_active) {
@@ -1418,7 +1418,11 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
int allvert;
BKE_pbvh_node_num_verts(ss->pbvh, node, NULL, &allvert);
BKE_pbvh_node_get_verts(ss->pbvh, node, &vert_indices, NULL);
- memcpy(unode->index, vert_indices, sizeof(int) * unode->totvert);
+
+ for (int i=0; i<unode->totvert; i++) {
+ unode->index[i].i = vert_indices[i];
+ }
+ //memcpy(unode->index, vert_indices, sizeof(int) * unode->totvert);
}
switch (type) {
More information about the Bf-blender-cvs
mailing list