[Bf-blender-cvs] [711d1f7591a] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features

Pablo Dobarro noreply at git.blender.org
Tue May 21 01:00:01 CEST 2019


Commit: 711d1f7591adb07456380ceaef61c5e3d4666e19
Author: Pablo Dobarro
Date:   Tue May 21 00:45:41 2019 +0200
Branches: sculpt-mode-features
https://developer.blender.org/rB711d1f7591adb07456380ceaef61c5e3d4666e19

Merge branch 'master' into sculpt-mode-features

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



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

diff --cc build_files/cmake/macros.cmake
index 90f07e7edc7,10b293c64b4..098792d4be6
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@@ -271,20 -271,40 +271,40 @@@ function(blender_add_lib_nolis
  endfunction()
  
  function(blender_add_lib
 -  name
 -  sources
 -  includes
 -  includes_sys
 -  library_deps
 -  )
 +	name
 +	sources
 +	includes
 +	includes_sys
 +	library_deps
 +	)
  
 -  add_cc_flags_custom_test(${name} PARENT_SCOPE)
 +	add_cc_flags_custom_test(${name} PARENT_SCOPE)
  
 -  blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}")
 +	blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}")
  
 -  set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
 +	set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
  endfunction()
  
+ # Ninja only: assign 'heavy pool' to some targets that are especially RAM-consuming to build.
+ function(setup_heavy_lib_pool)
+   if(WITH_NINJA_POOL_JOBS AND NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS)
+     if(WITH_CYCLES)
+       list(APPEND _HEAVY_LIBS "cycles_device" "cycles_kernel")
+     endif()
+     if(WITH_LIBMV)
+       list(APPEND _HEAVY_LIBS "bf_intern_libmv")
+     endif()
+     if(WITH_OPENVDB)
+       list(APPEND _HEAVY_LIBS "bf_intern_openvdb")
+     endif()
+ 
+     foreach(TARGET ${_HEAVY_LIBS})
+       if(TARGET ${TARGET})
+         set_property(TARGET ${TARGET} PROPERTY JOB_POOL_COMPILE compile_heavy_job_pool)
+       endif()
+     endforeach()
+   endif()
+ endfunction()
  
  function(SETUP_LIBDIRS)
  
diff --cc source/blender/blenkernel/intern/editmesh.c
index 130f4ae88f1,264054266eb..b8234ccc5bb
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@@ -248,3 -248,13 +248,13 @@@ void BKE_editmesh_lnorspace_update(BMEd
  
    BM_lnorspace_update(bm);
  }
+ 
+ /* If autosmooth not already set, set it */
+ void BKE_editmesh_ensure_autosmooth(BMEditMesh *em)
+ {
+   Mesh *me = em->ob->data;
+   if (!(me->flag & ME_AUTOSMOOTH)) {
+     me->flag |= ME_AUTOSMOOTH;
 -    BKE_editmesh_lnorspace_update (em);
++    BKE_editmesh_lnorspace_update(em);
+   }
+ }
diff --cc source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
index 4b65acac9d1,af9f1d14f4a..eb4ccd66f54
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
@@@ -6,9 -6,7 +6,8 @@@ uniform float materialRoughness
  
  uniform sampler2D image;
  uniform float ImageTransparencyCutoff = 0.1;
- uniform bool imageSrgb;
  uniform bool imageNearest;
 +uniform bool useVertexPaint;
  
  #ifdef NORMAL_VIEWPORT_PASS_ENABLED
  in vec3 normal_viewport;
diff --cc source/blender/editors/object/object_edit.c
index e079afc5253,a542911f4d4..a70a48a2c5a
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@@ -1790,245 -1779,5 +1790,246 @@@ void OBJECT_OT_link_to_collection(wmOpe
                          "Name",
                          "Name of the newly added collection");
    RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+   ot->prop = prop;
  }
 +
 +static int remesh_exec(bContext *C, wmOperator *op)
 +{
 +  bool linked_data = false;
 +
 +  Object *ob = CTX_data_active_object(C);
 +  Main *bmain = CTX_data_main(C);
 +
 +  ID *data;
 +  data = ob->data;
 +  if (data && ID_IS_LINKED(data)) {
 +    linked_data = true;
 +    return OPERATOR_CANCELLED;
 +  }
 +
 +  if (ID_REAL_USERS(data) != 1) {
 +    BKE_report(op->reports, RPT_ERROR, "Remesh cannot run on mesh data with multiple users");
 +    return OPERATOR_CANCELLED;
 +  }
 +
 +  if (BKE_object_is_in_editmode(ob)) {
 +    BKE_report(op->reports, RPT_ERROR, "Remesh cannot run from edit mode");
 +    return OPERATOR_CANCELLED;
 +  }
 +
 +  if (ob->type == OB_MESH) {
 +    Mesh *mesh = ob->data;
 +    Mesh *newMesh;
 +
 +    if (mesh->voxel_size <= 0.0f) {
 +      return OPERATOR_CANCELLED;
 +    }
 +
 +    if (ob->mode == OB_MODE_SCULPT) {
 +      Depsgraph *depsgraph = CTX_data_depsgraph(C);
 +      struct Scene *scene = CTX_data_scene(C);
 +      Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
 +      BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, true, true);
 +      PBVH *pbvh;
 +      PBVHNode **nodes;
 +      int totnode;
 +      pbvh = ob->sculpt->pbvh;
 +      BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
 +      sculpt_undo_push_begin("voxel remesh");
 +      sculpt_undo_push_node(ob, nodes[0], SCULPT_UNDO_REMESH);
 +    }
 +
 +    struct OpenVDBLevelSet *level_set;
 +    struct OpenVDBTransform *xform = OpenVDBTransform_create();
 +    OpenVDBTransform_create_linear_transform(xform, (double)mesh->voxel_size);
 +    level_set = BKE_remesh_voxel_ovdb_mesh_to_level_set_create(mesh, xform);
 +    newMesh = BKE_remesh_voxel_ovdb_volume_to_mesh_nomain(level_set, 0.0, 0.0, false);
 +    OpenVDBLevelSet_free(level_set);
 +    OpenVDBTransform_free(xform);
 +
 +    Mesh *objMesh_copy;
 +    if (mesh->flag & ME_REMESH_REPROJECT_VERTEX_PAINT ||
 +        mesh->flag & ME_REMESH_REPROJECT_PAINT_MASK) {
 +      objMesh_copy = BKE_mesh_new_nomain_from_template(mesh, mesh->totvert, 0, 0, 0, 0);
 +      CustomData_copy(
 +          &mesh->vdata, &objMesh_copy->vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, mesh->totvert);
 +      for (int i = 0; i < mesh->totvert; i++) {
 +        copy_v3_v3(objMesh_copy->mvert[i].co, mesh->mvert[i].co);
 +      }
 +    }
 +
 +    BKE_mesh_nomain_to_mesh(newMesh, mesh, ob, &CD_MASK_EVERYTHING, true);
 +
 +    BKE_remesh_voxel_init_empty_vertex_color_layer(mesh);
 +
 +    if (mesh->flag & ME_REMESH_REPROJECT_VERTEX_PAINT ||
 +        mesh->flag & ME_REMESH_REPROJECT_PAINT_MASK) {
 +      BKE_remesh_voxel_reproject(mesh, objMesh_copy, mesh->flag);
 +      BKE_mesh_free(objMesh_copy);
 +    }
 +
 +    if (mesh->flag & ME_REMESH_SMOOTH_NORMALS) {
 +      BKE_mesh_smooth_flag_set(ob, true);
 +    }
 +
 +    if (ob->mode == OB_MODE_SCULPT) {
 +      sculpt_undo_push_end();
 +    }
 +
 +    BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);
 +    DEG_relations_tag_update(bmain);
 +    DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
 +    WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
 +
 +    BKE_mesh_free(newMesh);
 +    return OPERATOR_FINISHED;
 +  }
 +
 +  return OPERATOR_CANCELLED;
 +}
 +
 +void OBJECT_OT_remesh(wmOperatorType *ot)
 +{
 +  /* identifiers */
 +  ot->name = "Voxel remesh";
 +  ot->description = "Run OpenVDB voxel remesher";
 +  ot->idname = "OBJECT_OT_remesh";
 +
 +  /* api callbacks */
 +  ot->poll = object_mode_set_poll;
 +  ot->exec = remesh_exec;
 +
 +  ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL;
 +}
 +
 +#define GET_CD_DATA(me, data) ((me)->edit_mesh ? &(me)->edit_mesh->bm->data : &(me)->data)
 +static int vertex_to_loop_colors_exec(bContext *C, wmOperator *op)
 +{
 +  bool linked_data = false;
 +
 +  Object *ob = CTX_data_active_object(C);
 +
 +  ID *data;
 +  data = ob->data;
 +  if (data && ID_IS_LINKED(data)) {
 +    linked_data = true;
 +    return OPERATOR_CANCELLED;
 +  }
 +
 +  if (ob->type == OB_MESH) {
 +    Mesh *mesh = ob->data;
 +    CustomData *ldata = GET_CD_DATA(mesh, ldata);
 +    const int n = CustomData_get_active_layer(ldata, CD_MLOOPCOL);
 +    if (n == -1) {
 +      return OPERATOR_CANCELLED;
 +    }
 +    MLoopCol *loopcols = CustomData_get_layer_n(&mesh->ldata, CD_MLOOPCOL, n);
 +    MVertCol *vertcols = CustomData_get_layer(&mesh->vdata, CD_MVERTCOL);
 +    MLoop *loops = CustomData_get_layer(&mesh->ldata, CD_MLOOP);
 +    MPoly *polys = CustomData_get_layer(&mesh->pdata, CD_MPOLY);
 +
 +    for (int i = 0; i < mesh->totpoly; i++) {
 +      MPoly *c_poly = &polys[i];
 +      for (int j = 0; j < c_poly->totloop; j++) {
 +        int loop_index = c_poly->loopstart + j;
 +        MLoop *c_loop = &loops[c_poly->loopstart + j];
 +        loopcols[loop_index].r = vertcols[c_loop->v].r;
 +        loopcols[loop_index].g = vertcols[c_loop->v].g;
 +        loopcols[loop_index].b = vertcols[c_loop->v].b;
 +        loopcols[loop_index].a = vertcols[c_loop->v].a;
 +      }
 +    }
 +
 +    DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
 +    WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
 +
 +    return OPERATOR_FINISHED;
 +  }
 +  return OPERATOR_CANCELLED;
 +}
 +
 +void OBJECT_OT_vertex_to_loop_colors(wmOperatorType *ot)
 +{
 +  /* identifiers */
 +  ot->name = "Vertex color to loop color";
 +  ot->description = "Copy the vertex color to a regular color layer";
 +  ot->idname = "OBJECT_OT_vertex_to_loop_colors";
 +
 +  /* api callbacks */
 +  ot->poll = object_mode_set_poll;
 +  ot->exec = vertex_to_loop_colors_exec;
 +
 +  ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +}
 +
 +static int loop_to_vertex_colors_exec(bContext *C, wmOperator *op)
 +{
 +  bool linked_data = false;
 +
 +  Object *ob = CTX_data_active_object(C);
 +
 +  ID *data;
 +  data = ob->data;
 +  if (data && ID_IS_LINKED(data)) {
 +    linked_data = true;
 +    return OPERATOR_CANCELLED;
 +  }
 +
 +  if (ob->type == OB_MESH) {
 +    Mesh *mesh = ob->data;
 +    CustomData *ldata = GET_CD_DATA(mesh, ldata);
 +    const int n = CustomData_get_active_layer(ldata, CD_MLOOPCOL);
 +    if (n == -1) {
 +      return OPERATOR_CANCELLED;
 +    }
 +    MLoopCol *loopcols = CustomData_get_layer_n(&mesh->ldata, CD_MLOOPCOL, n);
 +    MVertCol *vertcols;
 +    if (!CustomData_has_layer(&mesh->vdata, CD_MVERTCOL)) {
 +      vertcols = CustomData_add_layer_named(
 +          &mesh->vdata, CD_MVERTCOL, CD_CALLOC, NULL, mesh->totvert, "vcols");
 +      for (int i = 0; i < mesh->totvert; i++) {
 +        ob->sculpt->vcol[i].r = 255;
 +        ob->sculpt->vcol[i].g = 255;
 +        ob->sculpt->vcol[i].b = 255;
 +        ob->sculpt->vcol[i].a = 255;
 +      }
 +    }
 +    else {
 +      vertcols = CustomData_get_layer(&mesh->vdata, CD_MVERTCOL);
 +    }
 +    MLoop *loops = CustomData_get_layer(&mesh->ldata, CD_MLOOP);
 +    MPoly *polys = CustomData_get_layer(&mesh->pdata, CD_MPOLY);
 +
 +    for (int i = 0; i < mesh->totpoly; i++) {
 +      MPoly *c_poly = &polys[i];
 +      for (int j = 0; j < c_poly

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list