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,10 +416,10 @@ struct CCGSubSurf {
static int VertDataEqual(const float a[], const float b[], const CCGSubSurf *ss) static int VertDataEqual(const float a[], const float b[], const CCGSubSurf *ss)
{ {
int i; int i;
for(i = 0; i < ss->meshIFC.numLayers; i++) { for (i = 0; i < ss->meshIFC.numLayers; i++) {
if(a[i] != b[i]) if (a[i] != b[i])
return 0; return 0;
} }
return 1; return 1;
} }
@@ -431,38 +431,38 @@ static void VertDataZero(float v[], const CCGSubSurf *ss)
static void VertDataCopy(float dst[], const float src[], const CCGSubSurf *ss) static void VertDataCopy(float dst[], const float src[], const CCGSubSurf *ss)
{ {
int i; int i;
for(i = 0; i < ss->meshIFC.numLayers; i++) for (i = 0; i < ss->meshIFC.numLayers; i++)
dst[i] = src[i]; dst[i] = src[i];
} }
static void VertDataAdd(float a[], const float b[], const CCGSubSurf *ss) static void VertDataAdd(float a[], const float b[], const CCGSubSurf *ss)
{ {
int i; int i;
for(i = 0; i < ss->meshIFC.numLayers; i++) for (i = 0; i < ss->meshIFC.numLayers; i++)
a[i] += b[i]; a[i] += b[i];
} }
static void VertDataSub(float a[], const float b[], const CCGSubSurf *ss) static void VertDataSub(float a[], const float b[], const CCGSubSurf *ss)
{ {
int i; int i;
for(i = 0; i < ss->meshIFC.numLayers; i++) for (i = 0; i < ss->meshIFC.numLayers; i++)
a[i] -= b[i]; a[i] -= b[i];
} }
static void VertDataMulN(float v[], float f, const CCGSubSurf *ss) static void VertDataMulN(float v[], float f, const CCGSubSurf *ss)
{ {
int i; int i;
for(i = 0; i < ss->meshIFC.numLayers; i++) for (i = 0; i < ss->meshIFC.numLayers; i++)
v[i] *= f; v[i] *= f;
} }
static void VertDataAvg4(float v[], static void VertDataAvg4(float v[],
const float a[], const float b[], const float a[], const float b[],
const float c[], const float d[], const float c[], const float d[],
const CCGSubSurf *ss) const CCGSubSurf *ss)
{ {
int i; 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; 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; v->flags = Vert_eEffected | seamflag;
} }
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) || 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; int i, j;
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss); VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss);
@@ -1165,7 +1166,7 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa
v->flags = Vert_eEffected | seamflag; v->flags = Vert_eEffected | seamflag;
} }
else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) || else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) ||
((v->flags & Vert_eSeam) != seamflag)) { ((v->flags & Vert_eSeam) != seamflag)) {
*prevp = v->next; *prevp = v->next;
_ehash_insert(ss->vMap, (EHEntry *) v); _ehash_insert(ss->vMap, (EHEntry *) v);
VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss); 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(r, 1.0f / f->numVerts, ss);
VertDataMulN((float*)FACE_getCenterData(f), f->numVerts - 2.0f, ss); VertDataMulN((float *)FACE_getCenterData(f), f->numVerts - 2.0f, ss);
VertDataAdd((float*)FACE_getCenterData(f), q, ss); VertDataAdd((float *)FACE_getCenterData(f), q, ss);
VertDataAdd((float*)FACE_getCenterData(f), r, ss); VertDataAdd((float *)FACE_getCenterData(f), r, ss);
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 (S = 0; S < f->numVerts; S++) {
/* interior face shift /* interior face shift
@@ -2024,14 +2025,14 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
FACE_getIFCo(f, nextLvl, S, fx + 1, fy - 1), FACE_getIFCo(f, nextLvl, S, fx + 1, fy - 1),
FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 1), FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 1),
FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1), FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1),
ss); ss);
VertDataAvg4(r, VertDataAvg4(r,
FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 0), FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 0),
FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 0), FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 0),
FACE_getIFCo(f, nextLvl, S, fx + 0, fy - 1), FACE_getIFCo(f, nextLvl, S, fx + 0, fy - 1),
FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1), FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1),
ss); ss);
VertDataCopy(nCo, co, ss); VertDataCopy(nCo, co, ss);
VertDataSub(nCo, q, ss); VertDataSub(nCo, q, ss);
@@ -2061,7 +2062,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
FACE_getIECo(f, nextLvl, S, fx + 1), FACE_getIECo(f, nextLvl, S, fx + 1),
FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx), FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx),
FACE_getIFCo(f, nextLvl, S, fx, 1), FACE_getIFCo(f, nextLvl, S, fx, 1),
ss); ss);
VertDataCopy(nCo, co, ss); VertDataCopy(nCo, co, ss);
VertDataSub(nCo, q, ss); VertDataSub(nCo, q, ss);
@@ -2099,8 +2100,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss,
CCGEdge *e = FACE_getEdges(f)[S]; CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts]; 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_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_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_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); VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx), ss);
for (x = 1; x < gridSize - 1; x++) { 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); VertDataAdd(q, VERT_getCo(e->v1, curLvl), ss);
for (i = 0; i < e->numFaces; i++) { for (i = 0; i < e->numFaces; i++) {
CCGFace *f = e->faces[i]; CCGFace *f = e->faces[i];
VertDataAdd(q, (float*)FACE_getCenterData(f), ss); VertDataAdd(q, (float *)FACE_getCenterData(f), ss);
numFaces++; numFaces++;
} }
VertDataMulN(q, 1.0f / (2.0f + numFaces), ss); VertDataMulN(q, 1.0f / (2.0f + numFaces), ss);
@@ -2265,7 +2266,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
VertDataZero(q, ss); VertDataZero(q, ss);
for (i = 0; i < v->numFaces; i++) { for (i = 0; i < v->numFaces; i++) {
CCGFace *f = v->faces[i]; CCGFace *f = v->faces[i];
VertDataAdd(q, (float*)FACE_getCenterData(f), ss); VertDataAdd(q, (float *)FACE_getCenterData(f), ss);
numFaces++; numFaces++;
} }
VertDataMulN(q, 1.0f / numFaces, ss); VertDataMulN(q, 1.0f / numFaces, ss);
@@ -2365,8 +2366,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss)
CCGEdge *e = FACE_getEdges(f)[S]; CCGEdge *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts]; 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_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_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_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); 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 *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts]; 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); VertDataCopy(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss);
for (x = 0; x < gridSize; x++) 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, 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); 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++) { for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[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 (S = 0; S < f->numVerts; S++)
for (x = 0; x < gridSize; x++) 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 *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[prevS]; 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) if (FACE_getVerts(f)[S]->flags & Vert_eEffected)
VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss); 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++) { for (i = 0; i < numEffectedF; i++) {
CCGFace *f = effectedF[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 (S = 0; S < f->numVerts; S++)
for (x = 1; x < gridSize - 1; x++) 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 *e = FACE_getEdges(f)[S];
CCGEdge *prevE = FACE_getEdges(f)[prevS]; 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); VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl), ss);
for (x = 1; x < gridSize - 1; x++) { 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_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); 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

File diff suppressed because it is too large Load Diff

View File

@@ -39,47 +39,47 @@
/************************* File Format Definitions ***************************/ /************************* File Format Definitions ***************************/
#define CDF_ENDIAN_LITTLE 0 #define CDF_ENDIAN_LITTLE 0
#define CDF_ENDIAN_BIG 1 #define CDF_ENDIAN_BIG 1
#define CDF_DATA_FLOAT 0 #define CDF_DATA_FLOAT 0
typedef struct CDataFileHeader { typedef struct CDataFileHeader {
char ID[4]; /* "BCDF" */ char ID[4]; /* "BCDF" */
char endian; /* little, big */ char endian; /* little, big */
char version; /* non-compatible versions */ char version; /* non-compatible versions */
char subversion; /* compatible sub versions */ char subversion; /* compatible sub versions */
char pad; /* padding */ char pad; /* padding */
int structbytes; /* size of this struct in bytes */ int structbytes; /* size of this struct in bytes */
int type; /* image, mesh */ int type; /* image, mesh */
int totlayer; /* number of layers in the file */ int totlayer; /* number of layers in the file */
} CDataFileHeader; } CDataFileHeader;
typedef struct CDataFileImageHeader { typedef struct CDataFileImageHeader {
int structbytes; /* size of this struct in bytes */ int structbytes; /* size of this struct in bytes */
int width; /* image width */ int width; /* image width */
int height; /* image height */ int height; /* image height */
int tile_size; /* tile size (required power of 2) */ int tile_size; /* tile size (required power of 2) */
} CDataFileImageHeader; } CDataFileImageHeader;
typedef struct CDataFileMeshHeader { typedef struct CDataFileMeshHeader {
int structbytes; /* size of this struct in bytes */ int structbytes; /* size of this struct in bytes */
} CDataFileMeshHeader; } CDataFileMeshHeader;
struct CDataFileLayer { struct CDataFileLayer {
int structbytes; /* size of this struct in bytes */ int structbytes; /* size of this struct in bytes */
int datatype; /* only float for now */ int datatype; /* only float for now */
uint64_t datasize; /* size of data in layer */ uint64_t datasize; /* size of data in layer */
int type; /* layer type */ int type; /* layer type */
char name[CDF_LAYER_NAME_MAX]; /* layer name */ char name[CDF_LAYER_NAME_MAX]; /* layer name */
}; };
/**************************** Other Definitions ******************************/ /**************************** Other Definitions ******************************/
#define CDF_VERSION 0 #define CDF_VERSION 0
#define CDF_SUBVERSION 0 #define CDF_SUBVERSION 0
#define CDF_TILE_SIZE 64 #define CDF_TILE_SIZE 64
struct CDataFile { struct CDataFile {
int type; int type;
@@ -121,9 +121,9 @@ static int cdf_data_type_size(int datatype)
CDataFile *cdf_create(int type) 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; return cdf;
} }
@@ -147,11 +147,11 @@ static int cdf_read_header(CDataFile *cdf)
CDataFileImageHeader *image; CDataFileImageHeader *image;
CDataFileMeshHeader *mesh; CDataFileMeshHeader *mesh;
CDataFileLayer *layer; CDataFileLayer *layer;
FILE *f= cdf->readf; FILE *f = cdf->readf;
size_t offset = 0; size_t offset = 0;
int a; int a;
header= &cdf->header; header = &cdf->header;
if (!fread(header, sizeof(CDataFileHeader), 1, cdf->readf)) if (!fread(header, sizeof(CDataFileHeader), 1, cdf->readf))
return 0; return 0;
@@ -161,8 +161,8 @@ static int cdf_read_header(CDataFile *cdf)
if (header->version > CDF_VERSION) if (header->version > CDF_VERSION)
return 0; return 0;
cdf->switchendian= header->endian != cdf_endian(); cdf->switchendian = header->endian != cdf_endian();
header->endian= cdf_endian(); header->endian = cdf_endian();
if (cdf->switchendian) { if (cdf->switchendian) {
SWITCH_INT(header->type); SWITCH_INT(header->type);
@@ -174,13 +174,13 @@ static int cdf_read_header(CDataFile *cdf)
return 0; return 0;
offset += header->structbytes; offset += header->structbytes;
header->structbytes= sizeof(CDataFileHeader); header->structbytes = sizeof(CDataFileHeader);
if (fseek(f, offset, SEEK_SET) != 0) if (fseek(f, offset, SEEK_SET) != 0)
return 0; return 0;
if (header->type == CDF_TYPE_IMAGE) { if (header->type == CDF_TYPE_IMAGE) {
image= &cdf->btype.image; image = &cdf->btype.image;
if (!fread(image, sizeof(CDataFileImageHeader), 1, f)) if (!fread(image, sizeof(CDataFileImageHeader), 1, f))
return 0; return 0;
@@ -192,10 +192,10 @@ static int cdf_read_header(CDataFile *cdf)
} }
offset += image->structbytes; offset += image->structbytes;
image->structbytes= sizeof(CDataFileImageHeader); image->structbytes = sizeof(CDataFileImageHeader);
} }
else if (header->type == CDF_TYPE_MESH) { else if (header->type == CDF_TYPE_MESH) {
mesh= &cdf->btype.mesh; mesh = &cdf->btype.mesh;
if (!fread(mesh, sizeof(CDataFileMeshHeader), 1, f)) if (!fread(mesh, sizeof(CDataFileMeshHeader), 1, f))
return 0; return 0;
@@ -203,17 +203,17 @@ static int cdf_read_header(CDataFile *cdf)
SWITCH_INT(mesh->structbytes); SWITCH_INT(mesh->structbytes);
offset += mesh->structbytes; offset += mesh->structbytes;
mesh->structbytes= sizeof(CDataFileMeshHeader); mesh->structbytes = sizeof(CDataFileMeshHeader);
} }
if (fseek(f, offset, SEEK_SET) != 0) if (fseek(f, offset, SEEK_SET) != 0)
return 0; return 0;
cdf->layer= MEM_callocN(sizeof(CDataFileLayer)*header->totlayer, "CDataFileLayer"); cdf->layer = MEM_callocN(sizeof(CDataFileLayer) * header->totlayer, "CDataFileLayer");
cdf->totlayer= header->totlayer; cdf->totlayer = header->totlayer;
for (a=0; a<header->totlayer; a++) { for (a = 0; a < header->totlayer; a++) {
layer= &cdf->layer[a]; layer = &cdf->layer[a];
if (!fread(layer, sizeof(CDataFileLayer), 1, f)) if (!fread(layer, sizeof(CDataFileLayer), 1, f))
return 0; return 0;
@@ -229,13 +229,13 @@ static int cdf_read_header(CDataFile *cdf)
return 0; return 0;
offset += layer->structbytes; offset += layer->structbytes;
layer->structbytes= sizeof(CDataFileLayer); layer->structbytes = sizeof(CDataFileLayer);
if (fseek(f, offset, SEEK_SET) != 0) if (fseek(f, offset, SEEK_SET) != 0)
return 0; return 0;
} }
cdf->dataoffset= offset; cdf->dataoffset = offset;
return 1; return 1;
} }
@@ -246,27 +246,27 @@ static int cdf_write_header(CDataFile *cdf)
CDataFileImageHeader *image; CDataFileImageHeader *image;
CDataFileMeshHeader *mesh; CDataFileMeshHeader *mesh;
CDataFileLayer *layer; CDataFileLayer *layer;
FILE *f= cdf->writef; FILE *f = cdf->writef;
int a; int a;
header= &cdf->header; header = &cdf->header;
if (!fwrite(header, sizeof(CDataFileHeader), 1, f)) if (!fwrite(header, sizeof(CDataFileHeader), 1, f))
return 0; return 0;
if (header->type == CDF_TYPE_IMAGE) { if (header->type == CDF_TYPE_IMAGE) {
image= &cdf->btype.image; image = &cdf->btype.image;
if (!fwrite(image, sizeof(CDataFileImageHeader), 1, f)) if (!fwrite(image, sizeof(CDataFileImageHeader), 1, f))
return 0; return 0;
} }
else if (header->type == CDF_TYPE_MESH) { else if (header->type == CDF_TYPE_MESH) {
mesh= &cdf->btype.mesh; mesh = &cdf->btype.mesh;
if (!fwrite(mesh, sizeof(CDataFileMeshHeader), 1, f)) if (!fwrite(mesh, sizeof(CDataFileMeshHeader), 1, f))
return 0; return 0;
} }
for (a=0; a<header->totlayer; a++) { for (a = 0; a < header->totlayer; a++) {
layer= &cdf->layer[a]; layer = &cdf->layer[a];
if (!fwrite(layer, sizeof(CDataFileLayer), 1, f)) if (!fwrite(layer, sizeof(CDataFileLayer), 1, f))
return 0; return 0;
@@ -279,11 +279,11 @@ int cdf_read_open(CDataFile *cdf, const char *filename)
{ {
FILE *f; FILE *f;
f= BLI_fopen(filename, "rb"); f = BLI_fopen(filename, "rb");
if (!f) if (!f)
return 0; return 0;
cdf->readf= f; cdf->readf = f;
if (!cdf_read_header(cdf)) { if (!cdf_read_header(cdf)) {
cdf_read_close(cdf); cdf_read_close(cdf);
@@ -304,8 +304,8 @@ int cdf_read_layer(CDataFile *cdf, CDataFileLayer *blay)
int a; int a;
/* seek to right location in file */ /* seek to right location in file */
offset= cdf->dataoffset; offset = cdf->dataoffset;
for (a=0; a<cdf->totlayer; a++) { for (a = 0; a < cdf->totlayer; a++) {
if (&cdf->layer[a] == blay) if (&cdf->layer[a] == blay)
break; break;
else else
@@ -326,9 +326,9 @@ int cdf_read_data(CDataFile *cdf, unsigned int size, void *data)
/* switch endian if necessary */ /* switch endian if necessary */
if (cdf->switchendian) { 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]); SWITCH_INT(fdata[a]);
} }
} }
@@ -340,7 +340,7 @@ void cdf_read_close(CDataFile *cdf)
{ {
if (cdf->readf) { if (cdf->readf) {
fclose(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; CDataFileMeshHeader *mesh;
FILE *f; FILE *f;
f= BLI_fopen(filename, "wb"); f = BLI_fopen(filename, "wb");
if (!f) if (!f)
return 0; return 0;
cdf->writef= f; cdf->writef = f;
/* fill header */ /* fill header */
header= &cdf->header; header = &cdf->header;
/* strcpy(, "BCDF"); // terminator out of range */ /* strcpy(, "BCDF"); // terminator out of range */
header->ID[0]= 'B'; header->ID[1]= 'C'; header->ID[2]= 'D'; header->ID[3]= 'F'; header->ID[0] = 'B'; header->ID[1] = 'C'; header->ID[2] = 'D'; header->ID[3] = 'F';
header->endian= cdf_endian(); header->endian = cdf_endian();
header->version= CDF_VERSION; header->version = CDF_VERSION;
header->subversion= CDF_SUBVERSION; header->subversion = CDF_SUBVERSION;
header->structbytes= sizeof(CDataFileHeader); header->structbytes = sizeof(CDataFileHeader);
header->type= cdf->type; header->type = cdf->type;
header->totlayer= cdf->totlayer; header->totlayer = cdf->totlayer;
if (cdf->type == CDF_TYPE_IMAGE) { if (cdf->type == CDF_TYPE_IMAGE) {
/* fill image header */ /* fill image header */
image= &cdf->btype.image; image = &cdf->btype.image;
image->structbytes= sizeof(CDataFileImageHeader); image->structbytes = sizeof(CDataFileImageHeader);
image->tile_size= CDF_TILE_SIZE; image->tile_size = CDF_TILE_SIZE;
} }
else if (cdf->type == CDF_TYPE_MESH) { else if (cdf->type == CDF_TYPE_MESH) {
/* fill mesh header */ /* fill mesh header */
mesh= &cdf->btype.mesh; mesh = &cdf->btype.mesh;
mesh->structbytes= sizeof(CDataFileMeshHeader); mesh->structbytes = sizeof(CDataFileMeshHeader);
} }
cdf_write_header(cdf); cdf_write_header(cdf);
@@ -404,7 +404,7 @@ void cdf_write_close(CDataFile *cdf)
{ {
if (cdf->writef) { if (cdf->writef) {
fclose(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; CDataFileLayer *layer;
int a; int a;
for (a=0; a<cdf->totlayer; a++) { for (a = 0; a < cdf->totlayer; a++) {
layer= &cdf->layer[a]; layer = &cdf->layer[a];
if (layer->type == type && strcmp(layer->name, name) == 0) if (layer->type == type && strcmp(layer->name, name) == 0)
return layer; return layer;
@@ -435,18 +435,18 @@ CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t
CDataFileLayer *newlayer, *layer; CDataFileLayer *newlayer, *layer;
/* expand array */ /* expand array */
newlayer= MEM_callocN(sizeof(CDataFileLayer)*(cdf->totlayer+1), "CDataFileLayer"); newlayer = MEM_callocN(sizeof(CDataFileLayer) * (cdf->totlayer + 1), "CDataFileLayer");
memcpy(newlayer, cdf->layer, sizeof(CDataFileLayer)*cdf->totlayer); memcpy(newlayer, cdf->layer, sizeof(CDataFileLayer) * cdf->totlayer);
cdf->layer= newlayer; cdf->layer = newlayer;
cdf->totlayer++; cdf->totlayer++;
/* fill in new layer */ /* fill in new layer */
layer= &cdf->layer[cdf->totlayer-1]; layer = &cdf->layer[cdf->totlayer - 1];
layer->structbytes= sizeof(CDataFileLayer); layer->structbytes = sizeof(CDataFileLayer);
layer->datatype= CDF_DATA_FLOAT; layer->datatype = CDF_DATA_FLOAT;
layer->datasize= datasize; layer->datasize = datasize;
layer->type= type; layer->type = type;
BLI_strncpy(layer->name, name, CDF_LAYER_NAME_MAX); BLI_strncpy(layer->name, name, CDF_LAYER_NAME_MAX);
return layer; return layer;

File diff suppressed because it is too large Load Diff

View File

@@ -43,61 +43,61 @@ typedef struct {
const char *name, *plural; const char *name, *plural;
int flags; int flags;
#define IDTYPE_FLAGS_ISLINKABLE (1<<0) #define IDTYPE_FLAGS_ISLINKABLE (1 << 0)
} IDType; } IDType;
/* plural need to match rna_main.c's MainCollectionDef */ /* plural need to match rna_main.c's MainCollectionDef */
static IDType idtypes[]= { static IDType idtypes[] = {
{ ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE}, { ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE},
{ ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE}, { ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE},
{ ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE}, { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE},
{ ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE}, { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE},
{ ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE}, { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE},
{ ID_GD, "GPencil", "grease_pencil", IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */ { ID_GD, "GPencil", "grease_pencil", IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */
{ ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE}, { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE},
{ ID_ID, "ID", "ids", 0}, /* plural is fake */ { ID_ID, "ID", "ids", 0}, /* plural is fake */
{ ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE}, { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE},
{ ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE}, /* deprecated */ { ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE}, /* deprecated */
{ ID_KE, "Key", "shape_keys", 0}, { ID_KE, "Key", "shape_keys", 0},
{ ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE}, { ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE},
{ ID_LI, "Library", "libraries", 0}, { ID_LI, "Library", "libraries", 0},
{ ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE}, { ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE},
{ ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE}, { ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE},
{ ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE}, { ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE},
{ ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE}, { ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE},
{ ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE}, { ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE},
{ ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE}, { ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE},
{ ID_PA, "ParticleSettings", "particles", 0}, { ID_PA, "ParticleSettings", "particles", 0},
{ ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE}, { ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE},
{ ID_SCR, "Screen", "screens", 0}, { ID_SCR, "Screen", "screens", 0},
{ ID_SEQ, "Sequence", "sequences", 0}, /* not actually ID data */ { ID_SEQ, "Sequence", "sequences", 0}, /* not actually ID data */
{ ID_SPK, "Speaker", "speakers", IDTYPE_FLAGS_ISLINKABLE}, { ID_SPK, "Speaker", "speakers", IDTYPE_FLAGS_ISLINKABLE},
{ ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE}, { ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE},
{ ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE}, { ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE},
{ ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE}, { ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE},
{ ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE}, { ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE},
{ ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE}, { ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE},
{ ID_WM, "WindowManager", "window_managers", 0}, { ID_WM, "WindowManager", "window_managers", 0},
{ ID_MC, "MovieClip", "movieclips", IDTYPE_FLAGS_ISLINKABLE}, { 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) static IDType *idtype_from_name(const char *str)
{ {
int i= nidtypes; int i = nidtypes;
while (i--) while (i--)
if (strcmp(str, idtypes[i].name)==0) if (strcmp(str, idtypes[i].name) == 0)
return &idtypes[i]; return &idtypes[i];
return NULL; return NULL;
} }
static IDType *idtype_from_code(int code) static IDType *idtype_from_code(int code)
{ {
int i= nidtypes; int i = nidtypes;
while (i--) while (i--)
if (code==idtypes[i].code) if (code == idtypes[i].code)
return &idtypes[i]; return &idtypes[i];
return NULL; return NULL;
@@ -105,34 +105,34 @@ static IDType *idtype_from_code(int code)
int BKE_idcode_is_valid(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) int BKE_idcode_is_linkable(int code)
{ {
IDType *idt= idtype_from_code(code); IDType *idt = idtype_from_code(code);
return idt?(idt->flags&IDTYPE_FLAGS_ISLINKABLE):0; return idt ? (idt->flags & IDTYPE_FLAGS_ISLINKABLE) : 0;
} }
const char *BKE_idcode_to_name(int code) 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) 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) 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) int BKE_idcode_iter_step(int *index)

View File

@@ -82,8 +82,8 @@ void free_nlastrip(ListBase *strips, NlaStrip *strip)
return; return;
/* free child-strips */ /* free child-strips */
for (cs= strip->strips.first; cs; cs= csn) { for (cs = strip->strips.first; cs; cs = csn) {
csn= cs->next; csn = cs->next;
free_nlastrip(&strip->strips, cs); free_nlastrip(&strip->strips, cs);
} }
@@ -120,8 +120,8 @@ void free_nlatrack(ListBase *tracks, NlaTrack *nlt)
return; return;
/* free strips */ /* free strips */
for (strip= nlt->strips.first; strip; strip= stripn) { for (strip = nlt->strips.first; strip; strip = stripn) {
stripn= strip->next; stripn = strip->next;
free_nlastrip(&nlt->strips, strip); free_nlastrip(&nlt->strips, strip);
} }
@@ -144,19 +144,19 @@ void free_nladata(ListBase *tracks)
return; return;
/* free tracks one by one */ /* free tracks one by one */
for (nlt= tracks->first; nlt; nlt= nltn) { for (nlt = tracks->first; nlt; nlt = nltn) {
nltn= nlt->next; nltn = nlt->next;
free_nlatrack(tracks, nlt); free_nlatrack(tracks, nlt);
} }
/* clear the list's pointers to be safe */ /* clear the list's pointers to be safe */
tracks->first= tracks->last= NULL; tracks->first = tracks->last = NULL;
} }
/* Copying ------------------------------------------- */ /* Copying ------------------------------------------- */
/* Copy NLA strip */ /* Copy NLA strip */
NlaStrip *copy_nlastrip (NlaStrip *strip) NlaStrip *copy_nlastrip(NlaStrip *strip)
{ {
NlaStrip *strip_d; NlaStrip *strip_d;
NlaStrip *cs, *cs_d; NlaStrip *cs, *cs_d;
@@ -166,8 +166,8 @@ NlaStrip *copy_nlastrip (NlaStrip *strip)
return NULL; return NULL;
/* make a copy */ /* make a copy */
strip_d= MEM_dupallocN(strip); strip_d = MEM_dupallocN(strip);
strip_d->next= strip_d->prev= NULL; strip_d->next = strip_d->prev = NULL;
/* increase user-count of action */ /* increase user-count of action */
if (strip_d->act) if (strip_d->act)
@@ -178,10 +178,10 @@ NlaStrip *copy_nlastrip (NlaStrip *strip)
copy_fmodifiers(&strip_d->modifiers, &strip->modifiers); copy_fmodifiers(&strip_d->modifiers, &strip->modifiers);
/* make a copy of all the child-strips, one at a time */ /* 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) { for (cs = strip->strips.first; cs; cs = cs->next) {
cs_d= copy_nlastrip(cs); cs_d = copy_nlastrip(cs);
BLI_addtail(&strip_d->strips, cs_d); BLI_addtail(&strip_d->strips, cs_d);
} }
@@ -190,7 +190,7 @@ NlaStrip *copy_nlastrip (NlaStrip *strip)
} }
/* Copy NLA Track */ /* Copy NLA Track */
NlaTrack *copy_nlatrack (NlaTrack *nlt) NlaTrack *copy_nlatrack(NlaTrack *nlt)
{ {
NlaStrip *strip, *strip_d; NlaStrip *strip, *strip_d;
NlaTrack *nlt_d; NlaTrack *nlt_d;
@@ -200,14 +200,14 @@ NlaTrack *copy_nlatrack (NlaTrack *nlt)
return NULL; return NULL;
/* make a copy */ /* make a copy */
nlt_d= MEM_dupallocN(nlt); nlt_d = MEM_dupallocN(nlt);
nlt_d->next= nlt_d->prev= NULL; nlt_d->next = nlt_d->prev = NULL;
/* make a copy of all the strips, one at a time */ /* 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) { for (strip = nlt->strips.first; strip; strip = strip->next) {
strip_d= copy_nlastrip(strip); strip_d = copy_nlastrip(strip);
BLI_addtail(&nlt_d->strips, strip_d); BLI_addtail(&nlt_d->strips, strip_d);
} }
@@ -225,12 +225,12 @@ void copy_nladata(ListBase *dst, ListBase *src)
return; return;
/* clear out the destination list first for precautions... */ /* 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 */ /* 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 */ /* 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); BLI_addtail(dst, nlt_d);
} }
} }
@@ -240,7 +240,7 @@ void copy_nladata(ListBase *dst, ListBase *src)
/* Add a NLA Track to the given AnimData /* Add a NLA Track to the given AnimData
* - prev: NLA-Track to add the new one after * - 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; NlaTrack *nlt;
@@ -249,11 +249,11 @@ NlaTrack *add_nlatrack (AnimData *adt, NlaTrack *prev)
return NULL; return NULL;
/* allocate new track */ /* 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 */ /* set settings requiring the track to not be part of the stack yet */
nlt->flag = NLATRACK_SELECTED; 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 */ /* add track to stack, and make it the active one */
if (prev) if (prev)
@@ -271,7 +271,7 @@ NlaTrack *add_nlatrack (AnimData *adt, NlaTrack *prev)
} }
/* Add a NLA Strip referencing the given Action */ /* Add a NLA Strip referencing the given Action */
NlaStrip *add_nlastrip (bAction *act) NlaStrip *add_nlastrip(bAction *act)
{ {
NlaStrip *strip; NlaStrip *strip;
@@ -280,7 +280,7 @@ NlaStrip *add_nlastrip (bAction *act)
return NULL; return NULL;
/* allocate new strip */ /* allocate new strip */
strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip"); strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip");
/* generic settings /* generic settings
* - selected flag to highlight this to the user * - 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 * is not done though, since this should only really happens in editmode for strips now
* though this decision is still subject to further review... * 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 */ /* assign the action reference */
strip->act= act; strip->act = act;
id_us_plus(&act->id); id_us_plus(&act->id);
/* determine initial range /* determine initial range
@@ -302,10 +302,10 @@ NlaStrip *add_nlastrip (bAction *act)
calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); calc_action_range(strip->act, &strip->actstart, &strip->actend, 0);
strip->start = strip->actstart; 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 should be referenced as-is */
strip->scale= 1.0f; strip->scale = 1.0f;
strip->repeat = 1.0f; strip->repeat = 1.0f;
/* return the new strip */ /* 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 */ /* 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; NlaStrip *strip;
NlaTrack *nlt; NlaTrack *nlt;
@@ -323,7 +323,7 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act)
return NULL; return NULL;
/* create a new NLA strip */ /* create a new NLA strip */
strip= add_nlastrip(act); strip = add_nlastrip(act);
if (strip == NULL) if (strip == NULL)
return 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), /* 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... * 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); 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 */ /* 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"); 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) /* non clipped mapping for strip-time <-> global time (for Action-Clips)
* invert = convert action-strip time to global time * 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 actlength, scale;
// float repeat; // UNUSED // float repeat; // UNUSED
@@ -398,7 +398,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short
// repeat = strip->repeat; // UNUSED // repeat = strip->repeat; // UNUSED
/* scaling */ /* 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 */ scale = fabsf(strip->scale); /* scale must be positive - we've got a special flag for reversing */
/* length of referenced action */ /* 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) { if (strip->flag & NLASTRIP_FLAG_REVERSE) {
// FIXME: this won't work right with Graph Editor? // FIXME: this won't work right with Graph Editor?
if (mode == NLATIME_CONVERT_MAP) { 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) { else if (mode == NLATIME_CONVERT_UNMAP) {
return (strip->end + (strip->actstart * scale - cframe)) / scale; 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))) { 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 /* 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 * 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 'fmod(..., actlength*scale)' is needed to get the repeats working
* - the '/ scale' is needed to ensure that scaling influences the timing within the repeat * - 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 { else {
if (mode == NLATIME_CONVERT_MAP) { 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) { else if (mode == NLATIME_CONVERT_UNMAP) {
return strip->actstart + (cframe - strip->start) / scale; 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))) { 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 /* 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 * 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 'fmod(..., actlength*scale)' is needed to get the repeats working
* - the '/ scale' is needed to ensure that scaling influences the timing within the repeat * - 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) /* non clipped mapping for strip-time <-> global time (for Transitions)
* invert = convert action-strip time to global time * 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; float length;
/* length of strip */ /* length of strip */
length= strip->end - strip->start; length = strip->end - strip->start;
/* reversed = play strip backwards */ /* reversed = play strip backwards */
if (strip->flag & NLASTRIP_FLAG_REVERSE) { if (strip->flag & NLASTRIP_FLAG_REVERSE) {
@@ -481,7 +481,7 @@ static float nlastrip_get_frame_transition (NlaStrip *strip, float cframe, short
} }
/* non clipped mapping for strip-time <-> global time /* non clipped mapping for strip-time <-> global time
* mode = eNlaTime_ConvertModes[] -> NLATIME_CONVERT_* * mode = eNlaTime_ConvertModes[] -> NLATIME_CONVERT_*
* *
* only secure for 'internal' (i.e. within AnimSys evaluation) operations, * only secure for 'internal' (i.e. within AnimSys evaluation) operations,
* but should not be directly relied on for stuff which interacts with editors * but should not be directly relied on for stuff which interacts with editors
@@ -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 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 * - 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; return cframe;
/* if the active-strip info has been stored already, access this, otherwise look this up /* if the active-strip info has been stored already, access this, otherwise look this up
* and store for (very probable) future usage * and store for (very probable) future usage
*/ */
if (adt->actstrip == NULL) { if (adt->actstrip == NULL) {
NlaTrack *nlt= BKE_nlatrack_find_active(&adt->nla_tracks); NlaTrack *nlt = BKE_nlatrack_find_active(&adt->nla_tracks);
adt->actstrip= BKE_nlastrip_find_active(nlt); adt->actstrip = BKE_nlastrip_find_active(nlt);
} }
strip= adt->actstrip; strip = adt->actstrip;
/* sanity checks /* sanity checks
* - in rare cases, we may not be able to find this strip for some reason (internal error) * - 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... */ /* 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 /* 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 * 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, /* 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 * 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; 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 /* 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 * the list, assuming that the lists are in order
*/ */
BLI_remlink(strips, strip); BLI_remlink(strips, strip);
for (sstrip= tmp.last; sstrip; sstrip= sstrip->prev) { for (sstrip = tmp.last; sstrip; sstrip = sstrip->prev) {
/* check if add after */ /* check if add after */
if (sstrip->end <= strip->start) { if (sstrip->end <= strip->start) {
BLI_insertlinkafter(&tmp, sstrip, strip); BLI_insertlinkafter(&tmp, sstrip, strip);
not_added= 0; not_added = 0;
break; break;
} }
} }
@@ -617,8 +617,8 @@ void BKE_nlastrips_sort_strips(ListBase *strips)
} }
/* reassign the start and end points of the strips */ /* reassign the start and end points of the strips */
strips->first= tmp.first; strips->first = tmp.first;
strips->last= tmp.last; strips->last = tmp.last;
} }
/* Add the given NLA-Strip to the given list of strips, assuming that it /* 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; return 0;
/* check if any space to add */ /* 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; return 0;
/* find the right place to add the strip to the nominated track */ /* 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 current strip occurs after the new strip, add it before */
if (ns->start >= strip->end) { if (ns->start >= strip->end) {
BLI_insertlinkbefore(strips, ns, strip); BLI_insertlinkbefore(strips, ns, strip);
not_added= 0; not_added = 0;
break; break;
} }
} }
@@ -672,14 +672,14 @@ void BKE_nlastrips_make_metas(ListBase *strips, short temp)
return; return;
/* group all continuous chains of selected strips into meta-strips */ /* group all continuous chains of selected strips into meta-strips */
for (strip= strips->first; strip; strip= stripn) { for (strip = strips->first; strip; strip = stripn) {
stripn= strip->next; stripn = strip->next;
if (strip->flag & NLASTRIP_FLAG_SELECT) { if (strip->flag & NLASTRIP_FLAG_SELECT) {
/* if there is an existing meta-strip, add this strip to it, otherwise, create a new one */ /* if there is an existing meta-strip, add this strip to it, otherwise, create a new one */
if (mstrip == NULL) { if (mstrip == NULL) {
/* add a new meta-strip, and add it before the current strip that it will replace... */ /* 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; mstrip->type = NLASTRIP_TYPE_META;
BLI_insertlinkbefore(strips, strip, mstrip); BLI_insertlinkbefore(strips, strip, mstrip);
@@ -691,10 +691,10 @@ void BKE_nlastrips_make_metas(ListBase *strips, short temp)
mstrip->flag |= NLASTRIP_FLAG_TEMP_META; mstrip->flag |= NLASTRIP_FLAG_TEMP_META;
/* set default repeat/scale values to prevent warnings */ /* 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 */ /* 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 */ /* 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); BLI_addtail(&mstrip->strips, strip);
/* expand the meta's dimensions to include the newly added strip- i.e. its last frame */ /* 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 { else {
/* current strip wasn't selected, so the end of 'island' of selected strips has been reached, /* current strip wasn't selected, so the end of 'island' of selected strips has been reached,
* so stop adding strips to the current meta * 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 /* 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 * in the list of strips after unlinking them from the meta-strip
*/ */
for (cs= strip->strips.first; cs; cs= csn) { for (cs = strip->strips.first; cs; cs = csn) {
csn= cs->next; csn = cs->next;
BLI_remlink(&strip->strips, cs); BLI_remlink(&strip->strips, cs);
BLI_insertlinkbefore(strips, strip, cs); BLI_insertlinkbefore(strips, strip, cs);
} }
@@ -748,13 +748,13 @@ void BKE_nlastrips_clear_metas(ListBase *strips, short onlySel, short onlyTemp)
return; return;
/* remove meta-strips fitting the criteria of the arguments */ /* remove meta-strips fitting the criteria of the arguments */
for (strip= strips->first; strip; strip= stripn) { for (strip = strips->first; strip; strip = stripn) {
stripn= strip->next; stripn = strip->next;
/* check if strip is a meta-strip */ /* check if strip is a meta-strip */
if (strip->type == NLASTRIP_TYPE_META) { if (strip->type == NLASTRIP_TYPE_META) {
/* if check if selection and 'temporary-only' considerations are met */ /* 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)) { if ((!onlyTemp) || (strip->flag & NLASTRIP_FLAG_TEMP_META)) {
BKE_nlastrips_clear_metastrip(strips, strip); 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)) { if ((mstrip->prev == NULL) || (mstrip->prev->end <= strip->start)) {
/* add strip to start of meta's list, and expand dimensions */ /* add strip to start of meta's list, and expand dimensions */
BLI_addhead(&mstrip->strips, strip); BLI_addhead(&mstrip->strips, strip);
mstrip->start= strip->start; mstrip->start = strip->start;
return 1; return 1;
} }
@@ -800,7 +800,7 @@ short BKE_nlameta_add_strip(NlaStrip *mstrip, NlaStrip *strip)
if ((mstrip->next == NULL) || (mstrip->next->start >= strip->end)) { if ((mstrip->next == NULL) || (mstrip->next->start >= strip->end)) {
/* add strip to end of meta's list, and expand dimensions */ /* add strip to end of meta's list, and expand dimensions */
BLI_addtail(&mstrip->strips, strip); BLI_addtail(&mstrip->strips, strip);
mstrip->end= strip->end; mstrip->end = strip->end;
return 1; return 1;
} }
@@ -821,7 +821,7 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
NlaStrip *strip; NlaStrip *strip;
float oStart, oEnd, offset; float oStart, oEnd, offset;
float oLen, nLen; float oLen, nLen;
short scaleChanged= 0; short scaleChanged = 0;
/* sanity checks /* sanity checks
* - strip must exist * - 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, * - these are simply the start/end frames of the child strips,
* since we assume they weren't transformed yet * since we assume they weren't transformed yet
*/ */
oStart= ((NlaStrip *)mstrip->strips.first)->start; oStart = ((NlaStrip *)mstrip->strips.first)->start;
oEnd= ((NlaStrip *)mstrip->strips.last)->end; oEnd = ((NlaStrip *)mstrip->strips.last)->end;
offset= mstrip->start - oStart; offset = mstrip->start - oStart;
/* optimization: /* optimization:
* don't flush if nothing changed yet * don't flush if nothing changed yet
@@ -851,20 +851,20 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
oLen = oEnd - oStart; oLen = oEnd - oStart;
nLen = mstrip->end - mstrip->start; nLen = mstrip->end - mstrip->start;
if (IS_EQF(nLen, oLen) == 0) 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 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) { if (scaleChanged) {
float p1, p2; float p1, p2;
/* compute positions of endpoints relative to old extents of strip */ /* compute positions of endpoints relative to old extents of strip */
p1= (strip->start - oStart) / oLen; p1 = (strip->start - oStart) / oLen;
p2= (strip->end - oStart) / oLen; p2 = (strip->end - oStart) / oLen;
/* apply new strip endpoints using the proportions, then wait for second pass to flush scale properly */ /* apply new strip endpoints using the proportions, then wait for second pass to flush scale properly */
strip->start= (p1 * nLen) + mstrip->start; strip->start = (p1 * nLen) + mstrip->start;
strip->end= (p2 * nLen) + mstrip->start; strip->end = (p2 * nLen) + mstrip->start;
} }
else { else {
/* just apply the changes in offset to both ends of the strip */ /* 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 */ /* 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 */ /* only if scale changed, need to perform RNA updates */
if (scaleChanged) { if (scaleChanged) {
PointerRNA ptr; PointerRNA ptr;
@@ -894,7 +894,7 @@ void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
/* NLA-Tracks ---------------------------------------- */ /* NLA-Tracks ---------------------------------------- */
/* Find the active NLA-track for the given stack */ /* 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; NlaTrack *nlt;
@@ -903,7 +903,7 @@ NlaTrack *BKE_nlatrack_find_active (ListBase *tracks)
return NULL; return NULL;
/* try to find the first active track */ /* 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) if (nlt->flag & NLATRACK_ACTIVE)
return nlt; return nlt;
} }
@@ -924,7 +924,7 @@ void BKE_nlatrack_solo_toggle(AnimData *adt, NlaTrack *nlt)
return; return;
/* firstly, make sure 'solo' flag for all tracks is disabled */ /* 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) if (nt != nlt)
nt->flag &= ~NLATRACK_SOLO; nt->flag &= ~NLATRACK_SOLO;
} }
@@ -956,7 +956,7 @@ void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt_a)
return; return;
/* deactive all the rest */ /* deactive all the rest */
for (nlt= tracks->first; nlt; nlt= nlt->next) for (nlt = tracks->first; nlt; nlt = nlt->next)
nlt->flag &= ~NLATRACK_ACTIVE; nlt->flag &= ~NLATRACK_ACTIVE;
/* set the given one as the active one */ /* set the given one as the active one */
@@ -968,9 +968,9 @@ void BKE_nlatrack_set_active(ListBase *tracks, NlaTrack *nlt_a)
short BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end) short BKE_nlatrack_has_space(NlaTrack *nlt, float start, float end)
{ {
/* sanity checks /* sanity checks
* - track must exist * - track must exist
* - track must be editable * - track must be editable
* - bounds cannot be equal (0-length is nasty) * - bounds cannot be equal (0-length is nasty)
*/ */
if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQF(start, end)) if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQF(start, end))
return 0; return 0;
@@ -1042,7 +1042,7 @@ short BKE_nlatrack_get_bounds(NlaTrack *nlt, float bounds[2])
/* NLA Strips -------------------------------------- */ /* NLA Strips -------------------------------------- */
/* Find the active NLA-strip within the given track */ /* 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; NlaStrip *strip;
@@ -1051,7 +1051,7 @@ NlaStrip *BKE_nlastrip_find_active (NlaTrack *nlt)
return NULL; return NULL;
/* try to find the first active strip */ /* 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) if (strip->flag & NLASTRIP_FLAG_ACTIVE)
return strip; return strip;
} }
@@ -1071,8 +1071,8 @@ void BKE_nlastrip_set_active(AnimData *adt, NlaStrip *strip)
return; return;
/* loop over tracks, deactivating*/ /* loop over tracks, deactivating*/
for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (nls= nlt->strips.first; nls; nls= nls->next) { for (nls = nlt->strips.first; nls; nls = nls->next) {
if (nls != strip) if (nls != strip)
nls->flag &= ~NLASTRIP_FLAG_ACTIVE; nls->flag &= ~NLASTRIP_FLAG_ACTIVE;
else 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)? */ /* Does the given NLA-strip fall within the given bounds (times)? */
short BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max) short BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max)
{ {
const float stripLen= (strip) ? strip->end - strip->start : 0.0f; const float stripLen = (strip) ? strip->end - strip->start : 0.0f;
const float boundsLen= fabsf(max - min); const float boundsLen = fabsf(max - min);
/* sanity checks */ /* sanity checks */
if ((strip == NULL) || IS_EQF(stripLen, 0.0f) || IS_EQF(boundsLen, 0.0f)) 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; return;
/* calculate new length factors */ /* calculate new length factors */
actlen= strip->actend - strip->actstart; actlen = strip->actend - strip->actstart;
if (IS_EQF(actlen, 0.0f)) actlen= 1.0f; 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 */ /* adjust endpoint of strip in response to this */
if (IS_EQF(mapping, 0.0f) == 0) 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 */ /* 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 // 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; NlaTrack *nlt;
NlaStrip *ns; 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 */ /* 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? // 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 */ /* only check the first strip, assuming that they're all in order */
ns= nlt->strips.first; ns = nlt->strips.first;
if (ns) { if (ns) {
if (ns->start < strip->start) if (ns->start < strip->start)
return 0; return 0;
@@ -1180,7 +1180,7 @@ short BKE_nlatrack_has_animated_strips(NlaTrack *nlt)
return 0; return 0;
/* check each strip for F-Curves only (don't care about whether the flags are set) */ /* 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) if (strip->fcurves.first)
return 1; return 1;
} }
@@ -1199,7 +1199,7 @@ short BKE_nlatracks_have_animated_strips(ListBase *tracks)
return 0; return 0;
/* check each track, stopping on the first hit */ /* 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)) if (BKE_nlatrack_has_animated_strips(nlt))
return 1; return 1;
} }
@@ -1220,19 +1220,19 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
/* if controlling influence... */ /* if controlling influence... */
if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) { if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) {
/* try to get F-Curve */ /* 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 */ /* add one if not found */
if (fcu == NULL) { if (fcu == NULL) {
/* make new F-Curve */ /* make new F-Curve */
fcu= MEM_callocN(sizeof(FCurve), "NlaStrip FCurve"); fcu = MEM_callocN(sizeof(FCurve), "NlaStrip FCurve");
BLI_addtail(&strip->fcurves, fcu); BLI_addtail(&strip->fcurves, fcu);
/* set default flags */ /* set default flags */
fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
/* store path - make copy, and store that */ /* 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? // TODO: insert a few keyframes to ensure default behavior?
} }
@@ -1241,19 +1241,19 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
/* if controlling time... */ /* if controlling time... */
if (strip->flag & NLASTRIP_FLAG_USR_TIME) { if (strip->flag & NLASTRIP_FLAG_USR_TIME) {
/* try to get F-Curve */ /* 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 */ /* add one if not found */
if (fcu == NULL) { if (fcu == NULL) {
/* make new F-Curve */ /* make new F-Curve */
fcu= MEM_callocN(sizeof(FCurve), "NlaStrip FCurve"); fcu = MEM_callocN(sizeof(FCurve), "NlaStrip FCurve");
BLI_addtail(&strip->fcurves, fcu); BLI_addtail(&strip->fcurves, fcu);
/* set default flags */ /* set default flags */
fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
/* store path - make copy, and store that */ /* 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? // TODO: insert a few keyframes to ensure default behavior?
} }
@@ -1283,10 +1283,10 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
return; return;
/* give strip a default name if none already */ /* give strip a default name if none already */
if (strip->name[0]==0) { if (strip->name[0] == 0) {
switch (strip->type) { switch (strip->type) {
case NLASTRIP_TYPE_CLIP: /* act-clip */ 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; break;
case NLASTRIP_TYPE_TRANSITION: /* transition */ case NLASTRIP_TYPE_TRANSITION: /* transition */
BLI_strncpy(strip->name, "Transition", sizeof(strip->name)); 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 * - this is easier than iterating over all the tracks+strips hierarchy everytime
* (and probably faster) * (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 (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (tstrip= nlt->strips.first; tstrip; tstrip= tstrip->next) { for (tstrip = nlt->strips.first; tstrip; tstrip = tstrip->next) {
/* don't add the strip of interest */ /* don't add the strip of interest */
if (tstrip == strip) if (tstrip == strip)
continue; 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 * - track: nla-track that the overlapping strips should be found from
* - start, end: frames for the offending endpoints * - 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; NlaStrip *nls;
@@ -1341,46 +1341,46 @@ static void nlastrip_get_endpoint_overlaps (NlaStrip *strip, NlaTrack *track, fl
* but which don't cover the entire length * but which don't cover the entire length
*/ */
// TODO: this scheme could get quite slow for doing this on many strips... // 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 */ /* 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)) { if ((nls->start <= strip->start) && (nls->end >= strip->end)) {
*start= NULL; *start = NULL;
*end= NULL; *end = NULL;
return; return;
} }
/* check if strip doesn't even occur anywhere near... */ /* check if strip doesn't even occur anywhere near... */
if (nls->end < strip->start) if (nls->end < strip->start)
continue; /* skip checking this strip... not worthy of mention */ continue; /* skip checking this strip... not worthy of mention */
if (nls->start > strip->end) if (nls->start > strip->end)
return; /* the range we're after has already passed */ return; /* the range we're after has already passed */
/* if this strip is not part of an island of continuous strips, it can be used /* 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... * - 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)) 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)) if ((nls->start < strip->end) && (nls->start > strip->start))
*end= &nls->start; *end = &nls->start;
} }
} }
} }
/* Determine auto-blending for the given strip */ /* 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 *ps = NULL, *pe = NULL;
float *ns=NULL, *ne=NULL; float *ns = NULL, *ne = NULL;
/* sanity checks */ /* sanity checks */
if (ELEM(NULL, nls, nlt)) if (ELEM(NULL, nls, nlt))
return; return;
if ((nlt->prev == NULL) && (nlt->next == NULL)) if ((nlt->prev == NULL) && (nlt->next == NULL))
return; return;
if ((nls->flag & NLASTRIP_FLAG_AUTO_BLENDS)==0) if ((nls->flag & NLASTRIP_FLAG_AUTO_BLENDS) == 0)
return; return;
/* get test ranges */ /* 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 * is directly followed/preceeded by another strip, forming an
* 'island' of continuous strips * '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 */ /* start overlaps - pick the largest overlap */
if ( ((ps && ns) && (*ps > *ns)) || (ps) ) if ( ((ps && ns) && (*ps > *ns)) || (ps) )
nls->blendin= *ps - nls->start; nls->blendin = *ps - nls->start;
else else
nls->blendin= *ns - nls->start; nls->blendin = *ns - nls->start;
} }
else /* no overlap allowed/needed */ 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 */ /* end overlaps - pick the largest overlap */
if ( ((pe && ne) && (*pe > *ne)) || (pe) ) if ( ((pe && ne) && (*pe > *ne)) || (pe) )
nls->blendout= nls->end - *pe; nls->blendout = nls->end - *pe;
else else
nls->blendout= nls->end - *ne; nls->blendout = nls->end - *ne;
} }
else /* no overlap allowed/needed */ else /* no overlap allowed/needed */
nls->blendout= 0.0f; nls->blendout = 0.0f;
} }
/* Ensure that auto-blending and other settings are set correctly */ /* Ensure that auto-blending and other settings are set correctly */
void BKE_nla_validate_state(AnimData *adt) void BKE_nla_validate_state(AnimData *adt)
{ {
NlaStrip *strip, *fstrip=NULL; NlaStrip *strip, *fstrip = NULL;
NlaTrack *nlt; NlaTrack *nlt;
/* sanity checks */ /* sanity checks */
@@ -1426,20 +1426,20 @@ void BKE_nla_validate_state(AnimData *adt)
return; return;
/* adjust blending values for auto-blending, and also do an initial pass to find the earliest strip */ /* 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 (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip= nlt->strips.first; strip; strip= strip->next) { for (strip = nlt->strips.first; strip; strip = strip->next) {
/* auto-blending first */ /* auto-blending first */
BKE_nlastrip_validate_autoblends(nlt, strip); BKE_nlastrip_validate_autoblends(nlt, strip);
/* extend mode - find first strip */ /* extend mode - find first strip */
if ((fstrip == NULL) || (strip->start < fstrip->start)) 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 */ /* 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 (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
for (strip= nlt->strips.first; strip; strip= strip->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 /* 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) * 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] * Should fix problems such as [#29869]
*/ */
if (strip == fstrip) if (strip == fstrip)
strip->extendmode= NLASTRIP_EXTEND_HOLD; strip->extendmode = NLASTRIP_EXTEND_HOLD;
else if (strip->blendmode == NLASTRIP_MODE_REPLACE) 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 */ /* 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 */ /* do other necessary work on strip */
if (strip) { if (strip) {
/* clear reference to action now that we've pushed it onto the stack */ /* clear reference to action now that we've pushed it onto the stack */
id_us_min(&adt->action->id); 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 /* 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 * 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 * so that it doesn't override strips in previous tracks
*/ */
// FIXME: this needs to be more automated, since user can rearrange strips // 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... */ /* make strip the active one... */
@@ -1520,8 +1520,8 @@ void BKE_nla_action_pushdown(AnimData *adt)
*/ */
short BKE_nla_tweakmode_enter(AnimData *adt) short BKE_nla_tweakmode_enter(AnimData *adt)
{ {
NlaTrack *nlt, *activeTrack=NULL; NlaTrack *nlt, *activeTrack = NULL;
NlaStrip *strip, *activeStrip=NULL; NlaStrip *strip, *activeStrip = NULL;
/* verify that data is valid */ /* verify that data is valid */
if (ELEM(NULL, adt, adt->nla_tracks.first)) if (ELEM(NULL, adt, adt->nla_tracks.first))
@@ -1534,16 +1534,16 @@ short BKE_nla_tweakmode_enter(AnimData *adt)
return 1; return 1;
/* go over the tracks, finding the active one, and its active strip /* go over the tracks, finding the active one, and its active strip
* - if we cannot find both, then there's nothing to do * - 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 */ /* check if active */
if (nlt->flag & NLATRACK_ACTIVE) { if (nlt->flag & NLATRACK_ACTIVE) {
/* store reference to this active track */ /* store reference to this active track */
activeTrack= nlt; activeTrack = nlt;
/* now try to find active strip */ /* now try to find active strip */
activeStrip= BKE_nlastrip_find_active(nlt); activeStrip = BKE_nlastrip_find_active(nlt);
break; break;
} }
} }
@@ -1557,18 +1557,18 @@ short BKE_nla_tweakmode_enter(AnimData *adt)
for (nlt = adt->nla_tracks.last; nlt; nlt = nlt->prev) { for (nlt = adt->nla_tracks.last; nlt; nlt = nlt->prev) {
if (nlt->flag & NLATRACK_SELECTED) { if (nlt->flag & NLATRACK_SELECTED) {
/* assume this is the active track */ /* assume this is the active track */
activeTrack= nlt; activeTrack = nlt;
/* try to find active strip */ /* try to find active strip */
activeStrip= BKE_nlastrip_find_active(nlt); activeStrip = BKE_nlastrip_find_active(nlt);
break; break;
} }
} }
} }
if ((activeTrack) && (activeStrip == NULL)) { if ((activeTrack) && (activeStrip == NULL)) {
/* no active strip in active or last selected track; compromise for first selected (assuming only single)... */ /* 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) { for (strip = activeTrack->strips.first; strip; strip = strip->next) {
if (strip->flag & (NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE)) { if (strip->flag & (NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE)) {
activeStrip = strip; activeStrip = strip;
break; 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 /* 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 * action as the active strip, but leaving everything else alone
*/ */
for (nlt= activeTrack->prev; nlt; nlt= nlt->prev) { for (nlt = activeTrack->prev; nlt; nlt = nlt->prev) {
for (strip= nlt->strips.first; strip; strip= strip->next) { for (strip = nlt->strips.first; strip; strip = strip->next) {
if (strip->act == activeStrip->act) if (strip->act == activeStrip->act)
strip->flag |= NLASTRIP_FLAG_TWEAKUSER; strip->flag |= NLASTRIP_FLAG_TWEAKUSER;
else 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 /* 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 * - 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; nlt->flag |= NLATRACK_DISABLED;
/* handle AnimData level changes: /* 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) * - 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 * - take note of the active strip for mapping-correction of keyframes in the action being edited
*/ */
adt->tmpact= adt->action; adt->tmpact = adt->action;
adt->action= activeStrip->act; adt->action = activeStrip->act;
adt->actstrip= activeStrip; adt->actstrip = activeStrip;
id_us_plus(&activeStrip->act->id); id_us_plus(&activeStrip->act->id);
adt->flag |= ADT_NLA_EDIT_ON; 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 Tracks, clear the 'disabled' flag
* for all Strips, clear the 'tweak-user' 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; 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; strip->flag &= ~NLASTRIP_FLAG_TWEAKUSER;
} }
@@ -1652,15 +1652,15 @@ void BKE_nla_tweakmode_exit(AnimData *adt)
* - clear pointer to active strip * - clear pointer to active strip
*/ */
if (adt->action) adt->action->id.us--; if (adt->action) adt->action->id.us--;
adt->action= adt->tmpact; adt->action = adt->tmpact;
adt->tmpact= NULL; adt->tmpact = NULL;
adt->actstrip= NULL; adt->actstrip = NULL;
adt->flag &= ~ADT_NLA_EDIT_ON; adt->flag &= ~ADT_NLA_EDIT_ON;
} }
/* Baking Tools ------------------------------------------- */ /* 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 /* verify that data is valid

View File

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

View File

@@ -55,7 +55,7 @@ void freeSketch(SK_Sketch *sketch)
MEM_freeN(sketch); MEM_freeN(sketch);
} }
SK_Sketch* createSketch(void) SK_Sketch *createSketch(void)
{ {
SK_Sketch *sketch; SK_Sketch *sketch;
@@ -101,7 +101,7 @@ void sk_freeStroke(SK_Stroke *stk)
MEM_freeN(stk); MEM_freeN(stk);
} }
SK_Stroke* sk_createStroke(void) SK_Stroke *sk_createStroke(void)
{ {
SK_Stroke *stk; SK_Stroke *stk;
@@ -261,13 +261,13 @@ void sk_polygonizeStroke(SK_Stroke *stk, int start, int end)
int i; int i;
/* find first exact points outside of range */ /* find first exact points outside of range */
for (;start > 0; start--) { for (; start > 0; start--) {
if (stk->points[start].type == PT_EXACT) { if (stk->points[start].type == PT_EXACT) {
break; break;
} }
} }
for (;end < stk->nb_points - 1; end++) { for (; end < stk->nb_points - 1; end++) {
if (stk->points[end].type == PT_EXACT) { if (stk->points[end].type == PT_EXACT) {
break; break;
} }
@@ -382,7 +382,7 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
work = 0; work = 0;
ls = start; ls = start;
le = start+1; le = start + 1;
/* while not over interval */ /* while not over interval */
while (ls < end) { 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]; 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 mul;
float dist; float dist;
short v2[2]; short v2[2];
@@ -412,9 +412,9 @@ void sk_filterStroke(SK_Stroke *stk, int start, int end)
continue; 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) { if (dist > max_dist) {
max_dist = dist; max_dist = dist;
@@ -457,7 +457,7 @@ void sk_filterLastContinuousStroke(SK_Stroke *stk)
{ {
int start, end; 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--) { for (start = end - 1; start > 0 && stk->points[start].type == PT_CONTINUOUS; start--) {
/* nothing to do here*/ /* 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) static int txttl_cmp(const char *first, const char *second, int len)
{ {
int cmp, i; int cmp, i;
for (cmp=0, i=0; i<len; i++) { for (cmp = 0, i = 0; i < len; i++) {
if ( (cmp= toupper(first[i])-toupper(second[i])) ) { if ( (cmp = toupper(first[i]) - toupper(second[i])) ) {
break; break;
} }
} }
@@ -61,7 +61,7 @@ static int txttl_cmp(const char *first, const char *second, int len)
static void txttl_free_suggest(void) static void txttl_free_suggest(void)
{ {
SuggItem *item, *prev; SuggItem *item, *prev;
for (item = suggestions.last; item; item=prev) { for (item = suggestions.last; item; item = prev) {
prev = item->prev; prev = item->prev;
MEM_freeN(item); MEM_freeN(item);
} }
@@ -104,7 +104,7 @@ void texttool_text_clear(void)
short texttool_text_is_active(Text *text) 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 { else {
cmp = -1; 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); cmp = txttl_cmp(name, item->name, len);
/* Newitem comes after this item, insert here */ /* 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.firstmatch = suggestions.lastmatch = suggestions.selected = NULL;
suggestions.top= 0; suggestions.top = 0;
} }
void texttool_suggest_prefix(const char *prefix) 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; int cmp, len = strlen(prefix), top = 0;
if (!suggestions.first) return; if (!suggestions.first) return;
if (len==0) { if (len == 0) {
suggestions.selected = suggestions.firstmatch = suggestions.first; suggestions.selected = suggestions.firstmatch = suggestions.first;
suggestions.lastmatch = suggestions.last; suggestions.lastmatch = suggestions.last;
return; return;
} }
first = last = NULL; 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); cmp = txttl_cmp(prefix, match->name, len);
if (cmp==0) { if (cmp == 0) {
if (!first) { if (!first) {
first = match; first = match;
suggestions.top = top; suggestions.top = top;
} }
} }
else if (cmp<0) { else if (cmp < 0) {
if (!last) { if (!last) {
last = match->prev; last = match->prev;
break; break;
@@ -254,13 +254,13 @@ void texttool_docs_show(const char *docs)
} }
/* Ensure documentation ends with a '\n' */ /* Ensure documentation ends with a '\n' */
if (docs[len-1] != '\n') { if (docs[len - 1] != '\n') {
documentation = MEM_mallocN(len+2, "Documentation"); documentation = MEM_mallocN(len + 2, "Documentation");
strncpy(documentation, docs, len); strncpy(documentation, docs, len);
documentation[len++] = '\n'; documentation[len++] = '\n';
} }
else { else {
documentation = MEM_mallocN(len+1, "Documentation"); documentation = MEM_mallocN(len + 1, "Documentation");
strncpy(documentation, docs, len); strncpy(documentation, docs, len);
} }
documentation[len] = '\0'; documentation[len] = '\0';

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -79,52 +79,52 @@
#include <sys/stat.h> /* file permissions */ #include <sys/stat.h> /* file permissions */
#endif /* __APPLE__ */ #endif /* __APPLE__ */
#define kMyCreatorType FOUR_CHAR_CODE('TVOD') #define kMyCreatorType FOUR_CHAR_CODE('TVOD')
#define kTrackStart 0 #define kTrackStart 0
#define kMediaStart 0 #define kMediaStart 0
static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, int recty, 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_DoAddVideoSamplesToMedia(int frame, int *pixels, int rectx, int recty, struct ReportList *reports);
static void QT_EndAddVideoSamplesToMedia (void); static void QT_EndAddVideoSamplesToMedia(void);
static void QT_CreateMyVideoTrack (int rectx, int recty, struct ReportList *reports); static void QT_CreateMyVideoTrack(int rectx, int recty, struct ReportList *reports);
static void QT_EndCreateMyVideoTrack (struct ReportList *reports); static void QT_EndCreateMyVideoTrack(struct ReportList *reports);
static void check_renderbutton_framerate(struct RenderData *rd, 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); static int get_qtcodec_settings(struct RenderData *rd, struct ReportList *reports);
typedef struct QuicktimeExport { typedef struct QuicktimeExport {
FSSpec theSpec; FSSpec theSpec;
short resRefNum; short resRefNum;
Str255 qtfilename; Str255 qtfilename;
Media theMedia; Media theMedia;
Movie theMovie; Movie theMovie;
Track theTrack; Track theTrack;
GWorldPtr theGWorld; GWorldPtr theGWorld;
PixMapHandle thePixMap; PixMapHandle thePixMap;
ImageDescription **anImageDescription; ImageDescription **anImageDescription;
ImBuf *ibuf; //imagedata for Quicktime's Gworld ImBuf *ibuf; //imagedata for Quicktime's Gworld
ImBuf *ibuf2; //copy of renderdata, to be Y-flipped ImBuf *ibuf2; //copy of renderdata, to be Y-flipped
} QuicktimeExport; } QuicktimeExport;
typedef struct QuicktimeComponentData { typedef struct QuicktimeComponentData {
ComponentInstance theComponent; ComponentInstance theComponent;
SCTemporalSettings gTemporalSettings; SCTemporalSettings gTemporalSettings;
SCSpatialSettings gSpatialSettings; SCSpatialSettings gSpatialSettings;
SCDataRateSettings aDataRateSetting; SCDataRateSettings aDataRateSetting;
TimeValue duration; TimeValue duration;
long kVideoTimeScale; long kVideoTimeScale;
} QuicktimeComponentData; } QuicktimeComponentData;
static struct QuicktimeExport *qtexport; static struct QuicktimeExport *qtexport;
static struct QuicktimeComponentData *qtdata; static struct QuicktimeComponentData *qtdata;
static int sframe; static int sframe;
/* RNA functions */ /* RNA functions */
@@ -141,7 +141,8 @@ static QuicktimeCodecTypeDesc qtVideoCodecList[] = {
{kMPEG4VisualCodecType, 10, "MPEG4"}, {kMPEG4VisualCodecType, 10, "MPEG4"},
{kH263CodecType, 11, "H.263"}, {kH263CodecType, 11, "H.263"},
{kH264CodecType, 12, "H.264"}, {kH264CodecType, 12, "H.264"},
{0, 0, NULL}}; {0, 0, NULL}
};
static int qtVideoCodecCount = 12; static int qtVideoCodecCount = 12;
@@ -150,9 +151,9 @@ int quicktime_get_num_videocodecs()
return qtVideoCodecCount; 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]; return &qtVideoCodecList[indexValue];
else else
return NULL; return NULL;
@@ -161,7 +162,7 @@ QuicktimeCodecTypeDesc* quicktime_get_videocodecType_desc(int indexValue)
int quicktime_rnatmpvalue_from_videocodectype(int codecType) int quicktime_rnatmpvalue_from_videocodectype(int codecType)
{ {
int i; int i;
for (i=0;i<qtVideoCodecCount;i++) { for (i = 0; i < qtVideoCodecCount; i++) {
if (qtVideoCodecList[i].codecType == codecType) if (qtVideoCodecList[i].codecType == codecType)
return qtVideoCodecList[i].rnatmpvalue; return qtVideoCodecList[i].rnatmpvalue;
} }
@@ -172,7 +173,7 @@ int quicktime_rnatmpvalue_from_videocodectype(int codecType)
int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue) int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue)
{ {
int i; int i;
for (i=0;i<qtVideoCodecCount;i++) { for (i = 0; i < qtVideoCodecCount; i++) {
if (qtVideoCodecList[i].rnatmpvalue == rnatmpvalue) if (qtVideoCodecList[i].rnatmpvalue == rnatmpvalue)
return qtVideoCodecList[i].codecType; return qtVideoCodecList[i].codecType;
} }
@@ -192,12 +193,12 @@ static void CheckError(OSErr err, char *msg, ReportList *reports)
static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports) static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports)
{ {
QTAtomContainer myContainer = NULL; QTAtomContainer myContainer = NULL;
ComponentResult myErr = noErr; ComponentResult myErr = noErr;
Ptr myPtr; Ptr myPtr;
long mySize = 0; long mySize = 0;
CodecInfo ci; CodecInfo ci;
QuicktimeCodecData *qcd = rd->qtcodecdata; QuicktimeCodecData *qcd = rd->qtcodecdata;
@@ -210,9 +211,9 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports)
} }
// obtain all current codec settings // obtain all current codec settings
SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
// retreive codecdata from quicktime in a atomcontainer // retreive codecdata from quicktime in a atomcontainer
myErr = SCGetSettingsAsAtomContainer(qtdata->theComponent, &myContainer); myErr = SCGetSettingsAsAtomContainer(qtdata->theComponent, &myContainer);
@@ -234,7 +235,7 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports)
memcpy(qcd->cdParms, myPtr, mySize); memcpy(qcd->cdParms, myPtr, mySize);
qcd->cdSize = mySize; qcd->cdSize = mySize;
GetCodecInfo (&ci, qtdata->gSpatialSettings.codecType, 0); GetCodecInfo(&ci, qtdata->gSpatialSettings.codecType, 0);
} }
else { else {
BKE_reportf(reports, RPT_ERROR, "Quicktime: QT_SaveCodecSettingsToScene failed\n"); BKE_reportf(reports, RPT_ERROR, "Quicktime: QT_SaveCodecSettingsToScene failed\n");
@@ -252,8 +253,8 @@ bail:
static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports) static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports)
{ {
Handle myHandle = NULL; Handle myHandle = NULL;
ComponentResult myErr = noErr; ComponentResult myErr = noErr;
QuicktimeCodecData *qcd = rd->qtcodecdata; QuicktimeCodecData *qcd = rd->qtcodecdata;
@@ -272,9 +273,9 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports)
} }
// update runtime codecsettings for use with the codec dialog // update runtime codecsettings for use with the codec dialog
SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
//Fill the render QuicktimeCodecSettigns struct //Fill the render QuicktimeCodecSettigns struct
@@ -304,12 +305,12 @@ bail:
} }
static OSErr QT_AddUserDataTextToMovie (Movie theMovie, char *theText, OSType theType) static OSErr QT_AddUserDataTextToMovie(Movie theMovie, char *theText, OSType theType)
{ {
UserData myUserData = NULL; UserData myUserData = NULL;
Handle myHandle = NULL; Handle myHandle = NULL;
long myLength = strlen(theText); long myLength = strlen(theText);
OSErr myErr = noErr; OSErr myErr = noErr;
// get the movie's user data list // get the movie's user data list
myUserData = GetMovieUserData(theMovie); myUserData = GetMovieUserData(theMovie);
@@ -343,10 +344,10 @@ static void QT_CreateMyVideoTrack(int rectx, int recty, ReportList *reports)
trackFrame.bottom = recty; trackFrame.bottom = recty;
trackFrame.right = rectx; trackFrame.right = rectx;
qtexport->theTrack = NewMovieTrack (qtexport->theMovie, qtexport->theTrack = NewMovieTrack(qtexport->theMovie,
FixRatio(trackFrame.right, 1), FixRatio(trackFrame.right, 1),
FixRatio(trackFrame.bottom, 1), FixRatio(trackFrame.bottom, 1),
0); 0);
CheckError(GetMoviesError(), "NewMovieTrack error", reports); CheckError(GetMoviesError(), "NewMovieTrack error", reports);
// SetIdentityMatrix(&myMatrix); // SetIdentityMatrix(&myMatrix);
@@ -354,17 +355,17 @@ static void QT_CreateMyVideoTrack(int rectx, int recty, ReportList *reports)
// TranslateMatrix(&myMatrix, 0, Long2Fix(trackFrame.bottom)); // TranslateMatrix(&myMatrix, 0, Long2Fix(trackFrame.bottom));
// SetMovieMatrix(qtexport->theMovie, &myMatrix); // SetMovieMatrix(qtexport->theMovie, &myMatrix);
qtexport->theMedia = NewTrackMedia (qtexport->theTrack, qtexport->theMedia = NewTrackMedia(qtexport->theTrack,
VideoMediaType, VideoMediaType,
qtdata->kVideoTimeScale, qtdata->kVideoTimeScale,
nil, nil,
0); 0);
CheckError(GetMoviesError(), "NewTrackMedia error", reports); CheckError(GetMoviesError(), "NewTrackMedia error", reports);
err = BeginMediaEdits (qtexport->theMedia); err = BeginMediaEdits(qtexport->theMedia);
CheckError(err, "BeginMediaEdits error", reports); 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; OSErr err = noErr;
QT_EndAddVideoSamplesToMedia (); QT_EndAddVideoSamplesToMedia();
err = EndMediaEdits (qtexport->theMedia); err = EndMediaEdits(qtexport->theMedia);
CheckError(err, "EndMediaEdits error", reports); CheckError(err, "EndMediaEdits error", reports);
err = InsertMediaIntoTrack (qtexport->theTrack, err = InsertMediaIntoTrack(qtexport->theTrack,
kTrackStart, /* track start time */ kTrackStart, /* track start time */
kMediaStart, /* media start time */ kMediaStart, /* media start time */
GetMediaDuration (qtexport->theMedia), GetMediaDuration(qtexport->theMedia),
fixed1); fixed1);
CheckError(err, "InsertMediaIntoTrack error", reports); 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; SCTemporalSettings gTemporalSettings;
OSErr err = noErr; OSErr err = noErr;
qtexport->ibuf = 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); qtexport->ibuf2 = IMB_allocImBuf(rectx, recty, 32, IB_rect);
err = NewGWorldFromPtr( &qtexport->theGWorld, err = NewGWorldFromPtr(&qtexport->theGWorld,
k32ARGBPixelFormat, k32ARGBPixelFormat,
trackFrame, trackFrame,
NULL, NULL, 0, NULL, NULL, 0,
(Ptr)qtexport->ibuf->rect, (Ptr)qtexport->ibuf->rect,
rectx * 4 ); rectx * 4);
CheckError (err, "NewGWorldFromPtr error", reports); CheckError(err, "NewGWorldFromPtr error", reports);
qtexport->thePixMap = GetGWorldPixMap(qtexport->theGWorld); qtexport->thePixMap = GetGWorldPixMap(qtexport->theGWorld);
LockPixels(qtexport->thePixMap); 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 // workaround for crash with H.264, which requires an upgrade to
// the new callback based api for proper encoding, but that's not // the new callback based api for proper encoding, but that's not
@@ -418,32 +419,32 @@ static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, i
} }
} }
SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &gTemporalSettings); SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &gTemporalSettings);
SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
err = SCCompressSequenceBegin(qtdata->theComponent, qtexport->thePixMap, NULL, &qtexport->anImageDescription); 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; OSErr err = noErr;
Rect imageRect; Rect imageRect;
int index; int index;
int boxsize; int boxsize;
unsigned char *from, *to; unsigned char *from, *to;
short syncFlag; short syncFlag;
long dataSize; long dataSize;
Handle compressedData; Handle compressedData;
Ptr myPtr; Ptr myPtr;
//copy and flip renderdata //copy and flip renderdata
memcpy(qtexport->ibuf2->rect, pixels, 4*rectx*recty); memcpy(qtexport->ibuf2->rect, pixels, 4 * rectx * recty);
IMB_flipy(qtexport->ibuf2); IMB_flipy(qtexport->ibuf2);
//get pointers to parse bitmapdata //get pointers to parse bitmapdata
@@ -455,42 +456,42 @@ static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int
//parse RGBA bitmap into Quicktime's ARGB GWorld //parse RGBA bitmap into Quicktime's ARGB GWorld
boxsize = rectx * recty; boxsize = rectx * recty;
for ( index = 0; index < boxsize; index++) { for (index = 0; index < boxsize; index++) {
to[0] = from[3]; to[0] = from[3];
to[1] = from[0]; to[1] = from[0];
to[2] = from[1]; to[2] = from[1];
to[3] = from[2]; to[3] = from[2];
to +=4, from += 4; to += 4, from += 4;
} }
err = SCCompressSequenceFrame(qtdata->theComponent, err = SCCompressSequenceFrame(qtdata->theComponent,
qtexport->thePixMap, qtexport->thePixMap,
&imageRect, &imageRect,
&compressedData, &compressedData,
&dataSize, &dataSize,
&syncFlag); &syncFlag);
CheckError(err, "SCCompressSequenceFrame error", reports); CheckError(err, "SCCompressSequenceFrame error", reports);
err = AddMediaSample(qtexport->theMedia, err = AddMediaSample(qtexport->theMedia,
compressedData, compressedData,
0, 0,
dataSize, dataSize,
qtdata->duration, qtdata->duration,
(SampleDescriptionHandle)qtexport->anImageDescription, (SampleDescriptionHandle)qtexport->anImageDescription,
1, 1,
syncFlag, syncFlag,
NULL); NULL);
CheckError(err, "AddMediaSample error", reports); CheckError(err, "AddMediaSample error", reports);
} }
static void QT_EndAddVideoSamplesToMedia (void) static void QT_EndAddVideoSamplesToMedia(void)
{ {
SCCompressSequenceEnd(qtdata->theComponent); SCCompressSequenceEnd(qtdata->theComponent);
UnlockPixels(qtexport->thePixMap); UnlockPixels(qtexport->thePixMap);
if (qtexport->theGWorld) if (qtexport->theGWorld)
DisposeGWorld (qtexport->theGWorld); DisposeGWorld(qtexport->theGWorld);
if (qtexport->ibuf) if (qtexport->ibuf)
IMB_freeImBuf(qtexport->ibuf); IMB_freeImBuf(qtexport->ibuf);
@@ -504,7 +505,7 @@ void filepath_qt(char *string, RenderData *rd)
{ {
char txt[64]; char txt[64];
if (string==0) return; if (string == 0) return;
strcpy(string, rd->pic); strcpy(string, rd->pic);
BLI_path_abs(string, G.main->name); BLI_path_abs(string, G.main->name);
@@ -526,12 +527,12 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
char theFullPath[255]; char theFullPath[255];
#ifdef __APPLE__ #ifdef __APPLE__
int myFile; int myFile;
FSRef myRef; FSRef myRef;
#else #else
char *qtname; char *qtname;
#endif #endif
int success= 1; int success = 1;
if (qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport"); 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); sprintf(theFullPath, "%s", name);
/* hack: create an empty file to make FSPathMakeRef() happy */ /* 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) { if (myFile < 0) {
BKE_reportf(reports, RPT_ERROR, "error while creating movie file!\n"); BKE_reportf(reports, RPT_ERROR, "error while creating movie file!\n");
/* do something? */ /* 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); err = FSMakeFSSpec(0, 0L, qtexport->qtfilename, &qtexport->theSpec);
#endif #endif
err = CreateMovieFile (&qtexport->theSpec, err = CreateMovieFile(&qtexport->theSpec,
kMyCreatorType, kMyCreatorType,
smCurrentScript, smCurrentScript,
createMovieFileDeleteCurFile | createMovieFileDontCreateResFile, createMovieFileDeleteCurFile | createMovieFileDontCreateResFile,
&qtexport->resRefNum, &qtexport->resRefNum,
&qtexport->theMovie ); &qtexport->theMovie);
CheckError(err, "CreateMovieFile error", reports); CheckError(err, "CreateMovieFile error", reports);
if (err != noErr) { if (err != noErr) {
BKE_reportf(reports, RPT_ERROR, "Unable to create Quicktime movie: %s", name); BKE_reportf(reports, RPT_ERROR, "Unable to create Quicktime movie: %s", name);
success= 0; success = 0;
#ifdef __APPLE__ #ifdef __APPLE__
ExitMoviesOnThread(); ExitMoviesOnThread();
#endif #endif
@@ -622,7 +623,7 @@ void end_qt(void)
if (qtexport->theMovie) { if (qtexport->theMovie) {
QT_EndCreateMyVideoTrack(NULL); 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); CheckError(err, "AddMovieResource error", NULL);
err = QT_AddUserDataTextToMovie(qtexport->theMovie, "Made with Blender", kUserDataTextInformation); err = QT_AddUserDataTextToMovie(qtexport->theMovie, "Made with Blender", kUserDataTextInformation);
@@ -639,7 +640,7 @@ void end_qt(void)
} }
#ifdef __APPLE__ #ifdef __APPLE__
ExitMoviesOnThread(); ExitMoviesOnThread();
#endif #endif
if (qtexport) { if (qtexport) {
@@ -662,36 +663,36 @@ void free_qtcomponentdata(void)
static void check_renderbutton_framerate(RenderData *rd, ReportList *reports) static void check_renderbutton_framerate(RenderData *rd, ReportList *reports)
{ {
// to keep float framerates consistent between the codec dialog and frs/sec button. // to keep float framerates consistent between the codec dialog and frs/sec button.
OSErr err; OSErr err;
err = SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); err = SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
CheckError(err, "SCGetInfo fr error", reports); CheckError(err, "SCGetInfo fr error", reports);
if ( (rd->frs_sec == 24 || rd->frs_sec == 30 || rd->frs_sec == 60) && if ( (rd->frs_sec == 24 || rd->frs_sec == 30 || rd->frs_sec == 60) &&
(qtdata->gTemporalSettings.frameRate == 1571553 || (qtdata->gTemporalSettings.frameRate == 1571553 ||
qtdata->gTemporalSettings.frameRate == 1964113 || qtdata->gTemporalSettings.frameRate == 1964113 ||
qtdata->gTemporalSettings.frameRate == 3928227)) qtdata->gTemporalSettings.frameRate == 3928227))
{ {
/* do nothing */ /* do nothing */
} }
else { else {
if (rd->frs_sec_base > 0) if (rd->frs_sec_base > 0)
qtdata->gTemporalSettings.frameRate = qtdata->gTemporalSettings.frameRate =
((float)(rd->frs_sec << 16) / rd->frs_sec_base); ((float)(rd->frs_sec << 16) / rd->frs_sec_base);
} }
err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
CheckError(err, "SCSetInfo error", reports); CheckError(err, "SCSetInfo error", reports);
if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps
qtdata->kVideoTimeScale = 24000; qtdata->kVideoTimeScale = 24000;
qtdata->duration = 1001; qtdata->duration = 1001;
} }
else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps
qtdata->kVideoTimeScale = 30000; qtdata->kVideoTimeScale = 30000;
qtdata->duration = 1001; qtdata->duration = 1001;
} }
else if (qtdata->gTemporalSettings.frameRate == 3928227) { // 59.94 fps else if (qtdata->gTemporalSettings.frameRate == 3928227) { // 59.94 fps
qtdata->kVideoTimeScale = 60000; qtdata->kVideoTimeScale = 60000;
qtdata->duration = 1001; qtdata->duration = 1001;
} }
@@ -704,14 +705,14 @@ static void check_renderbutton_framerate(RenderData *rd, ReportList *reports)
void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf) void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf)
{ {
if (imf->imtype == R_IMF_IMTYPE_QUICKTIME) { if (imf->imtype == R_IMF_IMTYPE_QUICKTIME) {
if ((rd->qtcodecsettings.codecType== 0) || if ((rd->qtcodecsettings.codecType == 0) ||
(rd->qtcodecsettings.codecSpatialQuality <0) || (rd->qtcodecsettings.codecSpatialQuality < 0) ||
(rd->qtcodecsettings.codecSpatialQuality > 100)) { (rd->qtcodecsettings.codecSpatialQuality > 100)) {
rd->qtcodecsettings.codecType = kJPEGCodecType; rd->qtcodecsettings.codecType = kJPEGCodecType;
rd->qtcodecsettings.codec = (int)anyCodec; rd->qtcodecsettings.codec = (int)anyCodec;
rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality*100)/codecLosslessQuality; rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality * 100) / codecLosslessQuality;
rd->qtcodecsettings.codecTemporalQuality = (codecHighQuality*100)/codecLosslessQuality; rd->qtcodecsettings.codecTemporalQuality = (codecHighQuality * 100) / codecLosslessQuality;
rd->qtcodecsettings.keyFrameRate = 25; rd->qtcodecsettings.keyFrameRate = 25;
rd->qtcodecsettings.bitRate = 5000000; //5 Mbps rd->qtcodecsettings.bitRate = 5000000; //5 Mbps
} }
@@ -721,7 +722,7 @@ void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf)
int get_qtcodec_settings(RenderData *rd, ReportList *reports) int get_qtcodec_settings(RenderData *rd, ReportList *reports)
{ {
OSErr err = noErr; OSErr err = noErr;
// erase any existing codecsetting // erase any existing codecsetting
if (qtdata) { if (qtdata) {
if (qtdata->theComponent) CloseComponent(qtdata->theComponent); if (qtdata->theComponent) CloseComponent(qtdata->theComponent);
free_qtcomponentdata(); free_qtcomponentdata();
@@ -736,14 +737,14 @@ int get_qtcodec_settings(RenderData *rd, ReportList *reports)
QT_GetCodecSettingsFromScene(rd, reports); QT_GetCodecSettingsFromScene(rd, reports);
} }
else { else {
SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType; qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType;
qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec; qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec;
qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) /100; qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) / 100;
qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) /100; qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) / 100;
qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate; qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate;
qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate; qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate;
qtdata->gSpatialSettings.depth = rd->qtcodecsettings.colorDepth; qtdata->gSpatialSettings.depth = rd->qtcodecsettings.colorDepth;
@@ -751,14 +752,14 @@ int get_qtcodec_settings(RenderData *rd, ReportList *reports)
qtdata->aDataRateSetting.minTemporalQuality = (rd->qtcodecsettings.minTemporalQuality * codecLosslessQuality) / 100; qtdata->aDataRateSetting.minTemporalQuality = (rd->qtcodecsettings.minTemporalQuality * codecLosslessQuality) / 100;
qtdata->aDataRateSetting.frameDuration = rd->frs_sec; 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); err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
CheckError(err, "SCSetInfo1 error", reports); CheckError(err, "SCSetInfo1 error", reports);
err = SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); err = SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
CheckError(err, "SCSetInfo2 error", reports); CheckError(err, "SCSetInfo2 error", reports);
err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
CheckError(err, "SCSetInfo3 error", reports); CheckError(err, "SCSetInfo3 error", reports);
} }
@@ -769,7 +770,7 @@ int get_qtcodec_settings(RenderData *rd, ReportList *reports)
static int request_qtcodec_settings(bContext *C, wmOperator *op) static int request_qtcodec_settings(bContext *C, wmOperator *op)
{ {
OSErr err = noErr; OSErr err = noErr;
Scene *scene = CTX_data_scene(C); Scene *scene = CTX_data_scene(C);
RenderData *rd = &scene->r; RenderData *rd = &scene->r;
@@ -788,14 +789,14 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
QT_GetCodecSettingsFromScene(rd, op->reports); QT_GetCodecSettingsFromScene(rd, op->reports);
} }
else { else {
SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType; qtdata->gSpatialSettings.codecType = rd->qtcodecsettings.codecType;
qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec; qtdata->gSpatialSettings.codec = (CodecComponent)rd->qtcodecsettings.codec;
qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) /100; qtdata->gSpatialSettings.spatialQuality = (rd->qtcodecsettings.codecSpatialQuality * codecLosslessQuality) / 100;
qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) /100; qtdata->gTemporalSettings.temporalQuality = (rd->qtcodecsettings.codecTemporalQuality * codecLosslessQuality) / 100;
qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate; qtdata->gTemporalSettings.keyFrameRate = rd->qtcodecsettings.keyFrameRate;
qtdata->gTemporalSettings.frameRate = ((float)(rd->frs_sec << 16) / rd->frs_sec_base); qtdata->gTemporalSettings.frameRate = ((float)(rd->frs_sec << 16) / rd->frs_sec_base);
qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate; qtdata->aDataRateSetting.dataRate = rd->qtcodecsettings.bitRate;
@@ -805,29 +806,29 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
qtdata->aDataRateSetting.frameDuration = rd->frs_sec; qtdata->aDataRateSetting.frameDuration = rd->frs_sec;
err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
CheckError(err, "SCSetInfo1 error", op->reports); CheckError(err, "SCSetInfo1 error", op->reports);
err = SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); err = SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
CheckError(err, "SCSetInfo2 error", op->reports); CheckError(err, "SCSetInfo2 error", op->reports);
err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
CheckError(err, "SCSetInfo3 error", op->reports); CheckError(err, "SCSetInfo3 error", op->reports);
} }
// put up the dialog box - it needs to be called from the main thread // put up the dialog box - it needs to be called from the main thread
err = SCRequestSequenceSettings(qtdata->theComponent); err = SCRequestSequenceSettings(qtdata->theComponent);
if (err == scUserCancelled) { if (err == scUserCancelled) {
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
// update runtime codecsettings for use with the codec dialog // update runtime codecsettings for use with the codec dialog
SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
//Fill the render QuicktimeCodecSettings struct //Fill the render QuicktimeCodecSettings struct
rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality; rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality;
//Do not override scene frame rate (qtdata->gTemporalSettings.framerate) //Do not override scene frame rate (qtdata->gTemporalSettings.framerate)
rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate; rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate;
rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType; rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType;
@@ -838,26 +839,26 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate; rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate;
rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality; rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality;
rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality; rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality;
//Frame duration is already known (qtdata->aDataRateSetting.frameDuration) //Frame duration is already known (qtdata->aDataRateSetting.frameDuration)
QT_SaveCodecSettingsToScene(rd, op->reports); QT_SaveCodecSettingsToScene(rd, op->reports);
// framerate jugglin' // framerate jugglin'
if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps
qtdata->kVideoTimeScale = 24000; qtdata->kVideoTimeScale = 24000;
qtdata->duration = 1001; qtdata->duration = 1001;
rd->frs_sec = 24; rd->frs_sec = 24;
rd->frs_sec_base = 1.001; rd->frs_sec_base = 1.001;
} }
else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps
qtdata->kVideoTimeScale = 30000; qtdata->kVideoTimeScale = 30000;
qtdata->duration = 1001; qtdata->duration = 1001;
rd->frs_sec = 30; rd->frs_sec = 30;
rd->frs_sec_base = 1.001; rd->frs_sec_base = 1.001;
} }
else if (qtdata->gTemporalSettings.frameRate == 3928227) { // 59.94 fps else if (qtdata->gTemporalSettings.frameRate == 3928227) { // 59.94 fps
qtdata->kVideoTimeScale = 60000; qtdata->kVideoTimeScale = 60000;
qtdata->duration = 1001; qtdata->duration = 1001;
@@ -917,7 +918,7 @@ void SCENE_OT_render_data_set_quicktime_codec(wmOperatorType *ot)
ot->poll = ED_operator_setqtcodec; ot->poll = ED_operator_setqtcodec;
/* flags */ /* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
} }
#endif /* USE_QTKIT */ #endif /* USE_QTKIT */

View File

@@ -58,35 +58,35 @@
#include "quicktime_import.h" #include "quicktime_import.h"
#include "quicktime_export.h" #include "quicktime_export.h"
#define RECT_WIDTH(r) (r.right-r.left) #define RECT_WIDTH(r) (r.right - r.left)
#define RECT_HEIGHT(r) (r.bottom-r.top) #define RECT_HEIGHT(r) (r.bottom - r.top)
#define QTIME_DEBUG 0 #define QTIME_DEBUG 0
typedef struct _QuicktimeMovie { typedef struct _QuicktimeMovie {
GWorldPtr offscreenGWorld; GWorldPtr offscreenGWorld;
PixMapHandle offscreenPixMap; PixMapHandle offscreenPixMap;
Movie movie; Movie movie;
Rect movieBounds; Rect movieBounds;
short movieRefNum; short movieRefNum;
short movieResId; short movieResId;
int movWidth, movHeight; int movWidth, movHeight;
int framecount; int framecount;
ImBuf *ibuf; ImBuf *ibuf;
TimeValue *frameIndex; TimeValue *frameIndex;
Media theMedia; Media theMedia;
Track theTrack; Track theTrack;
long trackIndex; long trackIndex;
short depth; short depth;
int have_gw; //ugly int have_gw; /* ugly */
} QuicktimeMovie; } QuicktimeMovie;
@@ -105,7 +105,7 @@ void quicktime_init(void)
#endif /* _WIN32 */ #endif /* _WIN32 */
/* Initialize QuickTime */ /* Initialize QuickTime */
#if defined(_WIN32) || defined (__APPLE__) #if defined(_WIN32) || defined(__APPLE__)
nerr = EnterMovies(); nerr = EnterMovies();
if (nerr != noErr) if (nerr != noErr)
G.have_quicktime = FALSE; G.have_quicktime = FALSE;
@@ -113,7 +113,7 @@ void quicktime_init(void)
#endif /* _WIN32 || __APPLE__ */ #endif /* _WIN32 || __APPLE__ */
#ifdef __linux__ #ifdef __linux__
/* inititalize quicktime codec registry */ /* inititalize quicktime codec registry */
lqt_registry_init(); lqt_registry_init();
#endif #endif
G.have_quicktime = TRUE; G.have_quicktime = TRUE;
} }
@@ -141,7 +141,7 @@ char *get_valid_qtname(char *name)
TCHAR Buffer[MAX_PATH]; TCHAR Buffer[MAX_PATH];
DWORD dwRet; DWORD dwRet;
char *qtname; char *qtname;
DynStr *ds= BLI_dynstr_new(); DynStr *ds = BLI_dynstr_new();
dwRet = GetCurrentDirectory(MAX_PATH, Buffer); dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
@@ -166,7 +166,7 @@ char *get_valid_qtname(char *name)
BLI_dynstr_append(ds, name); BLI_dynstr_append(ds, name);
} }
qtname= BLI_dynstr_get_cstring(ds); qtname = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds); BLI_dynstr_free(ds);
return qtname; return qtname;
@@ -176,33 +176,33 @@ char *get_valid_qtname(char *name)
int anim_is_quicktime(const char *name) int anim_is_quicktime(const char *name)
{ {
FSSpec theFSSpec; FSSpec theFSSpec;
char theFullPath[255]; char theFullPath[255];
Boolean isMovieFile = false; Boolean isMovieFile = false;
AliasHandle myAlias = NULL; AliasHandle myAlias = NULL;
Component myImporter = NULL; Component myImporter = NULL;
#ifdef __APPLE__ #ifdef __APPLE__
FInfo myFinderInfo; FInfo myFinderInfo;
FSRef myRef; FSRef myRef;
#else #else
char *qtname; char *qtname;
Str255 dst; Str255 dst;
#endif #endif
OSErr err = noErr; OSErr err = noErr;
// don't let quicktime movie import handle these // 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, ".txt") ||
BLI_testextensie(name, ".mpg") || 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, ".tga") ||
BLI_testextensie(name, ".png") || BLI_testextensie(name, ".png") ||
BLI_testextensie(name, ".bmp") || BLI_testextensie(name, ".bmp") ||
BLI_testextensie(name, ".jpg") || BLI_testextensie(name, ".jpg") ||
BLI_testextensie(name, ".wav") || BLI_testextensie(name, ".wav") ||
BLI_testextensie(name, ".zip") || BLI_testextensie(name, ".zip") ||
BLI_testextensie(name, ".mp3")) BLI_testextensie(name, ".mp3"))
{ {
return 0; return 0;
} }
@@ -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; isMovieFile = true;
} }
@@ -268,8 +268,8 @@ void free_anim_quicktime(struct anim *anim)
DisposeMovie(anim->qtime->movie); DisposeMovie(anim->qtime->movie);
CloseMovieFile(anim->qtime->movieRefNum); CloseMovieFile(anim->qtime->movieRefNum);
if (anim->qtime->frameIndex) MEM_freeN (anim->qtime->frameIndex); if (anim->qtime->frameIndex) MEM_freeN(anim->qtime->frameIndex);
if (anim->qtime) MEM_freeN (anim->qtime); if (anim->qtime) MEM_freeN(anim->qtime);
anim->qtime = NULL; anim->qtime = NULL;
@@ -280,17 +280,17 @@ void free_anim_quicktime(struct anim *anim)
static OSErr QT_get_frameIndexes(struct anim *anim) static OSErr QT_get_frameIndexes(struct anim *anim)
{ {
int i; int i;
OSErr anErr = noErr; OSErr anErr = noErr;
OSType media = VideoMediaType; OSType media = VideoMediaType;
TimeValue nextTime = 0; TimeValue nextTime = 0;
TimeValue startPoint; TimeValue startPoint;
TimeValue tmpstartPoint; TimeValue tmpstartPoint;
long sampleCount = 0; long sampleCount = 0;
startPoint = -1; 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); 1, &startPoint, NULL);
tmpstartPoint = startPoint; tmpstartPoint = startPoint;
@@ -320,16 +320,16 @@ 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; PixMapHandle myPixMap = NULL;
Ptr myPtr; Ptr myPtr;
register int index; register int index;
register int boxsize; register int boxsize;
register uint32_t *readPos; register uint32_t *readPos;
register uint32_t *changePos; register uint32_t *changePos;
ImBuf *ibuf = NULL; ImBuf *ibuf = NULL;
unsigned int *rect; unsigned int *rect;
@@ -344,7 +344,7 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
return (NULL); 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; rect = ibuf->rect;
SetMovieTimeValue(anim->qtime->movie, anim->qtime->frameIndex[position]); SetMovieTimeValue(anim->qtime->movie, anim->qtime->frameIndex[position]);
@@ -356,8 +356,8 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
myPtr = GetPixBaseAddr(myPixMap); myPtr = GetPixBaseAddr(myPixMap);
if (myPtr == NULL) { if (myPtr == NULL) {
printf ("Error reading frame from Quicktime"); printf("Error reading frame from Quicktime");
IMB_freeImBuf (ibuf); IMB_freeImBuf(ibuf);
return NULL; return NULL;
} }
@@ -367,10 +367,10 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
#ifdef __APPLE__ #ifdef __APPLE__
// Swap alpha byte to the end, so ARGB become RGBA; // Swap alpha byte to the end, so ARGB become RGBA;
from= (unsigned char *)readPos; from = (unsigned char *)readPos;
to= (unsigned char *)changePos; 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[3] = from[0];
to[0] = from[1]; to[0] = from[1];
to[1] = from[2]; to[1] = from[2];
@@ -379,14 +379,14 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
for ( index = 0; index < boxsize; index++, changePos++, readPos++ ) for (index = 0; index < boxsize; index++, changePos++, readPos++)
*( changePos ) = *(readPos ); *(changePos) = *(readPos);
if (anim->qtime->depth < 32) { if (anim->qtime->depth < 32) {
//add alpha to ibuf //add alpha to ibuf
boxsize = anim->x * anim->y * 4; boxsize = anim->x * anim->y * 4;
crect = (unsigned char *) rect; 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; crect[3] = 0xFF;
} }
} }
@@ -403,12 +403,12 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
static int GetFirstVideoMedia(struct anim *anim) static int GetFirstVideoMedia(struct anim *anim)
{ {
long numTracks; long numTracks;
OSType mediaType; OSType mediaType;
numTracks = GetMovieTrackCount(anim->qtime->movie); 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); anim->qtime->theTrack = GetMovieIndTrack(anim->qtime->movie, anim->qtime->trackIndex);
if (anim->qtime->theTrack) if (anim->qtime->theTrack)
@@ -425,7 +425,7 @@ static int GetFirstVideoMedia(struct anim *anim)
static short GetFirstVideoTrackPixelDepth(struct anim *anim) static short GetFirstVideoTrackPixelDepth(struct anim *anim)
{ {
SampleDescriptionHandle imageDescH = (SampleDescriptionHandle)NewHandle(sizeof(Handle)); SampleDescriptionHandle imageDescH = (SampleDescriptionHandle)NewHandle(sizeof(Handle));
// long trackIndex = 0; /*unused*/ // long trackIndex = 0; /*unused*/
if (!GetFirstVideoMedia(anim)) if (!GetFirstVideoMedia(anim))
@@ -440,19 +440,19 @@ static short GetFirstVideoTrackPixelDepth(struct anim *anim)
int startquicktime(struct anim *anim) int startquicktime(struct anim *anim)
{ {
FSSpec theFSSpec; FSSpec theFSSpec;
OSErr err = noErr; OSErr err = noErr;
char theFullPath[255]; char theFullPath[255];
#ifdef __APPLE__ #ifdef __APPLE__
FSRef myRef; FSRef myRef;
#else #else
char *qtname; char *qtname;
Str255 dst; Str255 dst;
#endif #endif
short depth = 0; short depth = 0;
anim->qtime = MEM_callocN (sizeof(QuicktimeMovie), "animqt"); anim->qtime = MEM_callocN(sizeof(QuicktimeMovie), "animqt");
anim->qtime->have_gw = FALSE; anim->qtime->have_gw = FALSE;
if (anim->qtime == NULL) { if (anim->qtime == NULL) {
@@ -481,8 +481,8 @@ int startquicktime(struct anim *anim)
if (err == noErr) { if (err == noErr) {
if (QTIME_DEBUG) printf("qt: movie opened\n"); if (QTIME_DEBUG) printf("qt: movie opened\n");
err = NewMovieFromFile(&anim->qtime->movie, err = NewMovieFromFile(&anim->qtime->movie,
anim->qtime->movieRefNum, anim->qtime->movieRefNum,
&anim->qtime->movieResId, NULL, newMovieActive, NULL); &anim->qtime->movieResId, NULL, newMovieActive, NULL);
} }
if (err) { if (err) {
@@ -506,22 +506,22 @@ int startquicktime(struct anim *anim)
return -1; 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 #ifdef _WIN32
err = NewGWorldFromPtr(&anim->qtime->offscreenGWorld, err = NewGWorldFromPtr(&anim->qtime->offscreenGWorld,
k32RGBAPixelFormat, k32RGBAPixelFormat,
&anim->qtime->movieBounds, &anim->qtime->movieBounds,
NULL, NULL, 0, NULL, NULL, 0,
(unsigned char *)anim->qtime->ibuf->rect, (unsigned char *)anim->qtime->ibuf->rect,
anim->x * 4); anim->x * 4);
#else #else
err = NewGWorldFromPtr(&anim->qtime->offscreenGWorld, err = NewGWorldFromPtr(&anim->qtime->offscreenGWorld,
k32ARGBPixelFormat, k32ARGBPixelFormat,
&anim->qtime->movieBounds, &anim->qtime->movieBounds,
NULL, NULL, 0, NULL, NULL, 0,
(unsigned char *)anim->qtime->ibuf->rect, (unsigned char *)anim->qtime->ibuf->rect,
anim->x * 4); anim->x * 4);
#endif /* _WIN32 */ #endif /* _WIN32 */
if (err == noErr) { if (err == noErr) {
@@ -554,29 +554,29 @@ int startquicktime(struct anim *anim)
anim->curposition = 0; anim->curposition = 0;
if (QTIME_DEBUG) printf("qt: load %s %dx%dx%d frames %d\n", anim->name, anim->qtime->movWidth, if (QTIME_DEBUG) printf("qt: load %s %dx%dx%d frames %d\n", anim->name, anim->qtime->movWidth,
anim->qtime->movHeight, anim->qtime->depth, anim->qtime->framecount); anim->qtime->movHeight, anim->qtime->depth, anim->qtime->framecount);
return 0; return 0;
} }
int imb_is_a_quicktime (char *name) int imb_is_a_quicktime(char *name)
{ {
GraphicsImportComponent theImporter = NULL; GraphicsImportComponent theImporter = NULL;
FSSpec theFSSpec; FSSpec theFSSpec;
#ifdef _WIN32 #ifdef _WIN32
Str255 dst; /*unused*/ Str255 dst; /*unused*/
#endif #endif
char theFullPath[255]; char theFullPath[255];
// Boolean isMovieFile = false; /*unused*/ // Boolean isMovieFile = false; /*unused*/
// AliasHandle myAlias = NULL; /*unused*/ // AliasHandle myAlias = NULL; /*unused*/
// Component myImporter = NULL; /*unused*/ // Component myImporter = NULL; /*unused*/
#ifdef __APPLE__ #ifdef __APPLE__
// FInfo myFinderInfo; /*unused*/ // FInfo myFinderInfo; /*unused*/
FSRef myRef; FSRef myRef;
#endif #endif
OSErr err = noErr; OSErr err = noErr;
if (!G.have_quicktime) return 0; if (!G.have_quicktime) return 0;
@@ -587,7 +587,7 @@ int imb_is_a_quicktime (char *name)
BLI_testextensie(name, ".txt") || BLI_testextensie(name, ".txt") ||
BLI_testextensie(name, ".mpg") || BLI_testextensie(name, ".mpg") ||
BLI_testextensie(name, ".wav") || BLI_testextensie(name, ".wav") ||
BLI_testextensie(name, ".mov") || // not as image, doesn't work BLI_testextensie(name, ".mov") || // not as image, doesn't work
BLI_testextensie(name, ".avi") || BLI_testextensie(name, ".avi") ||
BLI_testextensie(name, ".mp3")) BLI_testextensie(name, ".mp3"))
{ {
@@ -616,30 +616,30 @@ int imb_is_a_quicktime (char *name)
ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags) ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
{ {
Rect myRect; Rect myRect;
OSErr err = noErr; OSErr err = noErr;
GraphicsImportComponent gImporter = NULL; GraphicsImportComponent gImporter = NULL;
ImageDescriptionHandle desc; ImageDescriptionHandle desc;
ComponentInstance dataHandler; ComponentInstance dataHandler;
PointerDataRef dataref; PointerDataRef dataref;
int x, y, depth; int x, y, depth;
int have_gw = FALSE; int have_gw = FALSE;
ImBuf *ibuf = NULL; ImBuf *ibuf = NULL;
// ImBuf *imbuf = NULL; /*unused*/ // ImBuf *imbuf = NULL; /*unused*/
GWorldPtr offGWorld; GWorldPtr offGWorld;
PixMapHandle myPixMap = NULL; PixMapHandle myPixMap = NULL;
#ifdef __APPLE__ #ifdef __APPLE__
Ptr myPtr; Ptr myPtr;
register int index; register int index;
register int boxsize; register int boxsize;
register uint32_t *readPos; register uint32_t *readPos;
register uint32_t *changePos; register uint32_t *changePos;
ImBuf *wbuf = NULL; ImBuf *wbuf = NULL;
unsigned int *rect; unsigned int *rect;
@@ -651,17 +651,17 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
if (QTIME_DEBUG) printf("qt: attempt to load mem as image\n"); 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).data = mem;
(**dataref).dataLength = size; (**dataref).dataLength = size;
err = OpenADataHandler((Handle)dataref, err = OpenADataHandler((Handle)dataref,
PointerDataHandlerSubType, PointerDataHandlerSubType,
nil, nil,
(OSType)0, (OSType)0,
nil, nil,
kDataHCanRead, kDataHCanRead,
&dataHandler); &dataHandler);
if (err != noErr) { if (err != noErr) {
if (QTIME_DEBUG) printf("no datahandler\n"); if (QTIME_DEBUG) printf("no datahandler\n");
goto bail; goto bail;
@@ -679,7 +679,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
goto bail; goto bail;
} }
err = GraphicsImportGetImageDescription (gImporter, &desc ); err = GraphicsImportGetImageDescription(gImporter, &desc);
if (err != noErr) { if (err != noErr) {
if (QTIME_DEBUG) printf("no imagedescription\n"); if (QTIME_DEBUG) printf("no imagedescription\n");
goto bail; goto bail;
@@ -693,26 +693,26 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
ibuf = IMB_allocImBuf(x, y, depth, 0); ibuf = IMB_allocImBuf(x, y, depth, 0);
ibuf->ftype = QUICKTIME; ibuf->ftype = QUICKTIME;
DisposeHandle((Handle)dataref); DisposeHandle((Handle)dataref);
if (gImporter != NULL) CloseComponent(gImporter); if (gImporter != NULL) CloseComponent(gImporter);
return ibuf; return ibuf;
} }
#ifdef __APPLE__ #ifdef __APPLE__
ibuf = IMB_allocImBuf (x, y, 32, IB_rect); ibuf = IMB_allocImBuf(x, y, 32, IB_rect);
wbuf = IMB_allocImBuf (x, y, 32, IB_rect); wbuf = IMB_allocImBuf(x, y, 32, IB_rect);
err = NewGWorldFromPtr(&offGWorld, err = NewGWorldFromPtr(&offGWorld,
k32ARGBPixelFormat, k32ARGBPixelFormat,
&myRect, NULL, NULL, 0, &myRect, NULL, NULL, 0,
(unsigned char *)wbuf->rect, x * 4); (unsigned char *)wbuf->rect, x * 4);
#else #else
ibuf = IMB_allocImBuf (x, y, 32, IB_rect); ibuf = IMB_allocImBuf(x, y, 32, IB_rect);
err = NewGWorldFromPtr(&offGWorld, err = NewGWorldFromPtr(&offGWorld,
k32RGBAPixelFormat, k32RGBAPixelFormat,
&myRect, NULL, NULL, 0, &myRect, NULL, NULL, 0,
(unsigned char *)ibuf->rect, x * 4); (unsigned char *)ibuf->rect, x * 4);
#endif #endif
if (err != noErr) { if (err != noErr) {
@@ -734,8 +734,8 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
myPtr = GetPixBaseAddr(myPixMap); myPtr = GetPixBaseAddr(myPixMap);
if (myPtr == NULL) { if (myPtr == NULL) {
printf ("Error reading frame from Quicktime"); printf("Error reading frame from Quicktime");
IMB_freeImBuf (ibuf); IMB_freeImBuf(ibuf);
return NULL; return NULL;
} }
@@ -744,10 +744,10 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
changePos = (uint32_t *) rect; changePos = (uint32_t *) rect;
// Swap alpha byte to the end, so ARGB become RGBA; // Swap alpha byte to the end, so ARGB become RGBA;
from= (unsigned char *)readPos; from = (unsigned char *)readPos;
to= (unsigned char *)changePos; 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[3] = from[0];
to[0] = from[1]; to[0] = from[1];
to[1] = from[2]; to[1] = from[2];
@@ -763,17 +763,17 @@ bail:
#ifdef __APPLE__ #ifdef __APPLE__
if (wbuf) { if (wbuf) {
IMB_freeImBuf (wbuf); IMB_freeImBuf(wbuf);
wbuf = NULL; wbuf = NULL;
} }
#endif #endif
if (gImporter != NULL) CloseComponent(gImporter); if (gImporter != NULL) CloseComponent(gImporter);
if (err != noErr) { if (err != noErr) {
if (QTIME_DEBUG) printf("quicktime import unsuccesfull\n"); if (QTIME_DEBUG) printf("quicktime import unsuccesfull\n");
if (ibuf) { if (ibuf) {
IMB_freeImBuf (ibuf); IMB_freeImBuf(ibuf);
ibuf = NULL; ibuf = NULL;
} }
} }
@@ -788,8 +788,8 @@ bail:
int box = x * y; int box = x * y;
unsigned char *arect = (unsigned char *) ibuf->rect; unsigned char *arect = (unsigned char *) ibuf->rect;
if ( depth < 32 && (**desc).cType != kGIFCodecType) { if (depth < 32 && (**desc).cType != kGIFCodecType) {
for (i = 0; i < box; i++, arect+=4) for (i = 0; i < box; i++, arect += 4)
arect[3] = 0xFF; arect[3] = 0xFF;
} }
#endif #endif