Merged revision(s) 58452-58584 from trunk/blender into soc-2013-dingto.

This commit is contained in:
Thomas Dinges 2013-07-24 21:56:06 +00:00
commit 45227e25fe
220 changed files with 2557 additions and 2784 deletions

@ -181,7 +181,7 @@ static void resize(int width, int height)
options.session->reset(session_buffer_params(), options.session_params.samples);
}
void keyboard(unsigned char key)
static void keyboard(unsigned char key)
{
if(key == 'r')
options.session->reset(session_buffer_params(), options.session_params.samples);

@ -141,11 +141,13 @@ __device_inline void path_rng_2D(KernelGlobals *kg, RNG *rng, int sample, int nu
int p = *rng + dimension;
cmj_sample_2D(sample, num_samples, p, fx, fy);
}
else
#endif
/* sobol */
*fx = path_rng_1D(kg, rng, sample, num_samples, dimension);
*fy = path_rng_1D(kg, rng, sample, num_samples, dimension + 1);
{
/* sobol */
*fx = path_rng_1D(kg, rng, sample, num_samples, dimension);
*fy = path_rng_1D(kg, rng, sample, num_samples, dimension + 1);
}
}
__device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, int num_samples, RNG *rng, int x, int y, float *fx, float *fy)

@ -189,10 +189,6 @@ void TaskScheduler::init(int num_threads)
/* automatic number of threads */
num_threads = system_cpu_thread_count();
}
else {
/* manual number of threads */
num_threads;
}
/* launch threads that will be waiting for work */
threads.resize(num_threads);

@ -136,7 +136,7 @@ static void view_keyboard(unsigned char key, int x, int y)
}
}
void view_idle()
static void view_idle(void)
{
if(V.redraw) {
V.redraw = false;

@ -715,9 +715,11 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
col = split.column()
col.label(text="Origin:")
col.prop(md, "origin", text="")
sub = col.column()
sub.active = (md.origin is not None)
sub.prop(md, "use_relative")
if md.deform_method in {'TAPER', 'STRETCH', 'TWIST'}:
col.label(text="Lock:")
col.prop(md, "lock_x")
col.prop(md, "lock_y")
col = split.column()
col.label(text="Deform:")
@ -726,9 +728,6 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
else:
col.prop(md, "angle")
col.prop(md, "limits", slider=True)
if md.deform_method in {'TAPER', 'STRETCH', 'TWIST'}:
col.prop(md, "lock_x")
col.prop(md, "lock_y")
def SMOKE(self, layout, ob, md):
layout.label(text="Settings can be found inside the Physics context")

@ -232,6 +232,7 @@ class IMAGE_MT_uvs_snap(Menu):
layout.operator("uv.snap_selected", text="Selected to Pixels").target = 'PIXELS'
layout.operator("uv.snap_selected", text="Selected to Cursor").target = 'CURSOR'
layout.operator("uv.snap_selected", text="Selected to Cursor (Offset)").target = 'CURSOR_OFFSET'
layout.operator("uv.snap_selected", text="Selected to Adjacent Unselected").target = 'ADJACENT_UNSELECTED'
layout.separator()

@ -671,13 +671,14 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel, Panel):
layout.separator()
layout.prop(strip, "filepath", text="")
row = layout.row()
if sound.packed_file:
row.operator("sound.unpack", icon='PACKAGE', text="Unpack")
else:
row.operator("sound.pack", icon='UGLYPACKAGE', text="Pack")
if sound is not None:
row = layout.row()
if sound.packed_file:
row.operator("sound.unpack", icon='PACKAGE', text="Unpack")
else:
row.operator("sound.pack", icon='UGLYPACKAGE', text="Pack")
row.prop(sound, "use_memory_cache")
row.prop(sound, "use_memory_cache")
layout.prop(strip, "show_waveform")
layout.prop(strip, "volume")

@ -293,7 +293,10 @@ class VIEW3D_MT_snap(Menu):
layout = self.layout
layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
props = layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
props.use_offset = False
props = layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor (Offset)")
props.use_offset = True
layout.separator()
@ -2194,7 +2197,9 @@ class VIEW3D_MT_edit_curve_specials(Menu):
layout.operator("curve.spline_weight_set")
layout.operator("curve.radius_set")
layout.operator("curve.smooth")
layout.operator("curve.smooth_weight")
layout.operator("curve.smooth_radius")
layout.operator("curve.smooth_tilt")
class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):

@ -277,7 +277,6 @@ class VIEW3D_PT_tools_curveedit(View3DPanel, Panel):
col.operator("curve.switch_direction")
col.operator("curve.spline_type_set")
col.operator("curve.radius_set")
col.operator("curve.smooth_radius")
col = layout.column(align=True)
col.label(text="Handles:")

@ -112,7 +112,7 @@ AviError AVI_set_compress_option(AviMovie *movie, int option_type, int stream, A
awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH);
}
}
break;
}
fseek(movie->fp, movie->offset_table[0], SEEK_SET);

@ -152,6 +152,11 @@ typedef enum DMDrawFlag {
DM_DRAW_ALWAYS_SMOOTH = 2
} DMDrawFlag;
typedef enum DMForeachFlag {
DM_FOREACH_NOP = 0,
DM_FOREACH_USE_NORMAL = (1 << 0), /* foreachMappedVert, foreachMappedFaceCenter */
} DMForeachFlag;
typedef enum DMDirtyFlag {
/* dm has valid tessellated faces, but tessellated CDDATA need to be updated. */
DM_DIRTY_TESS_CDLAYERS = 1 << 0,
@ -285,7 +290,8 @@ struct DerivedMesh {
void (*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);
/** Iterate over each mapped edge in the derived mesh, calling the
* given function with the original edge and the mapped edge's new
@ -303,7 +309,8 @@ struct DerivedMesh {
void (*foreachMappedFaceCenter)(DerivedMesh *dm,
void (*func)(void *userData, int index,
const float cent[3], const float no[3]),
void *userData);
void *userData,
DMForeachFlag flag);
/** Iterate over all vertex points, calling DO_MINMAX with given args.
*

@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 268
#define BLENDER_SUBVERSION 0
#define BLENDER_SUBVERSION 1
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
@ -50,7 +50,7 @@ extern "C" {
/* used by packaging tools */
/* can be left blank, otherwise a,b,c... etc with no quotes */
#define BLENDER_VERSION_CHAR
#define BLENDER_VERSION_CHAR a
/* alpha/beta/rc/release, docs use this */
#define BLENDER_VERSION_CYCLE alpha

@ -1,98 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2004 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): Geoffrey Bantle.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BKE_BMESH_H__
#define __BKE_BMESH_H__
/** \file BKE_bmesh.h
* \ingroup bke
* \since January 2007
* \brief BMesh modeler structure and functions.
*
*/
/*NOTE: this is the bmesh 1.0 code. it's completely outdated.*/
/* uncomment to use the new bevel operator as a modifier */
#define USE_BM_BEVEL_OP_AS_MOD
/* bevel tool defines */
/* element flags */
#define BME_BEVEL_ORIG 1
#define BME_BEVEL_BEVEL (1 << 1)
#define BME_BEVEL_NONMAN (1 << 2)
#define BME_BEVEL_WIRE (1 << 3)
/* tool options */
#define BME_BEVEL_SELECT 1
#define BME_BEVEL_VERT (1 << 1)
#define BME_BEVEL_RADIUS (1 << 2)
#define BME_BEVEL_ANGLE (1 << 3)
#define BME_BEVEL_WEIGHT (1 << 4)
#define BME_BEVEL_VGROUP (1 << 5)
//~ #define BME_BEVEL_EWEIGHT (1<<4)
//~ #define BME_BEVEL_VWEIGHT (1<<5)
#define BME_BEVEL_PERCENT (1 << 6)
#define BME_BEVEL_EMIN (1 << 7)
#define BME_BEVEL_EMAX (1 << 8)
#define BME_BEVEL_RUNNING (1 << 9)
#define BME_BEVEL_RES (1 << 10)
#define BME_BEVEL_EVEN (1 << 11) /* this is a new setting not related to old (trunk bmesh bevel code) but adding
* here because they are mixed - campbell */
#define BME_BEVEL_DIST (1 << 12) /* same as above */
#define BME_BEVEL_OVERLAP_OK (1 << 13)
typedef struct BME_TransData {
struct BMesh *bm; /* the bmesh the vert belongs to */
struct BMVert *v; /* pointer to the vert this tdata applies to */
float co[3]; /* the original coordinate */
float org[3]; /* the origin */
float vec[3]; /* a directional vector; always, always normalize! */
void *loc; /* a pointer to the data to transform (likely the vert's cos) */
float factor; /* primary scaling factor; also accumulates number of weighted edges for beveling tool */
float weight; /* another scaling factor; used primarily for propogating vertex weights to transforms; */
/* weight is also used across recursive bevels to help with the math */
float maxfactor; /* the unscaled, original factor (used only by "edge verts" in recursive beveling) */
float *max; /* the maximum distance this vert can be transformed; negative is infinite
* it points to the "parent" maxfactor (where maxfactor makes little sense)
* where the max limit is stored (limits are stored per-corner) */
} BME_TransData;
typedef struct BME_TransData_Head {
struct GHash *gh; /* the hash structure for element lookup */
struct MemArena *ma; /* the memory "pool" we will be drawing individual elements from */
int len;
} BME_TransData_Head;
struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BMVert *v);
void BME_free_transdata(struct BME_TransData_Head *td);
struct BMesh *BME_bevel(struct BMesh *bm, float value, int res, int options, int defgrp_index, float angle,
BME_TransData_Head **rtd);
#endif

@ -129,6 +129,14 @@ bool BKE_nurb_type_convert(struct Nurb *nu, const short type, const bool use_han
void BKE_nurb_points_add(struct Nurb *nu, int number);
void BKE_nurb_bezierPoints_add(struct Nurb *nu, int number);
struct BezTriple *BKE_nurb_bezt_get_next(struct Nurb *nu, struct BezTriple *bezt);
struct BezTriple *BKE_nurb_bezt_get_prev(struct Nurb *nu, struct BezTriple *bezt);
struct BPoint *BKE_nurb_bpoint_get_next(struct Nurb *nu, struct BPoint *bp);
struct BPoint *BKE_nurb_bpoint_get_prev(struct Nurb *nu, struct BPoint *bp);
void BKE_nurb_bezt_calc_normal(struct Nurb *nu, struct BezTriple *bezt, float r_normal[3]);
void BKE_nurb_bezt_calc_plane(struct Nurb *nu, struct BezTriple *bezt, float r_plane[3]);
void BKE_nurb_handle_calc(struct BezTriple *bezt, struct BezTriple *prev, struct BezTriple *next, int mode);
void BKE_nurb_handles_calc(struct Nurb *nu);

@ -46,7 +46,6 @@ extern "C" {
/* forwards */
struct Main;
struct Object;
struct BME_Glob;
typedef struct Global {

@ -223,7 +223,7 @@ typedef struct PBVHVertexIter {
struct CCGElem **grids;
struct CCGElem *grid;
struct CCGKey *key;
BLI_bitmap *grid_hidden, gh;
BLI_bitmap **grid_hidden, *gh;
int *grid_indices;
int totgrid;
int gridsize;

@ -208,6 +208,10 @@ int BKE_sequencer_recursive_apply(struct Sequence *seq, int (*apply_func)(struct
void BKE_sequencer_free_clipboard(void);
void BKE_sequence_clipboard_pointers_free(struct Sequence *seq);
void BKE_sequence_clipboard_pointers_store(struct Sequence *seq);
void BKE_sequence_clipboard_pointers_restore(struct Sequence *seq, struct Main *bmain);
void BKE_sequence_free(struct Scene *scene, struct Sequence *seq);
const char *BKE_sequence_give_name(struct Sequence *seq);
void BKE_sequence_calc(struct Scene *scene, struct Sequence *seq);
@ -319,8 +323,6 @@ void BKE_sequence_base_dupli_recursive(struct Scene *scene, struct Scene *scene_
bool BKE_sequence_is_valid_check(struct Sequence *seq);
void BKE_sequencer_clear_scene_in_allseqs(struct Main *bmain, struct Scene *sce);
void BKE_sequencer_clear_movieclip_in_clipboard(struct MovieClip *clip);
void BKE_sequencer_clear_mask_in_clipboard(struct Mask *mask);
struct Sequence *BKE_sequence_get_by_name(struct ListBase *seqbase, const char *name, int recursive);

@ -86,7 +86,6 @@ void txt_sel_all (struct Text *text);
void txt_sel_line (struct Text *text);
char *txt_sel_to_buf (struct Text *text);
void txt_insert_buf (struct Text *text, const char *in_buffer);
void txt_print_undo (struct Text *text);
void txt_undo_add_op (struct Text *text, int op);
void txt_do_undo (struct Text *text);
void txt_do_redo (struct Text *text);
@ -106,6 +105,10 @@ int txt_setcurr_tab_spaces(struct Text *text, int space);
bool txt_cursor_is_line_start(struct Text *text);
bool txt_cursor_is_line_end(struct Text *text);
#if 0
void txt_print_undo (struct Text *text);
#endif
/* utility functions, could be moved somewhere more generic but are python/text related */
int text_check_bracket(const char ch);
int text_check_delim(const char ch);

@ -165,7 +165,6 @@ set(SRC
BKE_armature.h
BKE_autoexec.h
BKE_blender.h
BKE_bmesh.h
BKE_bmfont.h
BKE_bmfont_types.h
BKE_boids.h

@ -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++) {

@ -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;
}
}

@ -1548,19 +1548,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 +1595,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);

@ -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

@ -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 */

@ -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_mallocN(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)
@ -2391,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;

@ -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 */

@ -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);
@ -926,9 +1060,9 @@ static void emDM_drawMappedFacesMat(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;
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);
@ -1139,7 +1279,9 @@ static void emDM_getVertNo(DerivedMesh *dm, int index, float r_no[3])
return;
}
if (bmdm->vertexNos) {
if (bmdm->vertexCos) {
emDM_ensureVertNormals(bmdm);
copy_v3_v3(r_no, bmdm->vertexNos[index]);
}
else {
@ -1159,7 +1301,8 @@ static void emDM_getPolyNo(DerivedMesh *dm, int index, float r_no[3])
return;
}
if (bmdm->polyNos) {
if (bmdm->vertexCos) {
emDM_ensurePolyNormals(bmdm);
copy_v3_v3(r_no, bmdm->polyNos[index]);
}
else {
@ -1313,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);
}
}
@ -1439,8 +1583,16 @@ 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);
if (bmdm->vertexNos) {
MEM_freeN(bmdm->vertexNos);
}
if (bmdm->polyNos) {
MEM_freeN(bmdm->polyNos);
}
}
if (bmdm->polyCos) {
MEM_freeN(bmdm->polyCos);
}
MEM_freeN(bmdm);
@ -1549,7 +1701,7 @@ 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) {
@ -1578,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;
}
@ -1877,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 */
@ -1886,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);
@ -1903,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;
@ -2006,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,
@ -2018,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,
@ -2029,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);
@ -2047,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 */
@ -2065,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],
@ -2082,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];
@ -2097,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);

@ -373,5 +373,6 @@ void BKE_editmesh_color_ensure(BMEditMesh *em, const char htype)
break;
default:
BLI_assert(0);
break;
}
}

@ -1764,6 +1764,7 @@ static float evaluate_driver(ChannelDriver *driver, const float evaltime)
* This is currently used as the mechanism which allows animated settings to be able
* to be changed via the UI.
*/
break;
}
}

@ -343,6 +343,8 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float
}
default:
printf("Invalid Function-Generator for F-Modifier - %d\n", data->type);
break;
}
/* execute function callback to set value if appropriate */

@ -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;
}
}

@ -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;

@ -1057,6 +1057,7 @@ void free_main(Main *mainvar)
case 32: BKE_libblock_free(lb, id); break;
default:
BLI_assert(0);
break;
}
#endif
}

@ -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) {

@ -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)
{

@ -37,7 +37,6 @@
#include "BLI_array.h"
#include "BKE_DerivedMesh.h"
#include "BKE_bmesh.h"
#include "BKE_editmesh.h"
/* Static function for alloc */

@ -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);

@ -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);

@ -1614,6 +1614,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;
}
}
}

@ -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;

@ -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;
}

@ -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;

@ -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);

@ -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;

@ -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));

@ -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);

@ -65,6 +65,7 @@
#include "BKE_fcurve.h"
#include "BKE_scene.h"
#include "BKE_mask.h"
#include "BKE_library.h"
#include "RNA_access.h"
@ -265,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);
}
@ -279,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) {
@ -818,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 {
@ -4245,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);
@ -4256,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 =
@ -4278,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)

@ -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));
}
}
}
@ -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;

@ -1496,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;
@ -1607,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;
}
}
}
@ -1659,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)
{
@ -1850,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;
@ -1925,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;
@ -2013,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);
@ -2050,10 +2052,7 @@ void txt_do_undo(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;
/* get and restore the cursors */
txt_undo_read_cursors(text->undo_buf, &text->undo_pos, &curln, &curc, &selln, &selc);
@ -2204,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);
@ -2233,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;
@ -2366,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;
@ -2375,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);

@ -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;

@ -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;

@ -26,7 +26,7 @@
#ifndef __BLI_BITMAP_H__
#define __BLI_BITMAP_H__
typedef unsigned int *BLI_bitmap;
typedef unsigned int BLI_bitmap;
/* warning: the bitmap does not keep track of its own size or check
* for out-of-bounds access */
@ -48,7 +48,7 @@ typedef unsigned int *BLI_bitmap;
/* allocate memory for a bitmap with '_tot' bits; free
* with MEM_freeN() */
#define BLI_BITMAP_NEW(_tot, _alloc_string) \
((BLI_bitmap)MEM_callocN(BLI_BITMAP_SIZE(_tot), \
((BLI_bitmap *)MEM_callocN(BLI_BITMAP_SIZE(_tot), \
_alloc_string))
/* get the value of a single bit at '_index' */

@ -89,7 +89,18 @@ void BLI_make_existing_file(const char *name);
void BLI_split_dirfile(const char *string, char *dir, char *file, const size_t dirlen, const size_t filelen);
void BLI_split_dir_part(const char *string, char *dir, const size_t dirlen);
void BLI_split_file_part(const char *string, char *file, const size_t filelen);
void BLI_join_dirfile(char *string, const size_t maxlen, const char *dir, const char *file);
void BLI_path_append(char *__restrict dst, const size_t maxlen,
const char *__restrict file)
#ifdef __GNUC__
__attribute__((nonnull))
#endif
;
void BLI_join_dirfile(char *__restrict string, const size_t maxlen,
const char *__restrict dir, const char *__restrict file)
#ifdef __GNUC__
__attribute__((nonnull))
#endif
;
const char *BLI_path_basename(const char *path);
typedef enum bli_rebase_state {

@ -31,43 +31,57 @@
extern "C" {
#endif
char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy);
char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy);
int BLI_utf8_invalid_byte(const char *str, int length);
int BLI_utf8_invalid_strip(char *str, int length);
#ifdef __GNUC__
# define ATTR_NONULL __attribute__((nonnull))
# define ATTR_NONULL_FIRST __attribute__((nonnull(1)))
# define ATTR_UNUSED_RESULT __attribute__((warn_unused_result))
#else
# define ATTR_NONULL
# define ATTR_NONULL_FIRST
# define ATTR_UNUSED_RESULT
#endif
int BLI_str_utf8_size(const char *p); /* warning, can return -1 on bad chars */
int BLI_str_utf8_size_safe(const char *p);
char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONULL;
char *BLI_strncat_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONULL;
int BLI_utf8_invalid_byte(const char *str, int length) ATTR_NONULL;
int BLI_utf8_invalid_strip(char *str, int length) ATTR_NONULL;
int BLI_str_utf8_size(const char *p) ATTR_NONULL; /* warning, can return -1 on bad chars */
int BLI_str_utf8_size_safe(const char *p) ATTR_NONULL;
/* copied from glib */
unsigned int BLI_str_utf8_as_unicode(const char *p);
unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t *__restrict index);
unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, size_t *__restrict index);
unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index);
unsigned int BLI_str_utf8_as_unicode(const char *p) ATTR_NONULL;
unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t *__restrict index) ATTR_NONULL;
unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, size_t *__restrict index) ATTR_NONULL;
unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index) ATTR_NONULL;
size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf);
char *BLI_str_find_prev_char_utf8(const char *str, const char *p);
char *BLI_str_find_next_char_utf8(const char *p, const char *end);
char *BLI_str_prev_char_utf8(const char *p);
char *BLI_str_find_prev_char_utf8(const char *str, const char *p) ATTR_NONULL;
char *BLI_str_find_next_char_utf8(const char *p, const char *end) ATTR_NONULL_FIRST;
char *BLI_str_prev_char_utf8(const char *p) ATTR_NONULL;
/* wchar_t functions, copied from blenders own font.c originally */
size_t BLI_wstrlen_utf8(const wchar_t *src);
size_t BLI_strlen_utf8_ex(const char *strc, int *r_len_bytes);
size_t BLI_strlen_utf8(const char *strc);
size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, int *r_len_bytes);
size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen);
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxcpy);
size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst, const char *__restrict src, const size_t maxcpy);
size_t BLI_wstrlen_utf8(const wchar_t *src) ATTR_NONULL;
size_t BLI_strlen_utf8_ex(const char *strc, size_t *r_len_bytes) ATTR_NONULL;
size_t BLI_strlen_utf8(const char *strc) ATTR_NONULL;
size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, size_t *r_len_bytes) ATTR_NONULL;
size_t BLI_strnlen_utf8(const char *strc, const size_t maxlen) ATTR_NONULL;
size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxcpy) ATTR_NONULL;
size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst, const char *__restrict src, const size_t maxcpy) ATTR_NONULL;
/* count columns that character/string occupies, based on wcwidth.c */
int BLI_wcwidth(wchar_t ucs);
int BLI_wcswidth(const wchar_t *pwcs, size_t n);
int BLI_str_utf8_char_width(const char *p); /* warning, can return -1 on bad chars */
int BLI_str_utf8_char_width_safe(const char *p);
int BLI_wcswidth(const wchar_t *pwcs, size_t n) ATTR_NONULL;
int BLI_str_utf8_char_width(const char *p) ATTR_NONULL; /* warning, can return -1 on bad chars */
int BLI_str_utf8_char_width_safe(const char *p) ATTR_NONULL;
#define BLI_UTF8_MAX 6 /* mem */
#define BLI_UTF8_WIDTH_MAX 2 /* columns */
#define BLI_UTF8_ERR ((unsigned int)-1)
#undef ATTR_NONULL
#undef ATTR_NONULL_FIRST
#undef ATTR_UNUSED_RESULT
#ifdef __cplusplus
}
#endif

@ -34,6 +34,7 @@
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include "MEM_guardedalloc.h"
@ -255,22 +256,14 @@ void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreef
GHashIterator *BLI_ghashIterator_new(GHash *gh)
{
GHashIterator *ghi = MEM_mallocN(sizeof(*ghi), "ghash iterator");
ghi->gh = gh;
ghi->curEntry = NULL;
ghi->curBucket = (unsigned int)-1;
while (!ghi->curEntry) {
ghi->curBucket++;
if (ghi->curBucket == ghi->gh->nbuckets)
break;
ghi->curEntry = ghi->gh->buckets[ghi->curBucket];
}
BLI_ghashIterator_init(ghi, gh);
return ghi;
}
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
{
ghi->gh = gh;
ghi->curEntry = NULL;
ghi->curBucket = (unsigned int)-1;
ghi->curBucket = UINT_MAX; /* wraps to zero */
while (!ghi->curEntry) {
ghi->curBucket++;
if (ghi->curBucket == ghi->gh->nbuckets)

@ -445,7 +445,7 @@ static void join_dirfile_alloc(char **dst, size_t *alloc_len, const char *dir, c
size_t len = strlen(dir) + strlen(file) + 1;
if (*dst == NULL)
*dst = MEM_callocN(len + 1, "join_dirfile_alloc path");
*dst = MEM_mallocN(len + 1, "join_dirfile_alloc path");
else if (*alloc_len < len)
*dst = MEM_reallocN(*dst, len + 1);

@ -150,6 +150,7 @@ void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr, in
break;
default:
assert(!"invalid colorspace");
break;
}
*ly = y;
@ -183,7 +184,8 @@ void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb, in
b = y + 1.772f * cb - 226.816f;
break;
default:
assert(!"invalid colorspace");
BLI_assert(0);
break;
}
*lr = r / 255.0f;
*lg = g / 255.0f;

@ -839,6 +839,7 @@ void orthogonalize_m3(float mat[3][3], int axis)
break;
default:
BLI_assert(0);
break;
}
mul_v3_fl(mat[0], size[0]);
mul_v3_fl(mat[1], size[1]);
@ -922,6 +923,7 @@ void orthogonalize_m4(float mat[4][4], int axis)
break;
default:
BLI_assert(0);
break;
}
mul_v3_fl(mat[0], size[0]);
mul_v3_fl(mat[1], size[1]);

@ -857,7 +857,8 @@ void single_axis_angle_to_mat3(float mat[3][3], const char axis, const float ang
mat[2][2] = 1.0f;
break;
default:
assert(0);
BLI_assert(0);
break;
}
}

@ -1252,6 +1252,7 @@ void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtyp
case 0:
default:
distfunc = dist_Real;
break;
}
xi = (int)(floor(x));
@ -1467,6 +1468,7 @@ float BLI_gNoise(float noisesize, float x, float y, float z, int hard, int noise
x += 1;
y += 1;
z += 1;
break;
}
}
@ -1522,6 +1524,7 @@ float BLI_gTurbulence(float noisesize, float x, float y, float z, int oct, int h
x += 1;
y += 1;
z += 1;
break;
}
if (noisesize != 0.0f) {
@ -1596,6 +1599,7 @@ float mg_fBm(float x, float y, float z, float H, float lacunarity, float octaves
default:
{
noisefunc = orgBlenderNoiseS;
break;
}
}
@ -1667,6 +1671,7 @@ float mg_MultiFractal(float x, float y, float z, float H, float lacunarity, floa
default:
{
noisefunc = orgBlenderNoiseS;
break;
}
}
@ -1734,6 +1739,7 @@ float mg_HeteroTerrain(float x, float y, float z, float H, float lacunarity, flo
default:
{
noisefunc = orgBlenderNoiseS;
break;
}
}
@ -1808,6 +1814,7 @@ float mg_HybridMultiFractal(float x, float y, float z, float H, float lacunarity
default:
{
noisefunc = orgBlenderNoiseS;
break;
}
}
@ -1884,6 +1891,7 @@ float mg_RidgedMultiFractal(float x, float y, float z, float H, float lacunarity
default:
{
noisefunc = orgBlenderNoiseS;
break;
}
}
@ -1950,6 +1958,7 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
default:
{
noisefunc1 = orgBlenderNoiseS;
break;
}
}
@ -1985,6 +1994,7 @@ float mg_VLNoise(float x, float y, float z, float distortion, int nbas1, int nba
default:
{
noisefunc2 = orgBlenderNoiseS;
break;
}
}

@ -695,8 +695,10 @@ bool BLI_path_frame(char *path, int frame, int digits)
if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
char tmp[FILE_MAX];
sprintf(tmp, "%.*s%.*d%s", ch_sta, path, ch_end - ch_sta, frame, path + ch_end);
strcpy(path, tmp);
BLI_snprintf(tmp, sizeof(tmp),
"%.*s%.*d%s",
ch_sta, path, ch_end - ch_sta, frame, path + ch_end);
BLI_strncpy(path, tmp, FILE_MAX);
return true;
}
return false;
@ -1228,6 +1230,7 @@ const char *BLI_get_folder(int folder_id, const char *subfolder)
default:
BLI_assert(0);
break;
}
return path;
@ -1256,7 +1259,9 @@ const char *BLI_get_user_folder_notest(int folder_id, const char *subfolder)
break;
default:
BLI_assert(0);
break;
}
if ('\0' == path[0]) {
return NULL;
}
@ -1306,6 +1311,7 @@ const char *BLI_get_folder_version(const int id, const int ver, const bool do_ch
path[0] = '\0'; /* in case do_check is false */
ok = false;
BLI_assert(!"incorrect ID");
break;
}
if (!ok && do_check) {
@ -1684,6 +1690,26 @@ void BLI_split_file_part(const char *string, char *file, const size_t filelen)
BLI_split_dirfile(string, NULL, file, 0, filelen);
}
/**
* Append a filename to a dir, ensuring slash separates.
*/
void BLI_path_append(char *dst, const size_t maxlen, const char *file)
{
size_t dirlen = BLI_strnlen(dst, maxlen);
/* inline BLI_add_slash */
if ((dirlen > 0) && (dst[dirlen - 1] != SEP)) {
dst[dirlen++] = SEP;
dst[dirlen] = '\0';
}
if (dirlen >= maxlen) {
return; /* fills the path */
}
BLI_strncpy(dst + dirlen, file, maxlen - dirlen);
}
/**
* Simple appending of filename to dir, does not check for valid path!
* Puts result into *dst, which may be same area as *dir.
@ -1692,15 +1718,16 @@ void BLI_join_dirfile(char *dst, const size_t maxlen, const char *dir, const cha
{
size_t dirlen = BLI_strnlen(dir, maxlen);
if (dst != dir) {
if (dirlen == maxlen) {
memcpy(dst, dir, dirlen);
dst[dirlen - 1] = '\0';
return; /* dir fills the path */
}
else {
memcpy(dst, dir, dirlen + 1);
}
/* args can't match */
BLI_assert(!ELEM(dst, dir, file));
if (dirlen == maxlen) {
memcpy(dst, dir, dirlen);
dst[dirlen - 1] = '\0';
return; /* dir fills the path */
}
else {
memcpy(dst, dir, dirlen + 1);
}
if (dirlen + 1 >= maxlen) {
@ -1717,10 +1744,6 @@ void BLI_join_dirfile(char *dst, const size_t maxlen, const char *dir, const cha
return; /* fills the path */
}
if (file == NULL) {
return;
}
BLI_strncpy(dst + dirlen, file, maxlen - dirlen);
}
@ -1836,7 +1859,7 @@ int BLI_rebase_path(char *abs, size_t abs_len,
/* subdirectories relative to blend_dir */
BLI_join_dirfile(dest_path, sizeof(dest_path), dest_dir, rel_dir);
/* same subdirectories relative to dest_dir */
BLI_join_dirfile(dest_path, sizeof(dest_path), dest_path, base);
BLI_path_append(dest_path, sizeof(dest_path), base);
/* keeping original item basename */
}
@ -2057,7 +2080,7 @@ static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name
else {
strncpy(filename, path, sizeof(filename));
}
BLI_join_dirfile(fullname, maxlen, fullname, name);
BLI_path_append(fullname, maxlen, name);
if (add_win32_extension(filename)) {
BLI_strncpy(fullname, filename, maxlen);
break;

@ -388,17 +388,14 @@ static void bli_adddirstrings(struct BuildDirCtx *dir_ctx)
*/
st_size = file->s.st_size;
/* FIXME: Either change decimal prefixes to binary ones
* <http://en.wikipedia.org/wiki/Binary_prefix>, or change
* divisor factors from 1024 to 1000. */
if (st_size > 1024 * 1024 * 1024) {
BLI_snprintf(file->size, sizeof(file->size), "%.2f GB", ((double)st_size) / (1024 * 1024 * 1024));
BLI_snprintf(file->size, sizeof(file->size), "%.2f GiB", ((double)st_size) / (1024 * 1024 * 1024));
}
else if (st_size > 1024 * 1024) {
BLI_snprintf(file->size, sizeof(file->size), "%.1f MB", ((double)st_size) / (1024 * 1024));
BLI_snprintf(file->size, sizeof(file->size), "%.1f MiB", ((double)st_size) / (1024 * 1024));
}
else if (st_size > 1024) {
BLI_snprintf(file->size, sizeof(file->size), "%d KB", (int)(st_size / 1024));
BLI_snprintf(file->size, sizeof(file->size), "%d KiB", (int)(st_size / 1024));
}
else {
BLI_snprintf(file->size, sizeof(file->size), "%d B", (int)st_size);

@ -87,15 +87,18 @@ char *BLI_strdup(const char *str)
*/
char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2)
{
size_t len;
char *n;
/* include the NULL terminator of str2 only */
const size_t str1_len = strlen(str1);
const size_t str2_len = strlen(str2) + 1;
char *str, *s;
len = strlen(str1) + strlen(str2);
n = MEM_mallocN(len + 1, "strdupcat");
strcpy(n, str1);
strcat(n, str2);
return n;
str = MEM_mallocN(str1_len + str2_len, "strdupcat");
s = str;
memcpy(s, str1, str1_len); s += str1_len;
memcpy(s, str2, str2_len);
return str;
}
/**
@ -240,6 +243,7 @@ size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const siz
goto escape_finish;
case '\\':
case '"':
/* fall-through */
/* less common but should also be support */
case '\t':
@ -253,9 +257,10 @@ size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const siz
/* not enough space to escape */
break;
}
/* intentionally pass through */
/* fall-through */
default:
*dst = *src;
break;
}
dst++;
src++;

@ -260,7 +260,7 @@ size_t BLI_wstrlen_utf8(const wchar_t *src)
return len;
}
size_t BLI_strlen_utf8_ex(const char *strc, int *r_len_bytes)
size_t BLI_strlen_utf8_ex(const char *strc, size_t *r_len_bytes)
{
size_t len;
const char *strc_orig = strc;
@ -268,7 +268,7 @@ size_t BLI_strlen_utf8_ex(const char *strc, int *r_len_bytes)
for (len = 0; *strc; len++)
strc += BLI_str_utf8_size_safe(strc);
*r_len_bytes = (strc - strc_orig);
*r_len_bytes = (size_t)(strc - strc_orig);
return len;
}
@ -282,7 +282,7 @@ size_t BLI_strlen_utf8(const char *strc)
return len;
}
size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, int *r_len_bytes)
size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, size_t *r_len_bytes)
{
size_t len;
const char *strc_orig = strc;
@ -292,7 +292,7 @@ size_t BLI_strnlen_utf8_ex(const char *strc, const size_t maxlen, int *r_len_byt
strc += BLI_str_utf8_size_safe(strc);
}
*r_len_bytes = (strc - strc_orig);
*r_len_bytes = (size_t)(strc - strc_orig);
return len;
}

@ -5803,21 +5803,23 @@ static void *restore_pointer_by_name(Main *mainp, ID *id, int user)
return NULL;
}
static void lib_link_seq_clipboard_pt_restore(ID *id, Main *newmain)
{
if (id) {
/* clipboard must ensure this */
BLI_assert(id->newid != NULL);
id->newid = restore_pointer_by_name(newmain, (ID *)id->newid, 1);
}
}
static int lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt)
{
Main *newmain = (Main *)arg_pt;
if (seq->sound) {
seq->sound = restore_pointer_by_name(newmain, (ID *)seq->sound, 0);
seq->sound->id.us++;
}
if (seq->scene)
seq->scene = restore_pointer_by_name(newmain, (ID *)seq->scene, 1);
if (seq->scene_camera)
seq->scene_camera = restore_pointer_by_name(newmain, (ID *)seq->scene_camera, 1);
lib_link_seq_clipboard_pt_restore((ID *)seq->scene, newmain);
lib_link_seq_clipboard_pt_restore((ID *)seq->scene_camera, newmain);
lib_link_seq_clipboard_pt_restore((ID *)seq->clip, newmain);
lib_link_seq_clipboard_pt_restore((ID *)seq->mask, newmain);
lib_link_seq_clipboard_pt_restore((ID *)seq->sound, newmain);
return 1;
}
@ -9487,7 +9489,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
if (!MAIN_VERSION_ATLEAST(main, 268, 1)) {
Brush *brush;
for (brush = main->brush.first; brush; brush = brush->id.next) {
brush->spacing = MAX2(1, brush->spacing);
}
}
{
bScreen *sc;
Object *ob;

@ -1660,8 +1660,8 @@ static void write_curves(WriteData *wd, ListBase *idbase)
if (cu->vfont) {
/* TODO, sort out 'cu->len', in editmode its character, object mode its bytes */
int len_bytes;
int len_chars = BLI_strlen_utf8_ex(cu->str, &len_bytes);
size_t len_bytes;
size_t len_chars = BLI_strlen_utf8_ex(cu->str, &len_bytes);
writedata(wd, DATA, len_bytes + 1, cu->str);
writestruct(wd, DATA, "CharInfo", len_chars + 1, cu->strinfo);

@ -23,7 +23,7 @@
#
# ***** END GPL LICENSE BLOCK *****
set(INC
set(INC
.
../blenfont
../blenkernel
@ -50,7 +50,7 @@ set(SRC
operators/bmo_edgenet.c
operators/bmo_extrude.c
operators/bmo_fill_edgeloop.c
operators/bmo_fill_grid.c
operators/bmo_fill_grid.c
operators/bmo_hull.c
operators/bmo_inset.c
operators/bmo_join_triangles.c
@ -115,7 +115,6 @@ set(SRC
intern/bmesh_operator_api.h
intern/bmesh_error.h
tools/BME_bevel.c
tools/bmesh_bevel.c
tools/bmesh_bevel.h
tools/bmesh_decimate_collapse.c

@ -817,11 +817,6 @@ void BM_elem_attrs_copy_ex(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v,
BLI_assert(ele_src->htype == ele_dst->htype);
if (ele_src->htype != ele_dst->htype) {
BLI_assert(!"type mismatch");
return;
}
if ((hflag_mask & BM_ELEM_SELECT) == 0) {
/* First we copy select */
if (BM_elem_flag_test((BMElem *)ele_src, BM_ELEM_SELECT)) {
@ -833,6 +828,9 @@ void BM_elem_attrs_copy_ex(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v,
if (hflag_mask == 0) {
ele_dst->hflag = ele_src->hflag;
}
else if (hflag_mask == 0xff) {
/* pass */
}
else {
ele_dst->hflag = ((ele_dst->hflag & hflag_mask) | (ele_src->hflag & ~hflag_mask));
}
@ -853,13 +851,26 @@ void BM_elem_attrs_copy_ex(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v,
break;
default:
BLI_assert(0);
break;
}
}
void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src, void *ele_dst)
{
/* BMESH_TODO, default 'use_flags' to false */
BM_elem_attrs_copy_ex(bm_src, bm_dst, ele_src, ele_dst, 0);
BM_elem_attrs_copy_ex(bm_src, bm_dst, ele_src, ele_dst, BM_ELEM_SELECT);
}
void BM_elem_select_copy(BMesh *UNUSED(bm_src), BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v)
{
const BMHeader *ele_src = ele_src_v;
BMHeader *ele_dst = ele_dst_v;
BLI_assert(ele_src->htype == ele_dst->htype);
if ((ele_src->hflag & BM_ELEM_SELECT) != (ele_dst->hflag & BM_ELEM_SELECT)) {
BM_elem_select_set(bm_dst, (BMElem *)ele_dst, (ele_src->hflag & BM_ELEM_SELECT) != 0);
}
}
/* helper function for 'BM_mesh_copy' */
@ -893,7 +904,8 @@ static BMFace *bm_mesh_copy_new_face(BMesh *bm_new, BMesh *bm_old,
/* use totface in case adding some faces fails */
BM_elem_index_set(f_new, (bm_new->totface - 1)); /* set_inline */
BM_elem_attrs_copy(bm_old, bm_new, f, f_new);
BM_elem_attrs_copy_ex(bm_old, bm_new, f, f_new, 0xff);
f_new->head.hflag = f->head.hflag; /* low level! don't do this for normal api use */
j = 0;
l_iter = l_first = BM_FACE_FIRST_LOOP(f_new);
@ -950,7 +962,8 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
BM_ITER_MESH_INDEX (v, &iter, bm_old, BM_VERTS_OF_MESH, i) {
/* copy between meshes so cant use 'example' argument */
v_new = BM_vert_create(bm_new, v->co, NULL, BM_CREATE_SKIP_CD);
BM_elem_attrs_copy(bm_old, bm_new, v, v_new);
BM_elem_attrs_copy_ex(bm_old, bm_new, v, v_new, 0xff);
v_new->head.hflag = v->head.hflag; /* low level! don't do this for normal api use */
vtable[i] = v_new;
BM_elem_index_set(v, i); /* set_inline */
BM_elem_index_set(v_new, i); /* set_inline */
@ -967,7 +980,8 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
vtable[BM_elem_index_get(e->v2)],
e, BM_CREATE_SKIP_CD);
BM_elem_attrs_copy(bm_old, bm_new, e, e_new);
BM_elem_attrs_copy_ex(bm_old, bm_new, e, e_new, 0xff);
e_new->head.hflag = e->head.hflag; /* low level! don't do this for normal api use */
etable[i] = e_new;
BM_elem_index_set(e, i); /* set_inline */
BM_elem_index_set(e_new, i); /* set_inline */
@ -990,6 +1004,12 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
bm_old->elem_index_dirty &= ~BM_FACE;
bm_new->elem_index_dirty &= ~BM_FACE;
/* low level! don't do this for normal api use */
bm_new->totvertsel = bm_old->totvertsel;
bm_new->totedgesel = bm_old->totedgesel;
bm_new->totfacesel = bm_old->totfacesel;
/* safety check */
BLI_assert(i == bm_old->totface);

@ -53,6 +53,7 @@ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type);
void BM_elem_attrs_copy_ex(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v,
const char hflag_mask);
void BM_elem_attrs_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v);
void BM_elem_select_copy(BMesh *bm_src, BMesh *bm_dst, const void *ele_src_v, void *ele_dst_v);
void BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh *bm_src, const struct BMAllocTemplate *allocsize);
BMesh *BM_mesh_copy(BMesh *bm_old);

@ -502,6 +502,7 @@ int bmesh_elem_check(void *element, const char htype)
}
default:
BLI_assert(0);
break;
}
BMESH_ASSERT(err == 0);

@ -583,9 +583,8 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
MEdge *med, *medge;
BMVert *v, *eve;
BMEdge *e;
BMLoop *l;
BMFace *f;
BMIter iter, liter;
BMIter iter;
int i, j, ototvert;
const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
@ -699,22 +698,26 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
i = 0;
j = 0;
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
BMLoop *l_iter, *l_first;
mpoly->loopstart = j;
mpoly->totloop = f->len;
mpoly->mat_nr = f->mat_nr;
mpoly->flag = BM_face_flag_to_mflag(f);
l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f);
for ( ; l; l = BM_iter_step(&liter), j++, mloop++) {
mloop->e = BM_elem_index_get(l->e);
mloop->v = BM_elem_index_get(l->v);
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
mloop->e = BM_elem_index_get(l_iter->e);
mloop->v = BM_elem_index_get(l_iter->v);
/* copy over customdat */
CustomData_from_bmesh_block(&bm->ldata, &me->ldata, l->head.data, j);
BM_CHECK_ELEMENT(l);
BM_CHECK_ELEMENT(l->e);
BM_CHECK_ELEMENT(l->v);
}
/* copy over customdata */
CustomData_from_bmesh_block(&bm->ldata, &me->ldata, l_iter->head.data, j);
j++;
mloop++;
BM_CHECK_ELEMENT(l_iter);
BM_CHECK_ELEMENT(l_iter->e);
BM_CHECK_ELEMENT(l_iter->v);
} while ((l_iter = l_iter->next) != l_first);
if (f == bm->act_face) me->act_face = i;

@ -49,9 +49,9 @@ enum {
};
enum {
SUBDIV_SELECT_NONE,
SUBDIV_SELECT_ORIG,
SUBDIV_SELECT_INNER,
SUBDIV_SELECT_INNER_SEL,
SUBDIV_SELECT_LOOPCUT
};

@ -125,7 +125,7 @@ static void bm_face_calc_poly_normal(BMFace *f, float n[3])
* Same as #calc_poly_normal and #bm_face_calc_poly_normal
* but takes an array of vertex locations.
*/
static void bm_face_calc_poly_normal_vertex_cos(BMFace *f, float n[3],
static void bm_face_calc_poly_normal_vertex_cos(BMFace *f, float r_no[3],
float const (*vertexCos)[3])
{
BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
@ -133,22 +133,40 @@ static void bm_face_calc_poly_normal_vertex_cos(BMFace *f, float n[3],
float const *v_prev = vertexCos[BM_elem_index_get(l_first->prev->v)];
float const *v_curr = vertexCos[BM_elem_index_get(l_first->v)];
zero_v3(n);
zero_v3(r_no);
/* Newell's Method */
do {
add_newell_cross_v3_v3v3(n, v_prev, v_curr);
add_newell_cross_v3_v3v3(r_no, v_prev, v_curr);
l_iter = l_iter->next;
v_prev = v_curr;
v_curr = vertexCos[BM_elem_index_get(l_iter->v)];
} while (l_iter != l_first);
if (UNLIKELY(normalize_v3(n) == 0.0f)) {
n[2] = 1.0f; /* other axis set to 0.0 */
if (UNLIKELY(normalize_v3(r_no) == 0.0f)) {
r_no[2] = 1.0f; /* other axis set to 0.0 */
}
}
/**
* \brief COMPUTE POLY CENTER (BMFace)
*/
static void bm_face_calc_poly_center_mean_vertex_cos(BMFace *f, float r_cent[3],
float const (*vertexCos)[3])
{
BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
BMLoop *l_iter = l_first;
zero_v3(r_cent);
/* Newell's Method */
do {
add_v3_v3(r_cent, vertexCos[BM_elem_index_get(l_iter->v)]);
} while ((l_iter = l_iter->next) != l_first);
mul_v3_fl(r_cent, 1.0f / f->len);
}
/**
* For tools that insist on using triangles, ideally we would cache this data.
*
@ -370,8 +388,7 @@ void BM_face_calc_center_bounds(BMFace *f, float r_cent[3])
*/
void BM_face_calc_center_mean(BMFace *f, float r_cent[3])
{
BMLoop *l_iter;
BMLoop *l_first;
BMLoop *l_iter, *l_first;
zero_v3(r_cent);
@ -379,9 +396,7 @@ void BM_face_calc_center_mean(BMFace *f, float r_cent[3])
do {
add_v3_v3(r_cent, l_iter->v->co);
} while ((l_iter = l_iter->next) != l_first);
if (f->len)
mul_v3_fl(r_cent, 1.0f / (float) f->len);
mul_v3_fl(r_cent, 1.0f / (float) f->len);
}
/**
@ -601,9 +616,9 @@ void BM_face_normal_update(BMFace *f)
BM_face_calc_normal(f, f->no);
}
/* exact same as 'bmesh_face_normal_update' but accepts vertex coords */
void BM_face_normal_update_vcos(BMesh *bm, BMFace *f, float no[3],
float const (*vertexCos)[3])
/* exact same as 'BM_face_calc_normal' but accepts vertex coords */
void BM_face_calc_normal_vcos(BMesh *bm, BMFace *f, float r_no[3],
float const (*vertexCos)[3])
{
BMLoop *l;
@ -620,7 +635,7 @@ void BM_face_normal_update_vcos(BMesh *bm, BMFace *f, float no[3],
const float *co3 = vertexCos[BM_elem_index_get((l = l->next)->v)];
const float *co4 = vertexCos[BM_elem_index_get((l->next)->v)];
normal_quad_v3(no, co1, co2, co3, co4);
normal_quad_v3(r_no, co1, co2, co3, co4);
break;
}
case 3:
@ -629,22 +644,33 @@ void BM_face_normal_update_vcos(BMesh *bm, BMFace *f, float no[3],
const float *co2 = vertexCos[BM_elem_index_get((l = l->next)->v)];
const float *co3 = vertexCos[BM_elem_index_get((l->next)->v)];
normal_tri_v3(no, co1, co2, co3);
normal_tri_v3(r_no, co1, co2, co3);
break;
}
case 0:
{
zero_v3(no);
zero_v3(r_no);
break;
}
default:
{
bm_face_calc_poly_normal_vertex_cos(f, no, vertexCos);
bm_face_calc_poly_normal_vertex_cos(f, r_no, vertexCos);
break;
}
}
}
/* exact same as 'BM_face_calc_normal' but accepts vertex coords */
void BM_face_calc_center_mean_vcos(BMesh *bm, BMFace *f, float r_cent[3],
float const (*vertexCos)[3])
{
/* must have valid index data */
BLI_assert((bm->elem_index_dirty & BM_VERT) == 0);
(void)bm;
bm_face_calc_poly_center_mean_vertex_cos(f, r_cent, vertexCos);
}
/**
* \brief Face Flip Normal
*

@ -34,16 +34,18 @@ int BM_face_calc_tessellation(BMFace *f, BMLoop **r_loops, int (*r_index)[3])
#endif
;
void BM_face_calc_normal(BMFace *f, float r_no[3]);
void BM_face_calc_normal_vcos(BMesh *bm, BMFace *f, float r_no[3],
float const (*vertexCos)[3]);
float BM_face_calc_area(BMFace *f);
float BM_face_calc_perimeter(BMFace *f);
void BM_face_calc_plane(BMFace *f, float r_plane[3]);
void BM_face_calc_center_bounds(BMFace *f, float center[3]);
void BM_face_calc_center_mean(BMFace *f, float center[3]);
void BM_face_calc_center_mean_vcos(BMesh *bm, BMFace *f, float r_cent[3],
float const (*vertexCos)[3]);
void BM_face_calc_center_mean_weighted(BMFace *f, float center[3]);
void BM_face_normal_update(BMFace *f);
void BM_face_normal_update_vcos(BMesh *bm, BMFace *f, float no[3],
float const (*vertexCos)[3]);
void BM_edge_normals_update(BMEdge *e);

@ -338,16 +338,16 @@ bool BM_verts_in_face(BMFace *f, BMVert **varr, int len)
*/
bool BM_edge_in_face(BMFace *f, BMEdge *e)
{
BMLoop *l_iter;
BMLoop *l_first;
if (e->l) {
BMLoop *l_iter, *l_first;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
if (l_iter->e == e) {
return true;
}
} while ((l_iter = l_iter->next) != l_first);
l_iter = l_first = e->l;
do {
if (l_iter->f == f) {
return true;
}
} while ((l_iter = l_iter->radial_next) != l_first);
}
return false;
}
@ -1758,20 +1758,27 @@ float BM_mesh_calc_volume(BMesh *bm, bool is_signed)
return vol;
}
/* note, almost duplicate of BM_mesh_calc_edge_groups, keep in sync */
/**
* TODO (as we need)
* - option to walk over faces by verts.
* - option to walk over non manifold edges.
* Calculate isolated groups of faces with optional filtering.
*
* \param bm the BMesh.
* \param r_groups_array Array of ints to fill in, length of bm->totface.
* \param r_groups_array Array of ints to fill in, length of bm->totface
* (or when hflag_test is set, the number of flagged faces).
* \param r_group_index index, length pairs into \a r_groups_array, size of return value
* int pairs: (array_start, array_length).
* int pairs: (array_start, array_length).
* \param filter_fn Filter the edges or verts we step over (depends on \a htype_step)
* as to which types we deal with.
* \param user_data Optional user data for \a filter_fn, can be NULL.
* \param hflag_test Optional flag to test faces,
* use to exclude faces from the calculation, 0 for all faces.
* \param htype_step BM_VERT to walk over face-verts, BM_EDGE to walk over faces edges
* (having both set is supported too).
* \return The number of groups found.
*/
int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
void *user_data, bool (*filter_fn)(BMEdge *, void *user_data))
BMElemFilterFunc filter_fn, void *user_data,
const char hflag_test, const char htype_step)
{
#ifdef DEBUG
int group_index_len = 1;
@ -1786,11 +1793,11 @@ int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_inde
int group_curr = 0;
const unsigned int tot_faces = bm->totface;
unsigned int tot_faces = 0;
unsigned int tot_touch = 0;
BMFace **fstack;
STACK_DECLARE(fstack);
BMFace **stack;
STACK_DECLARE(stack);
BMIter iter;
BMFace *f;
@ -1798,28 +1805,38 @@ int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_inde
STACK_INIT(group_array);
BLI_assert(((htype_step & ~(BM_VERT | BM_EDGE)) == 0) && (htype_step != 0));
/* init the array */
BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, i) {
if ((hflag_test == 0) || BM_elem_flag_test(f, hflag_test)) {
tot_faces++;
BM_elem_flag_disable(f, BM_ELEM_TAG);
}
else {
/* never walk over tagged */
BM_elem_flag_enable(f, BM_ELEM_TAG);
}
BM_elem_index_set(f, i); /* set_inline */
BM_elem_flag_disable(f, BM_ELEM_TAG);
}
bm->elem_index_dirty &= ~BM_FACE;
/* detect groups */
fstack = MEM_mallocN(sizeof(*fstack) * tot_faces, __func__);
stack = MEM_mallocN(sizeof(*stack) * tot_faces, __func__);
while (tot_touch != tot_faces) {
int *fg;
int *group_item;
bool ok = false;
BLI_assert(tot_touch < tot_faces);
STACK_INIT(fstack);
STACK_INIT(stack);
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(f, BM_ELEM_TAG) == false) {
BM_elem_flag_enable(f, BM_ELEM_TAG);
STACK_PUSH(fstack, f);
STACK_PUSH(stack, f);
ok = true;
break;
}
@ -1833,36 +1850,193 @@ int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_inde
group_index = MEM_reallocN(group_index, sizeof(*group_index) * group_index_len);
}
fg = group_index[group_curr];
fg[0] = STACK_SIZE(group_array);
fg[1] = 0;
group_item = group_index[group_curr];
group_item[0] = STACK_SIZE(group_array);
group_item[1] = 0;
while ((f = STACK_POP(fstack))) {
while ((f = STACK_POP(stack))) {
BMLoop *l_iter, *l_first;
/* add face */
STACK_PUSH(group_array, BM_elem_index_get(f));
tot_touch++;
fg[1]++;
group_item[1]++;
/* done */
/* search for other faces */
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
BMLoop *l_other = l_iter->radial_next;
if ((l_other != l_iter) && filter_fn(l_iter->e, user_data)) {
if (BM_elem_flag_test(l_other->f, BM_ELEM_TAG) == false) {
BM_elem_flag_enable(l_other->f, BM_ELEM_TAG);
STACK_PUSH(fstack, l_other->f);
if (htype_step & BM_EDGE) {
/* search for other faces */
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
BMLoop *l_radial_iter = l_iter->radial_next;
if ((l_radial_iter != l_iter) &&
((filter_fn == NULL) || filter_fn((BMElem *)l_iter->e, user_data)))
{
do {
BMFace *f_other = l_radial_iter->f;
if (BM_elem_flag_test(f_other, BM_ELEM_TAG) == false) {
BM_elem_flag_enable(f_other, BM_ELEM_TAG);
STACK_PUSH(stack, f_other);
}
} while ((l_radial_iter = l_radial_iter->radial_next) != l_iter);
}
}
} while ((l_iter = l_iter->next) != l_first);
} while ((l_iter = l_iter->next) != l_first);
}
if (htype_step & BM_VERT) {
BMIter liter;
/* search for other faces */
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
if ((filter_fn == NULL) || filter_fn((BMElem *)l_iter->v, user_data)) {
BMLoop *l_other;
BM_ITER_ELEM (l_other, &liter, l_iter, BM_LOOPS_OF_LOOP) {
BMFace *f_other = l_other->f;
if (BM_elem_flag_test(f_other, BM_ELEM_TAG) == false) {
BM_elem_flag_enable(f_other, BM_ELEM_TAG);
STACK_PUSH(stack, f_other);
}
}
}
} while ((l_iter = l_iter->next) != l_first);
}
}
group_curr++;
}
MEM_freeN(fstack);
MEM_freeN(stack);
/* reduce alloc to required size */
group_index = MEM_reallocN(group_index, sizeof(*group_index) * group_curr);
*r_group_index = group_index;
return group_curr;
}
/* note, almost duplicate of BM_mesh_calc_face_groups, keep in sync */
/**
* Calculate isolated groups of edges with optional filtering.
*
* \param bm the BMesh.
* \param r_groups_array Array of ints to fill in, length of bm->totedge
* (or when hflag_test is set, the number of flagged edges).
* \param r_group_index index, length pairs into \a r_groups_array, size of return value
* int pairs: (array_start, array_length).
* \param filter_fn Filter the edges or verts we step over (depends on \a htype_step)
* as to which types we deal with.
* \param user_data Optional user data for \a filter_fn, can be NULL.
* \param hflag_test Optional flag to test edges,
* use to exclude edges from the calculation, 0 for all edges.
* \return The number of groups found.
*
* \note Unlike #BM_mesh_calc_face_groups there is no 'htype_step' argument,
* since we always walk over verts.
*/
int BM_mesh_calc_edge_groups(BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
BMElemFilterFunc filter_fn, void *user_data,
const char hflag_test)
{
#ifdef DEBUG
int group_index_len = 1;
#else
int group_index_len = 32;
#endif
int (*group_index)[2] = MEM_mallocN(sizeof(*group_index) * group_index_len, __func__);
int *group_array = r_groups_array;
STACK_DECLARE(group_array);
int group_curr = 0;
unsigned int tot_edges = 0;
unsigned int tot_touch = 0;
BMEdge **stack;
STACK_DECLARE(stack);
BMIter iter;
BMEdge *e;
int i;
STACK_INIT(group_array);
/* init the array */
BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) {
if ((hflag_test == 0) || BM_elem_flag_test(e, hflag_test)) {
tot_edges++;
BM_elem_flag_disable(e, BM_ELEM_TAG);
}
else {
/* never walk over tagged */
BM_elem_flag_enable(e, BM_ELEM_TAG);
}
BM_elem_index_set(e, i); /* set_inline */
}
bm->elem_index_dirty &= ~BM_FACE;
/* detect groups */
stack = MEM_mallocN(sizeof(*stack) * tot_edges, __func__);
while (tot_touch != tot_edges) {
int *group_item;
bool ok = false;
BLI_assert(tot_touch < tot_edges);
STACK_INIT(stack);
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e, BM_ELEM_TAG) == false) {
BM_elem_flag_enable(e, BM_ELEM_TAG);
STACK_PUSH(stack, e);
ok = true;
break;
}
}
BLI_assert(ok == true);
/* manage arrays */
if (group_index_len == group_curr) {
group_index_len *= 2;
group_index = MEM_reallocN(group_index, sizeof(*group_index) * group_index_len);
}
group_item = group_index[group_curr];
group_item[0] = STACK_SIZE(group_array);
group_item[1] = 0;
while ((e = STACK_POP(stack))) {
BMIter viter;
BMIter eiter;
BMVert *v;
/* add edge */
STACK_PUSH(group_array, BM_elem_index_get(e));
tot_touch++;
group_item[1]++;
/* done */
/* search for other edges */
BM_ITER_ELEM (v, &viter, e, BM_VERTS_OF_EDGE) {
if ((filter_fn == NULL) || filter_fn((BMElem *)v, user_data)) {
BMEdge *e_other;
BM_ITER_ELEM (e_other, &eiter, v, BM_EDGES_OF_VERT) {
if (BM_elem_flag_test(e_other, BM_ELEM_TAG) == false) {
BM_elem_flag_enable(e_other, BM_ELEM_TAG);
STACK_PUSH(stack, e_other);
}
}
}
}
}
group_curr++;
}
MEM_freeN(stack);
/* reduce alloc to required size */
group_index = MEM_reallocN(group_index, sizeof(*group_index) * group_curr);
@ -1890,6 +2064,7 @@ float bmesh_subd_falloff_calc(const int falloff, float val)
break;
default:
BLI_assert(0);
break;
}
return val;

@ -27,6 +27,8 @@
* \ingroup bmesh
*/
typedef bool (*BMElemFilterFunc)(BMElem *, void *user_data);
bool BM_vert_in_face(BMFace *f, BMVert *v);
int BM_verts_in_face_count(BMFace *f, BMVert **varr, int len);
bool BM_verts_in_face(BMFace *f, BMVert **varr, int len);
@ -115,8 +117,13 @@ bool BM_face_is_any_vert_flag_test(BMFace *f, const char hflag);
bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag);
float BM_mesh_calc_volume(BMesh *bm, bool is_signed);
int BM_mesh_calc_face_groups(BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
void *user_data, bool (*filter_fn)(BMEdge *, void *user_data));
BMElemFilterFunc filter_fn, void *user_data,
const char hflag_test, const char htype_step);
int BM_mesh_calc_edge_groups(BMesh *bm, int *r_groups_array, int (**r_group_index)[2],
BMElemFilterFunc filter_fn, void *user_data,
const char hflag_test);
/* not really any good place to put this */
float bmesh_subd_falloff_calc(const int falloff, float val);

@ -150,10 +150,7 @@ static BMFace *copy_face(BMOperator *op,
#endif
/* lookup edge */
for (i = 0, source_loop = BM_iter_new(&iter, source_mesh, BM_LOOPS_OF_FACE, source_face);
source_loop;
source_loop = BM_iter_step(&iter), i++)
{
BM_ITER_ELEM_INDEX (source_loop, &iter, source_face, BM_LOOPS_OF_FACE, i) {
vtar[i] = BLI_ghash_lookup(vhash, source_loop->v);
edar[i] = BLI_ghash_lookup(ehash, source_loop->e);
}

@ -40,9 +40,9 @@
#define FACE_FLIP (1 << 1)
#define FACE_TEMP (1 << 2)
static bool bmo_recalc_normal_edge_filter_cb(BMEdge *e, void *UNUSED(user_data))
static bool bmo_recalc_normal_edge_filter_cb(BMElem *ele, void *UNUSED(user_data))
{
return BM_edge_is_manifold(e);
return BM_edge_is_manifold((BMEdge *)ele);
}
/**
@ -115,7 +115,7 @@ static void bmo_recalc_face_normals_array(BMesh *bm, BMFace **faces, const int f
do {
BMLoop *l_other = l_iter->radial_next;
if ((l_other != l_iter) && bmo_recalc_normal_edge_filter_cb(l_iter->e, NULL)) {
if ((l_other != l_iter) && bmo_recalc_normal_edge_filter_cb((BMElem *)l_iter->e, NULL)) {
if (!BMO_elem_flag_test(bm, l_other->f, FACE_TEMP)) {
BMO_elem_flag_enable(bm, l_other->f, FACE_TEMP);
BMO_elem_flag_set(bm, l_other->f, FACE_FLIP, (l_other->v == l_iter->v) != flip_state);
@ -146,14 +146,15 @@ static void bmo_recalc_face_normals_array(BMesh *bm, BMFace **faces, const int f
void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op)
{
int *groups_array = MEM_mallocN(sizeof(groups_array) * bm->totface, __func__);
int *groups_array = MEM_mallocN(sizeof(*groups_array) * bm->totface, __func__);
int faces_len;
BMFace **faces_arr = BM_iter_as_arrayN(bm, BM_FACES_OF_MESH, NULL, &faces_len, NULL, 0);
BMFace **faces_grp = MEM_mallocN(sizeof(faces_grp) * bm->totface, __func__);
BMFace **faces_grp = MEM_mallocN(sizeof(*faces_grp) * bm->totface, __func__);
int (*group_index)[2];
const int group_tot = BM_mesh_calc_face_groups(bm, groups_array, &group_index,
NULL, bmo_recalc_normal_edge_filter_cb);
bmo_recalc_normal_edge_filter_cb, NULL,
0, BM_EDGE);
int i;

@ -262,6 +262,7 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
#endif
default:
BLI_assert(0);
break;
}
}
}
@ -495,6 +496,7 @@ void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
#endif
default:
BLI_assert(0);
break;
}
}
}
@ -627,6 +629,7 @@ void bmo_similar_verts_exec(BMesh *bm, BMOperator *op)
break;
default:
BLI_assert(0);
break;
}
}
}

@ -1203,24 +1203,22 @@ void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag,
BMO_op_exec(bm, &op);
if (seltype == SUBDIV_SELECT_INNER) {
BMOIter iter;
BMElem *ele;
for (ele = BMO_iter_new(&iter, op.slots_out, "geom_inner.out", BM_EDGE | BM_VERT); ele; ele = BMO_iter_step(&iter)) {
BM_elem_select_set(bm, ele, true);
}
}
else if (seltype == SUBDIV_SELECT_LOOPCUT) {
BMOIter iter;
BMElem *ele;
/* deselect input */
BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
for (ele = BMO_iter_new(&iter, op.slots_out, "geom_inner.out", BM_EDGE); ele; ele = BMO_iter_step(&iter)) {
BM_edge_select_set(bm, (BMEdge *)ele, true);
}
switch (seltype) {
case SUBDIV_SELECT_NONE:
break;
case SUBDIV_SELECT_ORIG:
/* set the newly created data to be selected */
BMO_slot_buffer_hflag_enable(bm, op.slots_out, "geom_inner.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true);
BM_mesh_select_flush(bm);
break;
case SUBDIV_SELECT_INNER:
BMO_slot_buffer_hflag_enable(bm, op.slots_out, "geom_inner.out", BM_EDGE | BM_VERT, BM_ELEM_SELECT, true);
break;
case SUBDIV_SELECT_LOOPCUT:
/* deselect input */
BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
BMO_slot_buffer_hflag_enable(bm, op.slots_out, "geom_inner.out", BM_EDGE, BM_ELEM_SELECT, true);
break;
}
BMO_op_finish(bm, &op);

File diff suppressed because it is too large Load Diff

@ -91,13 +91,13 @@ protected:
virtual void executePixel(float output[4], float x, float y, float dx, float dy, PixelSampler sampler) {}
public:
inline void read(float *result, float x, float y, PixelSampler sampler) {
inline void read(float result[4], float x, float y, PixelSampler sampler) {
executePixel(result, x, y, sampler);
}
inline void read(float *result, int x, int y, void *chunkData) {
inline void read(float result[4], int x, int y, void *chunkData) {
executePixel(result, x, y, chunkData);
}
inline void read(float *result, float x, float y, float dx, float dy, PixelSampler sampler) {
inline void read(float result[4], float x, float y, float dx, float dy, PixelSampler sampler) {
executePixel(result, x, y, dx, dy, sampler);
}

@ -81,6 +81,7 @@ int g_highlightIndex;
void **g_highlightedNodes;
void **g_highlightedNodesRead;
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
#define HIGHLIGHT(wp) \
{ \
ExecutionGroup *group = wp->getExecutionGroup(); \
@ -103,6 +104,7 @@ void **g_highlightedNodesRead;
} \
} \
}
#endif /* COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE */
void COM_startReadHighlights()
{

@ -121,10 +121,12 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff)
val = val * val;
break;
case PROP_LIN:
/* fall-through */
#ifndef NDEBUG
/* uninitialized! */
case -1:
/* uninitialized! */
BLI_assert(0);
break;
#endif
default:
/* nothing */

@ -37,7 +37,7 @@ void ConvertColorToBWOperation::initExecution()
void ConvertColorToBWOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(&inputColor[0], x, y, sampler);
this->m_inputOperation->read(inputColor, x, y, sampler);
output[0] = rgb_to_bw(inputColor);
}

@ -37,7 +37,7 @@ void ConvertColorToValueProg::initExecution()
void ConvertColorToValueProg::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(&inputColor[0], x, y, sampler);
this->m_inputOperation->read(inputColor, x, y, sampler);
output[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f;
}

@ -77,8 +77,8 @@ void MathAddOperation::executePixel(float output[4], float x, float y, PixelSamp
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = inputValue1[0] + inputValue2[0];
@ -90,8 +90,8 @@ void MathSubtractOperation::executePixel(float output[4], float x, float y, Pixe
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = inputValue1[0] - inputValue2[0];
@ -103,8 +103,8 @@ void MathMultiplyOperation::executePixel(float output[4], float x, float y, Pixe
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = inputValue1[0] * inputValue2[0];
@ -116,8 +116,8 @@ void MathDivideOperation::executePixel(float output[4], float x, float y, PixelS
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
if (inputValue2[0] == 0) /* We don't want to divide by zero. */
output[0] = 0.0;
@ -132,8 +132,8 @@ void MathSineOperation::executePixel(float output[4], float x, float y, PixelSam
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = sin(inputValue1[0]);
@ -145,8 +145,8 @@ void MathCosineOperation::executePixel(float output[4], float x, float y, PixelS
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = cos(inputValue1[0]);
@ -158,8 +158,8 @@ void MathTangentOperation::executePixel(float output[4], float x, float y, Pixel
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = tan(inputValue1[0]);
@ -171,8 +171,8 @@ void MathArcSineOperation::executePixel(float output[4], float x, float y, Pixel
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
output[0] = asin(inputValue1[0]);
@ -187,8 +187,8 @@ void MathArcCosineOperation::executePixel(float output[4], float x, float y, Pix
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
output[0] = acos(inputValue1[0]);
@ -203,8 +203,8 @@ void MathArcTangentOperation::executePixel(float output[4], float x, float y, Pi
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = atan(inputValue1[0]);
@ -216,8 +216,8 @@ void MathPowerOperation::executePixel(float output[4], float x, float y, PixelSa
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
if (inputValue1[0] >= 0) {
output[0] = pow(inputValue1[0], inputValue2[0]);
@ -241,8 +241,8 @@ void MathLogarithmOperation::executePixel(float output[4], float x, float y, Pix
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
if (inputValue1[0] > 0 && inputValue2[0] > 0)
output[0] = log(inputValue1[0]) / log(inputValue2[0]);
@ -257,8 +257,8 @@ void MathMinimumOperation::executePixel(float output[4], float x, float y, Pixel
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = min(inputValue1[0], inputValue2[0]);
@ -270,8 +270,8 @@ void MathMaximumOperation::executePixel(float output[4], float x, float y, Pixel
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = max(inputValue1[0], inputValue2[0]);
@ -283,8 +283,8 @@ void MathRoundOperation::executePixel(float output[4], float x, float y, PixelSa
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = round(inputValue1[0]);
@ -296,8 +296,8 @@ void MathLessThanOperation::executePixel(float output[4], float x, float y, Pixe
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f;
@ -309,8 +309,8 @@ void MathGreaterThanOperation::executePixel(float output[4], float x, float y, P
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
output[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f;
@ -322,8 +322,8 @@ void MathModuloOperation::executePixel(float output[4], float x, float y, PixelS
float inputValue1[4];
float inputValue2[4];
this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler);
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler);
this->m_inputValue1Operation->read(inputValue1, x, y, sampler);
this->m_inputValue2Operation->read(inputValue2, x, y, sampler);
if (inputValue2[0] == 0)
output[0] = 0.0;

@ -37,7 +37,6 @@ void MixAddOperation::executePixel(float output[4], float x, float y, PixelSampl
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];

@ -31,13 +31,14 @@ void MixBurnOperation::executePixel(float output[4], float x, float y, PixelSamp
{
float inputColor1[4];
float inputColor2[4];
float value;
float inputValue[4];
float tmp;
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -35,12 +35,13 @@ void MixColorOperation::executePixel(float output[4], float x, float y, PixelSam
{
float inputColor1[4];
float inputColor2[4];
float value;
float inputValue[4];
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -31,12 +31,13 @@ void MixDarkenOperation::executePixel(float output[4], float x, float y, PixelSa
{
float inputColor1[4];
float inputColor2[4];
float value;
float inputValue[4];
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -32,12 +32,13 @@ void MixDifferenceOperation::executePixel(float output[4], float x, float y, Pix
{
float inputColor1[4];
float inputColor2[4];
float value;
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
float inputValue[4];
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -31,12 +31,13 @@ void MixDivideOperation::executePixel(float output[4], float x, float y, PixelSa
{
float inputColor1[4];
float inputColor2[4];
float value;
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
float inputValue[4];
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -31,13 +31,14 @@ void MixDodgeOperation::executePixel(float output[4], float x, float y, PixelSam
{
float inputColor1[4];
float inputColor2[4];
float value;
float inputValue[4];
float tmp;
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -35,12 +35,13 @@ void MixHueOperation::executePixel(float output[4], float x, float y, PixelSampl
{
float inputColor1[4];
float inputColor2[4];
float value;
float inputValue[4];
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -31,12 +31,13 @@ void MixLightenOperation::executePixel(float output[4], float x, float y, PixelS
{
float inputColor1[4];
float inputColor2[4];
float value;
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
float inputValue[4];
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -31,12 +31,13 @@ void MixLinearLightOperation::executePixel(float output[4], float x, float y, Pi
{
float inputColor1[4];
float inputColor2[4];
float value;
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
float inputValue[4];
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -31,12 +31,13 @@ void MixOverlayOperation::executePixel(float output[4], float x, float y, PixelS
{
float inputColor1[4];
float inputColor2[4];
float value;
float inputValue[4];
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -35,12 +35,13 @@ void MixSaturationOperation::executePixel(float output[4], float x, float y, Pix
{
float inputColor1[4];
float inputColor2[4];
float value;
float inputValue[4];
this->m_inputValueOperation->read(&value, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

@ -31,13 +31,13 @@ void MixScreenOperation::executePixel(float output[4], float x, float y, PixelSa
{
float inputColor1[4];
float inputColor2[4];
float valuev[4];
float inputValue[4];
this->m_inputValueOperation->read(valuev, x, y, sampler);
this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler);
this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler);
this->m_inputValueOperation->read(inputValue, x, y, sampler);
this->m_inputColor1Operation->read(inputColor1, x, y, sampler);
this->m_inputColor2Operation->read(inputColor2, x, y, sampler);
float value = valuev[0];
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}

Some files were not shown because too many files have changed in this diff Show More