style cleanup: whitespace

This commit is contained in:
2012-05-12 16:11:34 +00:00
parent bddc7dfc20
commit 53ee7908d6
14 changed files with 2673 additions and 2671 deletions

View File

@@ -416,8 +416,8 @@ struct CCGSubSurf {
static int VertDataEqual(const float a[], const float b[], const CCGSubSurf *ss)
{
int i;
for(i = 0; i < ss->meshIFC.numLayers; i++) {
if(a[i] != b[i])
for (i = 0; i < ss->meshIFC.numLayers; i++) {
if (a[i] != b[i])
return 0;
}
return 1;
@@ -431,28 +431,28 @@ static void VertDataZero(float v[], const CCGSubSurf *ss)
static void VertDataCopy(float dst[], const float src[], const CCGSubSurf *ss)
{
int i;
for(i = 0; i < ss->meshIFC.numLayers; i++)
for (i = 0; i < ss->meshIFC.numLayers; i++)
dst[i] = src[i];
}
static void VertDataAdd(float a[], const float b[], const CCGSubSurf *ss)
{
int i;
for(i = 0; i < ss->meshIFC.numLayers; i++)
for (i = 0; i < ss->meshIFC.numLayers; i++)
a[i] += b[i];
}
static void VertDataSub(float a[], const float b[], const CCGSubSurf *ss)
{
int i;
for(i = 0; i < ss->meshIFC.numLayers; i++)
for (i = 0; i < ss->meshIFC.numLayers; i++)
a[i] -= b[i];
}
static void VertDataMulN(float v[], float f, const CCGSubSurf *ss)
{
int i;
for(i = 0; i < ss->meshIFC.numLayers; i++)
for (i = 0; i < ss->meshIFC.numLayers; i++)
v[i] *= f;
}
@@ -462,7 +462,7 @@ static void VertDataAvg4(float v[],
const CCGSubSurf *ss)
{
int i;
for(i = 0; i < ss->meshIFC.numLayers; i++)
for (i = 0; i < ss->meshIFC.numLayers; i++)
v[i] = (a[i] + b[i] + c[i] + d[i]) * 0.25f;
}
@@ -1133,7 +1133,8 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
v->flags = Vert_eEffected | seamflag;
}
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) ||
((v->flags & Vert_eSeam) != seamflag)) {
((v->flags & Vert_eSeam) != seamflag))
{
int i, j;
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss);
@@ -2001,10 +2002,10 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
}
VertDataMulN(r, 1.0f / f->numVerts, ss);
VertDataMulN((float*)FACE_getCenterData(f), f->numVerts - 2.0f, ss);
VertDataAdd((float*)FACE_getCenterData(f), q, ss);
VertDataAdd((float*)FACE_getCenterData(f), r, ss);
VertDataMulN((float*)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
VertDataMulN((float *)FACE_getCenterData(f), f->numVerts - 2.0f, ss);
VertDataAdd((float *)FACE_getCenterData(f), q, ss);
VertDataAdd((float *)FACE_getCenterData(f), r, ss);
VertDataMulN((float *)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
for (S = 0; S < f->numVerts; S++) {
/* interior face shift
@@ -2099,8 +2100,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float*)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float*)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float *)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss);
VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx), ss);
for (x = 1; x < gridSize - 1; x++) {
@@ -2189,7 +2190,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
VertDataAdd(q, VERT_getCo(e->v1, curLvl), ss);
for (i = 0; i < e->numFaces; i++) {
CCGFace *f = e->faces[i];
VertDataAdd(q, (float*)FACE_getCenterData(f), ss);
VertDataAdd(q, (float *)FACE_getCenterData(f), ss);
numFaces++;
}
VertDataMulN(q, 1.0f / (2.0f + numFaces), ss);
@@ -2265,7 +2266,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
VertDataZero(q, ss);
for (i = 0; i < v->numFaces; i++) {
CCGFace *f = v->faces[i];
VertDataAdd(q, (float*)FACE_getCenterData(f), ss);
VertDataAdd(q, (float *)FACE_getCenterData(f), ss);
numFaces++;
}
VertDataMulN(q, 1.0f / numFaces, ss);
@@ -2365,8 +2366,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float*)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float*)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float *)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 1), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss);
VertDataCopy(FACE_getIECo(f, nextLvl, S, 1), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, 1), ss);
@@ -2495,7 +2496,7 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF
CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts];
VertDataCopy((float*)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
VertDataCopy((float *)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
VertDataCopy(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss);
for (x = 0; x < gridSize; x++)
@@ -2546,7 +2547,7 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF,
VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x), ss);
}
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float*)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl), ss);
}
}
@@ -2595,7 +2596,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
VertDataZero((float*)FACE_getCenterData(f), ss);
VertDataZero((float *)FACE_getCenterData(f), ss);
for (S = 0; S < f->numVerts; S++)
for (x = 0; x < gridSize; x++)
@@ -2606,7 +2607,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[prevS];
VertDataAdd((float*)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
VertDataAdd((float *)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss);
if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss);
@@ -2648,7 +2649,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[i];
VertDataMulN((float*)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
VertDataMulN((float *)FACE_getCenterData(f), 1.0f / f->numVerts, ss);
for (S = 0; S < f->numVerts; S++)
for (x = 1; x < gridSize - 1; x++)
@@ -2659,7 +2660,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[prevS];
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float*)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float *)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl), ss);
for (x = 1; x < gridSize - 1; x++) {
@@ -2674,7 +2675,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in
VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss);
}
VertDataCopy(FACE_getIECo(f, lvl, S, 0), (float*)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIECo(f, lvl, S, 0), (float *)FACE_getCenterData(f), ss);
VertDataCopy(FACE_getIECo(f, lvl, S, gridSize - 1), FACE_getIFCo(f, lvl, S, gridSize - 1, 0), ss);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -271,20 +271,20 @@ static void layerInterp_msticky(void **sources, float *weights,
co[0] = co[1] = 0.0f;
for (i = 0; i < count; i++) {
w = weights ? weights[i] : 1.0f;
mst = (MSticky*)sources[i];
mst = (MSticky *)sources[i];
madd_v2_v2fl(co, mst->co, w);
}
mst = (MSticky*)dest;
mst = (MSticky *)dest;
copy_v2_v2(mst->co, co);
}
static void layerCopy_tface(const void *source, void *dest, int count)
{
const MTFace *source_tf = (const MTFace*)source;
MTFace *dest_tf = (MTFace*)dest;
const MTFace *source_tf = (const MTFace *)source;
MTFace *dest_tf = (MTFace *)dest;
int i;
for (i = 0; i < count; ++i)
@@ -326,10 +326,8 @@ static void layerSwap_tface(void *data, const int *corner_indices)
{
MTFace *tf = data;
float uv[4][2];
static const short pin_flags[4] =
{ TF_PIN1, TF_PIN2, TF_PIN3, TF_PIN4 };
static const char sel_flags[4] =
{ TF_SEL1, TF_SEL2, TF_SEL3, TF_SEL4 };
static const short pin_flags[4] = { TF_PIN1, TF_PIN2, TF_PIN3, TF_PIN4 };
static const char sel_flags[4] = { TF_SEL1, TF_SEL2, TF_SEL3, TF_SEL4 };
short unwrap = tf->unwrap & ~(TF_PIN1 | TF_PIN2 | TF_PIN3 | TF_PIN4);
char flag = tf->flag & ~(TF_SEL1 | TF_SEL2 | TF_SEL3 | TF_SEL4);
int j;
@@ -358,8 +356,8 @@ static void layerSwap_tface(void *data, const int *corner_indices)
static void layerDefault_tface(void *data, int count)
{
static MTFace default_tf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, NULL,
0, 0, TF_DYNAMIC|TF_CONVERTED, 0, 0};
MTFace *tf = (MTFace*)data;
0, 0, TF_DYNAMIC | TF_CONVERTED, 0, 0};
MTFace *tf = (MTFace *)data;
int i;
for (i = 0; i < count; i++)
@@ -369,25 +367,25 @@ static void layerDefault_tface(void *data, int count)
static void layerCopy_propFloat(const void *source, void *dest,
int count)
{
memcpy(dest, source, sizeof(MFloatProperty)*count);
memcpy(dest, source, sizeof(MFloatProperty) * count);
}
static void layerCopy_propInt(const void *source, void *dest,
int count)
{
memcpy(dest, source, sizeof(MIntProperty)*count);
memcpy(dest, source, sizeof(MIntProperty) * count);
}
static void layerCopy_propString(const void *source, void *dest,
int count)
{
memcpy(dest, source, sizeof(MStringProperty)*count);
memcpy(dest, source, sizeof(MStringProperty) * count);
}
static void layerCopy_origspace_face(const void *source, void *dest, int count)
{
const OrigSpaceFace *source_tf = (const OrigSpaceFace*)source;
OrigSpaceFace *dest_tf = (OrigSpaceFace*)dest;
const OrigSpaceFace *source_tf = (const OrigSpaceFace *)source;
OrigSpaceFace *dest_tf = (OrigSpaceFace *)dest;
int i;
for (i = 0; i < count; ++i)
@@ -442,7 +440,7 @@ static void layerSwap_origspace_face(void *data, const int *corner_indices)
static void layerDefault_origspace_face(void *data, int count)
{
static OrigSpaceFace default_osf = {{{0, 0}, {1, 0}, {1, 1}, {0, 1}}};
OrigSpaceFace *osf = (OrigSpaceFace*)data;
OrigSpaceFace *osf = (OrigSpaceFace *)data;
int i;
for (i = 0; i < count; i++)
@@ -456,27 +454,27 @@ static void layerSwap_mdisps(void *data, const int *ci)
int corners, cornersize, S;
if (s->disps) {
int nverts= (ci[1] == 3) ? 4 : 3; /* silly way to know vertex count of face */
corners= multires_mdisp_corners(s);
cornersize= s->totdisp/corners;
int nverts = (ci[1] == 3) ? 4 : 3; /* silly way to know vertex count of face */
corners = multires_mdisp_corners(s);
cornersize = s->totdisp / corners;
if (corners!=nverts) {
if (corners != nverts) {
/* happens when face changed vertex count in edit mode
* if it happened, just forgot displacement */
MEM_freeN(s->disps);
s->totdisp= (s->totdisp/corners)*nverts;
s->disps= MEM_callocN(s->totdisp*sizeof(float)*3, "mdisp swap");
s->totdisp = (s->totdisp / corners) * nverts;
s->disps = MEM_callocN(s->totdisp * sizeof(float) * 3, "mdisp swap");
return;
}
d= MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap");
d = MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap");
for (S = 0; S < corners; S++)
memcpy(d + cornersize*S, s->disps + cornersize*ci[S], cornersize*3*sizeof(float));
memcpy(d + cornersize * S, s->disps + cornersize * ci[S], cornersize * 3 * sizeof(float));
MEM_freeN(s->disps);
s->disps= d;
s->disps = d;
}
}
@@ -527,9 +525,9 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count)
for (i = 0; i < count; ++i) {
if (!d[i].disps)
d[i].disps = MEM_callocN(sizeof(float)*3*d[i].totdisp, "mdisps read");
d[i].disps = MEM_callocN(sizeof(float) * 3 * d[i].totdisp, "mdisps read");
if (!cdf_read_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
if (!cdf_read_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) {
printf("failed to read multires displacement %d/%d %d\n", i, count, d[i].totdisp);
return 0;
}
@@ -544,7 +542,7 @@ static int layerWrite_mdisps(CDataFile *cdf, void *data, int count)
int i;
for (i = 0; i < count; ++i) {
if (!cdf_write_data(cdf, d[i].totdisp*3*sizeof(float), d[i].disps)) {
if (!cdf_write_data(cdf, d[i].totdisp * 3 * sizeof(float), d[i].disps)) {
printf("failed to write multires displacement %d/%d %d\n", i, count, d[i].totdisp);
return 0;
}
@@ -560,7 +558,7 @@ static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), void *data, int count
int i;
for (i = 0; i < count; ++i)
size += d[i].totdisp*3*sizeof(float);
size += d[i].totdisp * 3 * sizeof(float);
return size;
}
@@ -571,8 +569,8 @@ static void layerCopy_grid_paint_mask(const void *source, void *dest, int count)
const GridPaintMask *s = source;
GridPaintMask *d = dest;
for(i = 0; i < count; ++i) {
if(s[i].data) {
for (i = 0; i < count; ++i) {
if (s[i].data) {
d[i].data = MEM_dupallocN(s[i].data);
d[i].level = s[i].level;
}
@@ -589,8 +587,8 @@ static void layerFree_grid_paint_mask(void *data, int count, int UNUSED(size))
int i;
GridPaintMask *gpm = data;
for(i = 0; i < count; ++i) {
if(gpm[i].data)
for (i = 0; i < count; ++i) {
if (gpm[i].data)
MEM_freeN(gpm[i].data);
gpm[i].data = NULL;
gpm[i].level = 0;
@@ -675,7 +673,7 @@ static void layerInitMinMax_mloopcol(void *vmin, void *vmax)
static void layerDefault_mloopcol(void *data, int count)
{
MLoopCol default_mloopcol = {255, 255, 255, 255};
MLoopCol *mlcol = (MLoopCol*)data;
MLoopCol *mlcol = (MLoopCol *)data;
int i;
for (i = 0; i < count; i++)
mlcol[i] = default_mloopcol;
@@ -774,7 +772,7 @@ static void layerInterp_mloopuv(void **sources, float *weights,
float *sub_weights, int count, void *dest)
{
MLoopUV *mluv = dest;
float *uv= mluv->uv;
float *uv = mluv->uv;
int i;
zero_v2(uv);
@@ -844,7 +842,7 @@ static void layerInterp_mloop_origspace(void **sources, float *weights,
float *sub_weights, int count, void *dest)
{
OrigSpaceLoop *mluv = dest;
float *uv= mluv->uv;
float *uv = mluv->uv;
int i;
zero_v2(uv);
@@ -892,7 +890,7 @@ static void layerInterp_mcol(void **sources, float *weights,
if (sub_weights) {
MCol *src = sources[i];
for (k = 0; k < 4; ++k, ++sub_weight, ++src) {
const float w= (*sub_weight) * weight;
const float w = (*sub_weight) * weight;
col[j].a += src->a * w;
col[j].r += src->r * w;
col[j].g += src->g * w;
@@ -940,10 +938,10 @@ static void layerSwap_mcol(void *data, const int *corner_indices)
static void layerDefault_mcol(void *data, int count)
{
static MCol default_mcol = {255, 255, 255, 255};
MCol *mcol = (MCol*)data;
MCol *mcol = (MCol *)data;
int i;
for (i = 0; i < 4*count; i++) {
for (i = 0; i < 4 * count; i++) {
mcol[i] = default_mcol;
}
}
@@ -1012,13 +1010,13 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerInterp_tface, layerSwap_tface, layerDefault_tface},
/* 6: CD_MCOL */
/* 4 MCol structs per face */
{sizeof(MCol)*4, "MCol", 4, "Col", NULL, NULL, layerInterp_mcol,
{sizeof(MCol) * 4, "MCol", 4, "Col", NULL, NULL, layerInterp_mcol,
layerSwap_mcol, layerDefault_mcol},
/* 7: CD_ORIGINDEX */
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 8: CD_NORMAL */
/* 3 floats per normal vector */
{sizeof(float)*3, "vec3f", 1, NULL, NULL, NULL, NULL, NULL, NULL},
{sizeof(float) * 3, "vec3f", 1, NULL, NULL, NULL, NULL, NULL, NULL},
/* 9: CD_POLYINDEX */
{sizeof(int), "MIntProperty", 1, NULL, NULL, NULL, NULL, NULL, NULL},
/* 10: CD_PROP_FLT */
@@ -1031,10 +1029,10 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
{sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVMap", layerCopy_origspace_face, NULL,
layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face},
/* 14: CD_ORCO */
{sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
{sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 15: CD_MTEXPOLY */
/* note, when we expose the UV Map / TexFace split to the user, change this back to face Texture */
{sizeof(MTexPoly), "MTexPoly", 1, "UVMap"/* "Face Texture" */, NULL, NULL, NULL, NULL, NULL},
{sizeof(MTexPoly), "MTexPoly", 1, "UVMap" /* "Face Texture" */, NULL, NULL, NULL, NULL, NULL},
/* 16: CD_MLOOPUV */
{sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, layerInterp_mloopuv, NULL, NULL,
layerEqual_mloopuv, layerMultiply_mloopuv, layerInitMinMax_mloopuv,
@@ -1044,23 +1042,23 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol},
/* 18: CD_TANGENT */
{sizeof(float)*4*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
{sizeof(float) * 4 * 4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 19: CD_MDISPS */
{sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps,
layerFree_mdisps, NULL, layerSwap_mdisps, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps},
/* 20: CD_PREVIEW_MCOL */
{sizeof(MCol)*4, "MCol", 4, "PreviewCol", NULL, NULL, layerInterp_mcol,
{sizeof(MCol) * 4, "MCol", 4, "PreviewCol", NULL, NULL, layerInterp_mcol,
layerSwap_mcol, layerDefault_mcol},
/* 21: CD_ID_MCOL */
{sizeof(MCol)*4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol,
{sizeof(MCol) * 4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol,
layerSwap_mcol, layerDefault_mcol},
/* 22: CD_TEXTURE_MCOL */
{sizeof(MCol)*4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol,
{sizeof(MCol) * 4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol,
layerSwap_mcol, layerDefault_mcol},
/* 23: CD_CLOTH_ORCO */
{sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
{sizeof(float) * 3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 24: CD_RECAST */
{sizeof(MRecast), "MRecast", 1, "Recast", NULL, NULL, NULL, NULL},
@@ -1072,7 +1070,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
/* 27: CD_SHAPE_KEYINDEX */
{sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
/* 28: CD_SHAPEKEY */
{sizeof(float)*3, "", 0, "ShapeKey", NULL, NULL, layerInterp_shapekey},
{sizeof(float) * 3, "", 0, "ShapeKey", NULL, NULL, layerInterp_shapekey},
/* 29: CD_BWEIGHT */
{sizeof(float), "", 0, "BevelWeight", NULL, NULL, layerInterp_bweight},
/* 30: CD_CREASE */
@@ -1105,7 +1103,7 @@ static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
/* 5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags",
/* 10-14 */ "CDMFloatProperty", "CDMIntProperty", "CDMStringProperty", "CDOrigSpace", "CDOrco",
/* 15-19 */ "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps",
/* 20-24 */"CDPreviewMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast",
/* 20-24 */ "CDPreviewMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco", "CDMRecast",
/* BMESH ONLY */
/* 25-29 */ "CDMPoly", "CDMLoop", "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight",
@@ -1129,7 +1127,7 @@ const CustomDataMask CD_MASK_MESH =
const CustomDataMask CD_MASK_EDITMESH =
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MLOOPUV |
CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_SHAPE_KEYINDEX |
CD_MASK_MCOL|CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR |
CD_MASK_MCOL | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR |
CD_MASK_MDISPS | CD_MASK_SHAPEKEY | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
CD_MASK_GRID_PAINT_MASK;
const CustomDataMask CD_MASK_DERIVEDMESH =
@@ -1139,7 +1137,8 @@ const CustomDataMask CD_MASK_DERIVEDMESH =
CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORCO | CD_MASK_TANGENT |
CD_MASK_PREVIEW_MCOL | CD_MASK_NORMAL | CD_MASK_SHAPEKEY | CD_MASK_RECAST |
CD_MASK_ORIGINDEX | CD_MASK_POLYINDEX;
const CustomDataMask CD_MASK_BMESH = CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY |
const CustomDataMask CD_MASK_BMESH =
CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY |
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS |
CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
@@ -1175,11 +1174,11 @@ void CustomData_update_typemap(CustomData *data)
/* since we cant do in a pre-processor do here as an assert */
BLI_assert(sizeof(data->typemap) / sizeof(int) >= CD_NUMTYPES);
for (i=0; i<CD_NUMTYPES; i++) {
for (i = 0; i < CD_NUMTYPES; i++) {
data->typemap[i] = -1;
}
for (i=0; i<data->totlayer; i++) {
for (i = 0; i < data->totlayer; i++) {
if (data->layers[i].type != lasttype) {
data->typemap[data->layers[i].type] = i;
}
@@ -1242,7 +1241,7 @@ void CustomData_merge(const struct CustomData *source, struct CustomData *dest,
newlayer->active_rnd = lastrender;
newlayer->active_clone = lastclone;
newlayer->active_mask = lastmask;
newlayer->flag |= lastflag & (CD_FLAG_EXTERNAL|CD_FLAG_IN_MEMORY);
newlayer->flag |= lastflag & (CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY);
}
}
@@ -1255,7 +1254,7 @@ void CustomData_copy(const struct CustomData *source, struct CustomData *dest,
memset(dest, 0, sizeof(*dest));
if (source->external)
dest->external= MEM_dupallocN(source->external);
dest->external = MEM_dupallocN(source->external);
CustomData_merge(source, dest, mask, alloctype, totelem);
}
@@ -1279,7 +1278,7 @@ static void CustomData_external_free(CustomData *data)
{
if (data->external) {
MEM_freeN(data->external);
data->external= NULL;
data->external = NULL;
}
}
@@ -1318,7 +1317,7 @@ int CustomData_get_layer_index(const CustomData *data, int type)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
return i;
@@ -1340,8 +1339,8 @@ int CustomData_get_named_layer_index(const CustomData *data, int type, const cha
{
int i;
for (i=0; i < data->totlayer; ++i)
if (data->layers[i].type == type && strcmp(data->layers[i].name, name)==0)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type && strcmp(data->layers[i].name, name) == 0)
return i;
return -1;
@@ -1363,7 +1362,7 @@ int CustomData_get_render_layer_index(const CustomData *data, int type)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
return i + data->layers[i].active_rnd;
@@ -1374,7 +1373,7 @@ int CustomData_get_clone_layer_index(const CustomData *data, int type)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
return i + data->layers[i].active_clone;
@@ -1385,7 +1384,7 @@ int CustomData_get_stencil_layer_index(const CustomData *data, int type)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
return i + data->layers[i].active_mask;
@@ -1396,7 +1395,7 @@ int CustomData_get_active_layer(const CustomData *data, int type)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
return data->layers[i].active;
@@ -1407,7 +1406,7 @@ int CustomData_get_render_layer(const CustomData *data, int type)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
return data->layers[i].active_rnd;
@@ -1418,7 +1417,7 @@ int CustomData_get_clone_layer(const CustomData *data, int type)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
return data->layers[i].active_clone;
@@ -1429,7 +1428,7 @@ int CustomData_get_stencil_layer(const CustomData *data, int type)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
return data->layers[i].active_mask;
@@ -1440,7 +1439,7 @@ void CustomData_set_layer_active(CustomData *data, int type, int n)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
data->layers[i].active = n;
}
@@ -1449,7 +1448,7 @@ void CustomData_set_layer_render(CustomData *data, int type, int n)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
data->layers[i].active_rnd = n;
}
@@ -1458,7 +1457,7 @@ void CustomData_set_layer_clone(CustomData *data, int type, int n)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
data->layers[i].active_clone = n;
}
@@ -1467,7 +1466,7 @@ void CustomData_set_layer_stencil(CustomData *data, int type, int n)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
data->layers[i].active_mask = n;
}
@@ -1477,50 +1476,50 @@ void CustomData_set_layer_active_index(CustomData *data, int type, int n)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
data->layers[i].active = n-i;
data->layers[i].active = n - i;
}
void CustomData_set_layer_render_index(CustomData *data, int type, int n)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
data->layers[i].active_rnd = n-i;
data->layers[i].active_rnd = n - i;
}
void CustomData_set_layer_clone_index(CustomData *data, int type, int n)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
data->layers[i].active_clone = n-i;
data->layers[i].active_clone = n - i;
}
void CustomData_set_layer_stencil_index(CustomData *data, int type, int n)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
data->layers[i].active_mask = n-i;
data->layers[i].active_mask = n - i;
}
void CustomData_set_layer_flag(struct CustomData *data, int type, int flag)
{
int i;
for (i=0; i < data->totlayer; ++i)
for (i = 0; i < data->totlayer; ++i)
if (data->layers[i].type == type)
data->layers[i].flag |= flag;
}
static int customData_resize(CustomData *data, int amount)
{
CustomDataLayer *tmp = MEM_callocN(sizeof(*tmp)*(data->maxlayer + amount),
CustomDataLayer *tmp = MEM_callocN(sizeof(*tmp) * (data->maxlayer + amount),
"CustomData->layers");
if (!tmp) return 0;
@@ -1537,7 +1536,7 @@ static int customData_resize(CustomData *data, int amount)
static CustomDataLayer *customData_add_layer__internal(CustomData *data,
int type, int alloctype, void *layerdata, int totelem, const char *name)
{
const LayerTypeInfo *typeInfo= layerType_getInfo(type);
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
int size = typeInfo->size * totelem, flag = 0, index = data->totlayer;
void *newlayerdata = NULL;
@@ -1568,7 +1567,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
}
else if (alloctype == CD_DEFAULT) {
if (typeInfo->set_default)
typeInfo->set_default((char*)newlayerdata, totelem);
typeInfo->set_default((char *)newlayerdata, totelem);
}
else if (alloctype == CD_REFERENCE)
flag |= CD_FLAG_NOFREE;
@@ -1584,25 +1583,25 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
data->totlayer++;
/* keep layers ordered by type */
for ( ; index > 0 && data->layers[index - 1].type > type; --index)
for (; index > 0 && data->layers[index - 1].type > type; --index)
data->layers[index] = data->layers[index - 1];
data->layers[index].type = type;
data->layers[index].flag = flag;
data->layers[index].data = newlayerdata;
if (name || (name=typeInfo->defaultname)) {
if (name || (name = typeInfo->defaultname)) {
BLI_strncpy(data->layers[index].name, name, sizeof(data->layers[index].name));
CustomData_set_layer_unique_name(data, index);
}
else
data->layers[index].name[0] = '\0';
if (index > 0 && data->layers[index-1].type == type) {
data->layers[index].active = data->layers[index-1].active;
data->layers[index].active_rnd = data->layers[index-1].active_rnd;
data->layers[index].active_clone = data->layers[index-1].active_clone;
data->layers[index].active_mask = data->layers[index-1].active_mask;
if (index > 0 && data->layers[index - 1].type == type) {
data->layers[index].active = data->layers[index - 1].active;
data->layers[index].active_rnd = data->layers[index - 1].active_rnd;
data->layers[index].active_clone = data->layers[index - 1].active_clone;
data->layers[index].active_mask = data->layers[index - 1].active_mask;
}
else {
data->layers[index].active = 0;
@@ -1620,7 +1619,7 @@ void *CustomData_add_layer(CustomData *data, int type, int alloctype,
void *layerdata, int totelem)
{
CustomDataLayer *layer;
const LayerTypeInfo *typeInfo= layerType_getInfo(type);
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
layer = customData_add_layer__internal(data, type, alloctype, layerdata,
totelem, typeInfo->defaultname);
@@ -1657,8 +1656,8 @@ int CustomData_free_layer(CustomData *data, int type, int totelem, int index)
customData_free_layer__internal(&data->layers[index], totelem);
for (i=index+1; i < data->totlayer; ++i)
data->layers[i-1] = data->layers[i];
for (i = index + 1; i < data->totlayer; ++i)
data->layers[i - 1] = data->layers[i];
data->totlayer--;
@@ -1675,7 +1674,7 @@ int CustomData_free_layer(CustomData *data, int type, int totelem, int index)
}
}
if (data->totlayer <= data->maxlayer-CUSTOMDATA_GROW)
if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
customData_resize(data, -CUSTOMDATA_GROW);
customData_update_offsets(data);
@@ -1813,7 +1812,7 @@ void CustomData_free_temporary(CustomData *data, int totelem)
data->totlayer = j;
if (data->totlayer <= data->maxlayer-CUSTOMDATA_GROW)
if (data->totlayer <= data->maxlayer - CUSTOMDATA_GROW)
customData_resize(data, -CUSTOMDATA_GROW);
customData_update_offsets(data);
@@ -1836,7 +1835,7 @@ void CustomData_copy_elements(int type, void *source, void *dest, int count)
if (typeInfo->copy)
typeInfo->copy(source, dest, count);
else
memcpy(dest, source, typeInfo->size*count);
memcpy(dest, source, typeInfo->size * count);
}
void CustomData_copy_data(const CustomData *source, CustomData *dest,
@@ -1939,7 +1938,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest,
/* interpolates a layer at a time */
dest_i = 0;
for (src_i = 0; src_i < source->totlayer; ++src_i) {
const LayerTypeInfo *typeInfo= layerType_getInfo(source->layers[src_i].type);
const LayerTypeInfo *typeInfo = layerType_getInfo(source->layers[src_i].type);
if (!typeInfo->interp) continue;
/* find the first dest layer with type >= the source type
@@ -2016,7 +2015,7 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n)
if (layer_index < 0) return NULL;
offset = layerType_getInfo(type)->size * index;
return (char *)data->layers[layer_index+n].data + offset;
return (char *)data->layers[layer_index + n].data + offset;
}
void *CustomData_get_layer(const CustomData *data, int type)
@@ -2102,7 +2101,7 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l
int totloop, int totpoly)
{
int i;
for (i=0; i < fdata->totlayer; i++) {
for (i = 0; i < fdata->totlayer; i++) {
if (fdata->layers[i].type == CD_MTFACE) {
CustomData_add_layer_named(pdata, CD_MTEXPOLY, CD_CALLOC, NULL, totpoly, fdata->layers[i].name);
CustomData_add_layer_named(ldata, CD_MLOOPUV, CD_CALLOC, NULL, totloop, fdata->layers[i].name);
@@ -2119,12 +2118,12 @@ void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *l
void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total)
{
int i;
for (i=0; i < pdata->totlayer; i++) {
for (i = 0; i < pdata->totlayer; i++) {
if (pdata->layers[i].type == CD_MTEXPOLY) {
CustomData_add_layer_named(fdata, CD_MTFACE, CD_CALLOC, NULL, total, pdata->layers[i].name);
}
}
for (i=0; i < ldata->totlayer; i++) {
for (i = 0; i < ldata->totlayer; i++) {
if (ldata->layers[i].type == CD_MLOOPCOL) {
CustomData_add_layer_named(fdata, CD_MCOL, CD_CALLOC, NULL, total, ldata->layers[i].name);
}
@@ -2273,7 +2272,7 @@ void CustomData_bmesh_free_block(CustomData *data, void **block)
if (typeInfo->free) {
int offset = data->layers[i].offset;
typeInfo->free((char*)*block + offset, 1, typeInfo->size);
typeInfo->free((char *)*block + offset, 1, typeInfo->size);
}
}
}
@@ -2325,8 +2324,8 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest,
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type &&
strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0) {
char *src_data = (char*)src_block + source->layers[src_i].offset;
char *dest_data = (char*)*dest_block + dest->layers[dest_i].offset;
char *src_data = (char *)src_block + source->layers[src_i].offset;
char *dest_data = (char *)*dest_block + dest->layers[dest_i].offset;
typeInfo = layerType_getInfo(source->layers[src_i].type);
@@ -2364,7 +2363,7 @@ void *CustomData_bmesh_get_n(const CustomData *data, void *block, int type, int
layer_index = CustomData_get_layer_index(data, type);
if (layer_index < 0) return NULL;
return (char *)block + data->layers[layer_index+n].offset;
return (char *)block + data->layers[layer_index + n].offset;
}
/*gets from the layer at physical index n, note: doesn't check type.*/
@@ -2529,8 +2528,8 @@ void CustomData_bmesh_set_default(CustomData *data, void **block)
typeInfo = layerType_getInfo(data->layers[i].type);
if (typeInfo->set_default)
typeInfo->set_default((char*)*block + offset, 1);
else memset((char*)*block + offset, 0, typeInfo->size);
typeInfo->set_default((char *)*block + offset, 1);
else memset((char *)*block + offset, 0, typeInfo->size);
}
}
@@ -2561,7 +2560,7 @@ void CustomData_to_bmesh_block(const CustomData *source, CustomData *dest,
if (dest->layers[dest_i].type == source->layers[src_i].type) {
int offset = dest->layers[dest_i].offset;
char *src_data = source->layers[src_i].data;
char *dest_data = (char*)*dest_block + offset;
char *dest_data = (char *)*dest_block + offset;
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
src_offset = src_index * typeInfo->size;
@@ -2603,7 +2602,7 @@ void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest,
/* if we found a matching layer, copy the data */
if (dest->layers[dest_i].type == source->layers[src_i].type) {
int offset = source->layers[src_i].offset;
char *src_data = (char*)src_block + offset;
char *src_data = (char *)src_block + offset;
char *dest_data = dest->layers[dest_i].data;
typeInfo = layerType_getInfo(dest->layers[dest_i].type);
@@ -2665,17 +2664,17 @@ static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int
{
int i;
/* see if there is a duplicate */
for (i=0; i<data->totlayer; i++) {
for (i = 0; i < data->totlayer; i++) {
if (i != index) {
CustomDataLayer *layer= &data->layers[i];
CustomDataLayer *layer = &data->layers[i];
if (CustomData_is_property_layer(type)) {
if (CustomData_is_property_layer(layer->type) && strcmp(layer->name, name)==0) {
if (CustomData_is_property_layer(layer->type) && strcmp(layer->name, name) == 0) {
return 1;
}
}
else {
if (i!=index && layer->type==type && strcmp(layer->name, name)==0) {
if (i != index && layer->type == type && strcmp(layer->name, name) == 0) {
return 1;
}
}
@@ -2687,19 +2686,19 @@ static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int
static int customdata_unique_check(void *arg, const char *name)
{
struct {CustomData *data; int type; int index;} *data_arg= arg;
struct {CustomData *data; int type; int index; } *data_arg = arg;
return cd_layer_find_dupe(data_arg->data, name, data_arg->type, data_arg->index);
}
void CustomData_set_layer_unique_name(CustomData *data, int index)
{
CustomDataLayer *nlayer= &data->layers[index];
const LayerTypeInfo *typeInfo= layerType_getInfo(nlayer->type);
CustomDataLayer *nlayer = &data->layers[index];
const LayerTypeInfo *typeInfo = layerType_getInfo(nlayer->type);
struct {CustomData *data; int type; int index;} data_arg;
data_arg.data= data;
data_arg.type= nlayer->type;
data_arg.index= index;
struct {CustomData *data; int type; int index; } data_arg;
data_arg.data = data;
data_arg.type = nlayer->type;
data_arg.index = index;
if (!typeInfo->defaultname)
return;
@@ -2739,15 +2738,15 @@ int CustomData_verify_versions(struct CustomData *data, int index)
typeInfo = layerType_getInfo(layer->type);
if (!typeInfo->defaultname && (index > 0) &&
data->layers[index-1].type == layer->type)
data->layers[index - 1].type == layer->type)
{
keeplayer = 0; /* multiple layers of which we only support one */
}
}
if (!keeplayer) {
for (i=index+1; i < data->totlayer; ++i)
data->layers[i-1] = data->layers[i];
for (i = index + 1; i < data->totlayer; ++i)
data->layers[i - 1] = data->layers[i];
data->totlayer--;
}
@@ -2768,11 +2767,11 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask
const LayerTypeInfo *typeInfo;
int i;
for (i=0; i<data->totlayer; i++) {
for (i = 0; i < data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
if (!(mask & CD_TYPE_AS_MASK(layer->type)));
if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
else if ((layer->flag & CD_FLAG_EXTERNAL) && (layer->flag & CD_FLAG_IN_MEMORY)) {
if (typeInfo->free)
typeInfo->free(layer->data, totelem, typeInfo->size);
@@ -2783,7 +2782,7 @@ void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask
void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int totelem)
{
CustomDataExternal *external= data->external;
CustomDataExternal *external = data->external;
CustomDataLayer *layer;
CDataFile *cdf;
CDataFileLayer *blay;
@@ -2794,14 +2793,14 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
if (!external)
return;
for (i=0; i<data->totlayer; i++) {
for (i = 0; i < data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
if (!(mask & CD_TYPE_AS_MASK(layer->type)));
else if (layer->flag & CD_FLAG_IN_MEMORY);
if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
else if (layer->flag & CD_FLAG_IN_MEMORY) ;
else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read)
update= 1;
update = 1;
}
if (!update)
@@ -2809,24 +2808,24 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
customdata_external_filename(filename, id, external);
cdf= cdf_create(CDF_TYPE_MESH);
cdf = cdf_create(CDF_TYPE_MESH);
if (!cdf_read_open(cdf, filename)) {
fprintf(stderr, "Failed to read %s layer from %s.\n", layerType_getName(layer->type), filename);
return;
}
for (i=0; i<data->totlayer; i++) {
for (i = 0; i < data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
if (!(mask & CD_TYPE_AS_MASK(layer->type)));
else if (layer->flag & CD_FLAG_IN_MEMORY);
if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
else if (layer->flag & CD_FLAG_IN_MEMORY) ;
else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->read) {
blay= cdf_layer_find(cdf, layer->type, layer->name);
blay = cdf_layer_find(cdf, layer->type, layer->name);
if (blay) {
if (cdf_read_layer(cdf, blay)) {
if (typeInfo->read(cdf, layer->data, totelem));
if (typeInfo->read(cdf, layer->data, totelem)) ;
else break;
layer->flag |= CD_FLAG_IN_MEMORY;
}
@@ -2842,7 +2841,7 @@ void CustomData_external_read(CustomData *data, ID *id, CustomDataMask mask, int
void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, int totelem, int free)
{
CustomDataExternal *external= data->external;
CustomDataExternal *external = data->external;
CustomDataLayer *layer;
CDataFile *cdf;
CDataFileLayer *blay;
@@ -2854,13 +2853,13 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
return;
/* test if there is anything to write */
for (i=0; i<data->totlayer; i++) {
for (i = 0; i < data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
if (!(mask & CD_TYPE_AS_MASK(layer->type)));
if (!(mask & CD_TYPE_AS_MASK(layer->type))) ;
else if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write)
update= 1;
update = 1;
}
if (!update)
@@ -2870,9 +2869,9 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
CustomData_external_read(data, id, mask, totelem);
customdata_external_filename(filename, id, external);
cdf= cdf_create(CDF_TYPE_MESH);
cdf = cdf_create(CDF_TYPE_MESH);
for (i=0; i<data->totlayer; i++) {
for (i = 0; i < data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
@@ -2893,15 +2892,15 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
return;
}
for (i=0; i<data->totlayer; i++) {
for (i = 0; i < data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
if ((layer->flag & CD_FLAG_EXTERNAL) && typeInfo->write) {
blay= cdf_layer_find(cdf, layer->type, layer->name);
blay = cdf_layer_find(cdf, layer->type, layer->name);
if (cdf_write_layer(cdf, blay)) {
if (typeInfo->write(cdf, layer->data, totelem));
if (typeInfo->write(cdf, layer->data, totelem)) ;
else break;
}
else
@@ -2915,7 +2914,7 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
return;
}
for (i=0; i<data->totlayer; i++) {
for (i = 0; i < data->totlayer; i++) {
layer = &data->layers[i];
typeInfo = layerType_getInfo(layer->type);
@@ -2934,7 +2933,7 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in
void CustomData_external_add(CustomData *data, ID *UNUSED(id), int type, int UNUSED(totelem), const char *filename)
{
CustomDataExternal *external= data->external;
CustomDataExternal *external = data->external;
CustomDataLayer *layer;
int layer_index;
@@ -2947,17 +2946,17 @@ void CustomData_external_add(CustomData *data, ID *UNUSED(id), int type, int UNU
return;
if (!external) {
external= MEM_callocN(sizeof(CustomDataExternal), "CustomDataExternal");
data->external= external;
external = MEM_callocN(sizeof(CustomDataExternal), "CustomDataExternal");
data->external = external;
}
BLI_strncpy(external->filename, filename, sizeof(external->filename));
layer->flag |= CD_FLAG_EXTERNAL|CD_FLAG_IN_MEMORY;
layer->flag |= CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY;
}
void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
{
CustomDataExternal *external= data->external;
CustomDataExternal *external = data->external;
CustomDataLayer *layer;
//char filename[FILE_MAX];
int layer_index; // i, remove_file;
@@ -2977,10 +2976,10 @@ void CustomData_external_remove(CustomData *data, ID *id, int type, int totelem)
layer->flag &= ~CD_FLAG_EXTERNAL;
#if 0
remove_file= 1;
for (i=0; i<data->totlayer; i++)
remove_file = 1;
for (i = 0; i < data->totlayer; i++)
if (data->layers[i].flag & CD_FLAG_EXTERNAL)
remove_file= 0;
remove_file = 0;
if (remove_file) {
customdata_external_filename(filename, id, external);
@@ -3006,7 +3005,7 @@ int CustomData_external_test(CustomData *data, int type)
#if 0
void CustomData_external_remove_object(CustomData *data, ID *id)
{
CustomDataExternal *external= data->external;
CustomDataExternal *external = data->external;
char filename[FILE_MAX];
if (!external)

View File

@@ -121,9 +121,9 @@ static int cdf_data_type_size(int datatype)
CDataFile *cdf_create(int type)
{
CDataFile *cdf= MEM_callocN(sizeof(CDataFile), "CDataFile");
CDataFile *cdf = MEM_callocN(sizeof(CDataFile), "CDataFile");
cdf->type= type;
cdf->type = type;
return cdf;
}
@@ -147,11 +147,11 @@ static int cdf_read_header(CDataFile *cdf)
CDataFileImageHeader *image;
CDataFileMeshHeader *mesh;
CDataFileLayer *layer;
FILE *f= cdf->readf;
FILE *f = cdf->readf;
size_t offset = 0;
int a;
header= &cdf->header;
header = &cdf->header;
if (!fread(header, sizeof(CDataFileHeader), 1, cdf->readf))
return 0;
@@ -161,8 +161,8 @@ static int cdf_read_header(CDataFile *cdf)
if (header->version > CDF_VERSION)
return 0;
cdf->switchendian= header->endian != cdf_endian();
header->endian= cdf_endian();
cdf->switchendian = header->endian != cdf_endian();
header->endian = cdf_endian();
if (cdf->switchendian) {
SWITCH_INT(header->type);
@@ -174,13 +174,13 @@ static int cdf_read_header(CDataFile *cdf)
return 0;
offset += header->structbytes;
header->structbytes= sizeof(CDataFileHeader);
header->structbytes = sizeof(CDataFileHeader);
if (fseek(f, offset, SEEK_SET) != 0)
return 0;
if (header->type == CDF_TYPE_IMAGE) {
image= &cdf->btype.image;
image = &cdf->btype.image;
if (!fread(image, sizeof(CDataFileImageHeader), 1, f))
return 0;
@@ -192,10 +192,10 @@ static int cdf_read_header(CDataFile *cdf)
}
offset += image->structbytes;
image->structbytes= sizeof(CDataFileImageHeader);
image->structbytes = sizeof(CDataFileImageHeader);
}
else if (header->type == CDF_TYPE_MESH) {
mesh= &cdf->btype.mesh;
mesh = &cdf->btype.mesh;
if (!fread(mesh, sizeof(CDataFileMeshHeader), 1, f))
return 0;
@@ -203,17 +203,17 @@ static int cdf_read_header(CDataFile *cdf)
SWITCH_INT(mesh->structbytes);
offset += mesh->structbytes;
mesh->structbytes= sizeof(CDataFileMeshHeader);
mesh->structbytes = sizeof(CDataFileMeshHeader);
}
if (fseek(f, offset, SEEK_SET) != 0)
return 0;
cdf->layer= MEM_callocN(sizeof(CDataFileLayer)*header->totlayer, "CDataFileLayer");
cdf->totlayer= header->totlayer;
cdf->layer = MEM_callocN(sizeof(CDataFileLayer) * header->totlayer, "CDataFileLayer");
cdf->totlayer = header->totlayer;
for (a=0; a<header->totlayer; a++) {
layer= &cdf->layer[a];
for (a = 0; a < header->totlayer; a++) {
layer = &cdf->layer[a];
if (!fread(layer, sizeof(CDataFileLayer), 1, f))
return 0;
@@ -229,13 +229,13 @@ static int cdf_read_header(CDataFile *cdf)
return 0;
offset += layer->structbytes;
layer->structbytes= sizeof(CDataFileLayer);
layer->structbytes = sizeof(CDataFileLayer);
if (fseek(f, offset, SEEK_SET) != 0)
return 0;
}
cdf->dataoffset= offset;
cdf->dataoffset = offset;
return 1;
}
@@ -246,27 +246,27 @@ static int cdf_write_header(CDataFile *cdf)
CDataFileImageHeader *image;
CDataFileMeshHeader *mesh;
CDataFileLayer *layer;
FILE *f= cdf->writef;
FILE *f = cdf->writef;
int a;
header= &cdf->header;
header = &cdf->header;
if (!fwrite(header, sizeof(CDataFileHeader), 1, f))
return 0;
if (header->type == CDF_TYPE_IMAGE) {
image= &cdf->btype.image;
image = &cdf->btype.image;
if (!fwrite(image, sizeof(CDataFileImageHeader), 1, f))
return 0;
}
else if (header->type == CDF_TYPE_MESH) {
mesh= &cdf->btype.mesh;
mesh = &cdf->btype.mesh;
if (!fwrite(mesh, sizeof(CDataFileMeshHeader), 1, f))
return 0;
}
for (a=0; a<header->totlayer; a++) {
layer= &cdf->layer[a];
for (a = 0; a < header->totlayer; a++) {
layer = &cdf->layer[a];
if (!fwrite(layer, sizeof(CDataFileLayer), 1, f))
return 0;
@@ -279,11 +279,11 @@ int cdf_read_open(CDataFile *cdf, const char *filename)
{
FILE *f;
f= BLI_fopen(filename, "rb");
f = BLI_fopen(filename, "rb");
if (!f)
return 0;
cdf->readf= f;
cdf->readf = f;
if (!cdf_read_header(cdf)) {
cdf_read_close(cdf);
@@ -304,8 +304,8 @@ int cdf_read_layer(CDataFile *cdf, CDataFileLayer *blay)
int a;
/* seek to right location in file */
offset= cdf->dataoffset;
for (a=0; a<cdf->totlayer; a++) {
offset = cdf->dataoffset;
for (a = 0; a < cdf->totlayer; a++) {
if (&cdf->layer[a] == blay)
break;
else
@@ -326,9 +326,9 @@ int cdf_read_data(CDataFile *cdf, unsigned int size, void *data)
/* switch endian if necessary */
if (cdf->switchendian) {
fdata= data;
fdata = data;
for (a=0; a<size/sizeof(float); a++) {
for (a = 0; a < size / sizeof(float); a++) {
SWITCH_INT(fdata[a]);
}
}
@@ -340,7 +340,7 @@ void cdf_read_close(CDataFile *cdf)
{
if (cdf->readf) {
fclose(cdf->readf);
cdf->readf= NULL;
cdf->readf = NULL;
}
}
@@ -351,34 +351,34 @@ int cdf_write_open(CDataFile *cdf, const char *filename)
CDataFileMeshHeader *mesh;
FILE *f;
f= BLI_fopen(filename, "wb");
f = BLI_fopen(filename, "wb");
if (!f)
return 0;
cdf->writef= f;
cdf->writef = f;
/* fill header */
header= &cdf->header;
header = &cdf->header;
/* strcpy(, "BCDF"); // terminator out of range */
header->ID[0]= 'B'; header->ID[1]= 'C'; header->ID[2]= 'D'; header->ID[3]= 'F';
header->endian= cdf_endian();
header->version= CDF_VERSION;
header->subversion= CDF_SUBVERSION;
header->ID[0] = 'B'; header->ID[1] = 'C'; header->ID[2] = 'D'; header->ID[3] = 'F';
header->endian = cdf_endian();
header->version = CDF_VERSION;
header->subversion = CDF_SUBVERSION;
header->structbytes= sizeof(CDataFileHeader);
header->type= cdf->type;
header->totlayer= cdf->totlayer;
header->structbytes = sizeof(CDataFileHeader);
header->type = cdf->type;
header->totlayer = cdf->totlayer;
if (cdf->type == CDF_TYPE_IMAGE) {
/* fill image header */
image= &cdf->btype.image;
image->structbytes= sizeof(CDataFileImageHeader);
image->tile_size= CDF_TILE_SIZE;
image = &cdf->btype.image;
image->structbytes = sizeof(CDataFileImageHeader);
image->tile_size = CDF_TILE_SIZE;
}
else if (cdf->type == CDF_TYPE_MESH) {
/* fill mesh header */
mesh= &cdf->btype.mesh;
mesh->structbytes= sizeof(CDataFileMeshHeader);
mesh = &cdf->btype.mesh;
mesh->structbytes = sizeof(CDataFileMeshHeader);
}
cdf_write_header(cdf);
@@ -404,7 +404,7 @@ void cdf_write_close(CDataFile *cdf)
{
if (cdf->writef) {
fclose(cdf->writef);
cdf->writef= NULL;
cdf->writef = NULL;
}
}
@@ -420,8 +420,8 @@ CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, const char *name)
CDataFileLayer *layer;
int a;
for (a=0; a<cdf->totlayer; a++) {
layer= &cdf->layer[a];
for (a = 0; a < cdf->totlayer; a++) {
layer = &cdf->layer[a];
if (layer->type == type && strcmp(layer->name, name) == 0)
return layer;
@@ -435,18 +435,18 @@ CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t
CDataFileLayer *newlayer, *layer;
/* expand array */
newlayer= MEM_callocN(sizeof(CDataFileLayer)*(cdf->totlayer+1), "CDataFileLayer");
memcpy(newlayer, cdf->layer, sizeof(CDataFileLayer)*cdf->totlayer);
cdf->layer= newlayer;
newlayer = MEM_callocN(sizeof(CDataFileLayer) * (cdf->totlayer + 1), "CDataFileLayer");
memcpy(newlayer, cdf->layer, sizeof(CDataFileLayer) * cdf->totlayer);
cdf->layer = newlayer;
cdf->totlayer++;
/* fill in new layer */
layer= &cdf->layer[cdf->totlayer-1];
layer->structbytes= sizeof(CDataFileLayer);
layer->datatype= CDF_DATA_FLOAT;
layer->datasize= datasize;
layer->type= type;
layer = &cdf->layer[cdf->totlayer - 1];
layer->structbytes = sizeof(CDataFileLayer);
layer->datatype = CDF_DATA_FLOAT;
layer->datasize = datasize;
layer->type = type;
BLI_strncpy(layer->name, name, CDF_LAYER_NAME_MAX);
return layer;

File diff suppressed because it is too large Load Diff

View File

@@ -43,11 +43,11 @@ typedef struct {
const char *name, *plural;
int flags;
#define IDTYPE_FLAGS_ISLINKABLE (1<<0)
#define IDTYPE_FLAGS_ISLINKABLE (1 << 0)
} IDType;
/* plural need to match rna_main.c's MainCollectionDef */
static IDType idtypes[]= {
static IDType idtypes[] = {
{ ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE},
{ ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE},
{ ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE},
@@ -80,24 +80,24 @@ static IDType idtypes[]= {
{ ID_WM, "WindowManager", "window_managers", 0},
{ ID_MC, "MovieClip", "movieclips", IDTYPE_FLAGS_ISLINKABLE},
};
static int nidtypes= sizeof(idtypes)/sizeof(idtypes[0]);
static int nidtypes = sizeof(idtypes) / sizeof(idtypes[0]);
static IDType *idtype_from_name(const char *str)
{
int i= nidtypes;
int i = nidtypes;
while (i--)
if (strcmp(str, idtypes[i].name)==0)
if (strcmp(str, idtypes[i].name) == 0)
return &idtypes[i];
return NULL;
}
static IDType *idtype_from_code(int code)
{
int i= nidtypes;
int i = nidtypes;
while (i--)
if (code==idtypes[i].code)
if (code == idtypes[i].code)
return &idtypes[i];
return NULL;
@@ -105,34 +105,34 @@ static IDType *idtype_from_code(int code)
int BKE_idcode_is_valid(int code)
{
return idtype_from_code(code)?1:0;
return idtype_from_code(code) ? 1 : 0;
}
int BKE_idcode_is_linkable(int code)
{
IDType *idt= idtype_from_code(code);
return idt?(idt->flags&IDTYPE_FLAGS_ISLINKABLE):0;
IDType *idt = idtype_from_code(code);
return idt ? (idt->flags & IDTYPE_FLAGS_ISLINKABLE) : 0;
}
const char *BKE_idcode_to_name(int code)
{
IDType *idt= idtype_from_code(code);
IDType *idt = idtype_from_code(code);
return idt?idt->name:NULL;
return idt ? idt->name : NULL;
}
int BKE_idcode_from_name(const char *name)
{
IDType *idt= idtype_from_name(name);
IDType *idt = idtype_from_name(name);
return idt?idt->code:0;
return idt ? idt->code : 0;
}
const char *BKE_idcode_to_name_plural(int code)
{
IDType *idt= idtype_from_code(code);
IDType *idt = idtype_from_code(code);
return idt?idt->plural:NULL;
return idt ? idt->plural : NULL;
}
int BKE_idcode_iter_step(int *index)

View File

@@ -82,8 +82,8 @@ void free_nlastrip(ListBase *strips, NlaStrip *strip)
return;
/* free child-strips */
for (cs= strip->strips.first; cs; cs= csn) {
csn= cs->next;
for (cs = strip->strips.first; cs; cs = csn) {
csn = cs->next;
free_nlastrip(&strip->strips, cs);
}
@@ -120,8 +120,8 @@ void free_nlatrack(ListBase *tracks, NlaTrack *nlt)
return;
/* free strips */
for (strip= nlt->strips.first; strip; strip= stripn) {
stripn= strip->next;
for (strip = nlt->strips.first; strip; strip = stripn) {
stripn = strip->next;
free_nlastrip(&nlt->strips, strip);
}
@@ -144,19 +144,19 @@ void free_nladata(ListBase *tracks)
return;
/* free tracks one by one */
for (nlt= tracks->first; nlt; nlt= nltn) {
nltn= nlt->next;
for (nlt = tracks->first; nlt; nlt = nltn) {
nltn = nlt->next;
free_nlatrack(tracks, nlt);
}
/* clear the list's pointers to be safe */
tracks->first= tracks->last= NULL;
tracks->first = tracks->last = NULL;
}
/* Copying ------------------------------------------- */
/* Copy NLA strip */
NlaStrip *copy_nlastrip (NlaStrip *strip)
NlaStrip *copy_nlastrip(NlaStrip *strip)
{
NlaStrip *strip_d;
NlaStrip *cs, *cs_d;
@@ -166,8 +166,8 @@ NlaStrip *copy_nlastrip (NlaStrip *strip)
return NULL;
/* make a copy */
strip_d= MEM_dupallocN(strip);
strip_d->next= strip_d->prev= NULL;
strip_d = MEM_dupallocN(strip);
strip_d->next = strip_d->prev = NULL;
/* increase user-count of action */
if (strip_d->act)
@@ -178,10 +178,10 @@ NlaStrip *copy_nlastrip (NlaStrip *strip)
copy_fmodifiers(&strip_d->modifiers, &strip->modifiers);
/* make a copy of all the child-strips, one at a time */
strip_d->strips.first= strip_d->strips.last= NULL;
strip_d->strips.first = strip_d->strips.last = NULL;
for (cs= strip->strips.first; cs; cs= cs->next) {
cs_d= copy_nlastrip(cs);
for (cs = strip->strips.first; cs; cs = cs->next) {
cs_d = copy_nlastrip(cs);
BLI_addtail(&strip_d->strips, cs_d);
}
@@ -190,7 +190,7 @@ NlaStrip *copy_nlastrip (NlaStrip *strip)
}
/* Copy NLA Track */
NlaTrack *copy_nlatrack (NlaTrack *nlt)
NlaTrack *copy_nlatrack(NlaTrack *nlt)
{
NlaStrip *strip, *strip_d;
NlaTrack *nlt_d;
@@ -200,14 +200,14 @@ NlaTrack *copy_nlatrack (NlaTrack *nlt)
return NULL;
/* make a copy */
nlt_d= MEM_dupallocN(nlt);
nlt_d->next= nlt_d->prev= NULL;
nlt_d = MEM_dupallocN(nlt);
nlt_d->next = nlt_d->prev = NULL;
/* make a copy of all the strips, one at a time */
nlt_d->strips.first= nlt_d->strips.last= NULL;
nlt_d->strips.first = nlt_d->strips.last = NULL;
for (strip= nlt->strips.first; strip; strip= strip->next) {
strip_d= copy_nlastrip(strip);
for (strip = nlt->strips.first; strip; strip = strip->next) {
strip_d = copy_nlastrip(strip);
BLI_addtail(&nlt_d->strips, strip_d);
}
@@ -225,12 +225,12 @@ void copy_nladata(ListBase *dst, ListBase *src)
return;
/* clear out the destination list first for precautions... */
dst->first= dst->last= NULL;
dst->first = dst->last = NULL;
/* copy each NLA-track, one at a time */
for (nlt= src->first; nlt; nlt= nlt->next) {
for (nlt = src->first; nlt; nlt = nlt->next) {
/* make a copy, and add the copy to the destination list */
nlt_d= copy_nlatrack(nlt);
nlt_d = copy_nlatrack(nlt);
BLI_addtail(dst, nlt_d);
}
}
@@ -240,7 +240,7 @@ void copy_nladata(ListBase *dst, ListBase *src)
/* Add a NLA Track to the given AnimData
* - prev: NLA-Track to add the new one after
*/
NlaTrack *add_nlatrack (AnimData *adt, NlaTrack *prev)
NlaTrack *add_nlatrack(AnimData *adt, NlaTrack *prev)
{
NlaTrack *nlt;
@@ -249,11 +249,11 @@ NlaTrack *add_nlatrack (AnimData *adt, NlaTrack *prev)
return NULL;
/* allocate new track */
nlt= MEM_callocN(sizeof(NlaTrack), "NlaTrack");
nlt = MEM_callocN(sizeof(NlaTrack), "NlaTrack");
/* set settings requiring the track to not be part of the stack yet */
nlt->flag = NLATRACK_SELECTED;
nlt->index= BLI_countlist(&adt->nla_tracks);
nlt->index = BLI_countlist(&adt->nla_tracks);
/* add track to stack, and make it the active one */
if (prev)
@@ -271,7 +271,7 @@ NlaTrack *add_nlatrack (AnimData *adt, NlaTrack *prev)
}
/* Add a NLA Strip referencing the given Action */
NlaStrip *add_nlastrip (bAction *act)
NlaStrip *add_nlastrip(bAction *act)
{
NlaStrip *strip;
@@ -280,7 +280,7 @@ NlaStrip *add_nlastrip (bAction *act)
return NULL;
/* allocate new strip */
strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip");
strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
/* generic settings
* - selected flag to highlight this to the user
@@ -290,10 +290,10 @@ NlaStrip *add_nlastrip (bAction *act)
* is not done though, since this should only really happens in editmode for strips now
* though this decision is still subject to further review...
*/
strip->flag = NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_AUTO_BLENDS;
strip->flag = NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_AUTO_BLENDS;
/* assign the action reference */
strip->act= act;
strip->act = act;
id_us_plus(&act->id);
/* determine initial range
@@ -302,10 +302,10 @@ NlaStrip *add_nlastrip (bAction *act)
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
strip->start = strip->actstart;
strip->end = (IS_EQF(strip->actstart, strip->actend)) ? (strip->actstart + 1.0f): (strip->actend);
strip->end = (IS_EQF(strip->actstart, strip->actend)) ? (strip->actstart + 1.0f) : (strip->actend);
/* strip should be referenced as-is */
strip->scale= 1.0f;
strip->scale = 1.0f;
strip->repeat = 1.0f;
/* return the new strip */
@@ -313,7 +313,7 @@ NlaStrip *add_nlastrip (bAction *act)
}
/* Add new NLA-strip to the top of the NLA stack - i.e. into the last track if space, or a new one otherwise */
NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act)
NlaStrip *add_nlastrip_to_stack(AnimData *adt, bAction *act)
{
NlaStrip *strip;
NlaTrack *nlt;
@@ -323,7 +323,7 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act)
return NULL;
/* create a new NLA strip */
strip= add_nlastrip(act);
strip = add_nlastrip(act);
if (strip == NULL)
return NULL;
@@ -332,7 +332,7 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act)
/* trying to add to the last track failed (no track or no space),
* so add a new track to the stack, and add to that...
*/
nlt= add_nlatrack(adt, NULL);
nlt = add_nlatrack(adt, NULL);
BKE_nlatrack_add_strip(nlt, strip);
}
@@ -344,7 +344,7 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act)
}
/* Add a NLA Strip referencing the given speaker's sound */
NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
NlaStrip *add_nla_soundstrip(Scene *scene, Speaker *speaker)
{
NlaStrip *strip = MEM_callocN(sizeof(NlaStrip), "NlaSoundStrip");
@@ -388,7 +388,7 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker)
/* non clipped mapping for strip-time <-> global time (for Action-Clips)
* invert = convert action-strip time to global time
*/
static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short mode)
static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short mode)
{
float actlength, scale;
// float repeat; // UNUSED
@@ -398,7 +398,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short
// repeat = strip->repeat; // UNUSED
/* scaling */
if (IS_EQF(strip->scale, 0.0f)) strip->scale= 1.0f;
if (IS_EQF(strip->scale, 0.0f)) strip->scale = 1.0f;
scale = fabsf(strip->scale); /* scale must be positive - we've got a special flag for reversing */
/* length of referenced action */
@@ -409,12 +409,12 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short
if (strip->flag & NLASTRIP_FLAG_REVERSE) {
// FIXME: this won't work right with Graph Editor?
if (mode == NLATIME_CONVERT_MAP) {
return strip->end - scale*(cframe - strip->actstart);
return strip->end - scale * (cframe - strip->actstart);
}
else if (mode == NLATIME_CONVERT_UNMAP) {
return (strip->end + (strip->actstart * scale - cframe)) / scale;
}
else /* if (mode == NLATIME_CONVERT_EVAL) */{
else { /* if (mode == NLATIME_CONVERT_EVAL) */
if (IS_EQF(cframe, strip->end) && IS_EQF(strip->repeat, ((int)strip->repeat))) {
/* this case prevents the motion snapping back to the first frame at the end of the strip
* by catching the case where repeats is a whole number, which means that the end of the strip
@@ -426,18 +426,18 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short
/* - the 'fmod(..., actlength*scale)' is needed to get the repeats working
* - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
*/
return strip->actend - fmodf(cframe - strip->start, actlength*scale) / scale;
return strip->actend - fmodf(cframe - strip->start, actlength * scale) / scale;
}
}
}
else {
if (mode == NLATIME_CONVERT_MAP) {
return strip->start + scale*(cframe - strip->actstart);
return strip->start + scale * (cframe - strip->actstart);
}
else if (mode == NLATIME_CONVERT_UNMAP) {
return strip->actstart + (cframe - strip->start) / scale;
}
else /* if (mode == NLATIME_CONVERT_EVAL) */{
else { /* if (mode == NLATIME_CONVERT_EVAL) */
if (IS_EQF(cframe, strip->end) && IS_EQF(strip->repeat, ((int)strip->repeat))) {
/* this case prevents the motion snapping back to the first frame at the end of the strip
* by catching the case where repeats is a whole number, which means that the end of the strip
@@ -449,7 +449,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short
/* - the 'fmod(..., actlength*scale)' is needed to get the repeats working
* - the '/ scale' is needed to ensure that scaling influences the timing within the repeat
*/
return strip->actstart + fmodf(cframe - strip->start, actlength*scale) / scale;
return strip->actstart + fmodf(cframe - strip->start, actlength * scale) / scale;
}
}
}
@@ -458,12 +458,12 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short
/* non clipped mapping for strip-time <-> global time (for Transitions)
* invert = convert action-strip time to global time
*/
static float nlastrip_get_frame_transition (NlaStrip *strip, float cframe, short mode)
static float nlastrip_get_frame_transition(NlaStrip *strip, float cframe, short mode)
{
float length;
/* length of strip */
length= strip->end - strip->start;
length = strip->end - strip->start;
/* reversed = play strip backwards */
if (strip->flag & NLASTRIP_FLAG_REVERSE) {
@@ -515,17 +515,17 @@ float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
* - when not in tweakmode, the active Action does not have any scaling applied :)
* - when in tweakmode, if the no-mapping flag is set, do not map
*/
if ((adt == NULL) || (adt->flag & ADT_NLA_EDIT_ON)==0 || (adt->flag & ADT_NLA_EDIT_NOMAP))
if ((adt == NULL) || (adt->flag & ADT_NLA_EDIT_ON) == 0 || (adt->flag & ADT_NLA_EDIT_NOMAP))
return cframe;
/* if the active-strip info has been stored already, access this, otherwise look this up
* and store for (very probable) future usage
*/
if (adt->actstrip == NULL) {
NlaTrack *nlt= BKE_nlatrack_find_active(&adt->nla_tracks);
adt->actstrip= BKE_nlastrip_find_active(nlt);
NlaTrack *nlt = BKE_nlatrack_find_active(&adt->nla_tracks);
adt->actstrip = BKE_nlastrip_find_active(nlt);
}
strip= adt->actstrip;
strip = adt->actstrip;
/* sanity checks
* - in rare cases, we may not be able to find this strip for some reason (internal error)
@@ -559,7 +559,7 @@ short BKE_nlastrips_has_space(ListBase *strips, float start, float end)
}
/* loop over NLA strips checking for any overlaps with this area... */
for (strip= strips->first; strip; strip= strip->next) {
for (strip = strips->first; strip; strip = strip->next) {
/* if start frame of strip is past the target end-frame, that means that
* we've gone past the window we need to check for, so things are fine
*/
@@ -592,21 +592,21 @@ void BKE_nlastrips_sort_strips(ListBase *strips)
/* we simply perform insertion sort on this list, since it is assumed that per track,
* there are only likely to be at most 5-10 strips
*/
for (strip= strips->first; strip; strip= stripn) {
for (strip = strips->first; strip; strip = stripn) {
short not_added = 1;
stripn= strip->next;
stripn = strip->next;
/* remove this strip from the list, and add it to the new list, searching from the end of
* the list, assuming that the lists are in order
*/
BLI_remlink(strips, strip);
for (sstrip= tmp.last; sstrip; sstrip= sstrip->prev) {
for (sstrip = tmp.last; sstrip; sstrip = sstrip->prev) {
/* check if add after */
if (sstrip->end <= strip->start) {
BLI_insertlinkafter(&tmp, sstrip, strip);
not_added= 0;
not_added = 0;
break;
}
}
@@ -617,8 +617,8 @@ void BKE_nlastrips_sort_strips(ListBase *strips)
}
/* reassign the start and end points of the strips */
strips->first= tmp.first;
strips->last= tmp.last;
strips->first = tmp.first;
strips->last = tmp.last;
}
/* Add the given NLA-Strip to the given list of strips, assuming that it
@@ -634,15 +634,15 @@ short BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip)
return 0;
/* check if any space to add */
if (BKE_nlastrips_has_space(strips, strip->start, strip->end)==0)
if (BKE_nlastrips_has_space(strips, strip->start, strip->end) == 0)
return 0;
/* find the right place to add the strip to the nominated track */
for (ns= strips->first; ns; ns= ns->next) {
for (ns = strips->first; ns; ns = ns->next) {
/* if current strip occurs after the new strip, add it before */
if (ns->start >= strip->end) {
BLI_insertlinkbefore(strips, ns, strip);
not_added= 0;
not_added = 0;
break;
}
}
@@ -672,14 +672,14 @@ void BKE_nlastrips_make_metas(ListBase *strips, short temp)
return;
/* group all continuous chains of selected strips into meta-strips */
for (strip= strips->first; strip; strip= stripn) {
stripn= strip->next;
for (strip = strips->first; strip; strip = stripn) {
stripn = strip->next;
if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* if there is an existing meta-strip, add this strip to it, otherwise, create a new one */
if (mstrip == NULL) {
/* add a new meta-strip, and add it before the current strip that it will replace... */
mstrip= MEM_callocN(sizeof(NlaStrip), "Meta-NlaStrip");
mstrip = MEM_callocN(sizeof(NlaStrip), "Meta-NlaStrip");
mstrip->type = NLASTRIP_TYPE_META;
BLI_insertlinkbefore(strips, strip, mstrip);
@@ -691,10 +691,10 @@ void BKE_nlastrips_make_metas(ListBase *strips, short temp)
mstrip->flag |= NLASTRIP_FLAG_TEMP_META;
/* set default repeat/scale values to prevent warnings */
mstrip->repeat= mstrip->scale= 1.0f;
mstrip->repeat = mstrip->scale = 1.0f;
/* make its start frame be set to the start frame of the current strip */
mstrip->start= strip->start;
mstrip->start = strip->start;
}
/* remove the selected strips from the track, and add to the meta */
@@ -702,13 +702,13 @@ void BKE_nlastrips_make_metas(ListBase *strips, short temp)
BLI_addtail(&mstrip->strips, strip);
/* expand the meta's dimensions to include the newly added strip- i.e. its last frame */
mstrip->end= strip->end;
mstrip->end = strip->end;
}
else {
/* current strip wasn't selected, so the end of 'island' of selected strips has been reached,
* so stop adding strips to the current meta
*/
mstrip= NULL;
mstrip = NULL;
}
}
}
@@ -725,8 +725,8 @@ void BKE_nlastrips_clear_metastrip(ListBase *strips, NlaStrip *strip)
/* move each one of the meta-strip's children before the meta-strip
* in the list of strips after unlinking them from the meta-strip
*/
for (cs= strip->strips.first; cs; cs= csn) {
csn= cs->next;
for (cs = strip->strips.first; cs; cs = csn) {
csn = cs->next;
BLI_remlink(&strip->strips, cs);
BLI_insertlinkbefore(strips, strip, cs);
}
@@ -748,13 +748,13 @@ void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp)
return;
/* remove meta-strips fitting the criteria of the arguments */
for (strip= strips->first; strip; strip= stripn) {
stripn= strip->next;
for (strip = strips->first; strip; strip = stripn) {
stripn = strip->next;
/* check if strip is a meta-strip */
if (strip->type == NLASTRIP_TYPE_META) {
/* if check if selection and 'temporary-only' considerations are met */
if ((onlySel==0) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
if ((onlySel == 0) || (strip->flag & NLASTRIP_FLAG_SELECT)) {
if ((!onlyTemp) || (strip->flag & NLASTRIP_FLAG_TEMP_META)) {
BKE_nlastrips_clear_metastrip(strips, strip);
}
@@ -786,7 +786,7 @@ short BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
if ((mstrip->prev == NULL) || (mstrip->prev->end <= strip->start)) {
/* add strip to start of meta's list, and expand dimensions */
BLI_addhead(&mstrip->strips, strip);
mstrip->start= strip->start;
mstrip->start = strip->start;
return 1;
}
@@ -800,7 +800,7 @@ short BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
if ((mstrip->next == NULL) || (mstrip->next->start >= strip->end)) {
/* add strip to end of meta's list, and expand dimensions */
BLI_addtail(&mstrip->strips, strip);
mstrip->end= strip->end;
mstrip->end = strip->end;
return 1;
}
@@ -821,7 +821,7 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
NlaStrip *strip;
float oStart, oEnd, offset;
float oLen, nLen;
short scaleChanged= 0;
short scaleChanged = 0;
/* sanity checks
* - strip must exist
@@ -836,9 +836,9 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
* - these are simply the start/end frames of the child strips,
* since we assume they weren't transformed yet
*/
oStart= ((NlaStrip *)mstrip->strips.first)->start;
oEnd= ((NlaStrip *)mstrip->strips.last)->end;
offset= mstrip->start - oStart;
oStart = ((NlaStrip *)mstrip->strips.first)->start;
oEnd = ((NlaStrip *)mstrip->strips.last)->end;
offset = mstrip->start - oStart;
/* optimization:
* don't flush if nothing changed yet
@@ -851,20 +851,20 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
oLen = oEnd - oStart;
nLen = mstrip->end - mstrip->start;
if (IS_EQF(nLen, oLen) == 0)
scaleChanged= 1;
scaleChanged = 1;
/* for each child-strip, calculate new start/end points based on this new info */
for (strip= mstrip->strips.first; strip; strip= strip->next) {
for (strip = mstrip->strips.first; strip; strip = strip->next) {
if (scaleChanged) {
float p1, p2;
/* compute positions of endpoints relative to old extents of strip */
p1= (strip->start - oStart) / oLen;
p2= (strip->end - oStart) / oLen;
p1 = (strip->start - oStart) / oLen;
p2 = (strip->end - oStart) / oLen;
/* apply new strip endpoints using the proportions, then wait for second pass to flush scale properly */
strip->start= (p1 * nLen) + mstrip->start;
strip->end= (p2 * nLen) + mstrip->start;
strip->start = (p1 * nLen) + mstrip->start;
strip->end = (p2 * nLen) + mstrip->start;
}
else {
/* just apply the changes in offset to both ends of the strip */
@@ -874,7 +874,7 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
}
/* apply a second pass over child strips, to finish up unfinished business */
for (strip= mstrip->strips.first; strip; strip= strip->next) {
for (strip = mstrip->strips.first; strip; strip = strip->next) {
/* only if scale changed, need to perform RNA updates */
if (scaleChanged) {
PointerRNA ptr;
@@ -894,7 +894,7 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
/* NLA-Tracks ---------------------------------------- */
/* Find the active NLA-track for the given stack */
NlaTrack *BKE_nlatrack_find_active (ListBase *tracks)
NlaTrack *BKE_nlatrack_find_active(ListBase *tracks)
{
NlaTrack *nlt;
@@ -903,7 +903,7 @@ NlaTrack *BKE_nlatrack_find_active (ListBase *tracks)
return NULL;
/* try to find the first active track */
for (nlt= tracks->first; nlt; nlt= nlt->next) {
for (nlt = tracks->first; nlt; nlt = nlt->next) {
if (nlt->flag & NLATRACK_ACTIVE)
return nlt;
}
@@ -924,7 +924,7 @@ void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt)
return;
/* firstly, make sure 'solo' flag for all tracks is disabled */
for (nt= adt->nla_tracks.first; nt; nt= nt->next) {
for (nt = adt->nla_tracks.first; nt; nt = nt->next) {
if (nt != nlt)
nt->flag &= ~NLATRACK_SOLO;
}
@@ -956,7 +956,7 @@ void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt_a)
return;
/* deactive all the rest */
for (nlt= tracks->first; nlt; nlt= nlt->next)
for (nlt = tracks->first; nlt; nlt = nlt->next)
nlt->flag &= ~NLATRACK_ACTIVE;
/* set the given one as the active one */
@@ -1042,7 +1042,7 @@ short BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2])
/* NLA Strips -------------------------------------- */
/* Find the active NLA-strip within the given track */
NlaStrip *BKE_nlastrip_find_active (NlaTrack *nlt)
NlaStrip *BKE_nlastrip_find_active(NlaTrack *nlt)
{
NlaStrip *strip;
@@ -1051,7 +1051,7 @@ NlaStrip *BKE_nlastrip_find_active (NlaTrack *nlt)
return NULL;
/* try to find the first active strip */
for (strip= nlt->strips.first; strip; strip= strip->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (strip->flag & NLASTRIP_FLAG_ACTIVE)
return strip;
}
@@ -1071,8 +1071,8 @@ void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
return;
/* loop over tracks, deactivating*/
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
for (nls= nlt->strips.first; nls; nls= nls->next) {
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (nls = nlt->strips.first; nls; nls = nls->next) {
if (nls != strip)
nls->flag &= ~NLASTRIP_FLAG_ACTIVE;
else
@@ -1085,8 +1085,8 @@ void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
/* Does the given NLA-strip fall within the given bounds (times)? */
short BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max)
{
const float stripLen= (strip) ? strip->end - strip->start : 0.0f;
const float boundsLen= fabsf(max - min);
const float stripLen = (strip) ? strip->end - strip->start : 0.0f;
const float boundsLen = fabsf(max - min);
/* sanity checks */
if ((strip == NULL) || IS_EQF(stripLen, 0.0f) || IS_EQF(boundsLen, 0.0f))
@@ -1128,10 +1128,10 @@ void BKE_nlastrip_recalculate_bounds(NlaStrip *strip)
return;
/* calculate new length factors */
actlen= strip->actend - strip->actstart;
if (IS_EQF(actlen, 0.0f)) actlen= 1.0f;
actlen = strip->actend - strip->actstart;
if (IS_EQF(actlen, 0.0f)) actlen = 1.0f;
mapping= strip->scale * strip->repeat;
mapping = strip->scale * strip->repeat;
/* adjust endpoint of strip in response to this */
if (IS_EQF(mapping, 0.0f) == 0)
@@ -1140,7 +1140,7 @@ void BKE_nlastrip_recalculate_bounds(NlaStrip *strip)
/* Is the given NLA-strip the first one to occur for the given AnimData block */
// TODO: make this an api method if necesary, but need to add prefix first
static short nlastrip_is_first (AnimData *adt, NlaStrip *strip)
static short nlastrip_is_first(AnimData *adt, NlaStrip *strip)
{
NlaTrack *nlt;
NlaStrip *ns;
@@ -1155,9 +1155,9 @@ static short nlastrip_is_first (AnimData *adt, NlaStrip *strip)
/* check other tracks to see if they have a strip that's earlier */
// TODO: or should we check that the strip's track is also the first?
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
/* only check the first strip, assuming that they're all in order */
ns= nlt->strips.first;
ns = nlt->strips.first;
if (ns) {
if (ns->start < strip->start)
return 0;
@@ -1180,7 +1180,7 @@ short BKE_nlatrack_has_animated_strips(NlaTrack *nlt)
return 0;
/* check each strip for F-Curves only (don't care about whether the flags are set) */
for (strip= nlt->strips.first; strip; strip= strip->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (strip->fcurves.first)
return 1;
}
@@ -1199,7 +1199,7 @@ short BKE_nlatracks_have_animated_strips(ListBase *tracks)
return 0;
/* check each track, stopping on the first hit */
for (nlt= tracks->first; nlt; nlt= nlt->next) {
for (nlt = tracks->first; nlt; nlt = nlt->next) {
if (BKE_nlatrack_has_animated_strips(nlt))
return 1;
}
@@ -1220,19 +1220,19 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
/* if controlling influence... */
if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) {
/* try to get F-Curve */
fcu= list_find_fcurve(&strip->fcurves, "influence", 0);
fcu = list_find_fcurve(&strip->fcurves, "influence", 0);
/* add one if not found */
if (fcu == NULL) {
/* make new F-Curve */
fcu= MEM_callocN(sizeof(FCurve), "NlaStrip FCurve");
fcu = MEM_callocN(sizeof(FCurve), "NlaStrip FCurve");
BLI_addtail(&strip->fcurves, fcu);
/* set default flags */
fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED);
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
/* store path - make copy, and store that */
fcu->rna_path= BLI_strdupn("influence", 9);
fcu->rna_path = BLI_strdupn("influence", 9);
// TODO: insert a few keyframes to ensure default behavior?
}
@@ -1241,19 +1241,19 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
/* if controlling time... */
if (strip->flag & NLASTRIP_FLAG_USR_TIME) {
/* try to get F-Curve */
fcu= list_find_fcurve(&strip->fcurves, "strip_time", 0);
fcu = list_find_fcurve(&strip->fcurves, "strip_time", 0);
/* add one if not found */
if (fcu == NULL) {
/* make new F-Curve */
fcu= MEM_callocN(sizeof(FCurve), "NlaStrip FCurve");
fcu = MEM_callocN(sizeof(FCurve), "NlaStrip FCurve");
BLI_addtail(&strip->fcurves, fcu);
/* set default flags */
fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED);
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
/* store path - make copy, and store that */
fcu->rna_path= BLI_strdupn("strip_time", 10);
fcu->rna_path = BLI_strdupn("strip_time", 10);
// TODO: insert a few keyframes to ensure default behavior?
}
@@ -1283,10 +1283,10 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
return;
/* give strip a default name if none already */
if (strip->name[0]==0) {
if (strip->name[0] == 0) {
switch (strip->type) {
case NLASTRIP_TYPE_CLIP: /* act-clip */
BLI_strncpy(strip->name, (strip->act)?(strip->act->id.name+2):("<No Action>"), sizeof(strip->name));
BLI_strncpy(strip->name, (strip->act) ? (strip->act->id.name + 2) : ("<No Action>"), sizeof(strip->name));
break;
case NLASTRIP_TYPE_TRANSITION: /* transition */
BLI_strncpy(strip->name, "Transition", sizeof(strip->name));
@@ -1304,10 +1304,10 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
* - this is easier than iterating over all the tracks+strips hierarchy everytime
* (and probably faster)
*/
gh= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nlastrip_validate_name gh");
gh = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nlastrip_validate_name gh");
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
for (tstrip= nlt->strips.first; tstrip; tstrip= tstrip->next) {
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (tstrip = nlt->strips.first; tstrip; tstrip = tstrip->next) {
/* don't add the strip of interest */
if (tstrip == strip)
continue;
@@ -1333,7 +1333,7 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
* - track: nla-track that the overlapping strips should be found from
* - start, end: frames for the offending endpoints
*/
static void nlastrip_get_endpoint_overlaps (NlaStrip *strip, NlaTrack *track, float **start, float **end)
static void nlastrip_get_endpoint_overlaps(NlaStrip *strip, NlaTrack *track, float **start, float **end)
{
NlaStrip *nls;
@@ -1341,11 +1341,11 @@ static void nlastrip_get_endpoint_overlaps (NlaStrip *strip, NlaTrack *track, fl
* but which don't cover the entire length
*/
// TODO: this scheme could get quite slow for doing this on many strips...
for (nls= track->strips.first; nls; nls= nls->next) {
for (nls = track->strips.first; nls; nls = nls->next) {
/* check if strip overlaps (extends over or exactly on) the entire range of the strip we're validating */
if ((nls->start <= strip->start) && (nls->end >= strip->end)) {
*start= NULL;
*end= NULL;
*start = NULL;
*end = NULL;
return;
}
@@ -1358,29 +1358,29 @@ static void nlastrip_get_endpoint_overlaps (NlaStrip *strip, NlaTrack *track, fl
/* if this strip is not part of an island of continuous strips, it can be used
* - this check needs to be done for each end of the strip we try and use...
*/
if ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end)==0) {
if ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end) == 0) {
if ((nls->end > strip->start) && (nls->end < strip->end))
*start= &nls->end;
*start = &nls->end;
}
if ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start)==0) {
if ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0) {
if ((nls->start < strip->end) && (nls->start > strip->start))
*end= &nls->start;
*end = &nls->start;
}
}
}
/* Determine auto-blending for the given strip */
static void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls)
static void BKE_nlastrip_validate_autoblends(NlaTrack *nlt, NlaStrip *nls)
{
float *ps=NULL, *pe=NULL;
float *ns=NULL, *ne=NULL;
float *ps = NULL, *pe = NULL;
float *ns = NULL, *ne = NULL;
/* sanity checks */
if (ELEM(NULL, nls, nlt))
return;
if ((nlt->prev == NULL) && (nlt->next == NULL))
return;
if ((nls->flag & NLASTRIP_FLAG_AUTO_BLENDS)==0)
if ((nls->flag & NLASTRIP_FLAG_AUTO_BLENDS) == 0)
return;
/* get test ranges */
@@ -1394,31 +1394,31 @@ static void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls)
* is directly followed/preceeded by another strip, forming an
* 'island' of continuous strips
*/
if ((ps || ns) && ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start)==0)) {
if ((ps || ns) && ((nls->prev == NULL) || IS_EQF(nls->prev->end, nls->start) == 0)) {
/* start overlaps - pick the largest overlap */
if ( ((ps && ns) && (*ps > *ns)) || (ps) )
nls->blendin= *ps - nls->start;
nls->blendin = *ps - nls->start;
else
nls->blendin= *ns - nls->start;
nls->blendin = *ns - nls->start;
}
else /* no overlap allowed/needed */
nls->blendin= 0.0f;
nls->blendin = 0.0f;
if ((pe || ne) && ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end)==0)) {
if ((pe || ne) && ((nls->next == NULL) || IS_EQF(nls->next->start, nls->end) == 0)) {
/* end overlaps - pick the largest overlap */
if ( ((pe && ne) && (*pe > *ne)) || (pe) )
nls->blendout= nls->end - *pe;
nls->blendout = nls->end - *pe;
else
nls->blendout= nls->end - *ne;
nls->blendout = nls->end - *ne;
}
else /* no overlap allowed/needed */
nls->blendout= 0.0f;
nls->blendout = 0.0f;
}
/* Ensure that auto-blending and other settings are set correctly */
void BKE_nla_validate_state(AnimData *adt)
{
NlaStrip *strip, *fstrip=NULL;
NlaStrip *strip, *fstrip = NULL;
NlaTrack *nlt;
/* sanity checks */
@@ -1426,20 +1426,20 @@ void BKE_nla_validate_state(AnimData *adt)
return;
/* adjust blending values for auto-blending, and also do an initial pass to find the earliest strip */
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
for (strip= nlt->strips.first; strip; strip= strip->next) {
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* auto-blending first */
BKE_nlastrip_validate_autoblends(nlt, strip);
/* extend mode - find first strip */
if ((fstrip == NULL) || (strip->start < fstrip->start))
fstrip= strip;
fstrip = strip;
}
}
/* second pass over the strips to adjust the extend-mode to fix any problems */
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
for (strip= nlt->strips.first; strip; strip= strip->next) {
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
/* apart from 'nothing' option which user has to explicitly choose, we don't really know if
* we should be overwriting the extend setting (but assume that's what the user wanted)
*/
@@ -1454,9 +1454,9 @@ void BKE_nla_validate_state(AnimData *adt)
* Should fix problems such as [#29869]
*/
if (strip == fstrip)
strip->extendmode= NLASTRIP_EXTEND_HOLD;
strip->extendmode = NLASTRIP_EXTEND_HOLD;
else if (strip->blendmode == NLASTRIP_MODE_REPLACE)
strip->extendmode= NLASTRIP_EXTEND_HOLD_FORWARD;
strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD;
}
}
}
@@ -1489,13 +1489,13 @@ void BKE_nla_action_pushdown(AnimData *adt)
}
/* add a new NLA strip to the track, which references the active action */
strip= add_nlastrip_to_stack(adt, adt->action);
strip = add_nlastrip_to_stack(adt, adt->action);
/* do other necessary work on strip */
if (strip) {
/* clear reference to action now that we've pushed it onto the stack */
id_us_min(&adt->action->id);
adt->action= NULL;
adt->action = NULL;
/* if the strip is the first one in the track it lives in, check if there
* are strips in any other tracks that may be before this, and set the extend
@@ -1506,7 +1506,7 @@ void BKE_nla_action_pushdown(AnimData *adt)
* so that it doesn't override strips in previous tracks
*/
// FIXME: this needs to be more automated, since user can rearrange strips
strip->extendmode= NLASTRIP_EXTEND_HOLD_FORWARD;
strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD;
}
/* make strip the active one... */
@@ -1520,8 +1520,8 @@ void BKE_nla_action_pushdown(AnimData *adt)
*/
short BKE_nla_tweakmode_enter(AnimData *adt)
{
NlaTrack *nlt, *activeTrack=NULL;
NlaStrip *strip, *activeStrip=NULL;
NlaTrack *nlt, *activeTrack = NULL;
NlaStrip *strip, *activeStrip = NULL;
/* verify that data is valid */
if (ELEM(NULL, adt, adt->nla_tracks.first))
@@ -1536,14 +1536,14 @@ short BKE_nla_tweakmode_enter(AnimData *adt)
/* go over the tracks, finding the active one, and its active strip
* - if we cannot find both, then there's nothing to do
*/
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
/* check if active */
if (nlt->flag & NLATRACK_ACTIVE) {
/* store reference to this active track */
activeTrack= nlt;
activeTrack = nlt;
/* now try to find active strip */
activeStrip= BKE_nlastrip_find_active(nlt);
activeStrip = BKE_nlastrip_find_active(nlt);
break;
}
}
@@ -1557,18 +1557,18 @@ short BKE_nla_tweakmode_enter(AnimData *adt)
for (nlt = adt->nla_tracks.last; nlt; nlt = nlt->prev) {
if (nlt->flag & NLATRACK_SELECTED) {
/* assume this is the active track */
activeTrack= nlt;
activeTrack = nlt;
/* try to find active strip */
activeStrip= BKE_nlastrip_find_active(nlt);
activeStrip = BKE_nlastrip_find_active(nlt);
break;
}
}
}
if ((activeTrack) && (activeStrip == NULL)) {
/* no active strip in active or last selected track; compromise for first selected (assuming only single)... */
for (strip = activeTrack->strips.first; strip; strip= strip->next) {
if (strip->flag & (NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE)) {
for (strip = activeTrack->strips.first; strip; strip = strip->next) {
if (strip->flag & (NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE)) {
activeStrip = strip;
break;
}
@@ -1586,8 +1586,8 @@ short BKE_nla_tweakmode_enter(AnimData *adt)
/* go over all the tracks up to the active one, tagging each strip that uses the same
* action as the active strip, but leaving everything else alone
*/
for (nlt= activeTrack->prev; nlt; nlt= nlt->prev) {
for (strip= nlt->strips.first; strip; strip= strip->next) {
for (nlt = activeTrack->prev; nlt; nlt = nlt->prev) {
for (strip = nlt->strips.first; strip; strip = strip->next) {
if (strip->act == activeStrip->act)
strip->flag |= NLASTRIP_FLAG_TWEAKUSER;
else
@@ -1599,7 +1599,7 @@ short BKE_nla_tweakmode_enter(AnimData *adt)
/* go over all the tracks after AND INCLUDING the active one, tagging them as being disabled
* - the active track needs to also be tagged, otherwise, it'll overlap with the tweaks going on
*/
for (nlt= activeTrack; nlt; nlt= nlt->next)
for (nlt = activeTrack; nlt; nlt = nlt->next)
nlt->flag |= NLATRACK_DISABLED;
/* handle AnimData level changes:
@@ -1608,9 +1608,9 @@ short BKE_nla_tweakmode_enter(AnimData *adt)
* - editing-flag for this AnimData block should also get turned on (for more efficient restoring)
* - take note of the active strip for mapping-correction of keyframes in the action being edited
*/
adt->tmpact= adt->action;
adt->action= activeStrip->act;
adt->actstrip= activeStrip;
adt->tmpact = adt->action;
adt->action = activeStrip->act;
adt->actstrip = activeStrip;
id_us_plus(&activeStrip->act->id);
adt->flag |= ADT_NLA_EDIT_ON;
@@ -1637,10 +1637,10 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
/* for all Tracks, clear the 'disabled' flag
* for all Strips, clear the 'tweak-user' flag
*/
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) {
for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
nlt->flag &= ~NLATRACK_DISABLED;
for (strip= nlt->strips.first; strip; strip= strip->next)
for (strip = nlt->strips.first; strip; strip = strip->next)
strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER;
}
@@ -1652,15 +1652,15 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
* - clear pointer to active strip
*/
if (adt->action) adt->action->id.us--;
adt->action= adt->tmpact;
adt->tmpact= NULL;
adt->actstrip= NULL;
adt->action = adt->tmpact;
adt->tmpact = NULL;
adt->actstrip = NULL;
adt->flag &= ~ADT_NLA_EDIT_ON;
}
/* Baking Tools ------------------------------------------- */
static void UNUSED_FUNCTION(BKE_nla_bake) (Scene *scene, ID *UNUSED(id), AnimData *adt, int UNUSED(flag))
static void UNUSED_FUNCTION(BKE_nla_bake) (Scene * scene, ID *UNUSED(id), AnimData * adt, int UNUSED(flag))
{
/* verify that data is valid

View File

@@ -63,9 +63,9 @@ void BKE_reports_init(ReportList *reports, int flag)
memset(reports, 0, sizeof(ReportList));
reports->storelevel= RPT_INFO;
reports->printlevel= RPT_ERROR;
reports->flag= flag;
reports->storelevel = RPT_INFO;
reports->printlevel = RPT_ERROR;
reports->flag = flag;
}
void BKE_reports_clear(ReportList *reports)
@@ -75,16 +75,16 @@ void BKE_reports_clear(ReportList *reports)
if (!reports)
return;
report= reports->list.first;
report = reports->list.first;
while (report) {
report_next= report->next;
report_next = report->next;
MEM_freeN((void *)report->message);
MEM_freeN(report);
report= report_next;
report = report_next;
}
reports->list.first= reports->list.last= NULL;
reports->list.first = reports->list.last = NULL;
}
void BKE_report(ReportList *reports, ReportType type, const char *message)
@@ -101,15 +101,15 @@ void BKE_report(ReportList *reports, ReportType type, const char *message)
if (reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
char *message_alloc;
report= MEM_callocN(sizeof(Report), "Report");
report->type= type;
report->typestr= report_type_str(type);
report = MEM_callocN(sizeof(Report), "Report");
report->type = type;
report->typestr = report_type_str(type);
len= strlen(message);
message_alloc= MEM_callocN(sizeof(char)*(len+1), "ReportMessage");
memcpy(message_alloc, message, sizeof(char)*(len+1));
report->message= message_alloc;
report->len= len;
len = strlen(message);
message_alloc = MEM_callocN(sizeof(char) * (len + 1), "ReportMessage");
memcpy(message_alloc, message, sizeof(char) * (len + 1));
report->message = message_alloc;
report->len = len;
BLI_addtail(&reports->list, report);
}
}
@@ -129,19 +129,19 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
}
if (reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) {
report= MEM_callocN(sizeof(Report), "Report");
report = MEM_callocN(sizeof(Report), "Report");
ds= BLI_dynstr_new();
ds = BLI_dynstr_new();
va_start(args, format);
BLI_dynstr_vappendf(ds, format, args);
va_end(args);
report->message= BLI_dynstr_get_cstring(ds);
report->len= BLI_dynstr_get_len(ds);
report->message = BLI_dynstr_get_cstring(ds);
report->len = BLI_dynstr_get_len(ds);
BLI_dynstr_free(ds);
report->type= type;
report->typestr= report_type_str(type);
report->type = type;
report->typestr = report_type_str(type);
BLI_addtail(&reports->list, report);
}
@@ -155,15 +155,15 @@ void BKE_reports_prepend(ReportList *reports, const char *prepend)
if (!reports)
return;
for (report=reports->list.first; report; report=report->next) {
ds= BLI_dynstr_new();
for (report = reports->list.first; report; report = report->next) {
ds = BLI_dynstr_new();
BLI_dynstr_append(ds, prepend);
BLI_dynstr_append(ds, report->message);
MEM_freeN((void *)report->message);
report->message= BLI_dynstr_get_cstring(ds);
report->len= BLI_dynstr_get_len(ds);
report->message = BLI_dynstr_get_cstring(ds);
report->len = BLI_dynstr_get_len(ds);
BLI_dynstr_free(ds);
}
@@ -178,8 +178,8 @@ void BKE_reports_prependf(ReportList *reports, const char *prepend, ...)
if (!reports)
return;
for (report=reports->list.first; report; report=report->next) {
ds= BLI_dynstr_new();
for (report = reports->list.first; report; report = report->next) {
ds = BLI_dynstr_new();
va_start(args, prepend);
BLI_dynstr_vappendf(ds, prepend, args);
va_end(args);
@@ -187,8 +187,8 @@ void BKE_reports_prependf(ReportList *reports, const char *prepend, ...)
BLI_dynstr_append(ds, report->message);
MEM_freeN((void *)report->message);
report->message= BLI_dynstr_get_cstring(ds);
report->len= BLI_dynstr_get_len(ds);
report->message = BLI_dynstr_get_cstring(ds);
report->len = BLI_dynstr_get_len(ds);
BLI_dynstr_free(ds);
}
@@ -207,7 +207,7 @@ void BKE_report_print_level_set(ReportList *reports, ReportType level)
if (!reports)
return;
reports->printlevel= level;
reports->printlevel = level;
}
ReportType BKE_report_store_level(ReportList *reports)
@@ -223,7 +223,7 @@ void BKE_report_store_level_set(ReportList *reports, ReportType level)
if (!reports)
return;
reports->storelevel= level;
reports->storelevel = level;
}
char *BKE_reports_string(ReportList *reports, ReportType level)
@@ -235,15 +235,15 @@ char *BKE_reports_string(ReportList *reports, ReportType level)
if (!reports || !reports->list.first)
return NULL;
ds= BLI_dynstr_new();
for (report=reports->list.first; report; report=report->next)
ds = BLI_dynstr_new();
for (report = reports->list.first; report; report = report->next)
if (report->type >= level)
BLI_dynstr_appendf(ds, "%s: %s\n", report->typestr, report->message);
if (BLI_dynstr_get_len(ds))
cstring= BLI_dynstr_get_cstring(ds);
cstring = BLI_dynstr_get_cstring(ds);
else
cstring= NULL;
cstring = NULL;
BLI_dynstr_free(ds);
return cstring;
@@ -265,7 +265,7 @@ Report *BKE_reports_last_displayable(ReportList *reports)
{
Report *report;
for (report= reports->list.last; report; report=report->prev) {
for (report = reports->list.last; report; report = report->prev) {
if (ELEM3(report->type, RPT_ERROR, RPT_WARNING, RPT_INFO))
return report;
}
@@ -277,7 +277,7 @@ int BKE_reports_contain(ReportList *reports, ReportType level)
{
Report *report;
if (reports != NULL) {
for (report=reports->list.first; report; report=report->next)
for (report = reports->list.first; report; report = report->next)
if (report->type >= level)
return TRUE;
}

View File

@@ -55,7 +55,7 @@ void freeSketch(SK_Sketch *sketch)
MEM_freeN(sketch);
}
SK_Sketch* createSketch(void)
SK_Sketch *createSketch(void)
{
SK_Sketch *sketch;
@@ -101,7 +101,7 @@ void sk_freeStroke(SK_Stroke *stk)
MEM_freeN(stk);
}
SK_Stroke* sk_createStroke(void)
SK_Stroke *sk_createStroke(void)
{
SK_Stroke *stk;
@@ -261,13 +261,13 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end)
int i;
/* find first exact points outside of range */
for (;start > 0; start--) {
for (; start > 0; start--) {
if (stk->points[start].type == PT_EXACT) {
break;
}
}
for (;end < stk->nb_points - 1; end++) {
for (; end < stk->nb_points - 1; end++) {
if (stk->points[end].type == PT_EXACT) {
break;
}
@@ -382,7 +382,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
work = 0;
ls = start;
le = start+1;
le = start + 1;
/* while not over interval */
while (ls < end) {
@@ -400,7 +400,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
v1[0] = old_points[ls].p2d[1] - old_points[le].p2d[1];
for ( i = ls + 1; i < le; i++ ) {
for (i = ls + 1; i < le; i++) {
float mul;
float dist;
short v2[2];
@@ -412,9 +412,9 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
continue;
}
mul = (float)(v1[0]*v2[0] + v1[1]*v2[1]) / (float)(v2[0]*v2[0] + v2[1]*v2[1]);
mul = (float)(v1[0] * v2[0] + v1[1] * v2[1]) / (float)(v2[0] * v2[0] + v2[1] * v2[1]);
dist = mul * mul * (v2[0]*v2[0] + v2[1]*v2[1]);
dist = mul * mul * (v2[0] * v2[0] + v2[1] * v2[1]);
if (dist > max_dist) {
max_dist = dist;
@@ -457,7 +457,7 @@ void sk_filterLastContinuousStroke(SK_Stroke *stk)
{
int start, end;
end = stk->nb_points -1;
end = stk->nb_points - 1;
for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) {
/* nothing to do here*/

View File

@@ -50,8 +50,8 @@ static char *documentation = NULL;
static int txttl_cmp(const char *first, const char *second, int len)
{
int cmp, i;
for (cmp=0, i=0; i<len; i++) {
if ( (cmp= toupper(first[i])-toupper(second[i])) ) {
for (cmp = 0, i = 0; i < len; i++) {
if ( (cmp = toupper(first[i]) - toupper(second[i])) ) {
break;
}
}
@@ -61,7 +61,7 @@ static int txttl_cmp(const char *first, const char *second, int len)
static void txttl_free_suggest(void)
{
SuggItem *item, *prev;
for (item = suggestions.last; item; item=prev) {
for (item = suggestions.last; item; item = prev) {
prev = item->prev;
MEM_freeN(item);
}
@@ -104,7 +104,7 @@ void texttool_text_clear(void)
short texttool_text_is_active(Text *text)
{
return activeToolText==text ? 1 : 0;
return activeToolText == text ? 1 : 0;
}
/***************************/
@@ -135,7 +135,7 @@ void texttool_suggest_add(const char *name, char type)
}
else {
cmp = -1;
for (item=suggestions.last; item; item=item->prev) {
for (item = suggestions.last; item; item = item->prev) {
cmp = txttl_cmp(name, item->name, len);
/* Newitem comes after this item, insert here */
@@ -160,7 +160,7 @@ void texttool_suggest_add(const char *name, char type)
}
}
suggestions.firstmatch = suggestions.lastmatch = suggestions.selected = NULL;
suggestions.top= 0;
suggestions.top = 0;
}
void texttool_suggest_prefix(const char *prefix)
@@ -169,22 +169,22 @@ void texttool_suggest_prefix(const char *prefix)
int cmp, len = strlen(prefix), top = 0;
if (!suggestions.first) return;
if (len==0) {
if (len == 0) {
suggestions.selected = suggestions.firstmatch = suggestions.first;
suggestions.lastmatch = suggestions.last;
return;
}
first = last = NULL;
for (match=suggestions.first; match; match=match->next) {
for (match = suggestions.first; match; match = match->next) {
cmp = txttl_cmp(prefix, match->name, len);
if (cmp==0) {
if (cmp == 0) {
if (!first) {
first = match;
suggestions.top = top;
}
}
else if (cmp<0) {
else if (cmp < 0) {
if (!last) {
last = match->prev;
break;
@@ -254,13 +254,13 @@ void texttool_docs_show(const char *docs)
}
/* Ensure documentation ends with a '\n' */
if (docs[len-1] != '\n') {
documentation = MEM_mallocN(len+2, "Documentation");
if (docs[len - 1] != '\n') {
documentation = MEM_mallocN(len + 2, "Documentation");
strncpy(documentation, docs, len);
documentation[len++] = '\n';
}
else {
documentation = MEM_mallocN(len+1, "Documentation");
documentation = MEM_mallocN(len + 1, "Documentation");
strncpy(documentation, docs, len);
}
documentation[len] = '\0';

View File

@@ -73,9 +73,9 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
static bMovieHandle mh;
/* set the default handle, as builtin */
mh.start_movie= start_avi;
mh.append_movie= append_avi;
mh.end_movie= end_avi;
mh.start_movie = start_avi;
mh.append_movie = append_avi;
mh.end_movie = end_avi;
mh.get_next_frame = NULL;
mh.get_movie_path = filepath_avi;
@@ -89,9 +89,9 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
#endif
#ifdef WITH_QUICKTIME
if (imtype == R_IMF_IMTYPE_QUICKTIME) {
mh.start_movie= start_qt;
mh.append_movie= append_qt;
mh.end_movie= end_qt;
mh.start_movie = start_qt;
mh.append_movie = append_qt;
mh.end_movie = end_qt;
mh.get_movie_path = filepath_qt;
}
#endif
@@ -121,11 +121,11 @@ bMovieHandle *BKE_movie_handle_get(const char imtype)
/* ****************************************************************** */
static AviMovie *avi=NULL;
static AviMovie *avi = NULL;
static void filepath_avi (char *string, RenderData *rd)
static void filepath_avi(char *string, RenderData *rd)
{
if (string==NULL) return;
if (string == NULL) return;
strcpy(string, rd->pic);
BLI_path_abs(string, G.main->name);
@@ -153,28 +153,28 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL
x = rectx;
y = recty;
quality= rd->im_format.quality;
framerate= (double) rd->frs_sec / (double) rd->frs_sec_base;
quality = rd->im_format.quality;
framerate = (double) rd->frs_sec / (double) rd->frs_sec_base;
avi = MEM_mallocN (sizeof(AviMovie), "avimovie");
avi = MEM_mallocN(sizeof(AviMovie), "avimovie");
if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG ) format = AVI_FORMAT_AVI_RGB;
if (rd->im_format.imtype != R_IMF_IMTYPE_AVIJPEG) format = AVI_FORMAT_AVI_RGB;
else format = AVI_FORMAT_MJPEG;
if (AVI_open_compress (name, avi, 1, format) != AVI_ERROR_NONE) {
if (AVI_open_compress(name, avi, 1, format) != AVI_ERROR_NONE) {
BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file.");
MEM_freeN (avi);
MEM_freeN(avi);
avi = NULL;
return 0;
}
AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x);
AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_HEIGHT, &y);
AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_QUALITY, &quality);
AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_FRAMERATE, &framerate);
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x);
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_HEIGHT, &y);
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_QUALITY, &quality);
AVI_set_compress_option(avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_FRAMERATE, &framerate);
avi->interlace= 0;
avi->odd_fields= 0;
avi->interlace = 0;
avi->odd_fields = 0;
/* avi->interlace= rd->mode & R_FIELDS; */
/* avi->odd_fields= (rd->mode & R_ODDFIELD)?1:0; */
@@ -193,26 +193,26 @@ static int append_avi(RenderData *UNUSED(rd), int start_frame, int frame, int *p
return 0;
/* note that libavi free's the buffer... stupid interface - zr */
rectot= MEM_mallocN(rectx*recty*sizeof(int), "rectot");
rt1= rectot;
rt2= (unsigned int*)pixels + (recty-1)*rectx;
rectot = MEM_mallocN(rectx * recty * sizeof(int), "rectot");
rt1 = rectot;
rt2 = (unsigned int *)pixels + (recty - 1) * rectx;
/* flip y and convert to abgr */
for (y=0; y < recty; y++, rt1+= rectx, rt2-= rectx) {
memcpy (rt1, rt2, rectx*sizeof(int));
for (y = 0; y < recty; y++, rt1 += rectx, rt2 -= rectx) {
memcpy(rt1, rt2, rectx * sizeof(int));
cp= (char *)rt1;
for (x= rectx; x>0; x--) {
rt= cp[0];
cp[0]= cp[3];
cp[3]= rt;
rt= cp[1];
cp[1]= cp[2];
cp[2]= rt;
cp+= 4;
cp = (char *)rt1;
for (x = rectx; x > 0; x--) {
rt = cp[0];
cp[0] = cp[3];
cp[3] = rt;
rt = cp[1];
cp[1] = cp[2];
cp[2] = rt;
cp += 4;
}
}
AVI_write_frame (avi, (frame-start_frame), AVI_FORMAT_RGB32, rectot, rectx*recty*4);
AVI_write_frame(avi, (frame - start_frame), AVI_FORMAT_RGB32, rectot, rectx * recty * 4);
// printf ("added frame %3d (frame %3d in avi): ", frame, frame-start_frame);
return 1;
@@ -222,17 +222,17 @@ static void end_avi(void)
{
if (avi == NULL) return;
AVI_close_compress (avi);
MEM_freeN (avi);
avi= NULL;
AVI_close_compress(avi);
MEM_freeN(avi);
avi = NULL;
}
/* similar to BKE_makepicstring() */
void BKE_movie_filepath_get(char *string, RenderData *rd)
{
bMovieHandle *mh= BKE_movie_handle_get(rd->im_format.imtype);
bMovieHandle *mh = BKE_movie_handle_get(rd->im_format.imtype);
if (mh->get_movie_path)
mh->get_movie_path(string, rd);
else
string[0]= '\0';
string[0] = '\0';
}

View File

@@ -80,30 +80,30 @@ static int ffmpeg_gop_size = 12;
static int ffmpeg_autosplit = 0;
static int ffmpeg_autosplit_count = 0;
static AVFormatContext* outfile = 0;
static AVStream* video_stream = 0;
static AVStream* audio_stream = 0;
static AVFrame* current_frame = 0;
static AVFormatContext *outfile = 0;
static AVStream *video_stream = 0;
static AVStream *audio_stream = 0;
static AVFrame *current_frame = 0;
static struct SwsContext *img_convert_ctx = 0;
static uint8_t* video_buffer = 0;
static uint8_t *video_buffer = 0;
static int video_buffersize = 0;
static uint8_t* audio_input_buffer = 0;
static uint8_t *audio_input_buffer = 0;
static int audio_input_samples = 0;
static uint8_t* audio_output_buffer = 0;
static uint8_t *audio_output_buffer = 0;
static int audio_outbuf_size = 0;
static double audio_time = 0.0f;
#ifdef WITH_AUDASPACE
static AUD_Device* audio_mixdown_device = 0;
static AUD_Device *audio_mixdown_device = 0;
#endif
#define FFMPEG_AUTOSPLIT_SIZE 2000000000
/* Delete a picture buffer */
static void delete_picture(AVFrame* f)
static void delete_picture(AVFrame *f)
{
if (f) {
if (f->data[0]) MEM_freeN(f->data[0]);
@@ -114,7 +114,7 @@ static void delete_picture(AVFrame* f)
#ifdef WITH_AUDASPACE
static int write_audio_frame(void)
{
AVCodecContext* c = NULL;
AVCodecContext *c = NULL;
AVPacket pkt;
c = audio_stream->codec;
@@ -155,10 +155,10 @@ static int write_audio_frame(void)
#endif // #ifdef WITH_AUDASPACE
/* Allocate a temporary frame */
static AVFrame* alloc_picture(int pix_fmt, int width, int height)
static AVFrame *alloc_picture(int pix_fmt, int width, int height)
{
AVFrame* f;
uint8_t* buf;
AVFrame *f;
uint8_t *buf;
int size;
/* allocate space for the struct */
@@ -171,69 +171,69 @@ static AVFrame* alloc_picture(int pix_fmt, int width, int height)
free(f);
return NULL;
}
avpicture_fill((AVPicture*)f, buf, pix_fmt, width, height);
avpicture_fill((AVPicture *)f, buf, pix_fmt, width, height);
return f;
}
/* Get the correct file extensions for the requested format,
* first is always desired guess_format parameter */
static const char** get_file_extensions(int format)
static const char **get_file_extensions(int format)
{
switch (format) {
case FFMPEG_DV: {
static const char * rv[] = { ".dv", NULL };
static const char *rv[] = { ".dv", NULL };
return rv;
}
case FFMPEG_MPEG1: {
static const char * rv[] = { ".mpg", ".mpeg", NULL };
static const char *rv[] = { ".mpg", ".mpeg", NULL };
return rv;
}
case FFMPEG_MPEG2: {
static const char * rv[] = { ".dvd", ".vob", ".mpg", ".mpeg",
static const char *rv[] = { ".dvd", ".vob", ".mpg", ".mpeg",
NULL };
return rv;
}
case FFMPEG_MPEG4: {
static const char * rv[] = { ".mp4", ".mpg", ".mpeg", NULL };
static const char *rv[] = { ".mp4", ".mpg", ".mpeg", NULL };
return rv;
}
case FFMPEG_AVI: {
static const char * rv[] = { ".avi", NULL };
static const char *rv[] = { ".avi", NULL };
return rv;
}
case FFMPEG_MOV: {
static const char * rv[] = { ".mov", NULL };
static const char *rv[] = { ".mov", NULL };
return rv;
}
case FFMPEG_H264: {
/* FIXME: avi for now... */
static const char * rv[] = { ".avi", NULL };
static const char *rv[] = { ".avi", NULL };
return rv;
}
case FFMPEG_XVID: {
/* FIXME: avi for now... */
static const char * rv[] = { ".avi", NULL };
static const char *rv[] = { ".avi", NULL };
return rv;
}
case FFMPEG_FLV: {
static const char * rv[] = { ".flv", NULL };
static const char *rv[] = { ".flv", NULL };
return rv;
}
case FFMPEG_MKV: {
static const char * rv[] = { ".mkv", NULL };
static const char *rv[] = { ".mkv", NULL };
return rv;
}
case FFMPEG_OGG: {
static const char * rv[] = { ".ogg", ".ogv", NULL };
static const char *rv[] = { ".ogg", ".ogv", NULL };
return rv;
}
case FFMPEG_MP3: {
static const char * rv[] = { ".mp3", NULL };
static const char *rv[] = { ".mp3", NULL };
return rv;
}
case FFMPEG_WAV: {
static const char * rv[] = { ".wav", NULL };
static const char *rv[] = { ".wav", NULL };
return rv;
}
default:
@@ -242,11 +242,11 @@ static const char** get_file_extensions(int format)
}
/* Write a frame to the output file */
static int write_video_frame(RenderData *rd, int cfra, AVFrame* frame, ReportList *reports)
static int write_video_frame(RenderData *rd, int cfra, AVFrame *frame, ReportList *reports)
{
int outsize = 0;
int ret, success= 1;
AVCodecContext* c = video_stream->codec;
int ret, success = 1;
AVCodecContext *c = video_stream->codec;
frame->pts = cfra;
@@ -289,14 +289,14 @@ static int write_video_frame(RenderData *rd, int cfra, AVFrame* frame, ReportLis
}
/* read and encode a frame of audio from the buffer */
static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
static AVFrame *generate_video_frame(uint8_t *pixels, ReportList *reports)
{
uint8_t* rendered_frame;
uint8_t *rendered_frame;
AVCodecContext* c = video_stream->codec;
AVCodecContext *c = video_stream->codec;
int width = c->width;
int height = c->height;
AVFrame* rgb_frame;
AVFrame *rgb_frame;
if (c->pix_fmt != PIX_FMT_BGR32) {
rgb_frame = alloc_picture(PIX_FMT_BGR32, width, height);
@@ -317,9 +317,9 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
if (ENDIAN_ORDER == L_ENDIAN) {
int y;
for (y = 0; y < height; y++) {
uint8_t* target = rgb_frame->data[0] + width * 4 * (height - y - 1);
uint8_t* src = rendered_frame + width * 4 * y;
uint8_t* end = src + width * 4;
uint8_t *target = rgb_frame->data[0] + width * 4 * (height - y - 1);
uint8_t *src = rendered_frame + width * 4 * y;
uint8_t *end = src + width * 4;
while (src != end) {
target[3] = src[3];
target[2] = src[2];
@@ -334,9 +334,9 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
else {
int y;
for (y = 0; y < height; y++) {
uint8_t* target = rgb_frame->data[0] + width * 4 * (height - y - 1);
uint8_t* src = rendered_frame + width * 4 * y;
uint8_t* end = src + width * 4;
uint8_t *target = rgb_frame->data[0] + width * 4 * (height - y - 1);
uint8_t *src = rendered_frame + width * 4 * y;
uint8_t *end = src + width * 4;
while (src != end) {
target[3] = src[0];
target[2] = src[1];
@@ -350,7 +350,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
}
if (c->pix_fmt != PIX_FMT_BGR32) {
sws_scale(img_convert_ctx, (const uint8_t * const*) rgb_frame->data,
sws_scale(img_convert_ctx, (const uint8_t *const *) rgb_frame->data,
rgb_frame->linesize, 0, c->height,
current_frame->data, current_frame->linesize);
delete_picture(rgb_frame);
@@ -358,11 +358,11 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
return current_frame;
}
static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
static void set_ffmpeg_property_option(AVCodecContext *c, IDProperty *prop)
{
char name[128];
char * param;
const AVOption * rv = NULL;
char *param;
const AVOption *rv = NULL;
fprintf(stderr, "FFMPEG expert option: %s: ", prop->name);
@@ -408,23 +408,23 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
static int ffmpeg_proprty_valid(AVCodecContext *c, const char *prop_name, IDProperty *curr)
{
int valid= 1;
int valid = 1;
if (strcmp(prop_name, "video")==0) {
if (strcmp(curr->name, "bf")==0) {
if (strcmp(prop_name, "video") == 0) {
if (strcmp(curr->name, "bf") == 0) {
/* flash codec doesn't support b frames */
valid&= c->codec_id!=CODEC_ID_FLV1;
valid &= c->codec_id != CODEC_ID_FLV1;
}
}
return valid;
}
static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char * prop_name)
static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char *prop_name)
{
IDProperty * prop;
void * iter;
IDProperty * curr;
IDProperty *prop;
void *iter;
IDProperty *curr;
if (!rd->ffcodecdata.properties) {
return;
@@ -445,12 +445,12 @@ static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char
/* prepare a video stream for the output file */
static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContext* of,
static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContext *of,
int rectx, int recty)
{
AVStream* st;
AVCodecContext* c;
AVCodec* codec;
AVStream *st;
AVCodecContext *c;
AVCodec *codec;
st = av_new_stream(of, 0);
if (!st) return NULL;
@@ -482,9 +482,9 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
}
c->gop_size = ffmpeg_gop_size;
c->bit_rate = ffmpeg_video_bitrate*1000;
c->rc_max_rate = rd->ffcodecdata.rc_max_rate*1000;
c->rc_min_rate = rd->ffcodecdata.rc_min_rate*1000;
c->bit_rate = ffmpeg_video_bitrate * 1000;
c->rc_max_rate = rd->ffcodecdata.rc_max_rate * 1000;
c->rc_min_rate = rd->ffcodecdata.rc_min_rate * 1000;
c->rc_buffer_size = rd->ffcodecdata.rc_buffer_size * 1024;
c->rc_initial_buffer_occupancy = rd->ffcodecdata.rc_buffer_size * 3 / 4;
c->rc_buffer_aggressivity = 1.0;
@@ -506,13 +506,13 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
if (ffmpeg_type == FFMPEG_XVID) {
/* arghhhh ... */
c->pix_fmt = PIX_FMT_YUV420P;
c->codec_tag = (('D'<<24) + ('I'<<16) + ('V'<<8) + 'X');
c->codec_tag = (('D' << 24) + ('I' << 16) + ('V' << 8) + 'X');
}
if (codec_id == CODEC_ID_H264) {
/* correct wrong default ffmpeg param which crash x264 */
c->qmin=10;
c->qmax=51;
c->qmin = 10;
c->qmax = 51;
}
// Keep lossless encodes in the RGB domain.
@@ -534,7 +534,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
#endif
}
if (codec_id == CODEC_ID_QTRLE ) {
if (codec_id == CODEC_ID_QTRLE) {
if (rd->im_format.planes == R_IMF_PLANES_RGBA) {
c->pix_fmt = PIX_FMT_ARGB;
}
@@ -569,7 +569,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
return NULL;
}
if ( codec_id == CODEC_ID_QTRLE ) {
if (codec_id == CODEC_ID_QTRLE) {
// normally it should be enough to have buffer with actual image size,
// but some codecs like QTRLE might store extra information in this buffer,
// so it should be a way larger
@@ -577,12 +577,12 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
// maximum video buffer size is 6-bytes per pixel, plus DPX header size (1664)
// (from FFmpeg sources)
int size = c->width * c->height;
video_buffersize = 7*size + 10000;
video_buffersize = 7 * size + 10000;
}
else
video_buffersize = avpicture_get_size(c->pix_fmt, c->width, c->height);
video_buffer = (uint8_t*)MEM_mallocN(video_buffersize*sizeof(uint8_t),
video_buffer = (uint8_t *)MEM_mallocN(video_buffersize * sizeof(uint8_t),
"FFMPEG video buffer");
current_frame = alloc_picture(c->pix_fmt, c->width, c->height);
@@ -598,11 +598,11 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
/* Prepare an audio stream for the output file */
static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContext* of)
static AVStream *alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContext *of)
{
AVStream* st;
AVCodecContext* c;
AVCodec* codec;
AVStream *st;
AVCodecContext *c;
AVCodec *codec;
st = av_new_stream(of, 1);
if (!st) return NULL;
@@ -612,7 +612,7 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
c->codec_type = AVMEDIA_TYPE_AUDIO;
c->sample_rate = rd->ffcodecdata.audio_mixrate;
c->bit_rate = ffmpeg_audio_bitrate*1000;
c->bit_rate = ffmpeg_audio_bitrate * 1000;
c->sample_fmt = SAMPLE_FMT_S16;
c->channels = rd->ffcodecdata.audio_channels;
codec = avcodec_find_encoder(c->codec_id);
@@ -630,8 +630,8 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
/* need to prevent floating point exception when using vorbis audio codec,
* initialize this value in the same way as it's done in FFmpeg iteslf (sergey) */
st->codec->time_base.num= 1;
st->codec->time_base.den= st->codec->sample_rate;
st->codec->time_base.num = 1;
st->codec->time_base.den = st->codec->sample_rate;
audio_outbuf_size = FF_MIN_BUFFER_SIZE;
@@ -643,10 +643,10 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
audio_outbuf_size = c->frame_size * c->channels * sizeof(int16_t) * 4;
}
audio_output_buffer = (uint8_t*)av_malloc(
audio_output_buffer = (uint8_t *)av_malloc(
audio_outbuf_size);
audio_input_buffer = (uint8_t*)av_malloc(
audio_input_buffer = (uint8_t *)av_malloc(
audio_input_samples * c->channels * sizeof(int16_t));
audio_time = 0.0f;
@@ -658,10 +658,10 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, ReportList *reports)
{
/* Handle to the output file */
AVFormatContext* of;
AVOutputFormat* fmt;
AVFormatContext *of;
AVOutputFormat *fmt;
char name[256];
const char ** exts;
const char **exts;
ffmpeg_type = rd->ffcodecdata.type;
ffmpeg_codec = rd->ffcodecdata.codec;
@@ -703,7 +703,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
}
of->oformat = fmt;
of->packet_size= rd->ffcodecdata.mux_packet_size;
of->packet_size = rd->ffcodecdata.mux_packet_size;
if (ffmpeg_audio_codec != CODEC_ID_NONE) {
of->mux_rate = rd->ffcodecdata.mux_rate;
}
@@ -711,8 +711,8 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
of->mux_rate = 0;
}
of->preload = (int)(0.5*AV_TIME_BASE);
of->max_delay = (int)(0.7*AV_TIME_BASE);
of->preload = (int)(0.5 * AV_TIME_BASE);
of->max_delay = (int)(0.7 * AV_TIME_BASE);
fmt->audio_codec = ffmpeg_audio_codec;
@@ -838,7 +838,7 @@ void flush_ffmpeg(void)
int outsize = 0;
int ret = 0;
AVCodecContext* c = video_stream->codec;
AVCodecContext *c = video_stream->codec;
/* get the delayed frames */
while (1) {
AVPacket packet;
@@ -881,12 +881,12 @@ void flush_ffmpeg(void)
* ********************************************************************** */
/* Get the output filename-- similar to the other output formats */
void BKE_ffmpeg_filepath_get(char* string, RenderData* rd)
void BKE_ffmpeg_filepath_get(char *string, RenderData *rd)
{
char autosplit[20];
const char ** exts = get_file_extensions(rd->ffcodecdata.type);
const char ** fe = exts;
const char **exts = get_file_extensions(rd->ffcodecdata.type);
const char **fe = exts;
if (!string || !exts) return;
@@ -931,7 +931,7 @@ int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty,
success = start_ffmpeg_impl(rd, rectx, recty, reports);
#ifdef WITH_AUDASPACE
if (audio_stream) {
AVCodecContext* c = audio_stream->codec;
AVCodecContext *c = audio_stream->codec;
AUD_DeviceSpecs specs;
specs.channels = c->channels;
specs.format = AUD_FORMAT_S16;
@@ -964,7 +964,7 @@ static void write_audio_frames(double to_pts)
int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, ReportList *reports)
{
AVFrame* avframe;
AVFrame *avframe;
int success = 1;
fprintf(stderr, "Writing frame %i, "
@@ -975,8 +975,8 @@ int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, i
// write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base));
if (video_stream) {
avframe= generate_video_frame((unsigned char*) pixels, reports);
success= (avframe && write_video_frame(rd, frame - start_frame, avframe, reports));
avframe = generate_video_frame((unsigned char *) pixels, reports);
success = (avframe && write_video_frame(rd, frame - start_frame, avframe, reports));
if (ffmpeg_autosplit) {
if (avio_tell(outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) {
@@ -1012,7 +1012,7 @@ void BKE_ffmpeg_end(void)
if (video_stream && video_stream->codec) {
fprintf(stderr, "Flushing delayed frames...\n");
flush_ffmpeg ();
flush_ffmpeg();
}
if (outfile) {
@@ -1074,7 +1074,7 @@ void BKE_ffmpeg_end(void)
void BKE_ffmpeg_property_del(RenderData *rd, void *type, void *prop_)
{
struct IDProperty *prop = (struct IDProperty *) prop_;
IDProperty * group;
IDProperty *group;
if (!rd->ffcodecdata.properties) {
return;
@@ -1091,10 +1091,10 @@ void BKE_ffmpeg_property_del(RenderData *rd, void *type, void *prop_)
IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, int parent_index)
{
AVCodecContext c;
const AVOption * o;
const AVOption * parent;
IDProperty * group;
IDProperty * prop;
const AVOption *o;
const AVOption *parent;
IDProperty *group;
IDProperty *prop;
IDPropertyTemplate val;
int idp_type;
char name[256];
@@ -1166,10 +1166,10 @@ IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, int opt_in
static const AVOption *my_av_find_opt(void *v, const char *name,
const char *unit, int mask, int flags)
{
AVClass *c= *(AVClass**)v;
const AVOption *o= c->option;
AVClass *c = *(AVClass **)v;
const AVOption *o = c->option;
for (;o && o->name; o++) {
for (; o && o->name; o++) {
if (!strcmp(o->name, name) &&
(!unit || (o->unit && !strcmp(o->unit, unit))) &&
(o->flags & mask) == flags)
@@ -1180,15 +1180,15 @@ static const AVOption *my_av_find_opt(void *v, const char *name,
return NULL;
}
int BKE_ffmpeg_property_add_string(RenderData *rd, const char * type, const char * str)
int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char *str)
{
AVCodecContext c;
const AVOption * o = 0;
const AVOption * p = 0;
const AVOption *o = 0;
const AVOption *p = 0;
char name_[128];
char * name;
char * param;
IDProperty * prop;
char *name;
char *param;
IDProperty *prop;
avcodec_get_context_defaults(&c);
@@ -1217,12 +1217,12 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char * type, const char
if (param && o->type != FF_OPT_TYPE_CONST && o->unit) {
p = my_av_find_opt(&c, param, o->unit, 0, 0);
prop = BKE_ffmpeg_property_add(rd,
(char*) type, p - c.av_class->option,
(char *) type, p - c.av_class->option,
o - c.av_class->option);
}
else {
prop = BKE_ffmpeg_property_add(rd,
(char*) type, o - c.av_class->option, 0);
(char *) type, o - c.av_class->option, 0);
}
@@ -1320,7 +1320,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset)
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
rd->ffcodecdata.rc_max_rate = 1150;
rd->ffcodecdata.rc_min_rate = 1150;
rd->ffcodecdata.rc_buffer_size = 40*8;
rd->ffcodecdata.rc_buffer_size = 40 * 8;
rd->ffcodecdata.mux_packet_size = 2324;
rd->ffcodecdata.mux_rate = 2352 * 75 * 8;
break;
@@ -1333,7 +1333,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset)
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
rd->ffcodecdata.rc_max_rate = 2516;
rd->ffcodecdata.rc_min_rate = 0;
rd->ffcodecdata.rc_buffer_size = 224*8;
rd->ffcodecdata.rc_buffer_size = 224 * 8;
rd->ffcodecdata.mux_packet_size = 2324;
rd->ffcodecdata.mux_rate = 0;
break;
@@ -1349,7 +1349,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset)
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
rd->ffcodecdata.rc_max_rate = 9000;
rd->ffcodecdata.rc_min_rate = 0;
rd->ffcodecdata.rc_buffer_size = 224*8;
rd->ffcodecdata.rc_buffer_size = 224 * 8;
rd->ffcodecdata.mux_packet_size = 2048;
rd->ffcodecdata.mux_rate = 10080000;
break;
@@ -1367,7 +1367,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset)
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
rd->ffcodecdata.rc_max_rate = 9000;
rd->ffcodecdata.rc_min_rate = 0;
rd->ffcodecdata.rc_buffer_size = 224*8;
rd->ffcodecdata.rc_buffer_size = 224 * 8;
rd->ffcodecdata.mux_packet_size = 2048;
rd->ffcodecdata.mux_rate = 10080000;
@@ -1388,7 +1388,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset)
rd->ffcodecdata.gop_size = isntsc ? 18 : 15;
rd->ffcodecdata.rc_max_rate = 9000;
rd->ffcodecdata.rc_min_rate = 0;
rd->ffcodecdata.rc_buffer_size = 224*8;
rd->ffcodecdata.rc_buffer_size = 224 * 8;
rd->ffcodecdata.mux_packet_size = 2048;
rd->ffcodecdata.mux_rate = 10080000;
break;
@@ -1400,7 +1400,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset)
void BKE_ffmpeg_image_type_verify(RenderData *rd, ImageFormatData *imf)
{
int audio= 0;
int audio = 0;
if (imf->imtype == R_IMF_IMTYPE_FFMPEG) {
if (rd->ffcodecdata.type <= 0 ||
@@ -1416,24 +1416,24 @@ void BKE_ffmpeg_image_type_verify(RenderData *rd, ImageFormatData *imf)
rd->ffcodecdata.type = FFMPEG_MPEG2;
}
audio= 1;
audio = 1;
}
else if (imf->imtype == R_IMF_IMTYPE_H264) {
if (rd->ffcodecdata.codec != CODEC_ID_H264) {
BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_H264);
audio= 1;
audio = 1;
}
}
else if (imf->imtype == R_IMF_IMTYPE_XVID) {
if (rd->ffcodecdata.codec != CODEC_ID_MPEG4) {
BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_XVID);
audio= 1;
audio = 1;
}
}
else if (imf->imtype == R_IMF_IMTYPE_THEORA) {
if (rd->ffcodecdata.codec != CODEC_ID_THEORA) {
BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_THEORA);
audio= 1;
audio = 1;
}
}

View File

@@ -83,11 +83,11 @@
#define kTrackStart 0
#define kMediaStart 0
static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, int recty, struct ReportList *reports);
static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int recty, struct ReportList *reports);
static void QT_EndAddVideoSamplesToMedia (void);
static void QT_CreateMyVideoTrack (int rectx, int recty, struct ReportList *reports);
static void QT_EndCreateMyVideoTrack (struct ReportList *reports);
static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, int recty, struct ReportList *reports);
static void QT_DoAddVideoSamplesToMedia(int frame, int *pixels, int rectx, int recty, struct ReportList *reports);
static void QT_EndAddVideoSamplesToMedia(void);
static void QT_CreateMyVideoTrack(int rectx, int recty, struct ReportList *reports);
static void QT_EndCreateMyVideoTrack(struct ReportList *reports);
static void check_renderbutton_framerate(struct RenderData *rd, struct ReportList *reports);
static int get_qtcodec_settings(struct RenderData *rd, struct ReportList *reports);
@@ -141,7 +141,8 @@ static QuicktimeCodecTypeDesc qtVideoCodecList[] = {
{kMPEG4VisualCodecType, 10, "MPEG4"},
{kH263CodecType, 11, "H.263"},
{kH264CodecType, 12, "H.264"},
{0, 0, NULL}};
{0, 0, NULL}
};
static int qtVideoCodecCount = 12;
@@ -150,9 +151,9 @@ int quicktime_get_num_videocodecs()
return qtVideoCodecCount;
}
QuicktimeCodecTypeDesc* quicktime_get_videocodecType_desc(int indexValue)
QuicktimeCodecTypeDesc *quicktime_get_videocodecType_desc(int indexValue)
{
if ((indexValue>=0) && (indexValue < qtVideoCodecCount))
if ((indexValue >= 0) && (indexValue < qtVideoCodecCount))
return &qtVideoCodecList[indexValue];
else
return NULL;
@@ -161,7 +162,7 @@ QuicktimeCodecTypeDesc* quicktime_get_videocodecType_desc(int indexValue)
int quicktime_rnatmpvalue_from_videocodectype(int codecType)
{
int i;
for (i=0;i<qtVideoCodecCount;i++) {
for (i = 0; i < qtVideoCodecCount; i++) {
if (qtVideoCodecList[i].codecType == codecType)
return qtVideoCodecList[i].rnatmpvalue;
}
@@ -172,7 +173,7 @@ int quicktime_rnatmpvalue_from_videocodectype(int codecType)
int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue)
{
int i;
for (i=0;i<qtVideoCodecCount;i++) {
for (i = 0; i < qtVideoCodecCount; i++) {
if (qtVideoCodecList[i].rnatmpvalue == rnatmpvalue)
return qtVideoCodecList[i].codecType;
}
@@ -234,7 +235,7 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports)
memcpy(qcd->cdParms, myPtr, mySize);
qcd->cdSize = mySize;
GetCodecInfo (&ci, qtdata->gSpatialSettings.codecType, 0);
GetCodecInfo(&ci, qtdata->gSpatialSettings.codecType, 0);
}
else {
BKE_reportf(reports, RPT_ERROR, "Quicktime: QT_SaveCodecSettingsToScene failed\n");
@@ -304,7 +305,7 @@ bail:
}
static OSErr QT_AddUserDataTextToMovie (Movie theMovie, char *theText, OSType theType)
static OSErr QT_AddUserDataTextToMovie(Movie theMovie, char *theText, OSType theType)
{
UserData myUserData = NULL;
Handle myHandle = NULL;
@@ -343,7 +344,7 @@ static void QT_CreateMyVideoTrack(int rectx, int recty, ReportList *reports)
trackFrame.bottom = recty;
trackFrame.right = rectx;
qtexport->theTrack = NewMovieTrack (qtexport->theMovie,
qtexport->theTrack = NewMovieTrack(qtexport->theMovie,
FixRatio(trackFrame.right, 1),
FixRatio(trackFrame.bottom, 1),
0);
@@ -354,17 +355,17 @@ static void QT_CreateMyVideoTrack(int rectx, int recty, ReportList *reports)
// TranslateMatrix(&myMatrix, 0, Long2Fix(trackFrame.bottom));
// SetMovieMatrix(qtexport->theMovie, &myMatrix);
qtexport->theMedia = NewTrackMedia (qtexport->theTrack,
qtexport->theMedia = NewTrackMedia(qtexport->theTrack,
VideoMediaType,
qtdata->kVideoTimeScale,
nil,
0);
CheckError(GetMoviesError(), "NewTrackMedia error", reports);
err = BeginMediaEdits (qtexport->theMedia);
err = BeginMediaEdits(qtexport->theMedia);
CheckError(err, "BeginMediaEdits error", reports);
QT_StartAddVideoSamplesToMedia (&trackFrame, rectx, recty, reports);
QT_StartAddVideoSamplesToMedia(&trackFrame, rectx, recty, reports);
}
@@ -372,40 +373,40 @@ static void QT_EndCreateMyVideoTrack(ReportList *reports)
{
OSErr err = noErr;
QT_EndAddVideoSamplesToMedia ();
QT_EndAddVideoSamplesToMedia();
err = EndMediaEdits (qtexport->theMedia);
err = EndMediaEdits(qtexport->theMedia);
CheckError(err, "EndMediaEdits error", reports);
err = InsertMediaIntoTrack (qtexport->theTrack,
err = InsertMediaIntoTrack(qtexport->theTrack,
kTrackStart, /* track start time */
kMediaStart, /* media start time */
GetMediaDuration (qtexport->theMedia),
GetMediaDuration(qtexport->theMedia),
fixed1);
CheckError(err, "InsertMediaIntoTrack error", reports);
}
static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, int recty, ReportList *reports)
static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, int recty, ReportList *reports)
{
SCTemporalSettings gTemporalSettings;
OSErr err = noErr;
qtexport->ibuf = IMB_allocImBuf (rectx, recty, 32, IB_rect);
qtexport->ibuf2 = IMB_allocImBuf (rectx, recty, 32, IB_rect);
qtexport->ibuf = IMB_allocImBuf(rectx, recty, 32, IB_rect);
qtexport->ibuf2 = IMB_allocImBuf(rectx, recty, 32, IB_rect);
err = NewGWorldFromPtr( &qtexport->theGWorld,
err = NewGWorldFromPtr(&qtexport->theGWorld,
k32ARGBPixelFormat,
trackFrame,
NULL, NULL, 0,
(Ptr)qtexport->ibuf->rect,
rectx * 4 );
CheckError (err, "NewGWorldFromPtr error", reports);
rectx * 4);
CheckError(err, "NewGWorldFromPtr error", reports);
qtexport->thePixMap = GetGWorldPixMap(qtexport->theGWorld);
LockPixels(qtexport->thePixMap);
SCDefaultPixMapSettings (qtdata->theComponent, qtexport->thePixMap, true);
SCDefaultPixMapSettings(qtdata->theComponent, qtexport->thePixMap, true);
// workaround for crash with H.264, which requires an upgrade to
// the new callback based api for proper encoding, but that's not
@@ -423,11 +424,11 @@ static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, i
SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
err = SCCompressSequenceBegin(qtdata->theComponent, qtexport->thePixMap, NULL, &qtexport->anImageDescription);
CheckError (err, "SCCompressSequenceBegin error", reports );
CheckError(err, "SCCompressSequenceBegin error", reports);
}
static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int recty, ReportList *reports)
static void QT_DoAddVideoSamplesToMedia(int frame, int *pixels, int rectx, int recty, ReportList *reports)
{
OSErr err = noErr;
Rect imageRect;
@@ -443,7 +444,7 @@ static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int
//copy and flip renderdata
memcpy(qtexport->ibuf2->rect, pixels, 4*rectx*recty);
memcpy(qtexport->ibuf2->rect, pixels, 4 * rectx * recty);
IMB_flipy(qtexport->ibuf2);
//get pointers to parse bitmapdata
@@ -455,12 +456,12 @@ static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int
//parse RGBA bitmap into Quicktime's ARGB GWorld
boxsize = rectx * recty;
for ( index = 0; index < boxsize; index++) {
for (index = 0; index < boxsize; index++) {
to[0] = from[3];
to[1] = from[0];
to[2] = from[1];
to[3] = from[2];
to +=4, from += 4;
to += 4, from += 4;
}
err = SCCompressSequenceFrame(qtdata->theComponent,
@@ -484,13 +485,13 @@ static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int
}
static void QT_EndAddVideoSamplesToMedia (void)
static void QT_EndAddVideoSamplesToMedia(void)
{
SCCompressSequenceEnd(qtdata->theComponent);
UnlockPixels(qtexport->thePixMap);
if (qtexport->theGWorld)
DisposeGWorld (qtexport->theGWorld);
DisposeGWorld(qtexport->theGWorld);
if (qtexport->ibuf)
IMB_freeImBuf(qtexport->ibuf);
@@ -504,7 +505,7 @@ void filepath_qt(char *string, RenderData *rd)
{
char txt[64];
if (string==0) return;
if (string == 0) return;
strcpy(string, rd->pic);
BLI_path_abs(string, G.main->name);
@@ -531,7 +532,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
#else
char *qtname;
#endif
int success= 1;
int success = 1;
if (qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
@@ -561,7 +562,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
sprintf(theFullPath, "%s", name);
/* hack: create an empty file to make FSPathMakeRef() happy */
myFile = open(theFullPath, O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRUSR|S_IWUSR);
myFile = open(theFullPath, O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRUSR | S_IWUSR);
if (myFile < 0) {
BKE_reportf(reports, RPT_ERROR, "error while creating movie file!\n");
/* do something? */
@@ -582,17 +583,17 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
err = FSMakeFSSpec(0, 0L, qtexport->qtfilename, &qtexport->theSpec);
#endif
err = CreateMovieFile (&qtexport->theSpec,
err = CreateMovieFile(&qtexport->theSpec,
kMyCreatorType,
smCurrentScript,
createMovieFileDeleteCurFile | createMovieFileDontCreateResFile,
&qtexport->resRefNum,
&qtexport->theMovie );
&qtexport->theMovie);
CheckError(err, "CreateMovieFile error", reports);
if (err != noErr) {
BKE_reportf(reports, RPT_ERROR, "Unable to create Quicktime movie: %s", name);
success= 0;
success = 0;
#ifdef __APPLE__
ExitMoviesOnThread();
#endif
@@ -622,7 +623,7 @@ void end_qt(void)
if (qtexport->theMovie) {
QT_EndCreateMyVideoTrack(NULL);
err = AddMovieResource (qtexport->theMovie, qtexport->resRefNum, &resId, qtexport->qtfilename);
err = AddMovieResource(qtexport->theMovie, qtexport->resRefNum, &resId, qtexport->qtfilename);
CheckError(err, "AddMovieResource error", NULL);
err = QT_AddUserDataTextToMovie(qtexport->theMovie, "Made with Blender", kUserDataTextInformation);
@@ -704,14 +705,14 @@ static void check_renderbutton_framerate(RenderData *rd, ReportList *reports)
void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf)
{
if (imf->imtype == R_IMF_IMTYPE_QUICKTIME) {
if ((rd->qtcodecsettings.codecType== 0) ||
(rd->qtcodecsettings.codecSpatialQuality <0) ||
if ((rd->qtcodecsettings.codecType == 0) ||
(rd->qtcodecsettings.codecSpatialQuality < 0) ||
(rd->qtcodecsettings.codecSpatialQuality > 100)) {
rd->qtcodecsettings.codecType = kJPEGCodecType;
rd->qtcodecsettings.codec = (int)anyCodec;
rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality*100)/codecLosslessQuality;
rd->qtcodecsettings.codecTemporalQuality = (codecHighQuality*100)/codecLosslessQuality;
rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality * 100) / codecLosslessQuality;
rd->qtcodecsettings.codecTemporalQuality = (codecHighQuality * 100) / codecLosslessQuality;
rd->qtcodecsettings.keyFrameRate = 25;
rd->qtcodecsettings.bitRate = 5000000; //5 Mbps
}
@@ -742,8 +743,8 @@ int get_qtcodec_settings(RenderData *rd, ReportList *reports)
qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType;
qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec;
qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) /100;
qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) /100;
qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) / 100;
qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) / 100;
qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate;
qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate;
qtdata->gSpatialSettings.depth = rd->qtcodecsettings.colorDepth;
@@ -751,7 +752,7 @@ int get_qtcodec_settings(RenderData *rd, ReportList *reports)
qtdata->aDataRateSetting.minTemporalQuality = (rd->qtcodecsettings.minTemporalQuality * codecLosslessQuality) / 100;
qtdata->aDataRateSetting.frameDuration = rd->frs_sec;
SetMovieTimeScale(qtexport->theMovie, rd->frs_sec_base*1000);
SetMovieTimeScale(qtexport->theMovie, rd->frs_sec_base * 1000);
err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
@@ -794,8 +795,8 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType;
qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec;
qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) /100;
qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) /100;
qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) / 100;
qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) / 100;
qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate;
qtdata->gTemporalSettings.frameRate = ((float)(rd->frs_sec << 16) / rd->frs_sec_base);
qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate;
@@ -917,7 +918,7 @@ void SCENE_OT_render_data_set_quicktime_codec(wmOperatorType *ot)
ot->poll = ED_operator_setqtcodec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
#endif /* USE_QTKIT */

View File

@@ -58,8 +58,8 @@
#include "quicktime_import.h"
#include "quicktime_export.h"
#define RECT_WIDTH(r) (r.right-r.left)
#define RECT_HEIGHT(r) (r.bottom-r.top)
#define RECT_WIDTH(r) (r.right - r.left)
#define RECT_HEIGHT(r) (r.bottom - r.top)
#define QTIME_DEBUG 0
@@ -86,7 +86,7 @@ typedef struct _QuicktimeMovie {
long trackIndex;
short depth;
int have_gw; //ugly
int have_gw; /* ugly */
} QuicktimeMovie;
@@ -105,7 +105,7 @@ void quicktime_init(void)
#endif /* _WIN32 */
/* Initialize QuickTime */
#if defined(_WIN32) || defined (__APPLE__)
#if defined(_WIN32) || defined(__APPLE__)
nerr = EnterMovies();
if (nerr != noErr)
G.have_quicktime = FALSE;
@@ -141,7 +141,7 @@ char *get_valid_qtname(char *name)
TCHAR Buffer[MAX_PATH];
DWORD dwRet;
char *qtname;
DynStr *ds= BLI_dynstr_new();
DynStr *ds = BLI_dynstr_new();
dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
@@ -166,7 +166,7 @@ char *get_valid_qtname(char *name)
BLI_dynstr_append(ds, name);
}
qtname= BLI_dynstr_get_cstring(ds);
qtname = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return qtname;
@@ -192,10 +192,10 @@ int anim_is_quicktime(const char *name)
OSErr err = noErr;
// don't let quicktime movie import handle these
if ( BLI_testextensie(name, ".swf") ||
if (BLI_testextensie(name, ".swf") ||
BLI_testextensie(name, ".txt") ||
BLI_testextensie(name, ".mpg") ||
BLI_testextensie(name, ".avi") || // wouldnt be appropriate ;)
BLI_testextensie(name, ".avi") || /* wouldnt be appropriate ;) */
BLI_testextensie(name, ".tga") ||
BLI_testextensie(name, ".png") ||
BLI_testextensie(name, ".bmp") ||
@@ -245,7 +245,7 @@ int anim_is_quicktime(const char *name)
}
}
if ((err == noErr) && (myImporter != NULL)) { // this file is a movie file
if ((err == noErr) && (myImporter != NULL)) { /* this file is a movie file */
isMovieFile = true;
}
@@ -268,8 +268,8 @@ void free_anim_quicktime(struct anim *anim)
DisposeMovie(anim->qtime->movie);
CloseMovieFile(anim->qtime->movieRefNum);
if (anim->qtime->frameIndex) MEM_freeN (anim->qtime->frameIndex);
if (anim->qtime) MEM_freeN (anim->qtime);
if (anim->qtime->frameIndex) MEM_freeN(anim->qtime->frameIndex);
if (anim->qtime) MEM_freeN(anim->qtime);
anim->qtime = NULL;
@@ -289,7 +289,7 @@ static OSErr QT_get_frameIndexes(struct anim *anim)
startPoint = -1;
GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample+nextTimeEdgeOK, (TimeValue)1, &media, 0,
GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample + nextTimeEdgeOK, (TimeValue)1, &media, 0,
1, &startPoint, NULL);
tmpstartPoint = startPoint;
@@ -320,7 +320,7 @@ static OSErr QT_get_frameIndexes(struct anim *anim)
}
ImBuf * qtime_fetchibuf (struct anim *anim, int position)
ImBuf *qtime_fetchibuf(struct anim *anim, int position)
{
PixMapHandle myPixMap = NULL;
Ptr myPtr;
@@ -344,7 +344,7 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
return (NULL);
}
ibuf = IMB_allocImBuf (anim->x, anim->y, 32, IB_rect);
ibuf = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect);
rect = ibuf->rect;
SetMovieTimeValue(anim->qtime->movie, anim->qtime->frameIndex[position]);
@@ -356,8 +356,8 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
myPtr = GetPixBaseAddr(myPixMap);
if (myPtr == NULL) {
printf ("Error reading frame from Quicktime");
IMB_freeImBuf (ibuf);
printf("Error reading frame from Quicktime");
IMB_freeImBuf(ibuf);
return NULL;
}
@@ -367,10 +367,10 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
#ifdef __APPLE__
// Swap alpha byte to the end, so ARGB become RGBA;
from= (unsigned char *)readPos;
to= (unsigned char *)changePos;
from = (unsigned char *)readPos;
to = (unsigned char *)changePos;
for ( index = 0; index < boxsize; index++, from+=4, to+=4 ) {
for (index = 0; index < boxsize; index++, from += 4, to += 4) {
to[3] = from[0];
to[0] = from[1];
to[1] = from[2];
@@ -379,14 +379,14 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
#endif
#ifdef _WIN32
for ( index = 0; index < boxsize; index++, changePos++, readPos++ )
*( changePos ) = *(readPos );
for (index = 0; index < boxsize; index++, changePos++, readPos++)
*(changePos) = *(readPos);
if (anim->qtime->depth < 32) {
//add alpha to ibuf
boxsize = anim->x * anim->y * 4;
crect = (unsigned char *) rect;
for ( index = 0; index < boxsize; index+=4, crect+=4 ) {
for (index = 0; index < boxsize; index += 4, crect += 4) {
crect[3] = 0xFF;
}
}
@@ -408,7 +408,7 @@ static int GetFirstVideoMedia(struct anim *anim)
numTracks = GetMovieTrackCount(anim->qtime->movie);
for (anim->qtime->trackIndex=1; anim->qtime->trackIndex<=numTracks; (anim->qtime->trackIndex)++) {
for (anim->qtime->trackIndex = 1; anim->qtime->trackIndex <= numTracks; (anim->qtime->trackIndex)++) {
anim->qtime->theTrack = GetMovieIndTrack(anim->qtime->movie, anim->qtime->trackIndex);
if (anim->qtime->theTrack)
@@ -452,7 +452,7 @@ int startquicktime(struct anim *anim)
#endif
short depth = 0;
anim->qtime = MEM_callocN (sizeof(QuicktimeMovie), "animqt");
anim->qtime = MEM_callocN(sizeof(QuicktimeMovie), "animqt");
anim->qtime->have_gw = FALSE;
if (anim->qtime == NULL) {
@@ -506,7 +506,7 @@ int startquicktime(struct anim *anim)
return -1;
}
anim->qtime->ibuf = IMB_allocImBuf (anim->x, anim->y, 32, IB_rect);
anim->qtime->ibuf = IMB_allocImBuf(anim->x, anim->y, 32, IB_rect);
#ifdef _WIN32
err = NewGWorldFromPtr(&anim->qtime->offscreenGWorld,
@@ -559,7 +559,7 @@ int startquicktime(struct anim *anim)
return 0;
}
int imb_is_a_quicktime (char *name)
int imb_is_a_quicktime(char *name)
{
GraphicsImportComponent theImporter = NULL;
@@ -651,7 +651,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
if (QTIME_DEBUG) printf("qt: attempt to load mem as image\n");
dataref= (PointerDataRef)NewHandle(sizeof(PointerDataRefRecord));
dataref = (PointerDataRef)NewHandle(sizeof(PointerDataRefRecord));
(**dataref).data = mem;
(**dataref).dataLength = size;
@@ -679,7 +679,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
goto bail;
}
err = GraphicsImportGetImageDescription (gImporter, &desc );
err = GraphicsImportGetImageDescription(gImporter, &desc);
if (err != noErr) {
if (QTIME_DEBUG) printf("no imagedescription\n");
goto bail;
@@ -698,8 +698,8 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
}
#ifdef __APPLE__
ibuf = IMB_allocImBuf (x, y, 32, IB_rect);
wbuf = IMB_allocImBuf (x, y, 32, IB_rect);
ibuf = IMB_allocImBuf(x, y, 32, IB_rect);
wbuf = IMB_allocImBuf(x, y, 32, IB_rect);
err = NewGWorldFromPtr(&offGWorld,
k32ARGBPixelFormat,
@@ -707,7 +707,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
(unsigned char *)wbuf->rect, x * 4);
#else
ibuf = IMB_allocImBuf (x, y, 32, IB_rect);
ibuf = IMB_allocImBuf(x, y, 32, IB_rect);
err = NewGWorldFromPtr(&offGWorld,
k32RGBAPixelFormat,
@@ -734,8 +734,8 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
myPtr = GetPixBaseAddr(myPixMap);
if (myPtr == NULL) {
printf ("Error reading frame from Quicktime");
IMB_freeImBuf (ibuf);
printf("Error reading frame from Quicktime");
IMB_freeImBuf(ibuf);
return NULL;
}
@@ -744,10 +744,10 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
changePos = (uint32_t *) rect;
// Swap alpha byte to the end, so ARGB become RGBA;
from= (unsigned char *)readPos;
to= (unsigned char *)changePos;
from = (unsigned char *)readPos;
to = (unsigned char *)changePos;
for ( index = 0; index < boxsize; index++, from+=4, to+=4 ) {
for (index = 0; index < boxsize; index++, from += 4, to += 4) {
to[3] = from[0];
to[0] = from[1];
to[1] = from[2];
@@ -763,7 +763,7 @@ bail:
#ifdef __APPLE__
if (wbuf) {
IMB_freeImBuf (wbuf);
IMB_freeImBuf(wbuf);
wbuf = NULL;
}
#endif
@@ -773,7 +773,7 @@ bail:
if (err != noErr) {
if (QTIME_DEBUG) printf("quicktime import unsuccesfull\n");
if (ibuf) {
IMB_freeImBuf (ibuf);
IMB_freeImBuf(ibuf);
ibuf = NULL;
}
}
@@ -788,8 +788,8 @@ bail:
int box = x * y;
unsigned char *arect = (unsigned char *) ibuf->rect;
if ( depth < 32 && (**desc).cType != kGIFCodecType) {
for (i = 0; i < box; i++, arect+=4)
if (depth < 32 && (**desc).cType != kGIFCodecType) {
for (i = 0; i < box; i++, arect += 4)
arect[3] = 0xFF;
}
#endif