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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-06-21 05:14:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-06-21 05:14:49 +0300
commit48c58bd9138ad88d8aaa24ad9d6d67e1303e7905 (patch)
tree4e6b7d88ce3be745406cd83eaf132ae89180bfb0 /source
parent2cfff95ba315c0650b0be4045dd4adc187bbf65b (diff)
parent1c199401983bd53577cb180efe83ee5314f04296 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/anim.c10
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c201
-rw-r--r--source/blender/blenkernel/intern/library_idmap.c2
-rw-r--r--source/blender/blenkernel/intern/library_query.c50
-rw-r--r--source/blender/blenkernel/intern/node.c3
-rw-r--r--source/blender/blenlib/BLI_math_matrix.h6
-rw-r--r--source/blender/blenlib/BLI_math_vector.h2
-rw-r--r--source/blender/blenlib/BLI_quadric.h7
-rw-r--r--source/blender/blenlib/intern/array_utils.c2
-rw-r--r--source/blender/blenlib/intern/math_matrix.c17
-rw-r--r--source/blender/blenlib/intern/math_vector_inline.c7
-rw-r--r--source/blender/blenlib/intern/quadric.c86
-rw-r--r--source/blender/blenlib/intern/storage.c2
-rw-r--r--source/blender/blenlib/intern/task.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c38
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon_edgenet.c105
-rw-r--r--source/blender/bmesh/operators/bmo_connect_concave.c11
-rw-r--r--source/blender/bmesh/operators/bmo_triangulate.c38
-rw-r--r--source/blender/bmesh/tools/bmesh_decimate_collapse.c267
-rw-r--r--source/blender/collada/MeshImporter.cpp3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h4
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_transitive.cc2
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type_defines.cc6
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.h2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.cc2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_flush.h2
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node.cc2
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node.h2
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.cc6
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_component.h2
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_operation.cc2
-rw-r--r--source/blender/depsgraph/intern/nodes/deg_node_operation.h2
-rw-r--r--source/blender/editors/interface/interface_panel.c4
-rw-r--r--source/blender/editors/io/io_collada.c2
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c2
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h4
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c240
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c45
-rw-r--r--source/blender/editors/space_image/image_ops.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c18
-rw-r--r--source/blender/editors/space_view3d/drawobject.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c47
-rw-r--r--source/blender/editors/transform/transform_snap.c14
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsNoise.cpp2
-rw-r--r--source/blender/gpu/intern/gpu_draw.c1
-rw-r--r--source/blender/makesdna/DNA_camera_types.h4
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c2
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c2
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c9
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c3
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp2
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp3
-rw-r--r--source/gameengine/Expressions/EXP_PyObjectPlus.h18
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp6
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp15
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_VehicleWrapper.cpp8
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h2
-rw-r--r--source/gameengine/Physics/common/PHY_ICharacter.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IController.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IMotionState.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsController.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h2
-rw-r--r--source/gameengine/Physics/common/PHY_IVehicle.h2
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h2
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h2
77 files changed, 979 insertions, 414 deletions
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 440f49ffb08..17d76bb290a 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -340,11 +340,11 @@ static void motionpaths_calc_update_scene(Scene *scene)
}
}
#else // original, 'always correct' version
- /* do all updates
- * - if this is too slow, resort to using a more efficient way
- * that doesn't force complete update, but for now, this is the
- * most accurate way!
- */
+ /* do all updates
+ * - if this is too slow, resort to using a more efficient way
+ * that doesn't force complete update, but for now, this is the
+ * most accurate way!
+ */
BKE_scene_update_for_newframe(G.main->eval_ctx, G.main, scene, scene->lay); /* XXX this is the best way we can get anything moving */
#endif
}
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 7842d561557..d02041d6da8 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1813,14 +1813,14 @@ static DerivedMesh *dynamicPaint_Modifier_apply(
DynamicPaintModifierApplyData data = {.surface = surface, .fcolor = fcolor};
BLI_task_parallel_range(0, sData->total_points, &data,
dynamic_paint_apply_surface_vpaint_blend_cb,
- sData->total_points > 1000);
+ sData->total_points > 1000);
/* paint layer */
MLoopCol *mloopcol = CustomData_get_layer_named(&result->loopData, CD_MLOOPCOL, surface->output_name);
/* if output layer is lost from a constructive modifier, re-add it */
if (!mloopcol && dynamicPaint_outputLayerExists(surface, ob, 0)) {
mloopcol = CustomData_add_layer_named(
- &result->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, totloop, surface->output_name);
+ &result->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, totloop, surface->output_name);
}
/* wet layer */
@@ -1828,7 +1828,7 @@ static DerivedMesh *dynamicPaint_Modifier_apply(
/* if output layer is lost from a constructive modifier, re-add it */
if (!mloopcol_wet && dynamicPaint_outputLayerExists(surface, ob, 1)) {
mloopcol_wet = CustomData_add_layer_named(
- &result->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, totloop, surface->output_name2);
+ &result->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, totloop, surface->output_name2);
}
/* Save preview results to weight layer to be able to share same drawing methods */
@@ -1837,7 +1837,7 @@ static DerivedMesh *dynamicPaint_Modifier_apply(
mloopcol_preview = CustomData_get_layer(&result->loopData, CD_PREVIEW_MLOOPCOL);
if (!mloopcol_preview) {
mloopcol_preview = CustomData_add_layer(
- &result->loopData, CD_PREVIEW_MLOOPCOL, CD_CALLOC, NULL, totloop);
+ &result->loopData, CD_PREVIEW_MLOOPCOL, CD_CALLOC, NULL, totloop);
}
}
@@ -2323,15 +2323,15 @@ static int dynamic_paint_find_neighbour_pixel(
edge1_index = 0;
edge2_index = 1;
dist_squared = dist_squared_to_line_segment_v2(
- pixel,
- mloopuv[mlooptri[cPoint->tri_index].tri[0]].uv,
- mloopuv[mlooptri[cPoint->tri_index].tri[1]].uv);
+ pixel,
+ mloopuv[mlooptri[cPoint->tri_index].tri[0]].uv,
+ mloopuv[mlooptri[cPoint->tri_index].tri[1]].uv);
/* Dist to second edge */
t_dist_squared = dist_squared_to_line_segment_v2(
- pixel,
- mloopuv[mlooptri[cPoint->tri_index].tri[1]].uv,
- mloopuv[mlooptri[cPoint->tri_index].tri[2]].uv);
+ pixel,
+ mloopuv[mlooptri[cPoint->tri_index].tri[1]].uv,
+ mloopuv[mlooptri[cPoint->tri_index].tri[2]].uv);
if (t_dist_squared < dist_squared) {
e1_index = cPoint->v2;
e2_index = cPoint->v3;
@@ -2342,9 +2342,9 @@ static int dynamic_paint_find_neighbour_pixel(
/* Dist to third edge */
t_dist_squared = dist_squared_to_line_segment_v2(
- pixel,
- mloopuv[mlooptri[cPoint->tri_index].tri[2]].uv,
- mloopuv[mlooptri[cPoint->tri_index].tri[0]].uv);
+ pixel,
+ mloopuv[mlooptri[cPoint->tri_index].tri[2]].uv,
+ mloopuv[mlooptri[cPoint->tri_index].tri[0]].uv);
if (t_dist_squared < dist_squared) {
e1_index = cPoint->v3;
e2_index = cPoint->v1;
@@ -2395,9 +2395,9 @@ static int dynamic_paint_find_neighbour_pixel(
//printf("connected UV : %f,%f & %f,%f - %f,%f & %f,%f\n", s_uv1[0], s_uv1[1], s_uv2[0], s_uv2[1], t_uv1[0], t_uv1[1], t_uv2[0], t_uv2[1]);
if (((s_uv1[0] == t_uv1[0] && s_uv1[1] == t_uv1[1]) &&
- (s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1])) ||
- ((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) &&
- (s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1])))
+ (s_uv2[0] == t_uv2[0] && s_uv2[1] == t_uv2[1])) ||
+ ((s_uv2[0] == t_uv1[0] && s_uv2[1] == t_uv1[1]) &&
+ (s_uv1[0] == t_uv2[0] && s_uv1[1] == t_uv2[1])))
{
return ((px + neighX[n_index]) + w * (py + neighY[n_index]));
}
@@ -2407,15 +2407,15 @@ static int dynamic_paint_find_neighbour_pixel(
* on this other face UV
*/
lambda = closest_to_line_v2(
- closest_point, pixel,
- mloopuv[mlooptri[cPoint->tri_index].tri[edge1_index]].uv,
- mloopuv[mlooptri[cPoint->tri_index].tri[edge2_index]].uv);
+ closest_point, pixel,
+ mloopuv[mlooptri[cPoint->tri_index].tri[edge1_index]].uv,
+ mloopuv[mlooptri[cPoint->tri_index].tri[edge2_index]].uv);
CLAMP(lambda, 0.0f, 1.0f);
sub_v2_v2v2(
- dir_vec,
- mloopuv[mlooptri[target_tri].tri[target_uv2]].uv,
- mloopuv[mlooptri[target_tri].tri[target_uv1]].uv);
+ dir_vec,
+ mloopuv[mlooptri[target_tri].tri[target_uv2]].uv,
+ mloopuv[mlooptri[target_tri].tri[target_uv1]].uv);
mul_v2_fl(dir_vec, lambda);
@@ -2634,8 +2634,8 @@ int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface, flo
ImgSeqFormatData *f_data = MEM_callocN(sizeof(*f_data), "ImgSeqFormatData");
if (f_data) {
f_data->uv_p = MEM_callocN(active_points * sizeof(*f_data->uv_p), "PaintUVPoint");
- f_data->barycentricWeights = MEM_callocN(active_points * aa_samples * sizeof(*f_data->barycentricWeights),
- "PaintUVPoint");
+ f_data->barycentricWeights =
+ MEM_callocN(active_points * aa_samples * sizeof(*f_data->barycentricWeights), "PaintUVPoint");
if (!f_data->uv_p || !f_data->barycentricWeights)
error = 1;
@@ -2837,7 +2837,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam
}
DynamicPaintOutputSurfaceImageData data = {.surface = surface, .ibuf = ibuf};
- switch(surface->type) {
+ switch (surface->type) {
case MOD_DPAINT_SURFACE_T_PAINT:
switch (output_layer) {
case 0:
@@ -3838,12 +3838,12 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
/* loop through cell points and process brush */
DynamicPaintPaintData data = {
- .surface = surface,
+ .surface = surface,
.brush = brush, .brushOb = brushOb, .bMats = bMats,
.scene = scene, .timescale = timescale, .c_index = c_index,
- .dm = dm, .mvert = mvert, .mloop = mloop, .mlooptri = mlooptri,
- .brush_radius = brush_radius, .avg_brushNor = avg_brushNor, .brushVelocity = brushVelocity,
- .treeData = &treeData
+ .dm = dm, .mvert = mvert, .mloop = mloop, .mlooptri = mlooptri,
+ .brush_radius = brush_radius, .avg_brushNor = avg_brushNor, .brushVelocity = brushVelocity,
+ .treeData = &treeData
};
BLI_task_parallel_range_ex(0, grid->s_num[c_index], &data, NULL, 0,
dynamic_paint_paint_mesh_cell_point_cb_ex,
@@ -3991,16 +3991,16 @@ static int dynamicPaint_paintSinglePoint(
* Loop through every surface point
*/
DynamicPaintPaintData data = {
- .surface = surface,
- .brush = brush, .brushOb = brushOb, .bMats = bMats,
- .scene = scene, .timescale = timescale,
- .mvert = mvert,
- .brush_radius = brush_radius, .brushVelocity = &brushVel,
+ .surface = surface,
+ .brush = brush, .brushOb = brushOb, .bMats = bMats,
+ .scene = scene, .timescale = timescale,
+ .mvert = mvert,
+ .brush_radius = brush_radius, .brushVelocity = &brushVel,
.pointCoord = pointCoord,
};
BLI_task_parallel_range_ex(0, sData->total_points, &data, NULL, 0,
- dynamic_paint_paint_single_point_cb_ex,
- sData->total_points > 1000, true);
+ dynamic_paint_paint_single_point_cb_ex,
+ sData->total_points > 1000, true);
return 1;
}
@@ -4433,83 +4433,83 @@ static void dynamic_paint_effect_drip_cb(void *userdata, const int index)
{
const DynamicPaintEffectData *data = userdata;
- const DynamicPaintSurface *surface = data->surface;
- const PaintSurfaceData *sData = surface->data;
- BakeAdjPoint *bNeighs = sData->bData->bNeighs;
- PaintPoint *pPoint = &((PaintPoint *)sData->type_data)[index];
- const PaintPoint *prevPoint = data->prevPoint;
- const PaintPoint *pPoint_prev = &prevPoint[index];
- const float *force = data->force;
- const float eff_scale = data->eff_scale;
+ const DynamicPaintSurface *surface = data->surface;
+ const PaintSurfaceData *sData = surface->data;
+ BakeAdjPoint *bNeighs = sData->bData->bNeighs;
+ PaintPoint *pPoint = &((PaintPoint *)sData->type_data)[index];
+ const PaintPoint *prevPoint = data->prevPoint;
+ const PaintPoint *pPoint_prev = &prevPoint[index];
+ const float *force = data->force;
+ const float eff_scale = data->eff_scale;
- const int *n_target = sData->adj_data->n_target;
+ const int *n_target = sData->adj_data->n_target;
- uint8_t *point_locks = data->point_locks;
+ uint8_t *point_locks = data->point_locks;
- int closest_id[2];
- float closest_d[2];
+ int closest_id[2];
+ float closest_d[2];
- /* adjust drip speed depending on wetness */
- float w_factor = pPoint_prev->wetness - 0.025f;
- if (w_factor <= 0)
- return;
- CLAMP(w_factor, 0.0f, 1.0f);
+ /* adjust drip speed depending on wetness */
+ float w_factor = pPoint_prev->wetness - 0.025f;
+ if (w_factor <= 0)
+ return;
+ CLAMP(w_factor, 0.0f, 1.0f);
- /* get force affect points */
- surface_determineForceTargetPoints(sData, index, &force[index * 4], closest_d, closest_id);
+ /* get force affect points */
+ surface_determineForceTargetPoints(sData, index, &force[index * 4], closest_d, closest_id);
- /* Apply movement towards those two points */
- for (int i = 0; i < 2; i++) {
- const int n_idx = closest_id[i];
- if (n_idx != -1 && closest_d[i] > 0.0f) {
- const float dir_dot = closest_d[i];
+ /* Apply movement towards those two points */
+ for (int i = 0; i < 2; i++) {
+ const int n_idx = closest_id[i];
+ if (n_idx != -1 && closest_d[i] > 0.0f) {
+ const float dir_dot = closest_d[i];
- /* just skip if angle is too extreme */
- if (dir_dot <= 0.0f)
- continue;
+ /* just skip if angle is too extreme */
+ if (dir_dot <= 0.0f)
+ continue;
- float dir_factor, a_factor;
- const float speed_scale = eff_scale * force[index * 4 + 3] / bNeighs[n_idx].dist;
+ float dir_factor, a_factor;
+ const float speed_scale = eff_scale * force[index * 4 + 3] / bNeighs[n_idx].dist;
- const unsigned int n_trgt = (unsigned int)n_target[n_idx];
+ const unsigned int n_trgt = (unsigned int)n_target[n_idx];
- /* Sort of spinlock, but only for given ePoint.
- * Since the odds a same ePoint is modified at the same time by several threads is very low, this is
- * much more eficient than a global spin lock. */
- const unsigned int pointlock_idx = n_trgt / 8;
- const uint8_t pointlock_bitmask = 1 << (n_trgt & 7); /* 7 == 0b111 */
- while (atomic_fetch_and_or_uint8(&point_locks[pointlock_idx], pointlock_bitmask) & pointlock_bitmask);
+ /* Sort of spinlock, but only for given ePoint.
+ * Since the odds a same ePoint is modified at the same time by several threads is very low, this is
+ * much more eficient than a global spin lock. */
+ const unsigned int pointlock_idx = n_trgt / 8;
+ const uint8_t pointlock_bitmask = 1 << (n_trgt & 7); /* 7 == 0b111 */
+ while (atomic_fetch_and_or_uint8(&point_locks[pointlock_idx], pointlock_bitmask) & pointlock_bitmask);
- PaintPoint *ePoint = &((PaintPoint *)sData->type_data)[n_trgt];
- const float e_wet = ePoint->wetness;
+ PaintPoint *ePoint = &((PaintPoint *)sData->type_data)[n_trgt];
+ const float e_wet = ePoint->wetness;
- dir_factor = min_ff(0.5f, dir_dot * min_ff(speed_scale, 1.0f) * w_factor);
+ dir_factor = min_ff(0.5f, dir_dot * min_ff(speed_scale, 1.0f) * w_factor);
- /* mix new wetness */
- ePoint->wetness += dir_factor;
- CLAMP(ePoint->wetness, 0.0f, MAX_WETNESS);
+ /* mix new wetness */
+ ePoint->wetness += dir_factor;
+ CLAMP(ePoint->wetness, 0.0f, MAX_WETNESS);
- /* mix new color */
- a_factor = dir_factor / pPoint_prev->wetness;
- CLAMP(a_factor, 0.0f, 1.0f);
- mixColors(ePoint->e_color, ePoint->e_color[3], pPoint_prev->e_color, pPoint_prev->e_color[3], a_factor);
- /* dripping is supposed to preserve alpha level */
- if (pPoint_prev->e_color[3] > ePoint->e_color[3]) {
- ePoint->e_color[3] += a_factor * pPoint_prev->e_color[3];
- CLAMP_MAX(ePoint->e_color[3], pPoint_prev->e_color[3]);
- }
+ /* mix new color */
+ a_factor = dir_factor / pPoint_prev->wetness;
+ CLAMP(a_factor, 0.0f, 1.0f);
+ mixColors(ePoint->e_color, ePoint->e_color[3], pPoint_prev->e_color, pPoint_prev->e_color[3], a_factor);
+ /* dripping is supposed to preserve alpha level */
+ if (pPoint_prev->e_color[3] > ePoint->e_color[3]) {
+ ePoint->e_color[3] += a_factor * pPoint_prev->e_color[3];
+ CLAMP_MAX(ePoint->e_color[3], pPoint_prev->e_color[3]);
+ }
- /* decrease paint wetness on current point */
- pPoint->wetness -= (ePoint->wetness - e_wet);
- CLAMP(pPoint->wetness, 0.0f, MAX_WETNESS);
+ /* decrease paint wetness on current point */
+ pPoint->wetness -= (ePoint->wetness - e_wet);
+ CLAMP(pPoint->wetness, 0.0f, MAX_WETNESS);
#ifndef NDEBUG
uint8_t ret = atomic_fetch_and_and_uint8(&point_locks[pointlock_idx], ~pointlock_bitmask);
- BLI_assert(ret & pointlock_bitmask);
+ BLI_assert(ret & pointlock_bitmask);
#else
atomic_fetch_and_and_uint8(&point_locks[pointlock_idx], ~pointlock_bitmask);
#endif
- }
+ }
}
}
@@ -4570,7 +4570,7 @@ static void dynamicPaint_doEffectStep(
memcpy(prevPoint, sData->type_data, sData->total_points * sizeof(struct PaintPoint));
DynamicPaintEffectData data = {
- .surface = surface, .prevPoint = prevPoint,
+ .surface = surface, .prevPoint = prevPoint,
.eff_scale = eff_scale, .force = force,
.point_locks = point_locks,
};
@@ -4786,7 +4786,7 @@ static void dynamic_paint_surface_pre_step_cb(void *userdata, const int index)
if (pPoint->color[3]) {
for (i = 0; i < 3; i++) {
pPoint->color[i] = (f_color[i] * f_color[3] - pPoint->e_color[i] * pPoint->e_color[3]) /
- (pPoint->color[3] * (1.0f - pPoint->e_color[3]));
+ (pPoint->color[3] * (1.0f - pPoint->e_color[3]));
}
}
}
@@ -4807,17 +4807,17 @@ static void dynamic_paint_surface_pre_step_cb(void *userdata, const int index)
if (surface->flags & MOD_DPAINT_DISSOLVE) {
value_dissolve(&pPoint->color[3], surface->diss_speed, timescale,
- (surface->flags & MOD_DPAINT_DISSOLVE_LOG) != 0);
+ (surface->flags & MOD_DPAINT_DISSOLVE_LOG) != 0);
CLAMP_MIN(pPoint->color[3], 0.0f);
value_dissolve(&pPoint->e_color[3], surface->diss_speed, timescale,
- (surface->flags & MOD_DPAINT_DISSOLVE_LOG) != 0);
+ (surface->flags & MOD_DPAINT_DISSOLVE_LOG) != 0);
CLAMP_MIN(pPoint->e_color[3], 0.0f);
}
}
/* dissolve for float types */
else if (surface->flags & MOD_DPAINT_DISSOLVE &&
- (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || surface->type == MOD_DPAINT_SURFACE_T_WEIGHT))
+ (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || surface->type == MOD_DPAINT_SURFACE_T_WEIGHT))
{
float *point = &((float *)sData->type_data)[index];
/* log or linear */
@@ -5066,7 +5066,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Sce
*/
DynamicPaintGenerateBakeData data = {
.surface = surface, .ob = ob,
- .mvert = mvert, .canvas_verts = canvas_verts,
+ .mvert = mvert, .canvas_verts = canvas_verts,
.do_velocity_data = do_velocity_data, .new_bdata = new_bdata,
};
BLI_task_parallel_range(
@@ -5177,11 +5177,8 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su
dynamicPaint_updateBrushMaterials(brushObj, brush->mat, scene, &bMats);
/* Apply brush on the surface depending on it's collision type */
- /* Particle brush: */
- if (brush->collision == MOD_DPAINT_COL_PSYS) {
- }
/* Object center distance: */
- else if (brush->collision == MOD_DPAINT_COL_POINT && brushObj != ob) {
+ if (brush->collision == MOD_DPAINT_COL_POINT && brushObj != ob) {
dynamicPaint_paintSinglePoint(surface, brushObj->loc, brush, brushObj, &bMats, scene, timescale);
}
/* Mesh volume/proximity: */
diff --git a/source/blender/blenkernel/intern/library_idmap.c b/source/blender/blenkernel/intern/library_idmap.c
index 66025c04332..daf097b9f0b 100644
--- a/source/blender/blenkernel/intern/library_idmap.c
+++ b/source/blender/blenkernel/intern/library_idmap.c
@@ -33,7 +33,7 @@
#include "BKE_library.h"
#include "BKE_library_idmap.h" /* own include */
-/** \file blender/blenkernel/intern/library_map.c
+/** \file blender/blenkernel/intern/library_idmap.c
* \ingroup bke
*
* Utility functions for faster ID lookups.
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 7d4520ad138..42cecfe86db 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -218,6 +218,14 @@ static void library_foreach_mtex(LibraryForeachIDData *data, MTex *mtex)
FOREACH_FINALIZE_VOID;
}
+static void library_foreach_paint(LibraryForeachIDData *data, Paint *paint)
+{
+ FOREACH_CALLBACK_INVOKE(data, paint->brush, IDWALK_USER);
+ FOREACH_CALLBACK_INVOKE(data, paint->palette, IDWALK_USER);
+
+ FOREACH_FINALIZE_VOID;
+}
+
/**
* Loop over all of the ID's this datablock links to.
@@ -269,7 +277,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
CALLBACK_INVOKE(scene->camera, IDWALK_NOP);
CALLBACK_INVOKE(scene->world, IDWALK_USER);
CALLBACK_INVOKE(scene->set, IDWALK_NOP);
- CALLBACK_INVOKE(scene->clip, IDWALK_NOP);
+ CALLBACK_INVOKE(scene->clip, IDWALK_USER);
CALLBACK_INVOKE(scene->nodetree, IDWALK_NOP);
/* DO NOT handle scene->basact here, it's doubling with the loop over whole scene->base later,
* since basact is just a pointer to one of those items. */
@@ -309,6 +317,9 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
CALLBACK_INVOKE(seq->clip, IDWALK_USER);
CALLBACK_INVOKE(seq->mask, IDWALK_USER);
CALLBACK_INVOKE(seq->sound, IDWALK_USER);
+ for (SequenceModifierData *smd = seq->modifiers.first; smd; smd = smd->next) {
+ CALLBACK_INVOKE(smd->mask_id, IDWALK_USER);
+ }
}
SEQ_END
}
@@ -321,25 +332,24 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
if (toolsett) {
CALLBACK_INVOKE(toolsett->skgen_template, IDWALK_NOP);
- CALLBACK_INVOKE(toolsett->imapaint.stencil, IDWALK_NOP);
- CALLBACK_INVOKE(toolsett->imapaint.clone, IDWALK_NOP);
- CALLBACK_INVOKE(toolsett->imapaint.canvas, IDWALK_NOP);
+
+ library_foreach_paint(&data, &toolsett->imapaint.paint);
+ CALLBACK_INVOKE(toolsett->imapaint.stencil, IDWALK_USER);
+ CALLBACK_INVOKE(toolsett->imapaint.clone, IDWALK_USER);
+ CALLBACK_INVOKE(toolsett->imapaint.canvas, IDWALK_USER);
+
if (toolsett->vpaint) {
- CALLBACK_INVOKE(toolsett->vpaint->paint.brush, IDWALK_NOP);
- CALLBACK_INVOKE(toolsett->vpaint->paint.palette, IDWALK_NOP);
+ library_foreach_paint(&data, &toolsett->vpaint->paint);
}
if (toolsett->wpaint) {
- CALLBACK_INVOKE(toolsett->wpaint->paint.brush, IDWALK_NOP);
- CALLBACK_INVOKE(toolsett->wpaint->paint.palette, IDWALK_NOP);
+ library_foreach_paint(&data, &toolsett->wpaint->paint);
}
if (toolsett->sculpt) {
- CALLBACK_INVOKE(toolsett->sculpt->paint.brush, IDWALK_NOP);
- CALLBACK_INVOKE(toolsett->sculpt->paint.palette, IDWALK_NOP);
+ library_foreach_paint(&data, &toolsett->sculpt->paint);
CALLBACK_INVOKE(toolsett->sculpt->gravity_object, IDWALK_NOP);
}
if (toolsett->uvsculpt) {
- CALLBACK_INVOKE(toolsett->uvsculpt->paint.brush, IDWALK_NOP);
- CALLBACK_INVOKE(toolsett->uvsculpt->paint.palette, IDWALK_NOP);
+ library_foreach_paint(&data, &toolsett->uvsculpt->paint);
}
}
@@ -385,6 +395,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
CALLBACK_INVOKE(object->pd->tex, IDWALK_USER);
CALLBACK_INVOKE(object->pd->f_source, IDWALK_NOP);
}
+ /* Note that ob->effect is deprecated, so no need to handle it here. */
if (object->pose) {
bPoseChannel *pchan;
@@ -579,16 +590,23 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
MovieClip *clip = (MovieClip *) id;
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *object;
+ MovieTrackingTrack *track;
+ MovieTrackingPlaneTrack *plane_track;
CALLBACK_INVOKE(clip->gpd, IDWALK_USER);
- for (object = tracking->objects.first; object; object = object->next) {
- ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, object);
- MovieTrackingTrack *track;
- for (track = tracksbase->first; track; track = track->next) {
+ for (track = tracking->tracks.first; track; track = track->next) {
+ CALLBACK_INVOKE(track->gpd, IDWALK_USER);
+ }
+ for (object = tracking->objects.first; object; object = object->next) {
+ for (track = object->tracks.first; track; track = track->next) {
CALLBACK_INVOKE(track->gpd, IDWALK_USER);
}
}
+
+ for (plane_track = tracking->plane_tracks.first; plane_track; plane_track = plane_track->next) {
+ CALLBACK_INVOKE(plane_track->image, IDWALK_USER);
+ }
break;
}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index fa0367d1656..2b381f6ff0b 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -2418,7 +2418,8 @@ void ntreeInterfaceTypeUpdate(bNodeTree *ntree)
/* ************ find stuff *************** */
-bNode *ntreeFindType(const bNodeTree *ntree, int type) {
+bNode *ntreeFindType(const bNodeTree *ntree, int type)
+{
if (ntree) {
for (bNode * node = ntree->nodes.first; node; node = node->next) {
if (node->type == type) {
diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 6d6fbe4e7af..9120d9f53f7 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -138,10 +138,14 @@ bool invert_m3_m3(float R[3][3], float A[3][3]);
bool invert_m4(float R[4][4]);
bool invert_m4_m4(float R[4][4], float A[4][4]);
-/* double ariphmetics */
+/* double arithmetic (mixed float/double) */
void mul_m4_v4d(float M[4][4], double r[4]);
void mul_v4d_m4v4d(double r[4], float M[4][4], double v[4]);
+/* double matrix functions (no mixing types) */
+void mul_v3_m3v3_db(double r[3], double M[3][3], const double a[3]);
+void mul_m3_v3_db(double M[3][3], double r[3]);
+
/****************************** Linear Algebra *******************************/
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 25f485a25aa..8a36b047bad 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -148,6 +148,7 @@ MINLINE void negate_v4(float r[4]);
MINLINE void negate_v4_v4(float r[4], const float a[3]);
MINLINE void negate_v3_short(short r[3]);
+MINLINE void negate_v3_db(double r[3]);
MINLINE void invert_v2(float r[2]);
@@ -231,6 +232,7 @@ void flip_v4_v4v4(float v[4], const float v1[4], const float v2[4]);
void flip_v3_v3v3(float v[3], const float v1[3], const float v2[3]);
void flip_v2_v2v2(float v[2], const float v1[2], const float v2[2]);
+
/********************************* Comparison ********************************/
MINLINE bool is_zero_v2(const float a[3]) ATTR_WARN_UNUSED_RESULT;
diff --git a/source/blender/blenlib/BLI_quadric.h b/source/blender/blenlib/BLI_quadric.h
index eaf9c7a0738..d46a221d108 100644
--- a/source/blender/blenlib/BLI_quadric.h
+++ b/source/blender/blenlib/BLI_quadric.h
@@ -39,8 +39,7 @@ typedef struct Quadric {
/* conversion */
void BLI_quadric_from_plane(Quadric *q, const double v[4]);
-void BLI_quadric_to_tensor_m3(const Quadric *q, float m[3][3]);
-void BLI_quadric_to_vector_v3(const Quadric *q, float v[3]);
+void BLI_quadric_to_vector_v3(const Quadric *q, double v[3]);
void BLI_quadric_clear(Quadric *q);
@@ -50,7 +49,7 @@ void BLI_quadric_add_qu_ququ(Quadric *r, const Quadric *a, const Quadric *b);
void BLI_quadric_mul(Quadric *a, const double scalar);
/* solve */
-double BLI_quadric_evaluate(const Quadric *q, const float v_fl[3]);
-bool BLI_quadric_optimize(const Quadric *q, float v[3], const float epsilon);
+double BLI_quadric_evaluate(const Quadric *q, const double v[3]);
+bool BLI_quadric_optimize(const Quadric *q, double v[3], const double epsilon);
#endif /* __BLI_QUADRIC_H__ */
diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c
index 5d485e2033d..9c91da4abee 100644
--- a/source/blender/blenlib/intern/array_utils.c
+++ b/source/blender/blenlib/intern/array_utils.c
@@ -183,7 +183,7 @@ void _bli_array_binary_or(
* \param user_data: User data for \a test_fn.
* \param span_step: Indices to iterate over,
* initialize both values to the array length to initialize iteration.
- * \param: r_span_len: The length of the span, useful when \a use_wrap is enabled,
+ * \param r_span_len: The length of the span, useful when \a use_wrap is enabled,
* where calculating the length isnt a simple subtraction.
*/
bool _bli_array_iter_span(
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 0e3f905ef16..c9c61d5c878 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -587,6 +587,15 @@ void mul_v3_m3v3(float r[3], float M[3][3], const float a[3])
r[2] = M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
}
+void mul_v3_m3v3_db(double r[3], double M[3][3], const double a[3])
+{
+ BLI_assert(r != a);
+
+ r[0] = M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
+ r[1] = M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
+ r[2] = M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
+}
+
void mul_v2_m3v3(float r[2], float M[3][3], const float a[3])
{
BLI_assert(r != a);
@@ -597,10 +606,12 @@ void mul_v2_m3v3(float r[2], float M[3][3], const float a[3])
void mul_m3_v3(float M[3][3], float r[3])
{
- float tmp[3];
+ mul_v3_m3v3(r, M, (const float[3]){UNPACK3(r)});
+}
- mul_v3_m3v3(tmp, M, r);
- copy_v3_v3(r, tmp);
+void mul_m3_v3_db(double M[3][3], double r[3])
+{
+ mul_v3_m3v3_db(r, M, (const double[3]){UNPACK3(r)});
}
void mul_transposed_m3_v3(float mat[3][3], float vec[3])
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index b43fb6e986c..fd9f3d5ff99 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -633,6 +633,13 @@ MINLINE void negate_v3_short(short r[3])
r[2] = (short)-r[2];
}
+MINLINE void negate_v3_db(double r[3])
+{
+ r[0] = -r[0];
+ r[1] = -r[1];
+ r[2] = -r[2];
+}
+
MINLINE void invert_v2(float r[2])
{
BLI_assert(!ELEM(0.0f, r[0], r[1]));
diff --git a/source/blender/blenlib/intern/quadric.c b/source/blender/blenlib/intern/quadric.c
index 588cd9c2cb5..c9d27494455 100644
--- a/source/blender/blenlib/intern/quadric.c
+++ b/source/blender/blenlib/intern/quadric.c
@@ -63,26 +63,68 @@ void BLI_quadric_from_plane(Quadric *q, const double v[4])
q->d2 = v[3] * v[3];
}
-void BLI_quadric_to_tensor_m3(const Quadric *q, float m[3][3])
+#if 0 /* UNUSED */
+
+static void quadric_to_tensor_m3(const Quadric *q, double m[3][3])
{
- m[0][0] = (float)q->a2;
- m[0][1] = (float)q->ab;
- m[0][2] = (float)q->ac;
+ m[0][0] = q->a2;
+ m[0][1] = q->ab;
+ m[0][2] = q->ac;
- m[1][0] = (float)q->ab;
- m[1][1] = (float)q->b2;
- m[1][2] = (float)q->bc;
+ m[1][0] = q->ab;
+ m[1][1] = q->b2;
+ m[1][2] = q->bc;
- m[2][0] = (float)q->ac;
- m[2][1] = (float)q->bc;
- m[2][2] = (float)q->c2;
+ m[2][0] = q->ac;
+ m[2][1] = q->bc;
+ m[2][2] = q->c2;
}
-void BLI_quadric_to_vector_v3(const Quadric *q, float v[3])
+#endif
+
+/**
+ * Inline inverse matrix creation.
+ * Equivalent of:
+ *
+ * \code{.c}
+ * quadric_to_tensor_m3(q, m);
+ * invert_m3_db(m, eps);
+ * \endcode
+ */
+static bool quadric_to_tensor_m3_inverse(const Quadric *q, double m[3][3], double epsilon)
{
- v[0] = (float)q->ad;
- v[1] = (float)q->bd;
- v[2] = (float)q->cd;
+ const double det =
+ (q->a2 * (q->b2 * q->c2 - q->bc * q->bc) -
+ q->ab * (q->ab * q->c2 - q->ac * q->bc) +
+ q->ac * (q->ab * q->bc - q->ac * q->b2));
+
+ if (fabs(det) > epsilon) {
+ const double invdet = 1.0 / det;
+
+ m[0][0] = (q->b2 * q->c2 - q->bc * q->bc) * invdet;
+ m[1][0] = (q->bc * q->ac - q->ab * q->c2) * invdet;
+ m[2][0] = (q->ab * q->bc - q->b2 * q->ac) * invdet;
+
+ m[0][1] = (q->ac * q->bc - q->ab * q->c2) * invdet;
+ m[1][1] = (q->a2 * q->c2 - q->ac * q->ac) * invdet;
+ m[2][1] = (q->ab * q->ac - q->a2 * q->bc) * invdet;
+
+ m[0][2] = (q->ab * q->bc - q->ac * q->b2) * invdet;
+ m[1][2] = (q->ac * q->ab - q->a2 * q->bc) * invdet;
+ m[2][2] = (q->a2 * q->b2 - q->ab * q->ab) * invdet;
+
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+void BLI_quadric_to_vector_v3(const Quadric *q, double v[3])
+{
+ v[0] = q->ad;
+ v[1] = q->bd;
+ v[2] = q->cd;
}
void BLI_quadric_clear(Quadric *q)
@@ -105,26 +147,22 @@ void BLI_quadric_mul(Quadric *a, const double scalar)
mul_vn_db((double *)a, QUADRIC_FLT_TOT, scalar);
}
-double BLI_quadric_evaluate(const Quadric *q, const float v_fl[3])
+double BLI_quadric_evaluate(const Quadric *q, const double v[3])
{
- const double v[3] = {UNPACK3(v_fl)};
return ((q->a2 * v[0] * v[0]) + (q->ab * 2 * v[0] * v[1]) + (q->ac * 2 * v[0] * v[2]) + (q->ad * 2 * v[0]) +
(q->b2 * v[1] * v[1]) + (q->bc * 2 * v[1] * v[2]) + (q->bd * 2 * v[1]) +
(q->c2 * v[2] * v[2]) + (q->cd * 2 * v[2]) +
(q->d2));
}
-bool BLI_quadric_optimize(const Quadric *q, float v[3], const float epsilon)
+bool BLI_quadric_optimize(const Quadric *q, double v[3], const double epsilon)
{
- float m[3][3];
+ double m[3][3];
- BLI_quadric_to_tensor_m3(q, m);
-
- if (invert_m3_ex(m, epsilon)) {
+ if (quadric_to_tensor_m3_inverse(q, m, epsilon)) {
BLI_quadric_to_vector_v3(q, v);
- mul_m3_v3(m, v);
- negate_v3(v);
-
+ mul_m3_v3_db(m, v);
+ negate_v3_db(v);
return true;
}
else {
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index aba7c9d5ee2..3edc00a8c1a 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -389,7 +389,7 @@ LinkNode *BLI_file_read_as_lines(const char *name)
/*
* size = because on win32 reading
* all the bytes in the file will return
- * less bytes because of crnl changes.
+ * less bytes because of `CRNL` changes.
*/
size = fread(buf, 1, size, fp);
for (i = 0; i <= size; i++) {
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index 58475b7f835..0b299af88aa 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -928,7 +928,7 @@ static void task_parallel_range_ex(
func_finalize(userdata, userdata_chunk_local);
}
}
- MALLOCA_FREE(userdata_chunk_array, userdata_chunk_size * num_tasks);
+ MALLOCA_FREE(userdata_chunk_array, userdata_chunk_size * num_tasks);
}
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 4d5b885fb3c..3182f5f3055 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1512,6 +1512,15 @@ void *blo_do_versions_newlibadr_us(FileData *fd, const void *lib, const void *ad
return newlibadr_us(fd, lib, adr);
}
+static void *newlibadr_real_us(FileData *fd, const void *lib, const void *adr) /* ensures real user */
+{
+ ID *id = newlibadr(fd, lib, adr);
+
+ id_us_ensure_real(id);
+
+ return id;
+}
+
static void change_idid_adr_fd(FileData *fd, const void *old, void *new)
{
int i;
@@ -2173,9 +2182,10 @@ static void lib_link_brush(FileData *fd, Main *main)
if (brush->id.tag & LIB_TAG_NEED_LINK) {
brush->id.tag &= ~LIB_TAG_NEED_LINK;
+ /* brush->(mask_)mtex.obj is ignored on purpose? */
brush->mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mtex.tex);
brush->mask_mtex.tex = newlibadr_us(fd, brush->id.lib, brush->mask_mtex.tex);
- brush->clone.image = newlibadr_us(fd, brush->id.lib, brush->clone.image);
+ brush->clone.image = newlibadr(fd, brush->id.lib, brush->clone.image);
brush->toggle_brush = newlibadr(fd, brush->id.lib, brush->toggle_brush);
brush->paint_curve = newlibadr_us(fd, brush->id.lib, brush->paint_curve);
}
@@ -3805,7 +3815,7 @@ static void lib_link_texture(FileData *fd, Main *main)
lib_link_animdata(fd, &tex->id, tex->adt);
tex->ima = newlibadr_us(fd, tex->id.lib, tex->ima);
- tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo);
+ tex->ipo = newlibadr_us(fd, tex->id.lib, tex->ipo); // XXX deprecated - old animation system
if (tex->env)
tex->env->object = newlibadr(fd, tex->id.lib, tex->env->object);
if (tex->pd)
@@ -3889,7 +3899,7 @@ static void lib_link_material(FileData *fd, Main *main)
* of library blocks that implement this.*/
IDP_LibLinkProperty(ma->id.properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
- ma->ipo = newlibadr_us(fd, ma->id.lib, ma->ipo);
+ ma->ipo = newlibadr_us(fd, ma->id.lib, ma->ipo); // XXX deprecated - old animation system
ma->group = newlibadr_us(fd, ma->id.lib, ma->group);
for (a = 0; a < MAX_MTEX; a++) {
@@ -3961,8 +3971,7 @@ static void lib_link_mtface(FileData *fd, Mesh *me, MTFace *mtface, int totface)
* little bogus; it would be better if each mesh consistently added one ref
* to each image it used. - z0r */
for (i = 0; i < totface; i++, tf++) {
- tf->tpage= newlibadr(fd, me->id.lib, tf->tpage);
- id_us_ensure_real(&tf->tpage->id);
+ tf->tpage = newlibadr_real_us(fd, me->id.lib, tf->tpage);
}
}
@@ -3990,8 +3999,7 @@ static void lib_link_customdata_mtpoly(FileData *fd, Mesh *me, CustomData *pdata
int j;
for (j = 0; j < totface; j++, tf++) {
- tf->tpage = newlibadr(fd, me->id.lib, tf->tpage);
- id_us_ensure_real((ID *)tf->tpage);
+ tf->tpage = newlibadr_real_us(fd, me->id.lib, tf->tpage);
}
}
}
@@ -4541,7 +4549,7 @@ static void lib_link_object(FileData *fd, Main *main)
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
if (fluidmd && fluidmd->fss)
- fluidmd->fss->ipo = newlibadr_us(fd, ob->id.lib, fluidmd->fss->ipo);
+ fluidmd->fss->ipo = newlibadr_us(fd, ob->id.lib, fluidmd->fss->ipo); // XXX deprecated - old animation system
}
{
@@ -5238,7 +5246,6 @@ static void lib_link_scene(FileData *fd, Main *main)
for (base = sce->base.first; base; base = next) {
next = base->next;
- /* base->object= newlibadr_us(fd, sce->id.lib, base->object); */
base->object = newlibadr_us(fd, sce->id.lib, base->object);
if (base->object == NULL) {
@@ -5252,7 +5259,7 @@ static void lib_link_scene(FileData *fd, Main *main)
SEQ_BEGIN (sce->ed, seq)
{
- if (seq->ipo) seq->ipo = newlibadr_us(fd, sce->id.lib, seq->ipo);
+ if (seq->ipo) seq->ipo = newlibadr_us(fd, sce->id.lib, seq->ipo); // XXX deprecated - old animation system
seq->scene_sound = NULL;
if (seq->scene) {
seq->scene = newlibadr(fd, sce->id.lib, seq->scene);
@@ -5882,8 +5889,8 @@ static void lib_link_screen(FileData *fd, Main *main)
else if (sl->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
- sima->image = newlibadr_us(fd, sc->id.lib, sima->image);
- sima->mask_info.mask = newlibadr_us(fd, sc->id.lib, sima->mask_info.mask);
+ sima->image = newlibadr_real_us(fd, sc->id.lib, sima->image);
+ sima->mask_info.mask = newlibadr_real_us(fd, sc->id.lib, sima->mask_info.mask);
/* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
* so fingers crossed this works fine!
@@ -5989,8 +5996,8 @@ static void lib_link_screen(FileData *fd, Main *main)
else if (sl->spacetype == SPACE_CLIP) {
SpaceClip *sclip = (SpaceClip *)sl;
- sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip);
- sclip->mask_info.mask = newlibadr_us(fd, sc->id.lib, sclip->mask_info.mask);
+ sclip->clip = newlibadr_real_us(fd, sc->id.lib, sclip->clip);
+ sclip->mask_info.mask = newlibadr_real_us(fd, sc->id.lib, sclip->mask_info.mask);
}
else if (sl->spacetype == SPACE_LOGIC) {
SpaceLogic *slogic = (SpaceLogic *)sl;
@@ -6962,12 +6969,11 @@ static void lib_link_group(FileData *fd, Main *main)
add_us = false;
for (go = group->gobject.first; go; go = go->next) {
- go->ob= newlibadr(fd, group->id.lib, go->ob);
+ go->ob = newlibadr_real_us(fd, group->id.lib, go->ob);
if (go->ob) {
go->ob->flag |= OB_FROMGROUP;
/* if group has an object, it increments user... */
add_us = true;
- id_us_ensure_real(&go->ob->id);
}
}
if (add_us) {
diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
index c224a1ad587..c142dcae514 100644
--- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
+++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
@@ -97,6 +97,10 @@ static BMLoop *bm_edge_flagged_radial_first(BMEdge *e)
return NULL;
}
+/**
+ * \note Be sure to update #bm_face_split_edgenet_find_loop_pair_exists
+ * when making changed to edge picking logic.
+ */
static bool bm_face_split_edgenet_find_loop_pair(
BMVert *v_init, const float face_normal[3],
BMEdge *e_pair[2])
@@ -104,8 +108,6 @@ static bool bm_face_split_edgenet_find_loop_pair(
/* Always find one boundary edge (to determine winding)
* and one wire (if available), otherwise another boundary.
*/
- BMIter iter;
- BMEdge *e;
/* detect winding */
BMLoop *l_walk;
@@ -116,18 +118,22 @@ static bool bm_face_split_edgenet_find_loop_pair(
int edges_boundary_len = 0;
int edges_wire_len = 0;
- BM_ITER_ELEM (e, &iter, v_init, BM_EDGES_OF_VERT) {
- if (BM_ELEM_API_FLAG_TEST(e, EDGE_NET)) {
- const unsigned int count = bm_edge_flagged_radial_count(e);
- if (count == 1) {
- BLI_SMALLSTACK_PUSH(edges_boundary, e);
- edges_boundary_len++;
- }
- else if (count == 0) {
- BLI_SMALLSTACK_PUSH(edges_wire, e);
- edges_wire_len++;
+ {
+ BMEdge *e, *e_first;
+ e = e_first = v_init->e;
+ do {
+ if (BM_ELEM_API_FLAG_TEST(e, EDGE_NET)) {
+ const unsigned int count = bm_edge_flagged_radial_count(e);
+ if (count == 1) {
+ BLI_SMALLSTACK_PUSH(edges_boundary, e);
+ edges_boundary_len++;
+ }
+ else if (count == 0) {
+ BLI_SMALLSTACK_PUSH(edges_wire, e);
+ edges_wire_len++;
+ }
}
- }
+ } while ((e = BM_DISK_EDGE_NEXT(e, v_init)) != e_first);
}
/* first edge should always be boundary */
@@ -157,6 +163,7 @@ static bool bm_face_split_edgenet_find_loop_pair(
v_next = BM_edge_other_vert(e_pair[1], v_init);
angle_best = angle_on_axis_v3v3v3_v3(v_prev->co, v_init->co, v_next->co, face_normal);
+ BMEdge *e;
while ((e = BLI_SMALLSTACK_POP(edges_wire))) {
float angle_test;
v_next = BM_edge_other_vert(e, v_init);
@@ -186,6 +193,58 @@ static bool bm_face_split_edgenet_find_loop_pair(
return true;
}
+/**
+ * A reduced version of #bm_face_split_edgenet_find_loop_pair
+ * that only checks if it would return true.
+ *
+ * \note There is no use in caching resulting edges here,
+ * since between this check and running #bm_face_split_edgenet_find_loop,
+ * the selected edges may have had faces attached.
+ */
+static bool bm_face_split_edgenet_find_loop_pair_exists(
+ BMVert *v_init)
+{
+ int edges_boundary_len = 0;
+ int edges_wire_len = 0;
+
+ {
+ BMEdge *e, *e_first;
+ e = e_first = v_init->e;
+ do {
+ if (BM_ELEM_API_FLAG_TEST(e, EDGE_NET)) {
+ const unsigned int count = bm_edge_flagged_radial_count(e);
+ if (count == 1) {
+ edges_boundary_len++;
+ }
+ else if (count == 0) {
+ edges_wire_len++;
+ }
+ }
+ } while ((e = BM_DISK_EDGE_NEXT(e, v_init)) != e_first);
+ }
+
+ /* first edge should always be boundary */
+ if (edges_boundary_len == 0) {
+ return false;
+ }
+
+ /* attempt one boundary and one wire, or 2 boundary */
+ if (edges_wire_len == 0) {
+ if (edges_boundary_len >= 2) {
+ /* pass */
+ }
+ else {
+ /* one boundary and no wire */
+ return false;
+ }
+ }
+ else {
+ /* pass */
+ }
+
+ return true;
+}
+
static bool bm_face_split_edgenet_find_loop_walk(
BMVert *v_init, const float face_normal[3],
/* cache to avoid realloc every time */
@@ -232,9 +291,6 @@ static bool bm_face_split_edgenet_find_loop_walk(
* alternatives are stored in the 'vert_stack'.
*/
while ((v = BLI_SMALLSTACK_POP_EX(vert_stack, vert_stack_next))) {
- BMIter eiter;
- BMEdge *e_next;
-
#ifdef USE_FASTPATH_NOFORK
walk_nofork:
#else
@@ -250,9 +306,12 @@ walk_nofork:
goto finally;
}
- BM_ITER_ELEM (e_next, &eiter, v, BM_EDGES_OF_VERT) {
- if ((v->e != e_next) &&
- (BM_ELEM_API_FLAG_TEST(e_next, EDGE_NET)) &&
+ BMEdge *e_next, *e_first;
+ e_first = v->e;
+ e_next = BM_DISK_EDGE_NEXT(e_first, v); /* always skip this verts edge */
+ do {
+ BLI_assert(v->e != e_next);
+ if ((BM_ELEM_API_FLAG_TEST(e_next, EDGE_NET)) &&
(bm_edge_flagged_radial_count(e_next) < 2))
{
BMVert *v_next;
@@ -279,7 +338,7 @@ walk_nofork:
v_next->e = e_next;
}
}
- }
+ } while ((e_next = BM_DISK_EDGE_NEXT(e_next, v)) != e_first);
#ifdef USE_FASTPATH_NOFORK
if (STACK_SIZE(edge_order) == 1) {
@@ -447,7 +506,6 @@ bool BM_face_split_edgenet(
}
if (f_new) {
- bool l_prev_is_boundary;
BLI_array_append(face_arr, f_new);
copy_v3_v3(f_new->no, f->no);
@@ -463,13 +521,10 @@ bool BM_face_split_edgenet(
/* add new verts to keep finding loops for
* (verts between boundary and manifold edges) */
l_iter = l_first = BM_FACE_FIRST_LOOP(f_new);
- l_prev_is_boundary = (bm_edge_flagged_radial_count(l_iter->prev->e) == 1);
do {
- bool l_iter_is_boundary = (bm_edge_flagged_radial_count(l_iter->e) == 1);
- if (l_prev_is_boundary != l_iter_is_boundary) {
+ if (bm_face_split_edgenet_find_loop_pair_exists(l_iter->v)) {
STACK_PUSH(vert_queue, l_iter->v);
}
- l_prev_is_boundary = l_iter_is_boundary;
} while ((l_iter = l_iter->next) != l_first);
}
}
diff --git a/source/blender/bmesh/operators/bmo_connect_concave.c b/source/blender/bmesh/operators/bmo_connect_concave.c
index 34f59aad4f1..8b9c60ada52 100644
--- a/source/blender/bmesh/operators/bmo_connect_concave.c
+++ b/source/blender/bmesh/operators/bmo_connect_concave.c
@@ -85,7 +85,7 @@ static bool bm_face_split_by_concave(
BMFace **faces_array = BLI_array_alloca(faces_array, faces_array_tot);
BMEdge **edges_array = BLI_array_alloca(edges_array, edges_array_tot);
const int quad_method = 0, ngon_method = 0; /* beauty */
- LinkNode *r_faces_double = NULL;
+ LinkNode *faces_double = NULL;
float normal[3];
BLI_assert(f_base->len > 3);
@@ -96,7 +96,7 @@ static bool bm_face_split_by_concave(
bm, f_base,
faces_array, &faces_array_tot,
edges_array, &edges_array_tot,
- &r_faces_double,
+ &faces_double,
quad_method, ngon_method, false,
pf_arena,
pf_heap, pf_ehash);
@@ -163,6 +163,13 @@ static bool bm_face_split_by_concave(
BLI_heap_clear(pf_heap, NULL);
BLI_edgehash_clear_ex(pf_ehash, NULL, BLI_POLYFILL_ALLOC_NGON_RESERVE);
+ while (faces_double) {
+ LinkNode *next = faces_double->next;
+ BM_face_kill(bm, faces_double->link);
+ MEM_freeN(faces_double);
+ faces_double = next;
+ }
+
return true;
}
diff --git a/source/blender/bmesh/operators/bmo_triangulate.c b/source/blender/bmesh/operators/bmo_triangulate.c
index 6fb09c76ea4..974446f09c0 100644
--- a/source/blender/bmesh/operators/bmo_triangulate.c
+++ b/source/blender/bmesh/operators/bmo_triangulate.c
@@ -244,29 +244,33 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
BMO_slot_buffer_flag_enable(bm, bmop.slots_out, "geom.out", BM_FACE | BM_EDGE, ELE_NEW);
BMO_op_finish(bm, &bmop);
}
-
- BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW);
if (use_dissolve) {
- BMO_ITER (e, &siter, op->slots_out, "geom.out", BM_EDGE) {
- if (LIKELY(e->l)) { /* in rare cases the edges face will have already been removed from the edge */
- BMFace *f_new;
- f_new = BM_faces_join_pair(bm, e->l->f,
- e->l->radial_next->f, e,
- false); /* join faces */
- if (f_new) {
- BMO_elem_flag_enable(bm, f_new, ELE_NEW);
- BM_edge_kill(bm, e);
+ BMEdge *e_next;
+ BMIter iter;
+
+ BM_ITER_MESH_MUTABLE (e, e_next, &iter, bm, BM_EDGES_OF_MESH) {
+ if (BMO_elem_flag_test(bm, e, ELE_NEW)) {
+ /* in rare cases the edges face will have already been removed from the edge */
+ if (LIKELY(e->l)) {
+ BMFace *f_new = BM_faces_join_pair(
+ bm, e->l->f,
+ e->l->radial_next->f, e,
+ false); /* join faces */
+ if (f_new) {
+ BMO_elem_flag_enable(bm, f_new, ELE_NEW);
+ BM_edge_kill(bm, e);
+ }
+ else {
+ BMO_error_clear(bm);
+ }
}
else {
- BMO_error_clear(bm);
+ BM_edge_kill(bm, e);
}
}
- else {
- BM_edge_kill(bm, e);
- }
}
-
- BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW);
}
+
+ BMO_slot_buffer_from_enabled_flag(bm, op, op->slots_out, "geom.out", BM_EDGE | BM_FACE, ELE_NEW);
}
diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
index 589b6d4752b..acb220bdf21 100644
--- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c
+++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c
@@ -34,6 +34,14 @@
#include "BLI_math.h"
#include "BLI_quadric.h"
#include "BLI_heap.h"
+#include "BLI_linklist.h"
+#include "BLI_alloca.h"
+#include "BLI_memarena.h"
+#include "BLI_edgehash.h"
+#include "BLI_polyfill2d.h"
+#include "BLI_polyfill2d_beautify.h"
+#include "BLI_stackdefines.h"
+
#include "BKE_customdata.h"
@@ -59,11 +67,10 @@
# define TOPOLOGY_FALLBACK_EPS 1e-12f
#endif
-/* these checks are for rare cases that we can't avoid since they are valid meshes still */
-#define USE_SAFETY_CHECKS
-
#define BOUNDARY_PRESERVE_WEIGHT 100.0f
-#define OPTIMIZE_EPS 0.01f /* FLT_EPSILON is too small, see [#33106] */
+/* Uses double precision, impacts behavior on near-flat surfaces,
+ * cane give issues with very small faces. 1e-2 is too big, see: T48154. */
+#define OPTIMIZE_EPS 1e-8
#define COST_INVALID FLT_MAX
typedef enum CD_UseFlag {
@@ -135,8 +142,8 @@ static void bm_decim_build_quadrics(BMesh *bm, Quadric *vquadrics)
}
-static void bm_decim_calc_target_co(
- BMEdge *e, float optimize_co[3],
+static void bm_decim_calc_target_co_db(
+ BMEdge *e, double optimize_co[3],
const Quadric *vquadrics)
{
/* compute an edge contraction target for edge 'e'
@@ -153,10 +160,22 @@ static void bm_decim_calc_target_co(
return; /* all is good */
}
else {
- mid_v3_v3v3(optimize_co, e->v1->co, e->v2->co);
+ optimize_co[0] = 0.5 * ((double)e->v1->co[0] + (double)e->v2->co[0]);
+ optimize_co[1] = 0.5 * ((double)e->v1->co[1] + (double)e->v2->co[1]);
+ optimize_co[2] = 0.5 * ((double)e->v1->co[2] + (double)e->v2->co[2]);
}
}
+static void bm_decim_calc_target_co_fl(
+ BMEdge *e, float optimize_co[3],
+ const Quadric *vquadrics)
+{
+ double optimize_co_db[3];
+ bm_decim_calc_target_co_db(e, optimize_co_db, vquadrics);
+ copy_v3fl_v3db(optimize_co, optimize_co_db);
+}
+
+
static bool bm_edge_collapse_is_degenerate_flip(BMEdge *e, const float optimize_co[3])
{
BMIter liter;
@@ -235,8 +254,6 @@ static void bm_decim_build_edge_cost_single(
const float *vweights, const float vweight_factor,
Heap *eheap, HeapNode **eheap_table)
{
- const Quadric *q1, *q2;
- float optimize_co[3];
float cost;
if (eheap_table[BM_elem_index_get(e)]) {
@@ -274,15 +291,17 @@ static void bm_decim_build_edge_cost_single(
}
/* end sanity check */
+ {
+ double optimize_co[3];
+ bm_decim_calc_target_co_db(e, optimize_co, vquadrics);
- bm_decim_calc_target_co(e, optimize_co, vquadrics);
-
- q1 = &vquadrics[BM_elem_index_get(e->v1)];
- q2 = &vquadrics[BM_elem_index_get(e->v2)];
-
- cost = (BLI_quadric_evaluate(q1, optimize_co) +
- BLI_quadric_evaluate(q2, optimize_co));
+ const Quadric *q1, *q2;
+ q1 = &vquadrics[BM_elem_index_get(e->v1)];
+ q2 = &vquadrics[BM_elem_index_get(e->v2)];
+ cost = (BLI_quadric_evaluate(q1, optimize_co) +
+ BLI_quadric_evaluate(q2, optimize_co));
+ }
/* note, 'cost' shouldn't be negative but happens sometimes with small values.
* this can cause faces that make up a flat surface to over-collapse, see [#37121] */
@@ -473,12 +492,58 @@ static int *bm_edge_symmetry_map(BMesh *bm, unsigned int symmetry_axis, float li
*
* \return true if any faces were triangulated.
*/
+static bool bm_face_triangulate(
+ BMesh *bm, BMFace *f_base, LinkNode **r_faces_double, int *r_edges_tri_tot,
-static bool bm_decim_triangulate_begin(BMesh *bm)
+ MemArena *pf_arena,
+ /* use for MOD_TRIANGULATE_NGON_BEAUTY only! */
+ struct Heap *pf_heap, struct EdgeHash *pf_ehash)
+{
+ const int f_base_len = f_base->len;
+ int faces_array_tot = f_base_len - 3;
+ int edges_array_tot = f_base_len - 3;
+ BMFace **faces_array = BLI_array_alloca(faces_array, faces_array_tot);
+ BMEdge **edges_array = BLI_array_alloca(edges_array, edges_array_tot);
+ const int quad_method = 0, ngon_method = 0; /* beauty */
+
+ bool has_cut = false;
+
+ const int f_index = BM_elem_index_get(f_base);
+
+ BM_face_triangulate(
+ bm, f_base,
+ faces_array, &faces_array_tot,
+ edges_array, &edges_array_tot,
+ r_faces_double,
+ quad_method, ngon_method, false,
+ pf_arena,
+ pf_heap, pf_ehash);
+
+ for (int i = 0; i < edges_array_tot; i++) {
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = edges_array[i]->l;
+ do {
+ BM_elem_index_set(l_iter, f_index); /* set_dirty */
+ has_cut = true;
+ } while ((l_iter = l_iter->radial_next) != l_first);
+ }
+
+ for (int i = 0; i < faces_array_tot; i++) {
+ BM_face_normal_update(faces_array[i]);
+ }
+
+ *r_edges_tri_tot += edges_array_tot;
+
+ return has_cut;
+}
+
+
+static bool bm_decim_triangulate_begin(BMesh *bm, int *r_edges_tri_tot)
{
BMIter iter;
BMFace *f;
- // bool has_quad; // could optimize this a little
+ bool has_quad = false;
+ bool has_ngon = false;
bool has_cut = false;
BLI_assert((bm->elem_index_dirty & BM_VERT) == 0);
@@ -493,98 +558,105 @@ static bool bm_decim_triangulate_begin(BMesh *bm)
BM_elem_index_set(l_iter, -1); /* set_dirty */
} while ((l_iter = l_iter->next) != l_first);
- // has_quad |= (f->len == 4)
+ has_quad |= (f->len > 3);
+ has_ngon |= (f->len > 4);
}
bm->elem_index_dirty |= BM_LOOP;
- /* adding new faces as we loop over faces
- * is normally best avoided, however in this case its not so bad because any face touched twice
- * will already be triangulated*/
- BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
- if (f->len == 4) {
- BMLoop *f_l[4];
- BMLoop *l_a, *l_b;
+ {
+ MemArena *pf_arena;
+ Heap *pf_heap;
+ EdgeHash *pf_ehash;
- {
- BMLoop *l_iter = BM_FACE_FIRST_LOOP(f);
+ LinkNode *faces_double = NULL;
- f_l[0] = l_iter; l_iter = l_iter->next;
- f_l[1] = l_iter; l_iter = l_iter->next;
- f_l[2] = l_iter; l_iter = l_iter->next;
- f_l[3] = l_iter;
- }
+ if (has_ngon) {
+ pf_arena = BLI_memarena_new(BLI_POLYFILL_ARENA_SIZE, __func__);
+ pf_heap = BLI_heap_new_ex(BLI_POLYFILL_ALLOC_NGON_RESERVE);
+ pf_ehash = BLI_edgehash_new_ex(__func__, BLI_POLYFILL_ALLOC_NGON_RESERVE);
+ }
+ else {
+ pf_arena = NULL;
+ pf_heap = NULL;
+ pf_ehash = NULL;
+ }
- if (len_squared_v3v3(f_l[0]->v->co, f_l[2]->v->co) <
- len_squared_v3v3(f_l[1]->v->co, f_l[3]->v->co))
- {
- l_a = f_l[0];
- l_b = f_l[2];
+ /* adding new faces as we loop over faces
+ * is normally best avoided, however in this case its not so bad because any face touched twice
+ * will already be triangulated*/
+ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+ if (f->len > 3) {
+ has_cut |= bm_face_triangulate(
+ bm, f, &faces_double,
+ r_edges_tri_tot,
+
+ pf_arena,
+ pf_heap, pf_ehash);
}
- else {
- l_a = f_l[1];
- l_b = f_l[3];
- }
-
-#ifdef USE_SAFETY_CHECKS
- if (BM_edge_exists(l_a->v, l_b->v) == NULL)
-#endif
- {
- BMFace *f_new;
- BMLoop *l_new;
-
- /* warning, NO_DOUBLE option here isn't handled as nice as it could be
- * - if there is a quad that has a free standing edge joining it along
- * where we want to split the face, there isnt a good way we can handle this.
- * currently that edge will get removed when joining the tris back into a quad. */
- f_new = BM_face_split(bm, f, l_a, l_b, &l_new, NULL, false);
-
- if (f_new) {
- /* the value of this doesn't matter, only that the 2 loops match and have unique values */
- const int f_index = BM_elem_index_get(f);
-
- /* since we just split theres only ever 2 loops */
- BLI_assert(BM_edge_is_manifold(l_new->e));
+ }
- BM_elem_index_set(l_new, f_index); /* set_dirty */
- BM_elem_index_set(l_new->radial_next, f_index); /* set_dirty */
+ while (faces_double) {
+ LinkNode *next = faces_double->next;
+ BM_face_kill(bm, faces_double->link);
+ MEM_freeN(faces_double);
+ faces_double = next;
+ }
- BM_face_normal_update(f);
- BM_face_normal_update(f_new);
+ BLI_memarena_free(pf_arena);
- has_cut = true;
- }
- }
+ if (has_ngon) {
+ BLI_heap_free(pf_heap, NULL);
+ BLI_edgehash_free(pf_ehash, NULL);
}
- }
- BLI_assert((bm->elem_index_dirty & BM_VERT) == 0);
+ BLI_assert((bm->elem_index_dirty & BM_VERT) == 0);
- if (has_cut) {
- /* now triangulation is done we need to correct index values */
- BM_mesh_elem_index_ensure(bm, BM_EDGE | BM_FACE);
+ if (has_cut) {
+ /* now triangulation is done we need to correct index values */
+ BM_mesh_elem_index_ensure(bm, BM_EDGE | BM_FACE);
+ }
}
return has_cut;
}
-static void bm_decim_triangulate_end(BMesh *bm)
+
+static void bm_decim_triangulate_end(BMesh *bm, const int edges_tri_tot)
{
/* decimation finished, now re-join */
BMIter iter;
- BMEdge *e, *e_next;
+ BMEdge *e;
+
+ /* we need to collect before merging for ngons since the loops indices will be lost */
+ BMEdge **edges_tri = MEM_mallocN(MIN2(edges_tri_tot, bm->totedge) * sizeof(*edges_tri), __func__);
+ STACK_DECLARE(edges_tri);
+
+ STACK_INIT(edges_tri, MIN2(edges_tri_tot, bm->totedge));
/* boundary edges */
- BM_ITER_MESH_MUTABLE (e, e_next, &iter, bm, BM_EDGES_OF_MESH) {
+ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
BMLoop *l_a, *l_b;
if (BM_edge_loop_pair(e, &l_a, &l_b)) {
const int l_a_index = BM_elem_index_get(l_a);
if (l_a_index != -1) {
const int l_b_index = BM_elem_index_get(l_b);
if (l_a_index == l_b_index) {
- if (LIKELY(l_a->f->len == 3 && l_b->f->len == 3)) {
- if (l_a->v != l_b->v) { /* if this is the case, faces have become flipped */
- /* check we are not making a degenerate quad */
+ if (l_a->v != l_b->v) { /* if this is the case, faces have become flipped */
+ /* check we are not making a degenerate quad */
+
+#define CAN_LOOP_MERGE(l) \
+ (BM_loop_is_manifold(l) && \
+ ((l)->v != (l)->radial_next->v) && \
+ (l_a_index == BM_elem_index_get(l)) && \
+ (l_a_index == BM_elem_index_get((l)->radial_next)))
+
+ if ((l_a->f->len == 3 && l_b->f->len == 3) &&
+ (!CAN_LOOP_MERGE(l_a->next)) &&
+ (!CAN_LOOP_MERGE(l_a->prev)) &&
+ (!CAN_LOOP_MERGE(l_b->next)) &&
+ (!CAN_LOOP_MERGE(l_b->prev)))
+ {
BMVert *vquad[4] = {
e->v1,
BM_vert_in_edge(e, l_a->next->v) ? l_a->prev->v : l_a->next->v,
@@ -597,17 +669,32 @@ static void bm_decim_triangulate_end(BMesh *bm)
BLI_assert(ELEM(vquad[2], vquad[1], vquad[0], vquad[3]) == false);
BLI_assert(ELEM(vquad[3], vquad[1], vquad[2], vquad[0]) == false);
- if (is_quad_convex_v3(vquad[0]->co, vquad[1]->co, vquad[2]->co, vquad[3]->co)) {
- /* highly unlikely to fail, but prevents possible double-ups */
- BMFace *f[2] = {l_a->f, l_b->f};
- BM_faces_join(bm, f, 2, true);
+ if (!is_quad_convex_v3(vquad[0]->co, vquad[1]->co, vquad[2]->co, vquad[3]->co)) {
+ continue;
}
}
+#undef CAN_LOOP_MERGE
+
+ /* highly unlikely to fail, but prevents possible double-ups */
+ STACK_PUSH(edges_tri, e);
}
}
}
}
}
+
+ for (int i = 0; i < STACK_SIZE(edges_tri); i++) {
+ BMLoop *l_a, *l_b;
+ e = edges_tri[i];
+ if (BM_edge_loop_pair(e, &l_a, &l_b)) {
+ BMFace *f_array[2] = {l_a->f, l_b->f};
+ BM_faces_join(bm, f_array, 2, false);
+ if (e->l == NULL) {
+ BM_edge_kill(bm, e);
+ }
+ }
+ }
+ MEM_freeN(edges_tri);
}
#endif /* USE_TRIANGULATE */
@@ -1084,7 +1171,7 @@ static bool bm_decim_edge_collapse(
return false;
}
- bm_decim_calc_target_co(e, optimize_co, vquadrics);
+ bm_decim_calc_target_co_fl(e, optimize_co, vquadrics);
/* check if this would result in an overlapping face */
if (UNLIKELY(bm_edge_collapse_is_degenerate_flip(e, optimize_co))) {
@@ -1220,7 +1307,6 @@ void BM_mesh_decimate_collapse(
Quadric *vquadrics; /* vert index aligned quadrics */
int tot_edge_orig;
int face_tot_target;
- bool use_triangulate;
CD_UseFlag customdata_flag = 0;
@@ -1230,8 +1316,11 @@ void BM_mesh_decimate_collapse(
#endif
#ifdef USE_TRIANGULATE
+ int edges_tri_tot = 0;
/* temp convert quads to triangles */
- use_triangulate = bm_decim_triangulate_begin(bm);
+ bool use_triangulate = bm_decim_triangulate_begin(bm, &edges_tri_tot);
+#else
+ UNUSED_VARS(do_triangulate);
#endif
@@ -1353,7 +1442,7 @@ void BM_mesh_decimate_collapse(
goto invalidate;
}
- bm_decim_calc_target_co(e, optimize_co, vquadrics);
+ bm_decim_calc_target_co_fl(e, optimize_co, vquadrics);
if (e_index_mirr == e_index) {
optimize_co[symmetry_axis] = 0.0f;
@@ -1416,7 +1505,7 @@ invalidate:
/* its possible we only had triangles, skip this step in that case */
if (LIKELY(use_triangulate)) {
/* temp convert quads to triangles */
- bm_decim_triangulate_end(bm);
+ bm_decim_triangulate_end(bm, edges_tri_tot);
}
}
#endif
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 6085b66a8b8..6ff6de33d56 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -172,8 +172,7 @@ void UVDataWrapper::getUV(int uv_index, float *uv)
}
}
-VCOLDataWrapper::VCOLDataWrapper(COLLADAFW::MeshVertexData& vdata) : mVData(&vdata){
-}
+VCOLDataWrapper::VCOLDataWrapper(COLLADAFW::MeshVertexData& vdata) : mVData(&vdata) {}
void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol)
{
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index 9f80c21a6a4..6169100d574 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/build/deg_builder.cc
+/** \file blender/depsgraph/intern/builder/deg_builder.cc
* \ingroup depsgraph
*/
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.h b/source/blender/depsgraph/intern/builder/deg_builder.h
index 7ecb4b20684..bdc030e3810 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder.h
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/build/deg_builder.h
+/** \file blender/depsgraph/intern/builder/deg_builder.h
* \ingroup depsgraph
*/
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 688d4ad435c..2bff86b9932 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/builder/deg_build_nodes.cc
+/** \file blender/depsgraph/intern/builder/deg_builder_nodes.cc
* \ingroup depsgraph
*
* Methods for constructing depsgraph's nodes
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
index 0e78df52ff8..f870a33fb68 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/builder/deg_builder_pchanmap.h
+/** \file blender/depsgraph/intern/builder/deg_builder_pchanmap.cc
* \ingroup depsgraph
*/
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index cd150b2b70e..d9b1722c064 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1181,7 +1181,8 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *ob,
OperationKey done_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE);
add_relation(solver_key, done_key, DEPSREL_TYPE_TRANSFORM, "IK Chain Result");
- } else {
+ }
+ else {
OperationKey final_transforms_key(&ob->id, DEPSNODE_TYPE_BONE, parchan->name, DEG_OPCODE_BONE_DONE);
add_relation(solver_key, final_transforms_key, DEPSREL_TYPE_TRANSFORM, "IK Solver Result");
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index c0bf82becda..ce6d2c961fd 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -42,7 +42,6 @@
#include "BLI_utildefines.h"
#include "BLI_string.h"
-#include "intern/depsgraph_types.h"
#include "intern/nodes/deg_node.h"
#include "intern/nodes/deg_node_operation.h"
@@ -292,7 +291,8 @@ struct DepsNodeHandle
/* Utilities for Builders ----------------------------------------------------- */
template <typename KeyType>
-OperationDepsNode *DepsgraphRelationBuilder::find_operation_node(const KeyType& key) {
+OperationDepsNode *DepsgraphRelationBuilder::find_operation_node(const KeyType& key)
+{
DepsNode *node = find_node(key);
return node != NULL ? node->get_exit_operation() : NULL;
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
index 0322ef7fa1d..76cd81f1b8f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
@@ -99,7 +99,7 @@ void deg_graph_transitive_reduction(Depsgraph *graph)
/* Remove redundant paths to the target. */
for (DepsNode::Relations::const_iterator it_rel = target->inlinks.begin();
it_rel != target->inlinks.end();
- )
+ )
{
DepsRelation *rel = *it_rel;
/* Increment in advance, so we can safely remove the relation. */
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cc b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
index 97208939e57..4ce91516c84 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cc
@@ -136,13 +136,15 @@ static const char *stringify_opcode(eDepsOperation_Code opcode)
return "UNKNOWN";
}
-DepsOperationStringifier::DepsOperationStringifier() {
+DepsOperationStringifier::DepsOperationStringifier()
+{
for (int i = 0; i < DEG_NUM_OPCODES; ++i) {
names_[i] = stringify_opcode((eDepsOperation_Code)i);
}
}
-const char *DepsOperationStringifier::operator[](eDepsOperation_Code opcode) {
+const char *DepsOperationStringifier::operator[](eDepsOperation_Code opcode)
+{
BLI_assert((opcode > 0) && (opcode < DEG_NUM_OPCODES));
if (opcode >= 0 && opcode < DEG_NUM_OPCODES) {
return names_[opcode];
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index 198cd349002..3024d625846 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/depsgraph_eval.cc
+/** \file blender/depsgraph/intern/eval/deg_eval.cc
* \ingroup depsgraph
*
* Evaluation engine entrypoints for Depsgraph Engine.
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.h b/source/blender/depsgraph/intern/eval/deg_eval.h
index 0d42f63433f..92f87b03803 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval.h
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/eval/deg_eval.cc
+/** \file blender/depsgraph/intern/eval/deg_eval.h
* \ingroup depsgraph
*
* Evaluation engine entrypoints for Depsgraph Engine.
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index fda665b0db4..9ba0b61a4f1 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/depsgraph_tag.cc
+/** \file blender/depsgraph/intern/eval/deg_eval_flush.cc
* \ingroup depsgraph
*
* Core routines for how the Depsgraph works.
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.h b/source/blender/depsgraph/intern/eval/deg_eval_flush.h
index 8912aebee7d..ecd3a5ec660 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.h
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.h
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/eval/deg_eval_flush.cc
+/** \file blender/depsgraph/intern/eval/deg_eval_flush.h
* \ingroup depsgraph
*
* Core routines for how the Depsgraph works.
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.cc b/source/blender/depsgraph/intern/nodes/deg_node.cc
index 78293f7f483..12d5ee00a63 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/depsnode.cc
+/** \file blender/depsgraph/intern/nodes/deg_node.cc
* \ingroup depsgraph
*/
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.h b/source/blender/depsgraph/intern/nodes/deg_node.h
index d79d3d2348d..416996052c9 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node.h
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/depsnode.h
+/** \file depsgraph/intern/nodes/deg_node.h
* \ingroup depsgraph
*/
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
index 8e74317cfa2..f5f45dde519 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/depsnode_component.cc
+/** \file blender/depsgraph/intern/nodes/deg_node_component.cc
* \ingroup depsgraph
*/
@@ -256,7 +256,7 @@ OperationDepsNode *ComponentDepsNode::get_entry_operation()
entry_operation = op_node;
return op_node;
}
- else if(operations.size() == 1) {
+ else if (operations.size() == 1) {
return operations[0];
}
return NULL;
@@ -279,7 +279,7 @@ OperationDepsNode *ComponentDepsNode::get_exit_operation()
exit_operation = op_node;
return op_node;
}
- else if(operations.size() == 1) {
+ else if (operations.size() == 1) {
return operations[0];
}
return NULL;
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index 6ff4345d28b..6f62d91cd79 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/depsnode_component.h
+/** \file blender/depsgraph/intern/nodes/deg_node_component.h
* \ingroup depsgraph
*/
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
index a9f9703bb3b..5847af29ac2 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/depsnode_operation.cc
+/** \file blender/depsgraph/intern/nodes/deg_node_operation.cc
* \ingroup depsgraph
*/
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.h b/source/blender/depsgraph/intern/nodes/deg_node_operation.h
index f03078fc3db..598393054db 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_operation.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.h
@@ -24,7 +24,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file blender/depsgraph/intern/depsnode_operation.h
+/** \file blender/depsgraph/intern/nodes/deg_node_operation.h
* \ingroup depsgraph
*/
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 85e32144bcd..79961eae79d 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1765,8 +1765,8 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active)
/* tab highlight (3d look) */
glColor3ubv(is_active ? theme_col_tab_highlight : theme_col_tab_highlight_inactive);
ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin, rct->ymin, rct->xmax, rct->ymax,
- tab_curve_radius, roundboxtype, true, false,
- is_active ? theme_col_back : theme_col_tab_inactive);
+ tab_curve_radius, roundboxtype, true, false,
+ is_active ? theme_col_back : theme_col_tab_inactive);
}
/* tab blackline */
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 3803221b496..b74c4b5f526 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -400,7 +400,7 @@ static int wm_collada_import_exec(bContext *C, wmOperator *op)
C, filename,
import_units,
find_chains,
- auto_connect,
+ auto_connect,
fix_orientation,
min_chain_length))
{
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 0fd56fbcc4e..a84b8d9dcc8 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -2283,7 +2283,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe
BMEdge **edge_array = BLI_array_alloca(edge_array, edge_array_len);
- /* point to knife edges we've created edges in, edge_array aligned */
+ /* point to knife edges we've created edges in, edge_array aligned */
KnifeEdge **kfe_array = BLI_array_alloca(kfe_array, edge_array_len);
BLI_assert(BLI_gset_size(kcd->edgenet.edge_visit) == 0);
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 9e71e646b1a..8868827a11f 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -463,7 +463,7 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u
if ((ulp->l_pair[0] && ulp->l_pair[1]) &&
(ulp->l_pair[0]->e != ulp->l_pair[1]->e))
{
- /* time has come to make a face! */
+ /* time has come to make a face! */
BMVert *v_shared = BM_edge_share_vert(ulp->l_pair[0]->e, ulp->l_pair[1]->e);
BMFace *f, *f_example = ulp->l_pair[0]->f;
BMLoop *l_iter;
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index b6a7d671882..7e05ab929ae 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -101,6 +101,10 @@ bool ED_wpaint_fill(struct VPaint *wp, struct Object *ob, float paintweight);
bool ED_vpaint_smooth(struct Object *ob);
+typedef void (*VPaintTransform_Callback)(const float col[3], const void *user_data, float r_col[3]);
+
+bool ED_vpaint_color_transform(struct Object *ob, VPaintTransform_Callback vpaint_tx_fn, const void *user_data);
+
void PAINT_OT_weight_paint_toggle(struct wmOperatorType *ot);
void PAINT_OT_weight_paint(struct wmOperatorType *ot);
void PAINT_OT_weight_set(struct wmOperatorType *ot);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index da7667c775e..bf923415f01 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -315,6 +315,241 @@ static void PAINT_OT_vertex_color_smooth(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+
+/** \name Vertex Color Transformations
+ * \{ */
+
+struct VPaintTx_BrightContrastData {
+ /* pre-calculated */
+ float gain;
+ float offset;
+};
+
+static void vpaint_tx_brightness_contrast(const float col[3], const void *user_data, float r_col[3])
+{
+ const struct VPaintTx_BrightContrastData *data = user_data;
+
+ for (int i = 0; i < 3; i++) {
+ r_col[i] = data->gain * col[i] + data->offset;
+ }
+}
+
+static int vertex_color_brightness_contrast_exec(bContext *C, wmOperator *op)
+{
+ Object *obact = CTX_data_active_object(C);
+
+ float gain, offset;
+ {
+ float brightness = RNA_float_get(op->ptr, "brightness");
+ float contrast = RNA_float_get(op->ptr, "contrast");
+ brightness /= 100.0f;
+ float delta = contrast / 200.0f;
+ gain = 1.0f - delta * 2.0f;
+ /*
+ * The algorithm is by Werner D. Streidt
+ * (http://visca.com/ffactory/archives/5-99/msg00021.html)
+ * Extracted of OpenCV demhist.c
+ */
+ if (contrast > 0) {
+ gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON);
+ offset = gain * (brightness - delta);
+ }
+ else {
+ delta *= -1;
+ offset = gain * (brightness + delta);
+ }
+ }
+
+ const struct VPaintTx_BrightContrastData user_data = {
+ .gain = gain,
+ .offset = offset,
+ };
+
+ if (ED_vpaint_color_transform(obact, vpaint_tx_brightness_contrast, &user_data)) {
+ ED_region_tag_redraw(CTX_wm_region(C));
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+static void PAINT_OT_vertex_color_brightness_contrast(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ /* identifiers */
+ ot->name = "Vertex Paint Bright/Contrast";
+ ot->idname = "PAINT_OT_vertex_color_brightness_contrast";
+ ot->description = "Adjust vertex color brightness/contrast";
+
+ /* api callbacks */
+ ot->exec = vertex_color_brightness_contrast_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* params */
+ const float min = -100, max = +100;
+ prop = RNA_def_float(ot->srna, "brightness", 0.0f, min, max, "Brightness", "", min, max);
+ prop = RNA_def_float(ot->srna, "contrast", 0.0f, min, max, "Contrast", "", min, max);
+ RNA_def_property_ui_range(prop, min, max, 1, 1);
+}
+
+struct VPaintTx_HueSatData {
+ float hue;
+ float sat;
+ float val;
+};
+
+static void vpaint_tx_hsv(const float col[3], const void *user_data, float r_col[3])
+{
+ const struct VPaintTx_HueSatData *data = user_data;
+ float hsv[3];
+ rgb_to_hsv_v(col, hsv);
+
+ hsv[0] += (data->hue - 0.5f);
+ if (hsv[0] > 1.0f) {
+ hsv[0] -= 1.0f;
+ }
+ else if (hsv[0] < 0.0f) {
+ hsv[0] += 1.0f;
+ }
+ hsv[1] *= data->sat;
+ hsv[2] *= data->val;
+
+ hsv_to_rgb_v(hsv, r_col);
+}
+
+static int vertex_color_hsv_exec(bContext *C, wmOperator *op)
+{
+ Object *obact = CTX_data_active_object(C);
+
+ const struct VPaintTx_HueSatData user_data = {
+ .hue = RNA_float_get(op->ptr, "h"),
+ .sat = RNA_float_get(op->ptr, "s"),
+ .val = RNA_float_get(op->ptr, "v"),
+ };
+
+ if (ED_vpaint_color_transform(obact, vpaint_tx_hsv, &user_data)) {
+ ED_region_tag_redraw(CTX_wm_region(C));
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+static void PAINT_OT_vertex_color_hsv(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Vertex Paint Hue Saturation Value";
+ ot->idname = "PAINT_OT_vertex_color_hsv";
+ ot->description = "Adjust vertex color HSV values";
+
+ /* api callbacks */
+ ot->exec = vertex_color_hsv_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* params */
+ RNA_def_float(ot->srna, "h", 0.5f, 0.0f, 1.0f, "Hue", "", 0.0f, 1.0f);
+ RNA_def_float(ot->srna, "s", 1.0f, 0.0f, 2.0f, "Saturation", "", 0.0f, 2.0f);
+ RNA_def_float(ot->srna, "v", 1.0f, 0.0f, 2.0f, "Value", "", 0.0f, 2.0f);
+}
+
+static void vpaint_tx_invert(const float col[3], const void *UNUSED(user_data), float r_col[3])
+{
+ for (int i = 0; i < 3; i++) {
+ r_col[i] = 1.0f - col[i];
+ }
+}
+
+static int vertex_color_invert_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *obact = CTX_data_active_object(C);
+
+ if (ED_vpaint_color_transform(obact, vpaint_tx_invert, NULL)) {
+ ED_region_tag_redraw(CTX_wm_region(C));
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+static void PAINT_OT_vertex_color_invert(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Vertex Paint Invert";
+ ot->idname = "PAINT_OT_vertex_color_invert";
+ ot->description = "Invert RGB values";
+
+ /* api callbacks */
+ ot->exec = vertex_color_invert_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
+struct VPaintTx_LevelsData {
+ float gain;
+ float offset;
+};
+
+static void vpaint_tx_levels(const float col[3], const void *user_data, float r_col[3])
+{
+ const struct VPaintTx_LevelsData *data = user_data;
+ for (int i = 0; i < 3; i++) {
+ r_col[i] = data->gain * (col[i] + data->offset);
+ }
+}
+
+static int vertex_color_levels_exec(bContext *C, wmOperator *op)
+{
+ Object *obact = CTX_data_active_object(C);
+
+ const struct VPaintTx_LevelsData user_data = {
+ .gain = RNA_float_get(op->ptr, "gain"),
+ .offset = RNA_float_get(op->ptr, "offset"),
+ };
+
+ if (ED_vpaint_color_transform(obact, vpaint_tx_levels, &user_data)) {
+ ED_region_tag_redraw(CTX_wm_region(C));
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
+}
+
+static void PAINT_OT_vertex_color_levels(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Vertex Paint Levels";
+ ot->idname = "PAINT_OT_vertex_color_levels";
+ ot->description = "Adjust levels of vertex colors";
+
+ /* api callbacks */
+ ot->exec = vertex_color_levels_exec;
+ ot->poll = vertex_paint_mode_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* params */
+ RNA_def_float(ot->srna, "offset", 0.0f, -1.0f, 1.0f, "Offset", "Value to add to colors", -1.0f, 1.0f);
+ RNA_def_float(ot->srna, "gain", 1.0f, 0.0f, FLT_MAX, "Gain", "Value to multiply colors by", 0.0f, 10.0f);
+}
+
+/** \} */
+
+
static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
{
Paint *paint = BKE_paint_get_active_from_context(C);
@@ -1112,6 +1347,11 @@ void ED_operatortypes_paint(void)
WM_operatortype_append(PAINT_OT_vertex_color_set);
WM_operatortype_append(PAINT_OT_vertex_color_smooth);
+ WM_operatortype_append(PAINT_OT_vertex_color_brightness_contrast);
+ WM_operatortype_append(PAINT_OT_vertex_color_hsv);
+ WM_operatortype_append(PAINT_OT_vertex_color_invert);
+ WM_operatortype_append(PAINT_OT_vertex_color_levels);
+
/* face-select */
WM_operatortype_append(PAINT_OT_face_select_linked);
WM_operatortype_append(PAINT_OT_face_select_linked_pick);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index fe80bba9f0b..5a6e0fe30ea 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -501,6 +501,51 @@ bool ED_vpaint_smooth(Object *ob)
return true;
}
+/**
+ * Apply callback to each vertex of the active vertex color layer.
+ */
+bool ED_vpaint_color_transform(
+ struct Object *ob,
+ VPaintTransform_Callback vpaint_tx_fn,
+ const void *user_data)
+{
+ Mesh *me;
+ const MPoly *mp;
+
+ if (((me = BKE_mesh_from_object(ob)) == NULL) ||
+ (me->mloopcol == NULL && (make_vertexcol(ob) == false)))
+ {
+ return false;
+ }
+
+ const bool do_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
+ mp = me->mpoly;
+
+ for (int i = 0; i < me->totpoly; i++, mp++) {
+ MLoopCol *lcol = &me->mloopcol[mp->loopstart];
+
+ if (do_face_sel && !(mp->flag & ME_FACE_SEL)) {
+ continue;
+ }
+
+ for (int j = 0; j < mp->totloop; j++, lcol++) {
+ float col[3];
+ rgb_uchar_to_float(col, &lcol->r);
+
+ vpaint_tx_fn(col, user_data, col);
+
+ rgb_float_to_uchar(&lcol->r, col);
+ }
+ }
+
+ /* remove stale me->mcol, will be added later */
+ BKE_mesh_tessface_clear(me);
+
+ DAG_id_tag_update(&me->id, 0);
+
+ return true;
+}
+
/* XXX: should be re-implemented as a vertex/weight paint 'color correct' operator */
#if 0
void vpaint_dogamma(Scene *scene)
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 8db5a8f9bd3..06caf930988 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2979,7 +2979,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event
if (ibuf->zbuf) {
info->z = ibuf->zbuf[y * ibuf->x + x];
info->zp = &info->z;
- if (ibuf->zbuf == (int*)ibuf->rect) {
+ if (ibuf->zbuf == (int *)ibuf->rect) {
info->colp = NULL;
}
}
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 794195e980e..37a40acd519 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1573,11 +1573,19 @@ static void outliner_draw_tree_element(
glDisable(GL_BLEND);
/* name */
- if (active == OL_DRAWSEL_NORMAL) UI_ThemeColor(TH_TEXT_HI);
- else if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f);
- else UI_ThemeColor(TH_TEXT);
-
- UI_fontstyle_draw_simple(fstyle, startx + offsx, *starty + 5 * ufac, te->name);
+ if ((tselem->flag & TSE_TEXTBUT) == 0) {
+ if (active == OL_DRAWSEL_NORMAL) {
+ UI_ThemeColor(TH_TEXT_HI);
+ }
+ else if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) {
+ UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f);
+ }
+ else {
+ UI_ThemeColor(TH_TEXT);
+ }
+
+ UI_fontstyle_draw_simple(fstyle, startx + offsx, *starty + 5 * ufac, te->name);
+ }
offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(fstyle, te->name));
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 46d45c897ad..9ebdfb6f21d 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -3743,7 +3743,7 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d,
}
if ((dt > OB_WIRE) && (v3d->flag2 & V3D_RENDER_SHADOW)) {
- /* pass */
+ /* pass */
}
else {
/* annoying but active faces is stored differently */
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 1f0ea4eaf9b..afbf791b33a 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -3616,7 +3616,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
dist_range[0] = v3d->near * 1.5f;
}
else { /* othographic */
- /* find the current window width and height */
+ /* find the current window width and height */
vb[0] = ar->winx;
vb[1] = ar->winy;
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index c6951c79609..f46608b7d5e 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -259,6 +259,37 @@ static bool view3d_ruler_pick(RulerInfo *ruler_info, const float mval[2],
}
}
+/**
+ * Ensure the 'snap_context' is only cached while dragging,
+ * needed since the user may toggle modes between tool use.
+ */
+static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
+{
+ if (state == ruler_info->state) {
+ return;
+ }
+
+ /* always remove */
+ if (ruler_info->snap_context) {
+ ED_transform_snap_object_context_destroy(ruler_info->snap_context);
+ ruler_info->snap_context = NULL;
+ }
+
+ if (state == RULER_STATE_NORMAL) {
+ /* pass */
+ }
+ else if (state == RULER_STATE_DRAG) {
+ ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
+ CTX_data_main(C), CTX_data_scene(C), SNAP_OBJECT_USE_CACHE,
+ ruler_info->ar, CTX_wm_view3d(C));
+ }
+ else {
+ BLI_assert(0);
+ }
+
+ ruler_info->state = state;
+}
+
#define RULER_ID "RulerData3D"
static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info)
{
@@ -640,7 +671,9 @@ static void view3d_ruler_free(RulerInfo *ruler_info)
{
BLI_freelistN(&ruler_info->items);
- ED_transform_snap_object_context_destroy(ruler_info->snap_context);
+ if (ruler_info->snap_context) {
+ ED_transform_snap_object_context_destroy(ruler_info->snap_context);
+ }
MEM_freeN(ruler_info);
}
@@ -757,10 +790,6 @@ static int view3d_ruler_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
op->customdata = ruler_info;
- ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
- CTX_data_main(C), CTX_data_scene(C), SNAP_OBJECT_USE_CACHE,
- ar, CTX_wm_view3d(C));
-
ruler_info->win = win;
ruler_info->sa = sa;
ruler_info->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ruler_info_draw_pixel,
@@ -818,7 +847,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
ruler_info->snap_flag &= ~RULER_SNAP_OK;
do_draw = true;
}
- ruler_info->state = RULER_STATE_NORMAL;
+ ruler_state_set(C, ruler_info, RULER_STATE_NORMAL);
}
}
else {
@@ -835,7 +864,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
RulerItem *ruler_item_prev = ruler_item_active_get(ruler_info);
RulerItem *ruler_item;
/* check if we want to drag an existing point or add a new one */
- ruler_info->state = RULER_STATE_DRAG;
+ ruler_state_set(C, ruler_info, RULER_STATE_DRAG);
ruler_item = ruler_item_add(ruler_info);
ruler_item_active_set(ruler_info, ruler_item);
@@ -877,7 +906,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
ruler_item_active_set(ruler_info, ruler_item_pick);
ruler_item_pick->flag |= RULERITEM_USE_ANGLE;
ruler_item_pick->co_index = 1;
- ruler_info->state = RULER_STATE_DRAG;
+ ruler_state_set(C, ruler_info, RULER_STATE_DRAG);
/* find the factor */
{
@@ -904,7 +933,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
else {
ruler_item_active_set(ruler_info, ruler_item_pick);
ruler_item_pick->co_index = co_index;
- ruler_info->state = RULER_STATE_DRAG;
+ ruler_state_set(C, ruler_info, RULER_STATE_DRAG);
/* store the initial depth */
copy_v3_v3(ruler_info->drag_start_co, ruler_item_pick->co[ruler_item_pick->co_index]);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 2fc116b64ba..5bd9cab4b28 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -591,15 +591,15 @@ static void initSnappingMode(TransInfo *t)
if (t->spacetype == SPACE_VIEW3D) {
if (t->tsnap.object_context == NULL) {
t->tsnap.object_context = ED_transform_snap_object_context_create_view3d(
- G.main, t->scene, SNAP_OBJECT_USE_CACHE,
- t->ar, t->view);
+ G.main, t->scene, SNAP_OBJECT_USE_CACHE,
+ t->ar, t->view);
ED_transform_snap_object_context_set_editmesh_callbacks(
- t->tsnap.object_context,
- (bool (*)(BMVert *, void *))BM_elem_cb_check_hflag_disabled,
- bm_edge_is_snap_target,
- bm_face_is_snap_target,
- SET_UINT_IN_POINTER((BM_ELEM_SELECT | BM_ELEM_HIDDEN)));
+ t->tsnap.object_context,
+ (bool (*)(BMVert *, void *))BM_elem_cb_check_hflag_disabled,
+ bm_edge_is_snap_target,
+ bm_face_is_snap_target,
+ SET_UINT_IN_POINTER((BM_ELEM_SELECT | BM_ELEM_HIDDEN)));
}
}
}
diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
index 3f29d9899e8..9efbe6b53be 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
+++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
@@ -111,7 +111,7 @@ static PyObject *FrsNoise_drand(BPy_FrsNoise * /*self*/, PyObject *args, PyObjec
PyErr_SetString(PyExc_TypeError, "optional argument 1 must be of type int");
return NULL;
}
- if (seed){
+ if (seed) {
RandGen::srand48(seed);
}
return PyFloat_FromDouble(RandGen::drand48());
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 9897201ade6..52177b756c5 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -90,7 +90,6 @@
#ifdef WITH_OPENSUBDIV
# include "BKE_subsurf.h"
-# include "BKE_DerivedMesh.h"
# include "BKE_editmesh.h"
# include "gpu_codegen.h"
diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h
index 68741578f27..52e40cbc098 100644
--- a/source/blender/makesdna/DNA_camera_types.h
+++ b/source/blender/makesdna/DNA_camera_types.h
@@ -85,8 +85,8 @@ typedef struct Camera {
char sensor_fit;
char pad[7];
- /* Stereo settings */
- struct CameraStereoSettings stereo;
+ /* Stereo settings */
+ struct CameraStereoSettings stereo;
} Camera;
/* **************** CAMERA ********************* */
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 4f19e819625..b8783da73ca 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -1148,7 +1148,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
/* test: is type a struct? */
if (spc[0] >= firststructtypenr && !ispointer(name)) {
- /* struct field type */
+ /* struct field type */
/* where does the old data start (is there one?) */
cpo = find_elem(oldsdna, type, name, spo, data, NULL);
if (cpo) {
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index c3c66625c84..1d3537dc9a0 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -196,7 +196,7 @@ static void rna_Scene_collada_export(
int use_ngons,
int use_object_instantiation,
- int use_blender_profile,
+ int use_blender_profile,
int sort_by_name,
int export_transformation_type,
int open_sim)
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index afccef46174..5b65a2bbfd4 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -57,6 +57,8 @@
#include "RE_shader_ext.h"
+#include "NOD_common.h"
+
#include "node_common.h"
#include "node_exec.h"
#include "node_util.h"
@@ -323,9 +325,12 @@ static void ntree_shader_link_builtin_group_normal(
"NodeSocketVector",
"Normal");
/* Need to update tree so all node instances nodes gets proper sockets. */
+ bNode *group_input_node = ntreeFindType(group_ntree, NODE_GROUP_INPUT);
+ node_group_verify(ntree, group_node, &group_ntree->id);
+ node_group_input_verify(group_ntree, group_input_node, &group_ntree->id);
ntreeUpdateTree(G.main, group_ntree);
/* Assumes sockets are always added at the end. */
- bNodeSocket *group_node_normal_socket = (bNodeSocket*)group_node->inputs.last;
+ bNodeSocket *group_node_normal_socket = group_node->inputs.last;
if (displacement_node == group_node) {
/* If displacement is coming from this node group we need to perform
* some internal re-linking in order to avoid cycles.
@@ -346,7 +351,6 @@ static void ntree_shader_link_builtin_group_normal(
/* This code is similar to ntree_shader_relink_displacement() */
bNode *group_displacement_node = group_displacement_link->fromnode;
bNodeSocket *group_displacement_socket = group_displacement_link->fromsock;
- nodeRemLink(group_ntree, group_displacement_link);
/* Create and link bump node.
* Can't re-use bump node from parent tree because it'll cause cycle.
*/
@@ -371,7 +375,6 @@ static void ntree_shader_link_builtin_group_normal(
nodeAddLink(ntree,
node_from, socket_from,
group_node, group_node_normal_socket);
- bNode *group_input_node = ntreeFindType(group_ntree, NODE_GROUP_INPUT);
BLI_assert(group_input_node != NULL);
bNodeSocket *group_input_node_normal_socket =
nodeFindSocket(group_input_node,
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
index 57014bdc476..48d1688c386 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -172,7 +172,8 @@ static int gpu_shader_normal_map(GPUMaterial *mat, bNode *node, bNodeExecData *U
break;
}
- } else {
+ }
+ else {
/* ************** BLENDER INTERNAL without world space shading flag ******* */
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index 14dc0d71b83..4751e60996d 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -1366,7 +1366,7 @@ static void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
/* When the parent is not OB_DYNAMIC and has no OB_COLLISION then it gets no bullet controller
* and cant be apart of the parents compound shape, same goes for OB_SOFT_BODY */
if (parent && (parent->gameflag & (OB_DYNAMIC | OB_COLLISION))) {
- if( (parent->gameflag & OB_CHILD)!=0 && (blenderobject->gameflag & OB_CHILD) && !(parent->gameflag & OB_SOFT_BODY)) {
+ if ((parent->gameflag & OB_CHILD)!=0 && (blenderobject->gameflag & OB_CHILD) && !(parent->gameflag & OB_SOFT_BODY)) {
isCompoundChild = true;
}
}
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 455fef0aceb..974dcbca95b 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -394,8 +394,9 @@ void BL_ConvertActuators(const char* maggiename,
soundActuatorType);
// if we made it mono, we have to free it
- if(sound && snd_sound && snd_sound != sound->playback_handle)
+ if (sound && snd_sound && snd_sound != sound->playback_handle) {
AUD_Sound_free(snd_sound);
+ }
tmpsoundact->SetName(bact->name);
baseact = tmpsoundact;
diff --git a/source/gameengine/Expressions/EXP_PyObjectPlus.h b/source/gameengine/Expressions/EXP_PyObjectPlus.h
index dd612a08494..32dc79cf6eb 100644
--- a/source/gameengine/Expressions/EXP_PyObjectPlus.h
+++ b/source/gameengine/Expressions/EXP_PyObjectPlus.h
@@ -73,7 +73,7 @@ typedef struct {
wlink.warn_done = true; \
wlink.link = NULL; \
\
- if(wlink_last) { \
+ if (wlink_last) { \
wlink_last->link= (void *)&(wlink); \
PyObjectPlus::SetDeprecationWarningLinkLast(&(wlink)); \
} \
@@ -195,7 +195,7 @@ public: \
PyObject *Py##method_name(PyObject *args, PyObject *kwds); \
static PyObject * \
sPy##method_name(PyObject *self, PyObject *args, PyObject *kwds) { \
- if(BGE_PROXY_REF(self)==NULL) { \
+ if (BGE_PROXY_REF(self)==NULL) { \
PyErr_SetString(PyExc_RuntimeError, \
#class_name "." #method_name "() - " \
BGE_PROXY_ERROR_MSG); \
@@ -208,7 +208,7 @@ public: \
PyObject *Py##method_name(PyObject *args); \
static PyObject* \
sPy##method_name(PyObject *self, PyObject *args) { \
- if(BGE_PROXY_REF(self)==NULL) { \
+ if (BGE_PROXY_REF(self)==NULL) { \
PyErr_SetString(PyExc_RuntimeError, \
#class_name "." #method_name "() - " \
BGE_PROXY_ERROR_MSG); return NULL; \
@@ -220,7 +220,7 @@ public: \
PyObject *Py##method_name(); \
static PyObject* \
sPy##method_name(PyObject *self) { \
- if(BGE_PROXY_REF(self)==NULL) { \
+ if (BGE_PROXY_REF(self)==NULL) { \
PyErr_SetString(PyExc_RuntimeError, \
#class_name "." #method_name "() - " \
BGE_PROXY_ERROR_MSG); return NULL; \
@@ -232,7 +232,7 @@ public: \
PyObject *Py##method_name(PyObject *value); \
static PyObject* \
sPy##method_name(PyObject *self, PyObject *value) { \
- if(BGE_PROXY_REF(self)==NULL) { \
+ if (BGE_PROXY_REF(self)==NULL) { \
PyErr_SetString(PyExc_RuntimeError, \
#class_name "." #method_name "(value) - " \
BGE_PROXY_ERROR_MSG); return NULL; \
@@ -244,7 +244,7 @@ public: \
PyObject *Py##method_name(PyObject *args, PyObject *kwds); \
static PyObject* \
sPy##method_name(PyObject *self, PyObject *args, PyObject *kwds) { \
- if(BGE_PROXY_REF(self)==NULL) { \
+ if (BGE_PROXY_REF(self)==NULL) { \
PyErr_SetString(PyExc_RuntimeError, \
#class_name "." #method_name "(...) - " \
BGE_PROXY_ERROR_MSG); return NULL; \
@@ -257,7 +257,7 @@ public: \
PyObject *Py##method_name(PyObject *args); \
static PyObject* \
sPy##method_name(PyObject *self, PyObject *args) { \
- if(BGE_PROXY_REF(self)==NULL) { \
+ if (BGE_PROXY_REF(self)==NULL) { \
PyErr_SetString(PyExc_RuntimeError, \
#class_name "." #method_name "(...) - " \
BGE_PROXY_ERROR_MSG); \
@@ -271,7 +271,7 @@ public: \
PyObject *Py##method_name(PyObject *value); \
static PyObject * \
sPy##method_name(PyObject *self, PyObject *value) { \
- if(BGE_PROXY_REF(self)==NULL) { \
+ if (BGE_PROXY_REF(self)==NULL) { \
PyErr_SetString(PyExc_RuntimeError, \
#class_name "." #method_name "(value) - " \
BGE_PROXY_ERROR_MSG); \
@@ -285,7 +285,7 @@ public: \
PyObject *Py##method_name(); \
static PyObject * \
sPy##method_name(PyObject *self) { \
- if(BGE_PROXY_REF(self)==NULL) { \
+ if (BGE_PROXY_REF(self)==NULL) { \
PyErr_SetString(PyExc_RuntimeError, \
#class_name "." #method_name "() - " \
BGE_PROXY_ERROR_MSG); \
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
index 82f3bee86b2..abb64cf1733 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
@@ -199,7 +199,7 @@ bool SCA_PropertySensor::CheckPropertyCondition()
const float max = m_checkpropmaxval.ToFloat();
float val;
- if (orgprop->GetValueType() == VALUE_STRING_TYPE){
+ if (orgprop->GetValueType() == VALUE_STRING_TYPE) {
val = orgprop->GetText().ToFloat();
}
else {
@@ -240,7 +240,7 @@ bool SCA_PropertySensor::CheckPropertyCondition()
const float ref = m_checkpropval.ToFloat();
float val;
- if (orgprop->GetValueType() == VALUE_STRING_TYPE){
+ if (orgprop->GetValueType() == VALUE_STRING_TYPE) {
val = orgprop->GetText().ToFloat();
}
else {
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 69c1af35bd9..3244400e1bd 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -142,7 +142,7 @@ KX_GameObject::~KX_GameObject()
}
// Unregister collision callbacks
// Do this before we start freeing physics information like m_pClient_info
- if (m_collisionCallbacks){
+ if (m_collisionCallbacks) {
UnregisterCollisionCallbacks();
Py_CLEAR(m_collisionCallbacks);
}
@@ -1564,7 +1564,7 @@ void KX_GameObject::UnregisterCollisionCallbacks()
PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment();
PHY_IPhysicsController* spc = GetPhysicsController();
// If we are the last to unregister on this physics controller
- if (pe->RemoveCollisionCallback(spc)){
+ if (pe->RemoveCollisionCallback(spc)) {
// If we are a sensor object
if (m_pClient_info->isSensor())
// Remove sensor body from physics world
@@ -1584,7 +1584,7 @@ void KX_GameObject::RegisterCollisionCallbacks()
PHY_IPhysicsEnvironment* pe = scene->GetPhysicsEnvironment();
PHY_IPhysicsController* spc = GetPhysicsController();
// If we are the first to register on this physics controller
- if (pe->RequestCollisionCallback(spc)){
+ if (pe->RequestCollisionCallback(spc)) {
// If we are a sensor object
if (m_pClient_info->isSensor())
// Add sensor body to physics world
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index 9ccf60b15ce..5f490747c2b 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -195,7 +195,7 @@ int KX_LightObject::pyattr_set_layer(void *self_v, const KX_PYATTRIBUTE_DEF *att
PyErr_Format(PyExc_TypeError, "expected an integer greater than 1 for attribute \"%s\"", attrdef->m_name);
return PY_SET_ATTR_FAIL;
}
- else if(layer > MAX_LIGHT_LAYERS) {
+ else if (layer > MAX_LIGHT_LAYERS) {
PyErr_Format(PyExc_TypeError, "expected an integer less than %i for attribute \"%s\"", MAX_LIGHT_LAYERS, attrdef->m_name);
return PY_SET_ATTR_FAIL;
}
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 47ba2c4343f..c0d99d16a4c 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -1785,7 +1785,7 @@ void KX_Scene::UpdateObjectLods(void)
for (int i = 0; i < this->GetObjectList()->GetCount(); i++) {
gameobj = (KX_GameObject*) GetObjectList()->GetValue(i);
- if (!gameobj->GetCulled()){
+ if (!gameobj->GetCulled()) {
gameobj->UpdateLod(cam_pos);
}
}
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index 1c42d65ae75..a27f37c0441 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -79,21 +79,18 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
KX_SoundActuator::~KX_SoundActuator()
{
- if(m_handle)
- {
+ if (m_handle) {
AUD_Handle_stop(m_handle);
}
- if(m_sound)
- {
+ if (m_sound) {
AUD_Sound_free(m_sound);
}
}
void KX_SoundActuator::play()
{
- if(m_handle)
- {
+ if (m_handle) {
AUD_Handle_stop(m_handle);
m_handle = NULL;
}
@@ -130,10 +127,8 @@ void KX_SoundActuator::play()
if(sound != m_sound)
AUD_Sound_free(sound);
- if (m_handle != NULL)
- {
- if (m_is3d)
- {
+ if (m_handle != NULL) {
+ if (m_is3d) {
AUD_Handle_setRelative(m_handle, true);
AUD_Handle_setVolumeMaximum(m_handle, m_3d.max_gain);
AUD_Handle_setVolumeMinimum(m_handle, m_3d.min_gain);
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index beccdfaad93..a8fa9b0815d 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -207,7 +207,7 @@ static MT_Matrix3x3 vectomat(MT_Vector3 vec, short axis, short upflag, short thr
vec = vec.safe_normalized_vec(z);
/* if 2D doesn't move the up vector */
- if (!threedimup){
+ if (!threedimup) {
vec.setValue(MT_Scalar(vec[0]), MT_Scalar(vec[1]), MT_Scalar(0.0f));
vec = (vec - z.dot(vec)*z).safe_normalized_vec(z);
}
diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
index c1af6de127e..ddae645802c 100644
--- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
@@ -89,17 +89,17 @@ PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args)
if (gameOb->GetSGNode())
{
MT_Vector3 attachPos,attachDir,attachAxle;
- if(!PyVecTo(pylistPos,attachPos)) {
+ if (!PyVecTo(pylistPos,attachPos)) {
PyErr_SetString(PyExc_AttributeError,
"addWheel(...) Unable to add wheel. attachPos must be a vector with 3 elements.");
return NULL;
}
- if(!PyVecTo(pylistDir,attachDir)) {
+ if (!PyVecTo(pylistDir,attachDir)) {
PyErr_SetString(PyExc_AttributeError,
"addWheel(...) Unable to add wheel. downDir must be a vector with 3 elements.");
return NULL;
}
- if(!PyVecTo(pylistAxleDir,attachAxle)) {
+ if (!PyVecTo(pylistAxleDir,attachAxle)) {
PyErr_SetString(PyExc_AttributeError,
"addWheel(...) Unable to add wheel. axleDir must be a vector with 3 elements.");
return NULL;
@@ -108,7 +108,7 @@ PyObject *KX_VehicleWrapper::PyAddWheel(PyObject *args)
//someone reverse some conventions inside Bullet (axle winding)
attachAxle = -attachAxle;
- if(wheelRadius<=0) {
+ if (wheelRadius <= 0) {
PyErr_SetString(PyExc_AttributeError,
"addWheel(...) Unable to add wheel. wheelRadius must be positive.");
return NULL;
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 58ea5e2e390..7138409a7e8 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -430,7 +430,7 @@ public:
// PHY_ICharacter interface
virtual void Jump() { jump(); }
- virtual bool OnGround(){ return onGround(); }
+ virtual bool OnGround() { return onGround(); }
virtual float GetGravity() { return getGravity(); }
virtual void SetGravity(float gravity) { setGravity(gravity); }
virtual unsigned char GetMaxJumps() { return getMaxJumps(); }
diff --git a/source/gameengine/Physics/common/PHY_ICharacter.h b/source/gameengine/Physics/common/PHY_ICharacter.h
index 81c567ef08a..1a924904b7d 100644
--- a/source/gameengine/Physics/common/PHY_ICharacter.h
+++ b/source/gameengine/Physics/common/PHY_ICharacter.h
@@ -15,7 +15,7 @@
class PHY_ICharacter
{
public:
- virtual ~PHY_ICharacter(){};
+ virtual ~PHY_ICharacter() {};
virtual void Jump()= 0;
virtual bool OnGround()= 0;
diff --git a/source/gameengine/Physics/common/PHY_IController.h b/source/gameengine/Physics/common/PHY_IController.h
index 284d77ca221..741fae8d2ad 100644
--- a/source/gameengine/Physics/common/PHY_IController.h
+++ b/source/gameengine/Physics/common/PHY_IController.h
@@ -48,7 +48,7 @@ class PHY_IPhysicsEnvironment;
class PHY_IController
{
public:
- virtual ~PHY_IController(){};
+ virtual ~PHY_IController() {};
// clientinfo for raycasts for example
virtual void* GetNewClientInfo()=0;
virtual void SetNewClientInfo(void* clientinfo)=0;
diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h
index d40b8da9451..e803d658713 100644
--- a/source/gameengine/Physics/common/PHY_IMotionState.h
+++ b/source/gameengine/Physics/common/PHY_IMotionState.h
@@ -44,7 +44,7 @@ class PHY_IMotionState
{
public:
- virtual ~PHY_IMotionState(){};
+ virtual ~PHY_IMotionState() {};
virtual void GetWorldPosition(float& posX,float& posY,float& posZ)=0;
virtual void GetWorldScaling(float& scaleX,float& scaleY,float& scaleZ)=0;
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h
index 62b163536dd..4c6e8c71ef7 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsController.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h
@@ -53,7 +53,7 @@ class PHY_IPhysicsController : public PHY_IController
{
public:
- virtual ~PHY_IPhysicsController(){};
+ virtual ~PHY_IPhysicsController() {};
/**
* SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
*/
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index 2997048805f..72ec7b1edd0 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -116,7 +116,7 @@ public:
class PHY_IPhysicsEnvironment
{
public:
- virtual ~PHY_IPhysicsEnvironment(){}
+ virtual ~PHY_IPhysicsEnvironment() {}
virtual void BeginFrame() = 0;
virtual void EndFrame() = 0;
/// Perform an integration step of duration 'timeStep'.
diff --git a/source/gameengine/Physics/common/PHY_IVehicle.h b/source/gameengine/Physics/common/PHY_IVehicle.h
index 1dcec69a335..7e4a49e923e 100644
--- a/source/gameengine/Physics/common/PHY_IVehicle.h
+++ b/source/gameengine/Physics/common/PHY_IVehicle.h
@@ -18,7 +18,7 @@ class PHY_IMotionState;
class PHY_IVehicle
{
public:
- virtual ~PHY_IVehicle(){};
+ virtual ~PHY_IVehicle() {};
virtual void AddWheel(
PHY_IMotionState* motionState,
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
index 34fdca23ee6..a5a3170ed77 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.h
@@ -45,7 +45,7 @@ public:
virtual void IndexPrimitives(RAS_MeshSlot& ms);
- virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;};
+ virtual void SetDrawingMode(int drawingmode) {m_drawingmode = drawingmode;};
protected:
int m_drawingmode;
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
index 9cb3449bed5..4c8e4a8931c 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVBO.h
@@ -76,7 +76,7 @@ public:
virtual void IndexPrimitives(RAS_MeshSlot& ms);
- virtual void SetDrawingMode(int drawingmode){m_drawingmode=drawingmode;};
+ virtual void SetDrawingMode(int drawingmode) {m_drawingmode = drawingmode;};
protected:
int m_drawingmode;