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:
authorJacques Lucke <jacques@blender.org>2020-04-06 12:10:19 +0300
committerJacques Lucke <jacques@blender.org>2020-04-06 12:10:19 +0300
commit43f895a59247ea4058cb3f019cd4dabd9ad9b0e4 (patch)
tree51469fde8affa6b20f67d12a4602c5f109c1a204 /source/blender/modifiers
parent52606afaa60462db45e783607255f56c06fd8d73 (diff)
parent480ff89bf7cfb1f9ffd5ce66fbd5c65288ef04c0 (diff)
Merge branch 'master' into functions
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c4
-rw-r--r--source/blender/modifiers/intern/MOD_multires.c4
-rw-r--r--source/blender/modifiers/intern/MOD_remesh.c73
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c11
-rw-r--r--source/blender/modifiers/intern/MOD_weld.c91
5 files changed, 116 insertions, 67 deletions
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index 457f47bf025..d36fce3752b 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -20,6 +20,7 @@
#include <stddef.h>
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "DNA_dynamicpaint_types.h"
@@ -123,8 +124,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
/* Add relation from canvases to all brush objects. */
if (pmd->canvas != NULL && pmd->type == MOD_DYNAMICPAINT_TYPE_CANVAS) {
- for (DynamicPaintSurface *surface = pmd->canvas->surfaces.first; surface;
- surface = surface->next) {
+ LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) {
DEG_add_forcefield_relations(
ctx->node, ctx->object, surface->effector_weights, true, 0, "Dynamic Paint Field");
diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c
index ad8e0a9f259..f9d53d08c2e 100644
--- a/source/blender/modifiers/intern/MOD_multires.c
+++ b/source/blender/modifiers/intern/MOD_multires.c
@@ -211,7 +211,9 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
if (ctx->object->sculpt != NULL) {
SculptSession *sculpt_session = ctx->object->sculpt;
sculpt_session->subdiv_ccg = result->runtime.subdiv_ccg;
- sculpt_session->multires = mmd;
+ sculpt_session->multires.active = true;
+ sculpt_session->multires.modifier = mmd;
+ sculpt_session->multires.level = mmd->sculptlvl;
sculpt_session->totvert = mesh->totvert;
sculpt_session->totpoly = mesh->totpoly;
sculpt_session->mvert = NULL;
diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c
index 3300cda947c..2fa8dc973a1 100644
--- a/source/blender/modifiers/intern/MOD_remesh.c
+++ b/source/blender/modifiers/intern/MOD_remesh.c
@@ -34,6 +34,7 @@
#include "MOD_modifiertypes.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_remesh_voxel.h"
#include "BKE_mesh_runtime.h"
#include <assert.h>
@@ -54,8 +55,10 @@ static void initData(ModifierData *md)
rmd->depth = 4;
rmd->hermite_num = 1;
rmd->flag = MOD_REMESH_FLOOD_FILL;
- rmd->mode = MOD_REMESH_SHARP_FEATURES;
+ rmd->mode = MOD_REMESH_VOXEL;
rmd->threshold = 1;
+ rmd->voxel_size = 0.1f;
+ rmd->adaptivity = 0.0f;
}
#ifdef WITH_MOD_REMESH
@@ -144,36 +147,50 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *UNUSED(c
rmd = (RemeshModifierData *)md;
- init_dualcon_mesh(&input, mesh);
-
- if (rmd->flag & MOD_REMESH_FLOOD_FILL) {
- flags |= DUALCON_FLOOD_FILL;
+ if (rmd->mode == MOD_REMESH_VOXEL) {
+ /* OpenVDB modes. */
+ if (rmd->voxel_size == 0.0f) {
+ return NULL;
+ }
+ result = BKE_mesh_remesh_voxel_to_mesh_nomain(mesh, rmd->voxel_size, rmd->adaptivity, 0.0f);
}
+ else {
+ /* Dualcon modes. */
+ init_dualcon_mesh(&input, mesh);
- switch (rmd->mode) {
- case MOD_REMESH_CENTROID:
- mode = DUALCON_CENTROID;
- break;
- case MOD_REMESH_MASS_POINT:
- mode = DUALCON_MASS_POINT;
- break;
- case MOD_REMESH_SHARP_FEATURES:
- mode = DUALCON_SHARP_FEATURES;
- break;
- }
+ if (rmd->flag & MOD_REMESH_FLOOD_FILL) {
+ flags |= DUALCON_FLOOD_FILL;
+ }
- output = dualcon(&input,
- dualcon_alloc_output,
- dualcon_add_vert,
- dualcon_add_quad,
- flags,
- mode,
- rmd->threshold,
- rmd->hermite_num,
- rmd->scale,
- rmd->depth);
- result = output->mesh;
- MEM_freeN(output);
+ switch (rmd->mode) {
+ case MOD_REMESH_CENTROID:
+ mode = DUALCON_CENTROID;
+ break;
+ case MOD_REMESH_MASS_POINT:
+ mode = DUALCON_MASS_POINT;
+ break;
+ case MOD_REMESH_SHARP_FEATURES:
+ mode = DUALCON_SHARP_FEATURES;
+ break;
+ case MOD_REMESH_VOXEL:
+ /* Should have been processed before as an OpenVDB operation. */
+ BLI_assert(false);
+ break;
+ }
+
+ output = dualcon(&input,
+ dualcon_alloc_output,
+ dualcon_add_vert,
+ dualcon_add_quad,
+ flags,
+ mode,
+ rmd->threshold,
+ rmd->hermite_num,
+ rmd->scale,
+ rmd->depth);
+ result = output->mesh;
+ MEM_freeN(output);
+ }
if (rmd->flag & MOD_REMESH_SMOOTH_SHADING) {
MPoly *mpoly = result->mpoly;
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index b8db14f610a..c3515578e42 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -30,9 +30,9 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
+#include "BKE_action.h" /* BKE_pose_channel_find_name */
#include "BKE_colortools.h"
#include "BKE_deform.h"
-#include "BKE_action.h" /* BKE_pose_channel_find_name */
#include "BKE_editmesh.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
@@ -86,7 +86,10 @@ static void requiredDataMask(Object *UNUSED(ob),
}
}
-static void matrix_from_obj_pchan(float mat[4][4], float obinv[4][4], Object *ob, const char *bonename)
+static void matrix_from_obj_pchan(float mat[4][4],
+ const float obinv[4][4],
+ Object *ob,
+ const char *bonename)
{
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bonename);
if (pchan) {
@@ -150,8 +153,8 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void
}
static void warp_deps_object_bone_new(struct DepsNodeHandle *node,
- Object *object,
- const char *bonename)
+ Object *object,
+ const char *bonename)
{
if (bonename[0] && object->type == OB_ARMATURE) {
DEG_add_object_relation(node, object, DEG_OB_COMP_EVAL_POSE, "Warp Modifier");
diff --git a/source/blender/modifiers/intern/MOD_weld.c b/source/blender/modifiers/intern/MOD_weld.c
index 5d56152e0ff..90b71b2d504 100644
--- a/source/blender/modifiers/intern/MOD_weld.c
+++ b/source/blender/modifiers/intern/MOD_weld.c
@@ -801,6 +801,33 @@ static bool weld_iter_loop_of_poly_begin(WeldLoopOfPolyIter *iter,
iter->loop_map = loop_map;
iter->group = group_buffer;
+ uint group_len = 0;
+ if (group_buffer) {
+ /* First loop group needs more attention. */
+ uint loop_start, loop_end, l;
+ loop_start = iter->loop_start;
+ loop_end = l = iter->loop_end;
+ while (l >= loop_start) {
+ const uint loop_ctx = loop_map[l];
+ if (loop_ctx != OUT_OF_CONTEXT) {
+ const WeldLoop *wl = &wloop[loop_ctx];
+ if (wl->flag == ELEM_COLLAPSED) {
+ l--;
+ continue;
+ }
+ }
+ break;
+ }
+ if (l != loop_end) {
+ group_len = loop_end - l;
+ int i = 0;
+ while (l < loop_end) {
+ iter->group[i++] = ++l;
+ }
+ }
+ }
+ iter->group_len = group_len;
+
iter->l_next = iter->loop_start;
#ifdef USE_WELD_DEBUG
iter->v = OUT_OF_CONTEXT;
@@ -813,8 +840,13 @@ static bool weld_iter_loop_of_poly_next(WeldLoopOfPolyIter *iter)
uint loop_end = iter->loop_end;
const WeldLoop *wloop = iter->wloop;
const uint *loop_map = iter->loop_map;
- iter->group_len = 0;
uint l = iter->l_curr = iter->l_next;
+ if (l == iter->loop_start) {
+ /* `grupo_len` is already calculated in the first loop */
+ }
+ else {
+ iter->group_len = 0;
+ }
while (l <= loop_end) {
uint l_next = l + 1;
const uint loop_ctx = loop_map[l];
@@ -825,20 +857,6 @@ static bool weld_iter_loop_of_poly_next(WeldLoopOfPolyIter *iter)
}
if (wl->flag == ELEM_COLLAPSED) {
if (iter->group) {
- if (l == iter->loop_start) {
- uint l_prev = loop_end;
- const uint loop_ctx_end = loop_map[l_prev];
- if (loop_ctx_end != OUT_OF_CONTEXT) {
- const WeldLoop *wl_prev = &wloop[loop_ctx_end];
- while (wl_prev->flag == ELEM_COLLAPSED) {
- iter->group[iter->group_len++] = l_prev--;
- wl_prev--;
- if (wl_prev->loop_orig != l_prev) {
- break;
- }
- }
- }
- }
iter->group[iter->group_len++] = l;
}
l = l_next;
@@ -1471,6 +1489,8 @@ static void customdata_weld(
return;
}
+ CustomData_interp(source, dest, (const int *)src_indices, NULL, NULL, count, dest_index);
+
int src_i, dest_i;
int j;
@@ -1503,16 +1523,7 @@ static void customdata_weld(
if (dest->layers[dest_i].type == type) {
void *src_data = source->layers[src_i].data;
- if (CustomData_layer_has_math(dest, dest_i)) {
- const int size = CustomData_sizeof(type);
- void *dst_data = dest->layers[dest_i].data;
- void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size);
- for (j = 0; j < count; j++) {
- CustomData_data_add(
- type, v_dst, POINTER_OFFSET(src_data, (size_t)src_indices[j] * size));
- }
- }
- else if (type == CD_MVERT) {
+ if (type == CD_MVERT) {
for (j = 0; j < count; j++) {
MVert *mv_src = &((MVert *)src_data)[src_indices[j]];
add_v3_v3(co, mv_src->co);
@@ -1534,6 +1545,19 @@ static void customdata_weld(
flag |= me_src->flag;
}
}
+ else if (CustomData_layer_has_interp(dest, dest_i)) {
+ /* Already calculated.
+ * TODO: Optimize by exposing `typeInfo->interp`. */
+ }
+ else if (CustomData_layer_has_math(dest, dest_i)) {
+ const int size = CustomData_sizeof(type);
+ void *dst_data = dest->layers[dest_i].data;
+ void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size);
+ for (j = 0; j < count; j++) {
+ CustomData_data_add(
+ type, v_dst, POINTER_OFFSET(src_data, (size_t)src_indices[j] * size));
+ }
+ }
else {
CustomData_copy_layer_type_data(source, dest, type, src_indices[0], dest_index, 1);
}
@@ -1551,13 +1575,7 @@ static void customdata_weld(
for (dest_i = 0; dest_i < dest->totlayer; dest_i++) {
CustomDataLayer *layer_dst = &dest->layers[dest_i];
const int type = layer_dst->type;
- if (CustomData_layer_has_math(dest, dest_i)) {
- const int size = CustomData_sizeof(type);
- void *dst_data = layer_dst->data;
- void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size);
- CustomData_data_multiply(type, v_dst, fac);
- }
- else if (type == CD_MVERT) {
+ if (type == CD_MVERT) {
MVert *mv = &((MVert *)layer_dst->data)[dest_index];
mul_v3_fl(co, fac);
bweight *= fac;
@@ -1586,6 +1604,15 @@ static void customdata_weld(
me->bweight = (char)bweight;
me->flag = flag;
}
+ else if (CustomData_layer_has_interp(dest, dest_i)) {
+ /* Already calculated. */
+ }
+ else if (CustomData_layer_has_math(dest, dest_i)) {
+ const int size = CustomData_sizeof(type);
+ void *dst_data = layer_dst->data;
+ void *v_dst = POINTER_OFFSET(dst_data, (size_t)dest_index * size);
+ CustomData_data_multiply(type, v_dst, fac);
+ }
}
}