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.c8
-rw-r--r--source/blender/blenkernel/intern/armature.c12
-rw-r--r--source/blender/blenkernel/intern/blender.c13
-rw-r--r--source/blender/blenkernel/intern/bmfont.c9
-rw-r--r--source/blender/blenkernel/intern/brush.c15
-rw-r--r--source/blender/blenkernel/intern/camera.c9
-rw-r--r--source/blender/blenkernel/intern/curve.c72
-rw-r--r--source/blender/blenkernel/intern/customdata.c18
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c3
-rw-r--r--source/blender/blenkernel/intern/displist.c52
-rw-r--r--source/blender/blenkernel/intern/fcurve.c4
-rw-r--r--source/blender/blenkernel/intern/freestyle.c1
-rw-r--r--source/blender/blenkernel/intern/gpencil.c20
-rw-r--r--source/blender/blenkernel/intern/image.c45
-rw-r--r--source/blender/blenkernel/intern/implicit.c6
-rw-r--r--source/blender/blenkernel/intern/lamp.c3
-rw-r--r--source/blender/blenkernel/intern/lattice.c58
-rw-r--r--source/blender/blenkernel/intern/mball.c6
-rw-r--r--source/blender/blenkernel/intern/mesh.c7
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c93
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c12
-rw-r--r--source/blender/blenkernel/intern/multires.c2
-rw-r--r--source/blender/blenkernel/intern/node.c40
-rw-r--r--source/blender/blenkernel/intern/object.c25
-rw-r--r--source/blender/blenkernel/intern/particle.c5
-rw-r--r--source/blender/blenkernel/intern/pointcache.c2
-rw-r--r--source/blender/blenkernel/intern/sca.c5
-rw-r--r--source/blender/blenkernel/intern/scene.c5
-rw-r--r--source/blender/blenkernel/intern/screen.c33
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c4
-rw-r--r--source/blender/blenkernel/intern/smoke.c2
-rw-r--r--source/blender/blenkernel/intern/softbody.c307
-rw-r--r--source/blender/blenkernel/intern/text.c34
-rw-r--r--source/blender/blenkernel/intern/tracking.c2
-rw-r--r--source/blender/blenkernel/intern/unit.c13
-rw-r--r--source/blender/blenkernel/intern/writeavi.c13
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c31
37 files changed, 566 insertions, 423 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 731196c2480..5c98fe48ea6 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -3315,7 +3315,7 @@ bool DM_is_valid(DerivedMesh *dm)
const bool do_fixes = false;
bool is_valid = true;
- bool is_change = true;
+ bool changed = true;
is_valid &= BKE_mesh_validate_all_customdata(
dm->getVertDataLayout(dm),
@@ -3323,7 +3323,7 @@ bool DM_is_valid(DerivedMesh *dm)
dm->getLoopDataLayout(dm),
dm->getPolyDataLayout(dm),
0, /* setting mask here isn't useful, gives false positives */
- do_verbose, do_fixes, &is_change);
+ do_verbose, do_fixes, &changed);
is_valid &= BKE_mesh_validate_arrays(
NULL,
@@ -3333,9 +3333,9 @@ bool DM_is_valid(DerivedMesh *dm)
dm->getLoopArray(dm), dm->getNumLoops(dm),
dm->getPolyArray(dm), dm->getNumPolys(dm),
dm->getVertDataArray(dm, CD_MDEFORMVERT),
- do_verbose, do_fixes, &is_change);
+ do_verbose, do_fixes, &changed);
- BLI_assert(is_change == false);
+ BLI_assert(changed == false);
return is_valid;
}
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 3be80a7e30d..0267c9a6122 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -335,15 +335,15 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
* - otherwise, just append to end
*/
if (extension[0]) {
- int change = 1;
+ bool changed = true;
- while (change) { /* remove extensions */
- change = 0;
+ while (changed) { /* remove extensions */
+ changed = false;
if (len > 2 && basename[len - 2] == '.') {
if (basename[len - 1] == 'L' || basename[len - 1] == 'R') { /* L R */
basename[len - 2] = '\0';
len -= 2;
- change = 1;
+ changed = true;
}
}
else if (len > 3 && basename[len - 3] == '.') {
@@ -352,7 +352,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
{
basename[len - 3] = '\0';
len -= 3;
- change = 1;
+ changed = true;
}
}
else if (len > 4 && basename[len - 4] == '.') {
@@ -361,7 +361,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a
{
basename[len - 4] = '\0';
len -= 4;
- change = 1;
+ changed = true;
}
}
}
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 5ef39e8d48e..96adadebb48 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -897,6 +897,12 @@ int BKE_copybuffer_save(const char *filename, ReportList *reports)
ListBase *lbarray[MAX_LIBARRAY], *fromarray[MAX_LIBARRAY];
int a, retval;
+ /* path backup/restore */
+ void *path_list_backup;
+ const int path_list_flag = (BKE_BPATH_TRAVERSE_SKIP_LIBRARY | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE);
+
+ path_list_backup = BKE_bpath_list_backup(G.main, path_list_flag);
+
BLO_main_expander(copybuffer_doit);
BLO_expand_main(NULL, G.main);
@@ -918,7 +924,7 @@ int BKE_copybuffer_save(const char *filename, ReportList *reports)
/* save the buffer */
- retval = BLO_write_file(mainb, filename, 0, reports, NULL);
+ retval = BLO_write_file(mainb, filename, G_FILE_RELATIVE_REMAP, reports, NULL);
/* move back the main, now sorted again */
set_listbasepointers(G.main, lbarray);
@@ -938,6 +944,11 @@ int BKE_copybuffer_save(const char *filename, ReportList *reports)
/* set id flag to zero; */
flag_all_listbases_ids(LIB_NEED_EXPAND | LIB_DOIT, 0);
+ if (path_list_backup) {
+ BKE_bpath_list_restore(G.main, path_list_flag, path_list_backup);
+ BKE_bpath_list_free(path_list_backup);
+ }
+
return retval;
}
diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c
index 732c0c35feb..79b3f89da20 100644
--- a/source/blender/blenkernel/intern/bmfont.c
+++ b/source/blender/blenkernel/intern/bmfont.c
@@ -68,13 +68,10 @@ void printfGlyph(bmGlyph *glyph)
printf(" advan: %3d reser: %3d\n", glyph->advance, glyph->reserved);
}
-#define MAX2(x, y) ((x) > (y) ? (x) : (y))
-#define MAX3(x, y, z) (MAX2(MAX2((x), (y)), (z)))
-
void calcAlpha(ImBuf *ibuf)
{
int i;
- char * rect;
+ char *rect;
if (ibuf) {
rect = (char *) ibuf->rect;
@@ -88,7 +85,7 @@ void calcAlpha(ImBuf *ibuf)
void readBitmapFontVersion0(ImBuf *ibuf, unsigned char *rect, int step)
{
int glyphcount, bytes, i, index, linelength, ysize;
- unsigned char * buffer;
+ unsigned char *buffer;
bmFont * bmfont;
linelength = ibuf->x * step;
@@ -174,7 +171,7 @@ void readBitmapFontVersion0(ImBuf *ibuf, unsigned char *rect, int step)
void detectBitmapFont(ImBuf *ibuf)
{
- unsigned char * rect;
+ unsigned char *rect;
unsigned short version;
int i;
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 33c6f3eb7c0..8a59aab4036 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -45,6 +45,7 @@
#include "BKE_texture.h"
#include "BKE_icons.h"
+#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
@@ -306,7 +307,7 @@ void BKE_brush_debug_print_state(Brush *br)
BR_TEST_FLAG(BRUSH_ADAPTIVE_SPACE);
BR_TEST_FLAG(BRUSH_LOCK_SIZE);
BR_TEST_FLAG(BRUSH_EDGE_TO_EDGE);
- BR_TEST_FLAG(BRUSH_RESTORE_MESH);
+ BR_TEST_FLAG(BRUSH_DRAG_DOT);
BR_TEST_FLAG(BRUSH_INVERSE_SMOOTH_PRESSURE);
BR_TEST_FLAG(BRUSH_RANDOM_ROTATION);
BR_TEST_FLAG(BRUSH_PLANE_TRIM);
@@ -639,6 +640,16 @@ float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
rgba[2] = intensity;
rgba[3] = 1.0f;
}
+ else {
+ if (br->mtex.tex->type == TEX_IMAGE && br->mtex.tex->ima) {
+ ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(br->mtex.tex->ima, &br->mtex.tex->iuser, pool);
+ /* For consistency, sampling always returns color in linear space */
+ if (tex_ibuf->rect_float == NULL) {
+ IMB_colormanagement_colorspace_to_scene_linear_v3(rgba, tex_ibuf->rect_colorspace);
+ }
+ BKE_image_pool_release_ibuf(br->mtex.tex->ima, tex_ibuf, pool);
+ }
+ }
return intensity;
}
@@ -899,7 +910,7 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2],
/* jitter-ed brush gives weird and unpredictable result for this
* kinds of stroke, so manually disable jitter usage (sergey) */
- use_jitter &= (brush->flag & (BRUSH_RESTORE_MESH | BRUSH_ANCHORED)) == 0;
+ use_jitter &= (brush->flag & (BRUSH_DRAG_DOT | BRUSH_ANCHORED)) == 0;
if (use_jitter) {
float rand_pos[2];
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 536ec95e3d1..aee8ede4062 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -227,7 +227,7 @@ void BKE_camera_params_from_object(CameraParams *params, Object *ob)
else if (ob->type == OB_LAMP) {
/* lamp object */
Lamp *la = ob->data;
- float fac = cosf((float)M_PI * la->spotsize / 360.0f);
+ float fac = cosf(la->spotsize * 0.5f);
float phi = acos(fac);
params->lens = 16.0f * fac / sinf(phi);
@@ -535,16 +535,11 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object
float plane_isect_pt_1[3], plane_isect_pt_2[3];
- /* could make a generic macro */
-#define SQRT_SIGNED(f) copysign(sqrtf(fabsf(f)), f)
-
/* apply the dist-from-plane's to the transformed plane points */
for (i = 0; i < 4; i++) {
- mul_v3_v3fl(plane_tx[i], data_cb.normal_tx[i], SQRT_SIGNED(data_cb.dist_vals_sq[i]));
+ mul_v3_v3fl(plane_tx[i], data_cb.normal_tx[i], sqrtf_signed(data_cb.dist_vals_sq[i]));
}
-#undef SQRT_SIGNED
-
isect_plane_plane_v3(plane_isect_1, plane_isect_1_no,
plane_tx[0], data_cb.normal_tx[0],
plane_tx[2], data_cb.normal_tx[2]);
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index bcf0eafaa65..969db19a256 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -143,7 +143,6 @@ void BKE_curve_editNurb_free(Curve *cu)
void BKE_curve_free(Curve *cu)
{
BKE_nurbList_free(&cu->nurb);
- BKE_displist_free(&cu->disp);
BKE_curve_editfont_free(cu);
BKE_curve_editNurb_free(cu);
@@ -223,8 +222,6 @@ Curve *BKE_curve_copy(Curve *cu)
cun->key = BKE_key_copy(cu->key);
if (cun->key) cun->key->from = (ID *)cun;
- cun->disp.first = cun->disp.last = NULL;
-
cun->editnurb = NULL;
cun->editfont = NULL;
cun->selboxes = NULL;
@@ -379,7 +376,11 @@ void BKE_curve_boundbox_calc(Curve *cu, float r_loc[3], float r_size[3])
if (!r_size) r_size = msize;
INIT_MINMAX(min, max);
- BKE_displist_minmax(&cu->disp, min, max);
+ if (!BKE_curve_minmax(cu, true, min, max)) {
+ min[0] = min[1] = min[2] = -1.0f;
+ max[0] = max[1] = max[2] = 1.0f;
+ }
+
mid_v3_v3v3(r_loc, min, max);
r_size[0] = (max[0] - min[0]) / 2.0f;
@@ -642,18 +643,34 @@ void BKE_nurb_test2D(Nurb *nu)
}
}
-void BKE_nurb_minmax(Nurb *nu, float min[3], float max[3])
+/* if use_radius is truth, minmax will take points' radius into account,
+ * which will make boundbox closer to bevelled curve.
+ */
+void BKE_nurb_minmax(Nurb *nu, bool use_radius, float min[3], float max[3])
{
BezTriple *bezt;
BPoint *bp;
int a;
+ float point[3];
if (nu->type == CU_BEZIER) {
a = nu->pntsu;
bezt = nu->bezt;
while (a--) {
+ if (use_radius) {
+ float radius_vector[3];
+ radius_vector[0] = radius_vector[1] = radius_vector[2] = bezt->radius;
+
+ add_v3_v3v3(point, bezt->vec[1], radius_vector);
+ minmax_v3v3_v3(min, max, point);
+
+ sub_v3_v3v3(point, bezt->vec[1], radius_vector);
+ minmax_v3v3_v3(min, max, point);
+ }
+ else {
+ minmax_v3v3_v3(min, max, bezt->vec[1]);
+ }
minmax_v3v3_v3(min, max, bezt->vec[0]);
- minmax_v3v3_v3(min, max, bezt->vec[1]);
minmax_v3v3_v3(min, max, bezt->vec[2]);
bezt++;
}
@@ -662,7 +679,20 @@ void BKE_nurb_minmax(Nurb *nu, float min[3], float max[3])
a = nu->pntsu * nu->pntsv;
bp = nu->bp;
while (a--) {
- minmax_v3v3_v3(min, max, bp->vec);
+ if (nu->pntsv == 1 && use_radius) {
+ float radius_vector[3];
+ radius_vector[0] = radius_vector[1] = radius_vector[2] = bp->radius;
+
+ add_v3_v3v3(point, bp->vec, radius_vector);
+ minmax_v3v3_v3(min, max, point);
+
+ sub_v3_v3v3(point, bp->vec, radius_vector);
+ minmax_v3v3_v3(min, max, point);
+ }
+ else {
+ /* Surfaces doesn't use bevel, so no need to take radius into account. */
+ minmax_v3v3_v3(min, max, bp->vec);
+ }
bp++;
}
}
@@ -1518,6 +1548,9 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
else
numVerts += dl->parts * (dl->nr + 1);
}
+ else if (dl->flag & DL_CYCL_V) {
+ numVerts += (dl->parts + 1) * dl->nr;
+ }
else
numVerts += dl->parts * dl->nr;
}
@@ -1553,6 +1586,9 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob, int *r_numVerts)
if (dl->flag & DL_CYCL_V)
sizev++;
}
+ else if (dl->flag & DL_CYCL_V) {
+ sizev++;
+ }
for (u = 0; u < sizev; u++) {
for (v = 0; v < sizeu; v++, fp += 3) {
@@ -3658,30 +3694,30 @@ bool BKE_nurb_check_valid_v(struct Nurb *nu)
bool BKE_nurb_order_clamp_u(struct Nurb *nu)
{
- bool change = false;
+ bool changed = false;
if (nu->pntsu < nu->orderu) {
nu->orderu = nu->pntsu;
- change = true;
+ changed = true;
}
if (((nu->flagu & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) {
CLAMP(nu->orderu, 3, 4);
- change = true;
+ changed = true;
}
- return change;
+ return changed;
}
bool BKE_nurb_order_clamp_v(struct Nurb *nu)
{
- bool change = false;
+ bool changed = false;
if (nu->pntsv < nu->orderv) {
nu->orderv = nu->pntsv;
- change = true;
+ changed = true;
}
if (((nu->flagv & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) {
CLAMP(nu->orderv, 3, 4);
- change = true;
+ changed = true;
}
- return change;
+ return changed;
}
bool BKE_nurb_type_convert(Nurb *nu, const short type, const bool use_handles)
@@ -3834,13 +3870,13 @@ ListBase *BKE_curve_nurbs_get(Curve *cu)
/* basic vertex data functions */
-bool BKE_curve_minmax(Curve *cu, float min[3], float max[3])
+bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3])
{
ListBase *nurb_lb = BKE_curve_nurbs_get(cu);
Nurb *nu;
for (nu = nurb_lb->first; nu; nu = nu->next)
- BKE_nurb_minmax(nu, min, max);
+ BKE_nurb_minmax(nu, use_radius, min, max);
return (nurb_lb->first != NULL);
}
@@ -3887,7 +3923,7 @@ bool BKE_curve_center_bounds(Curve *cu, float cent[3])
{
float min[3], max[3];
INIT_MINMAX(min, max);
- if (BKE_curve_minmax(cu, min, max)) {
+ if (BKE_curve_minmax(cu, false, min, max)) {
mid_v3_v3v3(cent, min, max);
return true;
}
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 8a74f4719d5..441a2b410ad 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -507,16 +507,15 @@ static void layerCopy_mdisps(const void *source, void *dest, int count)
if (s[i].disps) {
d[i].disps = MEM_dupallocN(s[i].disps);
d[i].hidden = MEM_dupallocN(s[i].hidden);
- d[i].totdisp = s[i].totdisp;
- d[i].level = s[i].level;
}
else {
d[i].disps = NULL;
d[i].hidden = NULL;
- d[i].totdisp = 0;
- d[i].level = 0;
}
-
+
+ /* still copy even if not in memory, displacement can be external */
+ d[i].totdisp = s[i].totdisp;
+ d[i].level = s[i].level;
}
}
@@ -1296,7 +1295,7 @@ bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
CustomDataLayer *layer, *newlayer;
void *data;
int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0, lastflag = 0;
- bool change = false;
+ bool changed = false;
for (i = 0; i < source->totlayer; ++i) {
layer = &source->layers[i];
@@ -1346,12 +1345,12 @@ bool CustomData_merge(const struct CustomData *source, struct CustomData *dest,
newlayer->active_clone = lastclone;
newlayer->active_mask = lastmask;
newlayer->flag |= lastflag & (CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY);
- change = true;
+ changed = true;
}
}
CustomData_update_typemap(dest);
- return change;
+ return changed;
}
void CustomData_copy(const struct CustomData *source, struct CustomData *dest,
@@ -1752,6 +1751,7 @@ void *CustomData_add_layer_named(CustomData *data, int type, int alloctype,
bool CustomData_free_layer(CustomData *data, int type, int totelem, int index)
{
+ const int n = index - CustomData_get_layer_index(data, type);
int i;
if (index < 0) return 0;
@@ -1768,7 +1768,7 @@ bool CustomData_free_layer(CustomData *data, int type, int totelem, int index)
if (i != -1) {
/* don't decrement zero index */
- const int index_nonzero = index ? index : 1;
+ const int index_nonzero = n ? n : 1;
CustomDataLayer *layer;
for (layer = &data->layers[i]; i < data->totlayer && layer->type == type; i++, layer++) {
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index cb7b4a32feb..6ef20ecc047 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -1466,7 +1466,8 @@ static void flush_update_node(Main *bmain, DagNode *node, unsigned int layer, in
{
DagAdjList *itA;
Object *ob, *obc;
- int oldflag, changed = 0;
+ int oldflag;
+ bool changed = false;
unsigned int all_layer;
node->lasttime = curtime;
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 6a89ca2cb84..dd1df6ef4b0 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1086,7 +1086,7 @@ static DerivedMesh *create_orco_dm(Scene *scene, Object *ob)
return dm;
}
-static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
+static void add_orco_dm(Object *ob, DerivedMesh *dm, DerivedMesh *orcodm)
{
float (*orco)[3], (*layerorco)[3];
int totvert, a;
@@ -1094,23 +1094,12 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh *
totvert = dm->getNumVerts(dm);
- if (orcodm) {
- orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco");
+ orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco");
- if (orcodm->getNumVerts(orcodm) == totvert)
- orcodm->getVertCos(orcodm, orco);
- else
- dm->getVertCos(dm, orco);
- }
- else {
- int totvert_curve;
- orco = (float(*)[3])BKE_curve_make_orco(scene, ob, &totvert_curve);
- if (totvert != totvert_curve) {
- MEM_freeN(orco);
- orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco");
- dm->getVertCos(dm, orco);
- }
- }
+ if (orcodm->getNumVerts(orcodm) == totvert)
+ orcodm->getVertCos(orcodm, orco);
+ else
+ dm->getVertCos(dm, orco);
for (a = 0; a < totvert; a++) {
float *co = orco[a];
@@ -1157,6 +1146,15 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina
md = pretessellatePoint->next;
}
+ /* If modifiers are disabled, we wouldn't be here because
+ * this function is only called if there're enabled constructive
+ * modifiers applied on the curve.
+ *
+ * This means we can create ORCO DM in advance and assume it's
+ * never NULL.
+ */
+ orcodm = create_orco_dm(scene, ob);
+
for (; md; md = md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1167,9 +1165,6 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina
if (mti->type != eModifierTypeType_Constructive)
continue;
- if (!orcodm)
- orcodm = create_orco_dm(scene, ob);
-
ndm = modwrap_applyModifier(md, ob, orcodm, app_flag);
if (ndm) {
@@ -1182,10 +1177,9 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina
}
/* add an orco layer if needed */
- add_orco_dm(scene, ob, derivedFinal, orcodm);
+ add_orco_dm(ob, derivedFinal, orcodm);
- if (orcodm)
- orcodm->release(orcodm);
+ orcodm->release(orcodm);
}
void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
@@ -1271,11 +1265,6 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
}
}
- /* make copy of 'undeformed" displist for texture space calculation
- * actually, it's not totally undeformed -- pre-tessellation modifiers are
- * already applied, thats how it worked for years, so keep for compatibility (sergey) */
- BKE_displist_copy(&cu->disp, dispbase);
-
if (!forOrco) {
curve_calc_modifiers_post(scene, ob, &nubase, dispbase, derivedFinal,
forRender, renderResolution);
@@ -1575,11 +1564,6 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if ((cu->flag & CU_PATH) && !forOrco)
calc_curvepath(ob, &nubase);
- /* make copy of 'undeformed" displist for texture space calculation
- * actually, it's not totally undeformed -- pre-tessellation modifiers are
- * already applied, thats how it worked for years, so keep for compatibility (sergey) */
- BKE_displist_copy(&cu->disp, dispbase);
-
if (!forOrco)
curve_calc_modifiers_post(scene, ob, &nubase, dispbase, derivedFinal, forRender, renderResolution);
@@ -1593,7 +1577,6 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco)
{
- Curve *cu = ob->data;
ListBase *dispbase;
/* The same check for duplis as in do_makeDispListCurveTypes.
@@ -1602,7 +1585,6 @@ void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco)
if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT))
return;
- BKE_displist_free(&cu->disp);
BKE_object_free_derived_caches(ob);
if (!ob->curve_cache) {
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index a40d7401566..32098c67ca7 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1148,6 +1148,10 @@ static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar)
/* stop here... */
return 0.0f;
}
+ else {
+ dtar1->flag &= ~DTAR_FLAG_INVALID;
+ dtar2->flag &= ~DTAR_FLAG_INVALID;
+ }
/* use the final posed locations */
mat4_to_quat(q1, pchan->pose_mat);
diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c
index d87c93310c8..3e0668ba05c 100644
--- a/source/blender/blenkernel/intern/freestyle.c
+++ b/source/blender/blenkernel/intern/freestyle.c
@@ -83,7 +83,6 @@ void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *con
FreestyleModuleConfig *module, *new_module;
new_config->mode = config->mode;
- new_config->raycasting_algorithm = config->raycasting_algorithm; /* deprecated */
new_config->flags = config->flags;
new_config->sphere_radius = config->sphere_radius;
new_config->dkr_epsilon = config->dkr_epsilon;
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 42e146301a2..232ee335fbb 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -58,13 +58,11 @@
/* --------- Memory Management ------------ */
/* Free strokes belonging to a gp-frame */
-void free_gpencil_strokes(bGPDframe *gpf)
+bool free_gpencil_strokes(bGPDframe *gpf)
{
bGPDstroke *gps, *gpsn;
-
- /* error checking */
- if (gpf == NULL) return;
-
+ bool changed = (gpf->strokes.first != NULL);
+
/* free strokes */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
@@ -73,6 +71,8 @@ void free_gpencil_strokes(bGPDframe *gpf)
if (gps->points) MEM_freeN(gps->points);
BLI_freelinkN(&gpf->strokes, gps);
}
+
+ return changed;
}
/* Free all of a gp-layer's frames */
@@ -467,16 +467,20 @@ bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew)
}
/* delete the given frame from a layer */
-void gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf)
+bool gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf)
{
+ bool changed = false;
+
/* error checking */
if (ELEM(NULL, gpl, gpf))
- return;
+ return false;
/* free the frame and its data */
- free_gpencil_strokes(gpf);
+ changed = free_gpencil_strokes(gpf);
BLI_freelinkN(&gpl->frames, gpf);
gpl->actframe = NULL;
+
+ return changed;
}
/* get the active gp-layer for editing */
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 6a411f8c308..d59a23c1c30 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -976,7 +976,7 @@ int BKE_imtype_to_ftype(const char imtype)
return RADHDR;
#endif
else if (imtype == R_IMF_IMTYPE_PNG)
- return PNG | 90;
+ return PNG | 15;
#ifdef WITH_DDS
else if (imtype == R_IMF_IMTYPE_DDS)
return DDS;
@@ -1340,7 +1340,7 @@ void BKE_imformat_defaults(ImageFormatData *im_format)
im_format->imtype = R_IMF_IMTYPE_PNG;
im_format->depth = R_IMF_CHAN_DEPTH_8;
im_format->quality = 90;
- im_format->compress = 90;
+ im_format->compress = 15;
BKE_color_managed_display_settings_init(&im_format->display_settings);
BKE_color_managed_view_settings_init(&im_format->view_settings);
@@ -1636,6 +1636,9 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* this could be an argument if we want to operate on non linear float imbuf's
* for now though this is only used for renders which use scene settings */
+#define TEXT_SIZE_CHECK(str, w, h) \
+ ((str[0]) && ((void)(h = h_fixed), (w = BLF_width(mono, str, sizeof(str)))))
+
#define BUFF_MARGIN_X 2
#define BUFF_MARGIN_Y 1
@@ -1665,9 +1668,8 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
x = 0;
y = height;
- if (stamp_data.file[0]) {
+ if (TEXT_SIZE_CHECK(stamp_data.file, w, h)) {
/* Top left corner */
- BLF_width_and_height(mono, stamp_data.file, &w, &h); h = h_fixed;
y -= h;
/* also a little of space to the background. */
@@ -1683,8 +1685,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
}
/* Top left corner, below File */
- if (stamp_data.note[0]) {
- BLF_width_and_height(mono, stamp_data.note, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.note, w, h)) {
y -= h;
/* and space for background. */
@@ -1699,8 +1700,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
}
/* Top left corner, below File (or Note) */
- if (stamp_data.date[0]) {
- BLF_width_and_height(mono, stamp_data.date, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.date, w, h)) {
y -= h;
/* and space for background. */
@@ -1715,8 +1715,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
}
/* Top left corner, below File, Date or Note */
- if (stamp_data.rendertime[0]) {
- BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.rendertime, w, h)) {
y -= h;
/* and space for background. */
@@ -1731,8 +1730,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
y = 0;
/* Bottom left corner, leaving space for timing */
- if (stamp_data.marker[0]) {
- BLF_width_and_height(mono, stamp_data.marker, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.marker, w, h)) {
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
@@ -1747,8 +1745,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
}
/* Left bottom corner */
- if (stamp_data.time[0]) {
- BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.time, w, h)) {
/* extra space for background */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
@@ -1762,8 +1759,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
x += w + pad;
}
- if (stamp_data.frame[0]) {
- BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.frame, w, h)) {
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
@@ -1777,8 +1773,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
x += w + pad;
}
- if (stamp_data.camera[0]) {
- BLF_width_and_height(mono, stamp_data.camera, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.camera, w, h)) {
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
@@ -1790,8 +1785,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
x += w + pad;
}
- if (stamp_data.cameralens[0]) {
- BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.cameralens, w, h)) {
/* extra space for background. */
buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display,
@@ -1800,8 +1794,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
BLF_draw_buffer(mono, stamp_data.cameralens);
}
- if (stamp_data.scene[0]) {
- BLF_width_and_height(mono, stamp_data.scene, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.scene, w, h)) {
/* Bottom right corner, with an extra space because blenfont is too strict! */
x = width - w - 2;
@@ -1815,8 +1808,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
BLF_draw_buffer(mono, stamp_data.scene);
}
- if (stamp_data.strip[0]) {
- BLF_width_and_height(mono, stamp_data.strip, &w, &h); h = h_fixed;
+ if (TEXT_SIZE_CHECK(stamp_data.strip, w, h)) {
/* Top right corner, with an extra space because blenfont is too strict! */
x = width - w - pad;
@@ -1833,6 +1825,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
/* cleanup the buffer. */
BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL);
+#undef TEXT_SIZE_CHECK
#undef BUFF_MARGIN_X
#undef BUFF_MARGIN_Y
}
@@ -2855,7 +2848,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_
return ibuf;
}
-static void image_get_fame_and_index(Image *ima, ImageUser *iuser, int *frame_r, int *index_r)
+static void image_get_frame_and_index(Image *ima, ImageUser *iuser, int *frame_r, int *index_r)
{
int frame = 0, index = 0;
@@ -3176,7 +3169,7 @@ ImBuf *BKE_image_pool_acquire_ibuf(Image *ima, ImageUser *iuser, ImagePool *pool
return BKE_image_acquire_ibuf(ima, iuser, NULL);
}
- image_get_fame_and_index(ima, iuser, &frame, &index);
+ image_get_frame_and_index(ima, iuser, &frame, &index);
ibuf = image_pool_find_entry(pool, ima, frame, index, &found);
if (found)
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index c8e18bc3dee..fce6ed9d6c6 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -1265,7 +1265,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
k = clmd->sim_parms->structural;
- scaling = k + s->stiffness * ABS(clmd->sim_parms->max_struct-k);
+ scaling = k + s->stiffness * fabsf(clmd->sim_parms->max_struct - k);
k = scaling / (clmd->sim_parms->avg_spring_len + FLT_EPSILON);
@@ -1305,7 +1305,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
k = clmd->sim_parms->goalspring;
- scaling = k + s->stiffness * ABS(clmd->sim_parms->max_struct-k);
+ scaling = k + s->stiffness * fabsf(clmd->sim_parms->max_struct - k);
k = verts [s->ij].goal * scaling / (clmd->sim_parms->avg_spring_len + FLT_EPSILON);
@@ -1324,7 +1324,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
k = clmd->sim_parms->bending;
- scaling = k + s->stiffness * ABS(clmd->sim_parms->max_bend-k);
+ scaling = k + s->stiffness * fabsf(clmd->sim_parms->max_bend - k);
cb = k = scaling / (20.0f * (clmd->sim_parms->avg_spring_len + FLT_EPSILON));
mul_fvector_S(bending_force, dir, fbstar(length, L, k, cb));
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
index 903b032e080..904dbec24a4 100644
--- a/source/blender/blenkernel/intern/lamp.c
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -63,14 +63,13 @@ Lamp *BKE_lamp_add(Main *bmain, const char *name)
la->r = la->g = la->b = la->k = 1.0f;
la->haint = la->energy = 1.0f;
la->dist = 25.0f;
- la->spotsize = 45.0f;
+ la->spotsize = DEG2RADF(45.0f);
la->spotblend = 0.15f;
la->att2 = 1.0f;
la->mode = LA_SHAD_BUF;
la->bufsize = 512;
la->clipsta = 0.5f;
la->clipend = 40.0f;
- la->shadspotsize = 45.0f;
la->samp = 3;
la->bias = 1.0f;
la->soft = 3.0f;
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 60b4db6aa9b..850636e986c 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -36,9 +36,10 @@
#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
-#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
+#include "BLI_bitmap.h"
+#include "BLI_math.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -63,7 +64,7 @@
#include "BKE_deform.h"
-int BKE_lattice_index_from_uvw(struct Lattice *lt,
+int BKE_lattice_index_from_uvw(Lattice *lt,
const int u, const int v, const int w)
{
const int totu = lt->pntsu;
@@ -72,7 +73,7 @@ int BKE_lattice_index_from_uvw(struct Lattice *lt,
return (w * (totu * totv) + (v * totu) + u);
}
-void BKE_lattice_index_to_uvw(struct Lattice *lt, const int index,
+void BKE_lattice_index_to_uvw(Lattice *lt, const int index,
int *r_u, int *r_v, int *r_w)
{
const int totu = lt->pntsu;
@@ -83,6 +84,49 @@ void BKE_lattice_index_to_uvw(struct Lattice *lt, const int index,
*r_w = (index / (totu * totv));
}
+int BKE_lattice_index_flip(Lattice *lt, const int index,
+ const bool flip_u, const bool flip_v, const bool flip_w)
+{
+ int u, v, w;
+
+ BKE_lattice_index_to_uvw(lt, index, &u, &v, &w);
+
+ if (flip_u) {
+ u = (lt->pntsu - 1) - u;
+ }
+
+ if (flip_v) {
+ v = (lt->pntsv - 1) - v;
+ }
+
+ if (flip_w) {
+ w = (lt->pntsw - 1) - w;
+ }
+
+ return BKE_lattice_index_from_uvw(lt, u, v, w);
+}
+
+void BKE_lattice_bitmap_from_flag(Lattice *lt, BLI_bitmap *bitmap, const short flag,
+ const bool clear, const bool respecthide)
+{
+ const unsigned int tot = lt->pntsu * lt->pntsv * lt->pntsw;
+ unsigned int i;
+ BPoint *bp;
+
+ bp = lt->def;
+ for (i = 0; i < tot; i++, bp++) {
+ if ((bp->f1 & flag) && (!respecthide || !bp->hide)) {
+ BLI_BITMAP_SET(bitmap, i);
+ }
+ else {
+ if (clear) {
+ BLI_BITMAP_CLEAR(bitmap, i);
+ }
+ }
+ }
+
+}
+
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
{
if (res == 1) {
@@ -1072,7 +1116,7 @@ struct BPoint *BKE_lattice_active_point_get(Lattice *lt)
}
}
-void BKE_lattice_center_median(struct Lattice *lt, float cent[3])
+void BKE_lattice_center_median(Lattice *lt, float cent[3])
{
int i, numVerts;
@@ -1087,7 +1131,7 @@ void BKE_lattice_center_median(struct Lattice *lt, float cent[3])
mul_v3_fl(cent, 1.0f / (float)numVerts);
}
-void BKE_lattice_minmax(struct Lattice *lt, float min[3], float max[3])
+void BKE_lattice_minmax(Lattice *lt, float min[3], float max[3])
{
int i, numVerts;
@@ -1098,7 +1142,7 @@ void BKE_lattice_minmax(struct Lattice *lt, float min[3], float max[3])
minmax_v3v3_v3(min, max, lt->def[i].vec);
}
-void BKE_lattice_center_bounds(struct Lattice *lt, float cent[3])
+void BKE_lattice_center_bounds(Lattice *lt, float cent[3])
{
float min[3], max[3];
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 83c257dbd56..1128c3e55c7 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -2375,7 +2375,7 @@ bool BKE_mball_minmax_ex(MetaBall *mb, float min[3], float max[3],
{
const float scale = obmat ? mat4_to_scale(obmat) : 1.0f;
MetaElem *ml;
- bool change = false;
+ bool changed = false;
float centroid[3], vec[3];
INIT_MINMAX(min, max);
@@ -2398,11 +2398,11 @@ bool BKE_mball_minmax_ex(MetaBall *mb, float min[3], float max[3],
add_v3_fl(vec, scale_mb * i);
minmax_v3v3_v3(min, max, vec);
}
- change = true;
+ changed = true;
}
}
- return change;
+ return changed;
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 844252c583c..af23a84a26b 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -251,7 +251,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2
for (k = 0; k < dv1->totweight; k++, dw1++, dw2++) {
if (dw1->def_nr != dw2->def_nr)
return MESHCMP_DVERT_GROUPMISMATCH;
- if (ABS(dw1->weight - dw2->weight) > thresh)
+ if (fabsf(dw1->weight - dw2->weight) > thresh)
return MESHCMP_DVERT_WEIGHTMISMATCH;
}
}
@@ -1342,6 +1342,9 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
if (dl->flag & DL_CYCL_V)
orco_sizev++;
}
+ else if (dl->flag & DL_CYCL_V) {
+ orco_sizev++;
+ }
for (i = 0; i < 4; i++, mloopuv++) {
/* find uv based on vertex index into grid array */
@@ -1351,6 +1354,8 @@ int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
mloopuv->uv[1] = (v % dl->nr) / (float)orco_sizeu;
/* cyclic correction */
+ if ((i == 1 || i == 2) && mloopuv->uv[0] == 0.0f)
+ mloopuv->uv[0] = 1.0f;
if ((i == 0 || i == 1) && mloopuv->uv[1] == 0.0f)
mloopuv->uv[1] = 1.0f;
}
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 1e74ce23c2c..0a85d2bfa06 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -42,7 +42,7 @@
#include "BLI_math.h"
#include "BLI_edgehash.h"
#include "BLI_bitmap.h"
-#include "BLI_scanfill.h"
+#include "BLI_polyfill2d.h"
#include "BLI_linklist.h"
#include "BLI_linklist_stack.h"
#include "BLI_alloca.h"
@@ -1298,10 +1298,7 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
MPoly *mp, *mpoly;
MLoop *ml, *mloop;
MFace *mface, *mf;
- ScanFillContext sf_ctx;
- ScanFillVert *sf_vert, *sf_vert_last, *sf_vert_first;
- ScanFillFace *sf_tri;
- MemArena *sf_arena = NULL;
+ MemArena *arena = NULL;
int *mface_to_poly_map;
int lindex[4]; /* only ever use 3 in this case */
int poly_index, j, mface_index;
@@ -1375,60 +1372,60 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
}
#endif /* USE_TESSFACE_SPEEDUP */
else {
-#define USE_TESSFACE_CALCNORMAL
+ const float *co_curr, *co_prev;
- unsigned int totfilltri;
-
-#ifdef USE_TESSFACE_CALCNORMAL
float normal[3];
- zero_v3(normal);
-#endif
- ml = mloop + mp->loopstart;
- if (UNLIKELY(sf_arena == NULL)) {
- sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__);
- }
+ float axis_mat[3][3];
+ float (*projverts)[2];
+ unsigned int (*tris)[3];
- BLI_scanfill_begin_arena(&sf_ctx, sf_arena);
- sf_vert_first = NULL;
- sf_vert_last = NULL;
- for (j = 0; j < mp->totloop; j++, ml++) {
- sf_vert = BLI_scanfill_vert_add(&sf_ctx, mvert[ml->v].co);
+ const unsigned int loopstart = (unsigned int)mp->loopstart;
+ const int totfilltri = mp->totloop - 2;
- sf_vert->keyindex = (unsigned int)(mp->loopstart + j);
+ if (UNLIKELY(arena == NULL)) {
+ arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
+ }
- if (sf_vert_last) {
- BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert);
-#ifdef USE_TESSFACE_CALCNORMAL
- add_newell_cross_v3_v3v3(normal, sf_vert_last->co, sf_vert->co);
-#endif
- }
+ tris = BLI_memarena_alloc(arena, sizeof(*tris) * (size_t)totfilltri);
+ projverts = BLI_memarena_alloc(arena, sizeof(*projverts) * (size_t)mp->totloop);
+
+ zero_v3(normal);
- if (!sf_vert_first)
- sf_vert_first = sf_vert;
- sf_vert_last = sf_vert;
+ /* calc normal */
+ ml = mloop + loopstart;
+ co_prev = mvert[ml[mp->totloop - 1].v].co;
+ for (j = 0; j < mp->totloop; j++, ml++) {
+ co_curr = mvert[ml->v].co;
+ add_newell_cross_v3_v3v3(normal, co_prev, co_curr);
+ co_prev = co_curr;
}
- BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert_first);
-#ifdef USE_TESSFACE_CALCNORMAL
- add_newell_cross_v3_v3v3(normal, sf_vert_last->co, sf_vert_first->co);
if (UNLIKELY(normalize_v3(normal) == 0.0f)) {
normal[2] = 1.0f;
}
- totfilltri = BLI_scanfill_calc_ex(&sf_ctx, 0, normal);
-#else
- totfilltri = BLI_scanfill_calc(&sf_ctx, 0);
-#endif
- BLI_assert(totfilltri <= (unsigned int)(mp->totloop - 2));
- (void)totfilltri;
- for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next, mf++) {
+ /* project verts to 2d */
+ axis_dominant_v3_to_m3(axis_mat, normal);
+
+ ml = mloop + loopstart;
+ for (j = 0; j < mp->totloop; j++, ml++) {
+ mul_v2_m3v3(projverts[j], axis_mat, mvert[ml->v].co);
+ }
+
+ BLI_polyfill_calc_arena((const float (*)[2])projverts, (unsigned int)mp->totloop, tris, arena);
+
+ /* apply fill */
+ ml = mloop + loopstart;
+ for (j = 0; j < totfilltri; j++) {
+ unsigned int *tri = tris[j];
+
mface_to_poly_map[mface_index] = poly_index;
mf = &mface[mface_index];
/* set loop indices, transformed to vert indices later */
- mf->v1 = sf_tri->v1->keyindex;
- mf->v2 = sf_tri->v2->keyindex;
- mf->v3 = sf_tri->v3->keyindex;
+ mf->v1 = loopstart + tri[0];
+ mf->v2 = loopstart + tri[1];
+ mf->v3 = loopstart + tri[2];
mf->v4 = 0;
mf->mat_nr = mp->mat_nr;
@@ -1441,15 +1438,13 @@ int BKE_mesh_recalc_tessellation(CustomData *fdata,
mface_index++;
}
- BLI_scanfill_end_arena(&sf_ctx, sf_arena);
-
-#undef USE_TESSFACE_CALCNORMAL
+ BLI_memarena_clear(arena);
}
}
- if (sf_arena) {
- BLI_memarena_free(sf_arena);
- sf_arena = NULL;
+ if (arena) {
+ BLI_memarena_free(arena);
+ arena = NULL;
}
CustomData_free(fdata, totface);
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index a4f5529ee43..ad6a2de31cd 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -216,7 +216,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
MPoly *mpolys, unsigned int totpoly,
MDeformVert *dverts, /* assume totvert length */
const bool do_verbose, const bool do_fixes,
- bool *r_change)
+ bool *r_changed)
{
# define REMOVE_EDGE_TAG(_me) { _me->v2 = _me->v1; do_edge_free = true; } (void)0
# define IS_REMOVED_EDGE(_me) (_me->v2 == _me->v1)
@@ -854,7 +854,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
PRINT_MSG("%s: finished\n\n", __func__);
- *r_change = (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc || msel_fixed);
+ *r_changed = (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc || msel_fixed);
return is_valid;
}
@@ -963,7 +963,7 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata,
int BKE_mesh_validate(Mesh *me, const int do_verbose)
{
bool is_valid = true;
- bool is_change;
+ bool changed;
if (do_verbose) {
printf("MESH: %s\n", me->id.name + 2);
@@ -973,7 +973,7 @@ int BKE_mesh_validate(Mesh *me, const int do_verbose)
&me->vdata, &me->edata, &me->ldata, &me->pdata,
true,
do_verbose, true,
- &is_change);
+ &changed);
is_valid &= BKE_mesh_validate_arrays(
me,
@@ -984,9 +984,9 @@ int BKE_mesh_validate(Mesh *me, const int do_verbose)
me->mpoly, me->totpoly,
me->dvert,
do_verbose, true,
- &is_change);
+ &changed);
- if (is_change) {
+ if (changed) {
DAG_id_tag_update(&me->id, OB_RECALC_DATA);
return true;
}
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 0cdcf4e7298..7ef2505f4e9 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -2288,7 +2288,7 @@ void multires_topology_changed(Mesh *me)
MDisps *mdisp = NULL, *cur = NULL;
int i, grid = 0;
- CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totface);
+ CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS);
if (!mdisp)
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 869dbe032c9..85354e4e0d7 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -122,7 +122,6 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
node->miniwidth = 42.0f;
node->height = ntype->height;
node->color[0] = node->color[1] = node->color[2] = 0.608; /* default theme color */
-
/* initialize the node name with the node label.
* note: do this after the initfunc so nodes get their data set which may be used in naming
* (node groups for example) */
@@ -134,10 +133,13 @@ static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
nodeUniqueName(ntree, node);
node_add_sockets_from_type(ntree, node, ntype);
-
+
if (ntype->initfunc != NULL)
ntype->initfunc(ntree, node);
-
+
+ if (ntree->typeinfo->node_add_init != NULL)
+ ntree->typeinfo->node_add_init(ntree, node);
+
/* extra init callback */
if (ntype->initfunc_api) {
PointerRNA ptr;
@@ -1588,14 +1590,14 @@ static void node_unlink_attached(bNodeTree *ntree, bNode *parent)
}
/** \note caller needs to manage node->id user */
-void nodeFreeNode(bNodeTree *ntree, bNode *node)
+static void node_free_node_ex(bNodeTree *ntree, bNode *node, bool use_api_free_cb)
{
bNodeSocket *sock, *nextsock;
char propname_esc[MAX_IDPROP_NAME * 2];
char prefix[MAX_IDPROP_NAME * 2];
/* extra free callback */
- if (node->typeinfo && node->typeinfo->freefunc_api) {
+ if (use_api_free_cb && node->typeinfo->freefunc_api) {
PointerRNA ptr;
RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr);
@@ -1617,7 +1619,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
BKE_animdata_fix_paths_remove((ID *)ntree, prefix);
- if (ntree->typeinfo && ntree->typeinfo->free_node_cache)
+ if (ntree->typeinfo->free_node_cache)
ntree->typeinfo->free_node_cache(ntree, node);
/* texture node has bad habit of keeping exec data around */
@@ -1626,7 +1628,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
ntree->execdata = NULL;
}
- if (node->typeinfo && node->typeinfo->freefunc)
+ if (node->typeinfo->freefunc)
node->typeinfo->freefunc(node);
}
@@ -1654,6 +1656,11 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node)
ntree->update |= NTREE_UPDATE_NODES;
}
+void nodeFreeNode(bNodeTree *ntree, bNode *node)
+{
+ node_free_node_ex(ntree, node, true);
+}
+
static void node_socket_interface_free(bNodeTree *UNUSED(ntree), bNodeSocket *sock)
{
if (sock->prop) {
@@ -1736,7 +1743,7 @@ void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user)
(void)do_id_user;
#endif
- nodeFreeNode(ntree, node);
+ node_free_node_ex(ntree, node, false);
}
/* free interface sockets */
@@ -2507,7 +2514,7 @@ void BKE_node_clipboard_clear(void)
for (node = node_clipboard.nodes.first; node; node = node_next) {
node_next = node->next;
- nodeFreeNode(NULL, node);
+ node_free_node_ex(NULL, node, false);
}
node_clipboard.nodes.first = node_clipboard.nodes.last = NULL;
@@ -2979,22 +2986,22 @@ void nodeUpdate(bNodeTree *ntree, bNode *node)
ntree->is_updating = FALSE;
}
-int nodeUpdateID(bNodeTree *ntree, ID *id)
+bool nodeUpdateID(bNodeTree *ntree, ID *id)
{
bNode *node;
- int change = FALSE;
+ bool changed = false;
if (ELEM(NULL, id, ntree))
- return change;
+ return changed;
/* avoid reentrant updates, can be caused by RNA update callbacks */
if (ntree->is_updating)
- return change;
- ntree->is_updating = TRUE;
+ return changed;
+ ntree->is_updating = true;
for (node = ntree->nodes.first; node; node = node->next) {
if (node->id == id) {
- change = TRUE;
+ changed = true;
node->update |= NODE_UPDATE_ID;
if (node->typeinfo->updatefunc)
node->typeinfo->updatefunc(ntree, node);
@@ -3008,7 +3015,7 @@ int nodeUpdateID(bNodeTree *ntree, ID *id)
}
ntree->is_updating = FALSE;
- return change;
+ return changed;
}
void nodeUpdateInternalLinks(bNodeTree *ntree, bNode *node)
@@ -3435,6 +3442,7 @@ static void registerShaderNodes(void)
register_node_type_sh_output();
register_node_type_sh_material();
register_node_type_sh_camera();
+ register_node_type_sh_lamp();
register_node_type_sh_gamma();
register_node_type_sh_brightcontrast();
register_node_type_sh_value();
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 45d9d144f55..0694bde7b91 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -312,6 +312,11 @@ void BKE_object_free_derived_caches(Object *ob)
if (ob->curve_cache) {
BKE_displist_free(&ob->curve_cache->disp);
+ BLI_freelistN(&ob->curve_cache->bev);
+ if (ob->curve_cache->path) {
+ free_path(ob->curve_cache->path);
+ ob->curve_cache->path = NULL;
+ }
}
}
@@ -942,7 +947,7 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
ob->empty_drawtype = OB_PLAINAXES;
ob->empty_drawsize = 1.0;
- if (type == OB_CAMERA || type == OB_LAMP || type == OB_SPEAKER) {
+ if (ELEM3(type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
ob->trackflag = OB_NEGZ;
ob->upflag = OB_POSY;
}
@@ -2411,7 +2416,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
BoundBox bb;
float vec[3];
int a;
- bool change = false;
+ bool changed = false;
switch (ob->type) {
case OB_CURVE:
@@ -2424,7 +2429,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
mul_m4_v3(ob->obmat, bb.vec[a]);
minmax_v3v3_v3(min_r, max_r, bb.vec[a]);
}
- change = TRUE;
+ changed = true;
break;
}
case OB_LATTICE:
@@ -2441,7 +2446,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
}
}
}
- change = TRUE;
+ changed = true;
break;
}
case OB_ARMATURE:
@@ -2459,7 +2464,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
minmax_v3v3_v3(min_r, max_r, vec);
- change = TRUE;
+ changed = true;
}
}
}
@@ -2476,7 +2481,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
mul_m4_v3(ob->obmat, bb.vec[a]);
minmax_v3v3_v3(min_r, max_r, bb.vec[a]);
}
- change = TRUE;
+ changed = true;
}
break;
}
@@ -2484,8 +2489,8 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
{
float ob_min[3], ob_max[3];
- change = BKE_mball_minmax_ex(ob->data, ob_min, ob_max, ob->obmat, 0);
- if (change) {
+ changed = BKE_mball_minmax_ex(ob->data, ob_min, ob_max, ob->obmat, 0);
+ if (changed) {
minmax_v3v3_v3(min_r, max_r, ob_min);
minmax_v3v3_v3(min_r, max_r, ob_max);
}
@@ -2493,7 +2498,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
}
}
- if (change == FALSE) {
+ if (changed == false) {
float size[3];
copy_v3_v3(size, ob->size);
@@ -2539,7 +2544,7 @@ bool BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_m
minmax_v3v3_v3(r_min, r_max, vec);
}
- ok = TRUE;
+ ok = true;
}
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 24cf98d957d..b5825dab7c0 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3510,7 +3510,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n
if (BLI_countlist(&ob->particlesystem) > 1)
BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_countlist(&ob->particlesystem));
else
- strcpy(psys->name, DATA_("ParticleSystem"));
+ BLI_strncpy(psys->name, DATA_("ParticleSystem"), sizeof(psys->name));
md = modifier_new(eModifierType_ParticleSystem);
@@ -3525,7 +3525,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n
BLI_addtail(&ob->modifiers, md);
psys->totpart = 0;
- psys->flag = PSYS_ENABLED | PSYS_CURRENT;
+ psys->flag = PSYS_CURRENT;
psys->cfra = BKE_scene_frame_get_from_ctime(scene, CFRA + 1);
DAG_relations_tag_update(G.main);
@@ -3652,6 +3652,7 @@ static void default_particle_settings(ParticleSettings *part)
if (!part->effector_weights)
part->effector_weights = BKE_add_effector_weights(NULL);
+ part->omat = 1;
part->use_modifier_stack = false;
}
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 9891a8cde28..d2ef59b238f 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1769,7 +1769,7 @@ static void ptcache_file_pointers_init(PTCacheFile *pf)
/* Check to see if point number "index" is in pm, uses binary search for index data. */
int BKE_ptcache_mem_index_find(PTCacheMem *pm, unsigned int index)
{
- if (pm->data[BPHYS_DATA_INDEX]) {
+ if (pm->totpoint > 0 && pm->data[BPHYS_DATA_INDEX]) {
unsigned int *data = pm->data[BPHYS_DATA_INDEX];
unsigned int mid, low = 0, high = pm->totpoint - 1;
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 7c374fd5d78..b0b64cac802 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -44,6 +44,7 @@
#include "DNA_object_types.h"
#include "BLI_blenlib.h"
+#include "BLI_math.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_library.h"
@@ -405,8 +406,8 @@ void init_actuator(bActuator *act)
sa->sound3D.rolloff_factor = 1.0f;
sa->sound3D.reference_distance = 1.0f;
sa->sound3D.max_gain = 1.0f;
- sa->sound3D.cone_inner_angle = 360.0f;
- sa->sound3D.cone_outer_angle = 360.0f;
+ sa->sound3D.cone_inner_angle = DEG2RADF(360.0f);
+ sa->sound3D.cone_outer_angle = DEG2RADF(360.0f);
sa->sound3D.max_distance = FLT_MAX;
break;
case ACT_OBJECT:
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 985eae18570..80fcee18513 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -163,6 +163,9 @@ Scene *BKE_scene_copy(Scene *sce, int type)
scen->gm = sce->gm;
scen->audio = sce->audio;
+ if (sce->id.properties)
+ scen->id.properties = IDP_CopyProperty(sce->id.properties);
+
MEM_freeN(scen->toolsettings);
}
else {
@@ -435,7 +438,7 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
sce->r.im_format.imtype = R_IMF_IMTYPE_PNG;
sce->r.im_format.depth = R_IMF_CHAN_DEPTH_8;
sce->r.im_format.quality = 90;
- sce->r.im_format.compress = 90;
+ sce->r.im_format.compress = 15;
sce->r.displaymode = R_OUTPUT_AREA;
sce->r.framapto = 100;
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index c41c66ef561..5b1bb7854a5 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -417,7 +417,7 @@ ScrArea *BKE_screen_find_big_area(bScreen *sc, const int spacetype, const short
return big;
}
-void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene)
+void BKE_screen_view3d_sync(View3D *v3d, struct Scene *scene)
{
int bit;
@@ -481,6 +481,37 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene)
}
}
+void BKE_screen_view3d_twmode_remove(View3D *v3d, const int i)
+{
+ const int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
+ if (selected_index == i) {
+ v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
+ }
+ else if (selected_index > i) {
+ v3d->twmode--;
+ }
+}
+
+void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, Scene *scene, const int i)
+{
+ bScreen *sc;
+
+ for (sc = screen_lb->first; sc; sc = sc->id.next) {
+ if (sc->scene == scene) {
+ ScrArea *sa;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ SpaceLink *sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ BKE_screen_view3d_twmode_remove(v3d, i);
+ }
+ }
+ }
+ }
+ }
+}
+
/* magic zoom calculation, no idea what
* it signifies, if you find out, tell me! -zr
*/
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 7b3f18c1bd4..1507e1742cd 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1246,8 +1246,8 @@ typedef struct WipeZone {
static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo)
{
- wipezone->flip = (wipe->angle < 0);
- wipezone->angle = tanf(DEG2RADF(fabsf(wipe->angle)));
+ wipezone->flip = (wipe->angle < 0.0f);
+ wipezone->angle = tanf(fabsf(wipe->angle));
wipezone->xo = xo;
wipezone->yo = yo;
wipezone->width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0f));
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 23f7dd6ccfb..b39f31bd1ec 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -536,7 +536,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->time_scale = 1.0;
smd->domain->vorticity = 2.0;
smd->domain->border_collisions = SM_BORDER_OPEN; // open domain
- smd->domain->flags = MOD_SMOKE_DISSOLVE_LOG | MOD_SMOKE_HIGH_SMOOTH;
+ smd->domain->flags = MOD_SMOKE_DISSOLVE_LOG;
smd->domain->highres_sampling = SM_HRES_FULLSAMPLE;
smd->domain->strength = 2.0;
smd->domain->noise = MOD_SMOKE_NOISEWAVE;
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 5011080234e..4e2f708eae4 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -234,7 +234,7 @@ static float _final_goal(Object *ob, BodyPoint *bp)/*jow_go_for2_5 */
if (!(ob->softflag & OB_SB_GOAL)) return (0.0f);
if (sb&&bp) {
if (bp->goal < 0.0f) return (0.0f);
- f = sb->mingoal + bp->goal*ABS(sb->maxgoal - sb->mingoal);
+ f = sb->mingoal + bp->goal * fabsf(sb->maxgoal - sb->mingoal);
f = pow(f, 4.0f);
return (f);
}
@@ -316,7 +316,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
/* blow it up with forcefield ranges */
- hull = MAX2(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
+ hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
/* alloc and copy verts*/
pccd_M->mvert = MEM_dupallocN(cmd->xnew);
@@ -325,13 +325,13 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
for (i=0; i < pccd_M->totvert; i++) {
/* evaluate limits */
copy_v3_v3(v, pccd_M->mvert[i].co);
- pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0], v[0]-hull);
- pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1], v[1]-hull);
- pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2], v[2]-hull);
+ pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
+ pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
+ pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
- pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0], v[0]+hull);
- pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1], v[1]+hull);
- pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2], v[2]+hull);
+ pccd_M->bbmax[0] = max_ff(pccd_M->bbmax[0], v[0] + hull);
+ pccd_M->bbmax[1] = max_ff(pccd_M->bbmax[1], v[1] + hull);
+ pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull);
}
/* alloc and copy faces*/
@@ -349,44 +349,43 @@ static ccd_Mesh *ccd_mesh_make(Object *ob)
mima->maxx=mima->maxy=mima->maxz=-1e30f;
copy_v3_v3(v, pccd_M->mvert[mface->v1].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
copy_v3_v3(v, pccd_M->mvert[mface->v2].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
copy_v3_v3(v, pccd_M->mvert[mface->v3].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
if (mface->v4) {
copy_v3_v3(v, pccd_M->mvert[mface->v4].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
}
-
- mima++;
- mface++;
-
+ mima++;
+ mface++;
}
+
return pccd_M;
}
static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
@@ -414,7 +413,7 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
/* blow it up with forcefield ranges */
- hull = MAX2(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
+ hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
/* rotate current to previous */
if (pccd_M->mprevvert) MEM_freeN(pccd_M->mprevvert);
@@ -426,23 +425,23 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
for (i=0; i < pccd_M->totvert; i++) {
/* evaluate limits */
copy_v3_v3(v, pccd_M->mvert[i].co);
- pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0], v[0]-hull);
- pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1], v[1]-hull);
- pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2], v[2]-hull);
+ pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
+ pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
+ pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
- pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0], v[0]+hull);
- pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1], v[1]+hull);
- pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2], v[2]+hull);
+ pccd_M->bbmax[0] = max_ff(pccd_M->bbmax[0], v[0] + hull);
+ pccd_M->bbmax[1] = max_ff(pccd_M->bbmax[1], v[1] + hull);
+ pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull);
/* evaluate limits */
copy_v3_v3(v, pccd_M->mprevvert[i].co);
- pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0], v[0]-hull);
- pccd_M->bbmin[1] = MIN2(pccd_M->bbmin[1], v[1]-hull);
- pccd_M->bbmin[2] = MIN2(pccd_M->bbmin[2], v[2]-hull);
+ pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
+ pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
+ pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
- pccd_M->bbmax[0] = MAX2(pccd_M->bbmax[0], v[0]+hull);
- pccd_M->bbmax[1] = MAX2(pccd_M->bbmax[1], v[1]+hull);
- pccd_M->bbmax[2] = MAX2(pccd_M->bbmax[2], v[2]+hull);
+ pccd_M->bbmax[0] = max_ff(pccd_M->bbmax[0], v[0] + hull);
+ pccd_M->bbmax[1] = max_ff(pccd_M->bbmax[1], v[1] + hull);
+ pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull);
}
@@ -456,72 +455,72 @@ static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
mima->maxx=mima->maxy=mima->maxz=-1e30f;
copy_v3_v3(v, pccd_M->mvert[mface->v1].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
copy_v3_v3(v, pccd_M->mvert[mface->v2].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
copy_v3_v3(v, pccd_M->mvert[mface->v3].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
if (mface->v4) {
copy_v3_v3(v, pccd_M->mvert[mface->v4].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
}
copy_v3_v3(v, pccd_M->mprevvert[mface->v1].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
copy_v3_v3(v, pccd_M->mprevvert[mface->v2].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
copy_v3_v3(v, pccd_M->mprevvert[mface->v3].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
if (mface->v4) {
copy_v3_v3(v, pccd_M->mprevvert[mface->v4].co);
- mima->minx = MIN2(mima->minx, v[0]-hull);
- mima->miny = MIN2(mima->miny, v[1]-hull);
- mima->minz = MIN2(mima->minz, v[2]-hull);
- mima->maxx = MAX2(mima->maxx, v[0]+hull);
- mima->maxy = MAX2(mima->maxy, v[1]+hull);
- mima->maxz = MAX2(mima->maxz, v[2]+hull);
+ mima->minx = min_ff(mima->minx, v[0] - hull);
+ mima->miny = min_ff(mima->miny, v[1] - hull);
+ mima->minz = min_ff(mima->minz, v[2] - hull);
+ mima->maxx = max_ff(mima->maxx, v[0] + hull);
+ mima->maxy = max_ff(mima->maxy, v[1] + hull);
+ mima->maxz = max_ff(mima->maxz, v[2] + hull);
}
@@ -818,10 +817,10 @@ static void calculate_collision_balls(Object *ob)
for (b=bp->nofsprings;b>0;b--) {
bs = sb->bspring + bp->springs[b-1];
if (bs->springtype == SB_EDGE) {
- akku += bs->len;
- akku_count++,
- min = MIN2(bs->len, min);
- max = MAX2(bs->len, max);
+ akku += bs->len;
+ akku_count++;
+ min = min_ff(bs->len, min);
+ max = max_ff(bs->len, max);
}
}
@@ -1345,24 +1344,26 @@ static void scan_for_ext_face_forces(Object *ob, float timenow)
bf->flag &= ~BFF_INTERSECT;
feedback[0]=feedback[1]=feedback[2]=0.0f;
if (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos, sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos,
- &damp, feedback, ob->lay, ob, timenow)) {
+ &damp, feedback, ob->lay, ob, timenow))
+ {
Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback);
Vec3PlusStVec(sb->bpoint[bf->v2].force, tune, feedback);
Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback);
// Vec3PlusStVec(bf->ext_force, tune, feedback);
bf->flag |= BFF_INTERSECT;
- choke = MIN2(MAX2(damp, choke), 1.0f);
+ choke = min_ff(max_ff(damp, choke), 1.0f);
}
feedback[0]=feedback[1]=feedback[2]=0.0f;
if ((bf->v4) && (sb_detect_face_collisionCached(sb->bpoint[bf->v1].pos, sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos,
- &damp, feedback, ob->lay, ob, timenow))) {
+ &damp, feedback, ob->lay, ob, timenow)))
+ {
Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback);
Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback);
Vec3PlusStVec(sb->bpoint[bf->v4].force, tune, feedback);
// Vec3PlusStVec(bf->ext_force, tune, feedback);
bf->flag |= BFF_INTERSECT;
- choke = MIN2(MAX2(damp, choke), 1.0f);
+ choke = min_ff(max_ff(damp, choke), 1.0f);
}
/*---edges intruding*/
@@ -1372,24 +1373,26 @@ static void scan_for_ext_face_forces(Object *ob, float timenow)
tune = -1.0f;
feedback[0]=feedback[1]=feedback[2]=0.0f;
if (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos, sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos,
- &damp, feedback, ob->lay, ob, timenow)) {
- Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback);
- Vec3PlusStVec(sb->bpoint[bf->v2].force, tune, feedback);
- Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback);
-// Vec3PlusStVec(bf->ext_force, tune, feedback);
- bf->flag |= BFF_CLOSEVERT;
- choke = MIN2(MAX2(damp, choke), 1.0f);
+ &damp, feedback, ob->lay, ob, timenow))
+ {
+ Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback);
+ Vec3PlusStVec(sb->bpoint[bf->v2].force, tune, feedback);
+ Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback);
+// Vec3PlusStVec(bf->ext_force, tune, feedback);
+ bf->flag |= BFF_CLOSEVERT;
+ choke = min_ff(max_ff(damp, choke), 1.0f);
}
feedback[0]=feedback[1]=feedback[2]=0.0f;
if ((bf->v4) && (sb_detect_face_pointCached(sb->bpoint[bf->v1].pos, sb->bpoint[bf->v3].pos, sb->bpoint[bf->v4].pos,
- &damp, feedback, ob->lay, ob, timenow))) {
- Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback);
- Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback);
- Vec3PlusStVec(sb->bpoint[bf->v4].force, tune, feedback);
-// Vec3PlusStVec(bf->ext_force, tune, feedback);
- bf->flag |= BFF_CLOSEVERT;
- choke = MIN2(MAX2(damp, choke), 1.0f);
+ &damp, feedback, ob->lay, ob, timenow)))
+ {
+ Vec3PlusStVec(sb->bpoint[bf->v1].force, tune, feedback);
+ Vec3PlusStVec(sb->bpoint[bf->v3].force, tune, feedback);
+ Vec3PlusStVec(sb->bpoint[bf->v4].force, tune, feedback);
+// Vec3PlusStVec(bf->ext_force, tune, feedback);
+ bf->flag |= BFF_CLOSEVERT;
+ choke = min_ff(max_ff(damp, choke), 1.0f);
}
}
/*--- close vertices*/
@@ -1397,11 +1400,11 @@ static void scan_for_ext_face_forces(Object *ob, float timenow)
bf = sb->scratch->bodyface;
for (a=0; a<sb->scratch->totface; a++, bf++) {
if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) {
- sb->bpoint[bf->v1].choke2=MAX2(sb->bpoint[bf->v1].choke2, choke);
- sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2, choke);
- sb->bpoint[bf->v3].choke2=MAX2(sb->bpoint[bf->v3].choke2, choke);
+ sb->bpoint[bf->v1].choke2 = max_ff(sb->bpoint[bf->v1].choke2, choke);
+ sb->bpoint[bf->v2].choke2 = max_ff(sb->bpoint[bf->v2].choke2, choke);
+ sb->bpoint[bf->v3].choke2 = max_ff(sb->bpoint[bf->v3].choke2, choke);
if (bf->v4) {
- sb->bpoint[bf->v2].choke2=MAX2(sb->bpoint[bf->v2].choke2, choke);
+ sb->bpoint[bf->v2].choke2 = max_ff(sb->bpoint[bf->v2].choke2, choke);
}
}
}
@@ -1423,12 +1426,8 @@ static int sb_detect_edge_collisionCached(float edge_v1[3], float edge_v2[3], fl
float t, el;
int a, deflected=0;
- aabbmin[0] = MIN2(edge_v1[0], edge_v2[0]);
- aabbmin[1] = MIN2(edge_v1[1], edge_v2[1]);
- aabbmin[2] = MIN2(edge_v1[2], edge_v2[2]);
- aabbmax[0] = MAX2(edge_v1[0], edge_v2[0]);
- aabbmax[1] = MAX2(edge_v1[1], edge_v2[1]);
- aabbmax[2] = MAX2(edge_v1[2], edge_v2[2]);
+ minmax_v3v3_v3(aabbmin, aabbmax, edge_v1);
+ minmax_v3v3_v3(aabbmin, aabbmax, edge_v2);
el = len_v3v3(edge_v1, edge_v2);
@@ -1481,7 +1480,8 @@ static int sb_detect_edge_collisionCached(float edge_v1[3], float edge_v2[3], fl
(aabbmin[1] > mima->maxy) ||
(aabbmax[2] < mima->minz) ||
(aabbmin[2] > mima->maxz)
- ) {
+ )
+ {
mface++;
mima++;
continue;
@@ -1526,7 +1526,7 @@ static int sb_detect_edge_collisionCached(float edge_v1[3], float edge_v2[3], fl
sub_v3_v3v3(v2, edge_v2, nv2);
i1 = dot_v3v3(v1, d_nvect);
i2 = dot_v3v3(v2, d_nvect);
- intrusiondepth = -MIN2(i1, i2)/el;
+ intrusiondepth = -min_ff(i1, i2) / el;
Vec3PlusStVec(force, intrusiondepth, d_nvect);
*damp=ob->pd->pdef_sbdamp;
deflected = 2;
@@ -1543,9 +1543,9 @@ static int sb_detect_edge_collisionCached(float edge_v1[3], float edge_v2[3], fl
float intrusiondepth, i1, i2;
sub_v3_v3v3(v1, edge_v1, nv4);
sub_v3_v3v3(v2, edge_v2, nv4);
- i1 = dot_v3v3(v1, d_nvect);
- i2 = dot_v3v3(v2, d_nvect);
- intrusiondepth = -MIN2(i1, i2)/el;
+ i1 = dot_v3v3(v1, d_nvect);
+ i2 = dot_v3v3(v2, d_nvect);
+ intrusiondepth = -min_ff(i1, i2) / el;
Vec3PlusStVec(force, intrusiondepth, d_nvect);
@@ -1624,7 +1624,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow,
normalize_v3(vel);
if (ob->softflag & OB_SB_AERO_ANGLE) {
normalize_v3(sp);
- Vec3PlusStVec(bs->ext_force, f*(1.0f-ABS(dot_v3v3(vel, sp))), vel);
+ Vec3PlusStVec(bs->ext_force, f * (1.0f - fabsf(dot_v3v3(vel, sp))), vel);
}
else {
Vec3PlusStVec(bs->ext_force, f, vel); // to keep compatible with 2.45 release files
@@ -2947,9 +2947,9 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
bp->vec[1] = bp->prevvec[1] + 0.5f * (dv[1] + bp->prevdv[1]);
bp->vec[2] = bp->prevvec[2] + 0.5f * (dv[2] + bp->prevdv[2]);
/* compare euler to heun to estimate error for step sizing */
- maxerrvel = MAX2(maxerrvel, ABS(dv[0] - bp->prevdv[0]));
- maxerrvel = MAX2(maxerrvel, ABS(dv[1] - bp->prevdv[1]));
- maxerrvel = MAX2(maxerrvel, ABS(dv[2] - bp->prevdv[2]));
+ maxerrvel = max_ff(maxerrvel, fabsf(dv[0] - bp->prevdv[0]));
+ maxerrvel = max_ff(maxerrvel, fabsf(dv[1] - bp->prevdv[1]));
+ maxerrvel = max_ff(maxerrvel, fabsf(dv[2] - bp->prevdv[2]));
}
else { add_v3_v3(bp->vec, bp->force); }
@@ -2962,15 +2962,15 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
mul_v3_fl(dx, forcetime);
/* the freezer coming sooner or later */
- /*
+#if 0
if ((dot_v3v3(dx, dx)<freezeloc )&&(dot_v3v3(bp->force, bp->force)<freezeforce )) {
bp->frozen /=2;
}
else {
- bp->frozen = MIN2(bp->frozen*1.05f, 1.0f);
+ bp->frozen = min_ff(bp->frozen*1.05f, 1.0f);
}
mul_v3_fl(dx, bp->frozen);
- */
+#endif
/* again some nasty if's to have heun in here too */
if (mode ==1) {
copy_v3_v3(bp->prevpos, bp->pos);
@@ -2981,9 +2981,9 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
bp->pos[0] = bp->prevpos[0] + 0.5f * ( dx[0] + bp->prevdx[0]);
bp->pos[1] = bp->prevpos[1] + 0.5f * ( dx[1] + bp->prevdx[1]);
bp->pos[2] = bp->prevpos[2] + 0.5f * ( dx[2] + bp->prevdx[2]);
- maxerrpos = MAX2(maxerrpos, ABS(dx[0] - bp->prevdx[0]));
- maxerrpos = MAX2(maxerrpos, ABS(dx[1] - bp->prevdx[1]));
- maxerrpos = MAX2(maxerrpos, ABS(dx[2] - bp->prevdx[2]));
+ maxerrpos = max_ff(maxerrpos, fabsf(dx[0] - bp->prevdx[0]));
+ maxerrpos = max_ff(maxerrpos, fabsf(dx[1] - bp->prevdx[1]));
+ maxerrpos = max_ff(maxerrpos, fabsf(dx[2] - bp->prevdx[2]));
/* bp->choke is set when we need to pull a vertex or edge out of the collider.
* the collider object signals to get out by pushing hard. on the other hand
@@ -3000,12 +3000,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
else { add_v3_v3(bp->pos, dx);}
}/*snap*/
/* so while we are looping BPs anyway do statistics on the fly */
- aabbmin[0] = MIN2(aabbmin[0], bp->pos[0]);
- aabbmin[1] = MIN2(aabbmin[1], bp->pos[1]);
- aabbmin[2] = MIN2(aabbmin[2], bp->pos[2]);
- aabbmax[0] = MAX2(aabbmax[0], bp->pos[0]);
- aabbmax[1] = MAX2(aabbmax[1], bp->pos[1]);
- aabbmax[2] = MAX2(aabbmax[2], bp->pos[2]);
+ minmax_v3v3_v3(aabbmin, aabbmax, bp->pos);
if (bp->loc_flag & SBF_DOFUZZY) fuzzy =1;
} /*for*/
@@ -3017,9 +3012,9 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *
if (err) { /* so step size will be controlled by biggest difference in slope */
if (sb->solverflags & SBSO_OLDERR)
- *err = MAX2(maxerrpos, maxerrvel);
+ *err = max_ff(maxerrpos, maxerrvel);
else
- *err = maxerrpos;
+ *err = maxerrpos;
//printf("EP %f EV %f\n", maxerrpos, maxerrvel);
if (fuzzy) {
*err /= sb->fuzzyness;
@@ -3972,7 +3967,7 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
if (err > SoftHeunTol) { /* error needs to be scaled to some quantity */
if (forcetime > forcetimemin) {
- forcetime = MAX2(forcetime / 2.0f, forcetimemin);
+ forcetime = max_ff(forcetime / 2.0f, forcetimemin);
softbody_restore_prev_step(ob);
//printf("down, ");
}
@@ -3994,12 +3989,12 @@ static void softbody_step(Scene *scene, Object *ob, SoftBody *sb, float dtime)
}
}
timedone += forcetime;
- newtime=MIN2(forcetimemax, MAX2(newtime, forcetimemin));
+ newtime = min_ff(forcetimemax, max_ff(newtime, forcetimemin));
//if (newtime > forcetime) printf("up, ");
if (forcetime > 0.0f)
- forcetime = MIN2(dtime - timedone, newtime);
+ forcetime = min_ff(dtime - timedone, newtime);
else
- forcetime = MAX2(dtime - timedone, newtime);
+ forcetime = max_ff(dtime - timedone, newtime);
}
loops++;
if (sb->solverflags & SBSO_MONITOR ) {
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index be43aae1ed3..96601985f67 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -2650,22 +2650,26 @@ void txt_indent(Text *text)
num = 0;
while (TRUE) {
- tmp = MEM_mallocN(text->curl->len + indentlen + 1, "textline_string");
-
- text->curc = 0;
- if (text->curc) memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */
- memcpy(tmp + text->curc, add, indentlen);
-
- len = text->curl->len - text->curc;
- if (len > 0) memcpy(tmp + text->curc + indentlen, text->curl->line + text->curc, len);
- tmp[text->curl->len + indentlen] = 0;
- make_new_line(text->curl, tmp);
-
- text->curc += indentlen;
-
- txt_make_dirty(text);
- txt_clean_text(text);
+ /* don't indent blank lines */
+ if (text->curl->len != 0) {
+ tmp = MEM_mallocN(text->curl->len + indentlen + 1, "textline_string");
+
+ text->curc = 0;
+ if (text->curc) memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */
+ memcpy(tmp + text->curc, add, indentlen);
+
+ len = text->curl->len - text->curc;
+ if (len > 0) memcpy(tmp + text->curc + indentlen, text->curl->line + text->curc, len);
+ tmp[text->curl->len + indentlen] = 0;
+
+ make_new_line(text->curl, tmp);
+
+ text->curc += indentlen;
+
+ txt_make_dirty(text);
+ txt_clean_text(text);
+ }
if (text->curl == text->sell) {
text->selc += indentlen;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index d519b93f963..355922d157a 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1344,6 +1344,8 @@ MovieTrackingPlaneTrack *BKE_tracking_plane_track_add(MovieTracking *tracking, L
/* Use some default name. */
strcpy(plane_track->name, "Plane Track");
+ plane_track->image_opacity = 1.0f;
+
/* Use selected tracks from given list as a plane. */
plane_track->point_tracks = MEM_mallocN(sizeof(MovieTrackingTrack *) * num_selected_tracks, "new plane tracks array");
for (track = tracks->first, track_index = 0; track; track = track->next) {
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 64470542844..17aad7a5a2c 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -392,7 +392,7 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC
while (unit->name_short[j] && (i < len_max)) {
str[i++] = unit->name_short[j++];
}
-
+#if 0
if (pad) {
/* this loop only runs if so many zeros were removed that
* the unit name only used padded chars,
@@ -402,6 +402,7 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC
str[i++] = pad;
}
}
+#endif
}
/* terminate no matter whats done with padding above */
@@ -599,7 +600,7 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
bUnitDef *unit;
char str_tmp[TEMP_STR_SIZE];
- int change = 0;
+ int changed = 0;
if (usys == NULL || usys->units[0].name == NULL) {
return 0;
@@ -618,7 +619,7 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
for (unit = usys->units; unit->name; unit++) {
/* in case there are multiple instances */
while (unit_replace(str, len_max, str_tmp, scale_pref, unit))
- change = 1;
+ changed = true;
}
unit = NULL;
@@ -635,7 +636,7 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
int ofs = 0;
/* in case there are multiple instances */
while ((ofs = unit_replace(str + ofs, len_max - ofs, str_tmp, scale_pref, unit)))
- change = 1;
+ changed = true;
}
}
}
@@ -643,7 +644,7 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
}
unit = NULL;
- if (change == 0) {
+ if (changed == 0) {
/* no units given so infer a unit from the previous string or default */
if (str_prev) {
/* see which units the original value had */
@@ -701,7 +702,7 @@ int bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double sca
}
}
- return change;
+ return changed;
}
/* 45µm --> 45um */
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index ff6212f6b09..1d29ef70d8b 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -132,9 +132,16 @@ static void filepath_avi(char *string, RenderData *rd)
BLI_make_existing_file(string);
- if (!BLI_testextensie(string, ".avi")) {
- BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
- strcat(string, ".avi");
+ if (rd->scemode & R_EXTENSION) {
+ if (!BLI_testextensie(string, ".avi")) {
+ BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
+ strcat(string, ".avi");
+ }
+ }
+ else {
+ if (BLI_path_frame_check_chars(string)) {
+ BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
+ }
}
}
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index bcf5e712eff..ff4300c34e9 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1023,23 +1023,32 @@ void BKE_ffmpeg_filepath_get(char *string, RenderData *rd)
sprintf(autosplit, "_%03d", ffmpeg_autosplit_count);
}
- while (*fe) {
- if (BLI_strcasecmp(string + strlen(string) - strlen(*fe), *fe) == 0) {
- break;
+ if (rd->scemode & R_EXTENSION) {
+ while (*fe) {
+ if (BLI_strcasecmp(string + strlen(string) - strlen(*fe), *fe) == 0) {
+ break;
+ }
+ fe++;
}
- fe++;
- }
- if (*fe == NULL) {
- strcat(string, autosplit);
+ if (*fe == NULL) {
+ strcat(string, autosplit);
- BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
- strcat(string, *exts);
+ BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
+ strcat(string, *exts);
+ }
+ else {
+ *(string + strlen(string) - strlen(*fe)) = 0;
+ strcat(string, autosplit);
+ strcat(string, *fe);
+ }
}
else {
- *(string + strlen(string) - strlen(*fe)) = 0;
+ if (BLI_path_frame_check_chars(string)) {
+ BLI_path_frame_range(string, rd->sfra, rd->efra, 4);
+ }
+
strcat(string, autosplit);
- strcat(string, *fe);
}
}