Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c25
-rw-r--r--source/blender/blenkernel/intern/action.c6
-rw-r--r--source/blender/blenkernel/intern/anim.c2
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c2
-rw-r--r--source/blender/blenkernel/intern/armature.c5
-rw-r--r--source/blender/blenkernel/intern/boids.c1
-rw-r--r--source/blender/blenkernel/intern/brush.c7
-rw-r--r--source/blender/blenkernel/intern/camera.c25
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c56
-rw-r--r--source/blender/blenkernel/intern/cloth.c1
-rw-r--r--source/blender/blenkernel/intern/colortools.c2
-rw-r--r--source/blender/blenkernel/intern/constraint.c63
-rw-r--r--source/blender/blenkernel/intern/context.c4
-rw-r--r--source/blender/blenkernel/intern/curve.c159
-rw-r--r--source/blender/blenkernel/intern/customdata.c87
-rw-r--r--source/blender/blenkernel/intern/deform.c22
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c7
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c41
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c422
-rw-r--r--source/blender/blenkernel/intern/editmesh.c1
-rw-r--r--source/blender/blenkernel/intern/effect.c11
-rw-r--r--source/blender/blenkernel/intern/fcurve.c21
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c14
-rw-r--r--source/blender/blenkernel/intern/font.c2
-rw-r--r--source/blender/blenkernel/intern/idprop.c10
-rw-r--r--source/blender/blenkernel/intern/image.c9
-rw-r--r--source/blender/blenkernel/intern/implicit.c4
-rw-r--r--source/blender/blenkernel/intern/ipo.c5
-rw-r--r--source/blender/blenkernel/intern/key.c33
-rw-r--r--source/blender/blenkernel/intern/lattice.c2
-rw-r--r--source/blender/blenkernel/intern/library.c6
-rw-r--r--source/blender/blenkernel/intern/linestyle.c538
-rw-r--r--source/blender/blenkernel/intern/mask.c2
-rw-r--r--source/blender/blenkernel/intern/mask_rasterize.c10
-rw-r--r--source/blender/blenkernel/intern/material.c69
-rw-r--r--source/blender/blenkernel/intern/mball.c37
-rw-r--r--source/blender/blenkernel/intern/mesh.c33
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c2
-rw-r--r--source/blender/blenkernel/intern/modifier.c2
-rw-r--r--source/blender/blenkernel/intern/modifiers_bmesh.c7
-rw-r--r--source/blender/blenkernel/intern/movieclip.c4
-rw-r--r--source/blender/blenkernel/intern/multires.c34
-rw-r--r--source/blender/blenkernel/intern/navmesh_conversion.c3
-rw-r--r--source/blender/blenkernel/intern/node.c219
-rw-r--r--source/blender/blenkernel/intern/object.c73
-rw-r--r--source/blender/blenkernel/intern/packedFile.c7
-rw-r--r--source/blender/blenkernel/intern/paint.c9
-rw-r--r--source/blender/blenkernel/intern/particle.c5
-rw-r--r--source/blender/blenkernel/intern/particle_system.c108
-rw-r--r--source/blender/blenkernel/intern/pbvh.c8
-rw-r--r--source/blender/blenkernel/intern/pbvh_bmesh.c7
-rw-r--r--source/blender/blenkernel/intern/pbvh_intern.h4
-rw-r--r--source/blender/blenkernel/intern/pointcache.c10
-rw-r--r--source/blender/blenkernel/intern/property.c6
-rw-r--r--source/blender/blenkernel/intern/rigidbody.c27
-rw-r--r--source/blender/blenkernel/intern/scene.c74
-rw-r--r--source/blender/blenkernel/intern/sequencer.c155
-rw-r--r--source/blender/blenkernel/intern/smoke.c6
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c35
-rw-r--r--source/blender/blenkernel/intern/text.c58
-rw-r--r--source/blender/blenkernel/intern/texture.c36
-rw-r--r--source/blender/blenkernel/intern/tracking.c68
-rw-r--r--source/blender/blenkernel/intern/unit.c15
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c35
64 files changed, 1657 insertions, 1104 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 6f86b0c3f88..3422f783eeb 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -46,7 +46,6 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
-#include "BLI_array.h"
#include "BLI_utildefines.h"
#include "BLI_linklist.h"
@@ -484,8 +483,6 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask)
Mesh tmp = *me;
int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly;
int did_shapekeys = 0;
- float *texloc, *texrot, *texsize;
- short *texflag;
CustomData_reset(&tmp.vdata);
CustomData_reset(&tmp.edata);
@@ -533,12 +530,7 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask)
}
/* copy texture space */
- if (BKE_object_obdata_texspace_get(ob, &texflag, &texloc, &texsize, &texrot)) {
- tmp.texflag = *texflag;
- copy_v3_v3(tmp.loc, texloc);
- copy_v3_v3(tmp.size, texsize);
- copy_v3_v3(tmp.rot, texrot);
- }
+ BKE_mesh_texspace_copy_from_object(&tmp, ob);
/* not all DerivedMeshes store their verts/edges/faces in CustomData, so
* we set them here in case they are missing */
@@ -655,21 +647,25 @@ void DM_add_poly_layer(DerivedMesh *dm, int type, int alloctype, void *layer)
void *DM_get_vert_data(DerivedMesh *dm, int index, int type)
{
+ BLI_assert(index >= 0 && index < dm->getNumVerts(dm));
return CustomData_get(&dm->vertData, index, type);
}
void *DM_get_edge_data(DerivedMesh *dm, int index, int type)
{
+ BLI_assert(index >= 0 && index < dm->getNumEdges(dm));
return CustomData_get(&dm->edgeData, index, type);
}
void *DM_get_tessface_data(DerivedMesh *dm, int index, int type)
{
+ BLI_assert(index >= 0 && index < dm->getNumTessFaces(dm));
return CustomData_get(&dm->faceData, index, type);
}
void *DM_get_poly_data(DerivedMesh *dm, int index, int type)
{
+ BLI_assert(index >= 0 && index < dm->getNumPolys(dm));
return CustomData_get(&dm->polyData, index, type);
}
@@ -1948,7 +1944,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
{
ModifierData *md, *previewmd = NULL;
float (*deformedVerts)[3] = NULL;
- CustomDataMask mask, previewmask = 0;
+ CustomDataMask mask, previewmask = 0, append_mask = 0;
DerivedMesh *dm, *orcodm = NULL;
int i, numVerts = 0, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
CDMaskLink *datamasks, *curr;
@@ -2083,6 +2079,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
}
/* set the DerivedMesh to only copy needed data */
+ mask |= append_mask;
mask = curr->mask; /* CD_MASK_ORCO may have been cleared above */
DM_set_only_copy(dm, mask | CD_MASK_ORIGINDEX);
@@ -2112,6 +2109,12 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D
}
}
+ /* In case of active preview modifier, make sure preview mask remains for following modifiers. */
+ if ((md == previewmd) && (do_mod_wmcol)) {
+ DM_update_weight_mcol(ob, dm, draw_flag, NULL, 0, NULL);
+ append_mask |= CD_MASK_PREVIEW_MLOOPCOL;
+ }
+
if (cage_r && i == cageIndex) {
if (dm && deformedVerts) {
*cage_r = CDDM_copy(dm);
@@ -3099,7 +3102,7 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm)
}
}
else {
- printf("%s: Error during creation polygon infos\n", __func__);
+ printf("Navmesh: Unable to generate valid Navmesh");
}
/* clean up */
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index fa85f6e4f86..70fbf2d39e8 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -930,9 +930,8 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
if (fmd->flag & FCM_LIMIT_XMAX) {
max = max_ff(max, fmd->rect.xmax);
}
+ break;
}
- break;
-
case FMODIFIER_TYPE_CYCLES: /* Cycles F-Modifier */
{
FMod_Cycles *fmd = (FMod_Cycles *)fcm->data;
@@ -941,9 +940,8 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_
min = MINAFRAMEF;
if (fmd->after_mode != FCM_EXTRAPOLATE_NONE)
max = MAXFRAMEF;
+ break;
}
- break;
-
/* TODO: function modifier may need some special limits */
default: /* all other standard modifiers are on the infinite range... */
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 9fea3d2e13f..ba680147201 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -1036,7 +1036,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */
if (me->edit_btmesh) {
- dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void *) &vdd);
+ dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void *) &vdd, DM_FOREACH_USE_NORMAL);
}
else {
for (a = 0; a < totvert; a++) {
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 001964087b8..4b05b0800a5 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -39,8 +39,8 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-#include "BLI_array.h"
#include "BLI_blenlib.h"
+#include "BLI_alloca.h"
#include "BLI_dynstr.h"
#include "BLF_translation.h"
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 8fae3586439..d37ccae3089 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1329,6 +1329,7 @@ void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], short use_compa
mat3_to_compatible_eulO(pchan->eul, pchan->eul, pchan->rotmode, mat);
else
mat3_to_eulO(pchan->eul, pchan->rotmode, mat);
+ break;
}
}
@@ -2100,8 +2101,8 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
/* z-axis scale */
scale = len_v3(pchan->pose_mat[2]);
mul_v3_fl(poseMat[2], scale);
+ break;
}
- break;
case CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC:
{
/* 'volume preservation' */
@@ -2123,8 +2124,8 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
/* apply the scaling */
mul_v3_fl(poseMat[0], scale);
mul_v3_fl(poseMat[2], scale);
+ break;
}
- break;
}
/* finally, multiply the x and z scaling by the radius of the curve too,
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index dfffb7c795e..cf761bf3dab 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -981,6 +981,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
rule = BLI_findlink(&state->rules, rand % BLI_countlist(&state->rules));
apply_boid_rule(bbd, rule, &val, pa, -1.0);
+ break;
}
case eBoidRulesetType_Average:
{
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 307dbc64847..70b5d90120d 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -539,7 +539,7 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
else if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
float rotation = -mtex->rot;
float point_2d[2] = {point[0], point[1]};
- float x = 0.0f, y = 0.0f; /* Quite warnings */
+ float x, y;
float co[3];
x = point_2d[0] - br->stencil_pos[0];
@@ -658,7 +658,7 @@ float BKE_brush_sample_masktex(const Scene *scene, Brush *br,
if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) {
float rotation = -mtex->rot;
float point_2d[2] = {point[0], point[1]};
- float x = 0.0f, y = 0.0f; /* Quite warnings */
+ float x, y;
float co[3];
x = point_2d[0] - br->mask_stencil_pos[0];
@@ -993,7 +993,8 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side)
co[2] = 0.0f;
/* This is copied from displace modifier code */
- hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres, NULL);
+ /* TODO(sergey): brush are always cacheing with CM enabled for now. */
+ hasrgb = multitex_ext(mtex->tex, co, NULL, NULL, 0, &texres, NULL, true);
/* if the texture gave an RGB value, we assume it didn't give a valid
* intensity, so calculate one (formula from do_material_tex).
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index a47cab7f236..e86561d687d 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -408,26 +408,33 @@ void BKE_camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, cons
}
else {
/* that way it's always visible - clipsta+0.1 */
- float fac;
- float half_sensor = 0.5f * ((camera->sensor_fit == CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x));
+ float fac, scale_x, scale_y;
+ float half_sensor = 0.5f * ((camera->sensor_fit == CAMERA_SENSOR_FIT_VERT) ?
+ (camera->sensor_y) : (camera->sensor_x));
- *r_drawsize = drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
if (do_clip) {
/* fixed depth, variable size (avoids exceeding clipping range) */
- depth = -(camera->clipsta + 0.1f);
- fac = depth / (camera->lens / (-half_sensor) * scale[2]);
+ /* r_drawsize shouldn't be used in this case, set to dummy value */
+ *r_drawsize = 1.0f;
+ depth = -(camera->clipsta + 0.1f) * scale[2];
+ fac = depth / (camera->lens / (-half_sensor));
+ scale_x = 1.0f;
+ scale_y = 1.0f;
}
else {
/* fixed size, variable depth (stays a reasonable size in the 3D view) */
+ *r_drawsize = drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2];
fac = *r_drawsize;
+ scale_x = scale[0];
+ scale_y = scale[1];
}
- facx = fac * r_asp[0] * scale[0];
- facy = fac * r_asp[1] * scale[1];
- r_shift[0] = camera->shiftx * fac * 2 * scale[0];
- r_shift[1] = camera->shifty * fac * 2 * scale[1];
+ facx = fac * r_asp[0] * scale_x;
+ facy = fac * r_asp[1] * scale_y;
+ r_shift[0] = camera->shiftx * fac * 2.0f * scale_x;
+ r_shift[1] = camera->shifty * fac * 2.0f * scale_y;
}
r_vec[0][0] = r_shift[0] + facx; r_vec[0][1] = r_shift[1] + facy; r_vec[0][2] = depth;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 7f6dc680a74..60f6bb0a736 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -40,7 +40,6 @@
#include "BLI_blenlib.h"
#include "BLI_edgehash.h"
#include "BLI_math.h"
-#include "BLI_array.h"
#include "BLI_smallhash.h"
#include "BLI_utildefines.h"
#include "BLI_scanfill.h"
@@ -1424,7 +1423,7 @@ static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
void (*setMaterial)(void *userData, int, void *attribs),
- int (*setFace)(void *userData, int index), void *userData)
+ bool (*setFace)(void *userData, int index), void *userData)
{
CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
GPUVertexAttribs gattribs;
@@ -1548,19 +1547,26 @@ static void cdDM_drawMappedEdges(DerivedMesh *dm, DMSetDrawOptions setDrawOption
static void cdDM_foreachMappedVert(
DerivedMesh *dm,
void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]),
- void *userData)
+ void *userData,
+ DMForeachFlag flag)
{
MVert *mv = CDDM_get_verts(dm);
- int i, orig, *index = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
+ int *index = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
+ int i;
- for (i = 0; i < dm->numVertData; i++, mv++) {
- if (index) {
- orig = *index++;
+ if (index) {
+ for (i = 0; i < dm->numVertData; i++, mv++) {
+ const short *no = (flag & DM_FOREACH_USE_NORMAL) ? mv->no : NULL;
+ const int orig = *index++;
if (orig == ORIGINDEX_NONE) continue;
- func(userData, orig, mv->co, NULL, mv->no);
+ func(userData, orig, mv->co, NULL, no);
+ }
+ }
+ else {
+ for (i = 0; i < dm->numVertData; i++, mv++) {
+ const short *no = (flag & DM_FOREACH_USE_NORMAL) ? mv->no : NULL;
+ func(userData, i, mv->co, NULL, no);
}
- else
- func(userData, i, mv->co, NULL, mv->no);
}
}
@@ -1588,47 +1594,37 @@ static void cdDM_foreachMappedEdge(
static void cdDM_foreachMappedFaceCenter(
DerivedMesh *dm,
void (*func)(void *userData, int index, const float cent[3], const float no[3]),
- void *userData)
+ void *userData,
+ DMForeachFlag flag)
{
CDDerivedMesh *cddm = (CDDerivedMesh *)dm;
MVert *mvert = cddm->mvert;
MPoly *mp;
MLoop *ml;
- int i, j, orig, *index;
+ int i, orig, *index;
index = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX);
mp = cddm->mpoly;
for (i = 0; i < dm->numPolyData; i++, mp++) {
float cent[3];
- float no[3];
+ float *no, _no[3];
if (index) {
orig = *index++;
if (orig == ORIGINDEX_NONE) continue;
}
- else
+ else {
orig = i;
+ }
ml = &cddm->mloop[mp->loopstart];
- cent[0] = cent[1] = cent[2] = 0.0f;
- for (j = 0; j < mp->totloop; j++, ml++) {
- add_v3_v3v3(cent, cent, mvert[ml->v].co);
- }
- mul_v3_fl(cent, 1.0f / (float)j);
+ BKE_mesh_calc_poly_center(mp, ml, mvert, cent);
- ml = &cddm->mloop[mp->loopstart];
- if (j > 3) {
- normal_quad_v3(no,
- mvert[(ml + 0)->v].co,
- mvert[(ml + 1)->v].co,
- mvert[(ml + 2)->v].co,
- mvert[(ml + 3)->v].co);
+ if (flag & DM_FOREACH_USE_NORMAL) {
+ BKE_mesh_calc_poly_normal(mp, ml, mvert, (no = _no));
}
else {
- normal_tri_v3(no,
- mvert[(ml + 0)->v].co,
- mvert[(ml + 1)->v].co,
- mvert[(ml + 2)->v].co);
+ no = NULL;
}
func(userData, orig, cent, no);
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index a7311d5efc7..05ffd4a6265 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -476,7 +476,6 @@ void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, Derived
BKE_ptcache_validate(cache, 0);
cache->last_exact= 0;
cache->flag &= ~PTCACHE_REDO_NEEDED;
- return;
}
// unused in the moment, calculated separately in implicit.c
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 9323531e5fe..7e878e86c1e 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -328,8 +328,8 @@ void curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
cuma->curve[i].x = i / ((float)cuma->totpoint - 1);
cuma->curve[i].y = 0.5;
}
+ break;
}
- break;
case CURVE_PRESET_ROUND:
cuma->curve[0].x = 0;
cuma->curve[0].y = 1;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 0cd13d528d5..b8d851d082a 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -132,8 +132,8 @@ bConstraintOb *BKE_constraints_make_evalob(Scene *scene, Object *ob, void *subda
unit_m4(cob->matrix);
copy_m4_m4(cob->startmat, cob->matrix);
+ break;
}
- break;
case CONSTRAINT_OBTYPE_BONE:
{
/* only set if we have valid bone, otherwise default */
@@ -158,9 +158,8 @@ bConstraintOb *BKE_constraints_make_evalob(Scene *scene, Object *ob, void *subda
unit_m4(cob->matrix);
copy_m4_m4(cob->startmat, cob->matrix);
+ break;
}
- break;
-
default: /* other types not yet handled */
unit_m4(cob->matrix);
unit_m4(cob->startmat);
@@ -195,8 +194,8 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob)
/* copy inverse of delta back to owner */
invert_m4_m4(cob->ob->constinv, delta);
}
+ break;
}
- break;
case CONSTRAINT_OBTYPE_BONE:
{
/* cob->ob or cob->pchan might not exist */
@@ -207,8 +206,8 @@ void BKE_constraints_clear_evalob(bConstraintOb *cob)
/* copy inverse of delta back to owner */
invert_m4_m4(cob->pchan->constinv, delta);
}
+ break;
}
- break;
}
/* free tempolary struct */
@@ -246,8 +245,8 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
/* call self with slightly different values */
BKE_constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
}
+ break;
}
- break;
case CONSTRAINT_SPACE_POSE: /* ---------- FROM POSESPACE ---------- */
{
/* pose to world */
@@ -267,8 +266,8 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
mul_m4_m4m4(mat, imat, mat);
}
}
+ break;
}
- break;
case CONSTRAINT_SPACE_LOCAL: /* ------------ FROM LOCALSPACE --------- */
{
/* local to pose - do inverse procedure that was done for pose to local */
@@ -282,8 +281,8 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
/* call self with slightly different values */
BKE_constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
}
+ break;
}
- break;
case CONSTRAINT_SPACE_PARLOCAL: /* -------------- FROM LOCAL WITH PARENT ---------- */
{
/* local + parent to pose */
@@ -297,8 +296,8 @@ void BKE_constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[
/* call self with slightly different values */
BKE_constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to);
}
+ break;
}
- break;
}
}
else {
@@ -2235,8 +2234,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the z axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
+ break;
}
- break;
case TRACK_Z: /* LOCK X TRACK Z */
{
/* Projection of Vector on the plane */
@@ -2249,8 +2248,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the z axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
+ break;
}
- break;
case TRACK_nY: /* LOCK X TRACK -Y */
{
/* Projection of Vector on the plane */
@@ -2264,8 +2263,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the z axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
+ break;
}
- break;
case TRACK_nZ: /* LOCK X TRACK -Z */
{
/* Projection of Vector on the plane */
@@ -2279,16 +2278,16 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the z axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
+ break;
}
- break;
default:
{
unit_m3(totmat);
+ break;
}
- break;
}
+ break;
}
- break;
case LOCK_Y: /* LOCK Y */
{
switch (data->trackflag) {
@@ -2304,8 +2303,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the z axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
+ break;
}
- break;
case TRACK_Z: /* LOCK Y TRACK Z */
{
/* Projection of Vector on the plane */
@@ -2318,8 +2317,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the z axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
+ break;
}
- break;
case TRACK_nX: /* LOCK Y TRACK -X */
{
/* Projection of Vector on the plane */
@@ -2333,8 +2332,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the z axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[2], totmat[0], totmat[1]);
+ break;
}
- break;
case TRACK_nZ: /* LOCK Y TRACK -Z */
{
/* Projection of Vector on the plane */
@@ -2348,16 +2347,16 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the z axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
+ break;
}
- break;
default:
{
unit_m3(totmat);
+ break;
}
- break;
}
+ break;
}
- break;
case LOCK_Z: /* LOCK Z */
{
switch (data->trackflag) {
@@ -2373,8 +2372,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the x axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
+ break;
}
- break;
case TRACK_Y: /* LOCK Z TRACK Y */
{
/* Projection of Vector on the plane */
@@ -2387,8 +2386,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the x axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
+ break;
}
- break;
case TRACK_nX: /* LOCK Z TRACK -X */
{
/* Projection of Vector on the plane */
@@ -2402,8 +2401,8 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the x axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[1], totmat[2], totmat[0]);
+ break;
}
- break;
case TRACK_nY: /* LOCK Z TRACK -Y */
{
/* Projection of Vector on the plane */
@@ -2417,21 +2416,21 @@ static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* the x axis gets mapped onto a third orthogonal vector */
cross_v3_v3v3(totmat[0], totmat[1], totmat[2]);
+ break;
}
- break;
default:
{
unit_m3(totmat);
+ break;
}
- break;
}
+ break;
}
- break;
default:
{
unit_m3(totmat);
+ break;
}
- break;
}
/* Block to keep matrix heading */
copy_m3_m4(tmpmat, cob->matrix);
@@ -2519,7 +2518,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t
/* only evaluate if there is a target */
if (VALID_CONS_TARGET(ct)) {
- float dvec[3], dist = 0.0f, sfac = 1.0f;
+ float dvec[3], dist, sfac = 1.0f;
short clamp_surf = 0;
/* calculate our current distance from the target */
@@ -4414,8 +4413,8 @@ static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const ch
con->ownspace = CONSTRAINT_SPACE_POSE;
con->flag |= CONSTRAINT_SPACEONCE;
}
+ break;
}
- break;
}
return con;
@@ -4640,8 +4639,8 @@ void BKE_get_constraint_target_matrix(Scene *scene, bConstraint *con, int index,
unit_m4(cob->matrix);
unit_m4(cob->startmat);
}
+ break;
}
- break;
case CONSTRAINT_OBTYPE_BONE: /* this may occur in some cases */
{
cob->ob = NULL; /* this might not work at all :/ */
@@ -4654,8 +4653,8 @@ void BKE_get_constraint_target_matrix(Scene *scene, bConstraint *con, int index,
unit_m4(cob->matrix);
unit_m4(cob->startmat);
}
+ break;
}
- break;
}
/* get targets - we only need the first one though (and there should only be one) */
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index bbf254cd7d1..622b4f6df5a 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -531,12 +531,12 @@ ListBase CTX_data_dir_get(const bContext *C)
return CTX_data_dir_get_ex(C, TRUE, FALSE, FALSE);
}
-int CTX_data_equals(const char *member, const char *str)
+bool CTX_data_equals(const char *member, const char *str)
{
return (strcmp(member, str) == 0);
}
-int CTX_data_dir(const char *member)
+bool CTX_data_dir(const char *member)
{
return member[0] == '\0';
}
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 3b9fbbb1c4d..43e5cc101a7 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -681,6 +681,143 @@ void BKE_nurb_bezierPoints_add(Nurb *nu, int number)
nu->pntsu += number;
}
+
+BezTriple *BKE_nurb_bezt_get_next(Nurb *nu, BezTriple *bezt)
+{
+ BezTriple *bezt_next;
+
+ BLI_assert(ARRAY_HAS_ITEM(bezt, nu->bezt, nu->pntsu));
+
+ if (bezt == &nu->bezt[nu->pntsu - 1]) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ bezt_next = nu->bezt;
+ }
+ else {
+ bezt_next = NULL;
+ }
+ }
+ else {
+ bezt_next = bezt + 1;
+ }
+
+ return bezt_next;
+}
+
+BPoint *BKE_nurb_bpoint_get_next(Nurb *nu, BPoint *bp)
+{
+ BPoint *bp_next;
+
+ BLI_assert(ARRAY_HAS_ITEM(bp, nu->bp, nu->pntsu));
+
+ if (bp == &nu->bp[nu->pntsu - 1]) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ bp_next = nu->bp;
+ }
+ else {
+ bp_next = NULL;
+ }
+ }
+ else {
+ bp_next = bp + 1;
+ }
+
+ return bp_next;
+}
+
+BezTriple *BKE_nurb_bezt_get_prev(Nurb *nu, BezTriple *bezt)
+{
+ BezTriple *bezt_prev;
+
+ BLI_assert(ARRAY_HAS_ITEM(bezt, nu->bezt, nu->pntsu));
+
+ if (bezt == nu->bezt) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ bezt_prev = &nu->bezt[nu->pntsu - 1];
+ }
+ else {
+ bezt_prev = NULL;
+ }
+ }
+ else {
+ bezt_prev = bezt - 1;
+ }
+
+ return bezt_prev;
+}
+
+BPoint *BKE_nurb_bpoint_get_prev(Nurb *nu, BPoint *bp)
+{
+ BPoint *bp_prev;
+
+ BLI_assert(ARRAY_HAS_ITEM(bp, nu->bp, nu->pntsu));
+
+ if (bp == nu->bp) {
+ if (nu->flagu & CU_NURB_CYCLIC) {
+ bp_prev = &nu->bp[nu->pntsu - 1];
+ }
+ else {
+ bp_prev = NULL;
+ }
+ }
+ else {
+ bp_prev = bp - 1;
+ }
+
+ return bp_prev;
+}
+
+void BKE_nurb_bezt_calc_normal(struct Nurb *UNUSED(nu), struct BezTriple *bezt, float r_normal[3])
+{
+ /* calculate the axis matrix from the spline */
+ float dir_prev[3], dir_next[3];
+
+ sub_v3_v3v3(dir_prev, bezt->vec[0], bezt->vec[1]);
+ sub_v3_v3v3(dir_next, bezt->vec[1], bezt->vec[2]);
+
+ normalize_v3(dir_prev);
+ normalize_v3(dir_next);
+
+ add_v3_v3v3(r_normal, dir_prev, dir_next);
+ normalize_v3(r_normal);
+}
+
+void BKE_nurb_bezt_calc_plane(struct Nurb *nu, struct BezTriple *bezt, float r_plane[3])
+{
+ float dir_prev[3], dir_next[3];
+
+ sub_v3_v3v3(dir_prev, bezt->vec[0], bezt->vec[1]);
+ sub_v3_v3v3(dir_next, bezt->vec[1], bezt->vec[2]);
+
+ normalize_v3(dir_prev);
+ normalize_v3(dir_next);
+
+ cross_v3_v3v3(r_plane, dir_prev, dir_next);
+ if (normalize_v3(r_plane) < FLT_EPSILON) {
+ BezTriple *bezt_prev = BKE_nurb_bezt_get_prev(nu, bezt);
+ BezTriple *bezt_next = BKE_nurb_bezt_get_next(nu, bezt);
+
+ if (bezt_prev) {
+ sub_v3_v3v3(dir_prev, bezt_prev->vec[1], bezt->vec[1]);
+ normalize_v3(dir_prev);
+ }
+ if (bezt_next) {
+ sub_v3_v3v3(dir_next, bezt->vec[1], bezt_next->vec[1]);
+ normalize_v3(dir_next);
+ }
+ cross_v3_v3v3(r_plane, dir_prev, dir_next);
+ }
+
+ /* matches with bones more closely */
+ {
+ float dir_mid[3], tvec[3];
+ add_v3_v3v3(dir_mid, dir_prev, dir_next);
+ cross_v3_v3v3(tvec, r_plane, dir_mid);
+ copy_v3_v3(r_plane, tvec);
+ }
+
+ normalize_v3(r_plane);
+}
+
/* ~~~~~~~~~~~~~~~~~~~~Non Uniform Rational B Spline calculations ~~~~~~~~~~~ */
@@ -2173,6 +2310,7 @@ static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode)
break;
default: /* CU_TWIST_Z_UP default, pre 2.49c */
make_bevel_list_3D_zup(bl);
+ break;
}
if (bl->poly == -1) /* check its not cyclic */
@@ -2323,6 +2461,7 @@ void BKE_curve_bevelList_make(Object *ob)
bl = MEM_callocN(sizeof(BevList) + 1 * sizeof(BevPoint), "makeBevelList1");
BLI_addtail(&(cu->bev), bl);
bl->nr = 0;
+ bl->charidx = nu->charidx;
}
else {
if (G.is_rendering && cu->resolu_ren != 0)
@@ -2335,10 +2474,10 @@ void BKE_curve_bevelList_make(Object *ob)
bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelList2");
BLI_addtail(&(cu->bev), bl);
- if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0;
- else bl->poly = -1;
+ bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
bl->nr = len;
bl->dupe_nr = 0;
+ bl->charidx = nu->charidx;
bevp = (BevPoint *)(bl + 1);
bp = nu->bp;
@@ -2358,8 +2497,8 @@ void BKE_curve_bevelList_make(Object *ob)
bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelBPoints");
BLI_addtail(&(cu->bev), bl);
- if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0;
- else bl->poly = -1;
+ bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
+ bl->charidx = nu->charidx;
bevp = (BevPoint *)(bl + 1);
a = nu->pntsu - 1;
@@ -2445,8 +2584,8 @@ void BKE_curve_bevelList_make(Object *ob)
BLI_addtail(&(cu->bev), bl);
bl->nr = len;
bl->dupe_nr = 0;
- if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0;
- else bl->poly = -1;
+ bl->poly = (nu->flagu & CU_NURB_CYCLIC) ? 0 : -1;
+ bl->charidx = nu->charidx;
bevp = (BevPoint *)(bl + 1);
BKE_nurb_makeCurve(nu, &bevp->vec[0],
@@ -2572,9 +2711,11 @@ void BKE_curve_bevelList_make(Object *ob)
bl = sd->bl; /* is bl a hole? */
sd1 = sortdata + (a - 1);
for (b = a - 1; b >= 0; b--, sd1--) { /* all polys to the left */
- if (bevelinside(sd1->bl, bl)) {
- bl->hole = 1 - sd1->bl->hole;
- break;
+ if (sd1->bl->charidx == bl->charidx) { /* for text, only check matching char */
+ if (bevelinside(sd1->bl, bl)) {
+ bl->hole = 1 - sd1->bl->hole;
+ break;
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index b6c608661cd..d69ec6a9597 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -158,7 +158,7 @@ static void layerCopy_mdeformvert(const void *source, void *dest,
MDeformVert *dvert = (MDeformVert *)((char *)dest + i * size);
if (dvert->totweight) {
- MDeformWeight *dw = MEM_callocN(dvert->totweight * sizeof(*dw),
+ MDeformWeight *dw = MEM_mallocN(dvert->totweight * sizeof(*dw),
"layerCopy_mdeformvert dw");
memcpy(dw, dvert->dw, dvert->totweight * sizeof(*dw));
@@ -218,9 +218,16 @@ static void layerFree_bmesh_elem_py_ptr(void *data, int count, int size)
static void layerInterp_mdeformvert(void **sources, const float *weights,
const float *UNUSED(sub_weights), int count, void *dest)
{
+ /* a single linked list of MDeformWeight's
+ * use this to avoid double allocs (which LinkNode would do) */
+ struct MDeformWeight_Link {
+ struct MDeformWeight_Link *next;
+ MDeformWeight dw;
+ };
+
MDeformVert *dvert = dest;
- LinkNode *dest_dw = NULL; /* a list of lists of MDeformWeight pointers */
- LinkNode *node;
+ struct MDeformWeight_Link *dest_dwlink = NULL;
+ struct MDeformWeight_Link *node;
int i, j, totweight;
if (count <= 0) return;
@@ -238,8 +245,8 @@ static void layerInterp_mdeformvert(void **sources, const float *weights,
if (weight == 0.0f)
continue;
- for (node = dest_dw; node; node = node->next) {
- MDeformWeight *tmp_dw = (MDeformWeight *)node->link;
+ for (node = dest_dwlink; node; node = node->next) {
+ MDeformWeight *tmp_dw = &node->dw;
if (tmp_dw->def_nr == dw->def_nr) {
tmp_dw->weight += weight;
@@ -249,11 +256,14 @@ static void layerInterp_mdeformvert(void **sources, const float *weights,
/* if this def_nr is not in the list, add it */
if (!node) {
- MDeformWeight *tmp_dw = MEM_callocN(sizeof(*tmp_dw),
- "layerInterp_mdeformvert tmp_dw");
- tmp_dw->def_nr = dw->def_nr;
- tmp_dw->weight = weight;
- BLI_linklist_prepend(&dest_dw, tmp_dw);
+ struct MDeformWeight_Link *tmp_dwlink = MEM_mallocN(sizeof(*tmp_dwlink), __func__);
+ tmp_dwlink->dw.def_nr = dw->def_nr;
+ tmp_dwlink->dw.weight = weight;
+
+ /* inline linklist */
+ tmp_dwlink->next = dest_dwlink;
+ dest_dwlink = tmp_dwlink;
+
totweight++;
}
}
@@ -262,20 +272,31 @@ static void layerInterp_mdeformvert(void **sources, const float *weights,
/* delay writing to the destination incase dest is in sources */
/* now we know how many unique deform weights there are, so realloc */
- if (dvert->dw) MEM_freeN(dvert->dw);
+ if (dvert->dw && (dvert->totweight == totweight)) {
+ /* pass (fastpath if we don't need to realloc) */
+ }
+ else {
+ if (dvert->dw) {
+ MEM_freeN(dvert->dw);
+ }
+
+ if (totweight) {
+ dvert->dw = MEM_mallocN(sizeof(*dvert->dw) * totweight, __func__);
+ }
+ }
if (totweight) {
- dvert->dw = MEM_callocN(sizeof(*dvert->dw) * totweight,
- "layerInterp_mdeformvert dvert->dw");
+ struct MDeformWeight_Link *node_next;
dvert->totweight = totweight;
-
- for (i = 0, node = dest_dw; node; node = node->next, ++i)
- dvert->dw[i] = *((MDeformWeight *)node->link);
+ for (i = 0, node = dest_dwlink; node; node = node_next, i++) {
+ node_next = node->next;
+ dvert->dw[i] = node->dw;
+ MEM_freeN(node);
+ }
}
- else
+ else {
memset(dvert, 0, sizeof(*dvert));
-
- BLI_linklist_free(dest_dw, MEM_freeN);
+ }
}
static void layerCopy_tface(const void *source, void *dest, int count)
@@ -1729,16 +1750,19 @@ bool CustomData_free_layer(CustomData *data, int type, int totelem, int index)
data->totlayer--;
/* if layer was last of type in array, set new active layer */
- if ((index >= data->totlayer) || (data->layers[index].type != type)) {
- i = CustomData_get_layer_index__notypemap(data, type);
-
- if (i >= 0)
- for (; i < data->totlayer && data->layers[i].type == type; i++) {
- data->layers[i].active--;
- data->layers[i].active_rnd--;
- data->layers[i].active_clone--;
- data->layers[i].active_mask--;
- }
+ i = CustomData_get_layer_index__notypemap(data, type);
+
+ if (i != -1) {
+ /* don't decrement zero index */
+ const int index_nonzero = index ? index : 1;
+ CustomDataLayer *layer;
+
+ for (layer = &data->layers[i]; i < data->totlayer && layer->type == type; i++, layer++) {
+ if (layer->active >= index_nonzero) layer->active--;
+ if (layer->active_rnd >= index_nonzero) layer->active_rnd--;
+ if (layer->active_clone >= index_nonzero) layer->active_clone--;
+ if (layer->active_mask >= index_nonzero) layer->active_mask--;
+ }
}
if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
@@ -2073,6 +2097,8 @@ void *CustomData_get(const CustomData *data, int index, int type)
int offset;
int layer_index;
+ BLI_assert(index >= 0);
+
/* get the layer index of the active layer of type */
layer_index = CustomData_get_active_layer_index(data, type);
if (layer_index < 0) return NULL;
@@ -2088,6 +2114,8 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n)
int layer_index;
int offset;
+ BLI_assert(index >= 0 && n >= 0);
+
/* get the layer index of the first layer of type */
layer_index = data->typemap[type];
if (layer_index < 0) return NULL;
@@ -2384,6 +2412,7 @@ bool CustomData_bmesh_merge(CustomData *source, CustomData *dest,
BLI_assert(!"invalid type given");
iter_type = BM_VERTS_OF_MESH;
totelem = bm->totvert;
+ break;
}
dest->pool = NULL;
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index b82e89d1af6..882085aa5db 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -51,6 +51,22 @@
#include "BKE_deform.h" /* own include */
+bDeformGroup *BKE_defgroup_new(Object *ob, const char *name)
+{
+ bDeformGroup *defgroup;
+
+ BLI_assert(OB_TYPE_SUPPORT_VGROUP(ob->type));
+
+ defgroup = MEM_callocN(sizeof(bDeformGroup), __func__);
+
+ BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
+
+ BLI_addtail(&ob->defbase, defgroup);
+ defgroup_unique_name(defgroup, ob);
+
+ return defgroup;
+}
+
void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
{
bDeformGroup *defgroup, *defgroupn;
@@ -521,7 +537,7 @@ void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char body[MAX_V
body[0] = suf[0] = '\0';
- for (i = len - 1; i > 1; i--) {
+ for (i = len; i > 0; i--) {
if (is_char_sep(string[i])) {
BLI_strncpy(body, string, i + 1);
BLI_strncpy(suf, string + i, (len + 1) - i);
@@ -529,7 +545,7 @@ void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char body[MAX_V
}
}
- BLI_strncpy(body, string, len);
+ memcpy(body, string, len + 1);
}
/* "a.b.c" -> ("a.", "b.c") */
@@ -719,7 +735,7 @@ MDeformWeight *defvert_verify_index(MDeformVert *dvert, const int defgroup)
if (dw_new)
return dw_new;
- dw_new = MEM_callocN(sizeof(MDeformWeight) * (dvert->totweight + 1), "deformWeight");
+ dw_new = MEM_mallocN(sizeof(MDeformWeight) * (dvert->totweight + 1), "deformWeight");
if (dvert->dw) {
memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight);
MEM_freeN(dvert->dw);
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 2206770dfbd..4ce06623bae 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -558,6 +558,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
}
else
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Parent");
+ break;
}
/* exception case: parent is duplivert */
if (ob->type == OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) {
@@ -619,8 +620,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
node2 = dag_get_node(dag, cam->dof_ob);
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Camera DoF");
}
+ break;
}
- break;
case OB_MBALL:
{
Object *mom = BKE_mball_basis_find(scene, ob);
@@ -629,8 +630,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
node2 = dag_get_node(dag, mom);
dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Metaball"); /* mom depends on children! */
}
+ break;
}
- break;
case OB_CURVE:
case OB_FONT:
{
@@ -650,8 +651,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Texture On Curve");
}
}
+ break;
}
- break;
}
/* material drivers */
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 9d1c0e40d54..1d5eaf3a1fc 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1449,12 +1449,13 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for
MEM_freeN(temp_data);
}
-static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
+static void dynamicPaint_setInitialColor(Scene *scene, DynamicPaintSurface *surface)
{
PaintSurfaceData *sData = surface->data;
PaintPoint *pPoint = (PaintPoint *)sData->type_data;
DerivedMesh *dm = surface->canvas->dm;
int i;
+ bool scene_color_manage = BKE_scene_check_color_management_enabled(scene);
if (surface->type != MOD_DPAINT_SURFACE_T_PAINT)
return;
@@ -1503,7 +1504,7 @@ static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
uv[0] = tface[i].uv[j][0] * 2.0f - 1.0f;
uv[1] = tface[i].uv[j][1] * 2.0f - 1.0f;
- multitex_ext_safe(tex, uv, &texres, pool);
+ multitex_ext_safe(tex, uv, &texres, pool, scene_color_manage);
if (texres.tin > pPoint[*vert].alpha) {
copy_v3_v3(pPoint[*vert].color, &texres.tr);
@@ -1536,8 +1537,8 @@ static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
/* remap to -1.0 to 1.0 */
uv_final[0] = uv_final[0] * 2.0f - 1.0f;
uv_final[1] = uv_final[1] * 2.0f - 1.0f;
-
- multitex_ext_safe(tex, uv_final, &texres, NULL);
+
+ multitex_ext_safe(tex, uv_final, &texres, NULL, scene_color_manage);
/* apply color */
copy_v3_v3(pPoint[i].color, &texres.tr);
@@ -1596,7 +1597,7 @@ static void dynamicPaint_setInitialColor(DynamicPaintSurface *surface)
}
/* clears surface data back to zero */
-void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
+void dynamicPaint_clearSurface(Scene *scene, DynamicPaintSurface *surface)
{
PaintSurfaceData *sData = surface->data;
if (sData && sData->type_data) {
@@ -1613,7 +1614,7 @@ void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
/* set initial color */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
- dynamicPaint_setInitialColor(surface);
+ dynamicPaint_setInitialColor(scene, surface);
if (sData->bData)
sData->bData->clear = 1;
@@ -1621,7 +1622,7 @@ void dynamicPaint_clearSurface(DynamicPaintSurface *surface)
}
/* completely (re)initializes surface (only for point cache types)*/
-int dynamicPaint_resetSurface(DynamicPaintSurface *surface)
+int dynamicPaint_resetSurface(Scene *scene, DynamicPaintSurface *surface)
{
int numOfPoints = dynamicPaint_surfaceNumOfPoints(surface);
/* free existing data */
@@ -1642,16 +1643,16 @@ int dynamicPaint_resetSurface(DynamicPaintSurface *surface)
/* set initial color */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT)
- dynamicPaint_setInitialColor(surface);
+ dynamicPaint_setInitialColor(scene, surface);
return 1;
}
/* make sure allocated surface size matches current requirements */
-static int dynamicPaint_checkSurfaceData(DynamicPaintSurface *surface)
+static int dynamicPaint_checkSurfaceData(Scene *scene, DynamicPaintSurface *surface)
{
if (!surface->data || ((dynamicPaint_surfaceNumOfPoints(surface) != surface->data->total_points))) {
- return dynamicPaint_resetSurface(surface);
+ return dynamicPaint_resetSurface(scene, surface);
}
return 1;
}
@@ -1698,7 +1699,7 @@ static DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd,
if (pmd->canvas && !(pmd->canvas->flags & MOD_DPAINT_BAKING)) {
DynamicPaintSurface *surface;
- int update_normals = 0;
+ bool update_normals = false;
/* loop through surfaces */
for (surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
@@ -1881,19 +1882,21 @@ static DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd,
normal_short_to_float_v3(normal, mvert[i].no);
madd_v3_v3fl(mvert[i].co, normal, wPoint[i].height);
}
- update_normals = 1;
+ update_normals = true;
}
/* displace */
if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE) {
dynamicPaint_applySurfaceDisplace(surface, result);
- update_normals = 1;
+ update_normals = true;
}
}
}
}
- result->dirty |= DM_DIRTY_NORMALS;
+ if (update_normals) {
+ result->dirty |= DM_DIRTY_NORMALS;
+ }
}
/* make a copy of dm to use as brush data */
if (pmd->brush) {
@@ -1940,6 +1943,7 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
/* loop through surfaces */
for (; surface; surface = surface->next) {
int current_frame = (int)scene->r.cfra;
+ bool no_surface_data;
/* free bake data if not required anymore */
surface_freeUnusedData(surface);
@@ -1949,12 +1953,13 @@ static void dynamicPaint_frameUpdate(DynamicPaintModifierData *pmd, Scene *scene
if (!(surface->flags & MOD_DPAINT_ACTIVE)) continue;
/* make sure surface is valid */
- if (!dynamicPaint_checkSurfaceData(surface)) continue;
+ no_surface_data = surface->data == NULL;
+ if (!dynamicPaint_checkSurfaceData(scene, surface)) continue;
/* limit frame range */
CLAMP(current_frame, surface->start_frame, surface->end_frame);
- if (current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
+ if (no_surface_data || current_frame != surface->current_frame || (int)scene->r.cfra == surface->start_frame) {
PointCache *cache = surface->pointcache;
PTCacheID pid;
surface->current_frame = current_frame;
@@ -2221,7 +2226,7 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
/*
* Create a surface for uv image sequence format
*/
-int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
+int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
{
/* Antialias jitter point relative coords */
float jitter5sample[10] = {0.0f, 0.0f,
@@ -2672,7 +2677,7 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface)
}
#endif
- dynamicPaint_setInitialColor(surface);
+ dynamicPaint_setInitialColor(scene, surface);
}
return (error == 0);
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index 87f7da8a1fb..feb18c3babe 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -69,11 +69,120 @@ typedef struct EditDerivedBMesh {
BMEditMesh *em;
- float (*vertexCos)[3];
- float (*vertexNos)[3];
- float (*polyNos)[3];
+ /** when set, \a vertexNos, polyNos are lazy initialized */
+ const float (*vertexCos)[3];
+
+ /** lazy initialize (when \a vertexCos is set) */
+ float const (*vertexNos)[3];
+ float const (*polyNos)[3];
+ /** also lazy init but dont depend on \a vertexCos */
+ const float (*polyCos)[3];
} EditDerivedBMesh;
+/* -------------------------------------------------------------------- */
+/* Lazy initialize datastructures */
+
+static void emDM_ensurePolyNormals(EditDerivedBMesh *bmdm);
+
+static void emDM_ensureVertNormals(EditDerivedBMesh *bmdm)
+{
+ if (bmdm->vertexCos && (bmdm->vertexNos == NULL)) {
+
+ BMesh *bm = bmdm->em->bm;
+ const float (*vertexCos)[3], (*polyNos)[3];
+ float (*vertexNos)[3];
+
+ BMFace *efa;
+ BMVert *eve;
+ BMIter fiter;
+ BMIter viter;
+ int i;
+
+ vertexCos = bmdm->vertexCos;
+ vertexNos = MEM_callocN(sizeof(*vertexNos) * bm->totvert, __func__);
+
+ /* calculate vertex normals from poly normals */
+ emDM_ensurePolyNormals(bmdm);
+
+ BM_mesh_elem_index_ensure(bm, BM_FACE);
+
+ vertexCos = bmdm->vertexCos;
+ polyNos = bmdm->polyNos;
+
+ BM_ITER_MESH_INDEX (eve, &viter, bm, BM_VERTS_OF_MESH, i) {
+ float *no = vertexNos[i];
+ BM_ITER_ELEM (efa, &fiter, eve, BM_FACES_OF_VERT) {
+ add_v3_v3(no, polyNos[BM_elem_index_get(efa)]);
+ }
+
+ /* following Mesh convention; we use vertex coordinate itself
+ * for normal in this case */
+ if (UNLIKELY(normalize_v3(no) == 0.0f)) {
+ normalize_v3_v3(no, vertexCos[i]);
+ }
+ }
+
+ bmdm->vertexNos = (const float (*)[3])vertexNos;
+ }
+}
+
+static void emDM_ensurePolyNormals(EditDerivedBMesh *bmdm)
+{
+ if (bmdm->vertexCos && (bmdm->polyNos == NULL)) {
+ BMesh *bm = bmdm->em->bm;
+ const float (*vertexCos)[3];
+ float (*polyNos)[3];
+
+ BMFace *efa;
+ BMIter fiter;
+ int i;
+
+ BM_mesh_elem_index_ensure(bm, BM_VERT);
+
+ polyNos = MEM_mallocN(sizeof(*polyNos) * bm->totface, __func__);
+
+ vertexCos = bmdm->vertexCos;
+
+ BM_ITER_MESH_INDEX (efa, &fiter, bm, BM_FACES_OF_MESH, i) {
+ BM_elem_index_set(efa, i); /* set_inline */
+ BM_face_calc_normal_vcos(bm, efa, polyNos[i], vertexCos);
+ }
+ bm->elem_index_dirty &= ~BM_FACE;
+
+ bmdm->polyNos = (const float (*)[3])polyNos;
+ }
+}
+
+static void emDM_ensurePolyCenters(EditDerivedBMesh *bmdm)
+{
+ if (bmdm->polyCos == NULL) {
+ BMesh *bm = bmdm->em->bm;
+ float (*polyCos)[3];
+
+ BMFace *efa;
+ BMIter fiter;
+ int i;
+
+ polyCos = MEM_mallocN(sizeof(*polyCos) * bm->totface, __func__);
+
+ if (bmdm->vertexCos) {
+ const float (*vertexCos)[3];
+ vertexCos = bmdm->vertexCos;
+
+ BM_ITER_MESH_INDEX (efa, &fiter, bm, BM_FACES_OF_MESH, i) {
+ BM_face_calc_center_mean_vcos(bm, efa, polyCos[i], vertexCos);
+ }
+ }
+ else {
+ BM_ITER_MESH_INDEX (efa, &fiter, bm, BM_FACES_OF_MESH, i) {
+ BM_face_calc_center_mean(efa, polyCos[i]);
+ }
+ }
+
+ bmdm->polyCos = (const float (*)[3])polyCos;
+ }
+}
+
static void emDM_calcNormals(DerivedMesh *dm)
{
/* Nothing to do: normals are already calculated and stored on the
@@ -86,9 +195,11 @@ static void emDM_recalcTessellation(DerivedMesh *UNUSED(dm))
/* do nothing */
}
-static void emDM_foreachMappedVert(DerivedMesh *dm,
- void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]),
- void *userData)
+static void emDM_foreachMappedVert(
+ DerivedMesh *dm,
+ void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]),
+ void *userData,
+ DMForeachFlag flag)
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMesh *bm = bmdm->em->bm;
@@ -97,13 +208,26 @@ static void emDM_foreachMappedVert(DerivedMesh *dm,
int i;
if (bmdm->vertexCos) {
+ const float (*vertexCos)[3] = bmdm->vertexCos;
+ const float (*vertexNos)[3];
+
+ if (flag & DM_FOREACH_USE_NORMAL) {
+ emDM_ensureVertNormals(bmdm);
+ vertexNos = bmdm->vertexNos;
+ }
+ else {
+ vertexNos = NULL;
+ }
+
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
- func(userData, i, bmdm->vertexCos[i], bmdm->vertexNos[i], NULL);
+ const float *no = (flag & DM_FOREACH_USE_NORMAL) ? vertexNos[i] : NULL;
+ func(userData, i, vertexCos[i], no, NULL);
}
}
else {
BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
- func(userData, i, eve->co, eve->no, NULL);
+ const float *no = (flag & DM_FOREACH_USE_NORMAL) ? eve->no : NULL;
+ func(userData, i, eve->co, no, NULL);
}
}
}
@@ -248,56 +372,42 @@ static void emDM_drawUVEdges(DerivedMesh *dm)
glEnd();
}
-static void emDM__calcFaceCent(BMFace *efa, float cent[3], float (*vertexCos)[3])
-{
- BMIter liter;
- BMLoop *l;
- int tot = 0;
-
- zero_v3(cent);
-
- /*simple (and stupid) median (average) based method :/ */
-
- if (vertexCos) {
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- add_v3_v3(cent, vertexCos[BM_elem_index_get(l->v)]);
- tot++;
- }
- }
- else {
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- add_v3_v3(cent, l->v->co);
- tot++;
- }
- }
-
- if (tot == 0) return;
- mul_v3_fl(cent, 1.0f / (float)tot);
-}
-
-static void emDM_foreachMappedFaceCenter(DerivedMesh *dm,
- void (*func)(void *userData, int index, const float co[3], const float no[3]),
- void *userData)
+static void emDM_foreachMappedFaceCenter(
+ DerivedMesh *dm,
+ void (*func)(void *userData, int index, const float co[3], const float no[3]),
+ void *userData,
+ DMForeachFlag flag)
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMesh *bm = bmdm->em->bm;
- float (*polyNos)[3] = NULL;
+ const float (*polyNos)[3];
+ const float (*polyCos)[3];
BMFace *efa;
BMIter iter;
- float cent[3];
int i;
- /* ensure for face center calculation */
- if (bmdm->vertexCos) {
- BM_mesh_elem_index_ensure(bm, BM_VERT);
- polyNos = bmdm->polyNos;
+ emDM_ensurePolyCenters(bmdm);
+ polyCos = bmdm->polyCos; /* always set */
- BLI_assert(polyNos != NULL);
+ if (flag & DM_FOREACH_USE_NORMAL) {
+ emDM_ensurePolyNormals(bmdm);
+ polyNos = bmdm->polyNos; /* maybe NULL */
+ }
+ else {
+ polyNos = NULL;
}
- BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
- emDM__calcFaceCent(efa, cent, bmdm->vertexCos);
- func(userData, i, cent, polyNos ? polyNos[i] : efa->no);
+ if (polyNos) {
+ BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
+ const float *no = polyNos[i];
+ func(userData, i, polyCos[i], no);
+ }
+ }
+ else {
+ BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
+ const float *no = (flag & DM_FOREACH_USE_NORMAL) ? efa->no : NULL;
+ func(userData, i, polyCos[i], no);
+ }
}
}
@@ -349,10 +459,20 @@ static void emDM_drawMappedFaces(DerivedMesh *dm,
if (bmdm->vertexCos) {
/* add direct access */
- float (*vertexCos)[3] = bmdm->vertexCos;
- float (*vertexNos)[3] = bmdm->vertexNos;
- float (*polyNos)[3] = bmdm->polyNos;
- // int *triPolyMap = bmdm->triPolyMap;
+ const float (*vertexCos)[3] = bmdm->vertexCos;
+ const float (*vertexNos)[3];
+ const float (*polyNos)[3];
+
+ if (skip_normals) {
+ vertexNos = NULL;
+ polyNos = NULL;
+ }
+ else {
+ emDM_ensureVertNormals(bmdm);
+ emDM_ensurePolyNormals(bmdm);
+ vertexNos = bmdm->vertexNos;
+ polyNos = bmdm->polyNos;
+ }
BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
@@ -561,9 +681,6 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
BMEditMesh *em = bmdm->em;
BMesh *bm = em->bm;
struct BMLoop *(*looptris)[3] = em->looptris;
- float (*vertexCos)[3] = bmdm->vertexCos;
- float (*vertexNos)[3] = bmdm->vertexNos;
- float (*polyNos)[3] = bmdm->polyNos;
BMFace *efa;
MLoopUV *luv[3], dummyluv = {{0}};
MLoopCol *lcol[3] = {NULL} /* , dummylcol = {0} */;
@@ -593,7 +710,17 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
BM_mesh_elem_index_ensure(bm, BM_VERT);
}
- if (vertexCos) {
+ if (bmdm->vertexCos) {
+ /* add direct access */
+ const float (*vertexCos)[3] = bmdm->vertexCos;
+ const float (*vertexNos)[3];
+ const float (*polyNos)[3];
+
+ emDM_ensureVertNormals(bmdm);
+ emDM_ensurePolyNormals(bmdm);
+ vertexNos = bmdm->vertexNos;
+ polyNos = bmdm->polyNos;
+
BM_mesh_elem_index_ensure(bm, BM_VERT);
for (i = 0; i < em->tottri; i++) {
@@ -791,9 +918,11 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
BMEditMesh *em = bmdm->em;
BMesh *bm = em->bm;
struct BMLoop *(*looptris)[3] = em->looptris;
- float (*vertexCos)[3] = bmdm->vertexCos;
- float (*vertexNos)[3] = bmdm->vertexNos;
- float (*polyNos)[3] = bmdm->polyNos;
+ /* add direct access */
+ const float (*vertexCos)[3] = bmdm->vertexCos;
+ const float (*vertexNos)[3];
+ const float (*polyNos)[3];
+
BMFace *efa;
DMVertexAttribs attribs;
GPUVertexAttribs gattribs;
@@ -805,6 +934,11 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm,
memset(&attribs, 0, sizeof(attribs));
+ emDM_ensureVertNormals(bmdm);
+ emDM_ensurePolyNormals(bmdm);
+ vertexNos = bmdm->vertexNos;
+ polyNos = bmdm->polyNos;
+
/* always use smooth shading even for flat faces, else vertex colors wont interpolate */
glShadeModel(GL_SMOOTH);
BM_mesh_elem_index_ensure(bm, BM_VERT | BM_FACE);
@@ -920,15 +1054,15 @@ static void emdm_pass_attrib_vertex_mat(DMVertexAttribs *attribs, BMLoop *loop,
static void emDM_drawMappedFacesMat(DerivedMesh *dm,
void (*setMaterial)(void *userData, int, void *attribs),
- int (*setFace)(void *userData, int index), void *userData)
+ bool (*setFace)(void *userData, int index), void *userData)
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMEditMesh *em = bmdm->em;
BMesh *bm = em->bm;
struct BMLoop *(*looptris)[3] = em->looptris;
- float (*vertexCos)[3] = bmdm->vertexCos;
- float (*vertexNos)[3] = bmdm->vertexNos;
- float (*polyNos)[3] = bmdm->polyNos;
+ const float (*vertexCos)[3] = bmdm->vertexCos;
+ const float (*vertexNos)[3];
+ const float (*polyNos)[3];
BMFace *efa;
DMVertexAttribs attribs = {{{0}}};
GPUVertexAttribs gattribs;
@@ -936,6 +1070,12 @@ static void emDM_drawMappedFacesMat(DerivedMesh *dm,
matnr = -1;
+ emDM_ensureVertNormals(bmdm);
+ emDM_ensurePolyNormals(bmdm);
+
+ vertexNos = bmdm->vertexNos;
+ polyNos = bmdm->polyNos;
+
/* always use smooth shading even for flat faces, else vertex colors wont interpolate */
glShadeModel(GL_SMOOTH);
@@ -1109,6 +1249,69 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *r_vert)
copy_v3_v3(r_vert->co, bmdm->vertexCos[index]);
}
+static void emDM_getVertCo(DerivedMesh *dm, int index, float r_co[3])
+{
+ EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+ BMesh *bm = bmdm->em->bm;
+
+ if (UNLIKELY(index < 0 || index >= bm->totvert)) {
+ BLI_assert(!"error in emDM_getVertCo");
+ return;
+ }
+
+ if (bmdm->vertexCos) {
+ copy_v3_v3(r_co, bmdm->vertexCos[index]);
+ }
+ else {
+ BMVert *ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */
+ // ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
+ copy_v3_v3(r_co, ev->co);
+ }
+}
+
+static void emDM_getVertNo(DerivedMesh *dm, int index, float r_no[3])
+{
+ EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+ BMesh *bm = bmdm->em->bm;
+
+ if (UNLIKELY(index < 0 || index >= bm->totvert)) {
+ BLI_assert(!"error in emDM_getVertNo");
+ return;
+ }
+
+
+ if (bmdm->vertexCos) {
+ emDM_ensureVertNormals(bmdm);
+ copy_v3_v3(r_no, bmdm->vertexNos[index]);
+ }
+ else {
+ BMVert *ev = bmdm->em->vert_index[index]; /* should be EDBM_vert_at_index() */
+ // ev = BM_vert_at_index(bm, index); /* warning, does list loop, _not_ ideal */
+ copy_v3_v3(r_no, ev->no);
+ }
+}
+
+static void emDM_getPolyNo(DerivedMesh *dm, int index, float r_no[3])
+{
+ EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
+ BMesh *bm = bmdm->em->bm;
+
+ if (UNLIKELY(index < 0 || index >= bm->totface)) {
+ BLI_assert(!"error in emDM_getPolyNo");
+ return;
+ }
+
+ if (bmdm->vertexCos) {
+ emDM_ensurePolyNormals(bmdm);
+ copy_v3_v3(r_no, bmdm->polyNos[index]);
+ }
+ else {
+ BMFace *efa = bmdm->em->face_index[index]; /* should be EDBM_vert_at_index() */
+ // efa = BM_face_at_index(bm, index); /* warning, does list loop, _not_ ideal */
+ copy_v3_v3(r_no, efa->no);
+ }
+}
+
static void emDM_getEdge(DerivedMesh *dm, int index, MEdge *r_edge)
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
@@ -1253,18 +1456,19 @@ static void emDM_copyLoopArray(DerivedMesh *dm, MLoop *r_loop)
{
EditDerivedBMesh *bmdm = (EditDerivedBMesh *)dm;
BMesh *bm = bmdm->em->bm;
- BMIter iter, liter;
+ BMIter iter;
BMFace *efa;
- BMLoop *l;
BM_mesh_elem_index_ensure(bm, BM_VERT | BM_EDGE);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
- BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
- r_loop->v = BM_elem_index_get(l->v);
- r_loop->e = BM_elem_index_get(l->e);
+ BMLoop *l_iter, *l_first;
+ l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
+ do {
+ r_loop->v = BM_elem_index_get(l_iter->v);
+ r_loop->e = BM_elem_index_get(l_iter->e);
r_loop++;
- }
+ } while ((l_iter = l_iter->next) != l_first);
}
}
@@ -1378,9 +1582,17 @@ static void emDM_release(DerivedMesh *dm)
if (DM_release(dm)) {
if (bmdm->vertexCos) {
- MEM_freeN(bmdm->vertexCos);
- MEM_freeN(bmdm->vertexNos);
- MEM_freeN(bmdm->polyNos);
+ MEM_freeN((void *)bmdm->vertexCos);
+ if (bmdm->vertexNos) {
+ MEM_freeN((void *)bmdm->vertexNos);
+ }
+ if (bmdm->polyNos) {
+ MEM_freeN((void *)bmdm->polyNos);
+ }
+ }
+
+ if (bmdm->polyCos) {
+ MEM_freeN((void *)bmdm->polyCos);
}
MEM_freeN(bmdm);
@@ -1456,6 +1668,9 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
bmdm->dm.getNumPolys = emDM_getNumPolys;
bmdm->dm.getVert = emDM_getVert;
+ bmdm->dm.getVertCo = emDM_getVertCo;
+ bmdm->dm.getVertNo = emDM_getVertNo;
+ bmdm->dm.getPolyNo = emDM_getPolyNo;
bmdm->dm.getEdge = emDM_getEdge;
bmdm->dm.getTessFace = emDM_getTessFace;
bmdm->dm.copyVertArray = emDM_copyVertArray;
@@ -1486,7 +1701,8 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
bmdm->dm.release = emDM_release;
- bmdm->vertexCos = vertexCos;
+ bmdm->vertexCos = (const float (*)[3])vertexCos;
+ bmdm->dm.deformedOnly = (vertexCos != NULL);
if (cd_dvert_offset != -1) {
BMIter iter;
@@ -1514,38 +1730,6 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
}
}
- if (vertexCos) {
- BMFace *efa;
- BMVert *eve;
- BMIter fiter;
- BMIter viter;
- int i;
-
- BM_mesh_elem_index_ensure(bm, BM_VERT);
-
- bmdm->vertexNos = MEM_callocN(sizeof(*bmdm->vertexNos) * bm->totvert, "bmdm_vno");
- bmdm->polyNos = MEM_mallocN(sizeof(*bmdm->polyNos) * bm->totface, "bmdm_pno");
-
- BM_ITER_MESH_INDEX (efa, &fiter, bm, BM_FACES_OF_MESH, i) {
- BM_elem_index_set(efa, i); /* set_inline */
- BM_face_normal_update_vcos(bm, efa, bmdm->polyNos[i], (float const (*)[3])vertexCos);
- }
- bm->elem_index_dirty &= ~BM_FACE;
-
- BM_ITER_MESH_INDEX (eve, &viter, bm, BM_VERTS_OF_MESH, i) {
- float *no = bmdm->vertexNos[i];
- BM_ITER_ELEM (efa, &fiter, eve, BM_FACES_OF_VERT) {
- add_v3_v3(no, bmdm->polyNos[BM_elem_index_get(efa)]);
- }
-
- /* following Mesh convention; we use vertex coordinate itself
- * for normal in this case */
- if (UNLIKELY(normalize_v3(no) == 0.0f)) {
- normalize_v3_v3(no, vertexCos[i]);
- }
- }
- }
-
return (DerivedMesh *)bmdm;
}
@@ -1813,7 +1997,7 @@ static void statvis_calc_intersect(
static void statvis_calc_distort(
BMEditMesh *em,
- const float (*vertexCos)[3],
+ const float (*vertexCos)[3], const float (*polyNos)[3],
/* values for calculating */
const float min, const float max,
/* result */
@@ -1822,7 +2006,7 @@ static void statvis_calc_distort(
BMIter iter;
BMesh *bm = em->bm;
BMFace *f;
- float f_no[3];
+ const float *f_no;
int index;
const float minmax_irange = 1.0f / (max - min);
@@ -1839,10 +2023,10 @@ static void statvis_calc_distort(
else {
BMLoop *l_iter, *l_first;
if (vertexCos) {
- BM_face_normal_update_vcos(bm, f, f_no, vertexCos);
+ f_no = polyNos[index];
}
else {
- copy_v3_v3(f_no, f->no);
+ f_no = f->no;
}
fac = 0.0f;
@@ -1942,7 +2126,7 @@ void BKE_editmesh_statvis_calc(BMEditMesh *em, DerivedMesh *dm,
{
BKE_editmesh_color_ensure(em, BM_FACE);
statvis_calc_overhang(
- em, bmdm ? (const float (*)[3])bmdm->polyNos : NULL,
+ em, bmdm ? bmdm->polyNos : NULL,
statvis->overhang_min / (float)M_PI,
statvis->overhang_max / (float)M_PI,
statvis->overhang_axis,
@@ -1954,7 +2138,7 @@ void BKE_editmesh_statvis_calc(BMEditMesh *em, DerivedMesh *dm,
const float scale = 1.0f / mat4_to_scale(em->ob->obmat);
BKE_editmesh_color_ensure(em, BM_FACE);
statvis_calc_thickness(
- em, bmdm ? (const float (*)[3])bmdm->vertexCos : NULL,
+ em, bmdm ? bmdm->vertexCos : NULL,
statvis->thickness_min * scale,
statvis->thickness_max * scale,
statvis->thickness_samples,
@@ -1965,15 +2149,19 @@ void BKE_editmesh_statvis_calc(BMEditMesh *em, DerivedMesh *dm,
{
BKE_editmesh_color_ensure(em, BM_FACE);
statvis_calc_intersect(
- em, bmdm ? (const float (*)[3])bmdm->vertexCos : NULL,
+ em, bmdm ? bmdm->vertexCos : NULL,
em->derivedFaceColor);
break;
}
case SCE_STATVIS_DISTORT:
{
BKE_editmesh_color_ensure(em, BM_FACE);
+
+ if (bmdm)
+ emDM_ensurePolyNormals(bmdm);
+
statvis_calc_distort(
- em, bmdm ? (const float (*)[3])bmdm->vertexCos : NULL,
+ em, bmdm ? bmdm->vertexCos : NULL, bmdm ? bmdm->polyNos : NULL,
statvis->distort_min,
statvis->distort_max,
em->derivedFaceColor);
@@ -1983,7 +2171,7 @@ void BKE_editmesh_statvis_calc(BMEditMesh *em, DerivedMesh *dm,
{
BKE_editmesh_color_ensure(em, BM_VERT);
statvis_calc_sharp(
- em, bmdm ? (const float (*)[3])bmdm->vertexCos : NULL,
+ em, bmdm ? bmdm->vertexCos : NULL,
statvis->sharp_min,
statvis->sharp_max,
/* in this case they are vertex colors */
@@ -2001,7 +2189,7 @@ void BKE_editmesh_statvis_calc(BMEditMesh *em, DerivedMesh *dm,
struct CageUserData {
int totvert;
float (*cos_cage)[3];
- BLI_bitmap visit_bitmap;
+ BLI_bitmap *visit_bitmap;
};
static void cage_mapped_verts_callback(void *userData, int index, const float co[3],
@@ -2018,7 +2206,7 @@ static void cage_mapped_verts_callback(void *userData, int index, const float co
float (*BKE_editmesh_vertexCos_get(BMEditMesh *em, Scene *scene, int *r_numVerts))[3]
{
DerivedMesh *cage, *final;
- BLI_bitmap visit_bitmap;
+ BLI_bitmap *visit_bitmap;
struct CageUserData data;
float (*cos_cage)[3];
@@ -2033,7 +2221,7 @@ float (*BKE_editmesh_vertexCos_get(BMEditMesh *em, Scene *scene, int *r_numVerts
data.cos_cage = cos_cage;
data.visit_bitmap = visit_bitmap;
- cage->foreachMappedVert(cage, cage_mapped_verts_callback, &data);
+ cage->foreachMappedVert(cage, cage_mapped_verts_callback, &data, DM_FOREACH_NOP);
MEM_freeN(visit_bitmap);
diff --git a/source/blender/blenkernel/intern/editmesh.c b/source/blender/blenkernel/intern/editmesh.c
index 3e925b73116..74cd8834d5d 100644
--- a/source/blender/blenkernel/intern/editmesh.c
+++ b/source/blender/blenkernel/intern/editmesh.c
@@ -373,5 +373,6 @@ void BKE_editmesh_color_ensure(BMEditMesh *em, const char htype)
break;
default:
BLI_assert(0);
+ break;
}
}
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 02d1621e408..0df8684044a 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -744,6 +744,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
float nabla = eff->pd->tex_nabla;
int hasrgb;
short mode = eff->pd->tex_mode;
+ bool scene_color_manage;
if (!eff->pd->tex)
return;
@@ -763,7 +764,9 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
mul_m4_v3(eff->ob->imat, tex_co);
}
- hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result, NULL);
+ scene_color_manage = BKE_scene_check_color_management_enabled(eff->scene);
+
+ hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result, NULL, scene_color_manage);
if (hasrgb && mode==PFIELD_TEX_RGB) {
force[0] = (0.5f - result->tr) * strength;
@@ -774,15 +777,15 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
strength/=nabla;
tex_co[0] += nabla;
- multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+1, NULL);
+ multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+1, NULL, scene_color_manage);
tex_co[0] -= nabla;
tex_co[1] += nabla;
- multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+2, NULL);
+ multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+2, NULL, scene_color_manage);
tex_co[1] -= nabla;
tex_co[2] += nabla;
- multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3, NULL);
+ multitex_ext(eff->pd->tex, tex_co, NULL, NULL, 0, result+3, NULL, scene_color_manage);
if (mode == PFIELD_TEX_GRAD || !hasrgb) { /* if we don't have rgb fall back to grad */
/* generate intensity if texture only has rgb value */
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index f763670baef..791c47cc551 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -577,7 +577,7 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo
}
/* Calculate the extents of F-Curve's keyframes */
-void calc_fcurve_range(FCurve *fcu, float *start, float *end,
+bool calc_fcurve_range(FCurve *fcu, float *start, float *end,
const short do_sel_only, const short do_min_length)
{
float min = 999999999.0f, max = -999999999.0f;
@@ -621,6 +621,8 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end,
*start = min;
*end = max;
+
+ return foundvert;
}
/* ----------------- Status Checks -------------------------- */
@@ -665,17 +667,16 @@ short fcurve_are_keyframes_usable(FCurve *fcu)
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
return 0;
+ break;
}
- break;
case FMODIFIER_TYPE_FN_GENERATOR:
{
FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data;
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
return 0;
+ break;
}
- break;
-
/* always harmful - cannot allow */
default:
return 0;
@@ -1697,13 +1698,12 @@ static float evaluate_driver(ChannelDriver *driver, const float evaltime)
/* perform operations on the total if appropriate */
if (driver->type == DRIVER_TYPE_AVERAGE)
- driver->curval = (value / (float)tot);
+ driver->curval = tot ? (value / (float)tot) : 0.0f;
else
driver->curval = value;
}
+ break;
}
- break;
-
case DRIVER_TYPE_MIN: /* smallest value */
case DRIVER_TYPE_MAX: /* largest value */
{
@@ -1736,9 +1736,8 @@ static float evaluate_driver(ChannelDriver *driver, const float evaltime)
/* store value in driver */
driver->curval = value;
+ break;
}
- break;
-
case DRIVER_TYPE_PYTHON: /* expression */
{
#ifdef WITH_PYTHON
@@ -1757,15 +1756,15 @@ static float evaluate_driver(ChannelDriver *driver, const float evaltime)
#else /* WITH_PYTHON*/
(void)evaltime;
#endif /* WITH_PYTHON*/
+ break;
}
- break;
-
default:
{
/* special 'hack' - just use stored value
* This is currently used as the mechanism which allows animated settings to be able
* to be changed via the UI.
*/
+ break;
}
}
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 19912a19d94..915c75a0e7f 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -213,9 +213,8 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c
/* cleanup */
if (powers)
MEM_freeN(powers);
+ break;
}
- break;
-
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial */
{
float value = 1.0f, *cp = NULL;
@@ -232,8 +231,8 @@ static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *c
else
*cvalue = value;
}
+ break;
}
- break;
}
}
@@ -316,8 +315,8 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float
}
else
fn = tan;
+ break;
}
- break;
case FCM_GENERATOR_FN_LN: /* natural log */
{
/* check that value is greater than 1? */
@@ -328,8 +327,8 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
*cvalue = 0.0f; /* no value possible here */
}
+ break;
}
- break;
case FCM_GENERATOR_FN_SQRT: /* square root */
{
/* no negative numbers */
@@ -340,11 +339,12 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float
if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0)
*cvalue = 0.0f; /* no value possible here */
}
+ break;
}
- break;
-
default:
printf("Invalid Function-Generator for F-Modifier - %d\n", data->type);
+ break;
+
}
/* execute function callback to set value if appropriate */
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index b3edeb67928..7c23438f93d 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -516,7 +516,7 @@ struct CharTrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int
/* Create unicode string */
utf8len = BLI_strlen_utf8(cu->str);
- mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
+ mem = MEM_mallocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem");
BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1);
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index f60823edcc8..f20506af967 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -445,6 +445,7 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src)
IDP_FreeProperty(tmp);
MEM_freeN(tmp);
+ break;
}
}
}
@@ -709,9 +710,7 @@ int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_s
if (prop1->len == prop2->len && prop1->subtype == prop2->subtype) {
return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype] * prop1->len);
}
- else {
- return 0;
- }
+ return 0;
case IDP_GROUP:
{
IDProperty *link1, *link2;
@@ -813,9 +812,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n
prop->len = prop->totallen = val->array.len;
break;
}
- else {
- return NULL;
- }
+ return NULL;
}
case IDP_STRING:
{
@@ -911,5 +908,6 @@ void IDP_UnlinkProperty(IDProperty *prop)
switch (prop->type) {
case IDP_ID:
IDP_UnlinkID(prop);
+ break;
}
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index e28b1bf3f69..1a444d497a0 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -633,7 +633,7 @@ Image *BKE_image_load_exists(const char *filepath)
for (ima = G.main->image.first; ima; ima = ima->id.next) {
if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) {
BLI_strncpy(strtest, ima->name, sizeof(ima->name));
- BLI_path_abs(strtest, G.main->name);
+ BLI_path_abs(strtest, ID_BLEND_PATH(G.main, &ima->id));
if (BLI_path_cmp(strtest, str) == 0) {
if (ima->anim == NULL || ima->id.us == 0) {
@@ -695,6 +695,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char
break;
default:
BKE_image_buf_fill_color(rect, rect_float, width, height, color);
+ break;
}
if (rect_float) {
@@ -1120,6 +1121,7 @@ char BKE_imtype_valid_channels(const char imtype)
case R_IMF_IMTYPE_QUICKTIME:
case R_IMF_IMTYPE_DPX:
chan_flag |= IMA_CHAN_FLAG_ALPHA;
+ break;
}
/* bw */
@@ -1131,6 +1133,7 @@ char BKE_imtype_valid_channels(const char imtype)
case R_IMF_IMTYPE_TIFF:
case R_IMF_IMTYPE_IRIS:
chan_flag |= IMA_CHAN_FLAG_BW;
+ break;
}
return chan_flag;
@@ -2718,8 +2721,8 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
re = RE_GetRender(iuser->scene->id.name);
channels = 4;
- layer = (iuser) ? iuser->layer : 0;
- pass = (iuser) ? iuser->pass : 0;
+ layer = iuser->layer;
+ pass = iuser->pass;
if (from_render) {
RE_AcquireResultImage(re, &rres);
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index b9064fe8ba3..c8e18bc3dee 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -48,6 +48,10 @@
#include "BKE_global.h"
+#ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wtype-limits"
+#endif
+
#ifdef _OPENMP
# define CLOTH_OPENMP_LIMIT 512
#endif
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 10226ade786..ecc4a03d255 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1174,9 +1174,8 @@ static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *i
{
/* just copy, as the new defines match the old ones... */
fcu->extend = icu->extrap;
+ break;
}
- break;
-
case IPO_CYCL: /* cyclic extrapolation */
case IPO_CYCLX: /* cyclic extrapolation + offset */
{
@@ -1191,8 +1190,8 @@ static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *i
data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC_OFFSET;
else
data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC;
+ break;
}
- break;
}
/* -------- */
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index e141b9dbabe..5b8929e49fe 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -533,7 +533,7 @@ static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char **
if (me->edit_btmesh && me->edit_btmesh->bm->totvert == kb->totelem) {
a = 0;
- co = MEM_callocN(sizeof(float) * 3 * me->edit_btmesh->bm->totvert, "key_block_get_data");
+ co = MEM_mallocN(sizeof(float) * 3 * me->edit_btmesh->bm->totvert, "key_block_get_data");
BM_ITER_MESH (eve, &iter, me->edit_btmesh->bm, BM_VERTS_OF_MESH) {
copy_v3_v3(co[a], eve->co);
@@ -1091,7 +1091,7 @@ static float *get_weights_array(Object *ob, char *vgroup)
float *weights;
int i;
- weights = MEM_callocN(totvert * sizeof(float), "weights");
+ weights = MEM_mallocN(totvert * sizeof(float), "weights");
if (em) {
const int cd_dvert_offset = CustomData_get_offset(&em->bm->vdata, CD_MDEFORMVERT);
@@ -1342,7 +1342,8 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
}
/* returns key coordinates (+ tilt) when key applied, NULL otherwise */
-float *BKE_key_evaluate_object(Scene *scene, Object *ob, int *r_totelem)
+float *BKE_key_evaluate_object_ex(Scene *scene, Object *ob, int *r_totelem,
+ float *arr, size_t arr_size)
{
Key *key = BKE_key_from_object(ob);
KeyBlock *actkb = BKE_keyblock_from_object(ob);
@@ -1386,7 +1387,16 @@ float *BKE_key_evaluate_object(Scene *scene, Object *ob, int *r_totelem)
return NULL;
/* allocate array */
- out = MEM_callocN(size, "BKE_key_evaluate_object out");
+ if (arr == NULL) {
+ out = MEM_callocN(size, "BKE_key_evaluate_object out");
+ }
+ else {
+ if (arr_size != size) {
+ return NULL;
+ }
+
+ out = (char *)arr;
+ }
/* prevent python from screwing this up? anyhoo, the from pointer could be dropped */
key->from = (ID *)ob->data;
@@ -1427,6 +1437,11 @@ float *BKE_key_evaluate_object(Scene *scene, Object *ob, int *r_totelem)
return (float *)out;
}
+float *BKE_key_evaluate_object(Scene *scene, Object *ob, int *r_totelem)
+{
+ return BKE_key_evaluate_object_ex(scene, ob, r_totelem, NULL, 0);
+}
+
Key *BKE_key_from_object(Object *ob)
{
if (ob == NULL) return NULL;
@@ -1607,7 +1622,7 @@ void BKE_key_convert_from_lattice(Lattice *lt, KeyBlock *kb)
if (kb->data) MEM_freeN(kb->data);
- kb->data = MEM_callocN(lt->key->elemsize * tot, "kb->data");
+ kb->data = MEM_mallocN(lt->key->elemsize * tot, "kb->data");
kb->totelem = tot;
bp = lt->def;
@@ -1649,7 +1664,7 @@ void BKE_key_convert_from_curve(Curve *cu, KeyBlock *kb, ListBase *nurb)
if (kb->data) MEM_freeN(kb->data);
- kb->data = MEM_callocN(cu->key->elemsize * tot, "kb->data");
+ kb->data = MEM_mallocN(cu->key->elemsize * tot, "kb->data");
kb->totelem = tot;
nu = nurb->first;
@@ -1747,7 +1762,7 @@ void BKE_key_convert_from_mesh(Mesh *me, KeyBlock *kb)
if (kb->data) MEM_freeN(kb->data);
- kb->data = MEM_callocN(me->key->elemsize * me->totvert, "kb->data");
+ kb->data = MEM_mallocN(me->key->elemsize * me->totvert, "kb->data");
kb->totelem = me->totvert;
mvert = me->mvert;
@@ -1797,7 +1812,7 @@ float (*BKE_key_convert_to_vertcos(Object *ob, KeyBlock *kb))[3]
if (tot == 0) return NULL;
- vertCos = MEM_callocN(tot * sizeof(*vertCos), "BKE_key_convert_to_vertcos vertCos");
+ vertCos = MEM_mallocN(tot * sizeof(*vertCos), "BKE_key_convert_to_vertcos vertCos");
/* Copy coords to array */
co = (float *)vertCos;
@@ -1880,7 +1895,7 @@ void BKE_key_convert_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos)[3])
return;
}
- fp = kb->data = MEM_callocN(tot * elemsize, "BKE_key_convert_to_vertcos vertCos");
+ fp = kb->data = MEM_mallocN(tot * elemsize, "BKE_key_convert_to_vertcos vertCos");
/* Copy coords to keyblock */
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index c9b904e76ac..a4892253c63 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -681,7 +681,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target,
* we want either a Mesh with no derived data, or derived data with
* deformverts
*/
- if (target && target->type == OB_MESH) {
+ if (target->type == OB_MESH) {
/* if there's derived data without deformverts, don't use vgroups */
if (dm) {
use_vgroups = (dm->getVertData(dm, 0, CD_MDEFORMVERT) != NULL);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 5b5d4f3c318..7eb4a3a2a8d 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1057,6 +1057,7 @@ void free_main(Main *mainvar)
case 32: BKE_libblock_free(lb, id); break;
default:
BLI_assert(0);
+ break;
}
#endif
}
@@ -1573,7 +1574,10 @@ void BKE_library_make_local(Main *bmain, Library *lib, bool untagged_only)
{
if (lib == NULL || id->lib == lib) {
if (id->lib) {
- id_make_local(id, false);
+ /* for Make Local > All we should be calling id_make_local,
+ * but doing that breaks append (see #36003 and #36006), we
+ * we should make it work with all datablocks and id.us==0 */
+ id_clear_lib_data(bmain, id); /* sets 'id->flag' */
/* why sort alphabetically here but not in
* id_clear_lib_data() ? - campbell */
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index f47f86744af..497554be113 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -183,7 +183,7 @@ static LineStyleModifier *new_modifier(int type, size_t size)
m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
m->type = type;
- strcpy(m->name, modifier_name[type]);
+ BLI_strncpy(m->name, modifier_name[type], sizeof(m->name));
m->influence = 1.0f;
m->flags = LS_MODIFIER_ENABLED | LS_MODIFIER_EXPANDED;
@@ -201,20 +201,20 @@ static LineStyleModifier *alloc_color_modifier(int type)
size_t size;
switch (type) {
- case LS_MODIFIER_ALONG_STROKE:
- size = sizeof(LineStyleColorModifier_AlongStroke);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- size = sizeof(LineStyleColorModifier_DistanceFromCamera);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- size = sizeof(LineStyleColorModifier_DistanceFromObject);
- break;
- case LS_MODIFIER_MATERIAL:
- size = sizeof(LineStyleColorModifier_Material);
- break;
- default:
- return NULL; /* unknown modifier type */
+ case LS_MODIFIER_ALONG_STROKE:
+ size = sizeof(LineStyleColorModifier_AlongStroke);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ size = sizeof(LineStyleColorModifier_DistanceFromCamera);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ size = sizeof(LineStyleColorModifier_DistanceFromObject);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ size = sizeof(LineStyleColorModifier_Material);
+ break;
+ default:
+ return NULL; /* unknown modifier type */
}
return new_modifier(type, size);
@@ -228,26 +228,26 @@ LineStyleModifier *BKE_add_linestyle_color_modifier(FreestyleLineStyle *linestyl
m->blend = MA_RAMP_BLEND;
switch (type) {
- case LS_MODIFIER_ALONG_STROKE:
- ((LineStyleColorModifier_AlongStroke *)m)->color_ramp = add_colorband(1);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp = add_colorband(1);
- ((LineStyleColorModifier_DistanceFromCamera *)m)->range_min = 0.0f;
- ((LineStyleColorModifier_DistanceFromCamera *)m)->range_max = 10000.0f;
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- ((LineStyleColorModifier_DistanceFromObject *)m)->target = NULL;
- ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp = add_colorband(1);
- ((LineStyleColorModifier_DistanceFromObject *)m)->range_min = 0.0f;
- ((LineStyleColorModifier_DistanceFromObject *)m)->range_max = 10000.0f;
- break;
- case LS_MODIFIER_MATERIAL:
- ((LineStyleColorModifier_Material *)m)->color_ramp = add_colorband(1);
- ((LineStyleColorModifier_Material *)m)->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
- break;
- default:
- return NULL; /* unknown modifier type */
+ case LS_MODIFIER_ALONG_STROKE:
+ ((LineStyleColorModifier_AlongStroke *)m)->color_ramp = add_colorband(1);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp = add_colorband(1);
+ ((LineStyleColorModifier_DistanceFromCamera *)m)->range_min = 0.0f;
+ ((LineStyleColorModifier_DistanceFromCamera *)m)->range_max = 10000.0f;
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ ((LineStyleColorModifier_DistanceFromObject *)m)->target = NULL;
+ ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp = add_colorband(1);
+ ((LineStyleColorModifier_DistanceFromObject *)m)->range_min = 0.0f;
+ ((LineStyleColorModifier_DistanceFromObject *)m)->range_max = 10000.0f;
+ break;
+ case LS_MODIFIER_MATERIAL:
+ ((LineStyleColorModifier_Material *)m)->color_ramp = add_colorband(1);
+ ((LineStyleColorModifier_Material *)m)->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
+ break;
+ default:
+ return NULL; /* unknown modifier type */
}
add_to_modifier_list(&linestyle->color_modifiers, m);
@@ -264,23 +264,23 @@ LineStyleModifier *BKE_copy_linestyle_color_modifier(FreestyleLineStyle *linesty
new_m->blend = m->blend;
switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
+ case LS_MODIFIER_ALONG_STROKE:
{
LineStyleColorModifier_AlongStroke *p = (LineStyleColorModifier_AlongStroke *)m;
LineStyleColorModifier_AlongStroke *q = (LineStyleColorModifier_AlongStroke *)new_m;
q->color_ramp = MEM_dupallocN(p->color_ramp);
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
{
LineStyleColorModifier_DistanceFromCamera *p = (LineStyleColorModifier_DistanceFromCamera *)m;
LineStyleColorModifier_DistanceFromCamera *q = (LineStyleColorModifier_DistanceFromCamera *)new_m;
q->color_ramp = MEM_dupallocN(p->color_ramp);
q->range_min = p->range_min;
q->range_max = p->range_max;
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
{
LineStyleColorModifier_DistanceFromObject *p = (LineStyleColorModifier_DistanceFromObject *)m;
LineStyleColorModifier_DistanceFromObject *q = (LineStyleColorModifier_DistanceFromObject *)new_m;
@@ -290,19 +290,19 @@ LineStyleModifier *BKE_copy_linestyle_color_modifier(FreestyleLineStyle *linesty
q->color_ramp = MEM_dupallocN(p->color_ramp);
q->range_min = p->range_min;
q->range_max = p->range_max;
+ break;
}
- break;
- case LS_MODIFIER_MATERIAL:
+ case LS_MODIFIER_MATERIAL:
{
LineStyleColorModifier_Material *p = (LineStyleColorModifier_Material *)m;
LineStyleColorModifier_Material *q = (LineStyleColorModifier_Material *)new_m;
q->color_ramp = MEM_dupallocN(p->color_ramp);
q->flags = p->flags;
q->mat_attr = p->mat_attr;
+ break;
}
- break;
- default:
- return NULL; /* unknown modifier type */
+ default:
+ return NULL; /* unknown modifier type */
}
add_to_modifier_list(&linestyle->color_modifiers, new_m);
@@ -312,18 +312,18 @@ LineStyleModifier *BKE_copy_linestyle_color_modifier(FreestyleLineStyle *linesty
void BKE_remove_linestyle_color_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
{
switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- MEM_freeN(((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- MEM_freeN(((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- MEM_freeN(((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
- break;
- case LS_MODIFIER_MATERIAL:
- MEM_freeN(((LineStyleColorModifier_Material *)m)->color_ramp);
- break;
+ case LS_MODIFIER_ALONG_STROKE:
+ MEM_freeN(((LineStyleColorModifier_AlongStroke *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ MEM_freeN(((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ MEM_freeN(((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ MEM_freeN(((LineStyleColorModifier_Material *)m)->color_ramp);
+ break;
}
BLI_freelinkN(&linestyle->color_modifiers, m);
}
@@ -333,20 +333,20 @@ static LineStyleModifier *alloc_alpha_modifier(int type)
size_t size;
switch (type) {
- case LS_MODIFIER_ALONG_STROKE:
- size = sizeof(LineStyleAlphaModifier_AlongStroke);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- size = sizeof(LineStyleAlphaModifier_DistanceFromCamera);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- size = sizeof(LineStyleAlphaModifier_DistanceFromObject);
- break;
- case LS_MODIFIER_MATERIAL:
- size = sizeof(LineStyleAlphaModifier_Material);
- break;
- default:
- return NULL; /* unknown modifier type */
+ case LS_MODIFIER_ALONG_STROKE:
+ size = sizeof(LineStyleAlphaModifier_AlongStroke);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ size = sizeof(LineStyleAlphaModifier_DistanceFromCamera);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ size = sizeof(LineStyleAlphaModifier_DistanceFromObject);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ size = sizeof(LineStyleAlphaModifier_Material);
+ break;
+ default:
+ return NULL; /* unknown modifier type */
}
return new_modifier(type, size);
}
@@ -359,38 +359,38 @@ LineStyleModifier *BKE_add_linestyle_alpha_modifier(FreestyleLineStyle *linestyl
m->blend = LS_VALUE_BLEND;
switch (type) {
- case LS_MODIFIER_ALONG_STROKE:
+ case LS_MODIFIER_ALONG_STROKE:
{
LineStyleAlphaModifier_AlongStroke *p = (LineStyleAlphaModifier_AlongStroke *)m;
p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
{
LineStyleAlphaModifier_DistanceFromCamera *p = (LineStyleAlphaModifier_DistanceFromCamera *)m;
p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
p->range_min = 0.0f;
p->range_max = 10000.0f;
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
{
LineStyleAlphaModifier_DistanceFromObject *p = (LineStyleAlphaModifier_DistanceFromObject *)m;
p->target = NULL;
p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
p->range_min = 0.0f;
p->range_max = 10000.0f;
+ break;
}
- break;
- case LS_MODIFIER_MATERIAL:
+ case LS_MODIFIER_MATERIAL:
{
LineStyleAlphaModifier_Material *p = (LineStyleAlphaModifier_Material *)m;
p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
p->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
+ break;
}
- break;
- default:
- return NULL; /* unknown modifier type */
+ default:
+ return NULL; /* unknown modifier type */
}
add_to_modifier_list(&linestyle->alpha_modifiers, m);
@@ -407,15 +407,15 @@ LineStyleModifier *BKE_copy_linestyle_alpha_modifier(FreestyleLineStyle *linesty
new_m->blend = m->blend;
switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
+ case LS_MODIFIER_ALONG_STROKE:
{
LineStyleAlphaModifier_AlongStroke *p = (LineStyleAlphaModifier_AlongStroke *)m;
LineStyleAlphaModifier_AlongStroke *q = (LineStyleAlphaModifier_AlongStroke *)new_m;
q->curve = curvemapping_copy(p->curve);
q->flags = p->flags;
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
{
LineStyleAlphaModifier_DistanceFromCamera *p = (LineStyleAlphaModifier_DistanceFromCamera *)m;
LineStyleAlphaModifier_DistanceFromCamera *q = (LineStyleAlphaModifier_DistanceFromCamera *)new_m;
@@ -423,9 +423,9 @@ LineStyleModifier *BKE_copy_linestyle_alpha_modifier(FreestyleLineStyle *linesty
q->flags = p->flags;
q->range_min = p->range_min;
q->range_max = p->range_max;
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
{
LineStyleAlphaModifier_DistanceFromObject *p = (LineStyleAlphaModifier_DistanceFromObject *)m;
LineStyleAlphaModifier_DistanceFromObject *q = (LineStyleAlphaModifier_DistanceFromObject *)new_m;
@@ -436,19 +436,19 @@ LineStyleModifier *BKE_copy_linestyle_alpha_modifier(FreestyleLineStyle *linesty
q->flags = p->flags;
q->range_min = p->range_min;
q->range_max = p->range_max;
+ break;
}
- break;
- case LS_MODIFIER_MATERIAL:
+ case LS_MODIFIER_MATERIAL:
{
LineStyleAlphaModifier_Material *p = (LineStyleAlphaModifier_Material *)m;
LineStyleAlphaModifier_Material *q = (LineStyleAlphaModifier_Material *)new_m;
q->curve = curvemapping_copy(p->curve);
q->flags = p->flags;
q->mat_attr = p->mat_attr;
+ break;
}
- break;
- default:
- return NULL; /* unknown modifier type */
+ default:
+ return NULL; /* unknown modifier type */
}
add_to_modifier_list(&linestyle->alpha_modifiers, new_m);
@@ -458,18 +458,18 @@ LineStyleModifier *BKE_copy_linestyle_alpha_modifier(FreestyleLineStyle *linesty
void BKE_remove_linestyle_alpha_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
{
switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- curvemapping_free(((LineStyleAlphaModifier_AlongStroke *)m)->curve);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- curvemapping_free(((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- curvemapping_free(((LineStyleAlphaModifier_DistanceFromObject *)m)->curve);
- break;
- case LS_MODIFIER_MATERIAL:
- curvemapping_free(((LineStyleAlphaModifier_Material *)m)->curve);
- break;
+ case LS_MODIFIER_ALONG_STROKE:
+ curvemapping_free(((LineStyleAlphaModifier_AlongStroke *)m)->curve);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ curvemapping_free(((LineStyleAlphaModifier_DistanceFromCamera *)m)->curve);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ curvemapping_free(((LineStyleAlphaModifier_DistanceFromObject *)m)->curve);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ curvemapping_free(((LineStyleAlphaModifier_Material *)m)->curve);
+ break;
}
BLI_freelinkN(&linestyle->alpha_modifiers, m);
}
@@ -479,23 +479,23 @@ static LineStyleModifier *alloc_thickness_modifier(int type)
size_t size;
switch (type) {
- case LS_MODIFIER_ALONG_STROKE:
- size = sizeof(LineStyleThicknessModifier_AlongStroke);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- size = sizeof(LineStyleThicknessModifier_DistanceFromCamera);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- size = sizeof(LineStyleThicknessModifier_DistanceFromObject);
- break;
- case LS_MODIFIER_MATERIAL:
- size = sizeof(LineStyleThicknessModifier_Material);
- break;
- case LS_MODIFIER_CALLIGRAPHY:
- size = sizeof(LineStyleThicknessModifier_Calligraphy);
- break;
- default:
- return NULL; /* unknown modifier type */
+ case LS_MODIFIER_ALONG_STROKE:
+ size = sizeof(LineStyleThicknessModifier_AlongStroke);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ size = sizeof(LineStyleThicknessModifier_DistanceFromCamera);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ size = sizeof(LineStyleThicknessModifier_DistanceFromObject);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ size = sizeof(LineStyleThicknessModifier_Material);
+ break;
+ case LS_MODIFIER_CALLIGRAPHY:
+ size = sizeof(LineStyleThicknessModifier_Calligraphy);
+ break;
+ default:
+ return NULL; /* unknown modifier type */
}
return new_modifier(type, size);
@@ -509,15 +509,15 @@ LineStyleModifier *BKE_add_linestyle_thickness_modifier(FreestyleLineStyle *line
m->blend = LS_VALUE_BLEND;
switch (type) {
- case LS_MODIFIER_ALONG_STROKE:
+ case LS_MODIFIER_ALONG_STROKE:
{
LineStyleThicknessModifier_AlongStroke *p = (LineStyleThicknessModifier_AlongStroke *)m;
p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
p->value_min = 0.0f;
p->value_max = 1.0f;
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
{
LineStyleThicknessModifier_DistanceFromCamera *p = (LineStyleThicknessModifier_DistanceFromCamera *)m;
p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
@@ -525,9 +525,9 @@ LineStyleModifier *BKE_add_linestyle_thickness_modifier(FreestyleLineStyle *line
p->range_max = 1000.0f;
p->value_min = 0.0f;
p->value_max = 1.0f;
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
{
LineStyleThicknessModifier_DistanceFromObject *p = (LineStyleThicknessModifier_DistanceFromObject *)m;
p->target = NULL;
@@ -536,27 +536,27 @@ LineStyleModifier *BKE_add_linestyle_thickness_modifier(FreestyleLineStyle *line
p->range_max = 1000.0f;
p->value_min = 0.0f;
p->value_max = 1.0f;
+ break;
}
- break;
- case LS_MODIFIER_MATERIAL:
+ case LS_MODIFIER_MATERIAL:
{
LineStyleThicknessModifier_Material *p = (LineStyleThicknessModifier_Material *)m;
p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
p->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
p->value_min = 0.0f;
p->value_max = 1.0f;
+ break;
}
- break;
- case LS_MODIFIER_CALLIGRAPHY:
+ case LS_MODIFIER_CALLIGRAPHY:
{
LineStyleThicknessModifier_Calligraphy *p = (LineStyleThicknessModifier_Calligraphy *)m;
p->min_thickness = 1.0f;
p->max_thickness = 10.0f;
p->orientation = DEG2RADF(60.0f);
+ break;
}
- break;
- default:
- return NULL; /* unknown modifier type */
+ default:
+ return NULL; /* unknown modifier type */
}
add_to_modifier_list(&linestyle->thickness_modifiers, m);
@@ -575,7 +575,7 @@ LineStyleModifier *BKE_copy_linestyle_thickness_modifier(FreestyleLineStyle *lin
new_m->blend = m->blend;
switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
+ case LS_MODIFIER_ALONG_STROKE:
{
LineStyleThicknessModifier_AlongStroke *p = (LineStyleThicknessModifier_AlongStroke *)m;
LineStyleThicknessModifier_AlongStroke *q = (LineStyleThicknessModifier_AlongStroke *)new_m;
@@ -583,9 +583,9 @@ LineStyleModifier *BKE_copy_linestyle_thickness_modifier(FreestyleLineStyle *lin
q->flags = p->flags;
q->value_min = p->value_min;
q->value_max = p->value_max;
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
{
LineStyleThicknessModifier_DistanceFromCamera *p = (LineStyleThicknessModifier_DistanceFromCamera *)m;
LineStyleThicknessModifier_DistanceFromCamera *q = (LineStyleThicknessModifier_DistanceFromCamera *)new_m;
@@ -595,9 +595,9 @@ LineStyleModifier *BKE_copy_linestyle_thickness_modifier(FreestyleLineStyle *lin
q->range_max = p->range_max;
q->value_min = p->value_min;
q->value_max = p->value_max;
+ break;
}
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
{
LineStyleThicknessModifier_DistanceFromObject *p = (LineStyleThicknessModifier_DistanceFromObject *)m;
LineStyleThicknessModifier_DistanceFromObject *q = (LineStyleThicknessModifier_DistanceFromObject *)new_m;
@@ -610,9 +610,9 @@ LineStyleModifier *BKE_copy_linestyle_thickness_modifier(FreestyleLineStyle *lin
q->range_max = p->range_max;
q->value_min = p->value_min;
q->value_max = p->value_max;
+ break;
}
- break;
- case LS_MODIFIER_MATERIAL:
+ case LS_MODIFIER_MATERIAL:
{
LineStyleThicknessModifier_Material *p = (LineStyleThicknessModifier_Material *)m;
LineStyleThicknessModifier_Material *q = (LineStyleThicknessModifier_Material *)new_m;
@@ -621,19 +621,19 @@ LineStyleModifier *BKE_copy_linestyle_thickness_modifier(FreestyleLineStyle *lin
q->mat_attr = p->mat_attr;
q->value_min = p->value_min;
q->value_max = p->value_max;
+ break;
}
- break;
- case LS_MODIFIER_CALLIGRAPHY:
+ case LS_MODIFIER_CALLIGRAPHY:
{
LineStyleThicknessModifier_Calligraphy *p = (LineStyleThicknessModifier_Calligraphy *)m;
LineStyleThicknessModifier_Calligraphy *q = (LineStyleThicknessModifier_Calligraphy *)new_m;
q->min_thickness = p->min_thickness;
q->max_thickness = p->max_thickness;
q->orientation = p->orientation;
+ break;
}
- break;
- default:
- return NULL; /* unknown modifier type */
+ default:
+ return NULL; /* unknown modifier type */
}
add_to_modifier_list(&linestyle->thickness_modifiers, new_m);
@@ -643,20 +643,20 @@ LineStyleModifier *BKE_copy_linestyle_thickness_modifier(FreestyleLineStyle *lin
void BKE_remove_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *m)
{
switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- curvemapping_free(((LineStyleThicknessModifier_AlongStroke *)m)->curve);
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- curvemapping_free(((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve);
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- curvemapping_free(((LineStyleThicknessModifier_DistanceFromObject *)m)->curve);
- break;
- case LS_MODIFIER_MATERIAL:
- curvemapping_free(((LineStyleThicknessModifier_Material *)m)->curve);
- break;
- case LS_MODIFIER_CALLIGRAPHY:
- break;
+ case LS_MODIFIER_ALONG_STROKE:
+ curvemapping_free(((LineStyleThicknessModifier_AlongStroke *)m)->curve);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ curvemapping_free(((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve);
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ curvemapping_free(((LineStyleThicknessModifier_DistanceFromObject *)m)->curve);
+ break;
+ case LS_MODIFIER_MATERIAL:
+ curvemapping_free(((LineStyleThicknessModifier_Material *)m)->curve);
+ break;
+ case LS_MODIFIER_CALLIGRAPHY:
+ break;
}
BLI_freelinkN(&linestyle->thickness_modifiers, m);
}
@@ -666,47 +666,47 @@ static LineStyleModifier *alloc_geometry_modifier(int type)
size_t size;
switch (type) {
- case LS_MODIFIER_SAMPLING:
- size = sizeof(LineStyleGeometryModifier_Sampling);
- break;
- case LS_MODIFIER_BEZIER_CURVE:
- size = sizeof(LineStyleGeometryModifier_BezierCurve);
- break;
- case LS_MODIFIER_SINUS_DISPLACEMENT:
- size = sizeof(LineStyleGeometryModifier_SinusDisplacement);
- break;
- case LS_MODIFIER_SPATIAL_NOISE:
- size = sizeof(LineStyleGeometryModifier_SpatialNoise);
- break;
- case LS_MODIFIER_PERLIN_NOISE_1D:
- size = sizeof(LineStyleGeometryModifier_PerlinNoise1D);
- break;
- case LS_MODIFIER_PERLIN_NOISE_2D:
- size = sizeof(LineStyleGeometryModifier_PerlinNoise2D);
- break;
- case LS_MODIFIER_BACKBONE_STRETCHER:
- size = sizeof(LineStyleGeometryModifier_BackboneStretcher);
- break;
- case LS_MODIFIER_TIP_REMOVER:
- size = sizeof(LineStyleGeometryModifier_TipRemover);
- break;
- case LS_MODIFIER_POLYGONIZATION:
- size = sizeof(LineStyleGeometryModifier_Polygonalization);
- break;
- case LS_MODIFIER_GUIDING_LINES:
- size = sizeof(LineStyleGeometryModifier_GuidingLines);
- break;
- case LS_MODIFIER_BLUEPRINT:
- size = sizeof(LineStyleGeometryModifier_Blueprint);
- break;
- case LS_MODIFIER_2D_OFFSET:
- size = sizeof(LineStyleGeometryModifier_2DOffset);
- break;
- case LS_MODIFIER_2D_TRANSFORM:
- size = sizeof(LineStyleGeometryModifier_2DTransform);
- break;
- default:
- return NULL; /* unknown modifier type */
+ case LS_MODIFIER_SAMPLING:
+ size = sizeof(LineStyleGeometryModifier_Sampling);
+ break;
+ case LS_MODIFIER_BEZIER_CURVE:
+ size = sizeof(LineStyleGeometryModifier_BezierCurve);
+ break;
+ case LS_MODIFIER_SINUS_DISPLACEMENT:
+ size = sizeof(LineStyleGeometryModifier_SinusDisplacement);
+ break;
+ case LS_MODIFIER_SPATIAL_NOISE:
+ size = sizeof(LineStyleGeometryModifier_SpatialNoise);
+ break;
+ case LS_MODIFIER_PERLIN_NOISE_1D:
+ size = sizeof(LineStyleGeometryModifier_PerlinNoise1D);
+ break;
+ case LS_MODIFIER_PERLIN_NOISE_2D:
+ size = sizeof(LineStyleGeometryModifier_PerlinNoise2D);
+ break;
+ case LS_MODIFIER_BACKBONE_STRETCHER:
+ size = sizeof(LineStyleGeometryModifier_BackboneStretcher);
+ break;
+ case LS_MODIFIER_TIP_REMOVER:
+ size = sizeof(LineStyleGeometryModifier_TipRemover);
+ break;
+ case LS_MODIFIER_POLYGONIZATION:
+ size = sizeof(LineStyleGeometryModifier_Polygonalization);
+ break;
+ case LS_MODIFIER_GUIDING_LINES:
+ size = sizeof(LineStyleGeometryModifier_GuidingLines);
+ break;
+ case LS_MODIFIER_BLUEPRINT:
+ size = sizeof(LineStyleGeometryModifier_Blueprint);
+ break;
+ case LS_MODIFIER_2D_OFFSET:
+ size = sizeof(LineStyleGeometryModifier_2DOffset);
+ break;
+ case LS_MODIFIER_2D_TRANSFORM:
+ size = sizeof(LineStyleGeometryModifier_2DTransform);
+ break;
+ default:
+ return NULL; /* unknown modifier type */
}
return new_modifier(type, size);
@@ -719,78 +719,78 @@ LineStyleModifier *BKE_add_linestyle_geometry_modifier(FreestyleLineStyle *lines
m = alloc_geometry_modifier(type);
switch (type) {
- case LS_MODIFIER_SAMPLING:
+ case LS_MODIFIER_SAMPLING:
{
LineStyleGeometryModifier_Sampling *p = (LineStyleGeometryModifier_Sampling *)m;
p->sampling = 10.0f;
+ break;
}
- break;
- case LS_MODIFIER_BEZIER_CURVE:
+ case LS_MODIFIER_BEZIER_CURVE:
{
LineStyleGeometryModifier_BezierCurve *p = (LineStyleGeometryModifier_BezierCurve *)m;
p->error = 10.0f;
+ break;
}
- break;
- case LS_MODIFIER_SINUS_DISPLACEMENT:
+ case LS_MODIFIER_SINUS_DISPLACEMENT:
{
LineStyleGeometryModifier_SinusDisplacement *p = (LineStyleGeometryModifier_SinusDisplacement *)m;
p->wavelength = 20.0f;
p->amplitude = 5.0f;
p->phase = 0.0f;
+ break;
}
- break;
- case LS_MODIFIER_SPATIAL_NOISE:
+ case LS_MODIFIER_SPATIAL_NOISE:
{
LineStyleGeometryModifier_SpatialNoise *p = (LineStyleGeometryModifier_SpatialNoise *)m;
p->amplitude = 5.0f;
p->scale = 20.0f;
p->octaves = 4;
p->flags = LS_MODIFIER_SPATIAL_NOISE_SMOOTH | LS_MODIFIER_SPATIAL_NOISE_PURERANDOM;
+ break;
}
- break;
- case LS_MODIFIER_PERLIN_NOISE_1D:
+ case LS_MODIFIER_PERLIN_NOISE_1D:
{
LineStyleGeometryModifier_PerlinNoise1D *p = (LineStyleGeometryModifier_PerlinNoise1D *)m;
p->frequency = 10.0f;
p->amplitude = 10.0f;
p->octaves = 4;
p->angle = DEG2RADF(45.0f);
+ break;
}
- break;
- case LS_MODIFIER_PERLIN_NOISE_2D:
+ case LS_MODIFIER_PERLIN_NOISE_2D:
{
LineStyleGeometryModifier_PerlinNoise2D *p = (LineStyleGeometryModifier_PerlinNoise2D *)m;
p->frequency = 10.0f;
p->amplitude = 10.0f;
p->octaves = 4;
p->angle = DEG2RADF(45.0f);
+ break;
}
- break;
- case LS_MODIFIER_BACKBONE_STRETCHER:
+ case LS_MODIFIER_BACKBONE_STRETCHER:
{
LineStyleGeometryModifier_BackboneStretcher *p = (LineStyleGeometryModifier_BackboneStretcher *)m;
p->backbone_length = 10.0f;
+ break;
}
- break;
- case LS_MODIFIER_TIP_REMOVER:
+ case LS_MODIFIER_TIP_REMOVER:
{
LineStyleGeometryModifier_TipRemover *p = (LineStyleGeometryModifier_TipRemover *)m;
p->tip_length = 10.0f;
+ break;
}
- break;
- case LS_MODIFIER_POLYGONIZATION:
+ case LS_MODIFIER_POLYGONIZATION:
{
LineStyleGeometryModifier_Polygonalization *p = (LineStyleGeometryModifier_Polygonalization *)m;
p->error = 10.0f;
+ break;
}
- break;
- case LS_MODIFIER_GUIDING_LINES:
+ case LS_MODIFIER_GUIDING_LINES:
{
LineStyleGeometryModifier_GuidingLines *p = (LineStyleGeometryModifier_GuidingLines *)m;
p->offset = 0.0f;
+ break;
}
- break;
- case LS_MODIFIER_BLUEPRINT:
+ case LS_MODIFIER_BLUEPRINT:
{
LineStyleGeometryModifier_Blueprint *p = (LineStyleGeometryModifier_Blueprint *)m;
p->flags = LS_MODIFIER_BLUEPRINT_CIRCLES;
@@ -799,18 +799,18 @@ LineStyleModifier *BKE_add_linestyle_geometry_modifier(FreestyleLineStyle *lines
p->random_radius = 3;
p->random_center = 5;
p->random_backbone = 5;
+ break;
}
- break;
- case LS_MODIFIER_2D_OFFSET:
+ case LS_MODIFIER_2D_OFFSET:
{
LineStyleGeometryModifier_2DOffset *p = (LineStyleGeometryModifier_2DOffset *)m;
p->start = 0.0f;
p->end = 0.0f;
p->x = 0.0f;
p->y = 0.0f;
+ break;
}
- break;
- case LS_MODIFIER_2D_TRANSFORM:
+ case LS_MODIFIER_2D_TRANSFORM:
{
LineStyleGeometryModifier_2DTransform *p = (LineStyleGeometryModifier_2DTransform *)m;
p->pivot = LS_MODIFIER_2D_TRANSFORM_PIVOT_CENTER;
@@ -820,10 +820,10 @@ LineStyleModifier *BKE_add_linestyle_geometry_modifier(FreestyleLineStyle *lines
p->pivot_u = 0.5f;
p->pivot_x = 0.0f;
p->pivot_y = 0.0f;
+ break;
}
- break;
- default:
- return NULL; /* unknown modifier type */
+ default:
+ return NULL; /* unknown modifier type */
}
add_to_modifier_list(&linestyle->geometry_modifiers, m);
@@ -838,30 +838,30 @@ LineStyleModifier *BKE_copy_linestyle_geometry_modifier(FreestyleLineStyle *line
new_m->flags = m->flags;
switch (m->type) {
- case LS_MODIFIER_SAMPLING:
+ case LS_MODIFIER_SAMPLING:
{
LineStyleGeometryModifier_Sampling *p = (LineStyleGeometryModifier_Sampling *)m;
LineStyleGeometryModifier_Sampling *q = (LineStyleGeometryModifier_Sampling *)new_m;
q->sampling = p->sampling;
+ break;
}
- break;
- case LS_MODIFIER_BEZIER_CURVE:
+ case LS_MODIFIER_BEZIER_CURVE:
{
LineStyleGeometryModifier_BezierCurve *p = (LineStyleGeometryModifier_BezierCurve *)m;
LineStyleGeometryModifier_BezierCurve *q = (LineStyleGeometryModifier_BezierCurve *)new_m;
q->error = p->error;
+ break;
}
- break;
- case LS_MODIFIER_SINUS_DISPLACEMENT:
+ case LS_MODIFIER_SINUS_DISPLACEMENT:
{
LineStyleGeometryModifier_SinusDisplacement *p = (LineStyleGeometryModifier_SinusDisplacement *)m;
LineStyleGeometryModifier_SinusDisplacement *q = (LineStyleGeometryModifier_SinusDisplacement *)new_m;
q->wavelength = p->wavelength;
q->amplitude = p->amplitude;
q->phase = p->phase;
+ break;
}
- break;
- case LS_MODIFIER_SPATIAL_NOISE:
+ case LS_MODIFIER_SPATIAL_NOISE:
{
LineStyleGeometryModifier_SpatialNoise *p = (LineStyleGeometryModifier_SpatialNoise *)m;
LineStyleGeometryModifier_SpatialNoise *q = (LineStyleGeometryModifier_SpatialNoise *)new_m;
@@ -869,9 +869,9 @@ LineStyleModifier *BKE_copy_linestyle_geometry_modifier(FreestyleLineStyle *line
q->scale = p->scale;
q->octaves = p->octaves;
q->flags = p->flags;
+ break;
}
- break;
- case LS_MODIFIER_PERLIN_NOISE_1D:
+ case LS_MODIFIER_PERLIN_NOISE_1D:
{
LineStyleGeometryModifier_PerlinNoise1D *p = (LineStyleGeometryModifier_PerlinNoise1D *)m;
LineStyleGeometryModifier_PerlinNoise1D *q = (LineStyleGeometryModifier_PerlinNoise1D *)new_m;
@@ -880,9 +880,9 @@ LineStyleModifier *BKE_copy_linestyle_geometry_modifier(FreestyleLineStyle *line
q->angle = p->angle;
q->octaves = p->octaves;
q->seed = p->seed;
+ break;
}
- break;
- case LS_MODIFIER_PERLIN_NOISE_2D:
+ case LS_MODIFIER_PERLIN_NOISE_2D:
{
LineStyleGeometryModifier_PerlinNoise2D *p = (LineStyleGeometryModifier_PerlinNoise2D *)m;
LineStyleGeometryModifier_PerlinNoise2D *q = (LineStyleGeometryModifier_PerlinNoise2D *)new_m;
@@ -891,37 +891,37 @@ LineStyleModifier *BKE_copy_linestyle_geometry_modifier(FreestyleLineStyle *line
q->angle = p->angle;
q->octaves = p->octaves;
q->seed = p->seed;
+ break;
}
- break;
- case LS_MODIFIER_BACKBONE_STRETCHER:
+ case LS_MODIFIER_BACKBONE_STRETCHER:
{
LineStyleGeometryModifier_BackboneStretcher *p = (LineStyleGeometryModifier_BackboneStretcher *)m;
LineStyleGeometryModifier_BackboneStretcher *q = (LineStyleGeometryModifier_BackboneStretcher *)new_m;
q->backbone_length = p->backbone_length;
+ break;
}
- break;
- case LS_MODIFIER_TIP_REMOVER:
+ case LS_MODIFIER_TIP_REMOVER:
{
LineStyleGeometryModifier_TipRemover *p = (LineStyleGeometryModifier_TipRemover *)m;
LineStyleGeometryModifier_TipRemover *q = (LineStyleGeometryModifier_TipRemover *)new_m;
q->tip_length = p->tip_length;
+ break;
}
- break;
- case LS_MODIFIER_POLYGONIZATION:
+ case LS_MODIFIER_POLYGONIZATION:
{
LineStyleGeometryModifier_Polygonalization *p = (LineStyleGeometryModifier_Polygonalization *)m;
LineStyleGeometryModifier_Polygonalization *q = (LineStyleGeometryModifier_Polygonalization *)new_m;
q->error = p->error;
+ break;
}
- break;
- case LS_MODIFIER_GUIDING_LINES:
+ case LS_MODIFIER_GUIDING_LINES:
{
LineStyleGeometryModifier_GuidingLines *p = (LineStyleGeometryModifier_GuidingLines *)m;
LineStyleGeometryModifier_GuidingLines *q = (LineStyleGeometryModifier_GuidingLines *)new_m;
q->offset = p->offset;
+ break;
}
- break;
- case LS_MODIFIER_BLUEPRINT:
+ case LS_MODIFIER_BLUEPRINT:
{
LineStyleGeometryModifier_Blueprint *p = (LineStyleGeometryModifier_Blueprint *)m;
LineStyleGeometryModifier_Blueprint *q = (LineStyleGeometryModifier_Blueprint *)new_m;
@@ -931,9 +931,9 @@ LineStyleModifier *BKE_copy_linestyle_geometry_modifier(FreestyleLineStyle *line
q->random_radius = p->random_radius;
q->random_center = p->random_center;
q->random_backbone = p->random_backbone;
+ break;
}
- break;
- case LS_MODIFIER_2D_OFFSET:
+ case LS_MODIFIER_2D_OFFSET:
{
LineStyleGeometryModifier_2DOffset *p = (LineStyleGeometryModifier_2DOffset *)m;
LineStyleGeometryModifier_2DOffset *q = (LineStyleGeometryModifier_2DOffset *)new_m;
@@ -941,9 +941,9 @@ LineStyleModifier *BKE_copy_linestyle_geometry_modifier(FreestyleLineStyle *line
q->end = p->end;
q->x = p->x;
q->y = p->y;
+ break;
}
- break;
- case LS_MODIFIER_2D_TRANSFORM:
+ case LS_MODIFIER_2D_TRANSFORM:
{
LineStyleGeometryModifier_2DTransform *p = (LineStyleGeometryModifier_2DTransform *)m;
LineStyleGeometryModifier_2DTransform *q = (LineStyleGeometryModifier_2DTransform *)new_m;
@@ -954,10 +954,10 @@ LineStyleModifier *BKE_copy_linestyle_geometry_modifier(FreestyleLineStyle *line
q->pivot_u = p->pivot_u;
q->pivot_x = p->pivot_x;
q->pivot_y = p->pivot_y;
+ break;
}
- break;
- default:
- return NULL; /* unknown modifier type */
+ default:
+ return NULL; /* unknown modifier type */
}
add_to_modifier_list(&linestyle->geometry_modifiers, new_m);
@@ -1007,20 +1007,20 @@ void BKE_list_modifier_color_ramps(FreestyleLineStyle *linestyle, ListBase *list
listbase->first = listbase->last = NULL;
for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
switch (m->type) {
- case LS_MODIFIER_ALONG_STROKE:
- color_ramp = ((LineStyleColorModifier_AlongStroke *)m)->color_ramp;
- break;
- case LS_MODIFIER_DISTANCE_FROM_CAMERA:
- color_ramp = ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp;
- break;
- case LS_MODIFIER_DISTANCE_FROM_OBJECT:
- color_ramp = ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp;
- break;
- case LS_MODIFIER_MATERIAL:
- color_ramp = ((LineStyleColorModifier_Material *)m)->color_ramp;
- break;
- default:
- continue;
+ case LS_MODIFIER_ALONG_STROKE:
+ color_ramp = ((LineStyleColorModifier_AlongStroke *)m)->color_ramp;
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_CAMERA:
+ color_ramp = ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp;
+ break;
+ case LS_MODIFIER_DISTANCE_FROM_OBJECT:
+ color_ramp = ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp;
+ break;
+ case LS_MODIFIER_MATERIAL:
+ color_ramp = ((LineStyleColorModifier_Material *)m)->color_ramp;
+ break;
+ default:
+ continue;
}
link = (LinkData *) MEM_callocN( sizeof(LinkData), "link to color ramp");
link->data = color_ramp;
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index b3c5ceefb2d..21e7fb3116e 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -939,8 +939,6 @@ void BKE_mask_free(Main *bmain, Mask *mask)
SpaceLink *sl;
Scene *scene;
- BKE_sequencer_clear_mask_in_clipboard(mask);
-
for (scr = bmain->screen.first; scr; scr = scr->id.next) {
for (area = scr->areabase.first; area; area = area->next) {
for (sl = area->spacedata.first; sl; sl = sl->next) {
diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c
index 82410d56c52..ac48eaa3185 100644
--- a/source/blender/blenkernel/intern/mask_rasterize.c
+++ b/source/blender/blenkernel/intern/mask_rasterize.c
@@ -496,10 +496,10 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
/* this should _almost_ never happen but since it can in extreme cases,
* we have to clamp the values or we overrun the buffer and crash */
- CLAMP(xi_min, 0, layer->buckets_x - 1);
- CLAMP(xi_max, 0, layer->buckets_x - 1);
- CLAMP(yi_min, 0, layer->buckets_y - 1);
- CLAMP(yi_max, 0, layer->buckets_y - 1);
+ if (xi_min >= layer->buckets_x) xi_min = layer->buckets_x - 1;
+ if (xi_max >= layer->buckets_x) xi_max = layer->buckets_x - 1;
+ if (yi_min >= layer->buckets_y) yi_min = layer->buckets_y - 1;
+ if (yi_max >= layer->buckets_y) yi_max = layer->buckets_y - 1;
for (yi = yi_min; yi <= yi_max; yi++) {
unsigned int bucket_index = (layer->buckets_x * yi) + xi_min;
@@ -530,7 +530,7 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size)
if (1) {
/* now convert linknodes into arrays for faster per pixel access */
- unsigned int **buckets_face = MEM_mallocN(bucket_tot * sizeof(unsigned int **), __func__);
+ unsigned int **buckets_face = MEM_mallocN(bucket_tot * sizeof(*buckets_face), __func__);
unsigned int bucket_index;
for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) {
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index c8cd65e9477..6dc3c6d7bc6 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1148,55 +1148,6 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime)
ma->id.flag &= ~LIB_DOIT;
}
-
-/* ****************** */
-#if 0 /* UNUSED */
-static char colname_array[125][20] = {
-"Black", "DarkRed", "HalfRed", "Red", "Red",
-"DarkGreen", "DarkOlive", "Brown", "Chocolate", "OrangeRed",
-"HalfGreen", "GreenOlive", "DryOlive", "Goldenrod", "DarkOrange",
-"LightGreen", "Chartreuse", "YellowGreen", "Yellow", "Gold",
-"Green", "LawnGreen", "GreenYellow", "LightOlive", "Yellow",
-"DarkBlue", "DarkPurple", "HotPink", "VioletPink", "RedPink",
-"SlateGray", "DarkGray", "PalePurple", "IndianRed", "Tomato",
-"SeaGreen", "PaleGreen", "GreenKhaki", "LightBrown", "LightSalmon",
-"SpringGreen", "PaleGreen", "MediumOlive", "YellowBrown", "LightGold",
-"LightGreen", "LightGreen", "LightGreen", "GreenYellow", "PaleYellow",
-"HalfBlue", "DarkSky", "HalfMagenta", "VioletRed", "DeepPink",
-"SteelBlue", "SkyBlue", "Orchid", "LightHotPink", "HotPink",
-"SeaGreen", "SlateGray", "MediumGray", "Burlywood", "LightPink",
-"SpringGreen", "Aquamarine", "PaleGreen", "Khaki", "PaleOrange",
-"SpringGreen", "SeaGreen", "PaleGreen", "PaleWhite", "YellowWhite",
-"LightBlue", "Purple", "MediumOrchid", "Magenta", "Magenta",
-"RoyalBlue", "SlateBlue", "MediumOrchid", "Orchid", "Magenta",
-"DeepSkyBlue", "LightSteelBlue", "LightSkyBlue", "Violet", "LightPink",
-"Cyan", "DarkTurquoise", "SkyBlue", "Gray", "Snow",
-"Mint", "Mint", "Aquamarine", "MintCream", "Ivory",
-"Blue", "Blue", "DarkMagenta", "DarkOrchid", "Magenta",
-"SkyBlue", "RoyalBlue", "LightSlateBlue", "MediumOrchid", "Magenta",
-"DodgerBlue", "SteelBlue", "MediumPurple", "PalePurple", "Plum",
-"DeepSkyBlue", "PaleBlue", "LightSkyBlue", "PalePurple", "Thistle",
-"Cyan", "ColdBlue", "PaleTurquoise", "GhostWhite", "White"
-};
-
-void automatname(Material *ma)
-{
- int nr, r, g, b;
- float ref;
-
- if (ma == NULL) return;
- if (ma->mode & MA_SHLESS) ref = 1.0;
- else ref = ma->ref;
-
- r = (int)(4.99f * (ref * ma->r));
- g = (int)(4.99f * (ref * ma->g));
- b = (int)(4.99f * (ref * ma->b));
- nr = r + 5 * g + 25 * b;
- if (nr > 124) nr = 124;
- new_id(&G.main->mat, (ID *)ma, colname_array[nr]);
-
-}
-#endif
int object_remove_material_slot(Object *ob)
{
@@ -1225,7 +1176,9 @@ int object_remove_material_slot(Object *ob)
totcolp = give_totcolp(ob);
matarar = give_matarar(ob);
- if (*matarar == NULL) return FALSE;
+ if (ELEM(NULL, matarar, *matarar)) {
+ return false;
+ }
/* can happen on face selection in editmode */
if (ob->actcol > ob->totcol) {
@@ -1430,8 +1383,8 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
r_col[1] = facm * (r_col[1]) + fac * tmpg;
r_col[2] = facm * (r_col[2]) + fac * tmpb;
}
+ break;
}
- break;
case MA_RAMP_SAT:
{
float rH, rS, rV;
@@ -1441,8 +1394,8 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV);
hsv_to_rgb(rH, (facm * rS + fac * colS), rV, r_col + 0, r_col + 1, r_col + 2);
}
+ break;
}
- break;
case MA_RAMP_VAL:
{
float rH, rS, rV;
@@ -1450,8 +1403,8 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV);
rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV);
hsv_to_rgb(rH, rS, (facm * rV + fac * colV), r_col + 0, r_col + 1, r_col + 2);
+ break;
}
- break;
case MA_RAMP_COLOR:
{
float rH, rS, rV;
@@ -1465,8 +1418,8 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
r_col[1] = facm * (r_col[1]) + fac * tmpg;
r_col[2] = facm * (r_col[2]) + fac * tmpb;
}
+ break;
}
- break;
case MA_RAMP_SOFT:
{
float scr, scg, scb;
@@ -1479,8 +1432,8 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
r_col[0] = facm * (r_col[0]) + fac * (((1.0f - r_col[0]) * col[0] * (r_col[0])) + (r_col[0] * scr));
r_col[1] = facm * (r_col[1]) + fac * (((1.0f - r_col[1]) * col[1] * (r_col[1])) + (r_col[1] * scg));
r_col[2] = facm * (r_col[2]) + fac * (((1.0f - r_col[2]) * col[2] * (r_col[2])) + (r_col[2] * scb));
+ break;
}
- break;
case MA_RAMP_LINEAR:
if (col[0] > 0.5f)
r_col[0] = r_col[0] + fac * (2.0f * (col[0] - 0.5f));
@@ -2051,8 +2004,10 @@ int do_version_tface(Main *main, int fileload)
printf("Warning: material \"%s\" skipped - to convert old game texface to material go to the Help menu.\n", ma->id.name + 2);
nowarning = 0;
}
- else
- convert_tfacematerial(main, ma); continue;
+ else {
+ convert_tfacematerial(main, ma);
+ }
+ continue;
}
/* no conflicts in this material - 90% of cases
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 31212c3a6b7..173b193b752 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -485,14 +485,15 @@ void BKE_mball_properties_copy(Scene *scene, Object *active_object)
MetaBall *active_mball = (MetaBall *)active_object->data;
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
-
+ SceneBaseIter iter;
+
BLI_split_name_num(basisname, &basisnr, active_object->id.name + 2, '.');
/* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
- if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
+ if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
return;
- while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
+ while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob != active_object) {
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
@@ -529,14 +530,15 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis)
Object *ob, *bob = basis;
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
+ SceneBaseIter iter;
BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.');
/* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
- if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
+ if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
return NULL;
- while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
+ while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob != bob) {
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
@@ -1644,6 +1646,14 @@ BLI_INLINE void copy_v3_fl3(float v[3], float x, float y, float z)
v[2] = z;
}
+/* TODO(sergey): Perhaps it could be general utility function in mathutils. */
+static bool has_zero_axis_m4(float matrix[4][4])
+{
+ return len_squared_v3(matrix[0]) < FLT_EPSILON ||
+ len_squared_v3(matrix[1]) < FLT_EPSILON ||
+ len_squared_v3(matrix[2]) < FLT_EPSILON;
+}
+
static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return totsize */
{
Scene *sce_iter = scene;
@@ -1655,7 +1665,8 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return
//float max = 0.0f;
int a, obnr, zero_size = 0;
char obname[MAX_ID_NAME];
-
+ SceneBaseIter iter;
+
copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from BKE_scene_base_iter_next */
invert_m4_m4(obinv, ob->obmat);
a = 0;
@@ -1663,8 +1674,8 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return
BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.');
/* make main array */
- BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL);
- while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &bob)) {
+ BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL);
+ while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &bob)) {
if (bob->type == OB_MBALL) {
zero_size = 0;
@@ -1691,13 +1702,13 @@ static float init_meta(PROCESS *process, Scene *scene, Object *ob) /* return
/* when metaball object has zero scale, then MetaElem to this MetaBall
* will not be put to mainb array */
- if (bob->size[0] == 0.0f || bob->size[1] == 0.0f || bob->size[2] == 0.0f) {
+ if (has_zero_axis_m4(bob->obmat)) {
zero_size = 1;
}
else if (bob->parent) {
struct Object *pob = bob->parent;
while (pob) {
- if (pob->size[0] == 0.0f || pob->size[1] == 0.0f || pob->size[2] == 0.0f) {
+ if (has_zero_axis_m4(pob->obmat)) {
zero_size = 1;
break;
}
@@ -2225,15 +2236,16 @@ static void mball_count(PROCESS *process, Scene *scene, Object *basis)
MetaElem *ml = NULL;
int basisnr, obnr;
char basisname[MAX_ID_NAME], obname[MAX_ID_NAME];
+ SceneBaseIter iter;
BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.');
process->totelem = 0;
/* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */
- if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL))
+ if (F_ERROR == BKE_scene_base_iter_next(&iter, &sce_iter, 0, NULL, NULL))
return;
- while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) {
+ while (BKE_scene_base_iter_next(&iter, &sce_iter, 1, &base, &ob)) {
if (ob->type == OB_MBALL) {
if (ob == bob) {
MetaBall *mb = ob->data;
@@ -2434,6 +2446,7 @@ bool BKE_mball_center_median(MetaBall *mb, float r_cent[3])
for (ml = mb->elems.first; ml; ml = ml->next) {
add_v3_v3(r_cent, &ml->x);
+ total++;
}
if (total) {
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index b40c3475df5..095957b40d5 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -51,6 +51,7 @@
#include "BLI_bitmap.h"
#include "BLI_scanfill.h"
#include "BLI_array.h"
+#include "BLI_alloca.h"
#include "BKE_animsys.h"
#include "BKE_main.h"
@@ -702,6 +703,19 @@ void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_siz
if (r_size) copy_v3_v3(r_size, me->size);
}
+void BKE_mesh_texspace_copy_from_object(Mesh *me, Object *ob)
+{
+ float *texloc, *texrot, *texsize;
+ short *texflag;
+
+ if (BKE_object_obdata_texspace_get(ob, &texflag, &texloc, &texsize, &texrot)) {
+ me->texflag = *texflag;
+ copy_v3_v3(me->loc, texloc);
+ copy_v3_v3(me->size, texsize);
+ copy_v3_v3(me->rot, texrot);
+ }
+}
+
float (*BKE_mesh_orco_verts_get(Object *ob))[3]
{
Mesh *me = ob->data;
@@ -2176,10 +2190,13 @@ static void bm_corners_to_loops_ex(ID *id, CustomData *fdata, CustomData *ldata,
if (ld->disps)
MEM_freeN(ld->disps);
- ld->disps = MEM_callocN(sizeof(float) * 3 * side * side, "converted loop mdisps");
+ ld->disps = MEM_mallocN(sizeof(float) * 3 * side * side, "converted loop mdisps");
if (fd->disps) {
memcpy(ld->disps, disps, sizeof(float) * 3 * side * side);
}
+ else {
+ memset(ld->disps, 0, sizeof(float) * 3 * side * side);
+ }
}
}
}
@@ -2450,10 +2467,11 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
int totvert, int totpoly, int totloop)
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert poly map");
- int *indices = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
-
+ int *indices, *index_iter;
int i, j;
+ indices = index_iter = MEM_mallocN(sizeof(int) * totloop, "vert poly map mem");
+
/* Count number of polys for each vertex */
for (i = 0; i < totpoly; i++) {
const MPoly *p = &mpoly[i];
@@ -2464,8 +2482,8 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
/* Assign indices mem */
for (i = 0; i < totvert; i++) {
- map[i].indices = indices;
- indices += map[i].count;
+ map[i].indices = index_iter;
+ index_iter += map[i].count;
/* Reset 'count' for use as index in last loop */
map[i].count = 0;
@@ -2495,6 +2513,7 @@ void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
{
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * totvert, "vert-edge map");
int *indices = MEM_mallocN(sizeof(int) * totedge * 2, "vert-edge map mem");
+ int *i_pt = indices;
int i;
@@ -2506,8 +2525,8 @@ void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
/* Assign indices mem */
for (i = 0; i < totvert; i++) {
- map[i].indices = indices;
- indices += map[i].count;
+ map[i].indices = i_pt;
+ i_pt += map[i].count;
/* Reset 'count' for use as index in last loop */
map[i].count = 0;
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 878651cdb39..2eced15a147 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -294,7 +294,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
# define CHECK_FACE_EDGE(a, b) \
if (!BLI_edgehash_haskey(edge_hash, mf->a, mf->b)) { \
PRINT(" face %u: edge " STRINGIFY(a) "/" STRINGIFY(b) \
- " (%u,%u) is missing egde data\n", i, mf->a, mf->b); \
+ " (%u,%u) is missing edge data\n", i, mf->a, mf->b); \
do_edge_recalc = TRUE; \
} (void)0
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index a0fa3317297..41e0acf9f7a 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -421,7 +421,7 @@ ModifierData *modifiers_getLastPreview(struct Scene *scene, ModifierData *md, in
{
ModifierData *tmp_md = NULL;
- if (required_mode != eModifierMode_Realtime)
+ if ((required_mode & ~eModifierMode_Editmode) != eModifierMode_Realtime)
return tmp_md;
/* Find the latest modifier in stack generating preview. */
diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c
index b7257028316..290b0684e40 100644
--- a/source/blender/blenkernel/intern/modifiers_bmesh.c
+++ b/source/blender/blenkernel/intern/modifiers_bmesh.c
@@ -28,16 +28,15 @@
* \ingroup bke
*/
-#include "BLI_math.h"
-
#include "MEM_guardedalloc.h"
+#include "BLI_math.h"
+#include "BLI_alloca.h"
+
#include "DNA_object_types.h"
-#include "BLI_array.h"
#include "BKE_DerivedMesh.h"
-#include "BKE_bmesh.h"
#include "BKE_editmesh.h"
/* Static function for alloc */
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index d062f302379..e8550e12e4f 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -440,7 +440,7 @@ static void *moviecache_getprioritydata(void *key_v)
MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *) key_v;
MovieClipCachePriorityData *priority_data;
- priority_data = MEM_callocN(sizeof(priority_data), "movie cache clip priority data");
+ priority_data = MEM_callocN(sizeof(*priority_data), "movie cache clip priority data");
priority_data->framenr = key->framenr;
return priority_data;
@@ -1395,8 +1395,6 @@ void BKE_movieclip_build_proxy_frame_for_ibuf(MovieClip *clip, ImBuf *ibuf, stru
void BKE_movieclip_free(MovieClip *clip)
{
- BKE_sequencer_clear_movieclip_in_clipboard(clip);
-
free_buffers(clip);
BKE_tracking_free(&clip->tracking);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index cba4c9206c9..95bf56d00f2 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -105,15 +105,15 @@ void multires_customdata_delete(Mesh *me)
}
/** Grid hiding **/
-static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden,
- int lo_level,
- int hi_level,
+static BLI_bitmap *multires_mdisps_upsample_hidden(BLI_bitmap *lo_hidden,
+ int lo_level,
+ int hi_level,
- /* assumed to be at hi_level (or
- * null) */
- BLI_bitmap prev_hidden)
+ /* assumed to be at hi_level (or
+ * null) */
+ BLI_bitmap *prev_hidden)
{
- BLI_bitmap subd;
+ BLI_bitmap *subd;
int hi_gridsize = ccg_gridsize(hi_level);
int lo_gridsize = ccg_gridsize(lo_level);
int yh, xh, xl, yl, xo, yo, hi_ndx;
@@ -168,11 +168,11 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden,
return subd;
}
-static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden,
- int old_level,
- int new_level)
+static BLI_bitmap *multires_mdisps_downsample_hidden(BLI_bitmap *old_hidden,
+ int old_level,
+ int new_level)
{
- BLI_bitmap new_hidden;
+ BLI_bitmap *new_hidden;
int new_gridsize = ccg_gridsize(new_level);
int old_gridsize = ccg_gridsize(old_level);
int x, y, factor, old_value;
@@ -200,7 +200,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm,
Mesh *me, int level)
{
const MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
- BLI_bitmap *grid_hidden = ccgdm->gridHidden;
+ BLI_bitmap **grid_hidden = ccgdm->gridHidden;
int *gridOffset;
int i, j;
@@ -210,7 +210,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm,
for (j = 0; j < me->mpoly[i].totloop; j++) {
int g = gridOffset[i] + j;
const MDisps *md = &mdisps[g];
- BLI_bitmap gh = md->hidden;
+ BLI_bitmap *gh = md->hidden;
if (gh) {
grid_hidden[g] =
@@ -224,7 +224,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm,
* the current level of md.hidden) */
static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level)
{
- BLI_bitmap subd;
+ BLI_bitmap *subd;
BLI_assert(md->hidden);
@@ -647,7 +647,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl)
multires_copy_grid(ndisps, hdisps, nsize, hsize);
if (mdisp->hidden) {
- BLI_bitmap gh =
+ BLI_bitmap *gh =
multires_mdisps_downsample_hidden(mdisp->hidden,
mdisp->level,
lvl);
@@ -1251,7 +1251,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm)
void multires_modifier_update_hidden(DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
- BLI_bitmap *grid_hidden = ccgdm->gridHidden;
+ BLI_bitmap **grid_hidden = ccgdm->gridHidden;
Mesh *me = ccgdm->multires.ob->data;
MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
int totlvl = ccgdm->multires.totlvl;
@@ -1262,7 +1262,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm)
for (i = 0; i < me->totloop; i++) {
MDisps *md = &mdisps[i];
- BLI_bitmap gh = grid_hidden[i];
+ BLI_bitmap *gh = grid_hidden[i];
if (!gh && md->hidden) {
MEM_freeN(md->hidden);
diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c
index 1d662ae3116..75e6ce9837d 100644
--- a/source/blender/blenkernel/intern/navmesh_conversion.c
+++ b/source/blender/blenkernel/intern/navmesh_conversion.c
@@ -440,6 +440,9 @@ int buildNavMeshDataByDerivedMesh(DerivedMesh *dm, int *vertsPerPoly,
int ntris = 0, *recastData = NULL;
unsigned short *tris = NULL;
+ /* Don't bother converting if there is nothing to convert */
+ if (!*nverts) return 0;
+
res = buildRawVertIndicesData(dm, nverts, verts, &ntris, &tris, trisToFacesMap, &recastData);
if (!res) {
printf("Converting navmesh: Error! Can't get vertices and indices from mesh\n");
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 929d741282e..5001aa01653 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -349,9 +349,6 @@ static void free_dynamic_typeinfo(bNodeType *ntype)
if (ntype->outputs) {
MEM_freeN(ntype->outputs);
}
- if (ntype->ui_name) {
- MEM_freeN((void *)ntype->ui_name);
- }
}
}
@@ -528,60 +525,60 @@ bNodeSocket *nodeInsertSocket(bNodeTree *ntree, bNode *node, int in_out, const c
const char *nodeStaticSocketType(int type, int subtype)
{
switch (type) {
- case SOCK_FLOAT:
- switch (subtype) {
- case PROP_UNSIGNED:
- return "NodeSocketFloatUnsigned";
- case PROP_PERCENTAGE:
- return "NodeSocketFloatPercentage";
- case PROP_FACTOR:
- return "NodeSocketFloatFactor";
- case PROP_ANGLE:
- return "NodeSocketFloatAngle";
- case PROP_TIME:
- return "NodeSocketFloatTime";
- case PROP_NONE:
- default:
- return "NodeSocketFloat";
- }
- case SOCK_INT:
- switch (subtype) {
- case PROP_UNSIGNED:
- return "NodeSocketIntUnsigned";
- case PROP_PERCENTAGE:
- return "NodeSocketIntPercentage";
- case PROP_FACTOR:
- return "NodeSocketIntFactor";
- case PROP_NONE:
- default:
- return "NodeSocketInt";
- }
- case SOCK_BOOLEAN:
- return "NodeSocketBool";
- case SOCK_VECTOR:
- switch (subtype) {
- case PROP_TRANSLATION:
- return "NodeSocketVectorTranslation";
- case PROP_DIRECTION:
- return "NodeSocketVectorDirection";
- case PROP_VELOCITY:
- return "NodeSocketVectorVelocity";
- case PROP_ACCELERATION:
- return "NodeSocketVectorAcceleration";
- case PROP_EULER:
- return "NodeSocketVectorEuler";
- case PROP_XYZ:
- return "NodeSocketVectorXYZ";
- case PROP_NONE:
- default:
- return "NodeSocketVector";
- }
- case SOCK_RGBA:
- return "NodeSocketColor";
- case SOCK_STRING:
- return "NodeSocketString";
- case SOCK_SHADER:
- return "NodeSocketShader";
+ case SOCK_FLOAT:
+ switch (subtype) {
+ case PROP_UNSIGNED:
+ return "NodeSocketFloatUnsigned";
+ case PROP_PERCENTAGE:
+ return "NodeSocketFloatPercentage";
+ case PROP_FACTOR:
+ return "NodeSocketFloatFactor";
+ case PROP_ANGLE:
+ return "NodeSocketFloatAngle";
+ case PROP_TIME:
+ return "NodeSocketFloatTime";
+ case PROP_NONE:
+ default:
+ return "NodeSocketFloat";
+ }
+ case SOCK_INT:
+ switch (subtype) {
+ case PROP_UNSIGNED:
+ return "NodeSocketIntUnsigned";
+ case PROP_PERCENTAGE:
+ return "NodeSocketIntPercentage";
+ case PROP_FACTOR:
+ return "NodeSocketIntFactor";
+ case PROP_NONE:
+ default:
+ return "NodeSocketInt";
+ }
+ case SOCK_BOOLEAN:
+ return "NodeSocketBool";
+ case SOCK_VECTOR:
+ switch (subtype) {
+ case PROP_TRANSLATION:
+ return "NodeSocketVectorTranslation";
+ case PROP_DIRECTION:
+ return "NodeSocketVectorDirection";
+ case PROP_VELOCITY:
+ return "NodeSocketVectorVelocity";
+ case PROP_ACCELERATION:
+ return "NodeSocketVectorAcceleration";
+ case PROP_EULER:
+ return "NodeSocketVectorEuler";
+ case PROP_XYZ:
+ return "NodeSocketVectorXYZ";
+ case PROP_NONE:
+ default:
+ return "NodeSocketVector";
+ }
+ case SOCK_RGBA:
+ return "NodeSocketColor";
+ case SOCK_STRING:
+ return "NodeSocketString";
+ case SOCK_SHADER:
+ return "NodeSocketShader";
}
return NULL;
}
@@ -589,60 +586,60 @@ const char *nodeStaticSocketType(int type, int subtype)
const char *nodeStaticSocketInterfaceType(int type, int subtype)
{
switch (type) {
- case SOCK_FLOAT:
- switch (subtype) {
- case PROP_UNSIGNED:
- return "NodeSocketInterfaceFloatUnsigned";
- case PROP_PERCENTAGE:
- return "NodeSocketInterfaceFloatPercentage";
- case PROP_FACTOR:
- return "NodeSocketInterfaceFloatFactor";
- case PROP_ANGLE:
- return "NodeSocketInterfaceFloatAngle";
- case PROP_TIME:
- return "NodeSocketInterfaceFloatTime";
- case PROP_NONE:
- default:
- return "NodeSocketInterfaceFloat";
- }
- case SOCK_INT:
- switch (subtype) {
- case PROP_UNSIGNED:
- return "NodeSocketInterfaceIntUnsigned";
- case PROP_PERCENTAGE:
- return "NodeSocketInterfaceIntPercentage";
- case PROP_FACTOR:
- return "NodeSocketInterfaceIntFactor";
- case PROP_NONE:
- default:
- return "NodeSocketInterfaceInt";
- }
- case SOCK_BOOLEAN:
- return "NodeSocketInterfaceBool";
- case SOCK_VECTOR:
- switch (subtype) {
- case PROP_TRANSLATION:
- return "NodeSocketInterfaceVectorTranslation";
- case PROP_DIRECTION:
- return "NodeSocketInterfaceVectorDirection";
- case PROP_VELOCITY:
- return "NodeSocketInterfaceVectorVelocity";
- case PROP_ACCELERATION:
- return "NodeSocketInterfaceVectorAcceleration";
- case PROP_EULER:
- return "NodeSocketInterfaceVectorEuler";
- case PROP_XYZ:
- return "NodeSocketInterfaceVectorXYZ";
- case PROP_NONE:
- default:
- return "NodeSocketInterfaceVector";
- }
- case SOCK_RGBA:
- return "NodeSocketInterfaceColor";
- case SOCK_STRING:
- return "NodeSocketInterfaceString";
- case SOCK_SHADER:
- return "NodeSocketInterfaceShader";
+ case SOCK_FLOAT:
+ switch (subtype) {
+ case PROP_UNSIGNED:
+ return "NodeSocketInterfaceFloatUnsigned";
+ case PROP_PERCENTAGE:
+ return "NodeSocketInterfaceFloatPercentage";
+ case PROP_FACTOR:
+ return "NodeSocketInterfaceFloatFactor";
+ case PROP_ANGLE:
+ return "NodeSocketInterfaceFloatAngle";
+ case PROP_TIME:
+ return "NodeSocketInterfaceFloatTime";
+ case PROP_NONE:
+ default:
+ return "NodeSocketInterfaceFloat";
+ }
+ case SOCK_INT:
+ switch (subtype) {
+ case PROP_UNSIGNED:
+ return "NodeSocketInterfaceIntUnsigned";
+ case PROP_PERCENTAGE:
+ return "NodeSocketInterfaceIntPercentage";
+ case PROP_FACTOR:
+ return "NodeSocketInterfaceIntFactor";
+ case PROP_NONE:
+ default:
+ return "NodeSocketInterfaceInt";
+ }
+ case SOCK_BOOLEAN:
+ return "NodeSocketInterfaceBool";
+ case SOCK_VECTOR:
+ switch (subtype) {
+ case PROP_TRANSLATION:
+ return "NodeSocketInterfaceVectorTranslation";
+ case PROP_DIRECTION:
+ return "NodeSocketInterfaceVectorDirection";
+ case PROP_VELOCITY:
+ return "NodeSocketInterfaceVectorVelocity";
+ case PROP_ACCELERATION:
+ return "NodeSocketInterfaceVectorAcceleration";
+ case PROP_EULER:
+ return "NodeSocketInterfaceVectorEuler";
+ case PROP_XYZ:
+ return "NodeSocketInterfaceVectorXYZ";
+ case PROP_NONE:
+ default:
+ return "NodeSocketInterfaceVector";
+ }
+ case SOCK_RGBA:
+ return "NodeSocketInterfaceColor";
+ case SOCK_STRING:
+ return "NodeSocketInterfaceString";
+ case SOCK_SHADER:
+ return "NodeSocketInterfaceShader";
}
return NULL;
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index f1183868e8b..8ac067c0316 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -121,9 +121,6 @@
#include "GPU_material.h"
-/* Local function protos */
-float originmat[3][3]; /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */
-
void BKE_object_workob_clear(Object *workob)
{
memset(workob, 0, sizeof(Object));
@@ -696,6 +693,14 @@ void BKE_object_unlink(Object *ob)
sbuts->pinid = NULL;
}
}
+ else if (sl->spacetype == SPACE_NODE) {
+ SpaceNode *snode = (SpaceNode *)sl;
+
+ if (snode->from == (ID *)ob) {
+ snode->flag &= ~SNODE_PIN;
+ snode->from = NULL;
+ }
+ }
}
sa = sa->next;
@@ -1592,13 +1597,15 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat)
normalize_qt_qt(dquat, ob->dquat);
invert_qt(dquat);
mul_qt_qtqt(ob->quat, dquat, ob->quat);
+ break;
}
- break;
case ROT_MODE_AXISANGLE:
+ {
mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat);
sub_v3_v3(ob->rotAxis, ob->drotAxis);
ob->rotAngle -= ob->drotAngle;
break;
+ }
default: /* euler */
{
float quat[4];
@@ -1615,6 +1622,7 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat)
if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
else mat3_to_eulO(ob->rot, ob->rotmode, tmat);
+ break;
}
}
}
@@ -1739,6 +1747,18 @@ void BKE_object_to_mat4(Object *ob, float mat[4][4])
add_v3_v3v3(mat[3], ob->loc, ob->dloc);
}
+void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
+{
+ if (ob->parent) {
+ float invmat[4][4]; /* for inverse of parent's matrix */
+ invert_m4_m4(invmat, ob->parent->obmat);
+ mul_m4_m4m4(mat, invmat, ob->obmat);
+ }
+ else {
+ copy_m4_m4(mat, ob->obmat);
+ }
+}
+
/* extern */
int enable_cu_speed = 1;
@@ -1991,7 +2011,11 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4])
}
}
-static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4], int simul)
+/**
+ * \param r_originmat Optional matrix that stores the space the object is in (without its own matrix applied)
+ */
+static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4],
+ float r_originmat[3][3], const bool simul)
{
float totmat[4][4];
float tmat[4][4];
@@ -2056,8 +2080,10 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4
}
else {
- /* external usable originmat */
- copy_m3_m4(originmat, tmat);
+ if (r_originmat) {
+ /* usable originmat */
+ copy_m3_m4(r_originmat, tmat);
+ }
/* origin, for help line */
if ((ob->partype & PARTYPE) == PARSKEL) {
@@ -2091,7 +2117,7 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[
/* note, scene is the active scene while actual_scene is the scene the object resides in */
void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
- RigidBodyWorld *rbw)
+ RigidBodyWorld *rbw, float r_originmat[3][3])
{
if (ob == NULL) return;
@@ -2103,7 +2129,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
float slowmat[4][4] = MAT4_UNITY;
/* calculate parent matrix */
- solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
+ solve_parenting(scene, ob, par, ob->obmat, slowmat, r_originmat, false);
/* "slow parent" is definitely not threadsafe, and may also give bad results jumping around
* An old-fashioned hack which probably doesn't really cut it anymore
@@ -2138,7 +2164,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime,
void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
{
- BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL);
+ BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL, NULL);
}
/* get object transformation matrix without recalculating dependencies and
@@ -2152,7 +2178,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
if (ob->parent) {
Object *par = ob->parent;
- solve_parenting(scene, ob, par, obmat, slowmat, 1);
+ solve_parenting(scene, ob, par, obmat, slowmat, NULL, true);
if (ob->partype & PARSLOW)
where_is_object_parslow(ob, obmat, slowmat);
@@ -2162,13 +2188,13 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
}
}
-void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob)
+void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3])
{
- BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw);
+ BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat);
}
void BKE_object_where_is_calc(Scene *scene, Object *ob)
{
- BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL);
+ BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL, NULL);
}
/* was written for the old game engine (until 2.04) */
@@ -2186,7 +2212,7 @@ void BKE_object_where_is_calc_simul(Scene *scene, Object *ob)
if (ob->parent) {
par = ob->parent;
- solve_parenting(scene, ob, par, ob->obmat, slowmat, 1);
+ solve_parenting(scene, ob, par, ob->obmat, slowmat, NULL, true);
if (ob->partype & PARSLOW) {
fac1 = (float)(1.0 / (1.0 + fabs(ob->sf)));
@@ -2342,8 +2368,9 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
/* Use the object bounding box so that modifier output
* gets taken into account */
- if (ob->bb)
+ if (ob->bb) {
bb = *(ob->bb);
+ }
else {
if (cu->bb == NULL)
BKE_curve_texspace_calc(cu);
@@ -2355,8 +2382,8 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
minmax_v3v3_v3(min_r, max_r, bb.vec[a]);
}
change = TRUE;
+ break;
}
- break;
case OB_LATTICE:
{
Lattice *lt = ob->data;
@@ -2372,9 +2399,10 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
}
}
change = TRUE;
+ break;
}
- break;
case OB_ARMATURE:
+ {
if (ob->pose) {
bArmature *arm = ob->data;
bPoseChannel *pchan;
@@ -2393,6 +2421,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
}
}
break;
+ }
case OB_MESH:
{
Mesh *me = BKE_mesh_from_object(ob);
@@ -2406,8 +2435,8 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
}
change = TRUE;
}
+ break;
}
- break;
case OB_MBALL:
{
float ob_min[3], ob_max[3];
@@ -2658,7 +2687,7 @@ void BKE_object_handle_update_ex(Scene *scene, Object *ob,
copy_m4_m4(ob->obmat, ob->proxy_from->obmat);
}
else
- BKE_object_where_is_calc_ex(scene, rbw, ob);
+ BKE_object_where_is_calc_ex(scene, rbw, ob, NULL);
}
if (ob->recalc & OB_RECALC_DATA) {
@@ -2706,10 +2735,8 @@ void BKE_object_handle_update_ex(Scene *scene, Object *ob,
makeDerivedMesh(scene, ob, NULL, data_mask, 0);
}
#endif
-
+ break;
}
- break;
-
case OB_ARMATURE:
if (ob->id.lib && ob->proxy_from) {
if (BKE_pose_copy_result(ob->pose, ob->proxy_from->pose) == false) {
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index f97429d7e65..11d58c945fd 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -85,6 +85,7 @@ int seekPackedFile(PackedFile *pf, int offset, int whence)
break;
default:
oldseek = -1;
+ break;
}
if (seek < 0) {
seek = 0;
@@ -448,7 +449,8 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
temp = local_name;
break;
}
- /* else fall through and create it */
+ /* else create it */
+ /* fall-through */
case PF_WRITE_LOCAL:
if (writePackedFile(reports, local_name, pf, 1) == RET_OK) {
temp = local_name;
@@ -461,7 +463,8 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
temp = abs_name;
break;
}
- /* else fall through and create it */
+ /* else create it */
+ /* fall-through */
case PF_WRITE_ORIGINAL:
if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) {
temp = abs_name;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 0dbe4c56a09..b47a493581e 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -139,8 +139,7 @@ Paint *BKE_paint_get_active(Scene *sce)
case OB_MODE_EDIT:
if (ts->use_uv_sculpt)
return &ts->uvsculpt->paint;
- else
- return &ts->imapaint.paint;
+ return &ts->imapaint.paint;
}
}
@@ -187,8 +186,7 @@ Paint *BKE_paint_get_active_from_context(const bContext *C)
case OB_MODE_EDIT:
if (ts->use_uv_sculpt)
return &ts->uvsculpt->paint;
- else
- return &ts->imapaint.paint;
+ return &ts->imapaint.paint;
default:
return &ts->imapaint.paint;
}
@@ -238,8 +236,7 @@ PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
case OB_MODE_EDIT:
if (ts->use_uv_sculpt)
return PAINT_SCULPT_UV;
- else
- return PAINT_TEXTURE_2D;
+ return PAINT_TEXTURE_2D;
default:
return PAINT_TEXTURE_2D;
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index f6901c7b81b..6bea4bec3ce 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3414,8 +3414,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m
OrigSpaceFace *osface;
float (*orcodata)[3];
- int i = pa->num_dmcache == DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache;
-
+ int i = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? pa->num : pa->num_dmcache;
if (i == -1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; }
mface = dm->getTessFaceData(dm, i, CD_MFACE);
@@ -4511,7 +4510,7 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part,
num = DMCACHE_NOTFOUND;
}
- if (mtface && num != DMCACHE_NOTFOUND) {
+ if (mtface && !ELEM(num, DMCACHE_NOTFOUND, DMCACHE_ISCHILD)) {
mface = psmd->dm->getTessFaceData(psmd->dm, num, CD_MFACE);
mtface += num;
psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 9840852ad7e..16ea71204cc 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1660,17 +1660,22 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
{
Object *ob = sim->ob;
ParticleSystem *psys = sim->psys;
- ParticleSettings *part;
+ ParticleSettings *part = psys->part;
ParticleTexture ptex;
float fac, phasefac, nor[3] = {0,0,0},loc[3],vel[3] = {0.0,0.0,0.0},rot[4],q2[4];
float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3] = {0.0,0.0,0.0};
float x_vec[3] = {1.0,0.0,0.0}, utan[3] = {0.0,1.0,0.0}, vtan[3] = {0.0,0.0,1.0}, rot_vec[3] = {0.0,0.0,0.0};
float q_phase[4];
+
+ const bool use_boids = ((part->phystype == PART_PHYS_BOIDS) &&
+ (pa->boid != NULL));
+ const bool use_tangents = ((use_boids == false) &&
+ ((part->tanfac != 0.0f) || (part->rotmode == PART_ROT_NOR_TAN)));
+
int p = pa - psys->particles;
- part=psys->part;
/* get birth location from object */
- if (part->tanfac != 0.f)
+ if (use_tangents)
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0);
else
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0);
@@ -1688,7 +1693,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
normalize_v3(nor);
/* -tangent */
- if (part->tanfac!=0.0f) {
+ if (use_tangents) {
//float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
float phase=0.0f;
mul_v3_fl(vtan,-cosf((float)M_PI*(part->tanphase+phase)));
@@ -1737,7 +1742,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
mul_qt_qtqt(r_rot,r_rot,rot);
}
- if (part->phystype==PART_PHYS_BOIDS && pa->boid) {
+ if (use_boids) {
float dvec[3], q[4], mat[3][3];
copy_v3_v3(state->co,loc);
@@ -1823,35 +1828,112 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
unit_qt(state->rot);
if (part->rotmode) {
+ bool use_global_space;
+
/* create vector into which rotation is aligned */
switch (part->rotmode) {
case PART_ROT_NOR:
+ case PART_ROT_NOR_TAN:
copy_v3_v3(rot_vec, nor);
+ use_global_space = false;
break;
case PART_ROT_VEL:
copy_v3_v3(rot_vec, vel);
+ use_global_space = true;
break;
case PART_ROT_GLOB_X:
case PART_ROT_GLOB_Y:
case PART_ROT_GLOB_Z:
rot_vec[part->rotmode - PART_ROT_GLOB_X] = 1.0f;
+ use_global_space = true;
break;
case PART_ROT_OB_X:
case PART_ROT_OB_Y:
case PART_ROT_OB_Z:
copy_v3_v3(rot_vec, ob->obmat[part->rotmode - PART_ROT_OB_X]);
+ use_global_space = false;
+ break;
+ default:
+ use_global_space = true;
break;
}
/* create rotation quat */
- negate_v3(rot_vec);
- vec_to_quat( q2,rot_vec, OB_POSX, OB_POSZ);
- /* randomize rotation quat */
- if (part->randrotfac!=0.0f)
- interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
- else
- copy_qt_qt(rot,q2);
+
+ if (use_global_space) {
+ negate_v3(rot_vec);
+ vec_to_quat(q2, rot_vec, OB_POSX, OB_POSZ);
+
+ /* randomize rotation quat */
+ if (part->randrotfac != 0.0f) {
+ interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
+ }
+ else {
+ copy_qt_qt(rot, q2);
+ }
+ }
+ else {
+ /* calculate rotation in local-space */
+ float q_obmat[4];
+ float q_imat[4];
+
+ mat4_to_quat(q_obmat, ob->obmat);
+ invert_qt_qt(q_imat, q_obmat);
+
+
+ if (part->rotmode != PART_ROT_NOR_TAN) {
+ float rot_vec_local[3];
+
+ /* rot_vec */
+ negate_v3(rot_vec);
+ copy_v3_v3(rot_vec_local, rot_vec);
+ mul_qt_v3(q_imat, rot_vec_local);
+ normalize_v3(rot_vec_local);
+
+ vec_to_quat(q2, rot_vec_local, OB_POSX, OB_POSZ);
+ }
+ else {
+ /* (part->rotmode == PART_ROT_NOR_TAN) */
+ float tmat[3][3];
+
+ /* note: utan_local is not taken from 'utan', we calculate from rot_vec/vtan */
+ /* note: it looks like rotation phase may be applied twice (once with vtan, again below)
+ * however this isn't the case - campbell */
+ float *rot_vec_local = tmat[0];
+ float *vtan_local = tmat[1];
+ float *utan_local = tmat[2];
+
+ /* use tangents */
+ BLI_assert(use_tangents == true);
+
+ /* rot_vec */
+ copy_v3_v3(rot_vec_local, rot_vec);
+ mul_qt_v3(q_imat, rot_vec_local);
+
+ /* vtan_local */
+ copy_v3_v3(vtan_local, vtan); /* flips, cant use */
+ mul_qt_v3(q_imat, vtan_local);
+
+ /* ensure orthogonal matrix (rot_vec aligned) */
+ cross_v3_v3v3(utan_local, vtan_local, rot_vec_local);
+ cross_v3_v3v3(vtan_local, utan_local, rot_vec_local);
+
+ /* note: no need to normalize */
+ mat3_to_quat(q2, tmat);
+ }
+
+ /* randomize rotation quat */
+ if (part->randrotfac != 0.0f) {
+ mul_qt_qtqt(r_rot, r_rot, q_imat);
+ interp_qt_qtqt(rot, q2, r_rot, part->randrotfac);
+ }
+ else {
+ copy_qt_qt(rot, q2);
+ }
+
+ mul_qt_qtqt(rot, q_obmat, rot);
+ }
/* rotation phase */
phasefac = part->phasefac;
@@ -4313,7 +4395,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* SPH_SOLVER_CLASSICAL */
/* Apply SPH forces using classical algorithm (due to Gingold
* and Monaghan). Note that, unlike double-density relaxation,
- * this algorthim is separated into distinct loops. */
+ * this algorithm is separated into distinct loops. */
#pragma omp parallel for firstprivate (sphdata) private (pa) schedule(dynamic,5)
LOOP_DYNAMIC_PARTICLES {
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 99e6e898685..a0cc37dcf3f 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -538,7 +538,7 @@ void BKE_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, int
/* Do a full rebuild with on Grids data structure */
void BKE_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj,
- int totgrid, CCGKey *key, void **gridfaces, DMFlagMat *flagmats, BLI_bitmap *grid_hidden)
+ int totgrid, CCGKey *key, void **gridfaces, DMFlagMat *flagmats, BLI_bitmap **grid_hidden)
{
BBC *prim_bbc = NULL;
BB cb;
@@ -1253,7 +1253,7 @@ void BKE_pbvh_bounding_box(const PBVH *bvh, float min[3], float max[3])
}
}
-BLI_bitmap *BKE_pbvh_grid_hidden(const PBVH *bvh)
+BLI_bitmap **BKE_pbvh_grid_hidden(const PBVH *bvh)
{
BLI_assert(bvh->type == PBVH_GRIDS);
return bvh->grid_hidden;
@@ -1469,7 +1469,7 @@ static int pbvh_grids_node_raycast(PBVH *bvh, PBVHNode *node,
for (i = 0; i < totgrid; ++i) {
CCGElem *grid = bvh->grids[node->prim_indices[i]];
- BLI_bitmap gh;
+ BLI_bitmap *gh;
if (!grid)
continue;
@@ -1664,7 +1664,7 @@ void BKE_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3],
}
void BKE_pbvh_grids_update(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, void **gridfaces,
- DMFlagMat *flagmats, BLI_bitmap *grid_hidden)
+ DMFlagMat *flagmats, BLI_bitmap **grid_hidden)
{
int a;
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index c6a5552dbf7..cd21f8ad968 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -294,7 +294,7 @@ static BMVert *pbvh_bmesh_vert_create(PBVH *bvh, int node_index,
static BMFace *pbvh_bmesh_face_create(PBVH *bvh, int node_index,
BMVert *v_tri[3], BMEdge *e_tri[3],
- const BMFace *UNUSED(example))
+ const BMFace *f_example)
{
BMFace *f;
void *val = SET_INT_IN_POINTER(node_index);
@@ -302,9 +302,10 @@ static BMFace *pbvh_bmesh_face_create(PBVH *bvh, int node_index,
/* ensure we never add existing face */
BLI_assert(BM_face_exists(v_tri, 3, NULL) == false);
- /* Note: passing NULL for the 'example' parameter, profiling shows
- * a small performance bump */
f = BM_face_create(bvh->bm, v_tri, e_tri, 3, 0);
+ // BM_elem_attrs_copy(bvh->bm, bvh->bm, f_example, f);
+ f->mat_nr = f_example->mat_nr;
+
if (!BLI_ghash_haskey(bvh->bm_face_to_node, f)) {
BLI_ghash_insert(bvh->nodes[node_index].bm_faces, f, NULL);
diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h
index b3f7bf6e3d1..4154b8e4799 100644
--- a/source/blender/blenkernel/intern/pbvh_intern.h
+++ b/source/blender/blenkernel/intern/pbvh_intern.h
@@ -139,11 +139,11 @@ struct PBVH {
void **gridfaces;
const DMFlagMat *grid_flag_mats;
int totgrid;
- BLI_bitmap *grid_hidden;
+ BLI_bitmap **grid_hidden;
/* Only used during BVH build and update,
* don't need to remain valid after */
- BLI_bitmap vert_bitmap;
+ BLI_bitmap *vert_bitmap;
#ifdef PERFCNTRS
int perf_modified;
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 6f77d63d90f..41b9734315d 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -268,8 +268,9 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfr
PTCACHE_DATA_FROM(data, BPHYS_DATA_SIZE, &pa->size);
PTCACHE_DATA_FROM(data, BPHYS_DATA_TIMES, times);
- if (boid)
+ if (boid) {
PTCACHE_DATA_FROM(data, BPHYS_DATA_BOIDS, &boid->data);
+ }
/* return flag 1+1=2 for newly born particles to copy exact birth location to previously cached frame */
return 1 + (pa->state.time >= pa->time && pa->prev_state.time <= pa->time);
@@ -304,8 +305,9 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf
else if (cfra > pa->dietime)
pa->state.time = pa->dietime;
- if (data[BPHYS_DATA_SIZE])
+ if (data[BPHYS_DATA_SIZE]) {
PTCACHE_DATA_TO(data, BPHYS_DATA_SIZE, 0, &pa->size);
+ }
if (data[BPHYS_DATA_TIMES]) {
float times[3];
@@ -926,7 +928,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
/* version header */
ptcache_file_read(pf, version, 1, sizeof(char) * 4);
if (strncmp(version, DPAINT_CACHE_VERSION, 4)) {
- printf("Dynamic Paint: Invalid cache version: %s!\n", version);
+ printf("Dynamic Paint: Invalid cache version: '%c%c%c%c'!\n", UNPACK4(version));
return 0;
}
@@ -2800,7 +2802,7 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode)
smokeModifier_reset_turbulence(pid->calldata);
#endif
else if (pid->type == PTCACHE_TYPE_DYNAMICPAINT)
- dynamicPaint_clearSurface((DynamicPaintSurface*)pid->calldata);
+ dynamicPaint_clearSurface(scene, (DynamicPaintSurface*)pid->calldata);
}
if (clear)
BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0);
diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c
index ec23a7db8a1..73f2a864e32 100644
--- a/source/blender/blenkernel/intern/property.c
+++ b/source/blender/blenkernel/intern/property.c
@@ -177,9 +177,9 @@ void BKE_bproperty_unique(bProperty *first, bProperty *prop, int force)
i = 0;
do { /* ensure we have enough chars for the new number in the name */
- BLI_snprintf(num, sizeof(num), "%d", i++);
- BLI_strncpy(new_name, base_name, sizeof(prop->name) - strlen(num));
- strcat(new_name, num);
+ const size_t num_len = BLI_snprintf(num, sizeof(num), "%d", i++);
+ BLI_snprintf(new_name, sizeof(prop->name),
+ "%.*s%s", (int)(sizeof(prop->name) - num_len), base_name, num);
} while (bproperty_get(first, prop, new_name));
BLI_strncpy(prop->name, new_name, sizeof(prop->name));
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 9ddf0cd2d68..f3276992381 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -288,18 +288,18 @@ static rbCollisionShape *rigidbody_get_shape_trimesh_from_mesh(Object *ob)
for (i = 0; (i < totface) && (mface) && (mvert); i++, mface++) {
/* add first triangle - verts 1,2,3 */
{
- MVert *va = (IN_RANGE(mface->v1, 0, totvert)) ? (mvert + mface->v1) : (mvert);
- MVert *vb = (IN_RANGE(mface->v2, 0, totvert)) ? (mvert + mface->v2) : (mvert);
- MVert *vc = (IN_RANGE(mface->v3, 0, totvert)) ? (mvert + mface->v3) : (mvert);
+ MVert *va = (mface->v1 < totvert) ? (mvert + mface->v1) : (mvert);
+ MVert *vb = (mface->v2 < totvert) ? (mvert + mface->v2) : (mvert);
+ MVert *vc = (mface->v3 < totvert) ? (mvert + mface->v3) : (mvert);
RB_trimesh_add_triangle(mdata, va->co, vb->co, vc->co);
}
/* add second triangle if needed - verts 1,3,4 */
if (mface->v4) {
- MVert *va = (IN_RANGE(mface->v1, 0, totvert)) ? (mvert + mface->v1) : (mvert);
- MVert *vb = (IN_RANGE(mface->v3, 0, totvert)) ? (mvert + mface->v3) : (mvert);
- MVert *vc = (IN_RANGE(mface->v4, 0, totvert)) ? (mvert + mface->v4) : (mvert);
+ MVert *va = (mface->v1 < totvert) ? (mvert + mface->v1) : (mvert);
+ MVert *vb = (mface->v3 < totvert) ? (mvert + mface->v3) : (mvert);
+ MVert *vc = (mface->v4 < totvert) ? (mvert + mface->v4) : (mvert);
RB_trimesh_add_triangle(mdata, va->co, vb->co, vc->co);
}
@@ -602,7 +602,7 @@ void BKE_rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, shor
RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, rbc->spring_damping_z);
RB_constraint_set_equilibrium_6dof_spring(rbc->physics_constraint);
- /* fall through */
+ /* fall-through */
case RBC_TYPE_6DOF:
if (rbc->type == RBC_TYPE_6DOF) /* a litte awkward but avoids duplicate code for limits */
rbc->physics_constraint = RB_constraint_new_6dof(loc, rot, rb1, rb2);
@@ -914,12 +914,10 @@ void BKE_rigidbody_remove_object(Scene *scene, Object *ob)
if (obt && obt->rigidbody_constraint) {
rbc = obt->rigidbody_constraint;
if (rbc->ob1 == ob) {
- rbc->ob1 = NULL;
- rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
+ BKE_rigidbody_remove_constraint(scene, obt);
}
if (rbc->ob2 == ob) {
- rbc->ob2 = NULL;
- rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
+ BKE_rigidbody_remove_constraint(scene, obt);
}
}
}
@@ -938,10 +936,9 @@ void BKE_rigidbody_remove_constraint(Scene *scene, Object *ob)
RigidBodyWorld *rbw = scene->rigidbody_world;
RigidBodyCon *rbc = ob->rigidbody_constraint;
- if (rbw) {
- /* remove from rigidbody world, free object won't do this */
- if (rbw && rbw->physics_world && rbc->physics_constraint)
- RB_dworld_remove_constraint(rbw->physics_world, rbc->physics_constraint);
+ /* remove from rigidbody world, free object won't do this */
+ if (rbw && rbw->physics_world && rbc->physics_constraint) {
+ RB_dworld_remove_constraint(rbw->physics_world, rbc->physics_constraint);
}
/* remove object's settings */
BKE_rigidbody_free_constraint(ob);
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 26563afa65b..1874523dac9 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -684,12 +684,9 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
}
}
- /* sort baselist */
- DAG_scene_relations_rebuild(bmain, scene);
-
- /* ensure dags are built for sets */
+ /* sort baselist for scene and sets */
for (sce = scene; sce; sce = sce->set)
- DAG_scene_relations_update(bmain, sce);
+ DAG_scene_relations_rebuild(bmain, sce);
/* copy layers and flags from bases to objects */
for (base = scene->base.first; base; base = base->next) {
@@ -746,17 +743,16 @@ void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce)
/* used by metaballs
* doesn't return the original duplicated object, only dupli's
*/
-int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
+int BKE_scene_base_iter_next(SceneBaseIter *iter, Scene **scene, int val, Base **base, Object **ob)
{
- static ListBase *duplilist = NULL;
- static DupliObject *dupob;
- static int fase = F_START, in_next_object = 0;
+ static int in_next_object = 0;
int run_again = 1;
/* init */
if (val == 0) {
- fase = F_START;
- dupob = NULL;
+ iter->fase = F_START;
+ iter->dupob = NULL;
+ iter->duplilist = NULL;
/* XXX particle systems with metas+dupligroups call this recursively */
/* see bug #18725 */
@@ -774,11 +770,11 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
run_again = 0;
/* the first base */
- if (fase == F_START) {
+ if (iter->fase == F_START) {
*base = (*scene)->base.first;
if (*base) {
*ob = (*base)->object;
- fase = F_SCENE;
+ iter->fase = F_SCENE;
}
else {
/* exception: empty scene */
@@ -787,20 +783,20 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
if ((*scene)->base.first) {
*base = (*scene)->base.first;
*ob = (*base)->object;
- fase = F_SCENE;
+ iter->fase = F_SCENE;
break;
}
}
}
}
else {
- if (*base && fase != F_DUPLI) {
+ if (*base && iter->fase != F_DUPLI) {
*base = (*base)->next;
if (*base) {
*ob = (*base)->object;
}
else {
- if (fase == F_SCENE) {
+ if (iter->fase == F_SCENE) {
/* (*scene) is finished, now do the set */
while ((*scene)->set) {
(*scene) = (*scene)->set;
@@ -816,45 +812,45 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
}
if (*base == NULL) {
- fase = F_START;
+ iter->fase = F_START;
}
else {
- if (fase != F_DUPLI) {
+ if (iter->fase != F_DUPLI) {
if ( (*base)->object->transflag & OB_DUPLI) {
/* groups cannot be duplicated for mballs yet,
* this enters eternal loop because of
* makeDispListMBall getting called inside of group_duplilist */
if ((*base)->object->dup_group == NULL) {
- duplilist = object_duplilist((*scene), (*base)->object, FALSE);
+ iter->duplilist = object_duplilist((*scene), (*base)->object, FALSE);
- dupob = duplilist->first;
+ iter->dupob = iter->duplilist->first;
- if (!dupob)
- free_object_duplilist(duplilist);
+ if (!iter->dupob)
+ free_object_duplilist(iter->duplilist);
}
}
}
/* handle dupli's */
- if (dupob) {
+ if (iter->dupob) {
- copy_m4_m4(dupob->ob->obmat, dupob->mat);
+ copy_m4_m4(iter->dupob->ob->obmat, iter->dupob->mat);
(*base)->flag |= OB_FROMDUPLI;
- *ob = dupob->ob;
- fase = F_DUPLI;
+ *ob = iter->dupob->ob;
+ iter->fase = F_DUPLI;
- dupob = dupob->next;
+ iter->dupob = iter->dupob->next;
}
- else if (fase == F_DUPLI) {
- fase = F_SCENE;
+ else if (iter->fase == F_DUPLI) {
+ iter->fase = F_SCENE;
(*base)->flag &= ~OB_FROMDUPLI;
- for (dupob = duplilist->first; dupob; dupob = dupob->next) {
- copy_m4_m4(dupob->ob->obmat, dupob->omat);
+ for (iter->dupob = iter->duplilist->first; iter->dupob; iter->dupob = iter->dupob->next) {
+ copy_m4_m4(iter->dupob->ob->obmat, iter->dupob->omat);
}
- free_object_duplilist(duplilist);
- duplilist = NULL;
+ free_object_duplilist(iter->duplilist);
+ iter->duplilist = NULL;
run_again = 1;
}
}
@@ -870,7 +866,7 @@ int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob)
/* reset recursion test */
in_next_object = 0;
- return fase;
+ return iter->fase;
}
Object *BKE_scene_camera_find(Scene *sc)
@@ -1483,6 +1479,16 @@ void BKE_scene_disable_color_management(Scene *scene)
int BKE_scene_check_color_management_enabled(const Scene *scene)
{
+ /* TODO(sergey): shouldn't be needed. but we're currently far to close to the release,
+ * so better be extra-safe than sorry.
+ *
+ * Will remove the check after the release.
+ */
+ if (!scene) {
+ BLI_assert(!"Shouldn't happen!");
+ return TRUE;
+ }
+
return strcmp(scene->display_settings.display_device, "None") != 0;
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 68fac399c51..34b19e3f357 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -50,6 +50,7 @@
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
+#include "BLI_string_utf8.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
@@ -64,6 +65,7 @@
#include "BKE_fcurve.h"
#include "BKE_scene.h"
#include "BKE_mask.h"
+#include "BKE_library.h"
#include "RNA_access.h"
@@ -178,8 +180,10 @@ static void BKE_sequence_free_ex(Scene *scene, Sequence *seq, const int do_cache
if (seq->strip)
seq_free_strip(seq->strip);
- if (seq->anim)
+ if (seq->anim) {
IMB_free_anim(seq->anim);
+ seq->anim = NULL;
+ }
if (seq->type & SEQ_TYPE_EFFECT) {
struct SeqEffectHandle sh = BKE_sequence_get_effect(seq);
@@ -262,6 +266,7 @@ static void seq_free_clipboard_recursive(Sequence *seq_parent)
seq_free_clipboard_recursive(seq);
}
+ BKE_sequence_clipboard_pointers_free(seq_parent);
BKE_sequence_free_ex(NULL, seq_parent, FALSE);
}
@@ -276,6 +281,101 @@ void BKE_sequencer_free_clipboard(void)
seqbase_clipboard.first = seqbase_clipboard.last = NULL;
}
+/* -------------------------------------------------------------------- */
+/* Manage pointers in the clipboard.
+ * note that these pointers should _never_ be access in the sequencer,
+ * they are only for storage while in the clipboard
+ * notice 'newid' is used for temp pointer storage here, validate on access.
+ */
+#define ID_PT (*id_pt)
+static void seqclipboard_ptr_free(ID **id_pt)
+{
+ if (ID_PT) {
+ BLI_assert(ID_PT->newid != NULL);
+ MEM_freeN(ID_PT);
+ ID_PT = NULL;
+ }
+}
+static void seqclipboard_ptr_store(ID **id_pt)
+{
+ if (ID_PT) {
+ ID *id_prev = ID_PT;
+ ID_PT = MEM_dupallocN(ID_PT);
+ ID_PT->newid = id_prev;
+ }
+}
+static void seqclipboard_ptr_restore(Main *bmain, ID **id_pt)
+{
+ if (ID_PT) {
+ const ListBase *lb = which_libbase(bmain, GS(ID_PT->name));
+ void *id_restore;
+
+ BLI_assert(ID_PT->newid != NULL);
+ if (BLI_findindex(lb, (ID_PT)->newid) != -1) {
+ /* the pointer is still valid */
+ id_restore = (ID_PT)->newid;
+ }
+ else {
+ /* the pointer of the same name still exists */
+ id_restore = BLI_findstring(lb, (ID_PT)->name + 2, offsetof(ID, name) + 2);
+ }
+
+ if (id_restore == NULL) {
+ /* check for a data with the same filename */
+ switch (GS(ID_PT->name)) {
+ case ID_SO:
+ {
+ id_restore = BLI_findstring(lb, ((bSound *)ID_PT)->name, offsetof(bSound, name));
+ if (id_restore == NULL) {
+ id_restore = sound_new_file(bmain, ((bSound *)ID_PT)->name);
+ (ID_PT)->newid = id_restore; /* reuse next time */
+ }
+ break;
+ }
+ case ID_MC:
+ {
+ id_restore = BLI_findstring(lb, ((MovieClip *)ID_PT)->name, offsetof(MovieClip, name));
+ if (id_restore == NULL) {
+ id_restore = BKE_movieclip_file_add(bmain, ((MovieClip *)ID_PT)->name);
+ (ID_PT)->newid = id_restore; /* reuse next time */
+ }
+ break;
+ }
+ }
+ }
+
+ ID_PT = id_restore;
+ }
+}
+#undef ID_PT
+
+void BKE_sequence_clipboard_pointers_free(Sequence *seq)
+{
+ seqclipboard_ptr_free((ID **)&seq->scene);
+ seqclipboard_ptr_free((ID **)&seq->scene_camera);
+ seqclipboard_ptr_free((ID **)&seq->clip);
+ seqclipboard_ptr_free((ID **)&seq->mask);
+ seqclipboard_ptr_free((ID **)&seq->sound);
+}
+void BKE_sequence_clipboard_pointers_store(Sequence *seq)
+{
+ seqclipboard_ptr_store((ID **)&seq->scene);
+ seqclipboard_ptr_store((ID **)&seq->scene_camera);
+ seqclipboard_ptr_store((ID **)&seq->clip);
+ seqclipboard_ptr_store((ID **)&seq->mask);
+ seqclipboard_ptr_store((ID **)&seq->sound);
+}
+void BKE_sequence_clipboard_pointers_restore(Sequence *seq, Main *bmain)
+{
+ seqclipboard_ptr_restore(bmain, (ID **)&seq->scene);
+ seqclipboard_ptr_restore(bmain, (ID **)&seq->scene_camera);
+ seqclipboard_ptr_restore(bmain, (ID **)&seq->clip);
+ seqclipboard_ptr_restore(bmain, (ID **)&seq->mask);
+ seqclipboard_ptr_restore(bmain, (ID **)&seq->sound);
+}
+/* end clipboard pointer mess */
+
+
Editing *BKE_sequencer_editing_ensure(Scene *scene)
{
if (scene->ed == NULL) {
@@ -815,33 +915,6 @@ void BKE_sequencer_clear_scene_in_allseqs(Main *bmain, Scene *scene)
BKE_sequencer_base_recursive_apply(&scene_iter->ed->seqbase, clear_scene_in_allseqs_cb, scene);
}
}
-
- /* also clear clipboard */
- BKE_sequencer_base_recursive_apply(&seqbase_clipboard, clear_scene_in_allseqs_cb, scene);
-}
-
-static int clear_movieclip_in_clipboard_cb(Sequence *seq, void *arg_pt)
-{
- if (seq->clip == (MovieClip *)arg_pt)
- seq->clip = NULL;
- return 1;
-}
-
-void BKE_sequencer_clear_movieclip_in_clipboard(MovieClip *clip)
-{
- BKE_sequencer_base_recursive_apply(&seqbase_clipboard, clear_movieclip_in_clipboard_cb, clip);
-}
-
-static int clear_mask_in_clipboard_cb(Sequence *seq, void *arg_pt)
-{
- if (seq->mask == (Mask *)arg_pt)
- seq->mask = NULL;
- return 1;
-}
-
-void BKE_sequencer_clear_mask_in_clipboard(Mask *mask)
-{
- BKE_sequencer_base_recursive_apply(&seqbase_clipboard, clear_mask_in_clipboard_cb, mask);
}
typedef struct SeqUniqueInfo {
@@ -3111,8 +3184,18 @@ static void sequence_invalidate_cache(Scene *scene, Sequence *seq, int invalidat
Editing *ed = scene->ed;
/* invalidate cache for current sequence */
- if (invalidate_self)
+ if (invalidate_self) {
+ if (seq->anim) {
+ /* Animation structure holds some buffers inside,
+ * so for proper cache invalidation we need to
+ * re-open the animation.
+ */
+ IMB_free_anim(seq->anim);
+ seq->anim = NULL;
+ }
+
BKE_sequencer_cache_cleanup_sequence(seq);
+ }
/* if invalidation is invoked from sequence free routine, effectdata would be NULL here */
if (seq->effectdata && seq->type == SEQ_TYPE_SPEED)
@@ -3938,7 +4021,8 @@ Mask *BKE_sequencer_mask_get(Scene *scene)
static void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load)
{
if (seq) {
- BLI_strncpy(seq->name + 2, seq_load->name, sizeof(seq->name) - 2);
+ BLI_strncpy_utf8(seq->name + 2, seq_load->name, sizeof(seq->name) - 2);
+ BLI_utf8_invalid_strip(seq->name + 2, sizeof(seq->name) - 2);
BKE_sequence_base_unique_name_recursive(&scene->ed->seqbase, seq);
if (seq_load->flag & SEQ_LOAD_FRAME_ADVANCE) {
@@ -4231,6 +4315,12 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
if (seq->scene_sound)
seqn->scene_sound = sound_scene_add_scene_sound_defaults(sce_audio, seqn);
}
+ else if (seq->type == SEQ_TYPE_MOVIECLIP) {
+ /* avoid assert */
+ }
+ else if (seq->type == SEQ_TYPE_MASK) {
+ /* avoid assert */
+ }
else if (seq->type == SEQ_TYPE_MOVIE) {
seqn->strip->stripdata =
MEM_dupallocN(seq->strip->stripdata);
@@ -4242,7 +4332,7 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
if (seq->scene_sound)
seqn->scene_sound = sound_add_scene_sound_defaults(sce_audio, seqn);
- seqn->sound->id.us++;
+ id_us_plus((ID *)seqn->sound);
}
else if (seq->type == SEQ_TYPE_IMAGE) {
seqn->strip->stripdata =
@@ -4264,7 +4354,8 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
}
else {
- fprintf(stderr, "Aiiiiekkk! sequence type not handled in duplicate!\nExpect a crash now...\n");
+ /* sequence type not handled in duplicate! Expect a crash now... */
+ BLI_assert(0);
}
if (dupe_flag & SEQ_DUPE_UNIQUE_NAME)
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 05c3550d810..b2c0a45cbc4 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -1413,12 +1413,14 @@ static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, Smoke
}
}
+/* TODO(sergey): de-duplicate with get_texture_value from modifier utils */
+/* NOTE: Skips color management, because result is only used for value now, not for color. */
static void get_texture_value(Tex *texture, float tex_co[3], TexResult *texres)
{
int result_type;
/* no node textures for now */
- result_type = multitex_ext_safe(texture, tex_co, texres, NULL);
+ result_type = multitex_ext_safe(texture, tex_co, texres, NULL, false);
/* if the texture gave an RGB value, we assume it didn't give a valid
* intensity, since this is in the context of modifiers don't use perceptual color conversion.
@@ -2100,7 +2102,7 @@ static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sd
/* sample subframes */
else {
int scene_frame = scene->r.cfra;
- float scene_subframe = scene->r.subframe;
+ // float scene_subframe = scene->r.subframe; // UNUSED
int subframe;
for (subframe = 0; subframe <= subframes; subframe++) {
EmissionMap em_temp = {0};
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 9b5e5070342..cc33727030a 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1505,7 +1505,8 @@ static void ccgdm_getVertCos(DerivedMesh *dm, float (*cos)[3])
static void ccgDM_foreachMappedVert(
DerivedMesh *dm,
void (*func)(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]),
- void *userData)
+ void *userData,
+ DMForeachFlag flag)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGVertIterator *vi;
@@ -1514,11 +1515,13 @@ static void ccgDM_foreachMappedVert(
for (vi = ccgSubSurf_getVertIterator(ccgdm->ss); !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) {
CCGVert *v = ccgVertIterator_getCurrent(vi);
- CCGElem *vd = ccgSubSurf_getVertData(ccgdm->ss, v);
- int index = ccgDM_getVertMapIndex(ccgdm->ss, v);
+ const int index = ccgDM_getVertMapIndex(ccgdm->ss, v);
- if (index != -1)
- func(userData, index, CCG_elem_co(&key, vd), CCG_elem_no(&key, vd), NULL);
+ if (index != -1) {
+ CCGElem *vd = ccgSubSurf_getVertData(ccgdm->ss, v);
+ const float *no = (flag & DM_FOREACH_USE_NORMAL) ? CCG_elem_no(&key, vd) : NULL;
+ func(userData, index, CCG_elem_co(&key, vd), no, NULL);
+ }
}
ccgVertIterator_free(vi);
@@ -1539,12 +1542,13 @@ static void ccgDM_foreachMappedEdge(
for (ei = ccgSubSurf_getEdgeIterator(ss); !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) {
CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
- CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
- int index = ccgDM_getEdgeMapIndex(ss, e);
+ const int index = ccgDM_getEdgeMapIndex(ss, e);
if (index != -1) {
- for (i = 0; i < edgeSize - 1; i++)
+ CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
+ for (i = 0; i < edgeSize - 1; i++) {
func(userData, index, CCG_elem_offset_co(&key, edgeData, i), CCG_elem_offset_co(&key, edgeData, i + 1));
+ }
}
}
@@ -1970,7 +1974,7 @@ static void ccgDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial)
/* Only used by non-editmesh types */
static void ccgDM_drawMappedFacesMat(DerivedMesh *dm,
void (*setMaterial)(void *userData, int, void *attribs),
- int (*setFace)(void *userData, int index), void *userData)
+ bool (*setFace)(void *userData, int index), void *userData)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
@@ -2530,7 +2534,8 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm,
static void ccgDM_foreachMappedFaceCenter(
DerivedMesh *dm,
void (*func)(void *userData, int index, const float co[3], const float no[3]),
- void *userData)
+ void *userData,
+ DMForeachFlag flag)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm;
CCGSubSurf *ss = ccgdm->ss;
@@ -2541,13 +2546,13 @@ static void ccgDM_foreachMappedFaceCenter(
for (fi = ccgSubSurf_getFaceIterator(ss); !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) {
CCGFace *f = ccgFaceIterator_getCurrent(fi);
- int index = ccgDM_getFaceMapIndex(ss, f);
+ const int index = ccgDM_getFaceMapIndex(ss, f);
if (index != -1) {
/* Face center data normal isn't updated atm. */
CCGElem *vd = ccgSubSurf_getFaceGridData(ss, f, 0, 0, 0);
-
- func(userData, index, CCG_elem_co(&key, vd), CCG_elem_no(&key, vd));
+ const float *no = (flag & DM_FOREACH_USE_NORMAL) ? CCG_elem_no(&key, vd) : NULL;
+ func(userData, index, CCG_elem_co(&key, vd), no);
}
}
@@ -2925,7 +2930,7 @@ static void ccgdm_create_grids(DerivedMesh *dm)
gridFaces = MEM_mallocN(sizeof(CCGFace *) * numGrids, "ccgdm.gridFaces");
gridFlagMats = MEM_mallocN(sizeof(DMFlagMat) * numGrids, "ccgdm.gridFlagMats");
- ccgdm->gridHidden = MEM_callocN(sizeof(BLI_bitmap) * numGrids, "ccgdm.gridHidden");
+ ccgdm->gridHidden = MEM_callocN(sizeof(*ccgdm->gridHidden) * numGrids, "ccgdm.gridHidden");
for (gIndex = 0, index = 0; index < numFaces; index++) {
CCGFace *f = ccgdm->faceMap[index].face;
@@ -2997,7 +3002,7 @@ static DMFlagMat *ccgDM_getGridFlagMats(DerivedMesh *dm)
return ccgdm->gridFlagMats;
}
-static BLI_bitmap *ccgDM_getGridHidden(DerivedMesh *dm)
+static BLI_bitmap **ccgDM_getGridHidden(DerivedMesh *dm)
{
CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm;
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 296f25e303e..f0c01e25598 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -847,19 +847,6 @@ int txt_utf8_column_to_offset(const char *str, int column)
return offset;
}
-/* returns the real number of characters in string */
-/* not the same as BLI_strlen_utf8, which returns length for wide characters */
-static int txt_utf8_len(const char *src)
-{
- int len;
-
- for (len = 0; *src; len++) {
- src += BLI_str_utf8_size(src);
- }
-
- return len;
-}
-
void txt_move_up(Text *text, short sel)
{
TextLine **linep;
@@ -1509,6 +1496,7 @@ static int max_undo_test(Text *text, int x)
return 1;
}
+#if 0 /* UNUSED */
static void dump_buffer(Text *text)
{
int i = 0;
@@ -1620,6 +1608,7 @@ void txt_print_undo(Text *text)
c_len = BLI_str_utf8_from_unicode(uc, c);
c[c_len] = '\0';
puts(c);
+ break;
}
}
}
@@ -1672,6 +1661,7 @@ void txt_print_undo(Text *text)
i++;
}
}
+#endif
static void txt_undo_store_uint16(char *undo_buf, int *undo_pos, unsigned short value)
{
@@ -1863,6 +1853,7 @@ static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, s
/* should never happen */
BLI_assert(0);
unicode = 0;
+ break;
}
return unicode;
@@ -1938,6 +1929,7 @@ static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, s
/* should never happen */
BLI_assert(0);
unicode = 0;
+ break;
}
return unicode;
@@ -2026,10 +2018,7 @@ void txt_do_undo(Text *text)
buf[i] = 0;
/* skip over the length that was stored again */
- text->undo_pos--;
- text->undo_pos--;
- text->undo_pos--;
- text->undo_pos--;
+ text->undo_pos -= 4;
/* Get the cursor positions */
txt_undo_read_cursors(text->undo_buf, &text->undo_pos, &curln, &curc, &selln, &selc);
@@ -2059,14 +2048,11 @@ void txt_do_undo(Text *text)
text->undo_pos--;
}
buf[i] = 0;
- linep = txt_utf8_len(buf);
+ linep = BLI_strlen_utf8(buf);
MEM_freeN(buf);
/* skip over the length that was stored again */
- text->undo_pos--;
- text->undo_pos--;
- text->undo_pos--;
- text->undo_pos--;
+ text->undo_pos -= 4;
/* get and restore the cursors */
txt_undo_read_cursors(text->undo_buf, &text->undo_pos, &curln, &curc, &selln, &selc);
@@ -2217,10 +2203,7 @@ void txt_do_redo(Text *text)
text->undo_pos += linep;
/* skip over the length that was stored again */
- text->undo_pos++;
- text->undo_pos++;
- text->undo_pos++;
- text->undo_pos++;
+ text->undo_pos += 4;
txt_delete_sel(text);
@@ -2246,10 +2229,7 @@ void txt_do_redo(Text *text)
MEM_freeN(buf);
/* skip over the length that was stored again */
- text->undo_pos++;
- text->undo_pos++;
- text->undo_pos++;
- text->undo_pos++;
+ text->undo_pos += 4;
break;
@@ -2379,7 +2359,7 @@ static void txt_delete_line(Text *text, TextLine *line)
static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb)
{
- char *tmp;
+ char *tmp, *s;
if (!text) return;
@@ -2388,8 +2368,10 @@ static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb)
tmp = MEM_mallocN(linea->len + lineb->len + 1, "textline_string");
- strcpy(tmp, linea->line);
- strcat(tmp, lineb->line);
+ s = tmp;
+ s += BLI_strcpy_rlen(s, linea->line);
+ s += BLI_strcpy_rlen(s, lineb->line);
+ (void)s;
make_new_line(linea, tmp);
@@ -2642,10 +2624,6 @@ void txt_indent(Text *text)
return;
}
- if (!text) return;
- if (!text->curl) return;
- if (!text->sell) return;
-
/* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES) {
add = tab_to_spaces;
@@ -2705,9 +2683,9 @@ void txt_unindent(Text *text)
/* hardcoded: TXT_TABSIZE = 4 spaces: */
int spaceslen = TXT_TABSIZE;
- if (!text) return;
- if (!text->curl) return;
- if (!text->sell) return;
+ if (ELEM3(NULL, text, text->curl, text->sell)) {
+ return;
+ }
/* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES) {
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 1d0b0deae7e..e2b7358525a 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -906,42 +906,6 @@ void BKE_texture_make_local(Tex *tex)
}
}
-/* ------------------------------------------------------------------------- */
-#if 0 /* UNUSED */
-void autotexname(Tex *tex)
-{
- Main *bmain = G.main;
- char texstr[20][15] = {"None", "Clouds", "Wood", "Marble", "Magic", "Blend",
- "Stucci", "Noise", "Image", "EnvMap", "Musgrave",
- "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""};
- Image *ima;
- char di[FILE_MAXDIR], fi[FILE_MAXFILE];
-
- if (tex) {
- if (tex->use_nodes) {
- new_id(&bmain->tex, (ID *)tex, "Noddy");
- }
- else if (tex->type == TEX_IMAGE) {
- ima = tex->ima;
- if (ima) {
- BLI_split_file_part(ima->name, fi, sizeof(fi));
- strcpy(di, "I.");
- strcat(di, fi);
- new_id(&bmain->tex, (ID *)tex, di);
- }
- else {
- new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
- }
- }
- else {
- new_id(&bmain->tex, (ID *)tex, texstr[tex->type]);
- }
- }
-}
-#endif
-
-/* ------------------------------------------------------------------------- */
-
Tex *give_current_object_texture(Object *ob)
{
Material *ma, *node_ma;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 8141fc8aaa1..12c2967afcf 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1534,7 +1534,7 @@ void BKE_tracking_camera_get_reconstructed_interpolate(MovieTracking *tracking,
/*********************** Distortion/Undistortion *************************/
-static void cameraIntrinscisOptionsFromTracking(libmv_cameraIntrinsicsOptions *camera_intrinsics_options,
+static void cameraIntrinscisOptionsFromTracking(libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
MovieTracking *tracking, int calibration_width, int calibration_height)
{
MovieTrackingCamera *camera = &tracking->camera;
@@ -1559,7 +1559,7 @@ MovieDistortion *BKE_tracking_distortion_new(void)
distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
- distortion->intrinsics = libmv_CameraIntrinsicsNewEmpty();
+ distortion->intrinsics = libmv_cameraIntrinsicsNewEmpty();
return distortion;
}
@@ -1567,17 +1567,17 @@ MovieDistortion *BKE_tracking_distortion_new(void)
void BKE_tracking_distortion_update(MovieDistortion *distortion, MovieTracking *tracking,
int calibration_width, int calibration_height)
{
- libmv_cameraIntrinsicsOptions camera_intrinsics_options;
+ libmv_CameraIntrinsicsOptions camera_intrinsics_options;
cameraIntrinscisOptionsFromTracking(&camera_intrinsics_options, tracking,
calibration_width, calibration_height);
- libmv_CameraIntrinsicsUpdate(&camera_intrinsics_options, distortion->intrinsics);
+ libmv_cameraIntrinsicsUpdate(&camera_intrinsics_options, distortion->intrinsics);
}
void BKE_tracking_distortion_set_threads(MovieDistortion *distortion, int threads)
{
- libmv_CameraIntrinsicsSetThreads(distortion->intrinsics, threads);
+ libmv_cameraIntrinsicsSetThreads(distortion->intrinsics, threads);
}
MovieDistortion *BKE_tracking_distortion_copy(MovieDistortion *distortion)
@@ -1586,7 +1586,7 @@ MovieDistortion *BKE_tracking_distortion_copy(MovieDistortion *distortion)
new_distortion = MEM_callocN(sizeof(MovieDistortion), "BKE_tracking_distortion_create");
- new_distortion->intrinsics = libmv_CameraIntrinsicsCopy(distortion->intrinsics);
+ new_distortion->intrinsics = libmv_cameraIntrinsicsCopy(distortion->intrinsics);
return new_distortion;
}
@@ -1602,12 +1602,12 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
if (ibuf->rect_float) {
if (undistort) {
- libmv_CameraIntrinsicsUndistortFloat(distortion->intrinsics,
+ libmv_cameraIntrinsicsUndistortFloat(distortion->intrinsics,
ibuf->rect_float, resibuf->rect_float,
ibuf->x, ibuf->y, overscan, ibuf->channels);
}
else {
- libmv_CameraIntrinsicsDistortFloat(distortion->intrinsics,
+ libmv_cameraIntrinsicsDistortFloat(distortion->intrinsics,
ibuf->rect_float, resibuf->rect_float,
ibuf->x, ibuf->y, overscan, ibuf->channels);
}
@@ -1617,12 +1617,12 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
}
else {
if (undistort) {
- libmv_CameraIntrinsicsUndistortByte(distortion->intrinsics,
+ libmv_cameraIntrinsicsUndistortByte(distortion->intrinsics,
(unsigned char *)ibuf->rect, (unsigned char *)resibuf->rect,
ibuf->x, ibuf->y, overscan, ibuf->channels);
}
else {
- libmv_CameraIntrinsicsDistortByte(distortion->intrinsics,
+ libmv_cameraIntrinsicsDistortByte(distortion->intrinsics,
(unsigned char *)ibuf->rect, (unsigned char *)resibuf->rect,
ibuf->x, ibuf->y, overscan, ibuf->channels);
}
@@ -1633,7 +1633,7 @@ ImBuf *BKE_tracking_distortion_exec(MovieDistortion *distortion, MovieTracking *
void BKE_tracking_distortion_free(MovieDistortion *distortion)
{
- libmv_CameraIntrinsicsDestroy(distortion->intrinsics);
+ libmv_cameraIntrinsicsDestroy(distortion->intrinsics);
MEM_freeN(distortion);
}
@@ -1642,7 +1642,7 @@ void BKE_tracking_distort_v2(MovieTracking *tracking, const float co[2], float r
{
MovieTrackingCamera *camera = &tracking->camera;
- libmv_cameraIntrinsicsOptions camera_intrinsics_options;
+ libmv_CameraIntrinsicsOptions camera_intrinsics_options;
double x, y;
float aspy = 1.0f / tracking->camera.pixel_aspect;
@@ -1652,7 +1652,7 @@ void BKE_tracking_distort_v2(MovieTracking *tracking, const float co[2], float r
x = (co[0] - camera->principal[0]) / camera->focal;
y = (co[1] - camera->principal[1] * aspy) / camera->focal;
- libmv_ApplyCameraIntrinsics(&camera_intrinsics_options, x, y, &x, &y);
+ libmv_cameraIntrinsicsApply(&camera_intrinsics_options, x, y, &x, &y);
/* result is in image coords already */
r_co[0] = x;
@@ -1663,13 +1663,13 @@ void BKE_tracking_undistort_v2(MovieTracking *tracking, const float co[2], float
{
MovieTrackingCamera *camera = &tracking->camera;
- libmv_cameraIntrinsicsOptions camera_intrinsics_options;
+ libmv_CameraIntrinsicsOptions camera_intrinsics_options;
double x = co[0], y = co[1];
float aspy = 1.0f / tracking->camera.pixel_aspect;
cameraIntrinscisOptionsFromTracking(&camera_intrinsics_options, tracking, 0, 0);
- libmv_InvertCameraIntrinsics(&camera_intrinsics_options, x, y, &x, &y);
+ libmv_cameraIntrinsicsInvert(&camera_intrinsics_options, x, y, &x, &y);
r_co[0] = (float)x * camera->focal + camera->principal[0];
r_co[1] = (float)y * camera->focal + camera->principal[1] * aspy;
@@ -2529,7 +2529,7 @@ static bool track_context_update_reference(MovieTrackingContext *context, TrackC
/* Fill in libmv tracker options structure with settings need to be used to perform track. */
static void tracking_configure_tracker(MovieTrackingTrack *track, float *mask,
- struct libmv_trackRegionOptions *options)
+ libmv_TrackRegionOptions *options)
{
options->motion_model = track->motion_model;
@@ -2654,8 +2654,8 @@ static bool configure_and_run_tracker(ImBuf *destination_ibuf, MovieTrackingTrac
double src_pixel_x[5], src_pixel_y[5];
/* Settings for the tracker */
- struct libmv_trackRegionOptions options = {0};
- struct libmv_trackRegionResult result;
+ libmv_TrackRegionOptions options = {0};
+ libmv_TrackRegionResult result;
float *patch_new;
@@ -2930,17 +2930,17 @@ static struct libmv_Tracks *libmv_tracks_new(ListBase *tracksbase, int width, in
}
/* Retrieve refined camera intrinsics from libmv to blender. */
-static void reconstruct_retrieve_libmv_intrinscis(MovieReconstructContext *context, MovieTracking *tracking)
+static void reconstruct_retrieve_libmv_intrinsics(MovieReconstructContext *context, MovieTracking *tracking)
{
struct libmv_Reconstruction *libmv_reconstruction = context->reconstruction;
- struct libmv_CameraIntrinsics *libmv_intrinsics = libmv_ReconstructionExtractIntrinsics(libmv_reconstruction);
+ struct libmv_CameraIntrinsics *libmv_intrinsics = libmv_reconstructionExtractIntrinsics(libmv_reconstruction);
float aspy = 1.0f / tracking->camera.pixel_aspect;
double focal_length, principal_x, principal_y, k1, k2, k3;
int width, height;
- libmv_CameraIntrinsicsExtract(libmv_intrinsics, &focal_length, &principal_x, &principal_y,
+ libmv_cameraIntrinsicsExtract(libmv_intrinsics, &focal_length, &principal_x, &principal_y,
&k1, &k2, &k3, &width, &height);
tracking->camera.focal = focal_length;
@@ -2987,13 +2987,13 @@ static int reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context, M
while (track) {
double pos[3];
- if (libmv_reporojectionPointForTrack(libmv_reconstruction, tracknr, pos)) {
+ if (libmv_reprojectionPointForTrack(libmv_reconstruction, tracknr, pos)) {
track->bundle_pos[0] = pos[0];
track->bundle_pos[1] = pos[1];
track->bundle_pos[2] = pos[2];
track->flag |= TRACK_HAS_BUNDLE;
- track->error = libmv_reporojectionErrorForTrack(libmv_reconstruction, tracknr);
+ track->error = libmv_reprojectionErrorForTrack(libmv_reconstruction, tracknr);
}
else {
track->flag &= ~TRACK_HAS_BUNDLE;
@@ -3017,10 +3017,10 @@ static int reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context, M
for (a = sfra; a <= efra; a++) {
double matd[4][4];
- if (libmv_reporojectionCameraForImage(libmv_reconstruction, a, matd)) {
+ if (libmv_reprojectionCameraForImage(libmv_reconstruction, a, matd)) {
int i, j;
float mat[4][4];
- float error = libmv_reporojectionErrorForImage(libmv_reconstruction, a);
+ float error = libmv_reprojectionErrorForImage(libmv_reconstruction, a);
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++)
@@ -3081,8 +3081,8 @@ static int reconstruct_retrieve_libmv_tracks(MovieReconstructContext *context, M
/* Retrieve all the libmv data from context to blender's side data blocks. */
static int reconstruct_retrieve_libmv(MovieReconstructContext *context, MovieTracking *tracking)
{
- /* take the intrinscis back from libmv */
- reconstruct_retrieve_libmv_intrinscis(context, tracking);
+ /* take the intrinsics back from libmv */
+ reconstruct_retrieve_libmv_intrinsics(context, tracking);
return reconstruct_retrieve_libmv_tracks(context, tracking);
}
@@ -3243,7 +3243,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking *
void BKE_tracking_reconstruction_context_free(MovieReconstructContext *context)
{
if (context->reconstruction)
- libmv_destroyReconstruction(context->reconstruction);
+ libmv_reconstructionDestroy(context->reconstruction);
libmv_tracksDestroy(context->tracks);
@@ -3266,7 +3266,7 @@ static void reconstruct_update_solve_cb(void *customdata, double progress, const
}
/* FIll in camera intrinsics structure from reconstruction context. */
-static void camraIntrincicsOptionsFromContext(libmv_cameraIntrinsicsOptions *camera_intrinsics_options,
+static void camraIntrincicsOptionsFromContext(libmv_CameraIntrinsicsOptions *camera_intrinsics_options,
MovieReconstructContext *context)
{
camera_intrinsics_options->focal_length = context->focal_length;
@@ -3283,7 +3283,7 @@ static void camraIntrincicsOptionsFromContext(libmv_cameraIntrinsicsOptions *cam
}
/* Fill in reconstruction options structure from reconstruction context. */
-static void reconstructionOptionsFromContext(libmv_reconstructionOptions *reconstruction_options,
+static void reconstructionOptionsFromContext(libmv_ReconstructionOptions *reconstruction_options,
MovieReconstructContext *context)
{
reconstruction_options->select_keyframes = context->select_keyframes;
@@ -3313,8 +3313,8 @@ void BKE_tracking_reconstruction_solve(MovieReconstructContext *context, short *
ReconstructProgressData progressdata;
- libmv_cameraIntrinsicsOptions camera_intrinsics_options;
- libmv_reconstructionOptions reconstruction_options;
+ libmv_CameraIntrinsicsOptions camera_intrinsics_options;
+ libmv_ReconstructionOptions reconstruction_options;
progressdata.stop = stop;
progressdata.do_update = do_update;
@@ -3455,7 +3455,7 @@ static bool check_point_in_stroke(bGPDstroke *stroke, float x, float y)
prev = i;
}
- return count % 2 ? true : false;
+ return (count % 2) ? true : false;
}
/* Check whether point is inside any stroke of grease pencil layer. */
@@ -3558,7 +3558,7 @@ void BKE_tracking_detect_fast(MovieTracking *tracking, ListBase *tracksbase, ImB
framenr, ibuf->x, ibuf->y, layer,
place_outside_layer ? true : false);
- libmv_destroyFeatures(features);
+ libmv_featuresDestroy(features);
}
/*********************** 2D stabilization *************************/
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 097c9d076a4..a69df62f505 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -95,6 +95,11 @@ typedef struct bUnitDef {
#define B_UNIT_DEF_SUPPRESS 1 /* Use for units that are not used enough to be translated into for common use */
#define B_UNIT_DEF_TENTH 2 /* Display a unit even if its value is 0.1, eg 0.1mm instead of 100um */
+/* workaround encoding issue with "µm", bug [#36090] */
+#define B_UNIT_CHAR_MICRO "\xb5"
+#define UM B_UNIT_CHAR_MICRO"m"
+#define US B_UNIT_CHAR_MICRO"s"
+
/* define a single unit */
typedef struct bUnitCollection {
struct bUnitDef *units;
@@ -116,7 +121,7 @@ static struct bUnitDef buMetricLenDef[] = {
{"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
{"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE},
{"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
- {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too?
+ {"micrometer", "micrometers", UM, "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too?
/* These get displayed because of float precision problems in the transform header,
* could work around, but for now probably people wont use these */
@@ -149,7 +154,7 @@ static struct bUnitDef buMetricAreaDef[] = {
{"square decimeter", "square decimetees", "dm²", "dm2", "Square Decimeters", UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
{"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE},
{"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
- {"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
+ {"square micrometer", "square micrometers", UM"²", "um2", "Square Micrometers", UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buMetricAreaCollection = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef) / sizeof(bUnitDef)};
@@ -175,7 +180,7 @@ static struct bUnitDef buMetricVolDef[] = {
{"cubic decimeter", "cubic decimeters", "dm³", "dm3", "Cubic Decimeters", UN_SC_DM * UN_SC_DM * UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS},
{"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM * UN_SC_CM * UN_SC_CM, 0.0, B_UNIT_DEF_NONE},
{"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM * UN_SC_MM * UN_SC_MM, 0.0, B_UNIT_DEF_NONE | B_UNIT_DEF_TENTH},
- {"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
+ {"cubic micrometer", "cubic micrometers", UM"³", "um3", "Cubic Micrometers", UN_SC_UM * UN_SC_UM * UN_SC_UM, 0.0, B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buMetricVolCollection = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef) / sizeof(bUnitDef)};
@@ -253,7 +258,7 @@ static struct bUnitDef buNaturalTimeDef[] = {
{"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE},
{"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */
{"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0, B_UNIT_DEF_NONE},
- {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE},
+ {"microsecond", "microseconds", US, "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE},
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buNaturalTimeCollection = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef) / sizeof(bUnitDef)};
@@ -273,7 +278,7 @@ static struct bUnitDef buCameraLenDef[] = {
{"decimeter", "decimeters", "dm", NULL, "10 Centimeters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS},
{"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS},
{"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_M, 0.0, B_UNIT_DEF_NONE},
- {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_MM, 0.0, B_UNIT_DEF_SUPPRESS}, // micron too?
+ {"micrometer", "micrometers", UM, "um", "Micrometers", UN_SC_MM, 0.0, B_UNIT_DEF_SUPPRESS}, // micron too?
{NULL, NULL, NULL, NULL, NULL, 0.0, 0.0}
};
static struct bUnitCollection buCameraLenCollection = {buCameraLenDef, 3, 0, sizeof(buCameraLenDef) / sizeof(bUnitDef)};
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index f08a51e602c..538c98cc899 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -877,6 +877,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
break;
case FFMPEG_MP3:
fmt->audio_codec = CODEC_ID_MP3;
+ /* fall-through */
case FFMPEG_WAV:
fmt->video_codec = CODEC_ID_NONE;
break;
@@ -1072,23 +1073,23 @@ int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty,
specs.channels = c->channels;
switch (av_get_packed_sample_fmt(c->sample_fmt)) {
- case AV_SAMPLE_FMT_U8:
- specs.format = AUD_FORMAT_U8;
- break;
- case AV_SAMPLE_FMT_S16:
- specs.format = AUD_FORMAT_S16;
- break;
- case AV_SAMPLE_FMT_S32:
- specs.format = AUD_FORMAT_S32;
- break;
- case AV_SAMPLE_FMT_FLT:
- specs.format = AUD_FORMAT_FLOAT32;
- break;
- case AV_SAMPLE_FMT_DBL:
- specs.format = AUD_FORMAT_FLOAT64;
- break;
- default:
- return -31415;
+ case AV_SAMPLE_FMT_U8:
+ specs.format = AUD_FORMAT_U8;
+ break;
+ case AV_SAMPLE_FMT_S16:
+ specs.format = AUD_FORMAT_S16;
+ break;
+ case AV_SAMPLE_FMT_S32:
+ specs.format = AUD_FORMAT_S32;
+ break;
+ case AV_SAMPLE_FMT_FLT:
+ specs.format = AUD_FORMAT_FLOAT32;
+ break;
+ case AV_SAMPLE_FMT_DBL:
+ specs.format = AUD_FORMAT_FLOAT64;
+ break;
+ default:
+ return -31415;
}
specs.rate = rd->ffcodecdata.audio_mixrate;