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:
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/CMakeLists.txt4
-rw-r--r--source/blender/modifiers/SConscript3
-rw-r--r--source/blender/modifiers/intern/MOD_array.c69
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c6
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c9
5 files changed, 66 insertions, 25 deletions
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 584df9eee75..06e9f8f5b67 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -132,6 +132,10 @@ if(WITH_MOD_OCEANSIM)
add_definitions(-DWITH_OCEANSIM)
endif()
+if(WITH_BULLET)
+ add_definitions(-DWITH_BULLET)
+endif()
+
if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
diff --git a/source/blender/modifiers/SConscript b/source/blender/modifiers/SConscript
index 88bf33db38e..c15a562abc0 100644
--- a/source/blender/modifiers/SConscript
+++ b/source/blender/modifiers/SConscript
@@ -63,6 +63,9 @@ if env['WITH_BF_FLUID']:
if env['WITH_BF_OCEANSIM']:
defs.append('WITH_OCEANSIM')
+if env['WITH_BF_BULLET']:
+ defs.append('WITH_BULLET')
+
if env['WITH_BF_GAMEENGINE']:
incs.append('#/extern/recastnavigation')
defs.append('WITH_GAMEENGINE')
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 2768d9412d7..40db49afef2 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -404,6 +404,12 @@ static DerivedMesh *arrayModifier_doArray(
int *full_doubles_map = NULL;
int tot_doubles;
+ const bool use_merge = amd->flags & MOD_ARR_MERGE;
+ const bool use_recalc_normals = (dm->dirty & DM_DIRTY_NORMALS) || use_merge;
+ const bool use_offset_ob = ((amd->offset_type & MOD_ARR_OFF_OBJ) && amd->offset_ob);
+ /* allow pole vertices to be used by many faces */
+ const bool with_follow = use_offset_ob;
+
int start_cap_nverts = 0, start_cap_nedges = 0, start_cap_npolys = 0, start_cap_nloops = 0;
int end_cap_nverts = 0, end_cap_nedges = 0, end_cap_npolys = 0, end_cap_nloops = 0;
int result_nverts = 0, result_nedges = 0, result_npolys = 0, result_nloops = 0;
@@ -451,7 +457,7 @@ static DerivedMesh *arrayModifier_doArray(
offset[3][j] += amd->scale[j] * vertarray_size(src_mvert, chunk_nverts, j);
}
- if ((amd->offset_type & MOD_ARR_OFF_OBJ) && (amd->offset_ob)) {
+ if (use_offset_ob) {
float obinv[4][4];
float result_mat[4][4];
@@ -514,7 +520,7 @@ static DerivedMesh *arrayModifier_doArray(
result = CDDM_from_template(dm, result_nverts, result_nedges, 0, result_nloops, result_npolys);
result_dm_verts = CDDM_get_verts(result);
- if (amd->flags & MOD_ARR_MERGE) {
+ if (use_merge) {
/* Will need full_doubles_map for handling merge */
full_doubles_map = MEM_mallocN(sizeof(int) * result_nverts, "mod array doubles map");
fill_vn_i(full_doubles_map, result_nverts, -1);
@@ -561,6 +567,15 @@ static DerivedMesh *arrayModifier_doArray(
/* apply offset to all new verts */
for (i = 0; i < chunk_nverts; i++, mv++, mv_prev++) {
mul_m4_v3(current_offset, mv->co);
+
+ /* We have to correct normals too, if we do not tag them as dirty! */
+ if (!use_recalc_normals) {
+ float no[3];
+ normal_short_to_float_v3(no, mv->no);
+ mul_mat3_m4_v3(current_offset, no);
+ normalize_v3(no);
+ normal_float_to_short_v3(mv->no, no);
+ }
}
/* adjust edge vertex indices */
@@ -583,7 +598,7 @@ static DerivedMesh *arrayModifier_doArray(
}
/* Handle merge between chunk n and n-1 */
- if ((amd->flags & MOD_ARR_MERGE) && (c >= 1)) {
+ if (use_merge && (c >= 1)) {
if (!offset_has_scale && (c >= 2)) {
/* Mapping chunk 3 to chunk 2 is a translation of mapping 2 to 1
* ... that is except if scaling makes the distance grow */
@@ -594,10 +609,15 @@ static DerivedMesh *arrayModifier_doArray(
int target = full_doubles_map[prev_chunk_index];
if (target != -1) {
target += chunk_nverts; /* translate mapping */
- /* The rule here is to not follow mapping to chunk N-2, which could be too far
- * so if target vertex was itself mapped, then this vertex is not mapped */
if (full_doubles_map[target] != -1) {
- target = -1;
+ if (with_follow) {
+ target = full_doubles_map[target];
+ }
+ else {
+ /* The rule here is to not follow mapping to chunk N-2, which could be too far
+ * so if target vertex was itself mapped, then this vertex is not mapped */
+ target = -1;
+ }
}
}
full_doubles_map[this_chunk_index] = target;
@@ -612,7 +632,7 @@ static DerivedMesh *arrayModifier_doArray(
c * chunk_nverts,
chunk_nverts,
amd->merge_dist,
- false);
+ with_follow);
}
}
}
@@ -622,10 +642,7 @@ static DerivedMesh *arrayModifier_doArray(
copy_m4_m4(final_offset, current_offset);
- if ((amd->flags & MOD_ARR_MERGE) &&
- (amd->flags & MOD_ARR_MERGEFINAL) &&
- (count > 1))
- {
+ if (use_merge && (amd->flags & MOD_ARR_MERGEFINAL) && (count > 1)) {
/* Merge first and last copies */
dm_mvert_map_doubles(
full_doubles_map,
@@ -635,7 +652,7 @@ static DerivedMesh *arrayModifier_doArray(
first_chunk_start,
first_chunk_nverts,
amd->merge_dist,
- false);
+ with_follow);
}
/* start capping */
@@ -651,7 +668,7 @@ static DerivedMesh *arrayModifier_doArray(
result_npolys - start_cap_npolys - end_cap_npolys,
start_cap_nverts, start_cap_nedges, start_cap_nloops, start_cap_npolys);
/* Identify doubles with first chunk */
- if (amd->flags & MOD_ARR_MERGE) {
+ if (use_merge) {
dm_mvert_map_doubles(
full_doubles_map,
result_dm_verts,
@@ -676,7 +693,7 @@ static DerivedMesh *arrayModifier_doArray(
result_npolys - end_cap_npolys,
end_cap_nverts, end_cap_nedges, end_cap_nloops, end_cap_npolys);
/* Identify doubles with last chunk */
- if (amd->flags & MOD_ARR_MERGE) {
+ if (use_merge) {
dm_mvert_map_doubles(
full_doubles_map,
result_dm_verts,
@@ -690,19 +707,17 @@ static DerivedMesh *arrayModifier_doArray(
}
/* done capping */
- /* In case org dm has dirty normals, or we made some merging, mark normals as dirty in new dm!
- * TODO: we may need to set other dirty flags as well?
- */
- if ((dm->dirty & DM_DIRTY_NORMALS) || full_doubles_map) {
- result->dirty |= DM_DIRTY_NORMALS;
- }
-
/* Handle merging */
tot_doubles = 0;
- if (full_doubles_map) {
+ if (use_merge) {
for (i = 0; i < result_nverts; i++) {
if (full_doubles_map[i] != -1) {
- tot_doubles++;
+ if (i == full_doubles_map[i]) {
+ full_doubles_map[i] = -1;
+ }
+ else {
+ tot_doubles++;
+ }
}
}
if (tot_doubles > 0) {
@@ -710,6 +725,14 @@ static DerivedMesh *arrayModifier_doArray(
}
MEM_freeN(full_doubles_map);
}
+
+ /* In case org dm has dirty normals, or we made some merging, mark normals as dirty in new dm!
+ * TODO: we may need to set other dirty flags as well?
+ */
+ if (use_recalc_normals) {
+ result->dirty |= DM_DIRTY_NORMALS;
+ }
+
return result;
}
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 825015fa25c..1e422806d80 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -218,6 +218,7 @@ static bool skin_frame_find_contained_faces(const Frame *frame,
/* Returns true if hull is successfully built, false otherwise */
static bool build_hull(SkinOutput *so, Frame **frames, int totframe)
{
+#ifdef WITH_BULLET
BMesh *bm = so->bm;
BMOperator op;
BMIter iter;
@@ -326,6 +327,11 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe)
BM_mesh_delete_hflag_tagged(bm, BM_ELEM_TAG, BM_EDGE | BM_FACE);
return true;
+#else
+ (void)so, (void)frames, (void)totframe;
+ (void)skin_frame_find_contained_faces;
+ return false;
+#endif
}
/* Returns the average frame side length (frames are rectangular, so
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
index 76986583ef5..7349ca9f9ef 100644
--- a/source/blender/modifiers/intern/MOD_wireframe.c
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -60,7 +60,7 @@ static void copyData(ModifierData *md, ModifierData *target)
static bool isDisabled(ModifierData *UNUSED(md), int UNUSED(useRenderParams))
{
- return 0;
+ return false;
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
@@ -75,6 +75,11 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
}
+static bool dependsOnNormals(ModifierData *UNUSED(md))
+{
+ return true;
+}
+
static DerivedMesh *WireframeModifier_do( WireframeModifierData *wmd, Object *ob, DerivedMesh *dm)
{
DerivedMesh *result;
@@ -135,7 +140,7 @@ ModifierTypeInfo modifierType_Wireframe = {
/* isDisabled */ isDisabled,
/* updateDepgraph */ NULL,
/* dependsOnTime */ NULL,
- /* dependsOnNormals */ NULL,
+ /* dependsOnNormals */ dependsOnNormals,
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,