Commit: 36b93f09a96b38ecb36b5072a3eca91453e1c530
Author: mattoverby
Date:   Sat Aug 15 09:04:22 2020 -0500
Branches: soc-2020-soft-body
https://developer.blender.org/rB36b93f09a96b38ecb36b5072a3eca91453e1c530

added blender warnings and errors

===================================================================

M       extern/softbody/src/admmpd_collision.cpp
M       intern/softbody/admmpd_api.cpp
M       intern/softbody/admmpd_api.h
M       source/blender/blenkernel/intern/softbody.c

===================================================================

diff --git a/extern/softbody/src/admmpd_collision.cpp 
b/extern/softbody/src/admmpd_collision.cpp
index f6dc94dcbdd..3e2400ed9dd 100644
--- a/extern/softbody/src/admmpd_collision.cpp
+++ b/extern/softbody/src/admmpd_collision.cpp
@@ -75,7 +75,7 @@ bool Collision::set_obstacles(
        // Is the mesh closed?
        Discregrid::TriangleMesh tm(v1_dbl.data(), faces, nv, nf);
        if (!tm.is_closed()) {
-               if (err) { *err = "Collision obstacle not a closed mesh"; }
+               if (err) { *err = "Collision obstacle not a closed mesh - 
ignoring"; }
                obsdata.clear();
                return false;
        }
diff --git a/intern/softbody/admmpd_api.cpp b/intern/softbody/admmpd_api.cpp
index 2139355400f..8e5455387a4 100644
--- a/intern/softbody/admmpd_api.cpp
+++ b/intern/softbody/admmpd_api.cpp
@@ -747,7 +747,9 @@ int admmpd_solve(ADMMPDInterfaceData *iface, Object *ob, 
float (*vertexCos)[3])
   }
 
   if (had_set_obstacle_error) {
-    return 0; // we've already copied the error message.
+    // Return warning (-1).
+    // We've already copied the error message.
+    return -1;
   }
 
   return 1;
diff --git a/intern/softbody/admmpd_api.h b/intern/softbody/admmpd_api.h
index 5a14aff8f8e..18b0b8e3389 100644
--- a/intern/softbody/admmpd_api.h
+++ b/intern/softbody/admmpd_api.h
@@ -40,18 +40,20 @@ typedef struct ADMMPDInterfaceData {
 void admmpd_dealloc(ADMMPDInterfaceData*);
 
 // Test if the mesh topology has changed in a way that requires 
re-initialization.
+// Returns 0 (no update needed) or 1 (needs update)
 int admmpd_mesh_needs_update(ADMMPDInterfaceData*, Object*);
 
 // Initialize the mesh.
 // The SoftBody object's (ob->soft) bpoint array is also updated.
-// Returns 1 on success, 0 on failure
+// Returns 1 on success, 0 on failure, -1 on warning
 int admmpd_update_mesh(ADMMPDInterfaceData*, Object*, float (*vertexCos)[3]);
 
 // Test if certain parameter changes require re-initialization.
+// Returns 0 (no update needed) or 1 (needs update)
 int admmpd_solver_needs_update(ADMMPDInterfaceData*, Scene*, Object*);
 
 // Initialize solver variables.
-// Returns 1 on success, 0 on failure.
+// Returns 1 on success, 0 on failure, -1 on warning
 int admmpd_update_solver(ADMMPDInterfaceData*, Scene*, Object*, float 
(*vertexCos)[3]);
 
 // Copies BodyPoint data (from SoftBody)
@@ -74,7 +76,7 @@ void admmpd_update_obstacles(
     int nf);
 
 // Performs a time step. Object and vertexCos are not changed.
-// Returns 1 on success, 0 on error
+// Returns 1 on success, 0 on failure, -1 on warning
 int admmpd_solve(ADMMPDInterfaceData*, Object*, float (*vertexCos)[3]);
 
 #ifdef __cplusplus
diff --git a/source/blender/blenkernel/intern/softbody.c 
b/source/blender/blenkernel/intern/softbody.c
index 4e0826981da..c1118707b20 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -79,6 +79,8 @@
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_query.h"
 
+#include "../windowmanager/WM_api.h"
+
 #include "PIL_time.h"
 
 static CLG_LogRef LOG = {"bke.softbody"};
@@ -3668,6 +3670,7 @@ void sbObjectStep(struct Depsgraph *depsgraph,
 
   if (sb->admmpd == NULL) {
     CLOG_ERROR(&LOG, "No ADMM-PD data");
+    WM_reportf(RPT_ERROR, "No ADMM-PD data");
     return;
   }
 
@@ -3714,10 +3717,14 @@ void sbObjectStep(struct Depsgraph *depsgraph,
     int init_mesh = 0;
     if (is_first_frame || admmpd_mesh_needs_update(sb->admmpd, ob)) {
       init_mesh = admmpd_update_mesh(sb->admmpd, ob, vertexCos);
-      if (!init_mesh) {
+      if (init_mesh==0) {
         CLOG_ERROR(&LOG, "%s", sb->admmpd->last_error);
+        WM_reportf(RPT_ERROR, sb->admmpd->last_error);
         return;
       }
+      else if (init_mesh==-1) {
+        WM_reportf(RPT_WARNING, sb->admmpd->last_error);
+      }
     }
 
     /* Do we need to initialize the ADMM-PD solver?
@@ -3728,10 +3735,14 @@ void sbObjectStep(struct Depsgraph *depsgraph,
     if (is_first_frame || init_mesh ||
         admmpd_solver_needs_update(sb->admmpd, scene, ob)) {
       init_solver = admmpd_update_solver(sb->admmpd, scene, ob, vertexCos);
-      if (!init_solver) {
+      if (init_solver==0) {
         CLOG_ERROR(&LOG, "%s", sb->admmpd->last_error);
+        WM_reportf(RPT_ERROR, sb->admmpd->last_error);
         return;
       }
+      else if (init_solver==-1) {
+        WM_reportf(RPT_WARNING, sb->admmpd->last_error);
+      }
     }
 
     /* In case of paramter change, ob->soft->bpoint has not
@@ -3848,8 +3859,13 @@ void sbObjectStep(struct Depsgraph *depsgraph,
   if (sb->solver_mode == SOLVER_MODE_ADMMPD) {
     admmpd_copy_from_object(sb->admmpd,ob);
     update_collider_admmpd(depsgraph, sb->collision_group, ob);
-    if (!admmpd_solve(sb->admmpd,ob,vertexCos)) {
+    int solve_retval = admmpd_solve(sb->admmpd,ob,vertexCos);
+    if (solve_retval==0) {
       CLOG_ERROR(&LOG, "%s", sb->admmpd->last_error);
+      WM_reportf(RPT_ERROR, sb->admmpd->last_error);
+    }
+    else if (solve_retval==-1) {
+      WM_reportf(RPT_WARNING, sb->admmpd->last_error);
     }
     admmpd_copy_to_object(sb->admmpd,ob,vertexCos);
   }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to