style cleanup: follow style guide for formatting of if/for/while loops, and else if's
This commit is contained in:
@@ -216,7 +216,8 @@ int AVI_is_avi (char *name)
|
||||
!GET_FCC (fp) ||
|
||||
GET_FCC (fp) != FCC("AVI ")) {
|
||||
ret = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
@@ -312,9 +313,11 @@ int AVI_is_avi (const char *name)
|
||||
fcca == FCC ("RAW ") ||
|
||||
fcca == 0) {
|
||||
movie.streams[temp].format = AVI_FORMAT_AVI_RGB;
|
||||
} else if (fcca == FCC ("mjpg")||fcca == FCC ("MJPG")) {
|
||||
}
|
||||
else if (fcca == FCC ("mjpg")||fcca == FCC ("MJPG")) {
|
||||
movie.streams[temp].format = AVI_FORMAT_MJPEG;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
MEM_freeN(movie.streams);
|
||||
fclose(movie.fp);
|
||||
return 0;
|
||||
@@ -379,10 +382,12 @@ int AVI_is_avi (const char *name)
|
||||
fcca == FCC ("rgb ") ||
|
||||
fcca == FCC ("RAW ") ||
|
||||
fcca == 0 ) {
|
||||
} else if ( fcca == FCC ("mjpg") ||
|
||||
}
|
||||
else if ( fcca == FCC ("mjpg") ||
|
||||
fcca == FCC ("MJPG")) {
|
||||
movie.streams[temp].format = AVI_FORMAT_MJPEG;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
MEM_freeN(movie.streams);
|
||||
fclose(movie.fp);
|
||||
return 0;
|
||||
@@ -391,7 +396,8 @@ int AVI_is_avi (const char *name)
|
||||
|
||||
}
|
||||
if (j > 0) fseek (movie.fp, j, SEEK_CUR);
|
||||
} else fseek (movie.fp, movie.streams[temp].sf_size, SEEK_CUR);
|
||||
}
|
||||
else fseek (movie.fp, movie.streams[temp].sf_size, SEEK_CUR);
|
||||
|
||||
/* Walk to the next LIST */
|
||||
while (GET_FCC (movie.fp) != FCC("LIST")) {
|
||||
@@ -495,9 +501,11 @@ AviError AVI_open_movie (const char *name, AviMovie *movie)
|
||||
fcca == FCC ("RAW ") ||
|
||||
fcca == 0) {
|
||||
movie->streams[temp].format = AVI_FORMAT_AVI_RGB;
|
||||
} else if (fcca == FCC ("mjpg")||fcca == FCC ("MJPG")) {
|
||||
}
|
||||
else if (fcca == FCC ("mjpg")||fcca == FCC ("MJPG")) {
|
||||
movie->streams[temp].format = AVI_FORMAT_MJPEG;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return AVI_ERROR_COMPRESSION;
|
||||
}
|
||||
}
|
||||
@@ -558,17 +566,20 @@ AviError AVI_open_movie (const char *name, AviMovie *movie)
|
||||
fcca == FCC ("rgb ") ||
|
||||
fcca == FCC ("RAW ") ||
|
||||
fcca == 0 ) {
|
||||
} else if ( fcca == FCC ("mjpg") ||
|
||||
}
|
||||
else if ( fcca == FCC ("mjpg") ||
|
||||
fcca == FCC ("MJPG")) {
|
||||
movie->streams[temp].format = AVI_FORMAT_MJPEG;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return AVI_ERROR_COMPRESSION;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (j > 0) fseek (movie->fp, j, SEEK_CUR);
|
||||
} else fseek (movie->fp, movie->streams[temp].sf_size, SEEK_CUR);
|
||||
}
|
||||
else fseek (movie->fp, movie->streams[temp].sf_size, SEEK_CUR);
|
||||
|
||||
/* Walk to the next LIST */
|
||||
while (GET_FCC (movie->fp) != FCC("LIST")) {
|
||||
@@ -595,7 +606,8 @@ AviError AVI_open_movie (const char *name, AviMovie *movie)
|
||||
break;
|
||||
else
|
||||
fseek (movie->fp, size-4, SEEK_CUR);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fseek (movie->fp, size, SEEK_CUR);
|
||||
}
|
||||
if (ftell(movie->fp) > movie->size) {
|
||||
@@ -659,7 +671,7 @@ void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream)
|
||||
|
||||
/* Retrieve the record number of the desired frame in the index
|
||||
* If a chunk has Size 0 we need to rewind to previous frame */
|
||||
while(rewind && frame > -1) {
|
||||
while (rewind && frame > -1) {
|
||||
i=0;
|
||||
cur_frame=-1;
|
||||
rewind = 0;
|
||||
@@ -670,7 +682,8 @@ void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream)
|
||||
if ((cur_frame == frame -1) && (movie->entries[i].Size == 0)) {
|
||||
rewind = 1;
|
||||
frame = frame -1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cur_frame++;
|
||||
}
|
||||
}
|
||||
@@ -802,7 +815,8 @@ AviError AVI_open_compress (char *name, AviMovie *movie, int streams, ...)
|
||||
movie->streams[i].sf = MEM_mallocN (sizeof(AviBitmapInfoHeader)
|
||||
+ sizeof(AviMJPEGUnknown),"moviestreamformatL");
|
||||
movie->streams[i].sf_size = sizeof(AviBitmapInfoHeader) + sizeof(AviMJPEGUnknown);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
movie->streams[i].sf = MEM_mallocN (sizeof(AviBitmapInfoHeader), "moviestreamformatS");
|
||||
movie->streams[i].sf_size = sizeof(AviBitmapInfoHeader);
|
||||
|
||||
@@ -94,7 +94,8 @@ void *avi_converter_from_avi_rgb (AviMovie *movie, int stream, unsigned char *bu
|
||||
MEM_freeN (buffer);
|
||||
|
||||
return buf;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromavirgbbuf");
|
||||
|
||||
rowstride = movie->header->Width*3;
|
||||
|
||||
@@ -159,7 +159,7 @@ static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsign
|
||||
jpeg_create_decompress(&dinfo);
|
||||
jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize);
|
||||
jpeg_read_header(&dinfo, TRUE);
|
||||
if (dinfo.dc_huff_tbl_ptrs[0] == NULL){
|
||||
if (dinfo.dc_huff_tbl_ptrs[0] == NULL) {
|
||||
std_huff_tables(&dinfo);
|
||||
}
|
||||
dinfo.out_color_space = JCS_RGB;
|
||||
@@ -181,13 +181,13 @@ static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsign
|
||||
|
||||
numbytes= 0;
|
||||
jpeg_read_header(&dinfo, TRUE);
|
||||
if (dinfo.dc_huff_tbl_ptrs[0] == NULL){
|
||||
if (dinfo.dc_huff_tbl_ptrs[0] == NULL) {
|
||||
std_huff_tables(&dinfo);
|
||||
}
|
||||
|
||||
jpeg_start_decompress(&dinfo);
|
||||
rowstride= dinfo.output_width*dinfo.output_components;
|
||||
for (y= 0; y<dinfo.output_height; y++){
|
||||
for (y= 0; y<dinfo.output_height; y++) {
|
||||
jpeg_read_scanlines(&dinfo, (JSAMPARRAY) &outBuffer, 1);
|
||||
outBuffer += rowstride;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char *
|
||||
jpeg_write_marker (&cinfo, JPEG_COM, marker, 60);
|
||||
|
||||
rowstride= cinfo.image_width*cinfo.input_components;
|
||||
for (y = 0; y < cinfo.image_height; y++){
|
||||
for (y = 0; y < cinfo.image_height; y++) {
|
||||
jpeg_write_scanlines(&cinfo, (JSAMPARRAY) &inBuffer, 1);
|
||||
inBuffer += rowstride;
|
||||
}
|
||||
@@ -301,7 +301,8 @@ static int check_and_decode_jpeg(unsigned char *inbuf, unsigned char *outbuf, in
|
||||
MEM_freeN(tmpbuf);
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return Decode_JPEG(inbuf, outbuf, width, height, bufsize);
|
||||
}
|
||||
}
|
||||
@@ -329,7 +330,8 @@ static void check_and_compress_jpeg(int quality, unsigned char *outbuf, unsigned
|
||||
Compress_JPEG(quality, outbuf, tmpbuf, jwidth, jheight, bufsize);
|
||||
|
||||
MEM_freeN(tmpbuf);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Compress_JPEG(quality, outbuf, inbuf, width, height, bufsize);
|
||||
}
|
||||
}
|
||||
@@ -369,7 +371,8 @@ void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer
|
||||
buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "avi.avi_converter_to_mjpeg 1");
|
||||
if (!movie->interlace) {
|
||||
check_and_compress_jpeg(movie->streams[stream].sh.Quality/100, buf, buffer, movie->header->Width, movie->header->Height, bufsize);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
deinterlace (movie->odd_fields, buf, buffer, movie->header->Width, movie->header->Height);
|
||||
MEM_freeN (buffer);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer
|
||||
to= buf; from= buffer;
|
||||
i=movie->header->Height*movie->header->Width;
|
||||
|
||||
while(i--) {
|
||||
while (i--) {
|
||||
memcpy(to, from, 3);
|
||||
to+=4; from+=3;
|
||||
}
|
||||
|
||||
@@ -239,7 +239,8 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
|
||||
err += FT_Bitmap_Convert(font->ft_lib, &slot->bitmap, &tempbitmap, 1); /* Does Blender use Pitch 1 always? It works so far */
|
||||
err += FT_Bitmap_Copy(font->ft_lib, &tempbitmap, &slot->bitmap);
|
||||
err += FT_Bitmap_Done(font->ft_lib, &tempbitmap);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
err = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ int BLF_translate_tooltips(void)
|
||||
const char *BLF_translate_do_iface(const char *context, const char *msgid)
|
||||
{
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
if(BLF_translate_iface()) {
|
||||
if (BLF_translate_iface()) {
|
||||
if (context)
|
||||
return BLF_pgettext(context, msgid);
|
||||
else
|
||||
@@ -174,7 +174,7 @@ const char *BLF_translate_do_iface(const char *context, const char *msgid)
|
||||
const char *BLF_translate_do_tooltip(const char *context, const char *msgid)
|
||||
{
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
if(BLF_translate_tooltips()) {
|
||||
if (BLF_translate_tooltips()) {
|
||||
if (context)
|
||||
return BLF_pgettext(context, msgid);
|
||||
else
|
||||
|
||||
@@ -65,8 +65,8 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
|
||||
int a, t, segcount= 0, size, newsize, *oldparent, parent;
|
||||
|
||||
/* find IK constraint, and validate it */
|
||||
for(con= pchan_tip->constraints.first; con; con= con->next) {
|
||||
if(con->type==CONSTRAINT_TYPE_KINEMATIC) {
|
||||
for (con= pchan_tip->constraints.first; con; con= con->next) {
|
||||
if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
|
||||
data=(bKinematicConstraint*)con->data;
|
||||
if (data->flag & CONSTRAINT_IK_AUTO) break;
|
||||
if (data->tar==NULL) continue;
|
||||
@@ -74,36 +74,36 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
|
||||
if ((con->flag & (CONSTRAINT_DISABLE|CONSTRAINT_OFF))==0 && (con->enforce != 0.0f)) break;
|
||||
}
|
||||
}
|
||||
if(con==NULL) return;
|
||||
if (con==NULL) return;
|
||||
|
||||
/* exclude tip from chain? */
|
||||
if(!(data->flag & CONSTRAINT_IK_TIP))
|
||||
if (!(data->flag & CONSTRAINT_IK_TIP))
|
||||
pchan_tip= pchan_tip->parent;
|
||||
|
||||
/* Find the chain's root & count the segments needed */
|
||||
for (curchan = pchan_tip; curchan; curchan=curchan->parent){
|
||||
for (curchan = pchan_tip; curchan; curchan=curchan->parent) {
|
||||
pchan_root = curchan;
|
||||
|
||||
curchan->flag |= POSE_CHAIN; // don't forget to clear this
|
||||
chanlist[segcount]=curchan;
|
||||
segcount++;
|
||||
|
||||
if(segcount==data->rootbone || segcount>255) break; // 255 is weak
|
||||
if (segcount==data->rootbone || segcount>255) break; // 255 is weak
|
||||
}
|
||||
if (!segcount) return;
|
||||
|
||||
/* setup the chain data */
|
||||
|
||||
/* we make tree-IK, unless all existing targets are in this chain */
|
||||
for(tree= pchan_root->iktree.first; tree; tree= tree->next) {
|
||||
for(target= tree->targets.first; target; target= target->next) {
|
||||
for (tree= pchan_root->iktree.first; tree; tree= tree->next) {
|
||||
for (target= tree->targets.first; target; target= target->next) {
|
||||
curchan= tree->pchan[target->tip];
|
||||
if(curchan->flag & POSE_CHAIN)
|
||||
if (curchan->flag & POSE_CHAIN)
|
||||
curchan->flag &= ~POSE_CHAIN;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if(target) break;
|
||||
if (target) break;
|
||||
}
|
||||
|
||||
/* create a target */
|
||||
@@ -111,7 +111,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
|
||||
target->con= con;
|
||||
pchan_tip->flag &= ~POSE_CHAIN;
|
||||
|
||||
if(tree==NULL) {
|
||||
if (tree==NULL) {
|
||||
/* make new tree */
|
||||
tree= MEM_callocN(sizeof(PoseTree), "posetree");
|
||||
|
||||
@@ -123,7 +123,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
|
||||
|
||||
tree->pchan= MEM_callocN(segcount*sizeof(void*), "ik tree pchan");
|
||||
tree->parent= MEM_callocN(segcount*sizeof(int), "ik tree parent");
|
||||
for(a=0; a<segcount; a++) {
|
||||
for (a=0; a<segcount; a++) {
|
||||
tree->pchan[a]= chanlist[segcount-a-1];
|
||||
tree->parent[a]= a-1;
|
||||
}
|
||||
@@ -144,19 +144,19 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
|
||||
for (;t<tree->totchannel && tree->pchan[t]!=chanlist[segcount-a-1];t++);
|
||||
if (t>=tree->totchannel)
|
||||
break;
|
||||
for(; a<size && t<tree->totchannel && tree->pchan[t]==chanlist[segcount-a-1]; a++, t++);
|
||||
for (; a<size && t<tree->totchannel && tree->pchan[t]==chanlist[segcount-a-1]; a++, t++);
|
||||
}
|
||||
|
||||
segcount= segcount-a;
|
||||
target->tip= tree->totchannel + segcount - 1;
|
||||
|
||||
if (segcount > 0) {
|
||||
for(parent = a - 1; parent < tree->totchannel; parent++)
|
||||
if(tree->pchan[parent] == chanlist[segcount-1]->parent)
|
||||
for (parent = a - 1; parent < tree->totchannel; parent++)
|
||||
if (tree->pchan[parent] == chanlist[segcount-1]->parent)
|
||||
break;
|
||||
|
||||
/* shouldn't happen, but could with dependency cycles */
|
||||
if(parent == tree->totchannel)
|
||||
if (parent == tree->totchannel)
|
||||
parent = a - 1;
|
||||
|
||||
/* resize array */
|
||||
@@ -172,7 +172,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
|
||||
MEM_freeN(oldparent);
|
||||
|
||||
/* add new pose channels at the end, in reverse order */
|
||||
for(a=0; a<segcount; a++) {
|
||||
for (a=0; a<segcount; a++) {
|
||||
tree->pchan[tree->totchannel+a]= chanlist[segcount-a-1];
|
||||
tree->parent[tree->totchannel+a]= tree->totchannel+a-1;
|
||||
}
|
||||
@@ -256,20 +256,20 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
|
||||
|
||||
iktree= MEM_mallocN(sizeof(void*)*tree->totchannel, "ik tree");
|
||||
|
||||
for(a=0; a<tree->totchannel; a++) {
|
||||
for (a=0; a<tree->totchannel; a++) {
|
||||
pchan= tree->pchan[a];
|
||||
bone= pchan->bone;
|
||||
|
||||
/* set DoF flag */
|
||||
flag= 0;
|
||||
if(!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP))
|
||||
if (!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP))
|
||||
flag |= IK_XDOF;
|
||||
if(!(pchan->ikflag & BONE_IK_NO_YDOF) && !(pchan->ikflag & BONE_IK_NO_YDOF_TEMP))
|
||||
if (!(pchan->ikflag & BONE_IK_NO_YDOF) && !(pchan->ikflag & BONE_IK_NO_YDOF_TEMP))
|
||||
flag |= IK_YDOF;
|
||||
if(!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP))
|
||||
if (!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP))
|
||||
flag |= IK_ZDOF;
|
||||
|
||||
if(tree->stretch && (pchan->ikstretch > 0.0f)) {
|
||||
if (tree->stretch && (pchan->ikstretch > 0.0f)) {
|
||||
flag |= IK_TRANS_YDOF;
|
||||
hasstretch = 1;
|
||||
}
|
||||
@@ -277,7 +277,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
|
||||
seg= iktree[a]= IK_CreateSegment(flag);
|
||||
|
||||
/* find parent */
|
||||
if(a == 0)
|
||||
if (a == 0)
|
||||
parent= NULL;
|
||||
else
|
||||
parent= iktree[tree->parent[a]];
|
||||
@@ -334,7 +334,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
|
||||
IK_SetStiffness(seg, IK_Y, pchan->stiffness[1]);
|
||||
IK_SetStiffness(seg, IK_Z, pchan->stiffness[2]);
|
||||
|
||||
if(tree->stretch && (pchan->ikstretch > 0.0f)) {
|
||||
if (tree->stretch && (pchan->ikstretch > 0.0f)) {
|
||||
float ikstretch = pchan->ikstretch*pchan->ikstretch;
|
||||
IK_SetStiffness(seg, IK_TRANS_Y, MIN2(1.0f-ikstretch, 0.99f));
|
||||
IK_SetLimit(seg, IK_TRANS_Y, 0.001, 1e10);
|
||||
@@ -377,10 +377,10 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
|
||||
copy_m3_m4(goalrot, goal);
|
||||
|
||||
/* same for pole vector target */
|
||||
if(data->poletar) {
|
||||
if (data->poletar) {
|
||||
get_constraint_target_matrix(scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
|
||||
|
||||
if(data->flag & CONSTRAINT_IK_SETANGLE) {
|
||||
if (data->flag & CONSTRAINT_IK_SETANGLE) {
|
||||
/* don't solve IK when we are setting the pole angle */
|
||||
break;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
|
||||
resultblend= 1;
|
||||
resultinf= target->con->enforce;
|
||||
|
||||
if(data->flag & CONSTRAINT_IK_GETANGLE) {
|
||||
if (data->flag & CONSTRAINT_IK_GETANGLE) {
|
||||
poleangledata= data;
|
||||
data->flag &= ~CONSTRAINT_IK_GETANGLE;
|
||||
}
|
||||
@@ -429,14 +429,14 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
|
||||
|
||||
iktarget= iktree[target->tip];
|
||||
|
||||
if(data->weight != 0.0f) {
|
||||
if(poleconstrain)
|
||||
if (data->weight != 0.0f) {
|
||||
if (poleconstrain)
|
||||
IK_SolverSetPoleVectorConstraint(solver, iktarget, goalpos,
|
||||
polepos, data->poleangle, (poleangledata == data));
|
||||
IK_SolverAddGoal(solver, iktarget, goalpos, data->weight);
|
||||
}
|
||||
if((data->flag & CONSTRAINT_IK_ROT) && (data->orientweight != 0.0f))
|
||||
if((data->flag & CONSTRAINT_IK_AUTO)==0)
|
||||
if ((data->flag & CONSTRAINT_IK_ROT) && (data->orientweight != 0.0f))
|
||||
if ((data->flag & CONSTRAINT_IK_AUTO)==0)
|
||||
IK_SolverAddGoalOrientation(solver, iktarget, goalrot,
|
||||
data->orientweight);
|
||||
}
|
||||
@@ -444,27 +444,27 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
|
||||
/* solve */
|
||||
IK_Solve(solver, 0.0f, tree->iterations);
|
||||
|
||||
if(poleangledata)
|
||||
if (poleangledata)
|
||||
poleangledata->poleangle= IK_SolverGetPoleAngle(solver);
|
||||
|
||||
IK_FreeSolver(solver);
|
||||
|
||||
/* gather basis changes */
|
||||
tree->basis_change= MEM_mallocN(sizeof(float[3][3])*tree->totchannel, "ik basis change");
|
||||
if(hasstretch)
|
||||
if (hasstretch)
|
||||
ikstretch= MEM_mallocN(sizeof(float)*tree->totchannel, "ik stretch");
|
||||
|
||||
for(a=0; a<tree->totchannel; a++) {
|
||||
for (a=0; a<tree->totchannel; a++) {
|
||||
IK_GetBasisChange(iktree[a], tree->basis_change[a]);
|
||||
|
||||
if(hasstretch) {
|
||||
if (hasstretch) {
|
||||
/* have to compensate for scaling received from parent */
|
||||
float parentstretch, stretch;
|
||||
|
||||
pchan= tree->pchan[a];
|
||||
parentstretch= (tree->parent[a] >= 0)? ikstretch[tree->parent[a]]: 1.0f;
|
||||
|
||||
if(tree->stretch && (pchan->ikstretch > 0.0f)) {
|
||||
if (tree->stretch && (pchan->ikstretch > 0.0f)) {
|
||||
float trans[3], length;
|
||||
|
||||
IK_GetTranslationChange(iktree[a], trans);
|
||||
@@ -482,7 +482,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
|
||||
mul_v3_fl(tree->basis_change[a][2], stretch);
|
||||
}
|
||||
|
||||
if(resultblend && resultinf!=1.0f) {
|
||||
if (resultblend && resultinf!=1.0f) {
|
||||
unit_m3(identity);
|
||||
blend_m3_m3m3(tree->basis_change[a], identity,
|
||||
tree->basis_change[a], resultinf);
|
||||
@@ -492,15 +492,15 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
|
||||
}
|
||||
|
||||
MEM_freeN(iktree);
|
||||
if(ikstretch) MEM_freeN(ikstretch);
|
||||
if (ikstretch) MEM_freeN(ikstretch);
|
||||
}
|
||||
|
||||
static void free_posetree(PoseTree *tree)
|
||||
{
|
||||
BLI_freelistN(&tree->targets);
|
||||
if(tree->pchan) MEM_freeN(tree->pchan);
|
||||
if(tree->parent) MEM_freeN(tree->parent);
|
||||
if(tree->basis_change) MEM_freeN(tree->basis_change);
|
||||
if (tree->pchan) MEM_freeN(tree->pchan);
|
||||
if (tree->parent) MEM_freeN(tree->parent);
|
||||
if (tree->basis_change) MEM_freeN(tree->basis_change);
|
||||
MEM_freeN(tree);
|
||||
}
|
||||
|
||||
@@ -511,8 +511,8 @@ void iksolver_initialize_tree(struct Scene *UNUSED(scene), struct Object *ob, fl
|
||||
{
|
||||
bPoseChannel *pchan;
|
||||
|
||||
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
if(pchan->constflag & PCHAN_HAS_IK) // flag is set on editing constraints
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
if (pchan->constflag & PCHAN_HAS_IK) // flag is set on editing constraints
|
||||
initialize_posetree(ob, pchan); // will attach it to root!
|
||||
}
|
||||
ob->pose->flag &= ~POSE_WAS_REBUILT;
|
||||
@@ -520,7 +520,7 @@ void iksolver_initialize_tree(struct Scene *UNUSED(scene), struct Object *ob, fl
|
||||
|
||||
void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime)
|
||||
{
|
||||
while(pchan->iktree.first) {
|
||||
while (pchan->iktree.first) {
|
||||
PoseTree *tree= pchan->iktree.first;
|
||||
int a;
|
||||
|
||||
@@ -529,8 +529,8 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose
|
||||
return;
|
||||
|
||||
/* 4. walk over the tree for regular solving */
|
||||
for(a=0; a<tree->totchannel; a++) {
|
||||
if(!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag
|
||||
for (a=0; a<tree->totchannel; a++) {
|
||||
if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag
|
||||
where_is_pose_bone(scene, ob, tree->pchan[a], ctime, 1);
|
||||
// tell blender that this channel was controlled by IK, it's cleared on each where_is_pose()
|
||||
tree->pchan[a]->flag |= POSE_CHAIN;
|
||||
@@ -540,11 +540,11 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose
|
||||
|
||||
/* 6. apply the differences to the channels,
|
||||
* we need to calculate the original differences first */
|
||||
for(a=0; a<tree->totchannel; a++) {
|
||||
for (a=0; a<tree->totchannel; a++) {
|
||||
make_dmats(tree->pchan[a]);
|
||||
}
|
||||
|
||||
for(a=0; a<tree->totchannel; a++) {
|
||||
for (a=0; a<tree->totchannel; a++) {
|
||||
/* sets POSE_DONE */
|
||||
where_is_ik_bone(tree->pchan[a], tree->basis_change[a]);
|
||||
}
|
||||
|
||||
@@ -430,7 +430,8 @@ static double EulerAngleFromMatrix(const KDL::Rotation& R, int axis)
|
||||
if (axis == 0) return -KDL::atan2(R(1,2), R(2,2));
|
||||
else if(axis == 1) return KDL::atan2(-R(0,2), t);
|
||||
else return -KDL::atan2(R(0,1), R(0,0));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (axis == 0) return -KDL::atan2(-R(2,1), R(1,1));
|
||||
else if(axis == 1) return KDL::atan2(-R(0,2), t);
|
||||
else return 0.0f;
|
||||
@@ -476,7 +477,8 @@ static void GetEulerXZY(const KDL::Rotation& R, double& X,double& Z,double& Y)
|
||||
X = -KDL::sign(R(0,1)) * KDL::atan2(R(1,2), R(1,0));
|
||||
Z = -KDL::sign(R(0,1)) * KDL::PI / 2;
|
||||
Y = 0.0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
X = KDL::atan2(R(2,1), R(1,1));
|
||||
Z = KDL::atan2(-R(0,1), KDL::sqrt( KDL::sqr(R(0,0)) + KDL::sqr(R(0,2))));
|
||||
Y = KDL::atan2(R(0,2), R(0,0));
|
||||
@@ -489,7 +491,8 @@ static void GetEulerXYZ(const KDL::Rotation& R, double& X,double& Y,double& Z)
|
||||
X = KDL::sign(R(0,2)) * KDL::atan2(-R(1,0), R(1,1));
|
||||
Y = KDL::sign(R(0,2)) * KDL::PI / 2;
|
||||
Z = 0.0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
X = KDL::atan2(-R(1,2), R(2,2));
|
||||
Y = KDL::atan2(R(0,2), KDL::sqrt( KDL::sqr(R(0,0)) + KDL::sqr(R(0,1))));
|
||||
Z = KDL::atan2(-R(0,1), R(0,0));
|
||||
@@ -691,7 +694,8 @@ static bool copypose_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai
|
||||
values->action = iTaSC::ACT_ALPHA;
|
||||
values++;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (iktarget->controlType & iTaSC::CopyPose::CTL_POSITION) {
|
||||
// update error
|
||||
values->alpha = condata->weight;
|
||||
@@ -745,7 +749,8 @@ static bool distance_callback(const iTaSC::Timestamp& timestamp, iTaSC::Constrai
|
||||
// update weight according to mode
|
||||
if (iktarget->blenderConstraint->flag & CONSTRAINT_OFF) {
|
||||
values->alpha = 0.0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
switch (condata->mode) {
|
||||
case LIMITDIST_INSIDE:
|
||||
values->alpha = (values->values[0].y > condata->dist) ? condata->weight : 0.0;
|
||||
@@ -996,7 +1001,8 @@ static void convert_pose(IK_Scene *ikscene)
|
||||
if (pchan->parent) {
|
||||
unit_m4(bmat);
|
||||
mul_m4_m4m3(bmat, pchan->parent->pose_mat, bone->bone_mat);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
copy_m4_m4(bmat, bone->arm_mat);
|
||||
}
|
||||
invert_m4_m4(rmat, bmat);
|
||||
@@ -1076,7 +1082,8 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan)
|
||||
if (!ikparam) {
|
||||
// you must have our own copy
|
||||
ikparam = &DefIKParam;
|
||||
} else if (ingame) {
|
||||
}
|
||||
else if (ingame) {
|
||||
// tweak the param when in game to have efficient stepping
|
||||
// using fixed substep is not effecient since frames in the GE are often
|
||||
// shorter than in animation => move to auto step automatically and set
|
||||
@@ -1120,7 +1127,8 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan)
|
||||
// in the GE, set the initial joint angle to match the current pose
|
||||
// this will update the jointArray in ikscene
|
||||
convert_pose(ikscene);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// in Blender, the rest pose is always 0 for joints
|
||||
rest_pose(ikscene);
|
||||
}
|
||||
@@ -1393,7 +1401,8 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan)
|
||||
// move to the tail and scale to get rest pose of armature base
|
||||
copy_v3_v3(baseFrame[3], pchan->bone->arm_tail);
|
||||
invert_m4_m4(invBaseFrame, baseFrame);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
unit_m4(invBaseFrame);
|
||||
}
|
||||
// finally add the constraint
|
||||
@@ -1538,7 +1547,8 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl
|
||||
ikchan->pchan->flag |= (POSE_DONE|POSE_CHAIN);
|
||||
ikchan->jointValid = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// in animation mode, we must get the bone position from action and constraints
|
||||
for(i=0, ikchan=ikscene->channels; i<ikscene->numchan; i++, ++ikchan) {
|
||||
if (!(ikchan->pchan->flag & POSE_DONE))
|
||||
@@ -1589,7 +1599,8 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl
|
||||
// the cache is empty before this time, reiterate
|
||||
if (ikparam->flag & ITASC_INITIAL_REITERATION)
|
||||
reiterate = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// can take the cache as a start point.
|
||||
sts -= cts;
|
||||
timestep = sts/1000.0;
|
||||
@@ -1780,7 +1791,8 @@ void itasc_update_param(struct bPose *pose)
|
||||
ikscene->scene->setParam(iTaSC::Scene::MAX_TIMESTEP, ikparam->maxstep);
|
||||
ikscene->solver->setParam(iTaSC::Solver::DLS_QMAX, ikparam->maxvel);
|
||||
ikscene->armature->setControlParameter(CONSTRAINT_ID_ALL, iTaSC::Armature::ID_JOINT, iTaSC::ACT_FEEDBACK, ikparam->feedback);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// in animation mode timestep is 1s by convention =>
|
||||
// qmax becomes radiant and feedback becomes fraction of error gap corrected in one iteration
|
||||
ikscene->scene->setParam(iTaSC::Scene::MIN_TIMESTEP, 1.0);
|
||||
|
||||
@@ -178,11 +178,11 @@ int DNA_elem_array_size(const char *astr, int len)
|
||||
|
||||
memcpy(str, astr, len+1);
|
||||
|
||||
for(a=0; a<len; a++) {
|
||||
if( str[a]== '[' ) {
|
||||
for (a=0; a<len; a++) {
|
||||
if ( str[a]== '[' ) {
|
||||
cp= &(str[a+1]);
|
||||
}
|
||||
else if( str[a]==']' && cp) {
|
||||
else if ( str[a]==']' && cp) {
|
||||
str[a]= 0;
|
||||
mul*= atoi(cp);
|
||||
}
|
||||
@@ -226,17 +226,17 @@ static int elementsize(SDNA *sdna, short type, short name)
|
||||
|
||||
namelen= strlen(cp);
|
||||
/* is it a pointer or function pointer? */
|
||||
if(ispointer(cp)) {
|
||||
if (ispointer(cp)) {
|
||||
/* has the naam an extra length? (array) */
|
||||
mul= 1;
|
||||
if( cp[namelen-1]==']') mul= DNA_elem_array_size(cp, namelen);
|
||||
if ( cp[namelen-1]==']') mul= DNA_elem_array_size(cp, namelen);
|
||||
|
||||
len= sdna->pointerlen*mul;
|
||||
}
|
||||
else if( sdna->typelens[type] ) {
|
||||
else if ( sdna->typelens[type] ) {
|
||||
/* has the naam an extra length? (array) */
|
||||
mul= 1;
|
||||
if( cp[namelen-1]==']') mul= DNA_elem_array_size(cp, namelen);
|
||||
if ( cp[namelen-1]==']') mul= DNA_elem_array_size(cp, namelen);
|
||||
|
||||
len= mul*sdna->typelens[type];
|
||||
|
||||
@@ -258,7 +258,7 @@ static void printstruct(SDNA *sdna, short strnr)
|
||||
nr= sp[1];
|
||||
sp+= 2;
|
||||
|
||||
for(b=0; b< nr; b++, sp+= 2) {
|
||||
for (b=0; b< nr; b++, sp+= 2) {
|
||||
printf(" %s %s\n", sdna->types[sp[0]], sdna->names[sp[1]]);
|
||||
}
|
||||
}
|
||||
@@ -270,11 +270,11 @@ static short *findstruct_name(SDNA *sdna, const char *str)
|
||||
short *sp= NULL;
|
||||
|
||||
|
||||
for(a=0; a<sdna->nr_structs; a++) {
|
||||
for (a=0; a<sdna->nr_structs; a++) {
|
||||
|
||||
sp= sdna->structs[a];
|
||||
|
||||
if(strcmp( sdna->types[ sp[0] ], str )==0) return sp;
|
||||
if (strcmp( sdna->types[ sp[0] ], str )==0) return sp;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -284,9 +284,9 @@ int DNA_struct_find_nr(SDNA *sdna, const char *str)
|
||||
{
|
||||
short *sp= NULL;
|
||||
|
||||
if(sdna->lastfind<sdna->nr_structs) {
|
||||
if (sdna->lastfind<sdna->nr_structs) {
|
||||
sp= sdna->structs[sdna->lastfind];
|
||||
if(strcmp( sdna->types[ sp[0] ], str )==0) return sdna->lastfind;
|
||||
if (strcmp( sdna->types[ sp[0] ], str )==0) return sdna->lastfind;
|
||||
}
|
||||
|
||||
#ifdef WITH_DNA_GHASH
|
||||
@@ -295,11 +295,11 @@ int DNA_struct_find_nr(SDNA *sdna, const char *str)
|
||||
{
|
||||
int a;
|
||||
|
||||
for(a=0; a<sdna->nr_structs; a++) {
|
||||
for (a=0; a<sdna->nr_structs; a++) {
|
||||
|
||||
sp= sdna->structs[a];
|
||||
|
||||
if(strcmp( sdna->types[ sp[0] ], str )==0) {
|
||||
if (strcmp( sdna->types[ sp[0] ], str )==0) {
|
||||
sdna->lastfind= a;
|
||||
return a;
|
||||
}
|
||||
@@ -325,16 +325,16 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
data= (int *)sdna->data;
|
||||
|
||||
strcpy(str, "SDNA");
|
||||
if( *data == *verg ) {
|
||||
if ( *data == *verg ) {
|
||||
|
||||
data++;
|
||||
|
||||
/* load names array */
|
||||
strcpy(str, "NAME");
|
||||
if( *data == *verg ) {
|
||||
if ( *data == *verg ) {
|
||||
data++;
|
||||
|
||||
if(do_endian_swap) sdna->nr_names= le_int(*data);
|
||||
if (do_endian_swap) sdna->nr_names= le_int(*data);
|
||||
else sdna->nr_names= *data;
|
||||
|
||||
data++;
|
||||
@@ -347,20 +347,20 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
|
||||
nr= 0;
|
||||
cp= (char *)data;
|
||||
while(nr<sdna->nr_names) {
|
||||
while (nr<sdna->nr_names) {
|
||||
sdna->names[nr]= cp;
|
||||
|
||||
/* "float gravity [3]" was parsed wrong giving both "gravity" and
|
||||
* "[3]" members. we rename "[3]", and later set the type of
|
||||
* "gravity" to "void" so the offsets work out correct */
|
||||
if(*cp == '[' && strcmp(cp, "[3]")==0) {
|
||||
if(nr && strcmp(sdna->names[nr-1], "Cvi") == 0) {
|
||||
if (*cp == '[' && strcmp(cp, "[3]")==0) {
|
||||
if (nr && strcmp(sdna->names[nr-1], "Cvi") == 0) {
|
||||
sdna->names[nr]= "gravity[3]";
|
||||
gravity_fix= nr;
|
||||
}
|
||||
}
|
||||
|
||||
while( *cp) cp++;
|
||||
while ( *cp) cp++;
|
||||
cp++;
|
||||
nr++;
|
||||
}
|
||||
@@ -371,10 +371,10 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
/* load type names array */
|
||||
data= (int *)cp;
|
||||
strcpy(str, "TYPE");
|
||||
if( *data == *verg ) {
|
||||
if ( *data == *verg ) {
|
||||
data++;
|
||||
|
||||
if(do_endian_swap) sdna->nr_types= le_int(*data);
|
||||
if (do_endian_swap) sdna->nr_types= le_int(*data);
|
||||
else sdna->nr_types= *data;
|
||||
|
||||
data++;
|
||||
@@ -387,18 +387,18 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
|
||||
nr= 0;
|
||||
cp= (char *)data;
|
||||
while(nr<sdna->nr_types) {
|
||||
while (nr<sdna->nr_types) {
|
||||
sdna->types[nr]= cp;
|
||||
|
||||
/* this is a patch, to change struct names without a conflict with SDNA */
|
||||
/* be careful to use it, in this case for a system-struct (opengl/X) */
|
||||
|
||||
if( *cp == 'b') {
|
||||
if ( *cp == 'b') {
|
||||
/* struct Screen was already used by X, 'bScreen' replaces the old IrisGL 'Screen' struct */
|
||||
if( strcmp("bScreen", cp)==0 ) sdna->types[nr]= cp+1;
|
||||
if ( strcmp("bScreen", cp)==0 ) sdna->types[nr]= cp+1;
|
||||
}
|
||||
|
||||
while( *cp) cp++;
|
||||
while ( *cp) cp++;
|
||||
cp++;
|
||||
nr++;
|
||||
}
|
||||
@@ -409,16 +409,16 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
/* load typelen array */
|
||||
data= (int *)cp;
|
||||
strcpy(str, "TLEN");
|
||||
if( *data == *verg ) {
|
||||
if ( *data == *verg ) {
|
||||
data++;
|
||||
sp= (short *)data;
|
||||
sdna->typelens= sp;
|
||||
|
||||
if(do_endian_swap) {
|
||||
if (do_endian_swap) {
|
||||
short a, *spo= sp;
|
||||
|
||||
a= sdna->nr_types;
|
||||
while(a--) {
|
||||
while (a--) {
|
||||
spo[0]= le_short(spo[0]);
|
||||
spo++;
|
||||
}
|
||||
@@ -430,15 +430,15 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
printf("TLEN error in SDNA file\n");
|
||||
return;
|
||||
}
|
||||
if(sdna->nr_types & 1) sp++; /* prevent BUS error */
|
||||
if (sdna->nr_types & 1) sp++; /* prevent BUS error */
|
||||
|
||||
/* load struct array */
|
||||
data= (int *)sp;
|
||||
strcpy(str, "STRC");
|
||||
if( *data == *verg ) {
|
||||
if ( *data == *verg ) {
|
||||
data++;
|
||||
|
||||
if(do_endian_swap) sdna->nr_structs= le_int(*data);
|
||||
if (do_endian_swap) sdna->nr_structs= le_int(*data);
|
||||
else sdna->nr_structs= *data;
|
||||
|
||||
data++;
|
||||
@@ -451,10 +451,10 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
|
||||
nr= 0;
|
||||
sp= (short *)data;
|
||||
while(nr<sdna->nr_structs) {
|
||||
while (nr<sdna->nr_structs) {
|
||||
sdna->structs[nr]= sp;
|
||||
|
||||
if(do_endian_swap) {
|
||||
if (do_endian_swap) {
|
||||
short a;
|
||||
|
||||
sp[0]= le_short(sp[0]);
|
||||
@@ -462,7 +462,7 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
|
||||
a= sp[1];
|
||||
sp+= 2;
|
||||
while(a--) {
|
||||
while (a--) {
|
||||
sp[0]= le_short(sp[0]);
|
||||
sp[1]= le_short(sp[1]);
|
||||
sp+= 2;
|
||||
@@ -481,17 +481,17 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
|
||||
sdna->pointerlen= sdna->typelens[ sp[0] ]/2;
|
||||
|
||||
if(sp[1]!=2 || (sdna->pointerlen!=4 && sdna->pointerlen!=8)) {
|
||||
if (sp[1]!=2 || (sdna->pointerlen!=4 && sdna->pointerlen!=8)) {
|
||||
printf("ListBase struct error! Needs it to calculate pointerize.\n");
|
||||
exit(0);
|
||||
/* well, at least sizeof(ListBase) is error proof! (ton) */
|
||||
}
|
||||
|
||||
/* second part of gravity problem, setting "gravity" type to void */
|
||||
if(gravity_fix > -1) {
|
||||
for(nr=0; nr<sdna->nr_structs; nr++) {
|
||||
if (gravity_fix > -1) {
|
||||
for (nr=0; nr<sdna->nr_structs; nr++) {
|
||||
sp= sdna->structs[nr];
|
||||
if(strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0)
|
||||
if (strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0)
|
||||
sp[10]= SDNA_TYPE_VOID;
|
||||
}
|
||||
}
|
||||
@@ -500,7 +500,7 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
|
||||
/* create a ghash lookup to speed up */
|
||||
sdna->structs_map= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "init_structDNA gh");
|
||||
|
||||
for(nr = 0; nr < sdna->nr_structs; nr++) {
|
||||
for (nr = 0; nr < sdna->nr_structs; nr++) {
|
||||
sp= sdna->structs[nr];
|
||||
BLI_ghash_insert(sdna->structs_map, (void *)sdna->types[sp[0]], (void *)(nr + 1));
|
||||
}
|
||||
@@ -537,15 +537,15 @@ static void recurs_test_compflags(SDNA *sdna, char *compflags, int structnr)
|
||||
sp= sdna->structs[structnr];
|
||||
typenr= sp[0];
|
||||
|
||||
for(a=0; a<sdna->nr_structs; a++) {
|
||||
if(a!=structnr && compflags[a]==1) {
|
||||
for (a=0; a<sdna->nr_structs; a++) {
|
||||
if (a!=structnr && compflags[a]==1) {
|
||||
sp= sdna->structs[a];
|
||||
elems= sp[1];
|
||||
sp+= 2;
|
||||
for(b=0; b<elems; b++, sp+=2) {
|
||||
if(sp[0]==typenr) {
|
||||
for (b=0; b<elems; b++, sp+=2) {
|
||||
if (sp[0]==typenr) {
|
||||
cp= sdna->names[ sp[1] ];
|
||||
if(!ispointer(cp)) {
|
||||
if (!ispointer(cp)) {
|
||||
compflags[a]= 2;
|
||||
recurs_test_compflags(sdna, compflags, a);
|
||||
}
|
||||
@@ -578,7 +578,7 @@ char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna)
|
||||
const char *str1, *str2;
|
||||
char *compflags;
|
||||
|
||||
if(sdna->nr_structs==0) {
|
||||
if (sdna->nr_structs==0) {
|
||||
printf("error: file without SDNA\n");
|
||||
return NULL;
|
||||
}
|
||||
@@ -589,42 +589,42 @@ char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna)
|
||||
* the structs in 'newsdna'
|
||||
*/
|
||||
|
||||
for(a=0; a<sdna->nr_structs; a++) {
|
||||
for (a=0; a<sdna->nr_structs; a++) {
|
||||
spold= sdna->structs[a];
|
||||
|
||||
/* search for type in cur */
|
||||
spcur= findstruct_name(newsdna, sdna->types[spold[0]]);
|
||||
|
||||
if(spcur) {
|
||||
if (spcur) {
|
||||
compflags[a]= 2;
|
||||
|
||||
/* compare length and amount of elems */
|
||||
if( spcur[1] == spold[1]) {
|
||||
if( newsdna->typelens[spcur[0]] == sdna->typelens[spold[0]] ) {
|
||||
if ( spcur[1] == spold[1]) {
|
||||
if ( newsdna->typelens[spcur[0]] == sdna->typelens[spold[0]] ) {
|
||||
|
||||
/* same length, same amount of elems, now per type and name */
|
||||
b= spold[1];
|
||||
spold+= 2;
|
||||
spcur+= 2;
|
||||
while(b > 0) {
|
||||
while (b > 0) {
|
||||
str1= newsdna->types[spcur[0]];
|
||||
str2= sdna->types[spold[0]];
|
||||
if(strcmp(str1, str2)!=0) break;
|
||||
if (strcmp(str1, str2)!=0) break;
|
||||
|
||||
str1= newsdna->names[spcur[1]];
|
||||
str2= sdna->names[spold[1]];
|
||||
if(strcmp(str1, str2)!=0) break;
|
||||
if (strcmp(str1, str2)!=0) break;
|
||||
|
||||
/* same type and same name, now pointersize */
|
||||
if(ispointer(str1)) {
|
||||
if(sdna->pointerlen!=newsdna->pointerlen) break;
|
||||
if (ispointer(str1)) {
|
||||
if (sdna->pointerlen!=newsdna->pointerlen) break;
|
||||
}
|
||||
|
||||
b--;
|
||||
spold+= 2;
|
||||
spcur+= 2;
|
||||
}
|
||||
if(b==0) compflags[a]= 1;
|
||||
if (b==0) compflags[a]= 1;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -640,13 +640,13 @@ char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna)
|
||||
/* Because structs can be inside structs, we recursively
|
||||
* set flags when a struct is altered
|
||||
*/
|
||||
for(a=0; a<sdna->nr_structs; a++) {
|
||||
if(compflags[a]==2) recurs_test_compflags(sdna, compflags, a);
|
||||
for (a=0; a<sdna->nr_structs; a++) {
|
||||
if (compflags[a]==2) recurs_test_compflags(sdna, compflags, a);
|
||||
}
|
||||
|
||||
#if 0
|
||||
for(a=0; a<sdna->nr_structs; a++) {
|
||||
if(compflags[a]==2) {
|
||||
for (a=0; a<sdna->nr_structs; a++) {
|
||||
if (compflags[a]==2) {
|
||||
spold= sdna->structs[a];
|
||||
printf("changed: %s\n", sdna->types[ spold[0] ]);
|
||||
}
|
||||
@@ -659,16 +659,16 @@ char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna)
|
||||
static eSDNA_Type sdna_type_nr(const char *dna_type)
|
||||
{
|
||||
if ((strcmp(dna_type, "char")==0) || (strcmp(dna_type, "const char")==0)) return SDNA_TYPE_CHAR;
|
||||
else if((strcmp(dna_type, "uchar")==0) || (strcmp(dna_type, "unsigned char")==0)) return SDNA_TYPE_UCHAR;
|
||||
else if( strcmp(dna_type, "short")==0) return SDNA_TYPE_SHORT;
|
||||
else if((strcmp(dna_type, "ushort")==0)||(strcmp(dna_type, "unsigned short")==0)) return SDNA_TYPE_USHORT;
|
||||
else if( strcmp(dna_type, "int")==0) return SDNA_TYPE_INT;
|
||||
else if( strcmp(dna_type, "long")==0) return SDNA_TYPE_LONG;
|
||||
else if((strcmp(dna_type, "ulong")==0)||(strcmp(dna_type, "unsigned long")==0)) return SDNA_TYPE_ULONG;
|
||||
else if( strcmp(dna_type, "float")==0) return SDNA_TYPE_FLOAT;
|
||||
else if( strcmp(dna_type, "double")==0) return SDNA_TYPE_DOUBLE;
|
||||
else if( strcmp(dna_type, "int64_t")==0) return SDNA_TYPE_INT64;
|
||||
else if( strcmp(dna_type, "uint64_t")==0) return SDNA_TYPE_UINT64;
|
||||
else if ((strcmp(dna_type, "uchar")==0) || (strcmp(dna_type, "unsigned char")==0)) return SDNA_TYPE_UCHAR;
|
||||
else if ( strcmp(dna_type, "short")==0) return SDNA_TYPE_SHORT;
|
||||
else if ((strcmp(dna_type, "ushort")==0)||(strcmp(dna_type, "unsigned short")==0)) return SDNA_TYPE_USHORT;
|
||||
else if ( strcmp(dna_type, "int")==0) return SDNA_TYPE_INT;
|
||||
else if ( strcmp(dna_type, "long")==0) return SDNA_TYPE_LONG;
|
||||
else if ((strcmp(dna_type, "ulong")==0)||(strcmp(dna_type, "unsigned long")==0)) return SDNA_TYPE_ULONG;
|
||||
else if ( strcmp(dna_type, "float")==0) return SDNA_TYPE_FLOAT;
|
||||
else if ( strcmp(dna_type, "double")==0) return SDNA_TYPE_DOUBLE;
|
||||
else if ( strcmp(dna_type, "int64_t")==0) return SDNA_TYPE_INT64;
|
||||
else if ( strcmp(dna_type, "uint64_t")==0) return SDNA_TYPE_UINT64;
|
||||
else return -1; /* invalid! */
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch
|
||||
oldlen= DNA_elem_type_size(otypenr);
|
||||
curlen= DNA_elem_type_size(ctypenr);
|
||||
|
||||
while(arrlen>0) {
|
||||
while (arrlen>0) {
|
||||
switch(otypenr) {
|
||||
case SDNA_TYPE_CHAR:
|
||||
val= *olddata; break;
|
||||
@@ -733,10 +733,10 @@ static void cast_elem(const char *ctype, const char *otype, const char *name, ch
|
||||
case SDNA_TYPE_ULONG:
|
||||
*( (unsigned int *)curdata)= val; break;
|
||||
case SDNA_TYPE_FLOAT:
|
||||
if(otypenr<2) val/= 255;
|
||||
if (otypenr<2) val/= 255;
|
||||
*( (float *)curdata)= val; break;
|
||||
case SDNA_TYPE_DOUBLE:
|
||||
if(otypenr<2) val/= 255;
|
||||
if (otypenr<2) val/= 255;
|
||||
*( (double *)curdata)= val; break;
|
||||
case SDNA_TYPE_INT64:
|
||||
*( (int64_t *)curdata)= val; break;
|
||||
@@ -761,12 +761,12 @@ static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata
|
||||
|
||||
arrlen= DNA_elem_array_size(name, strlen(name));
|
||||
|
||||
while(arrlen>0) {
|
||||
while (arrlen>0) {
|
||||
|
||||
if(curlen==oldlen) {
|
||||
if (curlen==oldlen) {
|
||||
memcpy(curdata, olddata, curlen);
|
||||
}
|
||||
else if(curlen==4 && oldlen==8) {
|
||||
else if (curlen==4 && oldlen==8) {
|
||||
#ifdef WIN32
|
||||
lval= *( (__int64 *)olddata );
|
||||
#else
|
||||
@@ -774,7 +774,7 @@ static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata
|
||||
#endif
|
||||
*((int *)curdata) = lval>>3; /* is of course gambling! */
|
||||
}
|
||||
else if(curlen==8 && oldlen==4) {
|
||||
else if (curlen==8 && oldlen==4) {
|
||||
#ifdef WIN32
|
||||
*( (__int64 *)curdata ) = *((int *)olddata);
|
||||
#else
|
||||
@@ -799,10 +799,10 @@ static int elem_strcmp(const char *name, const char *oname)
|
||||
|
||||
/* strcmp without array part */
|
||||
|
||||
while(1) {
|
||||
if(name[a] != oname[a]) return 1;
|
||||
if(name[a]=='[') break;
|
||||
if(name[a]==0) break;
|
||||
while (1) {
|
||||
if (name[a] != oname[a]) return 1;
|
||||
if (name[a]=='[') break;
|
||||
if (name[a]==0) break;
|
||||
a++;
|
||||
}
|
||||
return 0;
|
||||
@@ -818,16 +818,16 @@ static char *find_elem(SDNA *sdna, const char *type, const char *name, short *ol
|
||||
/* in old is the old struct */
|
||||
elemcount= old[1];
|
||||
old+= 2;
|
||||
for(a=0; a<elemcount; a++, old+=2) {
|
||||
for (a=0; a<elemcount; a++, old+=2) {
|
||||
|
||||
otype= sdna->types[old[0]];
|
||||
oname= sdna->names[old[1]];
|
||||
|
||||
len= elementsize(sdna, old[0], old[1]);
|
||||
|
||||
if( elem_strcmp(name, oname)==0 ) { /* naam equal */
|
||||
if( strcmp(type, otype)==0 ) { /* type equal */
|
||||
if(sppo) *sppo= old;
|
||||
if ( elem_strcmp(name, oname)==0 ) { /* naam equal */
|
||||
if ( strcmp(type, otype)==0 ) { /* type equal */
|
||||
if (sppo) *sppo= old;
|
||||
return olddata;
|
||||
}
|
||||
|
||||
@@ -858,53 +858,53 @@ static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna,
|
||||
/* is 'name' an array? */
|
||||
cp= name;
|
||||
array= 0;
|
||||
while( *cp && *cp!='[') {
|
||||
while ( *cp && *cp!='[') {
|
||||
cp++; array++;
|
||||
}
|
||||
if( *cp!= '[' ) array= 0;
|
||||
if ( *cp!= '[' ) array= 0;
|
||||
|
||||
/* in old is the old struct */
|
||||
elemcount= old[1];
|
||||
old+= 2;
|
||||
for(a=0; a<elemcount; a++, old+=2) {
|
||||
for (a=0; a<elemcount; a++, old+=2) {
|
||||
otype= oldsdna->types[old[0]];
|
||||
oname= oldsdna->names[old[1]];
|
||||
len= elementsize(oldsdna, old[0], old[1]);
|
||||
|
||||
if( strcmp(name, oname)==0 ) { /* name equal */
|
||||
if ( strcmp(name, oname)==0 ) { /* name equal */
|
||||
|
||||
if(ispointer(name)) { /* pointer of functionpointer afhandelen */
|
||||
if (ispointer(name)) { /* pointer of functionpointer afhandelen */
|
||||
cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, name, curdata, olddata);
|
||||
}
|
||||
else if( strcmp(type, otype)==0 ) { /* type equal */
|
||||
else if ( strcmp(type, otype)==0 ) { /* type equal */
|
||||
memcpy(curdata, olddata, len);
|
||||
}
|
||||
else cast_elem(type, otype, name, curdata, olddata);
|
||||
|
||||
return;
|
||||
}
|
||||
else if(array) { /* name is an array */
|
||||
else if (array) { /* name is an array */
|
||||
|
||||
if(oname[array]=='[' && strncmp(name, oname, array)==0 ) { /* basis equal */
|
||||
if (oname[array]=='[' && strncmp(name, oname, array)==0 ) { /* basis equal */
|
||||
|
||||
cursize= DNA_elem_array_size(name, strlen(name));
|
||||
oldsize= DNA_elem_array_size(oname, strlen(oname));
|
||||
|
||||
if(ispointer(name)) { /* handle pointer or functionpointer */
|
||||
if(cursize>oldsize) cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, oname, curdata, olddata);
|
||||
if (ispointer(name)) { /* handle pointer or functionpointer */
|
||||
if (cursize>oldsize) cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, oname, curdata, olddata);
|
||||
else cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, name, curdata, olddata);
|
||||
}
|
||||
else if(name[0]=='*' || strcmp(type, otype)==0 ) { /* type equal */
|
||||
else if (name[0]=='*' || strcmp(type, otype)==0 ) { /* type equal */
|
||||
mul= len/oldsize;
|
||||
mul*= (cursize < oldsize)? cursize: oldsize;
|
||||
memcpy(curdata, olddata, mul);
|
||||
|
||||
/* terminate strings */
|
||||
if(oldsize > cursize && strcmp(type, "char")==0)
|
||||
if (oldsize > cursize && strcmp(type, "char")==0)
|
||||
curdata[mul-1]= 0;
|
||||
}
|
||||
else {
|
||||
if(cursize>oldsize) cast_elem(type, otype, oname, curdata, olddata);
|
||||
if (cursize>oldsize) cast_elem(type, otype, oname, curdata, olddata);
|
||||
else cast_elem(type, otype, name, curdata, olddata);
|
||||
}
|
||||
return;
|
||||
@@ -926,10 +926,10 @@ static void reconstruct_struct(SDNA *newsdna, SDNA *oldsdna,
|
||||
char *type, *cpo, *cpc;
|
||||
const char *name, *nameo;
|
||||
|
||||
if(oldSDNAnr== -1) return;
|
||||
if(curSDNAnr== -1) return;
|
||||
if (oldSDNAnr== -1) return;
|
||||
if (curSDNAnr== -1) return;
|
||||
|
||||
if( compflags[oldSDNAnr]==1 ) { /* if recursive: test for equal */
|
||||
if ( compflags[oldSDNAnr]==1 ) { /* if recursive: test for equal */
|
||||
|
||||
spo= oldsdna->structs[oldSDNAnr];
|
||||
elen= oldsdna->typelens[ spo[0] ];
|
||||
@@ -947,19 +947,19 @@ static void reconstruct_struct(SDNA *newsdna, SDNA *oldsdna,
|
||||
|
||||
spc+= 2;
|
||||
cpc= cur;
|
||||
for(a=0; a<elemcount; a++, spc+=2) {
|
||||
for (a=0; a<elemcount; a++, spc+=2) {
|
||||
type= newsdna->types[spc[0]];
|
||||
name= newsdna->names[spc[1]];
|
||||
|
||||
elen= elementsize(newsdna, spc[0], spc[1]);
|
||||
|
||||
/* test: is type a struct? */
|
||||
if(spc[0]>=firststructtypenr && !ispointer(name)) {
|
||||
if (spc[0]>=firststructtypenr && !ispointer(name)) {
|
||||
|
||||
/* where does the old struct data start (and is there an old one?) */
|
||||
cpo= find_elem(oldsdna, type, name, spo, data, &sppo);
|
||||
|
||||
if(cpo) {
|
||||
if (cpo) {
|
||||
oldSDNAnr= DNA_struct_find_nr(oldsdna, type);
|
||||
curSDNAnr= DNA_struct_find_nr(newsdna, type);
|
||||
|
||||
@@ -973,14 +973,14 @@ static void reconstruct_struct(SDNA *newsdna, SDNA *oldsdna,
|
||||
elen/= mul;
|
||||
eleno/= mulo;
|
||||
|
||||
while(mul--) {
|
||||
while (mul--) {
|
||||
reconstruct_struct(newsdna, oldsdna, compflags, oldSDNAnr, cpo, curSDNAnr, cpc);
|
||||
cpo+= eleno;
|
||||
cpc+= elen;
|
||||
|
||||
/* new struct array larger than old */
|
||||
mulo--;
|
||||
if(mulo<=0) break;
|
||||
if (mulo<=0) break;
|
||||
}
|
||||
}
|
||||
else cpc+= elen;
|
||||
@@ -1004,7 +1004,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
|
||||
char *type, *cpo, *cur, cval;
|
||||
const char *name;
|
||||
|
||||
if(oldSDNAnr== -1) return;
|
||||
if (oldSDNAnr== -1) return;
|
||||
firststructtypenr= *(oldsdna->structs[0]);
|
||||
|
||||
spo= spc= oldsdna->structs[oldSDNAnr];
|
||||
@@ -1014,7 +1014,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
|
||||
spc+= 2;
|
||||
cur= data;
|
||||
|
||||
for(a=0; a<elemcount; a++, spc+=2) {
|
||||
for (a=0; a<elemcount; a++, spc+=2) {
|
||||
type= oldsdna->types[spc[0]];
|
||||
name= oldsdna->names[spc[1]];
|
||||
|
||||
@@ -1022,16 +1022,16 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
|
||||
elen= elementsize(oldsdna, spc[0], spc[1]);
|
||||
|
||||
/* test: is type a struct? */
|
||||
if(spc[0]>=firststructtypenr && !ispointer(name)) {
|
||||
if (spc[0]>=firststructtypenr && !ispointer(name)) {
|
||||
/* where does the old data start (is there one?) */
|
||||
cpo= find_elem(oldsdna, type, name, spo, data, NULL);
|
||||
if(cpo) {
|
||||
if (cpo) {
|
||||
oldSDNAnr= DNA_struct_find_nr(oldsdna, type);
|
||||
|
||||
mul= DNA_elem_array_size(name, strlen(name));
|
||||
elena= elen/mul;
|
||||
|
||||
while(mul--) {
|
||||
while (mul--) {
|
||||
DNA_struct_switch_endian(oldsdna, oldSDNAnr, cpo);
|
||||
cpo += elena;
|
||||
}
|
||||
@@ -1039,12 +1039,12 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
|
||||
}
|
||||
else {
|
||||
|
||||
if(ispointer(name)) {
|
||||
if(oldsdna->pointerlen==8) {
|
||||
if (ispointer(name)) {
|
||||
if (oldsdna->pointerlen==8) {
|
||||
|
||||
mul= DNA_elem_array_size(name, strlen(name));
|
||||
cpo= cur;
|
||||
while(mul--) {
|
||||
while (mul--) {
|
||||
cval= cpo[0]; cpo[0]= cpo[7]; cpo[7]= cval;
|
||||
cval= cpo[1]; cpo[1]= cpo[6]; cpo[6]= cval;
|
||||
cval= cpo[2]; cpo[2]= cpo[5]; cpo[5]= cval;
|
||||
@@ -1063,17 +1063,17 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
|
||||
|
||||
/* exception: variable called blocktype/ipowin: derived from ID_ */
|
||||
skip= 0;
|
||||
if(name[0]=='b' && name[1]=='l') {
|
||||
if(strcmp(name, "blocktype")==0) skip= 1;
|
||||
if (name[0]=='b' && name[1]=='l') {
|
||||
if (strcmp(name, "blocktype")==0) skip= 1;
|
||||
}
|
||||
else if(name[0]=='i' && name[1]=='p') {
|
||||
if(strcmp(name, "ipowin")==0) skip= 1;
|
||||
else if (name[0]=='i' && name[1]=='p') {
|
||||
if (strcmp(name, "ipowin")==0) skip= 1;
|
||||
}
|
||||
|
||||
if(skip==0) {
|
||||
if (skip==0) {
|
||||
mul= DNA_elem_array_size(name, strlen(name));
|
||||
cpo= cur;
|
||||
while(mul--) {
|
||||
while (mul--) {
|
||||
cval= cpo[0];
|
||||
cpo[0]= cpo[1];
|
||||
cpo[1]= cval;
|
||||
@@ -1089,7 +1089,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
|
||||
|
||||
mul= DNA_elem_array_size(name, strlen(name));
|
||||
cpo= cur;
|
||||
while(mul--) {
|
||||
while (mul--) {
|
||||
cval= cpo[0];
|
||||
cpo[0]= cpo[3];
|
||||
cpo[3]= cval;
|
||||
@@ -1104,7 +1104,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
|
||||
{
|
||||
mul= DNA_elem_array_size(name, strlen(name));
|
||||
cpo= cur;
|
||||
while(mul--) {
|
||||
while (mul--) {
|
||||
cval= cpo[0]; cpo[0]= cpo[7]; cpo[7]= cval;
|
||||
cval= cpo[1]; cpo[1]= cpo[6]; cpo[6]= cval;
|
||||
cval= cpo[2]; cpo[2]= cpo[5]; cpo[5]= cval;
|
||||
@@ -1132,18 +1132,18 @@ void *DNA_struct_reconstruct(SDNA *newsdna, SDNA *oldsdna, char *compflags, int
|
||||
curSDNAnr= DNA_struct_find_nr(newsdna, type);
|
||||
|
||||
/* init data and alloc */
|
||||
if(curSDNAnr >= 0) {
|
||||
if (curSDNAnr >= 0) {
|
||||
spc= newsdna->structs[curSDNAnr];
|
||||
curlen= newsdna->typelens[ spc[0] ];
|
||||
}
|
||||
if(curlen==0) {
|
||||
if (curlen==0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cur= MEM_callocN( blocks*curlen, "reconstruct");
|
||||
cpc= cur;
|
||||
cpo= data;
|
||||
for(a=0; a<blocks; a++) {
|
||||
for (a=0; a<blocks; a++) {
|
||||
reconstruct_struct(newsdna, oldsdna, compflags, oldSDNAnr, cpo, curSDNAnr, cpc);
|
||||
cpc+= curlen;
|
||||
cpo+= oldlen;
|
||||
|
||||
@@ -228,7 +228,7 @@ static int add_type(const char *str, int len)
|
||||
char *cp;
|
||||
|
||||
/* first do validity check */
|
||||
if(str[0]==0) {
|
||||
if (str[0]==0) {
|
||||
return -1;
|
||||
}
|
||||
else if (strchr(str, '*')) {
|
||||
@@ -238,8 +238,8 @@ static int add_type(const char *str, int len)
|
||||
}
|
||||
|
||||
/* search through type array */
|
||||
for(nr=0; nr<nr_types; nr++) {
|
||||
if(strcmp(str, types[nr])==0) {
|
||||
for (nr=0; nr<nr_types; nr++) {
|
||||
if (strcmp(str, types[nr])==0) {
|
||||
if (len) {
|
||||
typelens[nr]= len;
|
||||
alphalens[nr] = len;
|
||||
@@ -249,7 +249,7 @@ static int add_type(const char *str, int len)
|
||||
}
|
||||
|
||||
/* append new type */
|
||||
if(nr_types==0) cp= typedata;
|
||||
if (nr_types==0) cp= typedata;
|
||||
else {
|
||||
cp= types[nr_types-1]+strlen(types[nr_types-1])+1;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ static int add_type(const char *str, int len)
|
||||
typelens[nr_types]= len;
|
||||
alphalens[nr_types]= len;
|
||||
|
||||
if(nr_types>=maxnr) {
|
||||
if (nr_types>=maxnr) {
|
||||
printf("too many types\n");
|
||||
return nr_types-1;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ static int add_name(const char *str)
|
||||
|
||||
additional_slen_offset = 0;
|
||||
|
||||
if(str[0]==0 /* || (str[1]==0) */) return -1;
|
||||
if (str[0]==0 /* || (str[1]==0) */) return -1;
|
||||
|
||||
if (str[0] == '(' && str[1] == '*') {
|
||||
/* we handle function pointer and special array cases here, e.g.
|
||||
@@ -321,7 +321,7 @@ static int add_name(const char *str)
|
||||
|
||||
if (!isfuncptr) {
|
||||
/* multidimensional array pointer case */
|
||||
if(str[j] == 0) {
|
||||
if (str[j] == 0) {
|
||||
if (debugSDNA > 3) printf("offsetting for multidim array pointer\n");
|
||||
}
|
||||
else
|
||||
@@ -337,10 +337,12 @@ static int add_name(const char *str)
|
||||
}
|
||||
if (debugSDNA > 3) printf("extra offset %d\n", k);
|
||||
additional_slen_offset = k;
|
||||
} else if (str[j] == ')' ) {
|
||||
}
|
||||
else if (str[j] == ')' ) {
|
||||
if (debugSDNA > 3) printf("offsetting for brace\n");
|
||||
; /* don't get extra offset */
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
printf("Error during tokening function pointer argument list\n");
|
||||
}
|
||||
|
||||
@@ -368,7 +370,8 @@ static int add_name(const char *str)
|
||||
buf[i+5] = 'd';
|
||||
buf[i+6] = ')';
|
||||
buf[i+7] = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
buf[i] = ')';
|
||||
buf[i+1] = '(';
|
||||
buf[i+2] = ')';
|
||||
@@ -377,27 +380,28 @@ static int add_name(const char *str)
|
||||
/* now precede with buf*/
|
||||
if (debugSDNA > 3) printf("\t\t\t\t\tProposing fp name %s\n", buf);
|
||||
name = buf;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* normal field: old code */
|
||||
name = str;
|
||||
}
|
||||
|
||||
/* search name array */
|
||||
for(nr=0; nr<nr_names; nr++) {
|
||||
if(strcmp(name, names[nr])==0) {
|
||||
for (nr=0; nr<nr_names; nr++) {
|
||||
if (strcmp(name, names[nr])==0) {
|
||||
return nr;
|
||||
}
|
||||
}
|
||||
|
||||
/* append new type */
|
||||
if(nr_names==0) cp= namedata;
|
||||
if (nr_names==0) cp= namedata;
|
||||
else {
|
||||
cp= names[nr_names-1]+strlen(names[nr_names-1])+1;
|
||||
}
|
||||
strcpy(cp, name);
|
||||
names[nr_names]= cp;
|
||||
|
||||
if(nr_names>=maxnr) {
|
||||
if (nr_names>=maxnr) {
|
||||
printf("too many names\n");
|
||||
return nr_names-1;
|
||||
}
|
||||
@@ -411,7 +415,7 @@ static short *add_struct(int namecode)
|
||||
int len;
|
||||
short *sp;
|
||||
|
||||
if(nr_structs==0) {
|
||||
if (nr_structs==0) {
|
||||
structs[0]= structdata;
|
||||
}
|
||||
else {
|
||||
@@ -423,7 +427,7 @@ static short *add_struct(int namecode)
|
||||
sp= structs[nr_structs];
|
||||
sp[0]= namecode;
|
||||
|
||||
if(nr_structs>=maxnr) {
|
||||
if (nr_structs>=maxnr) {
|
||||
printf("too many structs\n");
|
||||
return sp;
|
||||
}
|
||||
@@ -449,10 +453,11 @@ static int preprocess_include(char *maindata, int len)
|
||||
cp= temp;
|
||||
a= len;
|
||||
comment = 0;
|
||||
while(a--) {
|
||||
if(cp[0]=='/' && cp[1]=='/') {
|
||||
while (a--) {
|
||||
if (cp[0]=='/' && cp[1]=='/') {
|
||||
comment = 1;
|
||||
} else if (*cp<32) {
|
||||
}
|
||||
else if (*cp<32) {
|
||||
comment = 0;
|
||||
}
|
||||
if (comment || *cp<32 || *cp>128 ) *cp= 32;
|
||||
@@ -466,21 +471,21 @@ static int preprocess_include(char *maindata, int len)
|
||||
newlen= 0;
|
||||
comment= 0;
|
||||
a= len;
|
||||
while(a--) {
|
||||
while (a--) {
|
||||
|
||||
if(cp[0]=='/' && cp[1]=='*') {
|
||||
if (cp[0]=='/' && cp[1]=='*') {
|
||||
comment= 1;
|
||||
cp[0]=cp[1]= 32;
|
||||
}
|
||||
if(cp[0]=='*' && cp[1]=='/') {
|
||||
if (cp[0]=='*' && cp[1]=='/') {
|
||||
comment= 0;
|
||||
cp[0]=cp[1]= 32;
|
||||
}
|
||||
|
||||
/* do not copy when: */
|
||||
if(comment);
|
||||
else if( cp[0]==' ' && cp[1]==' ' );
|
||||
else if( cp[-1]=='*' && cp[0]==' ' ); /* pointers with a space */
|
||||
if (comment);
|
||||
else if ( cp[0]==' ' && cp[1]==' ' );
|
||||
else if ( cp[-1]=='*' && cp[0]==' ' ); /* pointers with a space */
|
||||
|
||||
/* skip special keywords */
|
||||
else if (strncmp("DNA_DEPRECATED", cp, 14)==0) {
|
||||
@@ -557,26 +562,26 @@ static int convert_include(char *filename)
|
||||
/* we look for '{' and then back to 'struct' */
|
||||
count= 0;
|
||||
overslaan= 0;
|
||||
while(count<filelen) {
|
||||
while (count<filelen) {
|
||||
|
||||
/* code for skipping a struct: two hashes on 2 lines. (preprocess added a space) */
|
||||
if(md[0]=='#' && md[1]==' ' && md[2]=='#') {
|
||||
if (md[0]=='#' && md[1]==' ' && md[2]=='#') {
|
||||
overslaan= 1;
|
||||
}
|
||||
|
||||
if(md[0]=='{') {
|
||||
if (md[0]=='{') {
|
||||
md[0]= 0;
|
||||
if(overslaan) {
|
||||
if (overslaan) {
|
||||
overslaan= 0;
|
||||
}
|
||||
else {
|
||||
if(md[-1]==' ') md[-1]= 0;
|
||||
if (md[-1]==' ') md[-1]= 0;
|
||||
md1= md-2;
|
||||
while( *md1!=32) md1--; /* to beginning of word */
|
||||
while ( *md1!=32) md1--; /* to beginning of word */
|
||||
md1++;
|
||||
|
||||
/* we've got a struct name when... */
|
||||
if( strncmp(md1-7, "struct", 6)==0 ) {
|
||||
if ( strncmp(md1-7, "struct", 6)==0 ) {
|
||||
|
||||
strct = add_type(md1, 0);
|
||||
if (strct == -1) {
|
||||
@@ -591,23 +596,23 @@ static int convert_include(char *filename)
|
||||
|
||||
/* first lets make it all nice strings */
|
||||
md1= md+1;
|
||||
while(*md1 != '}') {
|
||||
if(md1>mainend) break;
|
||||
while (*md1 != '}') {
|
||||
if (md1>mainend) break;
|
||||
|
||||
if(*md1==',' || *md1==' ') *md1= 0;
|
||||
if (*md1==',' || *md1==' ') *md1= 0;
|
||||
md1++;
|
||||
}
|
||||
|
||||
/* read types and names until first character that is not '}' */
|
||||
md1= md+1;
|
||||
while( *md1 != '}' ) {
|
||||
if(md1>mainend) break;
|
||||
while ( *md1 != '}' ) {
|
||||
if (md1>mainend) break;
|
||||
|
||||
/* skip when it says 'struct' or 'unsigned' or 'const' */
|
||||
if(*md1) {
|
||||
if( strncmp(md1, "struct", 6)==0 ) md1+= 7;
|
||||
if( strncmp(md1, "unsigned", 8)==0 ) md1+= 9;
|
||||
if( strncmp(md1, "const", 5)==0 ) md1+= 6;
|
||||
if (*md1) {
|
||||
if ( strncmp(md1, "struct", 6)==0 ) md1+= 7;
|
||||
if ( strncmp(md1, "unsigned", 8)==0 ) md1+= 9;
|
||||
if ( strncmp(md1, "const", 5)==0 ) md1+= 6;
|
||||
|
||||
/* we've got a type! */
|
||||
type= add_type(md1, 0);
|
||||
@@ -622,15 +627,15 @@ static int convert_include(char *filename)
|
||||
|
||||
|
||||
/* read until ';' */
|
||||
while( *md1 != ';' ) {
|
||||
if(md1>mainend) break;
|
||||
while ( *md1 != ';' ) {
|
||||
if (md1>mainend) break;
|
||||
|
||||
if(*md1) {
|
||||
if (*md1) {
|
||||
/* We've got a name. slen needs
|
||||
* correction for function
|
||||
* pointers! */
|
||||
slen= (int) strlen(md1);
|
||||
if( md1[slen-1]==';' ) {
|
||||
if ( md1[slen-1]==';' ) {
|
||||
md1[slen-1]= 0;
|
||||
|
||||
|
||||
@@ -688,11 +693,11 @@ static int arraysize(char *astr, int len)
|
||||
|
||||
memcpy(str, astr, len+1);
|
||||
|
||||
for(a=0; a<len; a++) {
|
||||
if( str[a]== '[' ) {
|
||||
for (a=0; a<len; a++) {
|
||||
if ( str[a]== '[' ) {
|
||||
cp= &(str[a+1]);
|
||||
}
|
||||
else if( str[a]==']' && cp) {
|
||||
else if ( str[a]==']' && cp) {
|
||||
str[a]= 0;
|
||||
/* if 'cp' is a preprocessor definition, it will evaluate to 0,
|
||||
* the caller needs to check for this case and throw an error */
|
||||
@@ -710,17 +715,17 @@ static int calculate_structlens(int firststruct)
|
||||
char *cp;
|
||||
int has_pointer, dna_error = 0;
|
||||
|
||||
while(unknown) {
|
||||
while (unknown) {
|
||||
lastunknown= unknown;
|
||||
unknown= 0;
|
||||
|
||||
/* check all structs... */
|
||||
for(a=0; a<nr_structs; a++) {
|
||||
for (a=0; a<nr_structs; a++) {
|
||||
structpoin= structs[a];
|
||||
structtype= structpoin[0];
|
||||
|
||||
/* when length is not known... */
|
||||
if(typelens[structtype]==0) {
|
||||
if (typelens[structtype]==0) {
|
||||
|
||||
sp= structpoin+2;
|
||||
len= 0;
|
||||
@@ -728,17 +733,17 @@ static int calculate_structlens(int firststruct)
|
||||
has_pointer = 0;
|
||||
|
||||
/* check all elements in struct */
|
||||
for(b=0; b<structpoin[1]; b++, sp+=2) {
|
||||
for (b=0; b<structpoin[1]; b++, sp+=2) {
|
||||
type= sp[0];
|
||||
cp= names[sp[1]];
|
||||
|
||||
namelen= (int) strlen(cp);
|
||||
/* is it a pointer or function pointer? */
|
||||
if(cp[0]=='*' || cp[1]=='*') {
|
||||
if (cp[0]=='*' || cp[1]=='*') {
|
||||
has_pointer = 1;
|
||||
/* has the name an extra length? (array) */
|
||||
mul= 1;
|
||||
if( cp[namelen-1]==']') mul= arraysize(cp, namelen);
|
||||
if ( cp[namelen-1]==']') mul= arraysize(cp, namelen);
|
||||
|
||||
if (mul == 0) {
|
||||
printf("Zero array size found or could not parse %s: '%.*s'\n", types[structtype], namelen + 1, cp);
|
||||
@@ -746,12 +751,13 @@ static int calculate_structlens(int firststruct)
|
||||
}
|
||||
|
||||
/* 4-8 aligned/ */
|
||||
if(sizeof(void *) == 4) {
|
||||
if (sizeof(void *) == 4) {
|
||||
if (len % 4) {
|
||||
printf("Align pointer error in struct (len4): %s %s\n", types[structtype], cp);
|
||||
dna_error = 1;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (len % 8) {
|
||||
printf("Align pointer error in struct (len8): %s %s\n", types[structtype], cp);
|
||||
dna_error = 1;
|
||||
@@ -766,14 +772,16 @@ static int calculate_structlens(int firststruct)
|
||||
len += sizeof(void *) * mul;
|
||||
alphalen += 8 * mul;
|
||||
|
||||
} else if(cp[0]=='[') {
|
||||
}
|
||||
else if (cp[0]=='[') {
|
||||
/* parsing can cause names "var" and "[3]" to be found for "float var [3]" ... */
|
||||
printf("Parse error in struct, invalid member name: %s %s\n", types[structtype], cp);
|
||||
dna_error = 1;
|
||||
} else if( typelens[type] ) {
|
||||
}
|
||||
else if ( typelens[type] ) {
|
||||
/* has the name an extra length? (array) */
|
||||
mul= 1;
|
||||
if( cp[namelen-1]==']') mul= arraysize(cp, namelen);
|
||||
if ( cp[namelen-1]==']') mul= arraysize(cp, namelen);
|
||||
|
||||
if (mul == 0) {
|
||||
printf("Zero array size found or could not parse %s: '%.*s'\n", types[structtype], namelen + 1, cp);
|
||||
@@ -781,19 +789,19 @@ static int calculate_structlens(int firststruct)
|
||||
}
|
||||
|
||||
/* struct alignment */
|
||||
if(type >= firststruct) {
|
||||
if(sizeof(void *)==8 && (len % 8) ) {
|
||||
if (type >= firststruct) {
|
||||
if (sizeof(void *)==8 && (len % 8) ) {
|
||||
printf("Align struct error: %s %s\n", types[structtype],cp);
|
||||
dna_error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 2-4 aligned/ */
|
||||
if(typelens[type]>3 && (len % 4) ) {
|
||||
if (typelens[type]>3 && (len % 4) ) {
|
||||
printf("Align 4 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len%4);
|
||||
dna_error = 1;
|
||||
}
|
||||
else if(typelens[type]==2 && (len % 2) ) {
|
||||
else if (typelens[type]==2 && (len % 2) ) {
|
||||
printf("Align 2 error in struct: %s %s (add %d padding bytes)\n", types[structtype], cp, len%2);
|
||||
dna_error = 1;
|
||||
}
|
||||
@@ -801,7 +809,8 @@ static int calculate_structlens(int firststruct)
|
||||
len += mul*typelens[type];
|
||||
alphalen += mul * alphalens[type];
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
len= 0;
|
||||
alphalen = 0;
|
||||
break;
|
||||
@@ -810,7 +819,8 @@ static int calculate_structlens(int firststruct)
|
||||
|
||||
if (len==0) {
|
||||
unknown++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
typelens[structtype]= len;
|
||||
alphalens[structtype]= alphalen;
|
||||
// two ways to detect if a struct contains a pointer:
|
||||
@@ -822,7 +832,7 @@ static int calculate_structlens(int firststruct)
|
||||
}
|
||||
}
|
||||
|
||||
if(len % 4) {
|
||||
if (len % 4) {
|
||||
printf("Sizeerror 4 in struct: %s (add %d bytes)\n", types[structtype], len%4);
|
||||
dna_error = 1;
|
||||
}
|
||||
@@ -831,21 +841,21 @@ static int calculate_structlens(int firststruct)
|
||||
}
|
||||
}
|
||||
|
||||
if(unknown==lastunknown) break;
|
||||
if (unknown==lastunknown) break;
|
||||
}
|
||||
|
||||
if(unknown) {
|
||||
if (unknown) {
|
||||
printf("ERROR: still %d structs unknown\n", unknown);
|
||||
|
||||
if (debugSDNA) {
|
||||
printf("*** Known structs : \n");
|
||||
|
||||
for(a=0; a<nr_structs; a++) {
|
||||
for (a=0; a<nr_structs; a++) {
|
||||
structpoin= structs[a];
|
||||
structtype= structpoin[0];
|
||||
|
||||
/* length unknown */
|
||||
if(typelens[structtype]!=0) {
|
||||
if (typelens[structtype]!=0) {
|
||||
printf(" %s\n", types[structtype]);
|
||||
}
|
||||
}
|
||||
@@ -854,12 +864,12 @@ static int calculate_structlens(int firststruct)
|
||||
|
||||
printf("*** Unknown structs : \n");
|
||||
|
||||
for(a=0; a<nr_structs; a++) {
|
||||
for (a=0; a<nr_structs; a++) {
|
||||
structpoin= structs[a];
|
||||
structtype= structpoin[0];
|
||||
|
||||
/* length unknown yet */
|
||||
if(typelens[structtype]==0) {
|
||||
if (typelens[structtype]==0) {
|
||||
printf(" %s\n", types[structtype]);
|
||||
}
|
||||
}
|
||||
@@ -896,12 +906,12 @@ void printStructLenghts(void)
|
||||
short *structpoin;
|
||||
printf("\n\n*** All detected structs:\n");
|
||||
|
||||
while(unknown) {
|
||||
while (unknown) {
|
||||
/*lastunknown= unknown;*/ /*UNUSED*/
|
||||
unknown= 0;
|
||||
|
||||
/* check all structs... */
|
||||
for(a=0; a<nr_structs; a++) {
|
||||
for (a=0; a<nr_structs; a++) {
|
||||
structpoin= structs[a];
|
||||
structtype= structpoin[0];
|
||||
printf("\t%s\t:%d\n", types[structtype], typelens[structtype]);
|
||||
@@ -984,24 +994,24 @@ static int make_structDNA(char *baseDirectory, FILE *file)
|
||||
short num_types;
|
||||
|
||||
printf("nr_names %d nr_types %d nr_structs %d\n", nr_names, nr_types, nr_structs);
|
||||
for(a=0; a<nr_names; a++) {
|
||||
for (a=0; a<nr_names; a++) {
|
||||
printf(" %s \n", names[a]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
sp= typelens;
|
||||
for(a=0; a<nr_types; a++, sp++) {
|
||||
for (a=0; a<nr_types; a++, sp++) {
|
||||
printf(" %s %d\n", types[a], *sp);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
for(a=0; a<nr_structs; a++) {
|
||||
for (a=0; a<nr_structs; a++) {
|
||||
sp= structs[a];
|
||||
printf(" struct %s elems: %d size: %d\n", types[sp[0]], sp[1],typelens[sp[0]]);
|
||||
num_types = sp[1];
|
||||
sp+= 2;
|
||||
/* ? num_types was elem? */
|
||||
for(b=0; b< num_types; b++, sp+= 2) {
|
||||
for (b=0; b< num_types; b++, sp+= 2) {
|
||||
printf(" %s %s\n", types[sp[0]], names[sp[1]]);
|
||||
}
|
||||
}
|
||||
@@ -1011,7 +1021,7 @@ static int make_structDNA(char *baseDirectory, FILE *file)
|
||||
|
||||
if (debugSDNA > -1) printf("Writing file ... ");
|
||||
|
||||
if(nr_names==0 || nr_structs==0);
|
||||
if (nr_names==0 || nr_structs==0);
|
||||
else {
|
||||
strcpy(str, "SDNA");
|
||||
dna_write(file, str, 4);
|
||||
@@ -1048,7 +1058,7 @@ static int make_structDNA(char *baseDirectory, FILE *file)
|
||||
dna_write(file, str, 4);
|
||||
|
||||
len= 2*nr_types;
|
||||
if(nr_types & 1) len+= 2;
|
||||
if (nr_types & 1) len+= 2;
|
||||
dna_write(file, typelens, len);
|
||||
|
||||
/* WRITE STRUCTS */
|
||||
@@ -1071,7 +1081,7 @@ static int make_structDNA(char *baseDirectory, FILE *file)
|
||||
int a;
|
||||
|
||||
fp= fopen("padding.c", "w");
|
||||
if(fp==NULL);
|
||||
if (fp==NULL);
|
||||
else {
|
||||
|
||||
// add all include files defined in the global array
|
||||
@@ -1079,11 +1089,11 @@ static int make_structDNA(char *baseDirectory, FILE *file)
|
||||
fprintf(fp, "#include \"%s%s\"\n", baseDirectory, includefiles[i]);
|
||||
}
|
||||
|
||||
fprintf(fp, "main(){\n");
|
||||
fprintf(fp, "main() {\n");
|
||||
sp = typelens;
|
||||
sp += firststruct;
|
||||
for(a=firststruct; a<nr_types; a++, sp++) {
|
||||
if(*sp) {
|
||||
for (a=firststruct; a<nr_types; a++, sp++) {
|
||||
if (*sp) {
|
||||
fprintf(fp, "\tif(sizeof(struct %s) - %d) printf(\"ALIGN ERROR:", types[a], *sp);
|
||||
fprintf(fp, "%%d %s %d ", types[a], *sp);
|
||||
fprintf(fp, "\\n\", sizeof(struct %s) - %d);\n", types[a], *sp);
|
||||
@@ -1132,17 +1142,20 @@ int main(int argc, char ** argv)
|
||||
if (argc!=2 && argc!=3) {
|
||||
printf("Usage: %s outfile.c [base directory]\n", argv[0]);
|
||||
return_status = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
file = fopen(argv[1], "w");
|
||||
if (!file) {
|
||||
printf ("Unable to open file: %s\n", argv[1]);
|
||||
return_status = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
char baseDirectory[256];
|
||||
|
||||
if (argc==3) {
|
||||
strcpy(baseDirectory, argv[2]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
strcpy(baseDirectory, BASE_HEADER);
|
||||
}
|
||||
|
||||
@@ -1152,7 +1165,8 @@ int main(int argc, char ** argv)
|
||||
fclose(file);
|
||||
make_bad_file(argv[1], __LINE__);
|
||||
return_status = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(file, "};\n");
|
||||
fprintf(file, "int DNAlen= sizeof(DNAstr);\n");
|
||||
|
||||
|
||||
@@ -607,12 +607,12 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
|
||||
"get_length");
|
||||
fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
|
||||
fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
|
||||
fprintf(f, " for(i=0; i<len; i++) {\n");
|
||||
fprintf(f, " for (i=0; i<len; i++) {\n");
|
||||
MEM_freeN(lenfunc);
|
||||
}
|
||||
else {
|
||||
fprintf(f, " int i;\n\n");
|
||||
fprintf(f, " for(i=0; i<%u; i++) {\n", prop->totarraylength);
|
||||
fprintf(f, " for (i=0; i<%u; i++) {\n", prop->totarraylength);
|
||||
}
|
||||
|
||||
if (dp->dnaarraylength == 1) {
|
||||
@@ -801,20 +801,20 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
|
||||
|
||||
if (prop->flag & PROP_ID_SELF_CHECK) {
|
||||
rna_print_id_get(f, dp);
|
||||
fprintf(f, " if(id==value.data) return;\n\n");
|
||||
fprintf(f, " if (id==value.data) return;\n\n");
|
||||
}
|
||||
|
||||
if (prop->flag & PROP_ID_REFCOUNT) {
|
||||
fprintf(f, "\n if(data->%s)\n", dp->dnaname);
|
||||
fprintf(f, "\n if (data->%s)\n", dp->dnaname);
|
||||
fprintf(f, " id_us_min((ID*)data->%s);\n", dp->dnaname);
|
||||
fprintf(f, " if(value.data)\n");
|
||||
fprintf(f, " if (value.data)\n");
|
||||
fprintf(f, " id_us_plus((ID*)value.data);\n\n");
|
||||
}
|
||||
else {
|
||||
PointerPropertyRNA *pprop = (PointerPropertyRNA*)dp->prop;
|
||||
StructRNA *type = rna_find_struct((const char*)pprop->type);
|
||||
if (type && (type->flag & STRUCT_ID)) {
|
||||
fprintf(f, " if(value.data)\n");
|
||||
fprintf(f, " if (value.data)\n");
|
||||
fprintf(f, " id_lib_extern((ID*)value.data);\n\n");
|
||||
}
|
||||
}
|
||||
@@ -846,18 +846,18 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
|
||||
fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
|
||||
fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc);
|
||||
rna_clamp_value_range(f, prop);
|
||||
fprintf(f, " for(i=0; i<len; i++) {\n");
|
||||
fprintf(f, " for (i=0; i<len; i++) {\n");
|
||||
MEM_freeN(lenfunc);
|
||||
}
|
||||
else {
|
||||
fprintf(f, " int i;\n\n");
|
||||
rna_clamp_value_range(f, prop);
|
||||
fprintf(f, " for(i=0; i<%u; i++) {\n", prop->totarraylength);
|
||||
fprintf(f, " for (i=0; i<%u; i++) {\n", prop->totarraylength);
|
||||
}
|
||||
|
||||
if (dp->dnaarraylength == 1) {
|
||||
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
||||
fprintf(f, " if(%svalues[i]) data->%s |= (%d<<i);\n",
|
||||
fprintf(f, " if (%svalues[i]) data->%s |= (%d<<i);\n",
|
||||
(dp->booleannegative)? "!": "", dp->dnaname, dp->booleanbit);
|
||||
fprintf(f, " else data->%s &= ~(%d<<i);\n", dp->dnaname, dp->booleanbit);
|
||||
}
|
||||
@@ -868,7 +868,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
|
||||
}
|
||||
else {
|
||||
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
||||
fprintf(f, " if(%svalues[i]) data->%s[i] |= ", (dp->booleannegative) ? "!" : "",
|
||||
fprintf(f, " if (%svalues[i]) data->%s[i] |= ", (dp->booleannegative) ? "!" : "",
|
||||
dp->dnaname);
|
||||
rna_int_print(f, dp->booleanbit);
|
||||
fprintf(f, ";\n");
|
||||
@@ -902,7 +902,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
|
||||
else {
|
||||
rna_print_data_get(f, dp);
|
||||
if (prop->type == PROP_BOOLEAN && dp->booleanbit) {
|
||||
fprintf(f, " if(%svalue) data->%s |= ", (dp->booleannegative) ? "!" : "", dp->dnaname);
|
||||
fprintf(f, " if (%svalue) data->%s |= ", (dp->booleannegative) ? "!" : "", dp->dnaname);
|
||||
rna_int_print(f, dp->booleanbit);
|
||||
fprintf(f, ";\n");
|
||||
fprintf(f, " else data->%s &= ~", dp->dnaname);
|
||||
@@ -1043,7 +1043,7 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *
|
||||
|
||||
getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
|
||||
|
||||
fprintf(f, "\n if(iter->valid)\n");
|
||||
fprintf(f, "\n if (iter->valid)\n");
|
||||
fprintf(f, " iter->ptr= %s(iter);\n", getfunc);
|
||||
|
||||
fprintf(f, "}\n\n");
|
||||
@@ -1087,19 +1087,19 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
|
||||
fprintf(f, " CollectionPropertyIterator iter;\n\n");
|
||||
|
||||
fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier));
|
||||
fprintf(f, " if(iter.valid){\n");
|
||||
fprintf(f, " if (iter.valid) {\n");
|
||||
|
||||
if (strcmp(nextfunc, "rna_iterator_array_next") == 0) {
|
||||
fprintf(f, " ArrayIterator *internal= iter.internal;\n");
|
||||
fprintf(f, " if(index < 0 || index >= internal->length) {\n");
|
||||
fprintf(f, " if (index < 0 || index >= internal->length) {\n");
|
||||
fprintf(f, "#ifdef __GNUC__\n");
|
||||
fprintf(f, " printf(\"Array iterator out of range: %%s (index %%d)\\n\", __func__, index);\n");
|
||||
fprintf(f, "#else\n");
|
||||
fprintf(f, " printf(\"Array iterator out of range: (index %%d)\\n\", index);\n");
|
||||
fprintf(f, "#endif\n");
|
||||
fprintf(f, " }\n");
|
||||
fprintf(f, " else if(internal->skip) {\n");
|
||||
fprintf(f, " while(index-- > 0 && iter.valid) {\n");
|
||||
fprintf(f, " else if (internal->skip) {\n");
|
||||
fprintf(f, " while (index-- > 0 && iter.valid) {\n");
|
||||
fprintf(f, " rna_iterator_array_next(&iter);\n");
|
||||
fprintf(f, " }\n");
|
||||
fprintf(f, " found= (index == -1 && iter.valid);\n");
|
||||
@@ -1111,20 +1111,20 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property
|
||||
}
|
||||
else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) {
|
||||
fprintf(f, " ListBaseIterator *internal= iter.internal;\n");
|
||||
fprintf(f, " if(internal->skip) {\n");
|
||||
fprintf(f, " while(index-- > 0 && iter.valid) {\n");
|
||||
fprintf(f, " if (internal->skip) {\n");
|
||||
fprintf(f, " while (index-- > 0 && iter.valid) {\n");
|
||||
fprintf(f, " rna_iterator_listbase_next(&iter);\n");
|
||||
fprintf(f, " }\n");
|
||||
fprintf(f, " found= (index == -1 && iter.valid);\n");
|
||||
fprintf(f, " }\n");
|
||||
fprintf(f, " else {\n");
|
||||
fprintf(f, " while(index-- > 0 && internal->link)\n");
|
||||
fprintf(f, " while (index-- > 0 && internal->link)\n");
|
||||
fprintf(f, " internal->link= internal->link->next;\n");
|
||||
fprintf(f, " found= (index == -1 && internal->link);\n");
|
||||
fprintf(f, " }\n");
|
||||
}
|
||||
|
||||
fprintf(f, " if(found) *r_ptr = %s_%s_get(&iter);\n", srna->identifier, rna_safe_id(prop->identifier));
|
||||
fprintf(f, " if (found) *r_ptr = %s_%s_get(&iter);\n", srna->identifier, rna_safe_id(prop->identifier));
|
||||
fprintf(f, " }\n\n");
|
||||
fprintf(f, " %s_%s_end(&iter);\n\n", srna->identifier, rna_safe_id(prop->identifier));
|
||||
|
||||
@@ -1175,7 +1175,7 @@ static char *rna_def_property_next_func(FILE *f, StructRNA *srna, PropertyRNA *p
|
||||
|
||||
getfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier), "get");
|
||||
|
||||
fprintf(f, "\n if(iter->valid)\n");
|
||||
fprintf(f, "\n if (iter->valid)\n");
|
||||
fprintf(f, " iter->ptr= %s(iter);\n", getfunc);
|
||||
|
||||
fprintf(f, "}\n\n");
|
||||
@@ -2754,7 +2754,7 @@ static void rna_generate_header(BlenderRNA *brna, FILE *f)
|
||||
fprintf(f, "#define FOREACH_BEGIN(property, sptr, itemptr) \\\n");
|
||||
fprintf(f, " { \\\n");
|
||||
fprintf(f, " CollectionPropertyIterator rna_macro_iter; \\\n");
|
||||
fprintf(f, " for(property##_begin(&rna_macro_iter, sptr); rna_macro_iter.valid; "
|
||||
fprintf(f, " for (property##_begin(&rna_macro_iter, sptr); rna_macro_iter.valid; "
|
||||
"property##_next(&rna_macro_iter)) { \\\n");
|
||||
fprintf(f, " itemptr= rna_macro_iter.ptr;\n\n");
|
||||
|
||||
|
||||
@@ -1179,7 +1179,8 @@ void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA
|
||||
|
||||
if (*free) {
|
||||
nitem = *item;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int totitem = 0;
|
||||
|
||||
/* count */
|
||||
@@ -2721,7 +2722,7 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA
|
||||
|
||||
/* py api calls directly */
|
||||
#if 0
|
||||
else if (cprop->add){
|
||||
else if (cprop->add) {
|
||||
if (!(cprop->add->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */
|
||||
ParameterList params;
|
||||
RNA_parameter_list_create(¶ms, ptr, cprop->add);
|
||||
@@ -2778,7 +2779,7 @@ int RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key)
|
||||
|
||||
/* py api calls directly */
|
||||
#if 0
|
||||
else if (cprop->remove){
|
||||
else if (cprop->remove) {
|
||||
if (!(cprop->remove->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */
|
||||
ParameterList params;
|
||||
RNA_parameter_list_create(¶ms, ptr, cprop->remove);
|
||||
|
||||
@@ -341,11 +341,13 @@ static void rna_ActionActuator_add_set(struct PointerRNA *ptr, int value)
|
||||
bActuator *act = (bActuator *)ptr->data;
|
||||
bActionActuator *aa = act->data;
|
||||
|
||||
if (value == 1){
|
||||
if (value == 1) {
|
||||
aa->flag &= ~ACT_IPOFORCE;
|
||||
aa->flag |= ACT_IPOADD;
|
||||
}else
|
||||
}
|
||||
else {
|
||||
aa->flag &= ~ACT_IPOADD;
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_ActionActuator_force_set(struct PointerRNA *ptr, int value)
|
||||
@@ -353,11 +355,13 @@ static void rna_ActionActuator_force_set(struct PointerRNA *ptr, int value)
|
||||
bActuator *act = (bActuator *)ptr->data;
|
||||
bActionActuator *aa = act->data;
|
||||
|
||||
if (value == 1){
|
||||
if (value == 1) {
|
||||
aa->flag &= ~ACT_IPOADD;
|
||||
aa->flag |= ACT_IPOFORCE;
|
||||
}else
|
||||
}
|
||||
else {
|
||||
aa->flag &= ~ACT_IPOFORCE;
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_ObjectActuator_type_set(struct PointerRNA *ptr, int value)
|
||||
@@ -422,9 +426,10 @@ EnumPropertyItem *rna_Actuator_type_itemf(bContext *C, PointerRNA *ptr, Property
|
||||
Object *ob = NULL;
|
||||
int totitem = 0;
|
||||
|
||||
if (ptr->type == &RNA_Actuator || RNA_struct_is_a(ptr->type, &RNA_Actuator)){
|
||||
if (ptr->type == &RNA_Actuator || RNA_struct_is_a(ptr->type, &RNA_Actuator)) {
|
||||
ob = (Object *)ptr->id.data;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* can't use ob from ptr->id.data because that enum is also used by operators */
|
||||
ob = CTX_data_active_object(C);
|
||||
}
|
||||
|
||||
@@ -316,7 +316,8 @@ static void rna_ActionConstraint_minmax_range(PointerRNA *ptr, float *min, float
|
||||
if (ELEM3(acon->type, 0, 1, 2)) {
|
||||
*min = -180.0f;
|
||||
*max = 180.0f;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
*min = -1000.f;
|
||||
*max = 1000.f;
|
||||
}
|
||||
@@ -374,7 +375,8 @@ static void rna_Constraint_followTrack_camera_set(PointerRNA *ptr, PointerRNA va
|
||||
if (ob->type == OB_CAMERA && ob != (Object*)ptr->id.data) {
|
||||
data->camera = ob;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
data->camera = NULL;
|
||||
}
|
||||
}
|
||||
@@ -389,7 +391,8 @@ static void rna_Constraint_followTrack_depthObject_set(PointerRNA *ptr, PointerR
|
||||
if (ob->type == OB_MESH && ob != (Object*)ptr->id.data) {
|
||||
data->depth_ob = ob;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
data->depth_ob = NULL;
|
||||
}
|
||||
}
|
||||
@@ -417,7 +420,8 @@ static void rna_Constraint_objectSolver_camera_set(PointerRNA *ptr, PointerRNA v
|
||||
if (ob->type == OB_CAMERA && ob != (Object*)ptr->id.data) {
|
||||
data->camera = ob;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
data->camera = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +353,8 @@ static void rna_Curve_bevelObject_set(PointerRNA *ptr, PointerRNA value)
|
||||
if (ob->type == OB_CURVE && ob->data != cu) {
|
||||
cu->bevobj = ob;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cu->bevobj = NULL;
|
||||
}
|
||||
}
|
||||
@@ -394,7 +395,8 @@ static void rna_Curve_taperObject_set(PointerRNA *ptr, PointerRNA value)
|
||||
if (ob->type == OB_CURVE && ob->data != cu) {
|
||||
cu->taperobj = ob;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cu->taperobj = NULL;
|
||||
}
|
||||
}
|
||||
@@ -480,7 +482,8 @@ static void rna_Nurb_update_cyclic_u(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
|
||||
if (nu->type == CU_BEZIER) {
|
||||
calchandlesNurb(nu);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
nurbs_knot_calc_u(nu);
|
||||
}
|
||||
|
||||
@@ -523,7 +526,8 @@ static void rna_Curve_spline_points_add(ID *id, Nurb *nu, ReportList *reports, i
|
||||
}
|
||||
else if (number == 0) {
|
||||
/* do nothing */
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
addNurbPoints(nu, number);
|
||||
|
||||
@@ -541,7 +545,8 @@ static void rna_Curve_spline_bezpoints_add(ID *id, Nurb *nu, ReportList *reports
|
||||
}
|
||||
else if (number == 0) {
|
||||
/* do nothing */
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
addNurbPointsBezier(nu, number);
|
||||
|
||||
/* update */
|
||||
|
||||
@@ -508,8 +508,8 @@ void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
|
||||
PropertyRNA *parm, *nextparm;
|
||||
|
||||
/*
|
||||
if(srna->flag & STRUCT_RUNTIME) {
|
||||
if(RNA_struct_py_type_get(srna)) {
|
||||
if (srna->flag & STRUCT_RUNTIME) {
|
||||
if (RNA_struct_py_type_get(srna)) {
|
||||
fprintf(stderr, "%s '%s' freed while holding a python reference\n", __func__, srna->identifier);
|
||||
}
|
||||
} */
|
||||
@@ -2717,7 +2717,8 @@ int rna_parameter_size(PropertyRNA *parm)
|
||||
if (parm->flag & PROP_THICK_WRAP) {
|
||||
StringPropertyRNA *sparm = (StringPropertyRNA*)parm;
|
||||
return sizeof(char) * sparm->maxlength;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return sizeof(char *);
|
||||
case PROP_POINTER: {
|
||||
#ifdef RNA_RUNTIME
|
||||
@@ -2762,7 +2763,7 @@ void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropert
|
||||
if (tot == 0) {
|
||||
*items = MEM_callocN(sizeof(EnumPropertyItem)*8, "RNA_enum_items_add");
|
||||
}
|
||||
else if (tot >= 8 && (tot&(tot-1)) == 0){
|
||||
else if (tot >= 8 && (tot&(tot-1)) == 0) {
|
||||
/* power of two > 8 */
|
||||
newitems = MEM_callocN(sizeof(EnumPropertyItem)*tot*2, "RNA_enum_items_add");
|
||||
memcpy(newitems, *items, sizeof(EnumPropertyItem)*tot);
|
||||
|
||||
@@ -191,7 +191,7 @@ static void rna_Image_file_format_set(PointerRNA *ptr, int value)
|
||||
|
||||
/*
|
||||
ibuf= BKE_image_get_ibuf(image, NULL);
|
||||
if(ibuf)
|
||||
if (ibuf)
|
||||
ibuf->ftype= ftype;
|
||||
*/
|
||||
|
||||
|
||||
@@ -94,7 +94,8 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports
|
||||
}
|
||||
|
||||
BKE_image_release_ibuf(image, lock);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BKE_reportf(reports, RPT_ERROR, "Scene not in context, couldn't get save parameters");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -869,20 +869,27 @@ static int rna_GameObjectSettings_physics_type_get(PointerRNA *ptr)
|
||||
if (!(ob->gameflag & OB_COLLISION)) {
|
||||
if (ob->gameflag & OB_OCCLUDER) {
|
||||
ob->body_type = OB_BODY_TYPE_OCCLUDER;
|
||||
} else if (ob->gameflag & OB_NAVMESH){
|
||||
}
|
||||
else if (ob->gameflag & OB_NAVMESH) {
|
||||
ob->body_type = OB_BODY_TYPE_NAVMESH;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ob->body_type = OB_BODY_TYPE_NO_COLLISION;
|
||||
}
|
||||
} else if (ob->gameflag & OB_SENSOR) {
|
||||
}
|
||||
else if (ob->gameflag & OB_SENSOR) {
|
||||
ob->body_type = OB_BODY_TYPE_SENSOR;
|
||||
} else if (!(ob->gameflag & OB_DYNAMIC)) {
|
||||
}
|
||||
else if (!(ob->gameflag & OB_DYNAMIC)) {
|
||||
ob->body_type = OB_BODY_TYPE_STATIC;
|
||||
} else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY))) {
|
||||
}
|
||||
else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY))) {
|
||||
ob->body_type = OB_BODY_TYPE_DYNAMIC;
|
||||
} else if (ob->gameflag & OB_RIGID_BODY) {
|
||||
}
|
||||
else if (ob->gameflag & OB_RIGID_BODY) {
|
||||
ob->body_type = OB_BODY_TYPE_RIGID;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ob->body_type = OB_BODY_TYPE_SOFT;
|
||||
/* create the structure here because we display soft body buttons in the main panel */
|
||||
if (!ob->bsoft)
|
||||
|
||||
@@ -155,7 +155,8 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_
|
||||
/* copies the data */
|
||||
tmpmesh = copy_mesh( ob->data );
|
||||
/* if not getting the original caged mesh, get final derived mesh */
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Make a dummy mesh, saves copying */
|
||||
DerivedMesh *dm;
|
||||
/* CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; */
|
||||
|
||||
@@ -570,7 +570,8 @@ static char *rna_FieldSettings_path(PointerRNA *ptr)
|
||||
return BLI_sprintfN("force_field_1");
|
||||
else if (part->pd2 == pd)
|
||||
return BLI_sprintfN("force_field_2");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* object force field */
|
||||
Object *ob = (Object*)ptr->id.data;
|
||||
|
||||
@@ -607,7 +608,8 @@ static char *rna_EffectorWeight_path(PointerRNA *ptr)
|
||||
|
||||
if (part->effector_weights == ew)
|
||||
return BLI_sprintfN("effector_weights");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Object *ob = (Object*)ptr->id.data;
|
||||
ModifierData *md;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ static StructRNA* rna_GameProperty_refine(struct PointerRNA *ptr)
|
||||
{
|
||||
bProperty *property = (bProperty*)ptr->data;
|
||||
|
||||
switch (property->type){
|
||||
switch (property->type) {
|
||||
case GPROP_BOOL:
|
||||
return &RNA_GameBooleanProperty;
|
||||
case GPROP_INT:
|
||||
|
||||
@@ -146,7 +146,8 @@ EnumPropertyItem *rna_Sensor_type_itemf(bContext *C, PointerRNA *ptr, PropertyRN
|
||||
|
||||
if (ptr->type == &RNA_Sensor || RNA_struct_is_a(ptr->type, &RNA_Sensor)) {
|
||||
ob = (Object *)ptr->id.data;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* can't use ob from ptr->id.data because that enum is also used by operators */
|
||||
ob = CTX_data_active_object(C);
|
||||
}
|
||||
|
||||
@@ -231,7 +231,8 @@ static void rna_Sequence_use_color_balance_set(PointerRNA *ptr, int value)
|
||||
seq->strip->color_balance->gain[c] = 1.0f;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
seq->flag ^= SEQ_USE_COLOR_BALANCE;
|
||||
}
|
||||
}
|
||||
@@ -248,7 +249,8 @@ static void rna_Sequence_use_proxy_set(PointerRNA *ptr, int value)
|
||||
seq->strip->proxy->build_size_flags
|
||||
= SEQ_PROXY_IMAGE_SIZE_25;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
seq->flag ^= SEQ_USE_PROXY;
|
||||
}
|
||||
}
|
||||
@@ -261,7 +263,8 @@ static void rna_Sequence_use_translation_set(PointerRNA *ptr, int value)
|
||||
if (seq->strip->transform == NULL) {
|
||||
seq->strip->transform = MEM_callocN(sizeof(struct StripTransform), "StripTransform");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
seq->flag ^= SEQ_USE_TRANSFORM;
|
||||
}
|
||||
}
|
||||
@@ -274,7 +277,8 @@ static void rna_Sequence_use_crop_set(PointerRNA *ptr, int value)
|
||||
if (seq->strip->crop == NULL) {
|
||||
seq->strip->crop = MEM_callocN(sizeof(struct StripCrop), "StripCrop");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
seq->flag ^= SEQ_USE_CROP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,7 +602,8 @@ static void rna_SpaceImageEditor_cursor_location_get(PointerRNA *ptr, float *val
|
||||
|
||||
if (sima->flag & SI_COORDFLOATS) {
|
||||
copy_v2_v2(values, sima->cursor);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int w, h;
|
||||
ED_space_image_size(sima, &w, &h);
|
||||
|
||||
@@ -617,7 +618,8 @@ static void rna_SpaceImageEditor_cursor_location_set(PointerRNA *ptr, const floa
|
||||
|
||||
if (sima->flag & SI_COORDFLOATS) {
|
||||
copy_v2_v2(sima->cursor, values);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int w, h;
|
||||
ED_space_image_size(sima, &w, &h);
|
||||
|
||||
|
||||
@@ -790,7 +790,7 @@ static void rna_def_userdef_theme_space_generic(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||
|
||||
/* buttons */
|
||||
/* if(! ELEM(spacetype, SPACE_BUTS, SPACE_OUTLINER)) { */
|
||||
/* if (! ELEM(spacetype, SPACE_BUTS, SPACE_OUTLINER)) { */
|
||||
prop = RNA_def_property(srna, "button", PROP_FLOAT, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_ui_text(prop, "Region Background", "");
|
||||
|
||||
@@ -144,7 +144,8 @@ static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int sp
|
||||
{
|
||||
if (modal == 0) {
|
||||
return WM_keymap_find(keyconf, idname, spaceid, regionid);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return WM_modalkeymap_add(keyconf, idname, NULL); /* items will be lazy init */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name);
|
||||
|
||||
/* free cache */
|
||||
if(amd->prevCos) {
|
||||
if (amd->prevCos) {
|
||||
MEM_freeN(amd->prevCos);
|
||||
amd->prevCos= NULL;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ static void deformVertsEM(
|
||||
ArmatureModifierData *amd = (ArmatureModifierData*) md;
|
||||
DerivedMesh *dm = derivedData;
|
||||
|
||||
if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
|
||||
if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
|
||||
|
||||
modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */
|
||||
|
||||
@@ -150,12 +150,12 @@ static void deformVertsEM(
|
||||
numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name);
|
||||
|
||||
/* free cache */
|
||||
if(amd->prevCos) {
|
||||
if (amd->prevCos) {
|
||||
MEM_freeN(amd->prevCos);
|
||||
amd->prevCos= NULL;
|
||||
}
|
||||
|
||||
if(!derivedData) dm->release(dm);
|
||||
if (!derivedData) dm->release(dm);
|
||||
}
|
||||
|
||||
static void deformMatricesEM(
|
||||
@@ -166,12 +166,12 @@ static void deformMatricesEM(
|
||||
ArmatureModifierData *amd = (ArmatureModifierData*) md;
|
||||
DerivedMesh *dm = derivedData;
|
||||
|
||||
if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
|
||||
if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
|
||||
|
||||
armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts,
|
||||
amd->deformflag, NULL, amd->defgrp_name);
|
||||
|
||||
if(!derivedData) dm->release(dm);
|
||||
if (!derivedData) dm->release(dm);
|
||||
}
|
||||
|
||||
static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData,
|
||||
@@ -180,12 +180,12 @@ static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedDat
|
||||
ArmatureModifierData *amd = (ArmatureModifierData*) md;
|
||||
DerivedMesh *dm = derivedData;
|
||||
|
||||
if(!derivedData) dm = CDDM_from_mesh((Mesh*)ob->data, ob);
|
||||
if (!derivedData) dm = CDDM_from_mesh((Mesh*)ob->data, ob);
|
||||
|
||||
armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts,
|
||||
amd->deformflag, NULL, amd->defgrp_name);
|
||||
|
||||
if(!derivedData) dm->release(dm);
|
||||
if (!derivedData) dm->release(dm);
|
||||
}
|
||||
|
||||
ModifierTypeInfo modifierType_Armature = {
|
||||
|
||||
@@ -149,14 +149,14 @@ static float vertarray_size(MVert *mvert, int numVerts, int axis)
|
||||
float min_co, max_co;
|
||||
|
||||
/* if there are no vertices, width is 0 */
|
||||
if(numVerts == 0) return 0;
|
||||
if (numVerts == 0) return 0;
|
||||
|
||||
/* find the minimum and maximum coordinates on the desired axis */
|
||||
min_co = max_co = mvert->co[axis];
|
||||
++mvert;
|
||||
for(i = 1; i < numVerts; ++i, ++mvert) {
|
||||
if(mvert->co[axis] < min_co) min_co = mvert->co[axis];
|
||||
if(mvert->co[axis] > max_co) max_co = mvert->co[axis];
|
||||
for (i = 1; i < numVerts; ++i, ++mvert) {
|
||||
if (mvert->co[axis] < min_co) min_co = mvert->co[axis];
|
||||
if (mvert->co[axis] > max_co) max_co = mvert->co[axis];
|
||||
}
|
||||
|
||||
return max_co - min_co;
|
||||
@@ -204,9 +204,9 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
|
||||
MVert *src_mvert;
|
||||
|
||||
/* need to avoid infinite recursion here */
|
||||
if(amd->start_cap && amd->start_cap != ob)
|
||||
if (amd->start_cap && amd->start_cap != ob)
|
||||
start_cap = mesh_get_derived_final(scene, amd->start_cap, CD_MASK_MESH);
|
||||
if(amd->end_cap && amd->end_cap != ob)
|
||||
if (amd->end_cap && amd->end_cap != ob)
|
||||
end_cap = mesh_get_derived_final(scene, amd->end_cap, CD_MASK_MESH);
|
||||
|
||||
unit_m4(offset);
|
||||
@@ -214,19 +214,19 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
|
||||
src_mvert = dm->getVertArray(dm);
|
||||
maxVerts = dm->getNumVerts(dm);
|
||||
|
||||
if(amd->offset_type & MOD_ARR_OFF_CONST)
|
||||
if (amd->offset_type & MOD_ARR_OFF_CONST)
|
||||
add_v3_v3v3(offset[3], offset[3], amd->offset);
|
||||
if(amd->offset_type & MOD_ARR_OFF_RELATIVE) {
|
||||
for(j = 0; j < 3; j++)
|
||||
if (amd->offset_type & MOD_ARR_OFF_RELATIVE) {
|
||||
for (j = 0; j < 3; j++)
|
||||
offset[3][j] += amd->scale[j] * vertarray_size(src_mvert,
|
||||
maxVerts, j);
|
||||
}
|
||||
|
||||
if((amd->offset_type & MOD_ARR_OFF_OBJ) && (amd->offset_ob)) {
|
||||
if ((amd->offset_type & MOD_ARR_OFF_OBJ) && (amd->offset_ob)) {
|
||||
float obinv[4][4];
|
||||
float result_mat[4][4];
|
||||
|
||||
if(ob)
|
||||
if (ob)
|
||||
invert_m4_m4(obinv, ob->obmat);
|
||||
else
|
||||
unit_m4(obinv);
|
||||
@@ -240,36 +240,36 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
|
||||
/* calculate the offset matrix of the final copy (for merging) */
|
||||
unit_m4(final_offset);
|
||||
|
||||
for(j=0; j < count - 1; j++) {
|
||||
for (j=0; j < count - 1; j++) {
|
||||
mult_m4_m4m4(tmp_mat, offset, final_offset);
|
||||
copy_m4_m4(final_offset, tmp_mat);
|
||||
}
|
||||
|
||||
if(amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
|
||||
if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
|
||||
Curve *cu = amd->curve_ob->data;
|
||||
if(cu) {
|
||||
if (cu) {
|
||||
float tmp_mat[3][3];
|
||||
float scale;
|
||||
|
||||
object_to_mat3(amd->curve_ob, tmp_mat);
|
||||
scale = mat3_to_scale(tmp_mat);
|
||||
|
||||
if(!cu->path) {
|
||||
if (!cu->path) {
|
||||
cu->flag |= CU_PATH; // needed for path & bevlist
|
||||
makeDispListCurveTypes(scene, amd->curve_ob, 0);
|
||||
}
|
||||
if(cu->path)
|
||||
if (cu->path)
|
||||
length = scale*cu->path->totdist;
|
||||
}
|
||||
}
|
||||
|
||||
/* calculate the maximum number of copies which will fit within the
|
||||
* prescribed length */
|
||||
if(amd->fit_type == MOD_ARR_FITLENGTH
|
||||
if (amd->fit_type == MOD_ARR_FITLENGTH
|
||||
|| amd->fit_type == MOD_ARR_FITCURVE) {
|
||||
float dist = sqrt(dot_v3v3(offset[3], offset[3]));
|
||||
|
||||
if(dist > 1e-6f)
|
||||
if (dist > 1e-6f)
|
||||
/* this gives length = first copy start to last copy end
|
||||
* add a tiny offset for floating point rounding errors */
|
||||
count = (length + 1e-6f) / dist;
|
||||
@@ -278,7 +278,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
|
||||
count = 1;
|
||||
}
|
||||
|
||||
if(count < 1)
|
||||
if (count < 1)
|
||||
count = 1;
|
||||
|
||||
/* BMESH_TODO: bumping up the stack level avoids computing the normals
|
||||
|
||||
@@ -83,7 +83,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(bmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if (bmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
{
|
||||
BooleanModifierData *bmd = (BooleanModifierData*) md;
|
||||
|
||||
if(bmd->object) {
|
||||
if (bmd->object) {
|
||||
DagNode *curNode = dag_get_node(forest, bmd->object);
|
||||
|
||||
dag_add_relation(forest, curNode, obNode,
|
||||
@@ -96,14 +96,14 @@ static DerivedMesh *get_quick_derivedMesh(DerivedMesh *derivedData, DerivedMesh
|
||||
{
|
||||
DerivedMesh *result = NULL;
|
||||
|
||||
if(derivedData->getNumPolys(derivedData) == 0 || dm->getNumPolys(dm) == 0) {
|
||||
if (derivedData->getNumPolys(derivedData) == 0 || dm->getNumPolys(dm) == 0) {
|
||||
switch(operation) {
|
||||
case eBooleanModifierOp_Intersect:
|
||||
result = CDDM_new(0, 0, 0, 0, 0);
|
||||
break;
|
||||
|
||||
case eBooleanModifierOp_Union:
|
||||
if(derivedData->getNumPolys(derivedData)) result = derivedData;
|
||||
if (derivedData->getNumPolys(derivedData)) result = derivedData;
|
||||
else result = CDDM_copy(dm);
|
||||
|
||||
break;
|
||||
@@ -125,12 +125,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
BooleanModifierData *bmd = (BooleanModifierData*) md;
|
||||
DerivedMesh *dm;
|
||||
|
||||
if(!bmd->object)
|
||||
if (!bmd->object)
|
||||
return derivedData;
|
||||
|
||||
dm = bmd->object->derivedFinal;
|
||||
|
||||
if(dm) {
|
||||
if (dm) {
|
||||
DerivedMesh *result;
|
||||
|
||||
/* when one of objects is empty (has got no faces) we could speed up
|
||||
@@ -138,7 +138,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
* Returning mesh is depended on modifiers operation (sergey) */
|
||||
result = get_quick_derivedMesh(derivedData, dm, bmd->operation);
|
||||
|
||||
if(result == NULL) {
|
||||
if (result == NULL) {
|
||||
|
||||
DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
|
||||
DM_ensure_tessface(derivedData); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
|
||||
@@ -153,7 +153,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
/* if new mesh returned, return it; otherwise there was
|
||||
* an error, so delete the modifier object */
|
||||
if(result)
|
||||
if (result)
|
||||
return result;
|
||||
else
|
||||
modifier_setError(md, "%s", TIP_("Can't execute boolean operation."));
|
||||
|
||||
@@ -185,17 +185,19 @@ static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face)
|
||||
|
||||
/* reverse face vertices if necessary */
|
||||
face->vertex_index[1] = mface->v2;
|
||||
if( face_it->flip == 0 ) {
|
||||
if ( face_it->flip == 0 ) {
|
||||
face->vertex_index[0] = mface->v1;
|
||||
face->vertex_index[2] = mface->v3;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
face->vertex_index[2] = mface->v1;
|
||||
face->vertex_index[0] = mface->v3;
|
||||
}
|
||||
if (mface->v4) {
|
||||
face->vertex_index[3] = mface->v4;
|
||||
face->vertex_number = 4;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
face->vertex_number = 3;
|
||||
}
|
||||
|
||||
@@ -234,17 +236,22 @@ static void FaceIt_Construct(
|
||||
if (ob->size[0] < 0.0f) {
|
||||
if (ob->size[1] < 0.0f && ob->size[2] < 0.0f) {
|
||||
it->flip = 1;
|
||||
} else if (ob->size[1] >= 0.0f && ob->size[2] >= 0.0f) {
|
||||
}
|
||||
else if (ob->size[1] >= 0.0f && ob->size[2] >= 0.0f) {
|
||||
it->flip = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
it->flip = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (ob->size[1] < 0.0f && ob->size[2] < 0.0f) {
|
||||
it->flip = 0;
|
||||
} else if (ob->size[1] >= 0.0f && ob->size[2] >= 0.0f) {
|
||||
}
|
||||
else if (ob->size[1] >= 0.0f && ob->size[2] >= 0.0f) {
|
||||
it->flip = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
it->flip = 1;
|
||||
}
|
||||
}
|
||||
@@ -382,7 +389,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
|
||||
origindex_layer = result->getTessFaceDataArray(result, CD_ORIGINDEX);
|
||||
|
||||
// step through the face iterators
|
||||
for(i = 0; !face_it->Done(face_it->it); i++) {
|
||||
for (i = 0; !face_it->Done(face_it->it); i++) {
|
||||
Mesh *orig_me;
|
||||
Object *orig_ob;
|
||||
Material *orig_mat;
|
||||
@@ -422,8 +429,8 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
|
||||
else
|
||||
mface->mat_nr = GET_INT_FROM_POINTER(BLI_ghash_lookup(material_hash, orig_mat));
|
||||
}
|
||||
else if(orig_mat) {
|
||||
if(orig_ob == ob1) {
|
||||
else if (orig_mat) {
|
||||
if (orig_ob == ob1) {
|
||||
// No need to change materian index for faces from left operand
|
||||
}
|
||||
else {
|
||||
@@ -433,8 +440,8 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
|
||||
int a;
|
||||
|
||||
mat_nr = 0;
|
||||
for(a = 0; a < ob1->totcol; a++) {
|
||||
if(give_current_material(ob1, a+1) == orig_mat) {
|
||||
for (a = 0; a < ob1->totcol; a++) {
|
||||
if (give_current_material(ob1, a+1) == orig_mat) {
|
||||
mat_nr = a;
|
||||
break;
|
||||
}
|
||||
@@ -456,7 +463,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
|
||||
|
||||
test_index_face(mface, &result->faceData, i, csgface.vertex_number);
|
||||
|
||||
if(origindex_layer && orig_ob == ob2)
|
||||
if (origindex_layer && orig_ob == ob2)
|
||||
origindex_layer[i] = ORIGINDEX_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
|
||||
else if (numEdges_dst) {
|
||||
MEdge *medge, *me;
|
||||
|
||||
if(bmd->randomize)
|
||||
if (bmd->randomize)
|
||||
BLI_array_randomize(edgeMap, sizeof(*edgeMap),
|
||||
numEdge_src, bmd->seed);
|
||||
|
||||
@@ -183,11 +183,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
|
||||
for (i = 0; i < numEdges_dst; i++) {
|
||||
me = medge + edgeMap[i];
|
||||
|
||||
if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v1))) {
|
||||
if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v1))) {
|
||||
BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(me->v1),
|
||||
SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
|
||||
}
|
||||
if(!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v2))) {
|
||||
if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v2))) {
|
||||
BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(me->v2), SET_INT_IN_POINTER(BLI_ghash_size(vertHash)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ static int isDisabled(ModifierData *md, int UNUSED(useRenderParams))
|
||||
|
||||
flag = cmd->flag & (MOD_CAST_X|MOD_CAST_Y|MOD_CAST_Z);
|
||||
|
||||
if((cmd->fac == 0.0f) || flag == 0) return 1;
|
||||
if ((cmd->fac == 0.0f) || flag == 0) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(cmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if (cmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ static void sphere_do(
|
||||
* space), by default, but if the user defined a control object,
|
||||
* we use its location, transformed to ob's local space */
|
||||
if (ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat);
|
||||
mult_m4_m4m4(mat, ctrl_ob->imat, ob->obmat);
|
||||
invert_m4_m4(imat, mat);
|
||||
@@ -178,14 +178,14 @@ static void sphere_do(
|
||||
* only those vertices should be affected */
|
||||
modifier_get_vgroup(ob, dm, cmd->defgrp_name, &dvert, &defgrp_index);
|
||||
|
||||
if(flag & MOD_CAST_SIZE_FROM_RADIUS) {
|
||||
if (flag & MOD_CAST_SIZE_FROM_RADIUS) {
|
||||
len = cmd->radius;
|
||||
}
|
||||
else {
|
||||
len = cmd->size;
|
||||
}
|
||||
|
||||
if(len <= 0) {
|
||||
if (len <= 0) {
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
len += len_v3v3(center, vertexCos[i]);
|
||||
}
|
||||
@@ -207,10 +207,11 @@ static void sphere_do(
|
||||
float weight;
|
||||
|
||||
copy_v3_v3(tmp_co, vertexCos[i]);
|
||||
if(ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (ctrl_ob) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
mul_m4_v3(mat, tmp_co);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sub_v3_v3(tmp_co, center);
|
||||
}
|
||||
}
|
||||
@@ -239,10 +240,11 @@ static void sphere_do(
|
||||
if (flag & MOD_CAST_Z)
|
||||
tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2];
|
||||
|
||||
if(ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (ctrl_ob) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
mul_m4_v3(imat, tmp_co);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
add_v3_v3(tmp_co, center);
|
||||
}
|
||||
}
|
||||
@@ -257,10 +259,11 @@ static void sphere_do(
|
||||
float tmp_co[3];
|
||||
|
||||
copy_v3_v3(tmp_co, vertexCos[i]);
|
||||
if(ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (ctrl_ob) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
mul_m4_v3(mat, tmp_co);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sub_v3_v3(tmp_co, center);
|
||||
}
|
||||
}
|
||||
@@ -283,10 +286,11 @@ static void sphere_do(
|
||||
if (flag & MOD_CAST_Z)
|
||||
tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2];
|
||||
|
||||
if(ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (ctrl_ob) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
mul_m4_v3(imat, tmp_co);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
add_v3_v3(tmp_co, center);
|
||||
}
|
||||
}
|
||||
@@ -329,7 +333,7 @@ static void cuboid_do(
|
||||
modifier_get_vgroup(ob, dm, cmd->defgrp_name, &dvert, &defgrp_index);
|
||||
|
||||
if (ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
invert_m4_m4(ctrl_ob->imat, ctrl_ob->obmat);
|
||||
mult_m4_m4m4(mat, ctrl_ob->imat, ob->obmat);
|
||||
invert_m4_m4(imat, mat);
|
||||
@@ -339,17 +343,19 @@ static void cuboid_do(
|
||||
mul_v3_m4v3(center, ob->imat, ctrl_ob->obmat[3]);
|
||||
}
|
||||
|
||||
if((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) {
|
||||
for(i = 0; i < 3; i++) {
|
||||
if ((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
min[i] = -cmd->radius;
|
||||
max[i] = cmd->radius;
|
||||
}
|
||||
} else if(!(flag & MOD_CAST_SIZE_FROM_RADIUS) && cmd->size > 0) {
|
||||
for(i = 0; i < 3; i++) {
|
||||
}
|
||||
else if (!(flag & MOD_CAST_SIZE_FROM_RADIUS) && cmd->size > 0) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
min[i] = -cmd->size;
|
||||
max[i] = cmd->size;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* get bound box */
|
||||
/* We can't use the object's bound box because other modifiers
|
||||
* may have changed the vertex data. */
|
||||
@@ -406,10 +412,11 @@ static void cuboid_do(
|
||||
float tmp_co[3];
|
||||
|
||||
copy_v3_v3(tmp_co, vertexCos[i]);
|
||||
if(ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (ctrl_ob) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
mul_m4_v3(mat, tmp_co);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sub_v3_v3(tmp_co, center);
|
||||
}
|
||||
}
|
||||
@@ -421,7 +428,7 @@ static void cuboid_do(
|
||||
}
|
||||
|
||||
for (j = 0; j < dvert[i].totweight; ++j) {
|
||||
if(dvert[i].dw[j].def_nr == defgrp_index) {
|
||||
if (dvert[i].dw[j].def_nr == defgrp_index) {
|
||||
dw = &dvert[i].dw[j];
|
||||
break;
|
||||
}
|
||||
@@ -482,10 +489,11 @@ static void cuboid_do(
|
||||
if (flag & MOD_CAST_Z)
|
||||
tmp_co[2] = facm * tmp_co[2] + fac * tmp_co[2] * fbb;
|
||||
|
||||
if(ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (ctrl_ob) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
mul_m4_v3(imat, tmp_co);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
add_v3_v3(tmp_co, center);
|
||||
}
|
||||
}
|
||||
@@ -502,10 +510,11 @@ static void cuboid_do(
|
||||
float tmp_co[3];
|
||||
|
||||
copy_v3_v3(tmp_co, vertexCos[i]);
|
||||
if(ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (ctrl_ob) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
mul_m4_v3(mat, tmp_co);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sub_v3_v3(tmp_co, center);
|
||||
}
|
||||
}
|
||||
@@ -550,10 +559,11 @@ static void cuboid_do(
|
||||
if (flag & MOD_CAST_Z)
|
||||
tmp_co[2] = facm * tmp_co[2] + fac * tmp_co[2] * fbb;
|
||||
|
||||
if(ctrl_ob) {
|
||||
if(flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
if (ctrl_ob) {
|
||||
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
||||
mul_m4_v3(imat, tmp_co);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
add_v3_v3(tmp_co, center);
|
||||
}
|
||||
}
|
||||
@@ -576,11 +586,12 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
|
||||
cuboid_do(cmd, ob, dm, vertexCos, numVerts);
|
||||
} else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
|
||||
}
|
||||
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
|
||||
sphere_do(cmd, ob, dm, vertexCos, numVerts);
|
||||
}
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -593,11 +604,12 @@ static void deformVertsEM(
|
||||
|
||||
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
|
||||
cuboid_do(cmd, ob, dm, vertexCos, numVerts);
|
||||
} else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
|
||||
}
|
||||
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
|
||||
sphere_do(cmd, ob, dm, vertexCos, numVerts);
|
||||
}
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ static void initData(ModifierData *md)
|
||||
clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches);
|
||||
|
||||
/* check for alloc failing */
|
||||
if(!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache)
|
||||
if (!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache)
|
||||
return;
|
||||
|
||||
cloth_init (clmd);
|
||||
@@ -78,12 +78,12 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
|
||||
if (!clmd->sim_parms || !clmd->coll_parms) {
|
||||
initData(md);
|
||||
|
||||
if(!clmd->sim_parms || !clmd->coll_parms)
|
||||
if (!clmd->sim_parms || !clmd->coll_parms)
|
||||
return;
|
||||
}
|
||||
|
||||
dm = get_dm(ob, NULL, derivedData, NULL, 0);
|
||||
if(dm == derivedData)
|
||||
if (dm == derivedData)
|
||||
dm = CDDM_copy(dm);
|
||||
|
||||
CDDM_apply_vert_coords(dm, vertexCos);
|
||||
@@ -92,7 +92,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
|
||||
|
||||
clothModifier_do(clmd, md->scene, ob, dm, vertexCos);
|
||||
|
||||
if(result) {
|
||||
if (result) {
|
||||
result->getVertCos(result, vertexCos);
|
||||
result->release(result);
|
||||
}
|
||||
@@ -106,8 +106,8 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Ob
|
||||
|
||||
Base *base;
|
||||
|
||||
if(clmd) {
|
||||
for(base = scene->base.first; base; base= base->next) {
|
||||
if (clmd) {
|
||||
for (base = scene->base.first; base; base= base->next) {
|
||||
Object *ob1= base->object;
|
||||
if (ob1 != ob) {
|
||||
CollisionModifierData *coll_clmd = (CollisionModifierData *)modifiers_findByType(ob1, eModifierType_Collision);
|
||||
@@ -125,10 +125,10 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
ClothModifierData *clmd = (ClothModifierData*)md;
|
||||
|
||||
if(cloth_uses_vgroup(clmd))
|
||||
if (cloth_uses_vgroup(clmd))
|
||||
dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
if(clmd->sim_parms->shapekey_rest != 0)
|
||||
if (clmd->sim_parms->shapekey_rest != 0)
|
||||
dataMask |= CD_MASK_CLOTH_ORCO;
|
||||
|
||||
return dataMask;
|
||||
@@ -139,20 +139,20 @@ static void copyData(ModifierData *md, ModifierData *target)
|
||||
ClothModifierData *clmd = (ClothModifierData*) md;
|
||||
ClothModifierData *tclmd = (ClothModifierData*) target;
|
||||
|
||||
if(tclmd->sim_parms) {
|
||||
if(tclmd->sim_parms->effector_weights)
|
||||
if (tclmd->sim_parms) {
|
||||
if (tclmd->sim_parms->effector_weights)
|
||||
MEM_freeN(tclmd->sim_parms->effector_weights);
|
||||
MEM_freeN(tclmd->sim_parms);
|
||||
}
|
||||
|
||||
if(tclmd->coll_parms)
|
||||
if (tclmd->coll_parms)
|
||||
MEM_freeN(tclmd->coll_parms);
|
||||
|
||||
BKE_ptcache_free_list(&tclmd->ptcaches);
|
||||
tclmd->point_cache = NULL;
|
||||
|
||||
tclmd->sim_parms = MEM_dupallocN(clmd->sim_parms);
|
||||
if(clmd->sim_parms->effector_weights)
|
||||
if (clmd->sim_parms->effector_weights)
|
||||
tclmd->sim_parms->effector_weights = MEM_dupallocN(clmd->sim_parms->effector_weights);
|
||||
tclmd->coll_parms = MEM_dupallocN(clmd->coll_parms);
|
||||
tclmd->point_cache = BKE_ptcache_copy_list(&tclmd->ptcaches, &clmd->ptcaches);
|
||||
@@ -169,17 +169,17 @@ static void freeData(ModifierData *md)
|
||||
ClothModifierData *clmd = (ClothModifierData*) md;
|
||||
|
||||
if (clmd) {
|
||||
if(G.rt > 0)
|
||||
if (G.rt > 0)
|
||||
printf("clothModifier_freeData\n");
|
||||
|
||||
cloth_free_modifier_extern (clmd);
|
||||
|
||||
if(clmd->sim_parms) {
|
||||
if(clmd->sim_parms->effector_weights)
|
||||
if (clmd->sim_parms) {
|
||||
if (clmd->sim_parms->effector_weights)
|
||||
MEM_freeN(clmd->sim_parms->effector_weights);
|
||||
MEM_freeN(clmd->sim_parms);
|
||||
}
|
||||
if(clmd->coll_parms)
|
||||
if (clmd->coll_parms)
|
||||
MEM_freeN(clmd->coll_parms);
|
||||
|
||||
BKE_ptcache_free_list(&clmd->ptcaches);
|
||||
@@ -192,11 +192,11 @@ static void foreachIDLink(ModifierData *md, Object *ob,
|
||||
{
|
||||
ClothModifierData *clmd = (ClothModifierData*) md;
|
||||
|
||||
if(clmd->coll_parms) {
|
||||
if (clmd->coll_parms) {
|
||||
walk(userData, ob, (ID **)&clmd->coll_parms->group);
|
||||
}
|
||||
|
||||
if(clmd->sim_parms && clmd->sim_parms->effector_weights) {
|
||||
if (clmd->sim_parms && clmd->sim_parms->effector_weights) {
|
||||
walk(userData, ob, (ID **)&clmd->sim_parms->effector_weights->group);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,19 +73,19 @@ static void freeData(ModifierData *md)
|
||||
|
||||
if (collmd)
|
||||
{
|
||||
if(collmd->bvhtree)
|
||||
if (collmd->bvhtree)
|
||||
BLI_bvhtree_free(collmd->bvhtree);
|
||||
if(collmd->x)
|
||||
if (collmd->x)
|
||||
MEM_freeN(collmd->x);
|
||||
if(collmd->xnew)
|
||||
if (collmd->xnew)
|
||||
MEM_freeN(collmd->xnew);
|
||||
if(collmd->current_x)
|
||||
if (collmd->current_x)
|
||||
MEM_freeN(collmd->current_x);
|
||||
if(collmd->current_xnew)
|
||||
if (collmd->current_xnew)
|
||||
MEM_freeN(collmd->current_xnew);
|
||||
if(collmd->current_v)
|
||||
if (collmd->current_v)
|
||||
MEM_freeN(collmd->current_v);
|
||||
if(collmd->mfaces)
|
||||
if (collmd->mfaces)
|
||||
MEM_freeN(collmd->mfaces);
|
||||
|
||||
collmd->x = NULL;
|
||||
@@ -117,16 +117,16 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
MVert *tempVert = NULL;
|
||||
|
||||
/* if possible use/create DerivedMesh */
|
||||
if(derivedData) dm = CDDM_copy(derivedData);
|
||||
else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob);
|
||||
if (derivedData) dm = CDDM_copy(derivedData);
|
||||
else if (ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob);
|
||||
|
||||
if(!ob->pd)
|
||||
if (!ob->pd)
|
||||
{
|
||||
printf("CollisionModifier deformVerts: Should not happen!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(dm)
|
||||
if (dm)
|
||||
{
|
||||
float current_time = 0;
|
||||
unsigned int numverts = 0;
|
||||
@@ -136,20 +136,20 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
current_time = BKE_curframe(md->scene);
|
||||
|
||||
if(G.rt > 0)
|
||||
if (G.rt > 0)
|
||||
printf("current_time %f, collmd->time_xnew %f\n", current_time, collmd->time_xnew);
|
||||
|
||||
numverts = dm->getNumVerts ( dm );
|
||||
|
||||
if((current_time > collmd->time_xnew)|| (BKE_ptcache_get_continue_physics()))
|
||||
if ((current_time > collmd->time_xnew)|| (BKE_ptcache_get_continue_physics()))
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
// check if mesh has changed
|
||||
if(collmd->x && (numverts != collmd->numverts))
|
||||
if (collmd->x && (numverts != collmd->numverts))
|
||||
freeData((ModifierData *)collmd);
|
||||
|
||||
if(collmd->time_xnew == -1000) // first time
|
||||
if (collmd->time_xnew == -1000) // first time
|
||||
{
|
||||
collmd->x = dm->dupVertArray(dm); // frame start position
|
||||
|
||||
@@ -176,7 +176,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
collmd->time_x = collmd->time_xnew = current_time;
|
||||
}
|
||||
else if(numverts == collmd->numverts) {
|
||||
else if (numverts == collmd->numverts) {
|
||||
// put positions to old positions
|
||||
tempVert = collmd->x;
|
||||
collmd->x = collmd->xnew;
|
||||
@@ -194,8 +194,8 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
memcpy(collmd->current_x, collmd->x, numverts*sizeof(MVert));
|
||||
|
||||
/* check if GUI setting has changed for bvh */
|
||||
if(collmd->bvhtree) {
|
||||
if(ob->pd->pdef_sboft != BLI_bvhtree_getepsilon(collmd->bvhtree)) {
|
||||
if (collmd->bvhtree) {
|
||||
if (ob->pd->pdef_sboft != BLI_bvhtree_getepsilon(collmd->bvhtree)) {
|
||||
BLI_bvhtree_free(collmd->bvhtree);
|
||||
collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sboft);
|
||||
}
|
||||
@@ -213,12 +213,12 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
collmd->time_xnew = current_time;
|
||||
}
|
||||
else if(numverts != collmd->numverts) {
|
||||
else if (numverts != collmd->numverts) {
|
||||
freeData((ModifierData *)collmd);
|
||||
}
|
||||
|
||||
}
|
||||
else if(current_time < collmd->time_xnew) {
|
||||
else if (current_time < collmd->time_xnew) {
|
||||
freeData((ModifierData *)collmd);
|
||||
}
|
||||
else {
|
||||
@@ -228,7 +228,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
}
|
||||
}
|
||||
|
||||
if(dm)
|
||||
if (dm)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(cmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if (cmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
@@ -131,11 +131,11 @@ static void deformVertsEM(
|
||||
{
|
||||
DerivedMesh *dm = derivedData;
|
||||
|
||||
if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
|
||||
if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
|
||||
|
||||
deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0);
|
||||
|
||||
if(!derivedData) dm->release(dm);
|
||||
if (!derivedData) dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
|
||||
if (mf->v4) numTris++;
|
||||
}
|
||||
|
||||
if(numTris<3) {
|
||||
if (numTris<3) {
|
||||
modifier_setError(md, "%s", TIP_("Modifier requires more than 3 input faces (triangles)."));
|
||||
dm = CDDM_copy(dm);
|
||||
return dm;
|
||||
@@ -109,7 +109,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
|
||||
lod.vertex_num= totvert;
|
||||
lod.face_num= numTris;
|
||||
|
||||
for(a=0; a<totvert; a++) {
|
||||
for (a=0; a<totvert; a++) {
|
||||
MVert *mv = &mvert[a];
|
||||
float *vbCo = &lod.vertex_buffer[a*3];
|
||||
float *vbNo = &lod.vertex_normal_buffer[a*3];
|
||||
@@ -119,14 +119,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
|
||||
}
|
||||
|
||||
numTris = 0;
|
||||
for(a=0; a<totface; a++) {
|
||||
for (a=0; a<totface; a++) {
|
||||
MFace *mf = &mface[a];
|
||||
int *tri = &lod.triangle_index_buffer[3*numTris++];
|
||||
tri[0]= mf->v1;
|
||||
tri[1]= mf->v2;
|
||||
tri[2]= mf->v3;
|
||||
|
||||
if(mf->v4) {
|
||||
if (mf->v4) {
|
||||
tri = &lod.triangle_index_buffer[3*numTris++];
|
||||
tri[0]= mf->v1;
|
||||
tri[1]= mf->v3;
|
||||
@@ -135,15 +135,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
|
||||
}
|
||||
|
||||
dmd->faceCount = 0;
|
||||
if(LOD_LoadMesh(&lod) ) {
|
||||
if( LOD_PreprocessMesh(&lod) ) {
|
||||
if (LOD_LoadMesh(&lod) ) {
|
||||
if ( LOD_PreprocessMesh(&lod) ) {
|
||||
/* we assume the decim_faces tells how much to reduce */
|
||||
|
||||
while(lod.face_num > numTris*dmd->percent) {
|
||||
if( LOD_CollapseEdge(&lod)==0) break;
|
||||
while (lod.face_num > numTris*dmd->percent) {
|
||||
if ( LOD_CollapseEdge(&lod)==0) break;
|
||||
}
|
||||
|
||||
if(lod.vertex_num>2) {
|
||||
if (lod.vertex_num>2) {
|
||||
result = CDDM_new(lod.vertex_num, 0, lod.face_num, 0, 0);
|
||||
dmd->faceCount = lod.face_num;
|
||||
}
|
||||
@@ -151,16 +151,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
|
||||
result = CDDM_new(lod.vertex_num, 0, 0, 0, 0);
|
||||
|
||||
mvert = CDDM_get_verts(result);
|
||||
for(a=0; a<lod.vertex_num; a++) {
|
||||
for (a=0; a<lod.vertex_num; a++) {
|
||||
MVert *mv = &mvert[a];
|
||||
float *vbCo = &lod.vertex_buffer[a*3];
|
||||
|
||||
copy_v3_v3(mv->co, vbCo);
|
||||
}
|
||||
|
||||
if(lod.vertex_num>2) {
|
||||
if (lod.vertex_num>2) {
|
||||
mface = CDDM_get_tessfaces(result);
|
||||
for(a=0; a<lod.face_num; a++) {
|
||||
for (a=0; a<lod.face_num; a++) {
|
||||
MFace *mf = &mface[a];
|
||||
int *tri = &lod.triangle_index_buffer[a*3];
|
||||
mf->v1 = tri[0];
|
||||
|
||||
@@ -87,10 +87,10 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(dmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if (dmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
/* ask for UV coordinates if we need them */
|
||||
if(dmd->texmapping == MOD_DISP_MAP_UV) dataMask |= CD_MASK_MTFACE;
|
||||
if (dmd->texmapping == MOD_DISP_MAP_UV) dataMask |= CD_MASK_MTFACE;
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ static int dependsOnTime(ModifierData *md)
|
||||
{
|
||||
DisplaceModifierData *dmd = (DisplaceModifierData *)md;
|
||||
|
||||
if(dmd->texture) {
|
||||
if (dmd->texture) {
|
||||
return BKE_texture_dependsOnTime(dmd->texture);
|
||||
}
|
||||
else {
|
||||
@@ -151,7 +151,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
{
|
||||
DisplaceModifierData *dmd = (DisplaceModifierData*) md;
|
||||
|
||||
if(dmd->map_object && dmd->texmapping == MOD_DISP_MAP_OBJECT) {
|
||||
if (dmd->map_object && dmd->texmapping == MOD_DISP_MAP_OBJECT) {
|
||||
DagNode *curNode = dag_get_node(forest, dmd->map_object);
|
||||
|
||||
dag_add_relation(forest, curNode, obNode,
|
||||
@@ -159,7 +159,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
}
|
||||
|
||||
|
||||
if(dmd->texmapping == MOD_DISP_MAP_GLOBAL)
|
||||
if (dmd->texmapping == MOD_DISP_MAP_GLOBAL)
|
||||
dag_add_relation(forest, obNode, obNode,
|
||||
DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Displace Modifier");
|
||||
|
||||
@@ -177,8 +177,8 @@ static void displaceModifier_do(
|
||||
float (*tex_co)[3];
|
||||
float weight= 1.0f; /* init value unused but some compilers may complain */
|
||||
|
||||
if(!dmd->texture) return;
|
||||
if(dmd->strength == 0.0f) return;
|
||||
if (!dmd->texture) return;
|
||||
if (dmd->strength == 0.0f) return;
|
||||
|
||||
mvert = CDDM_get_verts(dm);
|
||||
modifier_get_vgroup(ob, dm, dmd->defgrp_name, &dvert, &defgrp_index);
|
||||
@@ -187,13 +187,13 @@ static void displaceModifier_do(
|
||||
"displaceModifier_do tex_co");
|
||||
get_texture_coords((MappingInfoModifierData *)dmd, ob, dm, vertexCos, tex_co, numVerts);
|
||||
|
||||
for(i = 0; i < numVerts; ++i) {
|
||||
for (i = 0; i < numVerts; ++i) {
|
||||
TexResult texres;
|
||||
float delta = 0, strength = dmd->strength;
|
||||
|
||||
if(dvert) {
|
||||
if (dvert) {
|
||||
weight= defvert_find_weight(dvert + i, defgrp_index);
|
||||
if(weight == 0.0f) continue;
|
||||
if (weight == 0.0f) continue;
|
||||
}
|
||||
|
||||
texres.nor = NULL;
|
||||
@@ -201,7 +201,7 @@ static void displaceModifier_do(
|
||||
|
||||
delta = texres.tin - dmd->midlevel;
|
||||
|
||||
if(dvert) strength *= weight;
|
||||
if (dvert) strength *= weight;
|
||||
|
||||
delta *= strength;
|
||||
CLAMP(delta, -10000, 10000);
|
||||
@@ -244,7 +244,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
displaceModifier_do((DisplaceModifierData *)md, ob, dm,
|
||||
vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ static void deformVertsEM(
|
||||
displaceModifier_do((DisplaceModifierData *)md, ob, dm,
|
||||
vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
|
||||
if (pmd->canvas) {
|
||||
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
|
||||
for(; surface; surface=surface->next) {
|
||||
for (; surface; surface=surface->next) {
|
||||
/* tface */
|
||||
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ ||
|
||||
surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) {
|
||||
@@ -143,10 +143,10 @@ static void foreachIDLink(ModifierData *md, Object *ob,
|
||||
{
|
||||
DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md;
|
||||
|
||||
if(pmd->canvas) {
|
||||
if (pmd->canvas) {
|
||||
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
|
||||
|
||||
for(; surface; surface=surface->next) {
|
||||
for (; surface; surface=surface->next) {
|
||||
walk(userData, ob, (ID **)&surface->brush_group);
|
||||
walk(userData, ob, (ID **)&surface->init_texture);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ static void copyData(ModifierData *md, ModifierData *target)
|
||||
static DerivedMesh *edgesplitModifier_do(EdgeSplitModifierData *emd,
|
||||
Object *ob, DerivedMesh *dm)
|
||||
{
|
||||
if(!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG)))
|
||||
if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG)))
|
||||
return dm;
|
||||
|
||||
return doEdgeSplit(dm, emd, ob);
|
||||
@@ -149,7 +149,7 @@ static DerivedMesh *applyModifier(
|
||||
|
||||
result = edgesplitModifier_do(emd, ob, derivedData);
|
||||
|
||||
if(result != derivedData)
|
||||
if (result != derivedData)
|
||||
CDDM_calc_normals(result);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -67,7 +67,7 @@ static void freeData(ModifierData *md)
|
||||
{
|
||||
ExplodeModifierData *emd= (ExplodeModifierData*) md;
|
||||
|
||||
if(emd->facepa) MEM_freeN(emd->facepa);
|
||||
if (emd->facepa) MEM_freeN(emd->facepa);
|
||||
}
|
||||
static void copyData(ModifierData *md, ModifierData *target)
|
||||
{
|
||||
@@ -88,7 +88,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
ExplodeModifierData *emd= (ExplodeModifierData*) md;
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
if(emd->vgroup)
|
||||
if (emd->vgroup)
|
||||
dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
@@ -115,7 +115,7 @@ static void createFacepa(ExplodeModifierData *emd,
|
||||
|
||||
BLI_srandom(psys->seed);
|
||||
|
||||
if(emd->facepa)
|
||||
if (emd->facepa)
|
||||
MEM_freeN(emd->facepa);
|
||||
|
||||
facepa = emd->facepa = MEM_callocN(sizeof(int)*totface, "explode_facepa");
|
||||
@@ -123,21 +123,21 @@ static void createFacepa(ExplodeModifierData *emd,
|
||||
vertpa = MEM_callocN(sizeof(int)*totvert, "explode_vertpa");
|
||||
|
||||
/* initialize all faces & verts to no particle */
|
||||
for(i=0; i<totface; i++)
|
||||
for (i=0; i<totface; i++)
|
||||
facepa[i]=totpart;
|
||||
|
||||
for (i=0; i<totvert; i++)
|
||||
vertpa[i]=totpart;
|
||||
|
||||
/* set protected verts */
|
||||
if(emd->vgroup){
|
||||
if (emd->vgroup) {
|
||||
MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
|
||||
if(dvert){
|
||||
if (dvert) {
|
||||
const int defgrp_index= emd->vgroup-1;
|
||||
for(i=0; i<totvert; i++, dvert++){
|
||||
for (i=0; i<totvert; i++, dvert++) {
|
||||
float val = BLI_frand();
|
||||
val = (1.0f-emd->protect)*val + emd->protect*0.5f;
|
||||
if(val < defvert_find_weight(dvert, defgrp_index))
|
||||
if (val < defvert_find_weight(dvert, defgrp_index))
|
||||
vertpa[i] = -1;
|
||||
}
|
||||
}
|
||||
@@ -145,17 +145,17 @@ static void createFacepa(ExplodeModifierData *emd,
|
||||
|
||||
/* make tree of emitter locations */
|
||||
tree=BLI_kdtree_new(totpart);
|
||||
for(p=0,pa=psys->particles; p<totpart; p++,pa++){
|
||||
for (p=0,pa=psys->particles; p<totpart; p++,pa++) {
|
||||
psys_particle_on_emitter(psmd,psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,NULL,NULL,NULL,NULL,NULL);
|
||||
BLI_kdtree_insert(tree, p, co, NULL);
|
||||
}
|
||||
BLI_kdtree_balance(tree);
|
||||
|
||||
/* set face-particle-indexes to nearest particle to face center */
|
||||
for(i=0,fa=mface; i<totface; i++,fa++){
|
||||
for (i=0,fa=mface; i<totface; i++,fa++) {
|
||||
add_v3_v3v3(center,mvert[fa->v1].co,mvert[fa->v2].co);
|
||||
add_v3_v3(center, mvert[fa->v3].co);
|
||||
if(fa->v4){
|
||||
if (fa->v4) {
|
||||
add_v3_v3(center, mvert[fa->v4].co);
|
||||
mul_v3_fl(center,0.25);
|
||||
}
|
||||
@@ -167,19 +167,19 @@ static void createFacepa(ExplodeModifierData *emd,
|
||||
v1=vertpa[fa->v1];
|
||||
v2=vertpa[fa->v2];
|
||||
v3=vertpa[fa->v3];
|
||||
if(fa->v4)
|
||||
if (fa->v4)
|
||||
v4=vertpa[fa->v4];
|
||||
|
||||
if(v1>=0 && v2>=0 && v3>=0 && (fa->v4==0 || v4>=0))
|
||||
if (v1>=0 && v2>=0 && v3>=0 && (fa->v4==0 || v4>=0))
|
||||
facepa[i]=p;
|
||||
|
||||
if(v1>=0) vertpa[fa->v1]=p;
|
||||
if(v2>=0) vertpa[fa->v2]=p;
|
||||
if(v3>=0) vertpa[fa->v3]=p;
|
||||
if(fa->v4 && v4>=0) vertpa[fa->v4]=p;
|
||||
if (v1>=0) vertpa[fa->v1]=p;
|
||||
if (v2>=0) vertpa[fa->v2]=p;
|
||||
if (v3>=0) vertpa[fa->v3]=p;
|
||||
if (fa->v4 && v4>=0) vertpa[fa->v4]=p;
|
||||
}
|
||||
|
||||
if(vertpa) MEM_freeN(vertpa);
|
||||
if (vertpa) MEM_freeN(vertpa);
|
||||
BLI_kdtree_free(tree);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ static void remap_uvs_3_6_9_12(DerivedMesh *dm, DerivedMesh *split, int numlayer
|
||||
MTFace *mf, *df1, *df2, *df3;
|
||||
int l;
|
||||
|
||||
for(l=0; l<numlayer; l++) {
|
||||
for (l=0; l<numlayer; l++) {
|
||||
mf = CustomData_get_layer_n(&split->faceData, CD_MTFACE, l);
|
||||
df1 = mf+cur;
|
||||
df2 = df1 + 1;
|
||||
@@ -294,7 +294,7 @@ static void remap_uvs_5_10(DerivedMesh *dm, DerivedMesh *split, int numlayer, in
|
||||
MTFace *mf, *df1, *df2;
|
||||
int l;
|
||||
|
||||
for(l=0; l<numlayer; l++) {
|
||||
for (l=0; l<numlayer; l++) {
|
||||
mf = CustomData_get_layer_n(&split->faceData, CD_MTFACE, l);
|
||||
df1 = mf+cur;
|
||||
df2 = df1 + 1;
|
||||
@@ -355,7 +355,7 @@ static void remap_uvs_15(DerivedMesh *dm, DerivedMesh *split, int numlayer, int
|
||||
MTFace *mf, *df1, *df2, *df3, *df4;
|
||||
int l;
|
||||
|
||||
for(l=0; l<numlayer; l++) {
|
||||
for (l=0; l<numlayer; l++) {
|
||||
mf = CustomData_get_layer_n(&split->faceData, CD_MTFACE, l);
|
||||
df1 = mf+cur;
|
||||
df2 = df1 + 1;
|
||||
@@ -419,7 +419,7 @@ static void remap_uvs_7_11_13_14(DerivedMesh *dm, DerivedMesh *split, int numlay
|
||||
MTFace *mf, *df1, *df2, *df3;
|
||||
int l;
|
||||
|
||||
for(l=0; l<numlayer; l++) {
|
||||
for (l=0; l<numlayer; l++) {
|
||||
mf = CustomData_get_layer_n(&split->faceData, CD_MTFACE, l);
|
||||
df1 = mf+cur;
|
||||
df2 = df1 + 1;
|
||||
@@ -468,7 +468,7 @@ static void remap_uvs_19_21_22(DerivedMesh *dm, DerivedMesh *split, int numlayer
|
||||
MTFace *mf, *df1, *df2;
|
||||
int l;
|
||||
|
||||
for(l=0; l<numlayer; l++) {
|
||||
for (l=0; l<numlayer; l++) {
|
||||
mf = CustomData_get_layer_n(&split->faceData, CD_MTFACE, l);
|
||||
df1 = mf+cur;
|
||||
df2 = df1 + 1;
|
||||
@@ -519,7 +519,7 @@ static void remap_uvs_23(DerivedMesh *dm, DerivedMesh *split, int numlayer, int
|
||||
MTFace *mf, *df1, *df2;
|
||||
int l;
|
||||
|
||||
for(l=0; l<numlayer; l++) {
|
||||
for (l=0; l<numlayer; l++) {
|
||||
mf = CustomData_get_layer_n(&split->faceData, CD_MTFACE, l);
|
||||
df1 = mf+cur;
|
||||
df2 = df1 + 1;
|
||||
@@ -569,7 +569,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
|
||||
vertpa[mf->v1]=facepa[i];
|
||||
vertpa[mf->v2]=facepa[i];
|
||||
vertpa[mf->v3]=facepa[i];
|
||||
if(mf->v4)
|
||||
if (mf->v4)
|
||||
vertpa[mf->v4]=facepa[i];
|
||||
}
|
||||
|
||||
@@ -579,37 +579,37 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
|
||||
v2=vertpa[mf->v2];
|
||||
v3=vertpa[mf->v3];
|
||||
|
||||
if(v1!=v2){
|
||||
if (v1!=v2) {
|
||||
BLI_edgehash_insert(edgehash, mf->v1, mf->v2, NULL);
|
||||
(*fs) |= 1;
|
||||
}
|
||||
|
||||
if(v2!=v3){
|
||||
if (v2!=v3) {
|
||||
BLI_edgehash_insert(edgehash, mf->v2, mf->v3, NULL);
|
||||
(*fs) |= 2;
|
||||
}
|
||||
|
||||
if(mf->v4){
|
||||
if (mf->v4) {
|
||||
v4=vertpa[mf->v4];
|
||||
|
||||
if(v3!=v4){
|
||||
if (v3!=v4) {
|
||||
BLI_edgehash_insert(edgehash, mf->v3, mf->v4, NULL);
|
||||
(*fs) |= 4;
|
||||
}
|
||||
|
||||
if(v1!=v4){
|
||||
if (v1!=v4) {
|
||||
BLI_edgehash_insert(edgehash, mf->v1, mf->v4, NULL);
|
||||
(*fs) |= 8;
|
||||
}
|
||||
|
||||
/* mark center vertex as a fake edge split */
|
||||
if(*fs == 15)
|
||||
if (*fs == 15)
|
||||
BLI_edgehash_insert(edgehash, mf->v1, mf->v3, NULL);
|
||||
}
|
||||
else {
|
||||
(*fs) |= 16; /* mark face as tri */
|
||||
|
||||
if(v1!=v3){
|
||||
if (v1!=v3) {
|
||||
BLI_edgehash_insert(edgehash, mf->v1, mf->v3, NULL);
|
||||
(*fs) |= 4;
|
||||
}
|
||||
@@ -619,21 +619,21 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
|
||||
/* count splits & create indexes for new verts */
|
||||
ehi= BLI_edgehashIterator_new(edgehash);
|
||||
totesplit=totvert;
|
||||
for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totesplit));
|
||||
totesplit++;
|
||||
}
|
||||
BLI_edgehashIterator_free(ehi);
|
||||
|
||||
/* count new faces due to splitting */
|
||||
for(i=0,fs=facesplit; i<totface; i++,fs++)
|
||||
for (i=0,fs=facesplit; i<totface; i++,fs++)
|
||||
totfsplit += add_faces[*fs];
|
||||
|
||||
splitdm= CDDM_from_template(dm, totesplit, 0, totface+totfsplit, 0, 0);
|
||||
numlayer = CustomData_number_of_layers(&splitdm->faceData, CD_MTFACE);
|
||||
|
||||
/* copy new faces & verts (is it really this painful with custom data??) */
|
||||
for(i=0; i<totvert; i++){
|
||||
for (i=0; i<totvert; i++) {
|
||||
MVert source;
|
||||
MVert *dest;
|
||||
dm->getVert(dm, i, &source);
|
||||
@@ -655,7 +655,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
|
||||
|
||||
/* create new verts */
|
||||
ehi= BLI_edgehashIterator_new(edgehash);
|
||||
for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2);
|
||||
esplit= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
|
||||
mv=CDDM_get_vert(splitdm, ed_v2);
|
||||
@@ -675,7 +675,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
|
||||
/* create new faces */
|
||||
curdupface=0;//=totface;
|
||||
//curdupin=totesplit;
|
||||
for(i=0,fs=facesplit; i<totface; i++,fs++){
|
||||
for (i=0,fs=facesplit; i<totface; i++,fs++) {
|
||||
mf = dm->getTessFaceData(dm, i, CD_MFACE);
|
||||
|
||||
switch(*fs) {
|
||||
@@ -716,18 +716,18 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
|
||||
case 9:
|
||||
case 12:
|
||||
remap_faces_3_6_9_12(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
|
||||
if(numlayer)
|
||||
if (numlayer)
|
||||
remap_uvs_3_6_9_12(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
|
||||
break;
|
||||
case 5:
|
||||
case 10:
|
||||
remap_faces_5_10(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
|
||||
if(numlayer)
|
||||
if (numlayer)
|
||||
remap_uvs_5_10(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
|
||||
break;
|
||||
case 15:
|
||||
remap_faces_15(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
|
||||
if(numlayer)
|
||||
if (numlayer)
|
||||
remap_uvs_15(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
|
||||
break;
|
||||
case 7:
|
||||
@@ -735,19 +735,19 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
|
||||
case 13:
|
||||
case 14:
|
||||
remap_faces_7_11_13_14(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]);
|
||||
if(numlayer)
|
||||
if (numlayer)
|
||||
remap_uvs_7_11_13_14(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]);
|
||||
break;
|
||||
case 19:
|
||||
case 21:
|
||||
case 22:
|
||||
remap_faces_19_21_22(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]);
|
||||
if(numlayer)
|
||||
if (numlayer)
|
||||
remap_uvs_19_21_22(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]);
|
||||
break;
|
||||
case 23:
|
||||
remap_faces_23(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]);
|
||||
if(numlayer)
|
||||
if (numlayer)
|
||||
remap_uvs_23(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]);
|
||||
break;
|
||||
case 0:
|
||||
@@ -755,7 +755,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
|
||||
df1 = get_dface(dm, splitdm, curdupface, i, mf);
|
||||
facepa[curdupface] = vertpa[mf->v1];
|
||||
|
||||
if(df1->v4)
|
||||
if (df1->v4)
|
||||
df1->flag |= ME_FACE_SEL;
|
||||
else
|
||||
df1->flag &= ~ME_FACE_SEL;
|
||||
@@ -765,7 +765,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
|
||||
curdupface += add_faces[*fs]+1;
|
||||
}
|
||||
|
||||
for(i=0; i<curdupface; i++) {
|
||||
for (i=0; i<curdupface; i++) {
|
||||
mf = CDDM_get_tessface(splitdm, i);
|
||||
test_index_face(mf, &splitdm->faceData, i, (mf->flag & ME_FACE_SEL ? 4 : 3));
|
||||
}
|
||||
@@ -833,7 +833,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
|
||||
/* do mindex + totvert to ensure the vertex index to be the first
|
||||
* with BLI_edgehashIterator_getKey */
|
||||
if(facepa[i]==totpart || cfra < (pars+facepa[i])->time)
|
||||
if (facepa[i]==totpart || cfra < (pars+facepa[i])->time)
|
||||
mindex = totvert+totpart;
|
||||
else
|
||||
mindex = totvert+facepa[i];
|
||||
@@ -844,13 +844,13 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
BLI_edgehash_insert(vertpahash, mf->v1, mindex, NULL);
|
||||
BLI_edgehash_insert(vertpahash, mf->v2, mindex, NULL);
|
||||
BLI_edgehash_insert(vertpahash, mf->v3, mindex, NULL);
|
||||
if(mf->v4)
|
||||
if (mf->v4)
|
||||
BLI_edgehash_insert(vertpahash, mf->v4, mindex, NULL);
|
||||
}
|
||||
|
||||
/* make new vertice indexes & count total vertices after duplication */
|
||||
ehi= BLI_edgehashIterator_new(vertpahash);
|
||||
for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totdup));
|
||||
totdup++;
|
||||
}
|
||||
@@ -868,7 +868,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
|
||||
/* duplicate & displace vertices */
|
||||
ehi= BLI_edgehashIterator_new(vertpahash);
|
||||
for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
MVert source;
|
||||
MVert *dest;
|
||||
|
||||
@@ -883,7 +883,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
DM_copy_vert_data(dm, explode, ed_v1, v, 1);
|
||||
*dest = source;
|
||||
|
||||
if(ed_v2 != totpart) {
|
||||
if (ed_v2 != totpart) {
|
||||
/* get particle */
|
||||
pa= pars + ed_v2;
|
||||
|
||||
@@ -901,7 +901,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
sub_qt_qtqt(rot, state.rot, birth.rot);
|
||||
mul_qt_v3(rot, vertco);
|
||||
|
||||
if(emd->flag & eExplodeFlag_PaSize)
|
||||
if (emd->flag & eExplodeFlag_PaSize)
|
||||
mul_v3_fl(vertco,pa->size);
|
||||
|
||||
add_v3_v3(vertco, state.co);
|
||||
@@ -919,9 +919,9 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
if (facepa[i]!=totpart) {
|
||||
pa=pars+facepa[i];
|
||||
|
||||
if(pa->alive==PARS_UNBORN && (emd->flag&eExplodeFlag_Unborn)==0) continue;
|
||||
if(pa->alive==PARS_ALIVE && (emd->flag&eExplodeFlag_Alive)==0) continue;
|
||||
if(pa->alive==PARS_DEAD && (emd->flag&eExplodeFlag_Dead)==0) continue;
|
||||
if (pa->alive==PARS_UNBORN && (emd->flag&eExplodeFlag_Unborn)==0) continue;
|
||||
if (pa->alive==PARS_ALIVE && (emd->flag&eExplodeFlag_Alive)==0) continue;
|
||||
if (pa->alive==PARS_DEAD && (emd->flag&eExplodeFlag_Dead)==0) continue;
|
||||
}
|
||||
|
||||
dm->getTessFace(dm,i,&source);
|
||||
@@ -929,7 +929,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
|
||||
orig_v4 = source.v4;
|
||||
|
||||
if(facepa[i]!=totpart && cfra < pa->time)
|
||||
if (facepa[i]!=totpart && cfra < pa->time)
|
||||
mindex = totvert+totpart;
|
||||
else
|
||||
mindex = totvert+facepa[i];
|
||||
@@ -937,7 +937,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
source.v1 = edgecut_get(vertpahash, source.v1, mindex);
|
||||
source.v2 = edgecut_get(vertpahash, source.v2, mindex);
|
||||
source.v3 = edgecut_get(vertpahash, source.v3, mindex);
|
||||
if(source.v4)
|
||||
if (source.v4)
|
||||
source.v4 = edgecut_get(vertpahash, source.v4, mindex);
|
||||
|
||||
DM_copy_tessface_data(dm,explode,i,u,1);
|
||||
@@ -945,7 +945,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
*mf = source;
|
||||
|
||||
/* override uv channel for particle age */
|
||||
if(mtface) {
|
||||
if (mtface) {
|
||||
float age = (cfra - pa->time)/pa->lifetime;
|
||||
/* Clamp to this range to avoid flipping to the other side of the coordinates. */
|
||||
CLAMP(age, 0.001f, 0.999f);
|
||||
@@ -968,7 +968,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
|
||||
CDDM_tessfaces_to_faces(explode);
|
||||
CDDM_calc_normals(explode);
|
||||
|
||||
if(psmd->psys->lattice){
|
||||
if (psmd->psys->lattice) {
|
||||
end_latt_deform(psmd->psys->lattice);
|
||||
psmd->psys->lattice= NULL;
|
||||
}
|
||||
@@ -981,8 +981,8 @@ static ParticleSystemModifierData * findPrecedingParticlesystem(Object *ob, Modi
|
||||
ModifierData *md;
|
||||
ParticleSystemModifierData *psmd= NULL;
|
||||
|
||||
for (md=ob->modifiers.first; emd!=md; md=md->next){
|
||||
if(md->type==eModifierType_ParticleSystem)
|
||||
for (md=ob->modifiers.first; emd!=md; md=md->next) {
|
||||
if (md->type==eModifierType_ParticleSystem)
|
||||
psmd= (ParticleSystemModifierData*) md;
|
||||
}
|
||||
return psmd;
|
||||
@@ -998,29 +998,29 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
|
||||
|
||||
if(psmd){
|
||||
if (psmd) {
|
||||
ParticleSystem * psys=psmd->psys;
|
||||
|
||||
if(psys==NULL || psys->totpart==0) return derivedData;
|
||||
if(psys->part==NULL || psys->particles==NULL) return derivedData;
|
||||
if(psmd->dm==NULL) return derivedData;
|
||||
if (psys==NULL || psys->totpart==0) return derivedData;
|
||||
if (psys->part==NULL || psys->particles==NULL) return derivedData;
|
||||
if (psmd->dm==NULL) return derivedData;
|
||||
|
||||
/* 1. find faces to be exploded if needed */
|
||||
if(emd->facepa == NULL
|
||||
if (emd->facepa == NULL
|
||||
|| psmd->flag&eParticleSystemFlag_Pars
|
||||
|| emd->flag&eExplodeFlag_CalcFaces
|
||||
|| MEM_allocN_len(emd->facepa)/sizeof(int) != dm->getNumTessFaces(dm))
|
||||
{
|
||||
if(psmd->flag & eParticleSystemFlag_Pars)
|
||||
if (psmd->flag & eParticleSystemFlag_Pars)
|
||||
psmd->flag &= ~eParticleSystemFlag_Pars;
|
||||
|
||||
if(emd->flag & eExplodeFlag_CalcFaces)
|
||||
if (emd->flag & eExplodeFlag_CalcFaces)
|
||||
emd->flag &= ~eExplodeFlag_CalcFaces;
|
||||
|
||||
createFacepa(emd,psmd,derivedData);
|
||||
}
|
||||
/* 2. create new mesh */
|
||||
if(emd->flag & eExplodeFlag_EdgeCut){
|
||||
if (emd->flag & eExplodeFlag_EdgeCut) {
|
||||
int *facepa = emd->facepa;
|
||||
DerivedMesh *splitdm=cutEdges(emd,dm);
|
||||
DerivedMesh *explode=explodeMesh(emd, psmd, md->scene, ob, splitdm);
|
||||
|
||||
@@ -68,7 +68,7 @@ static void copyData(ModifierData *md, ModifierData *target)
|
||||
FluidsimModifierData *fluidmd= (FluidsimModifierData*) md;
|
||||
FluidsimModifierData *tfluidmd= (FluidsimModifierData*) target;
|
||||
|
||||
if(tfluidmd->fss)
|
||||
if (tfluidmd->fss)
|
||||
MEM_freeN(tfluidmd->fss);
|
||||
|
||||
tfluidmd->fss = MEM_dupallocN(fluidmd->fss);
|
||||
@@ -85,7 +85,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
DerivedMesh *result = NULL;
|
||||
|
||||
/* check for alloc failing */
|
||||
if(!fluidmd->fss) {
|
||||
if (!fluidmd->fss) {
|
||||
initData(md);
|
||||
|
||||
if (!fluidmd->fss) {
|
||||
@@ -105,15 +105,15 @@ static void updateDepgraph(
|
||||
FluidsimModifierData *fluidmd= (FluidsimModifierData*) md;
|
||||
Base *base;
|
||||
|
||||
if(fluidmd && fluidmd->fss) {
|
||||
if(fluidmd->fss->type == OB_FLUIDSIM_DOMAIN) {
|
||||
for(base = scene->base.first; base; base= base->next) {
|
||||
if (fluidmd && fluidmd->fss) {
|
||||
if (fluidmd->fss->type == OB_FLUIDSIM_DOMAIN) {
|
||||
for (base = scene->base.first; base; base= base->next) {
|
||||
Object *ob1= base->object;
|
||||
if(ob1 != ob) {
|
||||
if (ob1 != ob) {
|
||||
FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob1, eModifierType_Fluidsim);
|
||||
|
||||
// only put dependancies from NON-DOMAIN fluids in here
|
||||
if(fluidmdtmp && fluidmdtmp->fss && (fluidmdtmp->fss->type!=OB_FLUIDSIM_DOMAIN)) {
|
||||
if (fluidmdtmp && fluidmdtmp->fss && (fluidmdtmp->fss->type!=OB_FLUIDSIM_DOMAIN)) {
|
||||
DagNode *curNode = dag_get_node(forest, ob1);
|
||||
dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Fluidsim Object");
|
||||
}
|
||||
|
||||
@@ -66,13 +66,13 @@
|
||||
void fluidsim_init(FluidsimModifierData *fluidmd)
|
||||
{
|
||||
#ifdef WITH_MOD_FLUID
|
||||
if(fluidmd)
|
||||
if (fluidmd)
|
||||
{
|
||||
FluidsimSettings *fss = MEM_callocN(sizeof(FluidsimSettings), "fluidsimsettings");
|
||||
|
||||
fluidmd->fss = fss;
|
||||
|
||||
if(!fss)
|
||||
if (!fss)
|
||||
return;
|
||||
|
||||
fss->fmd = fluidmd;
|
||||
@@ -199,21 +199,21 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
|
||||
|
||||
|
||||
// read number of normals
|
||||
if(gotBytes)
|
||||
if (gotBytes)
|
||||
gotBytes = gzread(gzf, &wri, sizeof(wri));
|
||||
|
||||
// skip normals
|
||||
gotBytes = gzseek(gzf, numverts * 3 * sizeof(float), SEEK_CUR) != -1;
|
||||
|
||||
/* get no. of triangles */
|
||||
if(gotBytes)
|
||||
if (gotBytes)
|
||||
gotBytes = gzread(gzf, &wri, sizeof(wri));
|
||||
numfaces = wri;
|
||||
|
||||
gzclose(gzf);
|
||||
// ------------------------------------------------
|
||||
|
||||
if(!numfaces || !numverts || !gotBytes)
|
||||
if (!numfaces || !numverts || !gotBytes)
|
||||
return NULL;
|
||||
|
||||
gzf = BLI_gzopen(filename, "rb");
|
||||
@@ -224,7 +224,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
|
||||
|
||||
dm = CDDM_new(numverts, 0, 0, numfaces * 3, numfaces);
|
||||
|
||||
if(!dm)
|
||||
if (!dm)
|
||||
{
|
||||
gzclose(gzf);
|
||||
return NULL;
|
||||
@@ -236,30 +236,30 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
|
||||
// read vertex position from file
|
||||
mv = CDDM_get_verts(dm);
|
||||
|
||||
for(i=0; i<numverts; i++, mv++)
|
||||
for (i=0; i<numverts; i++, mv++)
|
||||
gotBytes = gzread(gzf, mv->co, sizeof(float) * 3);
|
||||
|
||||
// should be the same as numverts
|
||||
gotBytes = gzread(gzf, &wri, sizeof(wri));
|
||||
if(wri != numverts)
|
||||
if (wri != numverts)
|
||||
{
|
||||
if(dm)
|
||||
if (dm)
|
||||
dm->release(dm);
|
||||
gzclose(gzf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
normals = MEM_callocN(sizeof(short) * numverts * 3, "fluid_tmp_normals" );
|
||||
if(!normals)
|
||||
if (!normals)
|
||||
{
|
||||
if(dm)
|
||||
if (dm)
|
||||
dm->release(dm);
|
||||
gzclose(gzf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// read normals from file (but don't save them yet)
|
||||
for(i=numverts, no_s= normals; i>0; i--, no_s += 3)
|
||||
for (i=numverts, no_s= normals; i>0; i--, no_s += 3)
|
||||
{
|
||||
gotBytes = gzread(gzf, no, sizeof(float) * 3);
|
||||
normal_float_to_short_v3(no_s, no);
|
||||
@@ -268,9 +268,9 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
|
||||
/* read no. of triangles */
|
||||
gotBytes = gzread(gzf, &wri, sizeof(wri));
|
||||
|
||||
if(wri!=numfaces) {
|
||||
if (wri!=numfaces) {
|
||||
printf("Fluidsim: error in reading data from file.\n");
|
||||
if(dm)
|
||||
if (dm)
|
||||
dm->release(dm);
|
||||
gzclose(gzf);
|
||||
MEM_freeN(normals);
|
||||
@@ -280,7 +280,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam
|
||||
// read triangles from file
|
||||
mp = CDDM_get_polys(dm);
|
||||
ml = CDDM_get_loops(dm);
|
||||
for(i=0; i < numfaces; i++, mp++, ml += 3)
|
||||
for (i=0; i < numfaces; i++, mp++, ml += 3)
|
||||
{
|
||||
int face[3];
|
||||
|
||||
@@ -319,7 +319,7 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4],
|
||||
int i;
|
||||
float vec[3];
|
||||
|
||||
if(totvert == 0) {
|
||||
if (totvert == 0) {
|
||||
zero_v3(start);
|
||||
zero_v3(size);
|
||||
return;
|
||||
@@ -330,25 +330,25 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4],
|
||||
bbsx = vec[0]; bbsy = vec[1]; bbsz = vec[2];
|
||||
bbex = vec[0]; bbey = vec[1]; bbez = vec[2];
|
||||
|
||||
for(i = 1; i < totvert; i++) {
|
||||
for (i = 1; i < totvert; i++) {
|
||||
copy_v3_v3(vec, mvert[i].co);
|
||||
mul_m4_v3(obmat, vec);
|
||||
|
||||
if(vec[0] < bbsx){ bbsx= vec[0]; }
|
||||
if(vec[1] < bbsy){ bbsy= vec[1]; }
|
||||
if(vec[2] < bbsz){ bbsz= vec[2]; }
|
||||
if(vec[0] > bbex){ bbex= vec[0]; }
|
||||
if(vec[1] > bbey){ bbey= vec[1]; }
|
||||
if(vec[2] > bbez){ bbez= vec[2]; }
|
||||
if (vec[0] < bbsx) { bbsx= vec[0]; }
|
||||
if (vec[1] < bbsy) { bbsy= vec[1]; }
|
||||
if (vec[2] < bbsz) { bbsz= vec[2]; }
|
||||
if (vec[0] > bbex) { bbex= vec[0]; }
|
||||
if (vec[1] > bbey) { bbey= vec[1]; }
|
||||
if (vec[2] > bbez) { bbez= vec[2]; }
|
||||
}
|
||||
|
||||
// return values...
|
||||
if(start) {
|
||||
if (start) {
|
||||
start[0] = bbsx;
|
||||
start[1] = bbsy;
|
||||
start[2] = bbsz;
|
||||
}
|
||||
if(size) {
|
||||
if (size) {
|
||||
size[0] = bbex-bbsx;
|
||||
size[1] = bbey-bbsy;
|
||||
size[2] = bbez-bbsz;
|
||||
@@ -365,7 +365,7 @@ void fluid_estimate_memory(Object *ob, FluidsimSettings *fss, char *value)
|
||||
|
||||
value[0]= '\0';
|
||||
|
||||
if(ob->type == OB_MESH) {
|
||||
if (ob->type == OB_MESH) {
|
||||
/* use mesh bounding box and object scaling */
|
||||
mesh= ob->data;
|
||||
|
||||
@@ -388,15 +388,15 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
|
||||
|
||||
// mesh and vverts have to be valid from loading...
|
||||
|
||||
if(fss->meshVelocities)
|
||||
if (fss->meshVelocities)
|
||||
MEM_freeN(fss->meshVelocities);
|
||||
|
||||
if(len<7)
|
||||
if (len<7)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(fss->domainNovecgen>0) return;
|
||||
if (fss->domainNovecgen>0) return;
|
||||
|
||||
fss->meshVelocities = MEM_callocN(sizeof(FluidVertexVelocity)*dm->getNumVerts(dm), "Fluidsim_velocities");
|
||||
fss->totvert = totvert;
|
||||
@@ -418,16 +418,16 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *
|
||||
}
|
||||
|
||||
gzread(gzf, &wri, sizeof( wri ));
|
||||
if(wri != totvert)
|
||||
if (wri != totvert)
|
||||
{
|
||||
MEM_freeN(fss->meshVelocities);
|
||||
fss->meshVelocities = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
for(i=0; i<totvert;i++)
|
||||
for (i=0; i<totvert;i++)
|
||||
{
|
||||
for(j=0; j<3; j++)
|
||||
for (j=0; j<3; j++)
|
||||
{
|
||||
gzread(gzf, &wrf, sizeof( wrf ));
|
||||
velarray[i].vel[j] = wrf;
|
||||
@@ -447,9 +447,10 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim
|
||||
MPoly *mpoly;
|
||||
MPoly mp_example = {0};
|
||||
|
||||
if(!useRenderParams) {
|
||||
if (!useRenderParams) {
|
||||
displaymode = fss->guiDisplayMode;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
displaymode = fss->renderDisplayMode;
|
||||
}
|
||||
|
||||
@@ -483,15 +484,15 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim
|
||||
|
||||
dm = fluidsim_read_obj(targetFile, &mp_example);
|
||||
|
||||
if(!dm)
|
||||
if (!dm)
|
||||
{
|
||||
// switch, abort background rendering when fluidsim mesh is missing
|
||||
const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp
|
||||
|
||||
if(G.background==1) {
|
||||
if(getenv(strEnvName2)) {
|
||||
if (G.background==1) {
|
||||
if (getenv(strEnvName2)) {
|
||||
int elevel = atoi(getenv(strEnvName2));
|
||||
if(elevel>0) {
|
||||
if (elevel>0) {
|
||||
printf("Env. var %s set, fluid sim mesh '%s' not found, aborting render...\n",strEnvName2, targetFile);
|
||||
exit(1);
|
||||
}
|
||||
@@ -509,7 +510,7 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim
|
||||
fluidsim_read_vel_cache(fluidmd, dm, targetFile);
|
||||
}
|
||||
else {
|
||||
if(fss->meshVelocities)
|
||||
if (fss->meshVelocities)
|
||||
MEM_freeN(fss->meshVelocities);
|
||||
|
||||
fss->meshVelocities = NULL;
|
||||
@@ -532,11 +533,11 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene,
|
||||
framenr= (int)scene->r.cfra;
|
||||
|
||||
// only handle fluidsim domains
|
||||
if(fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN))
|
||||
if (fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN))
|
||||
return dm;
|
||||
|
||||
// sanity check
|
||||
if(!fluidmd || (fluidmd && !fluidmd->fss))
|
||||
if (!fluidmd || (fluidmd && !fluidmd->fss))
|
||||
return dm;
|
||||
|
||||
fss = fluidmd->fss;
|
||||
@@ -552,7 +553,7 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene,
|
||||
|
||||
/* try to read from cache */
|
||||
/* if the frame is there, fine, otherwise don't do anything */
|
||||
if((result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
|
||||
if ((result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
|
||||
return result;
|
||||
|
||||
return dm;
|
||||
|
||||
@@ -81,8 +81,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(hmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if(hmd->indexar) dataMask |= CD_MASK_ORIGINDEX;
|
||||
if (hmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if (hmd->indexar) dataMask |= CD_MASK_ORIGINDEX;
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
@@ -130,12 +130,12 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
|
||||
static float hook_falloff(float *co_1, float *co_2, const float falloff_squared, float fac)
|
||||
{
|
||||
if(falloff_squared) {
|
||||
if (falloff_squared) {
|
||||
float len_squared = len_squared_v3v3(co_1, co_2);
|
||||
if(len_squared > falloff_squared) {
|
||||
if (len_squared > falloff_squared) {
|
||||
return 0.0f;
|
||||
}
|
||||
else if(len_squared > 0.0f) {
|
||||
else if (len_squared > 0.0f) {
|
||||
return fac * (1.0f - (len_squared / falloff_squared));
|
||||
}
|
||||
}
|
||||
@@ -178,28 +178,28 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm,
|
||||
* not correct them on exit editmode. - zr
|
||||
*/
|
||||
|
||||
if(hmd->force == 0.0f) {
|
||||
if (hmd->force == 0.0f) {
|
||||
/* do nothing, avoid annoying checks in the loop */
|
||||
}
|
||||
else if(hmd->indexar) { /* vertex indices? */
|
||||
else if (hmd->indexar) { /* vertex indices? */
|
||||
const float fac_orig= hmd->force;
|
||||
float fac;
|
||||
const int *origindex_ar;
|
||||
|
||||
/* if DerivedMesh is present and has original index data, use it */
|
||||
if(dm && (origindex_ar= dm->getVertDataArray(dm, CD_ORIGINDEX))) {
|
||||
for(i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) {
|
||||
if(*index_pt < numVerts) {
|
||||
if (dm && (origindex_ar= dm->getVertDataArray(dm, CD_ORIGINDEX))) {
|
||||
for (i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) {
|
||||
if (*index_pt < numVerts) {
|
||||
int j;
|
||||
|
||||
for(j = 0; j < numVerts; j++) {
|
||||
if(origindex_ar[j] == *index_pt) {
|
||||
for (j = 0; j < numVerts; j++) {
|
||||
if (origindex_ar[j] == *index_pt) {
|
||||
float *co = vertexCos[j];
|
||||
if((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) {
|
||||
if(dvert)
|
||||
if ((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) {
|
||||
if (dvert)
|
||||
fac *= defvert_find_weight(dvert+j, defgrp_index);
|
||||
|
||||
if(fac) {
|
||||
if (fac) {
|
||||
mul_v3_m4v3(vec, mat, co);
|
||||
interp_v3_v3v3(co, co, vec, fac);
|
||||
}
|
||||
@@ -210,14 +210,14 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm,
|
||||
}
|
||||
}
|
||||
else { /* missing dm or ORIGINDEX */
|
||||
for(i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) {
|
||||
if(*index_pt < numVerts) {
|
||||
for (i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) {
|
||||
if (*index_pt < numVerts) {
|
||||
float *co = vertexCos[*index_pt];
|
||||
if((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) {
|
||||
if(dvert)
|
||||
if ((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) {
|
||||
if (dvert)
|
||||
fac *= defvert_find_weight(dvert+(*index_pt), defgrp_index);
|
||||
|
||||
if(fac) {
|
||||
if (fac) {
|
||||
mul_v3_m4v3(vec, mat, co);
|
||||
interp_v3_v3v3(co, co, vec, fac);
|
||||
}
|
||||
@@ -226,16 +226,16 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(dvert) { /* vertex group hook */
|
||||
else if (dvert) { /* vertex group hook */
|
||||
const float fac_orig= hmd->force;
|
||||
|
||||
for(i = 0; i < max_dvert; i++, dvert++) {
|
||||
for (i = 0; i < max_dvert; i++, dvert++) {
|
||||
float fac;
|
||||
float *co = vertexCos[i];
|
||||
|
||||
if((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) {
|
||||
if ((fac= hook_falloff(hmd->cent, co, falloff_squared, fac_orig))) {
|
||||
fac *= defvert_find_weight(dvert, defgrp_index);
|
||||
if(fac) {
|
||||
if (fac) {
|
||||
mul_v3_m4v3(vec, mat, co);
|
||||
interp_v3_v3v3(co, co, vec, fac);
|
||||
}
|
||||
@@ -251,12 +251,12 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
|
||||
HookModifierData *hmd = (HookModifierData*) md;
|
||||
DerivedMesh *dm = derivedData;
|
||||
/* We need a valid dm for meshes when a vgroup is set... */
|
||||
if(!dm && ob->type == OB_MESH && hmd->name[0] != '\0')
|
||||
if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0')
|
||||
dm = get_dm(ob, NULL, dm, NULL, 0);
|
||||
|
||||
deformVerts_do(hmd, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(derivedData != dm)
|
||||
if (derivedData != dm)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -266,12 +266,12 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD
|
||||
HookModifierData *hmd = (HookModifierData*) md;
|
||||
DerivedMesh *dm = derivedData;
|
||||
/* We need a valid dm for meshes when a vgroup is set... */
|
||||
if(!dm && ob->type == OB_MESH && hmd->name[0] != '\0')
|
||||
if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0')
|
||||
dm = get_dm(ob, editData, dm, NULL, 0);
|
||||
|
||||
deformVerts_do(hmd, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(derivedData != dm)
|
||||
if (derivedData != dm)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(lmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if (lmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
{
|
||||
LatticeModifierData *lmd = (LatticeModifierData*) md;
|
||||
|
||||
if(lmd->object) {
|
||||
if (lmd->object) {
|
||||
DagNode *latNode = dag_get_node(forest, lmd->object);
|
||||
|
||||
dag_add_relation(forest, latNode, obNode,
|
||||
@@ -124,11 +124,11 @@ static void deformVertsEM(
|
||||
{
|
||||
DerivedMesh *dm = derivedData;
|
||||
|
||||
if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
|
||||
if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
|
||||
|
||||
deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0);
|
||||
|
||||
if(!derivedData) dm->release(dm);
|
||||
if (!derivedData) dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
for (j= dv->totweight; j > 0; j--, dw++) {
|
||||
if (dw->def_nr < defbase_tot) {
|
||||
if (bone_select_array[dw->def_nr]) {
|
||||
if(dw->weight != 0.0f) {
|
||||
if (dw->weight != 0.0f) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,14 +66,14 @@ static void freeData(ModifierData *md)
|
||||
{
|
||||
MeshDeformModifierData *mmd = (MeshDeformModifierData*) md;
|
||||
|
||||
if(mmd->bindinfluences) MEM_freeN(mmd->bindinfluences);
|
||||
if(mmd->bindoffsets) MEM_freeN(mmd->bindoffsets);
|
||||
if(mmd->bindcagecos) MEM_freeN(mmd->bindcagecos);
|
||||
if(mmd->dyngrid) MEM_freeN(mmd->dyngrid);
|
||||
if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
|
||||
if(mmd->dynverts) MEM_freeN(mmd->dynverts);
|
||||
if(mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */
|
||||
if(mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */
|
||||
if (mmd->bindinfluences) MEM_freeN(mmd->bindinfluences);
|
||||
if (mmd->bindoffsets) MEM_freeN(mmd->bindoffsets);
|
||||
if (mmd->bindcagecos) MEM_freeN(mmd->bindcagecos);
|
||||
if (mmd->dyngrid) MEM_freeN(mmd->dyngrid);
|
||||
if (mmd->dyninfluences) MEM_freeN(mmd->dyninfluences);
|
||||
if (mmd->dynverts) MEM_freeN(mmd->dynverts);
|
||||
if (mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */
|
||||
if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */
|
||||
}
|
||||
|
||||
static void copyData(ModifierData *md, ModifierData *target)
|
||||
@@ -91,7 +91,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(mmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if (mmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
@@ -141,20 +141,20 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3
|
||||
totweight= 0.0f;
|
||||
size= mmd->dyngridsize;
|
||||
|
||||
for(i=0; i<3; i++) {
|
||||
for (i=0; i<3; i++) {
|
||||
gridvec[i]= (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth*0.5f)/mmd->dyncellwidth;
|
||||
ivec[i]= (int)gridvec[i];
|
||||
dvec[i]= gridvec[i] - ivec[i];
|
||||
}
|
||||
|
||||
for(i=0; i<8; i++) {
|
||||
if(i & 1) { x= ivec[0]+1; wx= dvec[0]; }
|
||||
for (i=0; i<8; i++) {
|
||||
if (i & 1) { x= ivec[0]+1; wx= dvec[0]; }
|
||||
else { x= ivec[0]; wx= 1.0f-dvec[0]; }
|
||||
|
||||
if(i & 2) { y= ivec[1]+1; wy= dvec[1]; }
|
||||
if (i & 2) { y= ivec[1]+1; wy= dvec[1]; }
|
||||
else { y= ivec[1]; wy= 1.0f-dvec[1]; }
|
||||
|
||||
if(i & 4) { z= ivec[2]+1; wz= dvec[2]; }
|
||||
if (i & 4) { z= ivec[2]+1; wz= dvec[2]; }
|
||||
else { z= ivec[2]; wz= 1.0f-dvec[2]; }
|
||||
|
||||
CLAMP(x, 0, size-1);
|
||||
@@ -166,7 +166,7 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3
|
||||
|
||||
cell= &mmd->dyngrid[a];
|
||||
inf= mmd->dyninfluences + cell->offset;
|
||||
for(j=0; j<cell->totinfluence; j++, inf++) {
|
||||
for (j=0; j<cell->totinfluence; j++, inf++) {
|
||||
cageco= dco[inf->vertex];
|
||||
cageweight= weight*inf->weight;
|
||||
co[0] += cageweight*cageco[0];
|
||||
@@ -197,13 +197,13 @@ static void meshdeformModifier_do(
|
||||
int a, b, totvert, totcagevert, defgrp_index;
|
||||
float (*cagecos)[3];
|
||||
|
||||
if(!mmd->object || (!mmd->bindcagecos && !mmd->bindfunc))
|
||||
if (!mmd->object || (!mmd->bindcagecos && !mmd->bindfunc))
|
||||
return;
|
||||
|
||||
/* get cage derivedmesh */
|
||||
if(em) {
|
||||
if (em) {
|
||||
tmpdm= editbmesh_get_derived_cage_and_final(md->scene, ob, em, &cagedm, 0);
|
||||
if(tmpdm)
|
||||
if (tmpdm)
|
||||
tmpdm->release(tmpdm);
|
||||
}
|
||||
else
|
||||
@@ -211,13 +211,13 @@ static void meshdeformModifier_do(
|
||||
|
||||
/* if we don't have one computed, use derivedmesh from data
|
||||
* without any modifiers */
|
||||
if(!cagedm) {
|
||||
if (!cagedm) {
|
||||
cagedm= get_dm(mmd->object, NULL, NULL, NULL, 0);
|
||||
if(cagedm)
|
||||
if (cagedm)
|
||||
cagedm->needsFree= 1;
|
||||
}
|
||||
|
||||
if(!cagedm) {
|
||||
if (!cagedm) {
|
||||
modifier_setError(md, "%s", TIP_("Can't get mesh from cage object."));
|
||||
return;
|
||||
}
|
||||
@@ -230,11 +230,11 @@ static void meshdeformModifier_do(
|
||||
copy_m3_m4(icagemat, iobmat);
|
||||
|
||||
/* bind weights if needed */
|
||||
if(!mmd->bindcagecos) {
|
||||
if (!mmd->bindcagecos) {
|
||||
static int recursive = 0;
|
||||
|
||||
/* progress bar redraw can make this recursive .. */
|
||||
if(!recursive) {
|
||||
if (!recursive) {
|
||||
recursive = 1;
|
||||
mmd->bindfunc(md->scene, mmd, (float*)vertexCos, numVerts, cagemat);
|
||||
recursive = 0;
|
||||
@@ -245,7 +245,7 @@ static void meshdeformModifier_do(
|
||||
totvert= numVerts;
|
||||
totcagevert= cagedm->getNumVerts(cagedm);
|
||||
|
||||
if(mmd->totvert != totvert) {
|
||||
if (mmd->totvert != totvert) {
|
||||
modifier_setError(md, TIP_("Verts changed from %d to %d."), mmd->totvert, totvert);
|
||||
cagedm->release(cagedm);
|
||||
return;
|
||||
@@ -254,7 +254,8 @@ static void meshdeformModifier_do(
|
||||
modifier_setError(md, TIP_("Cage verts changed from %d to %d."), mmd->totcagevert, totcagevert);
|
||||
cagedm->release(cagedm);
|
||||
return;
|
||||
} else if (mmd->bindcagecos == NULL) {
|
||||
}
|
||||
else if (mmd->bindcagecos == NULL) {
|
||||
modifier_setError(md, "%s", TIP_("Bind data missing."));
|
||||
cagedm->release(cagedm);
|
||||
return;
|
||||
@@ -269,11 +270,11 @@ static void meshdeformModifier_do(
|
||||
bindcagecos= (float(*)[3])mmd->bindcagecos;
|
||||
|
||||
dco= MEM_callocN(sizeof(*dco)*totcagevert, "MDefDco");
|
||||
for(a=0; a<totcagevert; a++) {
|
||||
for (a=0; a<totcagevert; a++) {
|
||||
/* get cage vertex in world space with binding transform */
|
||||
copy_v3_v3(co, cagecos[a]);
|
||||
|
||||
if(G.rt != 527) {
|
||||
if (G.rt != 527) {
|
||||
mul_m4_v3(mmd->bindmat, co);
|
||||
/* compute difference with world space bind coord */
|
||||
sub_v3_v3v3(dco[a], co, bindcagecos[a]);
|
||||
@@ -287,12 +288,12 @@ static void meshdeformModifier_do(
|
||||
/* do deformation */
|
||||
fac= 1.0f;
|
||||
|
||||
for(b=0; b<totvert; b++) {
|
||||
if(mmd->flag & MOD_MDEF_DYNAMIC_BIND)
|
||||
if(!mmd->dynverts[b])
|
||||
for (b=0; b<totvert; b++) {
|
||||
if (mmd->flag & MOD_MDEF_DYNAMIC_BIND)
|
||||
if (!mmd->dynverts[b])
|
||||
continue;
|
||||
|
||||
if(dvert) {
|
||||
if (dvert) {
|
||||
fac= defvert_find_weight(&dvert[b], defgrp_index);
|
||||
|
||||
if (mmd->flag & MOD_MDEF_INVERT_VGROUP) {
|
||||
@@ -304,7 +305,7 @@ static void meshdeformModifier_do(
|
||||
}
|
||||
}
|
||||
|
||||
if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
|
||||
if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
|
||||
/* transform coordinate into cage's local space */
|
||||
mul_v3_m4v3(co, cagemat, vertexCos[b]);
|
||||
totweight= meshdeform_dynamic_bind(mmd, dco, co);
|
||||
@@ -313,17 +314,17 @@ static void meshdeformModifier_do(
|
||||
totweight= 0.0f;
|
||||
zero_v3(co);
|
||||
|
||||
for(a=offsets[b]; a<offsets[b+1]; a++) {
|
||||
for (a=offsets[b]; a<offsets[b+1]; a++) {
|
||||
weight= influences[a].weight;
|
||||
madd_v3_v3fl(co, dco[influences[a].vertex], weight);
|
||||
totweight += weight;
|
||||
}
|
||||
}
|
||||
|
||||
if(totweight > 0.0f) {
|
||||
if (totweight > 0.0f) {
|
||||
mul_v3_fl(co, fac/totweight);
|
||||
mul_m3_v3(icagemat, co);
|
||||
if(G.rt != 527)
|
||||
if (G.rt != 527)
|
||||
add_v3_v3(vertexCos[b], co);
|
||||
else
|
||||
copy_v3_v3(vertexCos[b], co);
|
||||
@@ -349,7 +350,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
meshdeformModifier_do(md, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(dm && dm != derivedData)
|
||||
if (dm && dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -363,7 +364,7 @@ static void deformVertsEM(ModifierData *md, Object *ob,
|
||||
|
||||
meshdeformModifier_do(md, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(dm && dm != derivedData)
|
||||
if (dm && dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -376,18 +377,18 @@ void modifier_mdef_compact_influences(ModifierData *md)
|
||||
int totinfluence, totvert, totcagevert, a, b;
|
||||
|
||||
weights= mmd->bindweights;
|
||||
if(!weights)
|
||||
if (!weights)
|
||||
return;
|
||||
|
||||
totvert= mmd->totvert;
|
||||
totcagevert= mmd->totcagevert;
|
||||
|
||||
/* count number of influences above threshold */
|
||||
for(b=0; b<totvert; b++) {
|
||||
for(a=0; a<totcagevert; a++) {
|
||||
for (b=0; b<totvert; b++) {
|
||||
for (a=0; a<totcagevert; a++) {
|
||||
weight= weights[a + b*totcagevert];
|
||||
|
||||
if(weight > MESHDEFORM_MIN_INFLUENCE)
|
||||
if (weight > MESHDEFORM_MIN_INFLUENCE)
|
||||
mmd->totinfluence++;
|
||||
}
|
||||
}
|
||||
@@ -399,23 +400,23 @@ void modifier_mdef_compact_influences(ModifierData *md)
|
||||
/* write influences */
|
||||
totinfluence= 0;
|
||||
|
||||
for(b=0; b<totvert; b++) {
|
||||
for (b=0; b<totvert; b++) {
|
||||
mmd->bindoffsets[b]= totinfluence;
|
||||
totweight= 0.0f;
|
||||
|
||||
/* sum total weight */
|
||||
for(a=0; a<totcagevert; a++) {
|
||||
for (a=0; a<totcagevert; a++) {
|
||||
weight= weights[a + b*totcagevert];
|
||||
|
||||
if(weight > MESHDEFORM_MIN_INFLUENCE)
|
||||
if (weight > MESHDEFORM_MIN_INFLUENCE)
|
||||
totweight += weight;
|
||||
}
|
||||
|
||||
/* assign weights normalized */
|
||||
for(a=0; a<totcagevert; a++) {
|
||||
for (a=0; a<totcagevert; a++) {
|
||||
weight= weights[a + b*totcagevert];
|
||||
|
||||
if(weight > MESHDEFORM_MIN_INFLUENCE) {
|
||||
if (weight > MESHDEFORM_MIN_INFLUENCE) {
|
||||
mmd->bindinfluences[totinfluence].weight= weight/totweight;
|
||||
mmd->bindinfluences[totinfluence].vertex= a;
|
||||
totinfluence++;
|
||||
|
||||
@@ -84,7 +84,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
{
|
||||
MirrorModifierData *mmd = (MirrorModifierData*) md;
|
||||
|
||||
if(mmd->mirror_ob) {
|
||||
if (mmd->mirror_ob) {
|
||||
DagNode *latNode = dag_get_node(forest, mmd->mirror_ob);
|
||||
|
||||
dag_add_relation(forest, latNode, obNode,
|
||||
@@ -274,7 +274,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
|
||||
if (flip_map) {
|
||||
for (i = 0; i < maxVerts; dvert++, i++) {
|
||||
/* merged vertices get both groups, others get flipped */
|
||||
if(do_vtargetmap && (vtargetmap[i] != -1))
|
||||
if (do_vtargetmap && (vtargetmap[i] != -1))
|
||||
defvert_flip_merged(dvert, flip_map, flip_map_len);
|
||||
else
|
||||
defvert_flip(dvert, flip_map, flip_map_len);
|
||||
@@ -302,18 +302,18 @@ static DerivedMesh *mirrorModifier__doMirror(MirrorModifierData *mmd,
|
||||
DerivedMesh *result = dm;
|
||||
|
||||
/* check which axes have been toggled and mirror accordingly */
|
||||
if(mmd->flag & MOD_MIR_AXIS_X) {
|
||||
if (mmd->flag & MOD_MIR_AXIS_X) {
|
||||
result = doMirrorOnAxis(mmd, ob, result, 0);
|
||||
}
|
||||
if(mmd->flag & MOD_MIR_AXIS_Y) {
|
||||
if (mmd->flag & MOD_MIR_AXIS_Y) {
|
||||
DerivedMesh *tmp = result;
|
||||
result = doMirrorOnAxis(mmd, ob, result, 1);
|
||||
if(tmp != dm) tmp->release(tmp); /* free intermediate results */
|
||||
if (tmp != dm) tmp->release(tmp); /* free intermediate results */
|
||||
}
|
||||
if(mmd->flag & MOD_MIR_AXIS_Z) {
|
||||
if (mmd->flag & MOD_MIR_AXIS_Z) {
|
||||
DerivedMesh *tmp = result;
|
||||
result = doMirrorOnAxis(mmd, ob, result, 2);
|
||||
if(tmp != dm) tmp->release(tmp); /* free intermediate results */
|
||||
if (tmp != dm) tmp->release(tmp); /* free intermediate results */
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -329,7 +329,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
result = mirrorModifier__doMirror(mmd, ob, derivedData);
|
||||
|
||||
if(result != derivedData)
|
||||
if (result != derivedData)
|
||||
CDDM_calc_normals(result);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -77,8 +77,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
|
||||
DerivedMesh *result;
|
||||
Mesh *me= (Mesh*)ob->data;
|
||||
|
||||
if(mmd->totlvl) {
|
||||
if(!CustomData_get_layer(&me->ldata, CD_MDISPS)) {
|
||||
if (mmd->totlvl) {
|
||||
if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) {
|
||||
/* multires always needs a displacement layer */
|
||||
CustomData_add_layer(&me->ldata, CD_MDISPS, CD_CALLOC, NULL, me->totloop);
|
||||
}
|
||||
@@ -86,19 +86,19 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm,
|
||||
|
||||
result = multires_dm_create_from_derived(mmd, 0, dm, ob, useRenderParams);
|
||||
|
||||
if(result == dm)
|
||||
if (result == dm)
|
||||
return dm;
|
||||
|
||||
if(useRenderParams || !isFinalCalc) {
|
||||
if (useRenderParams || !isFinalCalc) {
|
||||
DerivedMesh *cddm;
|
||||
|
||||
cddm= CDDM_copy(result);
|
||||
|
||||
/* copy hidden flag to vertices */
|
||||
if(!useRenderParams) {
|
||||
if (!useRenderParams) {
|
||||
struct MDisps *mdisps;
|
||||
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
|
||||
if(mdisps) {
|
||||
if (mdisps) {
|
||||
subsurf_copy_grid_hidden(result, me->mpoly,
|
||||
cddm->getVertArray(cddm),
|
||||
mdisps);
|
||||
|
||||
@@ -240,7 +240,7 @@ static void dm_get_bounds(DerivedMesh *dm, float *sx, float *sy, float *ox, floa
|
||||
copy_v3_v3(min, mvert->co);
|
||||
copy_v3_v3(max, mvert->co);
|
||||
|
||||
for(v=1; v<totvert; v++, mvert++) {
|
||||
for (v=1; v<totvert; v++, mvert++) {
|
||||
min[0]=MIN2(min[0],mvert->co[0]);
|
||||
min[1]=MIN2(min[1],mvert->co[1]);
|
||||
min[2]=MIN2(min[2],mvert->co[2]);
|
||||
@@ -352,7 +352,7 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd)
|
||||
|
||||
/* add uvs */
|
||||
cdlayer= CustomData_number_of_layers(&result->loopData, CD_MLOOPUV);
|
||||
if(cdlayer < MAX_MTFACE) {
|
||||
if (cdlayer < MAX_MTFACE) {
|
||||
MLoopUV *mloopuvs= CustomData_add_layer(&result->loopData, CD_MLOOPUV, CD_CALLOC, NULL, num_faces * 4);
|
||||
|
||||
if (mloopuvs) { /* unlikely to fail */
|
||||
@@ -455,7 +455,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob,
|
||||
if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
|
||||
int cdlayer= CustomData_number_of_layers(&dm->loopData, CD_MLOOPCOL);
|
||||
|
||||
if(cdlayer < MAX_MCOL) {
|
||||
if (cdlayer < MAX_MCOL) {
|
||||
MLoopCol *mloopcols= CustomData_add_layer_named(&dm->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, num_faces * 4, omd->foamlayername);
|
||||
|
||||
if (mloopcols) { /* unlikely to fail */
|
||||
@@ -540,7 +540,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
result = doOcean(md, ob, derivedData, 0);
|
||||
|
||||
if(result != derivedData)
|
||||
if (result != derivedData)
|
||||
CDDM_calc_normals(result);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -126,27 +126,27 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
trackneg=((ob->trackflag>2)?1:0);
|
||||
|
||||
if(pimd->ob==ob){
|
||||
if (pimd->ob==ob) {
|
||||
pimd->ob= NULL;
|
||||
return derivedData;
|
||||
}
|
||||
|
||||
if(pimd->ob){
|
||||
if (pimd->ob) {
|
||||
psys = BLI_findlink(&pimd->ob->particlesystem,pimd->psys-1);
|
||||
if(psys==NULL || psys->totpart==0)
|
||||
if (psys==NULL || psys->totpart==0)
|
||||
return derivedData;
|
||||
}
|
||||
else return derivedData;
|
||||
|
||||
if(pimd->flag & eParticleInstanceFlag_Parents)
|
||||
if (pimd->flag & eParticleInstanceFlag_Parents)
|
||||
totpart+=psys->totpart;
|
||||
if(pimd->flag & eParticleInstanceFlag_Children){
|
||||
if(totpart==0)
|
||||
if (pimd->flag & eParticleInstanceFlag_Children) {
|
||||
if (totpart==0)
|
||||
first_particle=psys->totpart;
|
||||
totpart+=psys->totchild;
|
||||
}
|
||||
|
||||
if(totpart==0)
|
||||
if (totpart==0)
|
||||
return derivedData;
|
||||
|
||||
sim.scene = md->scene;
|
||||
@@ -154,20 +154,20 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
sim.psys = psys;
|
||||
sim.psmd = psys_get_modifier(pimd->ob, psys);
|
||||
|
||||
if(pimd->flag & eParticleInstanceFlag_UseSize) {
|
||||
if (pimd->flag & eParticleInstanceFlag_UseSize) {
|
||||
int p;
|
||||
float *si;
|
||||
si = size = MEM_callocN(totpart * sizeof(float), "particle size array");
|
||||
|
||||
if(pimd->flag & eParticleInstanceFlag_Parents) {
|
||||
for(p=0, pa= psys->particles; p<psys->totpart; p++, pa++, si++)
|
||||
if (pimd->flag & eParticleInstanceFlag_Parents) {
|
||||
for (p=0, pa= psys->particles; p<psys->totpart; p++, pa++, si++)
|
||||
*si = pa->size;
|
||||
}
|
||||
|
||||
if(pimd->flag & eParticleInstanceFlag_Children) {
|
||||
if (pimd->flag & eParticleInstanceFlag_Children) {
|
||||
ChildParticle *cpa = psys->child;
|
||||
|
||||
for(p=0; p<psys->totchild; p++, cpa++, si++) {
|
||||
for (p=0; p<psys->totchild; p++, cpa++, si++) {
|
||||
*si = psys_get_child_size(psys, cpa, 0.0f, NULL);
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
psys->lattice=psys_get_lattice(&sim);
|
||||
|
||||
if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED){
|
||||
if (psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) {
|
||||
|
||||
float min_r[3], max_r[3];
|
||||
INIT_MINMAX(min_r, max_r);
|
||||
@@ -197,7 +197,7 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
mvert=result->getVertArray(result);
|
||||
orig_mvert=dm->getVertArray(dm);
|
||||
|
||||
for(i=0; i<maxvert; i++){
|
||||
for (i=0; i<maxvert; i++) {
|
||||
MVert *inMV;
|
||||
MVert *mv = mvert + i;
|
||||
ParticleKey state;
|
||||
@@ -212,20 +212,20 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
mv->co[(axis+1)%3]=temp_co[(track+1)%3];
|
||||
mv->co[(axis+2)%3]=temp_co[(track+2)%3];
|
||||
|
||||
if((psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && pimd->flag & eParticleInstanceFlag_Path){
|
||||
if ((psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && pimd->flag & eParticleInstanceFlag_Path) {
|
||||
float ran = 0.0f;
|
||||
if(pimd->random_position != 0.0f) {
|
||||
if (pimd->random_position != 0.0f) {
|
||||
BLI_srandom(psys->seed + (i/totvert)%totpart);
|
||||
ran = pimd->random_position * BLI_frand();
|
||||
}
|
||||
|
||||
if(pimd->flag & eParticleInstanceFlag_KeepShape) {
|
||||
if (pimd->flag & eParticleInstanceFlag_KeepShape) {
|
||||
state.time = pimd->position * (1.0f - ran);
|
||||
}
|
||||
else {
|
||||
state.time=(mv->co[axis]-min_co)/(max_co-min_co) * pimd->position * (1.0f - ran);
|
||||
|
||||
if(trackneg)
|
||||
if (trackneg)
|
||||
state.time=1.0f-state.time;
|
||||
|
||||
mv->co[axis] = 0.0;
|
||||
@@ -236,7 +236,7 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
normalize_v3(state.vel);
|
||||
|
||||
/* TODO: incremental rotations somehow */
|
||||
if(state.vel[axis] < -0.9999f || state.vel[axis] > 0.9999f) {
|
||||
if (state.vel[axis] < -0.9999f || state.vel[axis] > 0.9999f) {
|
||||
state.rot[0] = 1;
|
||||
state.rot[1] = state.rot[2] = state.rot[3] = 0.0f;
|
||||
}
|
||||
@@ -251,13 +251,13 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
else {
|
||||
state.time=-1.0;
|
||||
psys_get_particle_state(&sim, first_particle + i/totvert, &state,1);
|
||||
}
|
||||
|
||||
mul_qt_v3(state.rot,mv->co);
|
||||
if(pimd->flag & eParticleInstanceFlag_UseSize)
|
||||
if (pimd->flag & eParticleInstanceFlag_UseSize)
|
||||
mul_v3_fl(mv->co, size[i/totvert]);
|
||||
add_v3_v3(mv->co, state.co);
|
||||
}
|
||||
@@ -265,31 +265,36 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
mface=result->getTessFaceArray(result);
|
||||
orig_mface=dm->getTessFaceArray(dm);
|
||||
|
||||
for(i=0; i<maxface; i++){
|
||||
for (i=0; i<maxface; i++) {
|
||||
MFace *inMF;
|
||||
MFace *mf = mface + i;
|
||||
|
||||
if(pimd->flag & eParticleInstanceFlag_Parents){
|
||||
if(i/totface>=psys->totpart){
|
||||
if(psys->part->childtype==PART_CHILD_PARTICLES)
|
||||
if (pimd->flag & eParticleInstanceFlag_Parents) {
|
||||
if (i/totface>=psys->totpart) {
|
||||
if (psys->part->childtype==PART_CHILD_PARTICLES) {
|
||||
pa=psys->particles+(psys->child+i/totface-psys->totpart)->parent;
|
||||
else
|
||||
}
|
||||
else {
|
||||
pa= NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
pa=pars+i/totface;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(psys->part->childtype==PART_CHILD_PARTICLES)
|
||||
else {
|
||||
if (psys->part->childtype==PART_CHILD_PARTICLES) {
|
||||
pa=psys->particles+(psys->child+i/totface)->parent;
|
||||
else
|
||||
}
|
||||
else {
|
||||
pa= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(pa){
|
||||
if(pa->alive==PARS_UNBORN && (pimd->flag&eParticleInstanceFlag_Unborn)==0) continue;
|
||||
if(pa->alive==PARS_ALIVE && (pimd->flag&eParticleInstanceFlag_Alive)==0) continue;
|
||||
if(pa->alive==PARS_DEAD && (pimd->flag&eParticleInstanceFlag_Dead)==0) continue;
|
||||
if (pa) {
|
||||
if (pa->alive==PARS_UNBORN && (pimd->flag&eParticleInstanceFlag_Unborn)==0) continue;
|
||||
if (pa->alive==PARS_ALIVE && (pimd->flag&eParticleInstanceFlag_Alive)==0) continue;
|
||||
if (pa->alive==PARS_DEAD && (pimd->flag&eParticleInstanceFlag_Dead)==0) continue;
|
||||
}
|
||||
|
||||
inMF = orig_mface + i%totface;
|
||||
@@ -299,18 +304,19 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
|
||||
mf->v1+=(i/totface)*totvert;
|
||||
mf->v2+=(i/totface)*totvert;
|
||||
mf->v3+=(i/totface)*totvert;
|
||||
if(mf->v4)
|
||||
if (mf->v4) {
|
||||
mf->v4+=(i/totface)*totvert;
|
||||
}
|
||||
}
|
||||
|
||||
CDDM_calc_edges_tessface(result);
|
||||
|
||||
if(psys->lattice){
|
||||
if (psys->lattice) {
|
||||
end_latt_deform(psys->lattice);
|
||||
psys->lattice= NULL;
|
||||
}
|
||||
|
||||
if(size)
|
||||
if (size)
|
||||
MEM_freeN(size);
|
||||
|
||||
CDDM_tessfaces_to_faces(result); /*builds ngon faces from tess (mface) faces*/
|
||||
|
||||
@@ -59,7 +59,7 @@ static void freeData(ModifierData *md)
|
||||
{
|
||||
ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md;
|
||||
|
||||
if(psmd->dm){
|
||||
if (psmd->dm) {
|
||||
psmd->dm->needsFree = 1;
|
||||
psmd->dm->release(psmd->dm);
|
||||
psmd->dm = NULL;
|
||||
@@ -67,7 +67,7 @@ static void freeData(ModifierData *md)
|
||||
|
||||
/* ED_object_modifier_remove may have freed this first before calling
|
||||
* modifier_free (which calls this function) */
|
||||
if(psmd->psys)
|
||||
if (psmd->psys)
|
||||
psmd->psys->flag |= PSYS_DELETE;
|
||||
}
|
||||
static void copyData(ModifierData *md, ModifierData *target)
|
||||
@@ -90,21 +90,21 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
MTex *mtex;
|
||||
int i;
|
||||
|
||||
if(!psmd->psys->part)
|
||||
if (!psmd->psys->part)
|
||||
return 0;
|
||||
|
||||
for(i=0; i<MAX_MTEX; i++) {
|
||||
for (i=0; i<MAX_MTEX; i++) {
|
||||
mtex = psmd->psys->part->mtex[i];
|
||||
if(mtex && mtex->mapto && (mtex->texco & TEXCO_UV))
|
||||
if (mtex && mtex->mapto && (mtex->texco & TEXCO_UV))
|
||||
dataMask |= CD_MASK_MTFACE;
|
||||
}
|
||||
|
||||
if(psmd->psys->part->tanfac != 0.0f)
|
||||
if (psmd->psys->part->tanfac != 0.0f)
|
||||
dataMask |= CD_MASK_MTFACE;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
for(i=0; i<PSYS_TOT_VG; i++){
|
||||
if(psmd->psys->vgroup[i]){
|
||||
for (i=0; i<PSYS_TOT_VG; i++) {
|
||||
if (psmd->psys->vgroup[i]) {
|
||||
dataMask |= CD_MASK_MDEFORMVERT;
|
||||
break;
|
||||
}
|
||||
@@ -132,29 +132,29 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
ParticleSystem * psys= NULL;
|
||||
int needsFree=0;
|
||||
|
||||
if(ob->particlesystem.first)
|
||||
if (ob->particlesystem.first)
|
||||
psys=psmd->psys;
|
||||
else
|
||||
return;
|
||||
|
||||
if(!psys_check_enabled(ob, psys))
|
||||
if (!psys_check_enabled(ob, psys))
|
||||
return;
|
||||
|
||||
if(dm==NULL) {
|
||||
if (dm==NULL) {
|
||||
dm= get_dm(ob, NULL, NULL, vertexCos, 1);
|
||||
|
||||
if(!dm)
|
||||
if (!dm)
|
||||
return;
|
||||
|
||||
needsFree= 1;
|
||||
}
|
||||
|
||||
/* clear old dm */
|
||||
if(psmd->dm){
|
||||
if (psmd->dm) {
|
||||
psmd->dm->needsFree = 1;
|
||||
psmd->dm->release(psmd->dm);
|
||||
}
|
||||
else if(psmd->flag & eParticleSystemFlag_file_loaded) {
|
||||
else if (psmd->flag & eParticleSystemFlag_file_loaded) {
|
||||
/* in file read dm just wasn't saved in file so no need to reset everything */
|
||||
psmd->flag &= ~eParticleSystemFlag_file_loaded;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
CDDM_apply_vert_coords(psmd->dm, vertexCos);
|
||||
CDDM_calc_normals(psmd->dm);
|
||||
|
||||
if(needsFree){
|
||||
if (needsFree) {
|
||||
dm->needsFree = 1;
|
||||
dm->release(dm);
|
||||
}
|
||||
@@ -177,9 +177,9 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
psmd->dm->needsFree = 0;
|
||||
|
||||
/* report change in mesh structure */
|
||||
if(psmd->dm->getNumVerts(psmd->dm)!=psmd->totdmvert ||
|
||||
if (psmd->dm->getNumVerts(psmd->dm)!=psmd->totdmvert ||
|
||||
psmd->dm->getNumEdges(psmd->dm)!=psmd->totdmedge ||
|
||||
psmd->dm->getNumTessFaces(psmd->dm)!=psmd->totdmface){
|
||||
psmd->dm->getNumTessFaces(psmd->dm)!=psmd->totdmface) {
|
||||
|
||||
psys->recalc |= PSYS_RECALC_RESET;
|
||||
|
||||
@@ -188,7 +188,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
psmd->totdmface= psmd->dm->getNumTessFaces(psmd->dm);
|
||||
}
|
||||
|
||||
if(psys) {
|
||||
if (psys) {
|
||||
psmd->flag &= ~eParticleSystemFlag_psys_updated;
|
||||
particle_system_update(md->scene, ob, psys);
|
||||
psmd->flag |= eParticleSystemFlag_psys_updated;
|
||||
@@ -204,11 +204,11 @@ static void deformVertsEM(
|
||||
{
|
||||
DerivedMesh *dm = derivedData;
|
||||
|
||||
if(!derivedData) dm = CDDM_from_editmesh(editData, ob->data);
|
||||
if (!derivedData) dm = CDDM_from_editmesh(editData, ob->data);
|
||||
|
||||
deformVerts(md, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(!derivedData) dm->release(dm);
|
||||
if (!derivedData) dm->release(dm);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ static void *dualcon_alloc_output(int totvert, int totquad)
|
||||
{
|
||||
DualConOutput *output;
|
||||
|
||||
if(!(output = MEM_callocN(sizeof(DualConOutput),
|
||||
if (!(output = MEM_callocN(sizeof(DualConOutput),
|
||||
"DualConOutput")))
|
||||
return NULL;
|
||||
|
||||
@@ -135,7 +135,7 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4])
|
||||
|
||||
cur_poly->loopstart = output->curface * 4;
|
||||
cur_poly->totloop = 4;
|
||||
for(i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
mloop[output->curface * 4 + i].v = vert_indices[i];
|
||||
|
||||
output->curface++;
|
||||
@@ -160,7 +160,7 @@ static DerivedMesh *applyModifier(ModifierData *md,
|
||||
|
||||
init_dualcon_mesh(&input, dm);
|
||||
|
||||
if(rmd->flag & MOD_REMESH_FLOOD_FILL)
|
||||
if (rmd->flag & MOD_REMESH_FLOOD_FILL)
|
||||
flags |= DUALCON_FLOOD_FILL;
|
||||
|
||||
switch(rmd->mode) {
|
||||
|
||||
@@ -207,11 +207,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
normalize_v3(axis_vec);
|
||||
|
||||
/* screw */
|
||||
if(ltmd->flag & MOD_SCREW_OBJECT_OFFSET) {
|
||||
if (ltmd->flag & MOD_SCREW_OBJECT_OFFSET) {
|
||||
/* find the offset along this axis relative to this objects matrix */
|
||||
float totlen = len_v3(mtx_tx[3]);
|
||||
|
||||
if(totlen != 0.0f) {
|
||||
if (totlen != 0.0f) {
|
||||
float zero[3]={0.0f, 0.0f, 0.0f};
|
||||
float cp[3];
|
||||
screw_ofs= closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec);
|
||||
@@ -224,7 +224,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
/* angle */
|
||||
|
||||
#if 0 // cant incluide this, not predictable enough, though quite fun,.
|
||||
if(ltmd->flag & MOD_SCREW_OBJECT_ANGLE) {
|
||||
if (ltmd->flag & MOD_SCREW_OBJECT_ANGLE) {
|
||||
float mtx3_tx[3][3];
|
||||
copy_m3_m4(mtx3_tx, mtx_tx);
|
||||
|
||||
@@ -248,7 +248,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
cross_v3_v3v3(axis_tmp, cross1, c2);
|
||||
normalize_v3(axis_tmp);
|
||||
|
||||
if(len_v3v3(axis_tmp, axis_vec) > 1.0f)
|
||||
if (len_v3v3(axis_tmp, axis_vec) > 1.0f)
|
||||
angle= -angle;
|
||||
|
||||
}
|
||||
@@ -276,7 +276,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
if (fabsf(screw_ofs) <= (FLT_EPSILON*100.0f) && fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON*100.0f)) {
|
||||
close= 1;
|
||||
step_tot--;
|
||||
if(step_tot < 3) step_tot= 3;
|
||||
if (step_tot < 3) step_tot= 3;
|
||||
|
||||
maxVerts = totvert * step_tot; /* -1 because we're joining back up */
|
||||
maxEdges = (totvert * step_tot) + /* these are the edges between new verts */
|
||||
@@ -287,7 +287,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
}
|
||||
else {
|
||||
close= 0;
|
||||
if(step_tot < 3) step_tot= 3;
|
||||
if (step_tot < 3) step_tot= 3;
|
||||
|
||||
maxVerts = totvert * step_tot; /* -1 because we're joining back up */
|
||||
maxEdges = (totvert * (step_tot-1)) + /* these are the edges between new verts */
|
||||
@@ -333,7 +333,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
med_new->flag= med_orig->flag & ~ME_LOOSEEDGE;
|
||||
}
|
||||
|
||||
if(ltmd->flag & MOD_SCREW_NORMAL_CALC) {
|
||||
if (ltmd->flag & MOD_SCREW_NORMAL_CALC) {
|
||||
/*
|
||||
* Normal Calculation (for face flipping)
|
||||
* Sort edge verts for correct face flipping
|
||||
@@ -459,7 +459,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
/*printf("Loop on connected vert: %i\n", i);*/
|
||||
|
||||
for(j=0; j<2; j++) {
|
||||
for (j=0; j<2; j++) {
|
||||
/*printf("\tSide: %i\n", j);*/
|
||||
screwvert_iter_init(<_iter, vert_connect, i, j);
|
||||
if (j == 1) {
|
||||
@@ -564,7 +564,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
ed_loop_flip= !ed_loop_flip;
|
||||
|
||||
/* if its closed, we only need 1 loop */
|
||||
for(j=ed_loop_closed; j<2; j++) {
|
||||
for (j=ed_loop_closed; j<2; j++) {
|
||||
/*printf("Ordering Side J %i\n", j);*/
|
||||
|
||||
screwvert_iter_init(<_iter, vert_connect, v_best, j);
|
||||
@@ -587,7 +587,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
if (ed_loop_flip == 0) {
|
||||
/*printf("\t\t\tFlipping 0\n");*/
|
||||
SWAP(unsigned int, lt_iter.e->v1, lt_iter.e->v2);
|
||||
}/* else {
|
||||
}
|
||||
/* else {
|
||||
printf("\t\t\tFlipping Not 0\n");
|
||||
}*/
|
||||
}
|
||||
@@ -595,13 +596,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
if (ed_loop_flip == 1) {
|
||||
/*printf("\t\t\tFlipping 1\n");*/
|
||||
SWAP(unsigned int, lt_iter.e->v1, lt_iter.e->v2);
|
||||
}/* else {
|
||||
}
|
||||
/* else {
|
||||
printf("\t\t\tFlipping Not 1\n");
|
||||
}*/
|
||||
}/* else {
|
||||
}
|
||||
/* else {
|
||||
printf("\t\tIncorrect edge topology");
|
||||
}*/
|
||||
}/* else {
|
||||
}
|
||||
/* else {
|
||||
printf("\t\tNo Edge at this point\n");
|
||||
}*/
|
||||
screwvert_iter_step(<_iter);
|
||||
@@ -700,7 +704,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
copy_m3_m4(mat3, mat);
|
||||
}
|
||||
|
||||
if(screw_ofs)
|
||||
if (screw_ofs)
|
||||
madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot-1)));
|
||||
|
||||
/* copy a slice */
|
||||
@@ -711,7 +715,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
for (j=0; j<totvert; j++, mv_new_base++, mv_new++) {
|
||||
/* set normal */
|
||||
if(vert_connect) {
|
||||
if (vert_connect) {
|
||||
mul_v3_m3v3(nor_tx, mat3, vert_connect[j].no);
|
||||
|
||||
/* set the normal now its transformed */
|
||||
@@ -744,7 +748,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
}
|
||||
|
||||
/* we can avoid if using vert alloc trick */
|
||||
if(vert_connect) {
|
||||
if (vert_connect) {
|
||||
MEM_freeN(vert_connect);
|
||||
vert_connect= NULL;
|
||||
}
|
||||
@@ -776,7 +780,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
for (step=0; step < step_tot-1; step++) {
|
||||
|
||||
/* new face */
|
||||
if(do_flip) {
|
||||
if (do_flip) {
|
||||
ml_new[3].v = i1;
|
||||
ml_new[2].v = i2;
|
||||
ml_new[1].v = i2 + totvert;
|
||||
@@ -822,7 +826,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
/* close the loop*/
|
||||
if (close) {
|
||||
if(do_flip) {
|
||||
if (do_flip) {
|
||||
ml_new[3].v = i1;
|
||||
ml_new[2].v = i2;
|
||||
ml_new[1].v = med_new_firstloop->v2;
|
||||
@@ -890,7 +894,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
}
|
||||
#endif
|
||||
|
||||
if((ltmd->flag & MOD_SCREW_NORMAL_CALC) == 0) {
|
||||
if ((ltmd->flag & MOD_SCREW_NORMAL_CALC) == 0) {
|
||||
/* BMESH_TODO, we only need to get vertex normals here, this is way overkill */
|
||||
CDDM_calc_normals(result);
|
||||
}
|
||||
@@ -906,7 +910,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
{
|
||||
ScrewModifierData *ltmd= (ScrewModifierData*) md;
|
||||
|
||||
if(ltmd->ob_axis) {
|
||||
if (ltmd->ob_axis) {
|
||||
DagNode *curNode= dag_get_node(forest, ltmd->ob_axis);
|
||||
|
||||
dag_add_relation(forest, curNode, obNode,
|
||||
|
||||
@@ -58,9 +58,9 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
KeyBlock *kb= ob_get_keyblock(ob);
|
||||
float (*deformedVerts)[3];
|
||||
|
||||
if(kb && kb->totelem == numVerts) {
|
||||
if (kb && kb->totelem == numVerts) {
|
||||
deformedVerts= (float(*)[3])do_ob_key(md->scene, ob);
|
||||
if(deformedVerts) {
|
||||
if (deformedVerts) {
|
||||
memcpy(vertexCos, deformedVerts, sizeof(float)*3*numVerts);
|
||||
MEM_freeN(deformedVerts);
|
||||
}
|
||||
@@ -76,13 +76,13 @@ static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedDat
|
||||
|
||||
(void)vertexCos; /* unused */
|
||||
|
||||
if(kb && kb->totelem==numVerts && kb!=key->refkey) {
|
||||
if (kb && kb->totelem==numVerts && kb!=key->refkey) {
|
||||
int a;
|
||||
|
||||
if(ob->shapeflag & OB_SHAPE_LOCK) scale_m3_fl(scale, 1);
|
||||
if (ob->shapeflag & OB_SHAPE_LOCK) scale_m3_fl(scale, 1);
|
||||
else scale_m3_fl(scale, kb->curval);
|
||||
|
||||
for(a=0; a<numVerts; a++)
|
||||
for (a=0; a<numVerts; a++)
|
||||
copy_m3_m3(defMats[a], scale);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ static void deformVertsEM(ModifierData *md, Object *ob,
|
||||
{
|
||||
Key *key= ob_get_key(ob);
|
||||
|
||||
if(key && key->type == KEY_RELATIVE)
|
||||
if (key && key->type == KEY_RELATIVE)
|
||||
deformVerts(md, ob, derivedData, vertexCos, numVerts, 0, 0);
|
||||
}
|
||||
|
||||
@@ -114,11 +114,11 @@ static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob,
|
||||
|
||||
(void)vertexCos; /* unused */
|
||||
|
||||
if(kb && kb->totelem==numVerts && kb!=key->refkey) {
|
||||
if (kb && kb->totelem==numVerts && kb!=key->refkey) {
|
||||
int a;
|
||||
scale_m3_fl(scale, kb->curval);
|
||||
|
||||
for(a=0; a<numVerts; a++)
|
||||
for (a=0; a<numVerts; a++)
|
||||
copy_m3_m3(defMats[a], scale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +83,10 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(smd->vgroup_name[0])
|
||||
if (smd->vgroup_name[0])
|
||||
dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
if(smd->shrinkType == MOD_SHRINKWRAP_PROJECT
|
||||
if (smd->shrinkType == MOD_SHRINKWRAP_PROJECT
|
||||
&& smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL)
|
||||
dataMask |= CD_MASK_MVERT;
|
||||
|
||||
@@ -119,12 +119,12 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
CustomDataMask dataMask = requiredDataMask(ob, md);
|
||||
|
||||
/* ensure we get a CDDM with applied vertex coords */
|
||||
if(dataMask)
|
||||
if (dataMask)
|
||||
dm= get_cddm(ob, NULL, dm, vertexCos);
|
||||
|
||||
shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -134,12 +134,12 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD
|
||||
CustomDataMask dataMask = requiredDataMask(ob, md);
|
||||
|
||||
/* ensure we get a CDDM with applied vertex coords */
|
||||
if(dataMask)
|
||||
if (dataMask)
|
||||
dm= get_cddm(ob, editData, dm, vertexCos);
|
||||
|
||||
shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@
|
||||
static void axis_limit(int axis, const float limits[2], float co[3], float dcut[3])
|
||||
{
|
||||
float val = co[axis];
|
||||
if(limits[0] > val) val = limits[0];
|
||||
if(limits[1] < val) val = limits[1];
|
||||
if (limits[0] > val) val = limits[0];
|
||||
if (limits[1] < val) val = limits[1];
|
||||
|
||||
dcut[axis] = co[axis] - val;
|
||||
co[axis] = val;
|
||||
@@ -112,7 +112,7 @@ static void simpleDeform_twist(const float factor, const float *dcut, float *co)
|
||||
co[1] = x*sint + y*cost;
|
||||
co[2] = z;
|
||||
|
||||
if(dcut) {
|
||||
if (dcut) {
|
||||
co[0] += dcut[0];
|
||||
co[1] += dcut[1];
|
||||
co[2] += dcut[2];
|
||||
@@ -157,15 +157,15 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
|
||||
MDeformVert *dvert;
|
||||
|
||||
//Safe-check
|
||||
if(smd->origin == ob) smd->origin = NULL; //No self references
|
||||
if (smd->origin == ob) smd->origin = NULL; //No self references
|
||||
|
||||
if(smd->limit[0] < 0.0f) smd->limit[0] = 0.0f;
|
||||
if(smd->limit[0] > 1.0f) smd->limit[0] = 1.0f;
|
||||
if (smd->limit[0] < 0.0f) smd->limit[0] = 0.0f;
|
||||
if (smd->limit[0] > 1.0f) smd->limit[0] = 1.0f;
|
||||
|
||||
smd->limit[0] = MIN2(smd->limit[0], smd->limit[1]); //Upper limit >= than lower limit
|
||||
|
||||
//Calculate matrixs do convert between coordinate spaces
|
||||
if(smd->origin) {
|
||||
if (smd->origin) {
|
||||
transf = &tmp_transf;
|
||||
|
||||
if (smd->originOpts & MOD_SIMPLEDEFORM_ORIGIN_LOCAL) {
|
||||
@@ -185,12 +185,12 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
|
||||
float lower = FLT_MAX;
|
||||
float upper = -FLT_MAX;
|
||||
|
||||
for(i=0; i<numVerts; i++)
|
||||
for (i=0; i<numVerts; i++)
|
||||
{
|
||||
float tmp[3];
|
||||
copy_v3_v3(tmp, vertexCos[i]);
|
||||
|
||||
if(transf) space_transform_apply(transf, tmp);
|
||||
if (transf) space_transform_apply(transf, tmp);
|
||||
|
||||
lower = MIN2(lower, tmp[limit_axis]);
|
||||
upper = MAX2(upper, tmp[limit_axis]);
|
||||
@@ -216,30 +216,30 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object
|
||||
return; //No simpledeform mode?
|
||||
}
|
||||
|
||||
for(i=0; i<numVerts; i++)
|
||||
for (i=0; i<numVerts; i++)
|
||||
{
|
||||
float weight = defvert_array_find_weight_safe(dvert, i, vgroup);
|
||||
|
||||
if (weight != 0.0f) {
|
||||
float co[3], dcut[3] = {0.0f, 0.0f, 0.0f};
|
||||
|
||||
if(transf) {
|
||||
if (transf) {
|
||||
space_transform_apply(transf, vertexCos[i]);
|
||||
}
|
||||
|
||||
copy_v3_v3(co, vertexCos[i]);
|
||||
|
||||
/* Apply axis limits */
|
||||
if(smd->mode != MOD_SIMPLEDEFORM_MODE_BEND) { /* Bend mode shoulnt have any lock axis */
|
||||
if(smd->axis & MOD_SIMPLEDEFORM_LOCK_AXIS_X) axis_limit(0, lock_axis, co, dcut);
|
||||
if(smd->axis & MOD_SIMPLEDEFORM_LOCK_AXIS_Y) axis_limit(1, lock_axis, co, dcut);
|
||||
if (smd->mode != MOD_SIMPLEDEFORM_MODE_BEND) { /* Bend mode shoulnt have any lock axis */
|
||||
if (smd->axis & MOD_SIMPLEDEFORM_LOCK_AXIS_X) axis_limit(0, lock_axis, co, dcut);
|
||||
if (smd->axis & MOD_SIMPLEDEFORM_LOCK_AXIS_Y) axis_limit(1, lock_axis, co, dcut);
|
||||
}
|
||||
axis_limit(limit_axis, smd_limit, co, dcut);
|
||||
|
||||
simpleDeform_callback(smd_factor, dcut, co); //Apply deform
|
||||
interp_v3_v3v3(vertexCos[i], vertexCos[i], co, weight); //Use vertex weight has coef of linear interpolation
|
||||
|
||||
if(transf) space_transform_invert(transf, vertexCos[i]);
|
||||
if (transf) space_transform_invert(transf, vertexCos[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,7 +281,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(smd->vgroup_name[0])
|
||||
if (smd->vgroup_name[0])
|
||||
dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
@@ -316,12 +316,12 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
/* we implement requiredDataMask but thats not really useful since
|
||||
* mesh_calc_modifiers pass a NULL derivedData */
|
||||
if(dataMask)
|
||||
if (dataMask)
|
||||
dm= get_dm(ob, NULL, dm, NULL, 0);
|
||||
|
||||
SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -336,12 +336,12 @@ static void deformVertsEM(ModifierData *md, Object *ob,
|
||||
|
||||
/* we implement requiredDataMask but thats not really useful since
|
||||
* mesh_calc_modifiers pass a NULL derivedData */
|
||||
if(dataMask)
|
||||
if (dataMask)
|
||||
dm= get_dm(ob, editData, dm, NULL, 0);
|
||||
|
||||
SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
smokeModifier_do(smd, md->scene, ob, dm);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
if (smd->domain->fluid_group || smd->domain->coll_group) {
|
||||
GroupObject *go = NULL;
|
||||
|
||||
if(smd->domain->fluid_group)
|
||||
if (smd->domain->fluid_group)
|
||||
for (go = smd->domain->fluid_group->gobject.first; go; go = go->next) {
|
||||
if (go->ob) {
|
||||
SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke);
|
||||
@@ -126,7 +126,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
}
|
||||
}
|
||||
|
||||
if(smd->domain->coll_group)
|
||||
if (smd->domain->coll_group)
|
||||
for (go = smd->domain->coll_group->gobject.first; go; go = go->next) {
|
||||
if (go->ob) {
|
||||
SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke);
|
||||
@@ -159,12 +159,12 @@ static void foreachIDLink(ModifierData *md, Object *ob,
|
||||
{
|
||||
SmokeModifierData *smd = (SmokeModifierData*) md;
|
||||
|
||||
if(smd->type==MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
|
||||
if (smd->type==MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
|
||||
walk(userData, ob, (ID **)&smd->domain->coll_group);
|
||||
walk(userData, ob, (ID **)&smd->domain->fluid_group);
|
||||
walk(userData, ob, (ID **)&smd->domain->eff_group);
|
||||
|
||||
if(smd->domain->effector_weights) {
|
||||
if (smd->domain->effector_weights) {
|
||||
walk(userData, ob, (ID **)&smd->domain->effector_weights->group);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ static int isDisabled(ModifierData *md, int UNUSED(useRenderParams))
|
||||
flag = smd->flag & (MOD_SMOOTH_X|MOD_SMOOTH_Y|MOD_SMOOTH_Z);
|
||||
|
||||
/* disable if modifier is off for X, Y and Z or if factor is 0 */
|
||||
if((smd->fac == 0.0f) || flag == 0) return 1;
|
||||
if ((smd->fac == 0.0f) || flag == 0) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
@@ -221,7 +221,7 @@ static void deformVerts(
|
||||
smoothModifier_do((SmoothModifierData *)md, ob, dm,
|
||||
vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ static void deformVertsEM(
|
||||
smoothModifier_do((SmoothModifierData *)md, ob, dm,
|
||||
vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
|
||||
#endif
|
||||
|
||||
face_nors = CustomData_get_layer(&dm->polyData, CD_NORMAL);
|
||||
if(!face_nors) {
|
||||
if (!face_nors) {
|
||||
calc_face_nors = 1;
|
||||
face_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, numFaces);
|
||||
}
|
||||
@@ -119,11 +119,11 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
|
||||
}
|
||||
/* --- end define --- */
|
||||
|
||||
for(i = 0; i < numFaces; i++, mp++) {
|
||||
for (i = 0; i < numFaces; i++, mp++) {
|
||||
int j;
|
||||
|
||||
f_no = face_nors[i];
|
||||
if(calc_face_nors)
|
||||
if (calc_face_nors)
|
||||
mesh_calc_poly_normal(mp, mloop+mp->loopstart, mvert, f_no);
|
||||
|
||||
ml = mloop + mp->loopstart;
|
||||
@@ -132,7 +132,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
|
||||
}
|
||||
}
|
||||
|
||||
for(edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) {
|
||||
for (edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) {
|
||||
/* Get the edge vert indices, and edge value (the face indices that use it)*/
|
||||
BLI_edgehashIterator_getKey(edge_iter, &ed_v1, &ed_v2);
|
||||
edge_ref = BLI_edgehashIterator_getValue(edge_iter);
|
||||
@@ -143,7 +143,8 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
|
||||
add_v3_v3v3(edge_normal, face_nors[edge_ref->f1], face_nors[edge_ref->f2]);
|
||||
normalize_v3(edge_normal);
|
||||
mul_v3_fl(edge_normal, angle_normalized_v3v3(face_nors[edge_ref->f1], face_nors[edge_ref->f2]));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* only one face attached to that edge */
|
||||
/* an edge without another attached- the weight on this is
|
||||
* undefined, M_PI/2 is 90d in radians and that seems good enough */
|
||||
@@ -158,8 +159,8 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
|
||||
}
|
||||
|
||||
/* normalize vertex normals and assign */
|
||||
for(i = 0; i < numVerts; i++, mv++) {
|
||||
if(normalize_v3(temp_nors[i]) == 0.0f) {
|
||||
for (i = 0; i < numVerts; i++, mv++) {
|
||||
if (normalize_v3(temp_nors[i]) == 0.0f) {
|
||||
normal_short_to_float_v3(temp_nors[i], mv->no);
|
||||
}
|
||||
}
|
||||
@@ -192,7 +193,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
@@ -257,17 +258,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
orig_mloop = dm->getLoopArray(dm);
|
||||
orig_mpoly = dm->getPolyArray(dm);
|
||||
|
||||
if(smd->flag & MOD_SOLIDIFY_RIM) {
|
||||
if (smd->flag & MOD_SOLIDIFY_RIM) {
|
||||
EdgeHash *edgehash = BLI_edgehash_new();
|
||||
EdgeHashIterator *ehi;
|
||||
unsigned int v1, v2;
|
||||
int eidx;
|
||||
|
||||
for(i=0, mv=orig_mvert; i<numVerts; i++, mv++) {
|
||||
for (i=0, mv=orig_mvert; i<numVerts; i++, mv++) {
|
||||
mv->flag &= ~ME_VERT_TMP_TAG;
|
||||
}
|
||||
|
||||
for(i=0, ed=orig_medge; i<numEdges; i++, ed++) {
|
||||
for (i=0, ed=orig_medge; i<numEdges; i++, ed++) {
|
||||
BLI_edgehash_insert(edgehash, ed->v1, ed->v2, SET_INT_IN_POINTER(i));
|
||||
}
|
||||
|
||||
@@ -279,7 +280,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
const unsigned int ml_v1 = _v1; \
|
||||
const unsigned int ml_v2 = _v2; \
|
||||
eidx= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edgehash, ml_v1, ml_v2)); \
|
||||
if(edge_users[eidx] == INVALID_UNUSED) { \
|
||||
if (edge_users[eidx] == INVALID_UNUSED) { \
|
||||
ed= orig_medge + eidx; \
|
||||
edge_users[eidx] = (ml_v1 < ml_v2) == (ed->v1 < ed->v2) ? i : (i + numFaces); \
|
||||
edge_order[eidx] = edge_ord; \
|
||||
@@ -307,9 +308,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
#undef INVALID_PAIR
|
||||
|
||||
ehi= BLI_edgehashIterator_new(edgehash);
|
||||
for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
|
||||
eidx= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
|
||||
if(edge_users[eidx] >= 0) {
|
||||
if (edge_users[eidx] >= 0) {
|
||||
BLI_edgehashIterator_getKey(ehi, &v1, &v2);
|
||||
orig_mvert[v1].flag |= ME_VERT_TMP_TAG;
|
||||
orig_mvert[v2].flag |= ME_VERT_TMP_TAG;
|
||||
@@ -320,8 +321,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
}
|
||||
BLI_edgehashIterator_free(ehi);
|
||||
|
||||
for(i=0, mv=orig_mvert; i<numVerts; i++, mv++) {
|
||||
if(mv->flag & ME_VERT_TMP_TAG) {
|
||||
for (i=0, mv=orig_mvert; i<numVerts; i++, mv++) {
|
||||
if (mv->flag & ME_VERT_TMP_TAG) {
|
||||
old_vert_arr[i] = BLI_array_count(new_vert_arr);
|
||||
BLI_array_append(new_vert_arr, i);
|
||||
newEdges++;
|
||||
@@ -333,7 +334,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
BLI_edgehash_free(edgehash, NULL);
|
||||
}
|
||||
|
||||
if(smd->flag & MOD_SOLIDIFY_NORMAL_CALC) {
|
||||
if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) {
|
||||
vert_nors= MEM_callocN(sizeof(float) * numVerts * 3, "mod_solid_vno_hq");
|
||||
dm_calc_normal(dm, vert_nors);
|
||||
}
|
||||
@@ -372,7 +373,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
mp->loopstart+(mp->totloop-j-1)+dm->numLoopData, 1);
|
||||
}
|
||||
|
||||
if(mat_ofs) {
|
||||
if (mat_ofs) {
|
||||
mp->mat_nr += mat_ofs;
|
||||
CLAMP(mp->mat_nr, 0, mat_nr_max);
|
||||
}
|
||||
@@ -395,25 +396,25 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0, ed=medge+numEdges; i<numEdges; i++, ed++) {
|
||||
for (i=0, ed=medge+numEdges; i<numEdges; i++, ed++) {
|
||||
ed->v1 += numVerts;
|
||||
ed->v2 += numVerts;
|
||||
}
|
||||
|
||||
/* note, copied vertex layers don't have flipped normals yet. do this after applying offset */
|
||||
if((smd->flag & MOD_SOLIDIFY_EVEN) == 0) {
|
||||
if ((smd->flag & MOD_SOLIDIFY_EVEN) == 0) {
|
||||
/* no even thickness, very simple */
|
||||
float scalar_short;
|
||||
float scalar_short_vgroup;
|
||||
|
||||
|
||||
if(ofs_new != 0.0f) {
|
||||
if (ofs_new != 0.0f) {
|
||||
scalar_short= scalar_short_vgroup= ofs_new / 32767.0f;
|
||||
mv= mvert + ((ofs_new >= ofs_orig) ? 0 : numVerts);
|
||||
dv= dvert;
|
||||
for(i=0; i<numVerts; i++, mv++) {
|
||||
if(dv) {
|
||||
if(defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index);
|
||||
for (i=0; i<numVerts; i++, mv++) {
|
||||
if (dv) {
|
||||
if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index);
|
||||
else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index);
|
||||
scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short;
|
||||
dv++;
|
||||
@@ -422,13 +423,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
}
|
||||
}
|
||||
|
||||
if(ofs_orig != 0.0f) {
|
||||
if (ofs_orig != 0.0f) {
|
||||
scalar_short= scalar_short_vgroup= ofs_orig / 32767.0f;
|
||||
mv= mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); /* same as above but swapped, intentional use of 'ofs_new' */
|
||||
dv= dvert;
|
||||
for(i=0; i<numVerts; i++, mv++) {
|
||||
if(dv) {
|
||||
if(defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index);
|
||||
for (i=0; i<numVerts; i++, mv++) {
|
||||
if (dv) {
|
||||
if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index);
|
||||
else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index);
|
||||
scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short;
|
||||
dv++;
|
||||
@@ -451,14 +452,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
int j, vidx;
|
||||
|
||||
face_nors = CustomData_get_layer(&dm->polyData, CD_NORMAL);
|
||||
if(!face_nors) {
|
||||
if (!face_nors) {
|
||||
face_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, dm->numPolyData);
|
||||
face_nors_calc= 1;
|
||||
}
|
||||
|
||||
if(vert_nors==NULL) {
|
||||
if (vert_nors==NULL) {
|
||||
vert_nors= MEM_mallocN(sizeof(float) * numVerts * 3, "mod_solid_vno");
|
||||
for(i=0, mv=mvert; i<numVerts; i++, mv++) {
|
||||
for (i=0, mv=mvert; i<numVerts; i++, mv++) {
|
||||
normal_short_to_float_v3(vert_nors[i], mv->no);
|
||||
}
|
||||
}
|
||||
@@ -491,19 +492,19 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
BLI_array_free(face_angles);
|
||||
|
||||
/* vertex group support */
|
||||
if(dvert) {
|
||||
if (dvert) {
|
||||
float scalar;
|
||||
|
||||
dv= dvert;
|
||||
if(defgrp_invert) {
|
||||
for(i=0; i<numVerts; i++, dv++) {
|
||||
if (defgrp_invert) {
|
||||
for (i=0; i<numVerts; i++, dv++) {
|
||||
scalar= 1.0f - defvert_find_weight(dv, defgrp_index);
|
||||
scalar= offset_fac_vg + (scalar * offset_fac_vg_inv);
|
||||
vert_angles[i] *= scalar;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(i=0; i<numVerts; i++, dv++) {
|
||||
for (i=0; i<numVerts; i++, dv++) {
|
||||
scalar= defvert_find_weight(dv, defgrp_index);
|
||||
scalar= offset_fac_vg + (scalar * offset_fac_vg_inv);
|
||||
vert_angles[i] *= scalar;
|
||||
@@ -511,21 +512,21 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
}
|
||||
}
|
||||
|
||||
if(ofs_new) {
|
||||
if (ofs_new) {
|
||||
mv= mvert + ((ofs_new >= ofs_orig) ? 0 : numVerts);
|
||||
|
||||
for(i=0; i<numVerts; i++, mv++) {
|
||||
if(vert_accum[i]) { /* zero if unselected */
|
||||
for (i=0; i<numVerts; i++, mv++) {
|
||||
if (vert_accum[i]) { /* zero if unselected */
|
||||
madd_v3_v3fl(mv->co, vert_nors[i], ofs_new * (vert_angles[i] / vert_accum[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ofs_orig) {
|
||||
if (ofs_orig) {
|
||||
mv= mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); /* same as above but swapped, intentional use of 'ofs_new' */
|
||||
|
||||
for(i=0; i<numVerts; i++, mv++) {
|
||||
if(vert_accum[i]) { /* zero if unselected */
|
||||
for (i=0; i<numVerts; i++, mv++) {
|
||||
if (vert_accum[i]) { /* zero if unselected */
|
||||
madd_v3_v3fl(mv->co, vert_nors[i], ofs_orig * (vert_angles[i] / vert_accum[i]));
|
||||
}
|
||||
}
|
||||
@@ -534,18 +535,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
MEM_freeN(vert_angles);
|
||||
}
|
||||
|
||||
if(vert_nors)
|
||||
if (vert_nors)
|
||||
MEM_freeN(vert_nors);
|
||||
|
||||
/* flip vertex normals for copied verts */
|
||||
mv= mvert + numVerts;
|
||||
for(i=0; i<numVerts; i++, mv++) {
|
||||
for (i=0; i<numVerts; i++, mv++) {
|
||||
mv->no[0]= -mv->no[0];
|
||||
mv->no[1]= -mv->no[1];
|
||||
mv->no[2]= -mv->no[2];
|
||||
}
|
||||
|
||||
if(smd->flag & MOD_SOLIDIFY_RIM) {
|
||||
if (smd->flag & MOD_SOLIDIFY_RIM) {
|
||||
int *origindex;
|
||||
|
||||
/* bugger, need to re-calculate the normals for the new edge faces.
|
||||
@@ -569,14 +570,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
/* add faces & edges */
|
||||
origindex= result->getEdgeDataArray(result, CD_ORIGINDEX);
|
||||
ed= medge + (numEdges * 2);
|
||||
for(i=0; i<newEdges; i++, ed++) {
|
||||
for (i=0; i<newEdges; i++, ed++) {
|
||||
ed->v1= new_vert_arr[i];
|
||||
ed->v2= new_vert_arr[i] + numVerts;
|
||||
ed->flag |= ME_EDGEDRAW;
|
||||
|
||||
origindex[numEdges * 2 + i]= ORIGINDEX_NONE;
|
||||
|
||||
if(crease_rim)
|
||||
if (crease_rim)
|
||||
ed->crease= crease_rim;
|
||||
}
|
||||
|
||||
@@ -587,12 +588,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
mp = mpoly + (numFaces * 2);
|
||||
ml = mloop + (numLoops * 2);
|
||||
j = 0;
|
||||
for(i=0; i<newFaces; i++, mp++) {
|
||||
for (i=0; i<newFaces; i++, mp++) {
|
||||
int eidx= new_edge_arr[i];
|
||||
int fidx= edge_users[eidx];
|
||||
int flip, k1, k2;
|
||||
|
||||
if(fidx >= numFaces) {
|
||||
if (fidx >= numFaces) {
|
||||
fidx -= numFaces;
|
||||
flip= 1;
|
||||
}
|
||||
@@ -620,7 +621,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops*2+j+2, 1);
|
||||
CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops*2+j+3, 1);
|
||||
|
||||
if(flip) {
|
||||
if (flip) {
|
||||
ml[j].v = ed->v1;
|
||||
ml[j++].e = eidx;
|
||||
|
||||
@@ -653,18 +654,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
}
|
||||
|
||||
/* use the next material index if option enabled */
|
||||
if(mat_ofs_rim) {
|
||||
if (mat_ofs_rim) {
|
||||
mp->mat_nr += mat_ofs_rim;
|
||||
CLAMP(mp->mat_nr, 0, mat_nr_max);
|
||||
}
|
||||
if(crease_outer) {
|
||||
if (crease_outer) {
|
||||
/* crease += crease_outer; without wrapping */
|
||||
unsigned char *cr= (unsigned char *)&(ed->crease);
|
||||
int tcr= *cr + crease_outer;
|
||||
*cr= tcr > 255 ? 255 : tcr;
|
||||
}
|
||||
|
||||
if(crease_inner) {
|
||||
if (crease_inner) {
|
||||
/* crease += crease_inner; without wrapping */
|
||||
unsigned char *cr= (unsigned char *)&(medge[numEdges + eidx].crease);
|
||||
int tcr= *cr + crease_inner;
|
||||
@@ -685,7 +686,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
|
||||
#ifdef SOLIDIFY_SIDE_NORMALS
|
||||
ed= medge + (numEdges * 2);
|
||||
for(i=0; i<newEdges; i++, ed++) {
|
||||
for (i=0; i<newEdges; i++, ed++) {
|
||||
float nor_cpy[3];
|
||||
short *nor_short;
|
||||
int j;
|
||||
@@ -693,7 +694,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
/* note, only the first vertex (lower half of the index) is calculated */
|
||||
normalize_v3_v3(nor_cpy, edge_vert_nos[ed->v1]);
|
||||
|
||||
for(j=0; j<2; j++) { /* loop over both verts of the edge */
|
||||
for (j=0; j<2; j++) { /* loop over both verts of the edge */
|
||||
nor_short= mvert[*(&ed->v1 + j)].no;
|
||||
normal_short_to_float_v3(nor, nor_short);
|
||||
add_v3_v3(nor, nor_cpy);
|
||||
|
||||
@@ -73,10 +73,10 @@ static void freeData(ModifierData *md)
|
||||
{
|
||||
SubsurfModifierData *smd = (SubsurfModifierData*) md;
|
||||
|
||||
if(smd->mCache) {
|
||||
if (smd->mCache) {
|
||||
ccgSubSurf_free(smd->mCache);
|
||||
}
|
||||
if(smd->emCache) {
|
||||
if (smd->emCache) {
|
||||
ccgSubSurf_free(smd->emCache);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
result = subsurf_make_derived_from_derived(derivedData, smd,
|
||||
useRenderParams, NULL, isFinalCalc, 0, (ob->flag & OB_MODE_EDIT));
|
||||
|
||||
if(useRenderParams || !isFinalCalc) {
|
||||
if (useRenderParams || !isFinalCalc) {
|
||||
DerivedMesh *cddm= CDDM_copy(result);
|
||||
result->release(result);
|
||||
result= cddm;
|
||||
|
||||
@@ -61,18 +61,18 @@ static void freeData(ModifierData *md)
|
||||
SurfaceModifierData *surmd = (SurfaceModifierData*) md;
|
||||
|
||||
if (surmd) {
|
||||
if(surmd->bvhtree) {
|
||||
if (surmd->bvhtree) {
|
||||
free_bvhtree_from_mesh(surmd->bvhtree);
|
||||
MEM_freeN(surmd->bvhtree);
|
||||
}
|
||||
|
||||
if(surmd->dm)
|
||||
if (surmd->dm)
|
||||
surmd->dm->release(surmd->dm);
|
||||
|
||||
if(surmd->x)
|
||||
if (surmd->x)
|
||||
MEM_freeN(surmd->x);
|
||||
|
||||
if(surmd->v)
|
||||
if (surmd->v)
|
||||
MEM_freeN(surmd->v);
|
||||
|
||||
surmd->bvhtree = NULL;
|
||||
@@ -94,11 +94,11 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
{
|
||||
SurfaceModifierData *surmd = (SurfaceModifierData*) md;
|
||||
|
||||
if(surmd->dm)
|
||||
if (surmd->dm)
|
||||
surmd->dm->release(surmd->dm);
|
||||
|
||||
/* if possible use/create DerivedMesh */
|
||||
if(derivedData) surmd->dm = CDDM_copy(derivedData);
|
||||
if (derivedData) surmd->dm = CDDM_copy(derivedData);
|
||||
else surmd->dm = get_dm(ob, NULL, NULL, NULL, 0);
|
||||
|
||||
if (!ob->pd) {
|
||||
@@ -106,7 +106,7 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
return;
|
||||
}
|
||||
|
||||
if(surmd->dm) {
|
||||
if (surmd->dm) {
|
||||
unsigned int numverts = 0, i = 0;
|
||||
int init = 0;
|
||||
float *vec;
|
||||
@@ -117,12 +117,12 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
numverts = surmd->dm->getNumVerts ( surmd->dm );
|
||||
|
||||
if(numverts != surmd->numverts || surmd->x == NULL || surmd->v == NULL || md->scene->r.cfra != surmd->cfra+1) {
|
||||
if(surmd->x) {
|
||||
if (numverts != surmd->numverts || surmd->x == NULL || surmd->v == NULL || md->scene->r.cfra != surmd->cfra+1) {
|
||||
if (surmd->x) {
|
||||
MEM_freeN(surmd->x);
|
||||
surmd->x = NULL;
|
||||
}
|
||||
if(surmd->v) {
|
||||
if (surmd->v) {
|
||||
MEM_freeN(surmd->v);
|
||||
surmd->v = NULL;
|
||||
}
|
||||
@@ -136,11 +136,11 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
}
|
||||
|
||||
/* convert to global coordinates and calculate velocity */
|
||||
for(i = 0, x = surmd->x, v = surmd->v; i<numverts; i++, x++, v++) {
|
||||
for (i = 0, x = surmd->x, v = surmd->v; i<numverts; i++, x++, v++) {
|
||||
vec = CDDM_get_vert(surmd->dm, i)->co;
|
||||
mul_m4_v3(ob->obmat, vec);
|
||||
|
||||
if(init)
|
||||
if (init)
|
||||
v->co[0] = v->co[1] = v->co[2] = 0.0f;
|
||||
else
|
||||
sub_v3_v3v3(v->co, vec, x->co);
|
||||
@@ -150,12 +150,12 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
surmd->cfra = md->scene->r.cfra;
|
||||
|
||||
if(surmd->bvhtree)
|
||||
if (surmd->bvhtree)
|
||||
free_bvhtree_from_mesh(surmd->bvhtree);
|
||||
else
|
||||
surmd->bvhtree = MEM_callocN(sizeof(BVHTreeFromMesh), "BVHTreeFromMesh");
|
||||
|
||||
if(surmd->dm->getNumTessFaces(surmd->dm))
|
||||
if (surmd->dm->getNumTessFaces(surmd->dm))
|
||||
bvhtree_from_mesh_faces(surmd->bvhtree, surmd->dm, 0.0, 2, 6);
|
||||
else
|
||||
bvhtree_from_mesh_edges(surmd->bvhtree, surmd->dm, 0.0, 2, 6);
|
||||
|
||||
@@ -68,7 +68,7 @@ void get_texture_value(Tex *texture, float *tex_co, TexResult *texres)
|
||||
* intensity, so calculate one (formula from do_material_tex).
|
||||
* if the texture didn't give an RGB value, copy the intensity across
|
||||
*/
|
||||
if(result_type & TEX_RGB)
|
||||
if (result_type & TEX_RGB)
|
||||
texres->tin = (0.35f * texres->tr + 0.45f * texres->tg
|
||||
+ 0.2f * texres->tb);
|
||||
else
|
||||
@@ -84,16 +84,16 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob,
|
||||
int texmapping = dmd->texmapping;
|
||||
float mapob_imat[4][4];
|
||||
|
||||
if(texmapping == MOD_DISP_MAP_OBJECT) {
|
||||
if(dmd->map_object)
|
||||
if (texmapping == MOD_DISP_MAP_OBJECT) {
|
||||
if (dmd->map_object)
|
||||
invert_m4_m4(mapob_imat, dmd->map_object->obmat);
|
||||
else /* if there is no map object, default to local */
|
||||
texmapping = MOD_DISP_MAP_LOCAL;
|
||||
}
|
||||
|
||||
/* UVs need special handling, since they come from faces */
|
||||
if(texmapping == MOD_DISP_MAP_UV) {
|
||||
if(CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) {
|
||||
if (texmapping == MOD_DISP_MAP_UV) {
|
||||
if (CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) {
|
||||
MPoly *mpoly = dm->getPolyArray(dm);
|
||||
MPoly *mp;
|
||||
MLoop *mloop = dm->getLoopArray(dm);
|
||||
@@ -107,7 +107,7 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob,
|
||||
mloop_uv = CustomData_get_layer_named(&dm->loopData, CD_MLOOPUV, uvname);
|
||||
|
||||
/* verts are given the UV from the first face that uses them */
|
||||
for(i = 0, mp = mpoly; i < numPolys; ++i, ++mp) {
|
||||
for (i = 0, mp = mpoly; i < numPolys; ++i, ++mp) {
|
||||
unsigned int fidx= mp->totloop - 1;
|
||||
|
||||
do {
|
||||
@@ -126,11 +126,12 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob,
|
||||
|
||||
MEM_freeN(done);
|
||||
return;
|
||||
} else /* if there are no UVs, default to local */
|
||||
}
|
||||
else /* if there are no UVs, default to local */
|
||||
texmapping = MOD_DISP_MAP_LOCAL;
|
||||
}
|
||||
|
||||
for(i = 0; i < numVerts; ++i, ++co, ++texco) {
|
||||
for (i = 0; i < numVerts; ++i, ++co, ++texco) {
|
||||
switch(texmapping) {
|
||||
case MOD_DISP_MAP_LOCAL:
|
||||
copy_v3_v3(*texco, *co);
|
||||
@@ -150,7 +151,7 @@ void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3])
|
||||
{
|
||||
while((md=md->next) && md->type==eModifierType_Armature) {
|
||||
ArmatureModifierData *amd = (ArmatureModifierData*) md;
|
||||
if(amd->multi && amd->prevCos==NULL)
|
||||
if (amd->multi && amd->prevCos==NULL)
|
||||
amd->prevCos= MEM_dupallocN(vertexCos);
|
||||
else
|
||||
break;
|
||||
@@ -161,10 +162,10 @@ void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3])
|
||||
/* returns a cdderivedmesh if dm == NULL or is another type of derivedmesh */
|
||||
DerivedMesh *get_cddm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (*vertexCos)[3])
|
||||
{
|
||||
if(dm && dm->type == DM_TYPE_CDDM)
|
||||
if (dm && dm->type == DM_TYPE_CDDM)
|
||||
return dm;
|
||||
|
||||
if(!dm) {
|
||||
if (!dm) {
|
||||
dm= get_dm(ob, em, dm, vertexCos, 0);
|
||||
}
|
||||
else {
|
||||
@@ -172,7 +173,7 @@ DerivedMesh *get_cddm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float
|
||||
CDDM_apply_vert_coords(dm, vertexCos);
|
||||
}
|
||||
|
||||
if(dm)
|
||||
if (dm)
|
||||
CDDM_calc_normals(dm);
|
||||
|
||||
return dm;
|
||||
@@ -181,22 +182,22 @@ DerivedMesh *get_cddm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float
|
||||
/* returns a derived mesh if dm == NULL, for deforming modifiers that need it */
|
||||
DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (*vertexCos)[3], int orco)
|
||||
{
|
||||
if(dm)
|
||||
if (dm)
|
||||
return dm;
|
||||
|
||||
if(ob->type==OB_MESH) {
|
||||
if(em) dm= CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
|
||||
if (ob->type==OB_MESH) {
|
||||
if (em) dm= CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE);
|
||||
else dm = CDDM_from_mesh((struct Mesh *)(ob->data), ob);
|
||||
|
||||
if(vertexCos) {
|
||||
if (vertexCos) {
|
||||
CDDM_apply_vert_coords(dm, vertexCos);
|
||||
//CDDM_calc_normals(dm);
|
||||
}
|
||||
|
||||
if(orco)
|
||||
if (orco)
|
||||
DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob));
|
||||
}
|
||||
else if(ELEM3(ob->type,OB_FONT,OB_CURVE,OB_SURF)) {
|
||||
else if (ELEM3(ob->type,OB_FONT,OB_CURVE,OB_SURF)) {
|
||||
dm= CDDM_from_curve(ob);
|
||||
}
|
||||
|
||||
@@ -208,10 +209,10 @@ void modifier_get_vgroup(Object *ob, DerivedMesh *dm, const char *name, MDeformV
|
||||
*defgrp_index = defgroup_name_index(ob, name);
|
||||
*dvert = NULL;
|
||||
|
||||
if(*defgrp_index >= 0) {
|
||||
if(ob->type == OB_LATTICE)
|
||||
if (*defgrp_index >= 0) {
|
||||
if (ob->type == OB_LATTICE)
|
||||
*dvert = lattice_get_deform_verts(ob);
|
||||
else if(dm)
|
||||
else if (dm)
|
||||
*dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ static void initData(ModifierData *md)
|
||||
UVProjectModifierData *umd = (UVProjectModifierData*) md;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i)
|
||||
for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i)
|
||||
umd->projectors[i] = NULL;
|
||||
umd->image = NULL;
|
||||
umd->flags = 0;
|
||||
@@ -76,7 +76,7 @@ static void copyData(ModifierData *md, ModifierData *target)
|
||||
UVProjectModifierData *tumd = (UVProjectModifierData*) target;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i)
|
||||
for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i)
|
||||
tumd->projectors[i] = umd->projectors[i];
|
||||
tumd->image = umd->image;
|
||||
tumd->flags = umd->flags;
|
||||
@@ -104,7 +104,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob,
|
||||
UVProjectModifierData *umd = (UVProjectModifierData*) md;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i)
|
||||
for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i)
|
||||
walk(userData, ob, &umd->projectors[i]);
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
UVProjectModifierData *umd = (UVProjectModifierData*) md;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < umd->num_projectors; ++i) {
|
||||
if(umd->projectors[i]) {
|
||||
for (i = 0; i < umd->num_projectors; ++i) {
|
||||
if (umd->projectors[i]) {
|
||||
DagNode *curNode = dag_get_node(forest, umd->projectors[i]);
|
||||
|
||||
dag_add_relation(forest, curNode, obNode,
|
||||
@@ -167,21 +167,21 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
|
||||
aspect = aspx / aspy;
|
||||
|
||||
for(i = 0; i < umd->num_projectors; ++i)
|
||||
if(umd->projectors[i])
|
||||
for (i = 0; i < umd->num_projectors; ++i)
|
||||
if (umd->projectors[i])
|
||||
projectors[num_projectors++].ob = umd->projectors[i];
|
||||
|
||||
if(num_projectors == 0) return dm;
|
||||
if (num_projectors == 0) return dm;
|
||||
|
||||
/* make sure there are UV Maps available */
|
||||
|
||||
if(!CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) return dm;
|
||||
if (!CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) return dm;
|
||||
|
||||
/* make sure we're using an existing layer */
|
||||
CustomData_validate_layer_name(&dm->loopData, CD_MLOOPUV, umd->uvlayer_name, uvname);
|
||||
|
||||
/* calculate a projection matrix and normal for each projector */
|
||||
for(i = 0; i < num_projectors; ++i) {
|
||||
for (i = 0; i < num_projectors; ++i) {
|
||||
float tmpmat[4][4];
|
||||
float offsetmat[4][4];
|
||||
Camera *cam = NULL;
|
||||
@@ -190,10 +190,10 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
|
||||
projectors[i].uci= NULL;
|
||||
|
||||
if(projectors[i].ob->type == OB_CAMERA) {
|
||||
if (projectors[i].ob->type == OB_CAMERA) {
|
||||
|
||||
cam = (Camera *)projectors[i].ob->data;
|
||||
if(cam->flag & CAM_PANORAMA) {
|
||||
if (cam->flag & CAM_PANORAMA) {
|
||||
projectors[i].uci= project_camera_info(projectors[i].ob, NULL, aspx, aspy);
|
||||
project_camera_info_scale(projectors[i].uci, scax, scay);
|
||||
free_uci= 1;
|
||||
@@ -204,7 +204,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
float scale= (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale;
|
||||
float xmax, xmin, ymax, ymin;
|
||||
|
||||
if(sensor_fit==CAMERA_SENSOR_FIT_HOR) {
|
||||
if (sensor_fit==CAMERA_SENSOR_FIT_HOR) {
|
||||
xmax = 0.5f * scale;
|
||||
ymax = xmax / aspect;
|
||||
}
|
||||
@@ -222,17 +222,19 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
ymin *= scay;
|
||||
ymax *= scay;
|
||||
|
||||
if(cam->type == CAM_PERSP) {
|
||||
if (cam->type == CAM_PERSP) {
|
||||
float perspmat[4][4];
|
||||
perspective_m4( perspmat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
|
||||
mult_m4_m4m4(tmpmat, perspmat, projectors[i].projmat);
|
||||
} else { /* if(cam->type == CAM_ORTHO) */
|
||||
}
|
||||
else { /* if(cam->type == CAM_ORTHO) */
|
||||
float orthomat[4][4];
|
||||
orthographic_m4( orthomat,xmin, xmax, ymin, ymax, cam->clipsta, cam->clipend);
|
||||
mult_m4_m4m4(tmpmat, orthomat, projectors[i].projmat);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
copy_m4_m4(tmpmat, projectors[i].projmat);
|
||||
}
|
||||
|
||||
@@ -282,22 +284,22 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
dm->getVertCos(dm, coords);
|
||||
|
||||
/* convert coords to world space */
|
||||
for(i = 0, co = coords; i < numVerts; ++i, ++co)
|
||||
for (i = 0, co = coords; i < numVerts; ++i, ++co)
|
||||
mul_m4_v3(ob->obmat, *co);
|
||||
|
||||
/* if only one projector, project coords to UVs */
|
||||
if(num_projectors == 1 && projectors[0].uci==NULL)
|
||||
for(i = 0, co = coords; i < numVerts; ++i, ++co)
|
||||
if (num_projectors == 1 && projectors[0].uci==NULL)
|
||||
for (i = 0, co = coords; i < numVerts; ++i, ++co)
|
||||
mul_project_m4_v3(projectors[0].projmat, *co);
|
||||
|
||||
mpoly = dm->getPolyArray(dm);
|
||||
mloop = dm->getLoopArray(dm);
|
||||
|
||||
/* apply coords as UVs, and apply image if tfaces are new */
|
||||
for(i = 0, mp = mpoly; i < numPolys; ++i, ++mp, ++mt) {
|
||||
if(override_image || !image || (mtexpoly == NULL || mt->tpage == image)) {
|
||||
if(num_projectors == 1) {
|
||||
if(projectors[0].uci) {
|
||||
for (i = 0, mp = mpoly; i < numPolys; ++i, ++mp, ++mt) {
|
||||
if (override_image || !image || (mtexpoly == NULL || mt->tpage == image)) {
|
||||
if (num_projectors == 1) {
|
||||
if (projectors[0].uci) {
|
||||
unsigned int fidx= mp->totloop - 1;
|
||||
do {
|
||||
unsigned int lidx= mp->loopstart + fidx;
|
||||
@@ -314,7 +316,8 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
copy_v2_v2(mloop_uv[lidx].uv, coords[vidx]);
|
||||
} while (fidx--);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* multiple projectors, select the closest to face normal direction */
|
||||
float face_no[3];
|
||||
int j;
|
||||
@@ -330,16 +333,16 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
best_dot = dot_v3v3(projectors[0].normal, face_no);
|
||||
best_projector = &projectors[0];
|
||||
|
||||
for(j = 1; j < num_projectors; ++j) {
|
||||
for (j = 1; j < num_projectors; ++j) {
|
||||
float tmp_dot = dot_v3v3(projectors[j].normal,
|
||||
face_no);
|
||||
if(tmp_dot > best_dot) {
|
||||
if (tmp_dot > best_dot) {
|
||||
best_dot = tmp_dot;
|
||||
best_projector = &projectors[j];
|
||||
}
|
||||
}
|
||||
|
||||
if(best_projector->uci) {
|
||||
if (best_projector->uci) {
|
||||
unsigned int fidx= mp->totloop - 1;
|
||||
do {
|
||||
unsigned int lidx= mp->loopstart + fidx;
|
||||
@@ -363,17 +366,17 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
}
|
||||
}
|
||||
|
||||
if(override_image && mtexpoly) {
|
||||
if (override_image && mtexpoly) {
|
||||
mt->tpage = image;
|
||||
}
|
||||
}
|
||||
|
||||
MEM_freeN(coords);
|
||||
|
||||
if(free_uci) {
|
||||
if (free_uci) {
|
||||
int j;
|
||||
for(j = 0; j < num_projectors; ++j) {
|
||||
if(projectors[j].uci) {
|
||||
for (j = 0; j < num_projectors; ++j) {
|
||||
if (projectors[j].uci) {
|
||||
MEM_freeN(projectors[j].uci);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,11 +88,11 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
CustomDataMask dataMask = 0;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(wmd->defgrp_name[0]) dataMask |= (CD_MASK_MDEFORMVERT);
|
||||
if (wmd->defgrp_name[0]) dataMask |= (CD_MASK_MDEFORMVERT);
|
||||
dataMask |= (CD_MASK_MDEFORMVERT);
|
||||
|
||||
/* ask for UV coordinates if we need them */
|
||||
if(wmd->texmapping == MOD_DISP_MAP_UV) dataMask |= (1 << CD_MTFACE);
|
||||
if (wmd->texmapping == MOD_DISP_MAP_UV) dataMask |= (1 << CD_MTFACE);
|
||||
|
||||
return dataMask;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ static int dependsOnTime(ModifierData *md)
|
||||
{
|
||||
WarpModifierData *wmd = (WarpModifierData *)md;
|
||||
|
||||
if(wmd->texture) {
|
||||
if (wmd->texture) {
|
||||
return BKE_texture_dependsOnTime(wmd->texture);
|
||||
}
|
||||
else {
|
||||
@@ -153,7 +153,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UN
|
||||
{
|
||||
WarpModifierData *wmd = (WarpModifierData*) md;
|
||||
|
||||
if(wmd->object_from && wmd->object_to) {
|
||||
if (wmd->object_from && wmd->object_to) {
|
||||
DagNode *fromNode = dag_get_node(forest, wmd->object_from);
|
||||
DagNode *toNode = dag_get_node(forest, wmd->object_to);
|
||||
|
||||
@@ -161,7 +161,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UN
|
||||
dag_add_relation(forest, toNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Warp Modifier2");
|
||||
}
|
||||
|
||||
if((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object) {
|
||||
if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object) {
|
||||
DagNode *curNode = dag_get_node(forest, wmd->map_object);
|
||||
dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Warp Modifier3");
|
||||
}
|
||||
@@ -187,12 +187,12 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
|
||||
|
||||
float (*tex_co)[3]= NULL;
|
||||
|
||||
if(!(wmd->object_from && wmd->object_to))
|
||||
if (!(wmd->object_from && wmd->object_to))
|
||||
return;
|
||||
|
||||
modifier_get_vgroup(ob, dm, wmd->defgrp_name, &dvert, &defgrp_index);
|
||||
|
||||
if(wmd->curfalloff==NULL) /* should never happen, but bad lib linking could cause it */
|
||||
if (wmd->curfalloff==NULL) /* should never happen, but bad lib linking could cause it */
|
||||
wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
|
||||
invert_m4_m4(obinv, ob->obmat);
|
||||
@@ -207,7 +207,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
|
||||
|
||||
unit_m4(mat_unit);
|
||||
|
||||
if(strength < 0.0f) {
|
||||
if (strength < 0.0f) {
|
||||
float loc[3];
|
||||
strength = -strength;
|
||||
|
||||
@@ -219,24 +219,24 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
|
||||
}
|
||||
weight= strength;
|
||||
|
||||
if(wmd->texture) {
|
||||
if (wmd->texture) {
|
||||
tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts, "warpModifier_do tex_co");
|
||||
get_texture_coords((MappingInfoModifierData *)wmd, ob, dm, vertexCos, tex_co, numVerts);
|
||||
}
|
||||
|
||||
for(i = 0; i < numVerts; i++) {
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
float *co = vertexCos[i];
|
||||
|
||||
if(wmd->falloff_type==eWarp_Falloff_None ||
|
||||
if (wmd->falloff_type==eWarp_Falloff_None ||
|
||||
((fac=len_v3v3(co, mat_from[3])) < wmd->falloff_radius && (fac=(wmd->falloff_radius-fac)/wmd->falloff_radius)) ) {
|
||||
|
||||
/* skip if no vert group found */
|
||||
if(dvert && defgrp_index >= 0) {
|
||||
if (dvert && defgrp_index >= 0) {
|
||||
dv = &dvert[i];
|
||||
|
||||
if(dv) {
|
||||
if (dv) {
|
||||
weight = defvert_find_weight(dv, defgrp_index) * strength;
|
||||
if(weight <= 0.0f) /* Should never occure... */
|
||||
if (weight <= 0.0f) /* Should never occure... */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
|
||||
|
||||
fac *= weight;
|
||||
|
||||
if(tex_co) {
|
||||
if (tex_co) {
|
||||
TexResult texres;
|
||||
texres.nor = NULL;
|
||||
get_texture_value(wmd->texture, tex_co[i], &texres);
|
||||
@@ -282,11 +282,11 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
|
||||
/* into the 'from' objects space */
|
||||
mul_m4_v3(mat_from_inv, co);
|
||||
|
||||
if(fac >= 1.0f) {
|
||||
if (fac >= 1.0f) {
|
||||
mul_m4_v3(mat_final, co);
|
||||
}
|
||||
else if(fac > 0.0f) {
|
||||
if(wmd->flag & MOD_WARP_VOLUME_PRESERVE) {
|
||||
else if (fac > 0.0f) {
|
||||
if (wmd->flag & MOD_WARP_VOLUME_PRESERVE) {
|
||||
/* interpolate the matrix for nicer locations */
|
||||
blend_m4_m4m4(tmat, mat_unit, mat_final, fac);
|
||||
mul_m4_v3(tmat, co);
|
||||
@@ -303,7 +303,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob,
|
||||
}
|
||||
}
|
||||
|
||||
if(tex_co)
|
||||
if (tex_co)
|
||||
MEM_freeN(tex_co);
|
||||
|
||||
}
|
||||
@@ -319,14 +319,14 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
|
||||
DerivedMesh *dm= NULL;
|
||||
int use_dm= warp_needs_dm((WarpModifierData *)md);
|
||||
|
||||
if(use_dm) {
|
||||
if (use_dm) {
|
||||
dm= get_cddm(ob, NULL, derivedData, vertexCos);
|
||||
}
|
||||
|
||||
warpModifier_do((WarpModifierData *)md, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(use_dm) {
|
||||
if(dm != derivedData) dm->release(dm);
|
||||
if (use_dm) {
|
||||
if (dm != derivedData) dm->release(dm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,15 +336,15 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD
|
||||
DerivedMesh *dm = derivedData;
|
||||
int use_dm= warp_needs_dm((WarpModifierData *)md);
|
||||
|
||||
if(use_dm) {
|
||||
if(!derivedData)
|
||||
if (use_dm) {
|
||||
if (!derivedData)
|
||||
dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE);
|
||||
}
|
||||
|
||||
deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0);
|
||||
|
||||
if(use_dm) {
|
||||
if(!derivedData) dm->release(dm);
|
||||
if (use_dm) {
|
||||
if (!derivedData) dm->release(dm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,14 +138,14 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
|
||||
{
|
||||
WaveModifierData *wmd = (WaveModifierData*) md;
|
||||
|
||||
if(wmd->objectcenter) {
|
||||
if (wmd->objectcenter) {
|
||||
DagNode *curNode = dag_get_node(forest, wmd->objectcenter);
|
||||
|
||||
dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA,
|
||||
"Wave Modifier");
|
||||
}
|
||||
|
||||
if(wmd->map_object) {
|
||||
if (wmd->map_object) {
|
||||
DagNode *curNode = dag_get_node(forest, wmd->map_object);
|
||||
|
||||
dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA,
|
||||
@@ -160,11 +160,11 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
|
||||
|
||||
/* ask for UV coordinates if we need them */
|
||||
if(wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV)
|
||||
if (wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV)
|
||||
dataMask |= CD_MASK_MTFACE;
|
||||
|
||||
/* ask for vertexgroups if we need them */
|
||||
if(wmd->defgrp_name[0])
|
||||
if (wmd->defgrp_name[0])
|
||||
dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
return dataMask;
|
||||
@@ -187,10 +187,10 @@ static void waveModifier_do(WaveModifierData *md,
|
||||
const float falloff= wmd->falloff;
|
||||
float falloff_fac= 1.0f; /* when falloff == 0.0f this stays at 1.0f */
|
||||
|
||||
if(wmd->flag & MOD_WAVE_NORM && ob->type == OB_MESH)
|
||||
if (wmd->flag & MOD_WAVE_NORM && ob->type == OB_MESH)
|
||||
mvert = dm->getVertArray(dm);
|
||||
|
||||
if(wmd->objectcenter){
|
||||
if (wmd->objectcenter) {
|
||||
float mat[4][4];
|
||||
/* get the control object's location in local coordinates */
|
||||
invert_m4_m4(ob->imat, ob->obmat);
|
||||
@@ -203,32 +203,32 @@ static void waveModifier_do(WaveModifierData *md,
|
||||
/* get the index of the deform group */
|
||||
modifier_get_vgroup(ob, dm, wmd->defgrp_name, &dvert, &defgrp_index);
|
||||
|
||||
if(wmd->damp == 0) wmd->damp = 10.0f;
|
||||
if (wmd->damp == 0) wmd->damp = 10.0f;
|
||||
|
||||
if(wmd->lifetime != 0.0f) {
|
||||
if (wmd->lifetime != 0.0f) {
|
||||
float x = ctime - wmd->timeoffs;
|
||||
|
||||
if(x > wmd->lifetime) {
|
||||
if (x > wmd->lifetime) {
|
||||
lifefac = x - wmd->lifetime;
|
||||
|
||||
if(lifefac > wmd->damp) lifefac = 0.0;
|
||||
if (lifefac > wmd->damp) lifefac = 0.0;
|
||||
else lifefac =
|
||||
(float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp)));
|
||||
}
|
||||
}
|
||||
|
||||
if(wmd->texture) {
|
||||
if (wmd->texture) {
|
||||
tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts,
|
||||
"waveModifier_do tex_co");
|
||||
get_texture_coords((MappingInfoModifierData *)wmd, ob, dm, vertexCos, tex_co, numVerts);
|
||||
}
|
||||
|
||||
if(lifefac != 0.0f) {
|
||||
if (lifefac != 0.0f) {
|
||||
/* avoid divide by zero checks within the loop */
|
||||
float falloff_inv= falloff ? 1.0f / falloff : 1.0f;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < numVerts; i++) {
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
float *co = vertexCos[i];
|
||||
float x = co[0] - wmd->startx;
|
||||
float y = co[1] - wmd->starty;
|
||||
@@ -236,11 +236,11 @@ static void waveModifier_do(WaveModifierData *md,
|
||||
float def_weight= 1.0f;
|
||||
|
||||
/* get weights */
|
||||
if(dvert) {
|
||||
if (dvert) {
|
||||
def_weight= defvert_find_weight(&dvert[i], defgrp_index);
|
||||
|
||||
/* if this vert isn't in the vgroup, don't deform it */
|
||||
if(def_weight == 0.0f) {
|
||||
if (def_weight == 0.0f) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -260,12 +260,12 @@ static void waveModifier_do(WaveModifierData *md,
|
||||
/* this way it makes nice circles */
|
||||
amplit -= (ctime - wmd->timeoffs) * wmd->speed;
|
||||
|
||||
if(wmd->flag & MOD_WAVE_CYCL) {
|
||||
if (wmd->flag & MOD_WAVE_CYCL) {
|
||||
amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width)
|
||||
+ wmd->width;
|
||||
}
|
||||
|
||||
if(falloff != 0.0f) {
|
||||
if (falloff != 0.0f) {
|
||||
float dist = 0.0f;
|
||||
|
||||
switch(wmd_axis) {
|
||||
@@ -285,12 +285,12 @@ static void waveModifier_do(WaveModifierData *md,
|
||||
}
|
||||
|
||||
/* GAUSSIAN */
|
||||
if((falloff_fac != 0.0f) && (amplit > -wmd->width) && (amplit < wmd->width)) {
|
||||
if ((falloff_fac != 0.0f) && (amplit > -wmd->width) && (amplit < wmd->width)) {
|
||||
amplit = amplit * wmd->narrow;
|
||||
amplit = (float)(1.0f / expf(amplit * amplit) - minfac);
|
||||
|
||||
/*apply texture*/
|
||||
if(wmd->texture) {
|
||||
if (wmd->texture) {
|
||||
TexResult texres;
|
||||
texres.nor = NULL;
|
||||
get_texture_value(wmd->texture, tex_co[i], &texres);
|
||||
@@ -300,15 +300,15 @@ static void waveModifier_do(WaveModifierData *md,
|
||||
/*apply weight & falloff */
|
||||
amplit *= def_weight * falloff_fac;
|
||||
|
||||
if(mvert) {
|
||||
if (mvert) {
|
||||
/* move along normals */
|
||||
if(wmd->flag & MOD_WAVE_NORM_X) {
|
||||
if (wmd->flag & MOD_WAVE_NORM_X) {
|
||||
co[0] += (lifefac * amplit) * mvert[i].no[0] / 32767.0f;
|
||||
}
|
||||
if(wmd->flag & MOD_WAVE_NORM_Y) {
|
||||
if (wmd->flag & MOD_WAVE_NORM_Y) {
|
||||
co[1] += (lifefac * amplit) * mvert[i].no[1] / 32767.0f;
|
||||
}
|
||||
if(wmd->flag & MOD_WAVE_NORM_Z) {
|
||||
if (wmd->flag & MOD_WAVE_NORM_Z) {
|
||||
co[2] += (lifefac * amplit) * mvert[i].no[2] / 32767.0f;
|
||||
}
|
||||
}
|
||||
@@ -320,7 +320,7 @@ static void waveModifier_do(WaveModifierData *md,
|
||||
}
|
||||
}
|
||||
|
||||
if(wmd->texture) MEM_freeN(tex_co);
|
||||
if (wmd->texture) MEM_freeN(tex_co);
|
||||
}
|
||||
|
||||
static void deformVerts(ModifierData *md, Object *ob,
|
||||
@@ -333,14 +333,14 @@ static void deformVerts(ModifierData *md, Object *ob,
|
||||
DerivedMesh *dm= derivedData;
|
||||
WaveModifierData *wmd = (WaveModifierData *)md;
|
||||
|
||||
if(wmd->flag & MOD_WAVE_NORM)
|
||||
if (wmd->flag & MOD_WAVE_NORM)
|
||||
dm= get_cddm(ob, NULL, dm, vertexCos);
|
||||
else if(wmd->texture || wmd->defgrp_name[0])
|
||||
else if (wmd->texture || wmd->defgrp_name[0])
|
||||
dm= get_dm(ob, NULL, dm, NULL, 0);
|
||||
|
||||
waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
@@ -351,14 +351,14 @@ static void deformVertsEM(
|
||||
DerivedMesh *dm= derivedData;
|
||||
WaveModifierData *wmd = (WaveModifierData *)md;
|
||||
|
||||
if(wmd->flag & MOD_WAVE_NORM)
|
||||
if (wmd->flag & MOD_WAVE_NORM)
|
||||
dm= get_cddm(ob, editData, dm, vertexCos);
|
||||
else if(wmd->texture || wmd->defgrp_name[0])
|
||||
else if (wmd->texture || wmd->defgrp_name[0])
|
||||
dm= get_dm(ob, editData, dm, NULL, 0);
|
||||
|
||||
waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts);
|
||||
|
||||
if(dm != derivedData)
|
||||
if (dm != derivedData)
|
||||
dm->release(dm);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,14 +64,14 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm
|
||||
|
||||
/* Return immediately, if we have nothing to do! */
|
||||
/* Also security checks... */
|
||||
if(((falloff_type == MOD_WVG_MAPPING_CURVE) && (cmap == NULL))
|
||||
if (((falloff_type == MOD_WVG_MAPPING_CURVE) && (cmap == NULL))
|
||||
|| !ELEM7(falloff_type, MOD_WVG_MAPPING_CURVE, MOD_WVG_MAPPING_SHARP, MOD_WVG_MAPPING_SMOOTH,
|
||||
MOD_WVG_MAPPING_ROOT, MOD_WVG_MAPPING_SPHERE, MOD_WVG_MAPPING_RANDOM,
|
||||
MOD_WVG_MAPPING_STEP))
|
||||
return;
|
||||
|
||||
/* Map each weight (vertex) to its new value, accordingly to the chosen mode. */
|
||||
for(i = 0; i < num; ++i) {
|
||||
for (i = 0; i < num; ++i) {
|
||||
float fac = new_w[i];
|
||||
|
||||
/* Code borrowed from the warp modifier. */
|
||||
@@ -146,7 +146,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne
|
||||
MEM_freeN(v_co);
|
||||
|
||||
/* For each weight (vertex), make the mix between org and new weights. */
|
||||
for(i = 0; i < num; ++i) {
|
||||
for (i = 0; i < num; ++i) {
|
||||
int idx = indices ? indices[i] : i;
|
||||
TexResult texres;
|
||||
float h, s, v; /* For HSV color space. */
|
||||
@@ -237,7 +237,7 @@ void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, MDeformWeight **dws,
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < num; i++) {
|
||||
for (i = 0; i < num; i++) {
|
||||
float w = weights[i];
|
||||
MDeformVert *dv = &dvert[indices ? indices[i] : i];
|
||||
MDeformWeight *dw = dws ? dws[i] : defvert_find_index(dv, defgrp_idx);
|
||||
@@ -246,8 +246,8 @@ void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, MDeformWeight **dws,
|
||||
CLAMP(w, 0.0f, 1.0f);
|
||||
|
||||
/* If the vertex is in this vgroup, remove it if needed, or just update it. */
|
||||
if(dw != NULL) {
|
||||
if(do_rem && w < rem_thresh) {
|
||||
if (dw != NULL) {
|
||||
if (do_rem && w < rem_thresh) {
|
||||
defvert_remove_group(dv, dw);
|
||||
}
|
||||
else {
|
||||
@@ -255,7 +255,7 @@ void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, MDeformWeight **dws,
|
||||
}
|
||||
}
|
||||
/* Else, add it if needed! */
|
||||
else if(do_add && w > add_thresh) {
|
||||
else if (do_add && w > add_thresh) {
|
||||
defvert_add_index_notest(dv, defgrp_idx, w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
/* Ask for UV coordinates if we need them. */
|
||||
if(wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
|
||||
if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
|
||||
dataMask |= CD_MASK_MTFACE;
|
||||
|
||||
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
|
||||
@@ -123,7 +123,7 @@ static int dependsOnTime(ModifierData *md)
|
||||
{
|
||||
WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md;
|
||||
|
||||
if(wmd->mask_texture)
|
||||
if (wmd->mask_texture)
|
||||
return BKE_texture_dependsOnTime(wmd->mask_texture);
|
||||
return 0;
|
||||
}
|
||||
@@ -156,14 +156,14 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UN
|
||||
WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md;
|
||||
DagNode *curNode;
|
||||
|
||||
if(wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
if (wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
curNode = dag_get_node(forest, wmd->mask_tex_map_obj);
|
||||
|
||||
dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA,
|
||||
"WeightVGEdit Modifier");
|
||||
}
|
||||
|
||||
if(wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL)
|
||||
if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL)
|
||||
dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA,
|
||||
"WeightVGEdit Modifier");
|
||||
}
|
||||
@@ -211,15 +211,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
|
||||
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
|
||||
/* If no vertices were ever added to an object's vgroup, dvert might be NULL. */
|
||||
if(!dvert)
|
||||
if (!dvert)
|
||||
/* If this modifier is not allowed to add vertices, just return. */
|
||||
if(!do_add)
|
||||
if (!do_add)
|
||||
return dm;
|
||||
/* Else, add a valid data layer! */
|
||||
dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC,
|
||||
NULL, numVerts, wmd->defgrp_name);
|
||||
/* Ultimate security check. */
|
||||
if(!dvert)
|
||||
if (!dvert)
|
||||
return dm;
|
||||
|
||||
/* Get org weights, assuming 0.0 for vertices not in given vgroup. */
|
||||
@@ -228,7 +228,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
dw = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGEdit Modifier, dw");
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
dw[i] = defvert_find_index(&dvert[i], defgrp_idx);
|
||||
if(dw[i]) {
|
||||
if (dw[i]) {
|
||||
org_w[i] = new_w[i] = dw[i]->weight;
|
||||
}
|
||||
else {
|
||||
@@ -252,7 +252,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
|
||||
/* If weight preview enabled... */
|
||||
#if 0 /* XXX Currently done in mod stack :/ */
|
||||
if(do_prev)
|
||||
if (do_prev)
|
||||
DM_update_weight_mcol(ob, dm, 0, org_w, 0, NULL);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
/* Ask for UV coordinates if we need them. */
|
||||
if(wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
|
||||
if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
|
||||
dataMask |= CD_MASK_MTFACE;
|
||||
|
||||
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
|
||||
@@ -165,7 +165,7 @@ static int dependsOnTime(ModifierData *md)
|
||||
{
|
||||
WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md;
|
||||
|
||||
if(wmd->mask_texture)
|
||||
if (wmd->mask_texture)
|
||||
return BKE_texture_dependsOnTime(wmd->mask_texture);
|
||||
return 0;
|
||||
}
|
||||
@@ -198,14 +198,14 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UN
|
||||
WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md;
|
||||
DagNode *curNode;
|
||||
|
||||
if(wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
if (wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
curNode = dag_get_node(forest, wmd->mask_tex_map_obj);
|
||||
|
||||
dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA,
|
||||
"WeightVGMix Modifier");
|
||||
}
|
||||
|
||||
if(wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL)
|
||||
if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL)
|
||||
dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA,
|
||||
"WeightVGMix Modifier");
|
||||
}
|
||||
@@ -258,15 +258,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
|
||||
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
|
||||
/* If no vertices were ever added to an object's vgroup, dvert might be NULL. */
|
||||
if(!dvert)
|
||||
if (!dvert)
|
||||
/* If not affecting all vertices, just return. */
|
||||
if(wmd->mix_set != MOD_WVG_SET_ALL)
|
||||
if (wmd->mix_set != MOD_WVG_SET_ALL)
|
||||
return dm;
|
||||
/* Else, add a valid data layer! */
|
||||
dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC,
|
||||
NULL, numVerts, wmd->defgrp_name_a);
|
||||
/* Ultimate security check. */
|
||||
if(!dvert)
|
||||
if (!dvert)
|
||||
return dm;
|
||||
|
||||
/* Find out which vertices to work on. */
|
||||
@@ -278,7 +278,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
/* All vertices in first vgroup. */
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx);
|
||||
if(dw) {
|
||||
if (dw) {
|
||||
tdw1[numIdx] = dw;
|
||||
tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_idx2);
|
||||
tidx[numIdx++] = i;
|
||||
@@ -289,7 +289,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
/* All vertices in second vgroup. */
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx2);
|
||||
if(dw) {
|
||||
if (dw) {
|
||||
tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_idx);
|
||||
tdw2[numIdx] = dw;
|
||||
tidx[numIdx++] = i;
|
||||
@@ -301,7 +301,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx);
|
||||
MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2);
|
||||
if(adw || bdw) {
|
||||
if (adw || bdw) {
|
||||
tdw1[numIdx] = adw;
|
||||
tdw2[numIdx] = bdw;
|
||||
tidx[numIdx++] = i;
|
||||
@@ -313,7 +313,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx);
|
||||
MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2);
|
||||
if(adw && bdw) {
|
||||
if (adw && bdw) {
|
||||
tdw1[numIdx] = adw;
|
||||
tdw2[numIdx] = bdw;
|
||||
tidx[numIdx++] = i;
|
||||
@@ -330,7 +330,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
numIdx = -1;
|
||||
break;
|
||||
}
|
||||
if(numIdx == 0) {
|
||||
if (numIdx == 0) {
|
||||
/* Use no vertices! Hence, return org data. */
|
||||
MEM_freeN(tdw1);
|
||||
MEM_freeN(tdw2);
|
||||
@@ -380,7 +380,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
|
||||
/* If weight preview enabled... */
|
||||
#if 0 /* XXX Currently done in mod stack :/ */
|
||||
if(do_prev)
|
||||
if (do_prev)
|
||||
DM_update_weight_mcol(ob, dm, 0, org_w, numIdx, indices);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3],
|
||||
if (dist_v) {
|
||||
/* Create a bvh-tree of the given target's verts. */
|
||||
bvhtree_from_mesh_verts(&treeData_v, target, 0.0, 2, 6);
|
||||
if(treeData_v.tree == NULL) {
|
||||
if (treeData_v.tree == NULL) {
|
||||
OUT_OF_MEMORY();
|
||||
return;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3],
|
||||
if (dist_e) {
|
||||
/* Create a bvh-tree of the given target's edges. */
|
||||
bvhtree_from_mesh_edges(&treeData_e, target, 0.0, 2, 6);
|
||||
if(treeData_e.tree == NULL) {
|
||||
if (treeData_e.tree == NULL) {
|
||||
OUT_OF_MEMORY();
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3],
|
||||
if (dist_f) {
|
||||
/* Create a bvh-tree of the given target's faces. */
|
||||
bvhtree_from_mesh_faces(&treeData_f, target, 0.0, 2, 6);
|
||||
if(treeData_f.tree == NULL) {
|
||||
if (treeData_f.tree == NULL) {
|
||||
OUT_OF_MEMORY();
|
||||
return;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ static void get_vert2ob_distance(int numVerts, float (*v_cos)[3], float *dist,
|
||||
float v_wco[3];
|
||||
unsigned int i= numVerts;
|
||||
|
||||
while(i-- > 0) {
|
||||
while (i-- > 0) {
|
||||
/* Get world-coordinates of the vertex (constraints and anim included). */
|
||||
mul_v3_m4v3(v_wco, ob->obmat, v_cos[i]);
|
||||
/* Return distance between both coordinates. */
|
||||
@@ -189,27 +189,27 @@ void do_map(float *weights, const int nidx, const float min_d, const float max_d
|
||||
{
|
||||
const float range_inv= 1.0f / (max_d - min_d); /* invert since multiplication is faster */
|
||||
unsigned int i= nidx;
|
||||
if(max_d == min_d) {
|
||||
if (max_d == min_d) {
|
||||
while (i-- > 0) {
|
||||
weights[i] = (weights[i] >= max_d) ? 1.0f : 0.0f; /* "Step" behavior... */
|
||||
}
|
||||
}
|
||||
else if(max_d > min_d) {
|
||||
else if (max_d > min_d) {
|
||||
while (i-- > 0) {
|
||||
if (weights[i] >= max_d) weights[i]= 1.0f; /* most likely case first */
|
||||
else if(weights[i] <= min_d) weights[i]= 0.0f;
|
||||
else if (weights[i] <= min_d) weights[i]= 0.0f;
|
||||
else weights[i]= (weights[i] - min_d) * range_inv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (i-- > 0) {
|
||||
if (weights[i] <= max_d) weights[i]= 1.0f; /* most likely case first */
|
||||
else if(weights[i] >= min_d) weights[i]= 0.0f;
|
||||
else if (weights[i] >= min_d) weights[i]= 0.0f;
|
||||
else weights[i]= (weights[i] - min_d) * range_inv;
|
||||
}
|
||||
}
|
||||
|
||||
if(!ELEM(mode, MOD_WVG_MAPPING_NONE, MOD_WVG_MAPPING_CURVE)) {
|
||||
if (!ELEM(mode, MOD_WVG_MAPPING_NONE, MOD_WVG_MAPPING_CURVE)) {
|
||||
weightvg_do_map(nidx, weights, mode, NULL);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
||||
dataMask |= CD_MASK_MDEFORMVERT;
|
||||
|
||||
/* Ask for UV coordinates if we need them. */
|
||||
if(wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
|
||||
if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
|
||||
dataMask |= CD_MASK_MTFACE;
|
||||
|
||||
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
|
||||
@@ -276,7 +276,7 @@ static int dependsOnTime(ModifierData *md)
|
||||
{
|
||||
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md;
|
||||
|
||||
if(wmd->mask_texture)
|
||||
if (wmd->mask_texture)
|
||||
return BKE_texture_dependsOnTime(wmd->mask_texture);
|
||||
return 0;
|
||||
}
|
||||
@@ -316,14 +316,14 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UN
|
||||
"WeightVGProximity Modifier");
|
||||
}
|
||||
|
||||
if(wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
if (wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
curNode = dag_get_node(forest, wmd->mask_tex_map_obj);
|
||||
|
||||
dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA,
|
||||
"WeightVGProximity Modifier");
|
||||
}
|
||||
|
||||
if(wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL)
|
||||
if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL)
|
||||
dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA,
|
||||
"WeightVGProximity Modifier");
|
||||
}
|
||||
@@ -385,7 +385,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts);
|
||||
/* If no vertices were ever added to an object's vgroup, dvert might be NULL.
|
||||
* As this modifier never add vertices to vgroup, just return. */
|
||||
if(!dvert)
|
||||
if (!dvert)
|
||||
return dm;
|
||||
|
||||
/* Find out which vertices to work on (all vertices in vgroup), and get their relevant weight.
|
||||
@@ -395,20 +395,20 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
tdw = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGProximity Modifier, tdw");
|
||||
for (i = 0; i < numVerts; i++) {
|
||||
MDeformWeight *_dw = defvert_find_index(&dvert[i], defgrp_idx);
|
||||
if(_dw) {
|
||||
if (_dw) {
|
||||
tidx[numIdx] = i;
|
||||
tw[numIdx] = _dw->weight;
|
||||
tdw[numIdx++] = _dw;
|
||||
}
|
||||
}
|
||||
/* If no vertices found, return org data! */
|
||||
if(numIdx == 0) {
|
||||
if (numIdx == 0) {
|
||||
MEM_freeN(tidx);
|
||||
MEM_freeN(tw);
|
||||
MEM_freeN(tdw);
|
||||
return dm;
|
||||
}
|
||||
if(numIdx != numVerts) {
|
||||
if (numIdx != numVerts) {
|
||||
indices = MEM_mallocN(sizeof(int) * numIdx, "WeightVGProximity Modifier, indices");
|
||||
memcpy(indices, tidx, sizeof(int) * numIdx);
|
||||
org_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, org_w");
|
||||
@@ -427,7 +427,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
|
||||
/* Get our vertex coordinates. */
|
||||
v_cos = MEM_mallocN(sizeof(float[3]) * numIdx, "WeightVGProximity Modifier, v_cos");
|
||||
if(numIdx != numVerts) {
|
||||
if (numIdx != numVerts) {
|
||||
/* XXX In some situations, this code can be up to about 50 times more performant
|
||||
* than simply using getVertCo for each affected vertex...
|
||||
*/
|
||||
@@ -443,7 +443,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
/* Compute wanted distances. */
|
||||
if (wmd->proximity_mode == MOD_WVG_PROXIMITY_OBJECT) {
|
||||
const float dist = get_ob2ob_distance(ob, obr);
|
||||
for(i = 0; i < numIdx; i++)
|
||||
for (i = 0; i < numIdx; i++)
|
||||
new_w[i] = dist;
|
||||
}
|
||||
else if (wmd->proximity_mode == MOD_WVG_PROXIMITY_GEOMETRY) {
|
||||
@@ -477,17 +477,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
space_transform_setup(&loc2trgt, ob, obr);
|
||||
get_vert2geom_distance(numIdx, v_cos, dists_v, dists_e, dists_f,
|
||||
target_dm, &loc2trgt);
|
||||
for(i = 0; i < numIdx; i++) {
|
||||
for (i = 0; i < numIdx; i++) {
|
||||
new_w[i] = dists_v ? dists_v[i] : FLT_MAX;
|
||||
if(dists_e)
|
||||
if (dists_e)
|
||||
new_w[i] = minf(dists_e[i], new_w[i]);
|
||||
if(dists_f)
|
||||
if (dists_f)
|
||||
new_w[i] = minf(dists_f[i], new_w[i]);
|
||||
}
|
||||
if(free_target_dm) target_dm->release(target_dm);
|
||||
if(dists_v) MEM_freeN(dists_v);
|
||||
if(dists_e) MEM_freeN(dists_e);
|
||||
if(dists_f) MEM_freeN(dists_f);
|
||||
if (free_target_dm) target_dm->release(target_dm);
|
||||
if (dists_v) MEM_freeN(dists_v);
|
||||
if (dists_e) MEM_freeN(dists_e);
|
||||
if (dists_f) MEM_freeN(dists_f);
|
||||
}
|
||||
/* Else, fall back to default obj2vert behavior. */
|
||||
else {
|
||||
@@ -512,7 +512,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
|
||||
/* If weight preview enabled... */
|
||||
#if 0 /* XXX Currently done in mod stack :/ */
|
||||
if(do_prev)
|
||||
if (do_prev)
|
||||
DM_update_weight_mcol(ob, dm, 0, org_w, numIdx, indices);
|
||||
#endif
|
||||
|
||||
@@ -520,7 +520,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
|
||||
MEM_freeN(org_w);
|
||||
MEM_freeN(new_w);
|
||||
MEM_freeN(dw);
|
||||
if(indices)
|
||||
if (indices)
|
||||
MEM_freeN(indices);
|
||||
MEM_freeN(v_cos);
|
||||
|
||||
|
||||
@@ -707,7 +707,7 @@ char *PyC_FlagSet_AsString(PyC_FlagSet *item)
|
||||
|
||||
int PyC_FlagSet_ValueFromID_int(PyC_FlagSet *item, const char *identifier, int *value)
|
||||
{
|
||||
for( ; item->identifier; item++) {
|
||||
for ( ; item->identifier; item++) {
|
||||
if (strcmp(item->identifier, identifier) == 0) {
|
||||
*value = item->value;
|
||||
return 1;
|
||||
|
||||
@@ -6086,7 +6086,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
|
||||
}
|
||||
|
||||
/* always use O not N when calling, N causes refcount errors */
|
||||
newclass = PyObject_CallFunction(metaclass, (char *)"s(O){sss()}",
|
||||
newclass = PyObject_CallFunction(metaclass, (char *)"s(O) {sss()}",
|
||||
idname, py_base, "__module__","bpy.types", "__slots__");
|
||||
|
||||
/* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */
|
||||
|
||||
@@ -485,7 +485,8 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
|
||||
qtexport->audioFile = NULL;
|
||||
[qtexport->audioFileName release];
|
||||
qtexport->audioFileName = nil;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
UInt32 prop,propSize;
|
||||
/* Set up codec properties */
|
||||
if (rd->qtcodecsettings.audiocodecType == kAudioFormatMPEG4AAC) { /*Lossy compressed format*/
|
||||
@@ -535,7 +536,8 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
|
||||
qtexport->movie = [[QTMovie alloc] initToWritableFile:qtexport->videoTempFileName error:&error];
|
||||
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
qtexport->movie = [[QTMovie alloc] initToWritableFile:qtexport->filename error:&error];
|
||||
|
||||
if(qtexport->movie == nil) {
|
||||
@@ -548,7 +550,8 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
|
||||
if (qtexport->videoTempFileName) [qtexport->videoTempFileName release];
|
||||
qtexport->videoTempFileName = nil;
|
||||
[QTMovie exitQTKitOnThread];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
[qtexport->movie retain];
|
||||
[qtexport->movie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieEditableAttribute];
|
||||
[qtexport->movie setAttribute:@"Made with Blender" forKey:QTMovieCopyrightAttribute];
|
||||
@@ -661,7 +664,8 @@ int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, in
|
||||
if (qtexport->audioOutputFormat.mFramesPerPacket) {
|
||||
// this is the common case: format has constant frames per packet
|
||||
qtexport->audioTotalSavedFrames += (audioPacketsConverted * qtexport->audioOutputFormat.mFramesPerPacket);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
unsigned int i;
|
||||
// if there are variable frames per packet, then we have to do this for each packeet
|
||||
for (i = 0; i < audioPacketsConverted; ++i)
|
||||
|
||||
@@ -187,7 +187,7 @@ int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue)
|
||||
|
||||
static void CheckError(OSErr err, char *msg, ReportList *reports)
|
||||
{
|
||||
if(err != noErr) {
|
||||
if (err != noErr) {
|
||||
BKE_reportf(reports, RPT_ERROR, "%s: %d", msg, err);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,8 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports)
|
||||
// check if current scene already has qtcodec settings, and clear them
|
||||
if (qcd) {
|
||||
free_qtcodecdata(qcd);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qcd = rd->qtcodecdata = MEM_callocN(sizeof(QuicktimeCodecData), "QuicktimeCodecData");
|
||||
}
|
||||
|
||||
@@ -237,7 +238,8 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports)
|
||||
qcd->cdSize = mySize;
|
||||
|
||||
GetCodecInfo (&ci, qtdata->gSpatialSettings.codecType, 0);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BKE_reportf(reports, RPT_ERROR, "Quicktime: QT_SaveCodecSettingsToScene failed\n");
|
||||
}
|
||||
|
||||
@@ -265,7 +267,7 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports)
|
||||
}
|
||||
|
||||
// restore codecsettings to the quicktime component
|
||||
if(qcd->cdParms && qcd->cdSize) {
|
||||
if (qcd->cdParms && qcd->cdSize) {
|
||||
myErr = SCSetSettingsFromAtomContainer((GraphicsExportComponent)qtdata->theComponent, (QTAtomContainer)myHandle);
|
||||
if (myErr != noErr) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed\n");
|
||||
@@ -293,7 +295,8 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports)
|
||||
rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality;
|
||||
//Frame duration is already known (qtdata->aDataRateSetting.frameDuration)
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BKE_reportf(reports, RPT_ERROR, "Quicktime: QT_GetCodecSettingsFromScene failed\n");
|
||||
}
|
||||
bail:
|
||||
@@ -411,8 +414,8 @@ static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, i
|
||||
// the new callback based api for proper encoding, but that's not
|
||||
// really compatible with rendering out frames sequentially
|
||||
gTemporalSettings = qtdata->gTemporalSettings;
|
||||
if(qtdata->gSpatialSettings.codecType == kH264CodecType) {
|
||||
if(gTemporalSettings.temporalQuality != codecMinQuality) {
|
||||
if (qtdata->gSpatialSettings.codecType == kH264CodecType) {
|
||||
if (gTemporalSettings.temporalQuality != codecMinQuality) {
|
||||
BKE_reportf(reports, RPT_WARNING, "Only minimum quality compression supported for QuickTime H.264.\n");
|
||||
gTemporalSettings.temporalQuality = codecMinQuality;
|
||||
}
|
||||
@@ -455,7 +458,7 @@ static void QT_DoAddVideoSamplesToMedia (int frame, int *pixels, int rectx, int
|
||||
|
||||
//parse RGBA bitmap into Quicktime's ARGB GWorld
|
||||
boxsize = rectx * recty;
|
||||
for( index = 0; index < boxsize; index++) {
|
||||
for ( index = 0; index < boxsize; index++) {
|
||||
to[0] = from[3];
|
||||
to[1] = from[0];
|
||||
to[2] = from[1];
|
||||
@@ -533,18 +536,19 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
|
||||
#endif
|
||||
int success= 1;
|
||||
|
||||
if(qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
|
||||
if (qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport");
|
||||
|
||||
if(qtdata) {
|
||||
if(qtdata->theComponent) CloseComponent(qtdata->theComponent);
|
||||
if (qtdata) {
|
||||
if (qtdata->theComponent) CloseComponent(qtdata->theComponent);
|
||||
free_qtcomponentdata();
|
||||
}
|
||||
|
||||
qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeCodecDataExt");
|
||||
|
||||
if(rd->qtcodecdata == NULL || rd->qtcodecdata->cdParms == NULL) {
|
||||
if (rd->qtcodecdata == NULL || rd->qtcodecdata->cdParms == NULL) {
|
||||
get_qtcodec_settings(rd, reports);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
|
||||
|
||||
QT_GetCodecSettingsFromScene(rd, reports);
|
||||
@@ -589,13 +593,14 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R
|
||||
&qtexport->theMovie );
|
||||
CheckError(err, "CreateMovieFile error", reports);
|
||||
|
||||
if(err != noErr) {
|
||||
if (err != noErr) {
|
||||
BKE_reportf(reports, RPT_ERROR, "Unable to create Quicktime movie: %s", name);
|
||||
success= 0;
|
||||
#ifdef __APPLE__
|
||||
ExitMoviesOnThread();
|
||||
#endif
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
//printf("Created QuickTime movie: %s\n", name);
|
||||
|
||||
QT_CreateMyVideoTrack(rectx, recty, reports);
|
||||
@@ -617,7 +622,7 @@ void end_qt(void)
|
||||
OSErr err = noErr;
|
||||
short resId = movieInDataForkResID;
|
||||
|
||||
if(qtexport->theMovie) {
|
||||
if (qtexport->theMovie) {
|
||||
QT_EndCreateMyVideoTrack(NULL);
|
||||
|
||||
err = AddMovieResource (qtexport->theMovie, qtexport->resRefNum, &resId, qtexport->qtfilename);
|
||||
@@ -629,7 +634,7 @@ void end_qt(void)
|
||||
err = UpdateMovieResource(qtexport->theMovie, qtexport->resRefNum, resId, qtexport->qtfilename);
|
||||
CheckError(err, "UpdateMovieResource error", NULL);
|
||||
|
||||
if(qtexport->resRefNum) CloseMovieFile(qtexport->resRefNum);
|
||||
if (qtexport->resRefNum) CloseMovieFile(qtexport->resRefNum);
|
||||
|
||||
DisposeMovie(qtexport->theMovie);
|
||||
|
||||
@@ -640,7 +645,7 @@ void end_qt(void)
|
||||
ExitMoviesOnThread();
|
||||
#endif
|
||||
|
||||
if(qtexport) {
|
||||
if (qtexport) {
|
||||
MEM_freeN(qtexport);
|
||||
qtexport = NULL;
|
||||
}
|
||||
@@ -649,8 +654,8 @@ void end_qt(void)
|
||||
|
||||
void free_qtcomponentdata(void)
|
||||
{
|
||||
if(qtdata) {
|
||||
if(qtdata->theComponent) CloseComponent(qtdata->theComponent);
|
||||
if (qtdata) {
|
||||
if (qtdata->theComponent) CloseComponent(qtdata->theComponent);
|
||||
MEM_freeN(qtdata);
|
||||
qtdata = NULL;
|
||||
}
|
||||
@@ -665,7 +670,7 @@ static void check_renderbutton_framerate(RenderData *rd, ReportList *reports)
|
||||
err = SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
|
||||
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 == 1964113 ||
|
||||
qtdata->gTemporalSettings.frameRate == 3928227))
|
||||
@@ -681,16 +686,19 @@ static void check_renderbutton_framerate(RenderData *rd, ReportList *reports)
|
||||
err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
|
||||
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->duration = 1001;
|
||||
} else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps
|
||||
}
|
||||
else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps
|
||||
qtdata->kVideoTimeScale = 30000;
|
||||
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->duration = 1001;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
qtdata->kVideoTimeScale = (qtdata->gTemporalSettings.frameRate >> 16) * 100;
|
||||
qtdata->duration = 100;
|
||||
}
|
||||
@@ -717,8 +725,8 @@ int get_qtcodec_settings(RenderData *rd, ReportList *reports)
|
||||
{
|
||||
OSErr err = noErr;
|
||||
// erase any existing codecsetting
|
||||
if(qtdata) {
|
||||
if(qtdata->theComponent) CloseComponent(qtdata->theComponent);
|
||||
if (qtdata) {
|
||||
if (qtdata->theComponent) CloseComponent(qtdata->theComponent);
|
||||
free_qtcomponentdata();
|
||||
}
|
||||
|
||||
@@ -727,9 +735,10 @@ int get_qtcodec_settings(RenderData *rd, ReportList *reports)
|
||||
qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
|
||||
|
||||
// get previous selected codecsetting, from qtatom or detailed settings
|
||||
if(rd->qtcodecdata && rd->qtcodecdata->cdParms) {
|
||||
if (rd->qtcodecdata && rd->qtcodecdata->cdParms) {
|
||||
QT_GetCodecSettingsFromScene(rd, reports);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
|
||||
SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
|
||||
SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
|
||||
@@ -768,8 +777,8 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
|
||||
RenderData *rd = &scene->r;
|
||||
|
||||
// erase any existing codecsetting
|
||||
if(qtdata) {
|
||||
if(qtdata->theComponent) CloseComponent(qtdata->theComponent);
|
||||
if (qtdata) {
|
||||
if (qtdata->theComponent) CloseComponent(qtdata->theComponent);
|
||||
free_qtcomponentdata();
|
||||
}
|
||||
|
||||
@@ -778,9 +787,10 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
|
||||
qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
|
||||
|
||||
// get previous selected codecsetting, from qtatom or detailed settings
|
||||
if(rd->qtcodecdata && rd->qtcodecdata->cdParms) {
|
||||
if (rd->qtcodecdata && rd->qtcodecdata->cdParms) {
|
||||
QT_GetCodecSettingsFromScene(rd, op->reports);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting);
|
||||
SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings);
|
||||
SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings);
|
||||
@@ -836,25 +846,28 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
|
||||
QT_SaveCodecSettingsToScene(rd, op->reports);
|
||||
|
||||
// framerate jugglin'
|
||||
if(qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps
|
||||
if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps
|
||||
qtdata->kVideoTimeScale = 24000;
|
||||
qtdata->duration = 1001;
|
||||
|
||||
rd->frs_sec = 24;
|
||||
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->duration = 1001;
|
||||
|
||||
rd->frs_sec = 30;
|
||||
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->duration = 1001;
|
||||
|
||||
rd->frs_sec = 60;
|
||||
rd->frs_sec_base = 1.001;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
double fps = qtdata->gTemporalSettings.frameRate;
|
||||
|
||||
qtdata->kVideoTimeScale = 60000;
|
||||
@@ -863,7 +876,8 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
|
||||
if ((qtdata->gTemporalSettings.frameRate & 0xffff) == 0) {
|
||||
rd->frs_sec = fps / 65536;
|
||||
rd->frs_sec_base = 1.0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* we do our very best... */
|
||||
rd->frs_sec = fps / 65536;
|
||||
rd->frs_sec_base = 1.0;
|
||||
|
||||
@@ -125,7 +125,7 @@ void quicktime_exit(void)
|
||||
{
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
#ifdef WITH_QUICKTIME
|
||||
if(G.have_quicktime) {
|
||||
if (G.have_quicktime) {
|
||||
free_qtcomponentdata();
|
||||
ExitMovies();
|
||||
#ifdef _WIN32
|
||||
@@ -147,22 +147,24 @@ char *get_valid_qtname(char *name)
|
||||
|
||||
dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
|
||||
|
||||
if(name[1] != ':') {
|
||||
if (name[1] != ':') {
|
||||
char drive[2];
|
||||
|
||||
if(name[0] == '/' || name[0] == '\\') {
|
||||
if (name[0] == '/' || name[0] == '\\') {
|
||||
drive[0] = Buffer[0];
|
||||
drive[1] = '\0';
|
||||
|
||||
BLI_dynstr_append(ds, drive);
|
||||
BLI_dynstr_append(ds, ":");
|
||||
BLI_dynstr_append(ds, name);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BLI_dynstr_append(ds, Buffer);
|
||||
BLI_dynstr_append(ds, "/");
|
||||
BLI_dynstr_append(ds, name);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
BLI_dynstr_append(ds, name);
|
||||
}
|
||||
|
||||
@@ -192,7 +194,7 @@ int anim_is_quicktime (const char *name)
|
||||
OSErr err = noErr;
|
||||
|
||||
// don't let quicktime movie import handle these
|
||||
if( BLI_testextensie(name, ".swf") ||
|
||||
if ( BLI_testextensie(name, ".swf") ||
|
||||
BLI_testextensie(name, ".txt") ||
|
||||
BLI_testextensie(name, ".mpg") ||
|
||||
BLI_testextensie(name, ".avi") || // wouldnt be appropriate ;)
|
||||
@@ -204,7 +206,7 @@ int anim_is_quicktime (const char *name)
|
||||
BLI_testextensie(name, ".zip") ||
|
||||
BLI_testextensie(name, ".mp3")) return 0;
|
||||
|
||||
if(QTIME_DEBUG) printf("qt: checking as movie: %s\n", name);
|
||||
if (QTIME_DEBUG) printf("qt: checking as movie: %s\n", name);
|
||||
|
||||
#ifdef __APPLE__
|
||||
sprintf(theFullPath, "%s", name);
|
||||
@@ -257,16 +259,16 @@ void free_anim_quicktime (struct anim *anim)
|
||||
|
||||
UnlockPixels(anim->qtime->offscreenPixMap);
|
||||
|
||||
if(anim->qtime->have_gw)
|
||||
if (anim->qtime->have_gw)
|
||||
DisposeGWorld( anim->qtime->offscreenGWorld );
|
||||
if(anim->qtime->ibuf)
|
||||
if (anim->qtime->ibuf)
|
||||
IMB_freeImBuf(anim->qtime->ibuf);
|
||||
|
||||
DisposeMovie( anim->qtime->movie );
|
||||
CloseMovieFile( anim->qtime->movieRefNum );
|
||||
|
||||
if(anim->qtime->frameIndex) MEM_freeN (anim->qtime->frameIndex);
|
||||
if(anim->qtime) MEM_freeN (anim->qtime);
|
||||
if (anim->qtime->frameIndex) MEM_freeN (anim->qtime->frameIndex);
|
||||
if (anim->qtime) MEM_freeN (anim->qtime);
|
||||
|
||||
anim->qtime = NULL;
|
||||
|
||||
@@ -305,7 +307,7 @@ static OSErr QT_get_frameIndexes(struct anim *anim)
|
||||
GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample, 1, &media, (TimeValue)1, 0, &tmpstartPoint, NULL);
|
||||
|
||||
anim->qtime->frameIndex[0] = startPoint;
|
||||
for(i = 1; i < anim->qtime->framecount; i++) {
|
||||
for (i = 1; i < anim->qtime->framecount; i++) {
|
||||
nextTime = 0;
|
||||
GetMovieNextInterestingTime(anim->qtime->movie, nextTimeMediaSample, 1, &media, startPoint, 0, &nextTime, NULL);
|
||||
startPoint = nextTime;
|
||||
@@ -367,7 +369,7 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
|
||||
from= (unsigned char *)readPos;
|
||||
to= (unsigned char *)changePos;
|
||||
|
||||
for( index = 0; index < boxsize; index++, from+=4, to+=4 ) {
|
||||
for ( index = 0; index < boxsize; index++, from+=4, to+=4 ) {
|
||||
to[3] = from[0];
|
||||
to[0] = from[1];
|
||||
to[1] = from[2];
|
||||
@@ -376,14 +378,14 @@ ImBuf * qtime_fetchibuf (struct anim *anim, int position)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
for( index = 0; index < boxsize; index++, changePos++, readPos++ )
|
||||
for ( index = 0; index < boxsize; index++, changePos++, readPos++ )
|
||||
*( changePos ) = *(readPos );
|
||||
|
||||
if(anim->qtime->depth < 32) {
|
||||
if (anim->qtime->depth < 32) {
|
||||
//add alpha to ibuf
|
||||
boxsize = anim->x * anim->y * 4;
|
||||
crect = (unsigned char *) rect;
|
||||
for( index = 0; index < boxsize; index+=4, crect+=4 ) {
|
||||
for ( index = 0; index < boxsize; index+=4, crect+=4 ) {
|
||||
crect[3] = 0xFF;
|
||||
}
|
||||
}
|
||||
@@ -425,7 +427,7 @@ static short GetFirstVideoTrackPixelDepth(struct anim *anim)
|
||||
SampleDescriptionHandle imageDescH = (SampleDescriptionHandle)NewHandle(sizeof(Handle));
|
||||
// long trackIndex = 0; /*unused*/
|
||||
|
||||
if(!GetFirstVideoMedia(anim))
|
||||
if (!GetFirstVideoMedia(anim))
|
||||
return -1;
|
||||
|
||||
if (!anim->qtime->trackIndex || !anim->qtime->theMedia) return -1; // we need both
|
||||
@@ -453,11 +455,11 @@ int startquicktime (struct anim *anim)
|
||||
anim->qtime->have_gw = FALSE;
|
||||
|
||||
if (anim->qtime == NULL) {
|
||||
if(QTIME_DEBUG) printf("Can't alloc qtime: %s\n", anim->name);
|
||||
if (QTIME_DEBUG) printf("Can't alloc qtime: %s\n", anim->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(QTIME_DEBUG) printf("qt: attempting to load as movie %s\n", anim->name);
|
||||
if (QTIME_DEBUG) printf("qt: attempting to load as movie %s\n", anim->name);
|
||||
|
||||
#ifdef __APPLE__
|
||||
sprintf(theFullPath, "%s", anim->name);
|
||||
@@ -476,18 +478,18 @@ int startquicktime (struct anim *anim)
|
||||
err = OpenMovieFile(&theFSSpec, &anim->qtime->movieRefNum, fsRdPerm);
|
||||
|
||||
if (err == noErr) {
|
||||
if(QTIME_DEBUG) printf("qt: movie opened\n");
|
||||
if (QTIME_DEBUG) printf("qt: movie opened\n");
|
||||
err = NewMovieFromFile(&anim->qtime->movie,
|
||||
anim->qtime->movieRefNum,
|
||||
&anim->qtime->movieResId, NULL, newMovieActive, NULL);
|
||||
}
|
||||
|
||||
if (err) {
|
||||
if(QTIME_DEBUG) printf("qt: bad movie %s\n", anim->name);
|
||||
if (QTIME_DEBUG) printf("qt: bad movie %s\n", anim->name);
|
||||
if (anim->qtime->movie) {
|
||||
DisposeMovie(anim->qtime->movie);
|
||||
MEM_freeN(anim->qtime);
|
||||
if(QTIME_DEBUG) printf("qt: can't load %s\n", anim->name);
|
||||
if (QTIME_DEBUG) printf("qt: can't load %s\n", anim->name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -495,10 +497,10 @@ int startquicktime (struct anim *anim)
|
||||
GetMovieBox(anim->qtime->movie, &anim->qtime->movieBounds);
|
||||
anim->x = anim->qtime->movWidth = RECT_WIDTH(anim->qtime->movieBounds);
|
||||
anim->y = anim->qtime->movHeight = RECT_HEIGHT(anim->qtime->movieBounds);
|
||||
if(QTIME_DEBUG) printf("qt: got bounds %s\n", anim->name);
|
||||
if (QTIME_DEBUG) printf("qt: got bounds %s\n", anim->name);
|
||||
|
||||
if(anim->x == 0 && anim->y == 0) {
|
||||
if(QTIME_DEBUG) printf("qt: error, no dimensions\n");
|
||||
if (anim->x == 0 && anim->y == 0) {
|
||||
if (QTIME_DEBUG) printf("qt: error, no dimensions\n");
|
||||
free_anim_quicktime(anim);
|
||||
return -1;
|
||||
}
|
||||
@@ -521,7 +523,7 @@ int startquicktime (struct anim *anim)
|
||||
anim->x * 4);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
if(err == noErr) {
|
||||
if (err == noErr) {
|
||||
anim->qtime->have_gw = TRUE;
|
||||
|
||||
SetMovieGWorld(anim->qtime->movie,
|
||||
@@ -550,7 +552,7 @@ int startquicktime (struct anim *anim)
|
||||
|
||||
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);
|
||||
|
||||
return 0;
|
||||
@@ -575,12 +577,12 @@ int imb_is_a_quicktime (char *name)
|
||||
#endif
|
||||
OSErr err = noErr;
|
||||
|
||||
if(!G.have_quicktime) return 0;
|
||||
if (!G.have_quicktime) return 0;
|
||||
|
||||
if(QTIME_DEBUG) printf("qt: checking as image %s\n", name);
|
||||
if (QTIME_DEBUG) printf("qt: checking as image %s\n", name);
|
||||
|
||||
// don't let quicktime image import handle these
|
||||
if( BLI_testextensie(name, ".swf") ||
|
||||
if ( BLI_testextensie(name, ".swf") ||
|
||||
BLI_testextensie(name, ".txt") ||
|
||||
BLI_testextensie(name, ".mpg") ||
|
||||
BLI_testextensie(name, ".wav") ||
|
||||
@@ -600,7 +602,7 @@ int imb_is_a_quicktime (char *name)
|
||||
GetGraphicsImporterForFile(&theFSSpec, &theImporter);
|
||||
|
||||
if (theImporter != NULL) {
|
||||
if(QTIME_DEBUG) printf("qt: %s valid\n", name);
|
||||
if (QTIME_DEBUG) printf("qt: %s valid\n", name);
|
||||
CloseComponent(theImporter);
|
||||
return 1;
|
||||
}
|
||||
@@ -643,7 +645,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
|
||||
if (mem == NULL || !G.have_quicktime)
|
||||
goto bail;
|
||||
|
||||
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).data = mem;
|
||||
@@ -657,25 +659,25 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
|
||||
kDataHCanRead,
|
||||
&dataHandler);
|
||||
if (err != noErr) {
|
||||
if(QTIME_DEBUG) printf("no datahandler\n");
|
||||
if (QTIME_DEBUG) printf("no datahandler\n");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
err = GetGraphicsImporterForDataRef((Handle)dataref, PointerDataHandlerSubType, &gImporter);
|
||||
if (err != noErr) {
|
||||
if(QTIME_DEBUG) printf("no graphimport\n");
|
||||
if (QTIME_DEBUG) printf("no graphimport\n");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
err = GraphicsImportGetNaturalBounds(gImporter, &myRect);
|
||||
if (err != noErr) {
|
||||
if(QTIME_DEBUG) printf("no bounds\n");
|
||||
if (QTIME_DEBUG) printf("no bounds\n");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
err = GraphicsImportGetImageDescription (gImporter, &desc );
|
||||
if (err != noErr) {
|
||||
if(QTIME_DEBUG) printf("no imagedescription\n");
|
||||
if (QTIME_DEBUG) printf("no imagedescription\n");
|
||||
goto bail;
|
||||
}
|
||||
|
||||
@@ -710,9 +712,10 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
|
||||
#endif
|
||||
|
||||
if (err != noErr) {
|
||||
if(QTIME_DEBUG) printf("no newgworld\n");
|
||||
if (QTIME_DEBUG) printf("no newgworld\n");
|
||||
goto bail;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
have_gw = TRUE;
|
||||
}
|
||||
|
||||
@@ -740,7 +743,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags)
|
||||
from= (unsigned char *)readPos;
|
||||
to= (unsigned char *)changePos;
|
||||
|
||||
for( index = 0; index < boxsize; index++, from+=4, to+=4 ) {
|
||||
for ( index = 0; index < boxsize; index++, from+=4, to+=4 ) {
|
||||
to[3] = from[0];
|
||||
to[0] = from[1];
|
||||
to[1] = from[2];
|
||||
@@ -752,7 +755,7 @@ bail:
|
||||
|
||||
DisposeHandle((Handle)dataref);
|
||||
UnlockPixels(myPixMap);
|
||||
if(have_gw) DisposeGWorld(offGWorld);
|
||||
if (have_gw) DisposeGWorld(offGWorld);
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (wbuf) {
|
||||
@@ -764,14 +767,14 @@ bail:
|
||||
if (gImporter != NULL) CloseComponent(gImporter);
|
||||
|
||||
if (err != noErr) {
|
||||
if(QTIME_DEBUG) printf("quicktime import unsuccesfull\n");
|
||||
if (QTIME_DEBUG) printf("quicktime import unsuccesfull\n");
|
||||
if (ibuf) {
|
||||
IMB_freeImBuf (ibuf);
|
||||
ibuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(ibuf) {
|
||||
if (ibuf) {
|
||||
|
||||
#ifdef _WIN32
|
||||
// add non transparent alpha layer, so images without alpha show up in the sequence editor
|
||||
@@ -781,8 +784,8 @@ bail:
|
||||
int box = x * y;
|
||||
unsigned char *arect = (unsigned char *) ibuf->rect;
|
||||
|
||||
if( depth < 32 && (**desc).cType != kGIFCodecType) {
|
||||
for(i = 0; i < box; i++, arect+=4)
|
||||
if ( depth < 32 && (**desc).cType != kGIFCodecType) {
|
||||
for (i = 0; i < box; i++, arect+=4)
|
||||
arect[3] = 0xFF;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -75,31 +75,31 @@ void WM_operator_free(wmOperator *op)
|
||||
{
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
if(op->py_instance) {
|
||||
if (op->py_instance) {
|
||||
/* do this first in case there are any __del__ functions or
|
||||
* similar that use properties */
|
||||
BPY_DECREF(op->py_instance);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(op->ptr) {
|
||||
if (op->ptr) {
|
||||
op->properties= op->ptr->data;
|
||||
MEM_freeN(op->ptr);
|
||||
}
|
||||
|
||||
if(op->properties) {
|
||||
if (op->properties) {
|
||||
IDP_FreeProperty(op->properties);
|
||||
MEM_freeN(op->properties);
|
||||
}
|
||||
|
||||
if(op->reports && (op->reports->flag & RPT_FREE)) {
|
||||
if (op->reports && (op->reports->flag & RPT_FREE)) {
|
||||
BKE_reports_clear(op->reports);
|
||||
MEM_freeN(op->reports);
|
||||
}
|
||||
|
||||
if(op->macro.first) {
|
||||
if (op->macro.first) {
|
||||
wmOperator *opm, *opmnext;
|
||||
for(opm= op->macro.first; opm; opm= opmnext) {
|
||||
for (opm= op->macro.first; opm; opm= opmnext) {
|
||||
opmnext = opm->next;
|
||||
WM_operator_free(opm);
|
||||
}
|
||||
@@ -124,7 +124,7 @@ void wm_operator_register(bContext *C, wmOperator *op)
|
||||
BLI_addtail(&wm->operators, op);
|
||||
tot= BLI_countlist(&wm->operators);
|
||||
|
||||
while(tot>MAX_OP_REGISTERED) {
|
||||
while (tot>MAX_OP_REGISTERED) {
|
||||
wmOperator *opt= wm->operators.first;
|
||||
BLI_remlink(&wm->operators, opt);
|
||||
WM_operator_free(opt);
|
||||
@@ -141,7 +141,7 @@ void WM_operator_stack_clear(wmWindowManager *wm)
|
||||
{
|
||||
wmOperator *op;
|
||||
|
||||
while((op= wm->operators.first)) {
|
||||
while ((op= wm->operators.first)) {
|
||||
BLI_remlink(&wm->operators, op);
|
||||
WM_operator_free(op);
|
||||
}
|
||||
@@ -159,11 +159,11 @@ MenuType *WM_menutype_find(const char *idname, int quiet)
|
||||
|
||||
if (idname[0]) {
|
||||
mt= BLI_ghash_lookup(menutypes_hash, idname);
|
||||
if(mt)
|
||||
if (mt)
|
||||
return mt;
|
||||
}
|
||||
|
||||
if(!quiet)
|
||||
if (!quiet)
|
||||
printf("search for unknown menutype %s\n", idname);
|
||||
|
||||
return NULL;
|
||||
@@ -190,9 +190,9 @@ void WM_menutype_free(void)
|
||||
{
|
||||
GHashIterator *iter= BLI_ghashIterator_new(menutypes_hash);
|
||||
|
||||
for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
|
||||
for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
|
||||
MenuType *mt= BLI_ghashIterator_getValue(iter);
|
||||
if(mt->ext.free) {
|
||||
if (mt->ext.free) {
|
||||
mt->ext.free(mt->ext.data);
|
||||
}
|
||||
}
|
||||
@@ -209,19 +209,19 @@ void WM_keymap_init(bContext *C)
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
|
||||
/* create standard key configs */
|
||||
if(!wm->defaultconf)
|
||||
if (!wm->defaultconf)
|
||||
wm->defaultconf= WM_keyconfig_new(wm, "Blender");
|
||||
if(!wm->addonconf)
|
||||
if (!wm->addonconf)
|
||||
wm->addonconf= WM_keyconfig_new(wm, "Blender Addon");
|
||||
if(!wm->userconf)
|
||||
if (!wm->userconf)
|
||||
wm->userconf= WM_keyconfig_new(wm, "Blender User");
|
||||
|
||||
/* initialize only after python init is done, for keymaps that
|
||||
* use python operators */
|
||||
if(CTX_py_init_get(C) && (wm->initialized & WM_INIT_KEYMAP) == 0) {
|
||||
if (CTX_py_init_get(C) && (wm->initialized & WM_INIT_KEYMAP) == 0) {
|
||||
/* create default key config, only initialize once,
|
||||
* it's persistent across sessions */
|
||||
if(!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
|
||||
if (!(wm->defaultconf->flag & KEYCONF_INIT_DEFAULT)) {
|
||||
wm_window_keymap(wm->defaultconf);
|
||||
ED_spacetypes_keymap(wm->defaultconf);
|
||||
|
||||
@@ -240,16 +240,16 @@ void WM_check(bContext *C)
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
|
||||
/* wm context */
|
||||
if(wm==NULL) {
|
||||
if (wm==NULL) {
|
||||
wm= CTX_data_main(C)->wm.first;
|
||||
CTX_wm_manager_set(C, wm);
|
||||
}
|
||||
if(wm==NULL) return;
|
||||
if(wm->windows.first==NULL) return;
|
||||
if (wm==NULL) return;
|
||||
if (wm->windows.first==NULL) return;
|
||||
|
||||
if (!G.background) {
|
||||
/* case: fileread */
|
||||
if((wm->initialized & WM_INIT_WINDOW) == 0) {
|
||||
if ((wm->initialized & WM_INIT_WINDOW) == 0) {
|
||||
WM_keymap_init(C);
|
||||
WM_autosave_init(wm);
|
||||
}
|
||||
@@ -260,7 +260,7 @@ void WM_check(bContext *C)
|
||||
|
||||
/* case: fileread */
|
||||
/* note: this runs in bg mode to set the screen context cb */
|
||||
if((wm->initialized & WM_INIT_WINDOW) == 0) {
|
||||
if ((wm->initialized & WM_INIT_WINDOW) == 0) {
|
||||
ED_screens_initialize(wm);
|
||||
wm->initialized |= WM_INIT_WINDOW;
|
||||
}
|
||||
@@ -272,14 +272,14 @@ void wm_clear_default_size(bContext *C)
|
||||
wmWindow *win;
|
||||
|
||||
/* wm context */
|
||||
if(wm==NULL) {
|
||||
if (wm==NULL) {
|
||||
wm= CTX_data_main(C)->wm.first;
|
||||
CTX_wm_manager_set(C, wm);
|
||||
}
|
||||
if(wm==NULL) return;
|
||||
if(wm->windows.first==NULL) return;
|
||||
if (wm==NULL) return;
|
||||
if (wm->windows.first==NULL) return;
|
||||
|
||||
for(win= wm->windows.first; win; win= win->next) {
|
||||
for (win= wm->windows.first; win; win= win->next) {
|
||||
win->sizex = 0;
|
||||
win->sizey = 0;
|
||||
win->posx = 0;
|
||||
@@ -314,22 +314,22 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
|
||||
wmOperator *op;
|
||||
wmKeyConfig *keyconf;
|
||||
|
||||
if(wm->autosavetimer)
|
||||
if (wm->autosavetimer)
|
||||
wm_autosave_timer_ended(wm);
|
||||
|
||||
while((win= wm->windows.first)) {
|
||||
while ((win= wm->windows.first)) {
|
||||
BLI_remlink(&wm->windows, win);
|
||||
win->screen= NULL; /* prevent draw clear to use screen */
|
||||
wm_draw_window_clear(win);
|
||||
wm_window_free(C, wm, win);
|
||||
}
|
||||
|
||||
while((op= wm->operators.first)) {
|
||||
while ((op= wm->operators.first)) {
|
||||
BLI_remlink(&wm->operators, op);
|
||||
WM_operator_free(op);
|
||||
}
|
||||
|
||||
while((keyconf=wm->keyconfigs.first)) {
|
||||
while ((keyconf=wm->keyconfigs.first)) {
|
||||
BLI_remlink(&wm->keyconfigs, keyconf);
|
||||
WM_keyconfig_free(keyconf);
|
||||
}
|
||||
@@ -341,14 +341,14 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
|
||||
|
||||
wm_reports_free(wm);
|
||||
|
||||
if(C && CTX_wm_manager(C)==wm) CTX_wm_manager_set(C, NULL);
|
||||
if (C && CTX_wm_manager(C)==wm) CTX_wm_manager_set(C, NULL);
|
||||
}
|
||||
|
||||
void wm_close_and_free_all(bContext *C, ListBase *wmlist)
|
||||
{
|
||||
wmWindowManager *wm;
|
||||
|
||||
while((wm=wmlist->first)) {
|
||||
while ((wm=wmlist->first)) {
|
||||
wm_close_and_free(C, wm);
|
||||
BLI_remlink(wmlist, wm);
|
||||
MEM_freeN(wm);
|
||||
@@ -357,7 +357,7 @@ void wm_close_and_free_all(bContext *C, ListBase *wmlist)
|
||||
|
||||
void WM_main(bContext *C)
|
||||
{
|
||||
while(1) {
|
||||
while (1) {
|
||||
|
||||
/* get events from ghost, handle window events, add to window queues */
|
||||
wm_window_process_events(C);
|
||||
|
||||
@@ -127,7 +127,8 @@ void wm_set_apple_prefsize(int scr_x, int scr_y)
|
||||
WM_setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64);
|
||||
G.windowstate= 0;
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
/* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
|
||||
WM_setprefsize(120, 40, 850, 684);
|
||||
|
||||
@@ -88,7 +88,8 @@ static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useB
|
||||
cursor->big_sizex,cursor->big_sizey,
|
||||
cursor->big_hotx,cursor->big_hoty,
|
||||
cursor->fg_color, cursor->bg_color);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
GHOST_SetCustomCursorShapeEx(win->ghostwin,
|
||||
(GHOST_TUns8 *)cursor->small_bm, (GHOST_TUns8 *)cursor->small_mask,
|
||||
cursor->small_sizex,cursor->small_sizey,
|
||||
@@ -114,19 +115,19 @@ void WM_cursor_set(wmWindow *win, int curs)
|
||||
#ifdef _WIN32
|
||||
/* the default win32 cross cursor is barely visible,
|
||||
* only 1 pixel thick, use another one instead */
|
||||
if(curs==CURSOR_EDIT)
|
||||
if (curs==CURSOR_EDIT)
|
||||
curs= BC_CROSSCURSOR;
|
||||
#endif
|
||||
|
||||
GHOST_SetCursorVisibility(win->ghostwin, 1);
|
||||
|
||||
if(curs == CURSOR_STD && win->modalcursor)
|
||||
if (curs == CURSOR_STD && win->modalcursor)
|
||||
curs= win->modalcursor;
|
||||
|
||||
win->cursor= curs;
|
||||
|
||||
/* detect if we use system cursor or Blender cursor */
|
||||
if(curs>=BC_GHOST_CURSORS) {
|
||||
if (curs>=BC_GHOST_CURSORS) {
|
||||
GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs));
|
||||
}
|
||||
else {
|
||||
@@ -146,7 +147,7 @@ void WM_cursor_set(wmWindow *win, int curs)
|
||||
|
||||
void WM_cursor_modal(wmWindow *win, int val)
|
||||
{
|
||||
if(win->lastcursor == 0)
|
||||
if (win->lastcursor == 0)
|
||||
win->lastcursor = win->cursor;
|
||||
win->modalcursor = val;
|
||||
WM_cursor_set(win, val);
|
||||
@@ -155,7 +156,7 @@ void WM_cursor_modal(wmWindow *win, int val)
|
||||
void WM_cursor_restore(wmWindow *win)
|
||||
{
|
||||
win->modalcursor = 0;
|
||||
if(win->lastcursor)
|
||||
if (win->lastcursor)
|
||||
WM_cursor_set(win, win->lastcursor);
|
||||
win->lastcursor = 0;
|
||||
}
|
||||
@@ -163,14 +164,15 @@ void WM_cursor_restore(wmWindow *win)
|
||||
/* to allow usage all over, we do entire WM */
|
||||
void WM_cursor_wait(int val)
|
||||
{
|
||||
if(!G.background) {
|
||||
if (!G.background) {
|
||||
wmWindowManager *wm= G.main->wm.first;
|
||||
wmWindow *win= wm?wm->windows.first:NULL;
|
||||
|
||||
for(; win; win= win->next) {
|
||||
if(val) {
|
||||
for (; win; win= win->next) {
|
||||
if (val) {
|
||||
WM_cursor_modal(win, BC_WAITCURSOR);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
WM_cursor_restore(win);
|
||||
}
|
||||
}
|
||||
@@ -184,8 +186,8 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds)
|
||||
* */
|
||||
GHOST_TGrabCursorMode mode = GHOST_kGrabNormal;
|
||||
|
||||
if(hide) mode = GHOST_kGrabHide;
|
||||
else if(wrap) mode = GHOST_kGrabWrap;
|
||||
if (hide) mode = GHOST_kGrabHide;
|
||||
else if (wrap) mode = GHOST_kGrabWrap;
|
||||
if ((G.f & G_DEBUG) == 0) {
|
||||
if (win && win->ghostwin) {
|
||||
const GHOST_TabletData *tabletdata= GHOST_GetTabletData(win->ghostwin);
|
||||
@@ -203,7 +205,7 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds)
|
||||
void WM_cursor_ungrab(wmWindow *win)
|
||||
{
|
||||
if ((G.f & G_DEBUG) == 0) {
|
||||
if(win && win->ghostwin) {
|
||||
if (win && win->ghostwin) {
|
||||
GHOST_SetCursorGrab(win->ghostwin, GHOST_kGrabDisable, NULL);
|
||||
win->grabcursor = GHOST_kGrabDisable;
|
||||
}
|
||||
@@ -213,18 +215,21 @@ void WM_cursor_ungrab(wmWindow *win)
|
||||
/* give it a modal keymap one day? */
|
||||
int wm_cursor_arrow_move(wmWindow *win, wmEvent *event)
|
||||
{
|
||||
if(win && event->val==KM_PRESS) {
|
||||
if (win && event->val==KM_PRESS) {
|
||||
|
||||
if(event->type==UPARROWKEY) {
|
||||
if (event->type==UPARROWKEY) {
|
||||
WM_cursor_warp(win, event->x, event->y+1);
|
||||
return 1;
|
||||
} else if(event->type==DOWNARROWKEY) {
|
||||
}
|
||||
else if (event->type==DOWNARROWKEY) {
|
||||
WM_cursor_warp(win, event->x, event->y-1);
|
||||
return 1;
|
||||
} else if(event->type==LEFTARROWKEY) {
|
||||
}
|
||||
else if (event->type==LEFTARROWKEY) {
|
||||
WM_cursor_warp(win, event->x-1, event->y);
|
||||
return 1;
|
||||
} else if(event->type==RIGHTARROWKEY) {
|
||||
}
|
||||
else if (event->type==RIGHTARROWKEY) {
|
||||
WM_cursor_warp(win, event->x+1, event->y);
|
||||
return 1;
|
||||
}
|
||||
@@ -253,7 +258,7 @@ void WM_timecursor(wmWindow *win, int nr)
|
||||
unsigned char bitmap[16][2]= {{0}};
|
||||
int i, idx;
|
||||
|
||||
if(win->lastcursor == 0)
|
||||
if (win->lastcursor == 0)
|
||||
win->lastcursor= win->cursor;
|
||||
|
||||
memset(&mask, 0xFF, sizeof(mask));
|
||||
|
||||
@@ -83,9 +83,9 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
|
||||
{
|
||||
wmDropBoxMap *dm;
|
||||
|
||||
for(dm= dropboxes.first; dm; dm= dm->next)
|
||||
if(dm->spaceid==spaceid && dm->regionid==regionid)
|
||||
if(0==strncmp(idname, dm->idname, KMAP_MAX_NAME))
|
||||
for (dm= dropboxes.first; dm; dm= dm->next)
|
||||
if (dm->spaceid==spaceid && dm->regionid==regionid)
|
||||
if (0==strncmp(idname, dm->idname, KMAP_MAX_NAME))
|
||||
return &dm->dropboxes;
|
||||
|
||||
dm= MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list");
|
||||
@@ -109,7 +109,7 @@ wmDropBox *WM_dropbox_add(ListBase *lb, const char *idname, int (*poll)(bContext
|
||||
drop->ot= WM_operatortype_find(idname, 0);
|
||||
drop->opcontext= WM_OP_INVOKE_DEFAULT;
|
||||
|
||||
if(drop->ot==NULL) {
|
||||
if (drop->ot==NULL) {
|
||||
MEM_freeN(drop);
|
||||
printf("Error: dropbox with unknown operator: %s\n", idname);
|
||||
return NULL;
|
||||
@@ -125,11 +125,11 @@ void wm_dropbox_free(void)
|
||||
{
|
||||
wmDropBoxMap *dm;
|
||||
|
||||
for(dm= dropboxes.first; dm; dm= dm->next) {
|
||||
for (dm= dropboxes.first; dm; dm= dm->next) {
|
||||
wmDropBox *drop;
|
||||
|
||||
for(drop= dm->dropboxes.first; drop; drop= drop->next) {
|
||||
if(drop->ptr) {
|
||||
for (drop= dm->dropboxes.first; drop; drop= drop->next) {
|
||||
if (drop->ptr) {
|
||||
WM_operator_properties_free(drop->ptr);
|
||||
MEM_freeN(drop->ptr);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ wmDrag *WM_event_start_drag(struct bContext *C, int icon, int type, void *poin,
|
||||
BLI_addtail(&wm->drags, drag);
|
||||
drag->icon= icon;
|
||||
drag->type= type;
|
||||
if(type==WM_DRAG_PATH)
|
||||
if (type==WM_DRAG_PATH)
|
||||
BLI_strncpy(drag->path, poin, FILE_MAX);
|
||||
else
|
||||
drag->poin= poin;
|
||||
@@ -175,11 +175,11 @@ void WM_event_drag_image(wmDrag *drag, ImBuf *imb, float scale, int sx, int sy)
|
||||
static const char *dropbox_active(bContext *C, ListBase *handlers, wmDrag *drag, wmEvent *event)
|
||||
{
|
||||
wmEventHandler *handler= handlers->first;
|
||||
for(; handler; handler= handler->next) {
|
||||
if(handler->dropboxes) {
|
||||
for (; handler; handler= handler->next) {
|
||||
if (handler->dropboxes) {
|
||||
wmDropBox *drop= handler->dropboxes->first;
|
||||
for(; drop; drop= drop->next) {
|
||||
if(drop->poll(C, drag, event))
|
||||
for (; drop; drop= drop->next) {
|
||||
if (drop->poll(C, drag, event))
|
||||
return drop->ot->name;
|
||||
}
|
||||
}
|
||||
@@ -196,13 +196,13 @@ static const char *wm_dropbox_active(bContext *C, wmDrag *drag, wmEvent *event)
|
||||
const char *name;
|
||||
|
||||
name= dropbox_active(C, &win->handlers, drag, event);
|
||||
if(name) return name;
|
||||
if (name) return name;
|
||||
|
||||
name= dropbox_active(C, &sa->handlers, drag, event);
|
||||
if(name) return name;
|
||||
if (name) return name;
|
||||
|
||||
name= dropbox_active(C, &ar->handlers, drag, event);
|
||||
if(name) return name;
|
||||
if (name) return name;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -213,19 +213,19 @@ static void wm_drop_operator_options(bContext *C, wmDrag *drag, wmEvent *event)
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
|
||||
/* for multiwin drags, we only do this if mouse inside */
|
||||
if(event->x<0 || event->y<0 || event->x>win->sizex || event->y>win->sizey)
|
||||
if (event->x<0 || event->y<0 || event->x>win->sizex || event->y>win->sizey)
|
||||
return;
|
||||
|
||||
drag->opname[0]= 0;
|
||||
|
||||
/* check buttons (XXX todo rna and value) */
|
||||
if( UI_but_active_drop_name(C) ) {
|
||||
if ( UI_but_active_drop_name(C) ) {
|
||||
strcpy(drag->opname, "Paste name");
|
||||
}
|
||||
else {
|
||||
const char *opname= wm_dropbox_active(C, drag, event);
|
||||
|
||||
if(opname) {
|
||||
if (opname) {
|
||||
BLI_strncpy(drag->opname, opname, FILE_MAX);
|
||||
// WM_cursor_modal(win, CURSOR_COPY);
|
||||
}
|
||||
@@ -241,7 +241,7 @@ void wm_drags_check_ops(bContext *C, wmEvent *event)
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmDrag *drag;
|
||||
|
||||
for(drag= wm->drags.first; drag; drag= drag->next) {
|
||||
for (drag= wm->drags.first; drag; drag= drag->next) {
|
||||
wm_drop_operator_options(C, drag, event);
|
||||
}
|
||||
}
|
||||
@@ -279,13 +279,13 @@ static const char *wm_drag_name(wmDrag *drag)
|
||||
|
||||
static void drag_rect_minmax(rcti *rect, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
if(rect->xmin > x1)
|
||||
if (rect->xmin > x1)
|
||||
rect->xmin = x1;
|
||||
if(rect->xmax < x2)
|
||||
if (rect->xmax < x2)
|
||||
rect->xmax = x2;
|
||||
if(rect->ymin > y1)
|
||||
if (rect->ymin > y1)
|
||||
rect->ymin = y1;
|
||||
if(rect->ymax < y2)
|
||||
if (rect->ymax < y2)
|
||||
rect->ymax = y2;
|
||||
}
|
||||
|
||||
@@ -299,21 +299,21 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
|
||||
|
||||
cursorx= win->eventstate->x;
|
||||
cursory= win->eventstate->y;
|
||||
if(rect) {
|
||||
if (rect) {
|
||||
rect->xmin = rect->xmax = cursorx;
|
||||
rect->ymin = rect->ymax = cursory;
|
||||
}
|
||||
|
||||
/* XXX todo, multiline drag draws... but maybe not, more types mixed wont work well */
|
||||
glEnable(GL_BLEND);
|
||||
for(drag= wm->drags.first; drag; drag= drag->next) {
|
||||
for (drag= wm->drags.first; drag; drag= drag->next) {
|
||||
|
||||
/* image or icon */
|
||||
if(drag->imb) {
|
||||
if (drag->imb) {
|
||||
x= cursorx - drag->sx/2;
|
||||
y= cursory - drag->sy/2;
|
||||
|
||||
if(rect)
|
||||
if (rect)
|
||||
drag_rect_minmax(rect, x, y, x+drag->sx, y+drag->sy);
|
||||
else {
|
||||
glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */
|
||||
@@ -325,14 +325,14 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
|
||||
y= cursory - 2;
|
||||
|
||||
/* icons assumed to be 16 pixels */
|
||||
if(rect)
|
||||
if (rect)
|
||||
drag_rect_minmax(rect, x, y, x+16, y+16);
|
||||
else
|
||||
UI_icon_draw_aspect(x, y, drag->icon, 1.0, 0.8);
|
||||
}
|
||||
|
||||
/* item name */
|
||||
if(drag->imb) {
|
||||
if (drag->imb) {
|
||||
x= cursorx - drag->sx/2;
|
||||
y= cursory - drag->sy/2 - 16;
|
||||
}
|
||||
@@ -341,7 +341,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
|
||||
y= cursory + 1;
|
||||
}
|
||||
|
||||
if(rect) {
|
||||
if (rect) {
|
||||
int w= UI_GetStringWidth(wm_drag_name(drag));
|
||||
drag_rect_minmax(rect, x, y, x+w, y+16);
|
||||
}
|
||||
@@ -351,8 +351,8 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
|
||||
}
|
||||
|
||||
/* operator name with roundbox */
|
||||
if(drag->opname[0]) {
|
||||
if(drag->imb) {
|
||||
if (drag->opname[0]) {
|
||||
if (drag->imb) {
|
||||
x= cursorx - drag->sx/2;
|
||||
y= cursory + drag->sy/2 + 4;
|
||||
}
|
||||
@@ -361,7 +361,7 @@ void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect)
|
||||
y= cursory + 16;
|
||||
}
|
||||
|
||||
if(rect) {
|
||||
if (rect) {
|
||||
int w= UI_GetStringWidth(wm_drag_name(drag));
|
||||
drag_rect_minmax(rect, x, y, x+w, y+16);
|
||||
}
|
||||
|
||||
@@ -78,14 +78,14 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
|
||||
if(wm->paintcursors.first) {
|
||||
if (wm->paintcursors.first) {
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
bScreen *screen= win->screen;
|
||||
wmPaintCursor *pc;
|
||||
|
||||
if(screen->subwinactive == ar->swinid) {
|
||||
for(pc= wm->paintcursors.first; pc; pc= pc->next) {
|
||||
if(pc->poll == NULL || pc->poll(C)) {
|
||||
if (screen->subwinactive == ar->swinid) {
|
||||
for (pc= wm->paintcursors.first; pc; pc= pc->next) {
|
||||
if (pc->poll == NULL || pc->poll(C)) {
|
||||
ARegion *ar_other= CTX_wm_region(C);
|
||||
if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) {
|
||||
int x = 0, y = 0;
|
||||
@@ -111,13 +111,13 @@ static void wm_paintcursor_draw(bContext *C, ARegion *ar)
|
||||
|
||||
static void wm_area_mark_invalid_backbuf(ScrArea *sa)
|
||||
{
|
||||
if(sa->spacetype == SPACE_VIEW3D)
|
||||
if (sa->spacetype == SPACE_VIEW3D)
|
||||
((View3D*)sa->spacedata.first)->flag |= V3D_INVALID_BACKBUF;
|
||||
}
|
||||
|
||||
static int wm_area_test_invalid_backbuf(ScrArea *sa)
|
||||
{
|
||||
if(sa->spacetype == SPACE_VIEW3D)
|
||||
if (sa->spacetype == SPACE_VIEW3D)
|
||||
return (((View3D*)sa->spacedata.first)->flag & V3D_INVALID_BACKBUF);
|
||||
else
|
||||
return 1;
|
||||
@@ -125,11 +125,11 @@ static int wm_area_test_invalid_backbuf(ScrArea *sa)
|
||||
|
||||
static void wm_region_test_render_do_draw(ScrArea *sa, ARegion *ar)
|
||||
{
|
||||
if(sa->spacetype == SPACE_VIEW3D) {
|
||||
if (sa->spacetype == SPACE_VIEW3D) {
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
RenderEngine *engine = (rv3d)? rv3d->render_engine: NULL;
|
||||
|
||||
if(engine && (engine->flag & RE_ENGINE_DO_DRAW)) {
|
||||
if (engine && (engine->flag & RE_ENGINE_DO_DRAW)) {
|
||||
ar->do_draw = 1;
|
||||
engine->flag &= ~RE_ENGINE_DO_DRAW;
|
||||
}
|
||||
@@ -146,11 +146,11 @@ static void wm_method_draw_full(bContext *C, wmWindow *win)
|
||||
ARegion *ar;
|
||||
|
||||
/* draw area regions */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
for(ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
if(ar->swinid) {
|
||||
for (ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->swinid) {
|
||||
CTX_wm_region_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
wm_paintcursor_draw(C, ar);
|
||||
@@ -167,15 +167,15 @@ static void wm_method_draw_full(bContext *C, wmWindow *win)
|
||||
ED_area_overdraw(C);
|
||||
|
||||
/* draw overlapping regions */
|
||||
for(ar=screen->regionbase.first; ar; ar= ar->next) {
|
||||
if(ar->swinid) {
|
||||
for (ar=screen->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->swinid) {
|
||||
CTX_wm_menu_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
CTX_wm_menu_set(C, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if(screen->do_draw_gesture)
|
||||
if (screen->do_draw_gesture)
|
||||
wm_gesture_draw(win);
|
||||
}
|
||||
|
||||
@@ -191,9 +191,9 @@ static void wm_flush_regions_down(bScreen *screen, rcti *dirty)
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next) {
|
||||
if(BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for (ar= sa->regionbase.first; ar; ar= ar->next) {
|
||||
if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
|
||||
ar->do_draw= RGN_DRAW;
|
||||
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
|
||||
ar->swap= WIN_NONE_OK;
|
||||
@@ -207,8 +207,8 @@ static void wm_flush_regions_up(bScreen *screen, rcti *dirty)
|
||||
{
|
||||
ARegion *ar;
|
||||
|
||||
for(ar= screen->regionbase.first; ar; ar= ar->next) {
|
||||
if(BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
|
||||
for (ar= screen->regionbase.first; ar; ar= ar->next) {
|
||||
if (BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
|
||||
ar->do_draw= RGN_DRAW;
|
||||
memset(&ar->drawrct, 0, sizeof(ar->drawrct));
|
||||
ar->swap= WIN_NONE_OK;
|
||||
@@ -225,58 +225,58 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
|
||||
static rcti rect= {0, 0, 0, 0};
|
||||
|
||||
/* after backbuffer selection draw, we need to redraw */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next)
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
if(ar->swinid && !wm_area_test_invalid_backbuf(sa))
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next)
|
||||
for (ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
if (ar->swinid && !wm_area_test_invalid_backbuf(sa))
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
/* flush overlapping regions */
|
||||
if(screen->regionbase.first) {
|
||||
if (screen->regionbase.first) {
|
||||
/* flush redraws of area regions up to overlapping regions */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next)
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
if(ar->swinid && ar->do_draw)
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next)
|
||||
for (ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
if (ar->swinid && ar->do_draw)
|
||||
wm_flush_regions_up(screen, &ar->winrct);
|
||||
|
||||
/* flush between overlapping regions */
|
||||
for(ar= screen->regionbase.last; ar; ar= ar->prev)
|
||||
if(ar->swinid && ar->do_draw)
|
||||
for (ar= screen->regionbase.last; ar; ar= ar->prev)
|
||||
if (ar->swinid && ar->do_draw)
|
||||
wm_flush_regions_up(screen, &ar->winrct);
|
||||
|
||||
/* flush redraws of overlapping regions down to area regions */
|
||||
for(ar= screen->regionbase.last; ar; ar= ar->prev)
|
||||
if(ar->swinid && ar->do_draw)
|
||||
for (ar= screen->regionbase.last; ar; ar= ar->prev)
|
||||
if (ar->swinid && ar->do_draw)
|
||||
wm_flush_regions_down(screen, &ar->winrct);
|
||||
}
|
||||
|
||||
/* flush drag item */
|
||||
if(rect.xmin!=rect.xmax) {
|
||||
if (rect.xmin!=rect.xmax) {
|
||||
wm_flush_regions_down(screen, &rect);
|
||||
rect.xmin = rect.xmax = 0;
|
||||
}
|
||||
if(wm->drags.first) {
|
||||
if (wm->drags.first) {
|
||||
/* doesnt draw, fills rect with boundbox */
|
||||
wm_drags_draw(C, win, &rect);
|
||||
}
|
||||
|
||||
/* draw marked area regions */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
for(ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
if(ar->swinid) {
|
||||
if(ar->do_draw) {
|
||||
for (ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->swinid) {
|
||||
if (ar->do_draw) {
|
||||
CTX_wm_region_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
wm_paintcursor_draw(C, ar);
|
||||
ED_area_overdraw_flush(sa, ar);
|
||||
CTX_wm_region_set(C, NULL);
|
||||
|
||||
if(exchange)
|
||||
if (exchange)
|
||||
ar->swap= WIN_FRONT_OK;
|
||||
}
|
||||
else if(exchange) {
|
||||
if(ar->swap == WIN_FRONT_OK) {
|
||||
else if (exchange) {
|
||||
if (ar->swap == WIN_FRONT_OK) {
|
||||
CTX_wm_region_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
wm_paintcursor_draw(C, ar);
|
||||
@@ -285,9 +285,9 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
|
||||
|
||||
ar->swap= WIN_BOTH_OK;
|
||||
}
|
||||
else if(ar->swap == WIN_BACK_OK)
|
||||
else if (ar->swap == WIN_BACK_OK)
|
||||
ar->swap= WIN_FRONT_OK;
|
||||
else if(ar->swap == WIN_BOTH_OK)
|
||||
else if (ar->swap == WIN_BOTH_OK)
|
||||
ar->swap= WIN_BOTH_OK;
|
||||
}
|
||||
}
|
||||
@@ -298,39 +298,39 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
|
||||
}
|
||||
|
||||
/* after area regions so we can do area 'overlay' drawing */
|
||||
if(screen->do_draw) {
|
||||
if (screen->do_draw) {
|
||||
ED_screen_draw(win);
|
||||
|
||||
if(exchange)
|
||||
if (exchange)
|
||||
screen->swap= WIN_FRONT_OK;
|
||||
}
|
||||
else if(exchange) {
|
||||
if(screen->swap==WIN_FRONT_OK) {
|
||||
else if (exchange) {
|
||||
if (screen->swap==WIN_FRONT_OK) {
|
||||
ED_screen_draw(win);
|
||||
screen->swap= WIN_BOTH_OK;
|
||||
}
|
||||
else if(screen->swap==WIN_BACK_OK)
|
||||
else if (screen->swap==WIN_BACK_OK)
|
||||
screen->swap= WIN_FRONT_OK;
|
||||
else if(screen->swap==WIN_BOTH_OK)
|
||||
else if (screen->swap==WIN_BOTH_OK)
|
||||
screen->swap= WIN_BOTH_OK;
|
||||
}
|
||||
|
||||
ED_area_overdraw(C);
|
||||
|
||||
/* draw marked overlapping regions */
|
||||
for(ar=screen->regionbase.first; ar; ar= ar->next) {
|
||||
if(ar->swinid && ar->do_draw) {
|
||||
for (ar=screen->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->swinid && ar->do_draw) {
|
||||
CTX_wm_menu_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
CTX_wm_menu_set(C, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if(screen->do_draw_gesture)
|
||||
if (screen->do_draw_gesture)
|
||||
wm_gesture_draw(win);
|
||||
|
||||
/* needs pixel coords in screen */
|
||||
if(wm->drags.first) {
|
||||
if (wm->drags.first) {
|
||||
wm_drags_draw(C, win, NULL);
|
||||
}
|
||||
}
|
||||
@@ -368,13 +368,13 @@ static void split_width(int x, int n, int *splitx, int *nx)
|
||||
int a, newnx, waste;
|
||||
|
||||
/* if already power of two just use it */
|
||||
if(is_power_of_2_i(x)) {
|
||||
if (is_power_of_2_i(x)) {
|
||||
splitx[0]= x;
|
||||
(*nx)++;
|
||||
return;
|
||||
}
|
||||
|
||||
if(n == 1) {
|
||||
if (n == 1) {
|
||||
/* last part, we have to go larger */
|
||||
splitx[0]= power_of_2_max_i(x);
|
||||
(*nx)++;
|
||||
@@ -385,12 +385,12 @@ static void split_width(int x, int n, int *splitx, int *nx)
|
||||
newnx= ++(*nx);
|
||||
split_width(x-splitx[0], n-1, splitx+1, &newnx);
|
||||
|
||||
for(waste=0, a=0; a<n; a++)
|
||||
for (waste=0, a=0; a<n; a++)
|
||||
waste += splitx[a];
|
||||
|
||||
/* if we waste more space or use the same amount,
|
||||
* revert deeper splits and just use larger */
|
||||
if(waste >= power_of_2_max_i(x)) {
|
||||
if (waste >= power_of_2_max_i(x)) {
|
||||
splitx[0]= power_of_2_max_i(x);
|
||||
memset(splitx+1, 0, sizeof(int)*(n-1));
|
||||
}
|
||||
@@ -401,7 +401,7 @@ static void split_width(int x, int n, int *splitx, int *nx)
|
||||
|
||||
static void wm_draw_triple_free(wmWindow *win)
|
||||
{
|
||||
if(win->drawdata) {
|
||||
if (win->drawdata) {
|
||||
wmDrawTriple *triple= win->drawdata;
|
||||
|
||||
glDeleteTextures(triple->nx*triple->ny, triple->bind);
|
||||
@@ -426,14 +426,14 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
|
||||
int x, y;
|
||||
|
||||
/* compute texture sizes */
|
||||
if(GLEW_ARB_texture_rectangle || GLEW_NV_texture_rectangle || GLEW_EXT_texture_rectangle) {
|
||||
if (GLEW_ARB_texture_rectangle || GLEW_NV_texture_rectangle || GLEW_EXT_texture_rectangle) {
|
||||
triple->target= GL_TEXTURE_RECTANGLE_ARB;
|
||||
triple->nx= 1;
|
||||
triple->ny= 1;
|
||||
triple->x[0]= win->sizex;
|
||||
triple->y[0]= win->sizey;
|
||||
}
|
||||
else if(GPU_non_power_of_two_support()) {
|
||||
else if (GPU_non_power_of_two_support()) {
|
||||
triple->target= GL_TEXTURE_2D;
|
||||
triple->nx= 1;
|
||||
triple->ny= 1;
|
||||
@@ -451,19 +451,19 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
|
||||
/* generate texture names */
|
||||
glGenTextures(triple->nx*triple->ny, triple->bind);
|
||||
|
||||
if(!triple->bind[0]) {
|
||||
if (!triple->bind[0]) {
|
||||
/* not the typical failure case but we handle it anyway */
|
||||
printf("WM: failed to allocate texture for triple buffer drawing (glGenTextures).\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(y=0; y<triple->ny; y++) {
|
||||
for(x=0; x<triple->nx; x++) {
|
||||
for (y=0; y<triple->ny; y++) {
|
||||
for (x=0; x<triple->nx; x++) {
|
||||
/* proxy texture is only guaranteed to test for the cases that
|
||||
* there is only one texture in use, which may not be the case */
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
|
||||
|
||||
if(triple->x[x] > maxsize || triple->y[y] > maxsize) {
|
||||
if (triple->x[x] > maxsize || triple->y[y] > maxsize) {
|
||||
glBindTexture(triple->target, 0);
|
||||
printf("WM: failed to allocate texture for triple buffer drawing "
|
||||
"(texture too large for graphics card).\n");
|
||||
@@ -480,7 +480,7 @@ static int wm_triple_gen_textures(wmWindow *win, wmDrawTriple *triple)
|
||||
glBindTexture(triple->target, 0);
|
||||
|
||||
/* not sure if this works everywhere .. */
|
||||
if(glGetError() == GL_OUT_OF_MEMORY) {
|
||||
if (glGetError() == GL_OUT_OF_MEMORY) {
|
||||
printf("WM: failed to allocate texture for triple buffer drawing (out of memory).\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -497,8 +497,8 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
|
||||
|
||||
glEnable(triple->target);
|
||||
|
||||
for(y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) {
|
||||
for(x=0, offx=0; x<triple->nx; offx+=triple->x[x], x++) {
|
||||
for (y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) {
|
||||
for (x=0, offx=0; x<triple->nx; offx+=triple->x[x], x++) {
|
||||
sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x];
|
||||
sizey= (y == triple->ny-1)? win->sizey-offy: triple->y[y];
|
||||
|
||||
@@ -509,7 +509,7 @@ static void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple)
|
||||
halfy= 0.375f;
|
||||
|
||||
/* texture rectangle has unnormalized coordinates */
|
||||
if(triple->target == GL_TEXTURE_2D) {
|
||||
if (triple->target == GL_TEXTURE_2D) {
|
||||
ratiox /= triple->x[x];
|
||||
ratioy /= triple->y[y];
|
||||
halfx /= triple->x[x];
|
||||
@@ -543,8 +543,8 @@ static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple)
|
||||
{
|
||||
int x, y, sizex, sizey, offx, offy;
|
||||
|
||||
for(y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) {
|
||||
for(x=0, offx=0; x<triple->nx; offx+=triple->x[x], x++) {
|
||||
for (y=0, offy=0; y<triple->ny; offy+=triple->y[y], y++) {
|
||||
for (x=0, offx=0; x<triple->nx; offx+=triple->x[x], x++) {
|
||||
sizex= (x == triple->nx-1)? win->sizex-offx: triple->x[x];
|
||||
sizey= (y == triple->ny-1)? win->sizey-offy: triple->y[y];
|
||||
|
||||
@@ -565,7 +565,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
ARegion *ar;
|
||||
int copytex= 0, paintcursor= 1;
|
||||
|
||||
if(win->drawdata) {
|
||||
if (win->drawdata) {
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
@@ -576,7 +576,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
else {
|
||||
win->drawdata= MEM_callocN(sizeof(wmDrawTriple), "wmDrawTriple");
|
||||
|
||||
if(!wm_triple_gen_textures(win, win->drawdata)) {
|
||||
if (!wm_triple_gen_textures(win, win->drawdata)) {
|
||||
wm_draw_triple_fail(C, win);
|
||||
return;
|
||||
}
|
||||
@@ -585,11 +585,11 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
triple= win->drawdata;
|
||||
|
||||
/* draw marked area regions */
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
for(ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
if(ar->swinid && ar->do_draw) {
|
||||
for (ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->swinid && ar->do_draw) {
|
||||
CTX_wm_region_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
ED_area_overdraw_flush(sa, ar);
|
||||
@@ -602,7 +602,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
CTX_wm_area_set(C, NULL);
|
||||
}
|
||||
|
||||
if(copytex) {
|
||||
if (copytex) {
|
||||
wmSubWindowSet(win, screen->mainwin);
|
||||
ED_area_overdraw(C);
|
||||
|
||||
@@ -613,8 +613,8 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
ED_screen_draw(win);
|
||||
|
||||
/* draw overlapping regions */
|
||||
for(ar=screen->regionbase.first; ar; ar= ar->next) {
|
||||
if(ar->swinid) {
|
||||
for (ar=screen->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->swinid) {
|
||||
CTX_wm_menu_set(C, ar);
|
||||
ED_region_do_draw(C, ar);
|
||||
CTX_wm_menu_set(C, NULL);
|
||||
@@ -624,13 +624,13 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
}
|
||||
|
||||
/* always draw, not only when screen tagged */
|
||||
if(win->gesture.first)
|
||||
if (win->gesture.first)
|
||||
wm_gesture_draw(win);
|
||||
|
||||
if(paintcursor && wm->paintcursors.first) {
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for(ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
if(ar->swinid == screen->subwinactive) {
|
||||
if (paintcursor && wm->paintcursors.first) {
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for (ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->swinid == screen->subwinactive) {
|
||||
CTX_wm_area_set(C, sa);
|
||||
CTX_wm_region_set(C, ar);
|
||||
|
||||
@@ -648,7 +648,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
|
||||
}
|
||||
|
||||
/* needs pixel coords in screen */
|
||||
if(wm->drags.first) {
|
||||
if (wm->drags.first) {
|
||||
wm_drags_draw(C, win, NULL);
|
||||
}
|
||||
|
||||
@@ -663,36 +663,36 @@ static int wm_draw_update_test_window(wmWindow *win)
|
||||
ARegion *ar;
|
||||
int do_draw= 0;
|
||||
|
||||
for(ar= win->screen->regionbase.first; ar; ar= ar->next) {
|
||||
if(ar->do_draw_overlay) {
|
||||
for (ar= win->screen->regionbase.first; ar; ar= ar->next) {
|
||||
if (ar->do_draw_overlay) {
|
||||
wm_tag_redraw_overlay(win, ar);
|
||||
ar->do_draw_overlay= 0;
|
||||
}
|
||||
if(ar->swinid && ar->do_draw)
|
||||
if (ar->swinid && ar->do_draw)
|
||||
do_draw= 1;
|
||||
}
|
||||
|
||||
for(sa= win->screen->areabase.first; sa; sa= sa->next) {
|
||||
for(ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
for (sa= win->screen->areabase.first; sa; sa= sa->next) {
|
||||
for (ar=sa->regionbase.first; ar; ar= ar->next) {
|
||||
wm_region_test_render_do_draw(sa, ar);
|
||||
|
||||
if(ar->swinid && ar->do_draw)
|
||||
if (ar->swinid && ar->do_draw)
|
||||
do_draw = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(do_draw)
|
||||
if (do_draw)
|
||||
return 1;
|
||||
|
||||
if(win->screen->do_refresh)
|
||||
if (win->screen->do_refresh)
|
||||
return 1;
|
||||
if(win->screen->do_draw)
|
||||
if (win->screen->do_draw)
|
||||
return 1;
|
||||
if(win->screen->do_draw_gesture)
|
||||
if (win->screen->do_draw_gesture)
|
||||
return 1;
|
||||
if(win->screen->do_draw_paintcursor)
|
||||
if (win->screen->do_draw_paintcursor)
|
||||
return 1;
|
||||
if(win->screen->do_draw_drag)
|
||||
if (win->screen->do_draw_drag)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
@@ -705,24 +705,24 @@ static int wm_automatic_draw_method(wmWindow *win)
|
||||
* for sculpting or drawing overlapping menus. For typically lower end cards
|
||||
* copy to texture is slow though and so we use overlap instead there. */
|
||||
|
||||
if(win->drawmethod == USER_DRAW_AUTOMATIC) {
|
||||
if (win->drawmethod == USER_DRAW_AUTOMATIC) {
|
||||
/* ATI opensource driver is known to be very slow at this */
|
||||
if(GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE))
|
||||
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE))
|
||||
return USER_DRAW_OVERLAP;
|
||||
/* also Intel drivers are slow */
|
||||
else if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_UNIX, GPU_DRIVER_ANY))
|
||||
else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_UNIX, GPU_DRIVER_ANY))
|
||||
return USER_DRAW_OVERLAP;
|
||||
else if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_ANY))
|
||||
else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_WIN, GPU_DRIVER_ANY))
|
||||
return USER_DRAW_OVERLAP_FLIP;
|
||||
else if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_ANY))
|
||||
else if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_ANY))
|
||||
return USER_DRAW_OVERLAP_FLIP;
|
||||
/* Windows software driver darkens color on each redraw */
|
||||
else if(GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE))
|
||||
else if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE))
|
||||
return USER_DRAW_OVERLAP_FLIP;
|
||||
else if(GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_UNIX, GPU_DRIVER_SOFTWARE))
|
||||
else if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_UNIX, GPU_DRIVER_SOFTWARE))
|
||||
return USER_DRAW_OVERLAP;
|
||||
/* drawing lower color depth again degrades colors each time */
|
||||
else if(GPU_color_depth() < 24)
|
||||
else if (GPU_color_depth() < 24)
|
||||
return USER_DRAW_OVERLAP;
|
||||
else
|
||||
return USER_DRAW_TRIPLE;
|
||||
@@ -734,8 +734,8 @@ static int wm_automatic_draw_method(wmWindow *win)
|
||||
void wm_tag_redraw_overlay(wmWindow *win, ARegion *ar)
|
||||
{
|
||||
/* for draw triple gestures, paint cursors don't need region redraw */
|
||||
if(ar && win) {
|
||||
if(wm_automatic_draw_method(win) != USER_DRAW_TRIPLE)
|
||||
if (ar && win) {
|
||||
if (wm_automatic_draw_method(win) != USER_DRAW_TRIPLE)
|
||||
ED_region_tag_redraw(ar);
|
||||
win->screen->do_draw_paintcursor= 1;
|
||||
}
|
||||
@@ -749,31 +749,31 @@ void wm_draw_update(bContext *C)
|
||||
|
||||
GPU_free_unused_buffers();
|
||||
|
||||
for(win= wm->windows.first; win; win= win->next) {
|
||||
if(win->drawmethod != U.wmdrawmethod) {
|
||||
for (win= wm->windows.first; win; win= win->next) {
|
||||
if (win->drawmethod != U.wmdrawmethod) {
|
||||
wm_draw_window_clear(win);
|
||||
win->drawmethod= U.wmdrawmethod;
|
||||
}
|
||||
|
||||
if(wm_draw_update_test_window(win)) {
|
||||
if (wm_draw_update_test_window(win)) {
|
||||
CTX_wm_window_set(C, win);
|
||||
|
||||
/* sets context window+screen */
|
||||
wm_window_make_drawable(C, win);
|
||||
|
||||
/* notifiers for screen redraw */
|
||||
if(win->screen->do_refresh)
|
||||
if (win->screen->do_refresh)
|
||||
ED_screen_refresh(wm, win);
|
||||
|
||||
drawmethod= wm_automatic_draw_method(win);
|
||||
|
||||
if(win->drawfail)
|
||||
if (win->drawfail)
|
||||
wm_method_draw_overlap_all(C, win, 0);
|
||||
else if(drawmethod == USER_DRAW_FULL)
|
||||
else if (drawmethod == USER_DRAW_FULL)
|
||||
wm_method_draw_full(C, win);
|
||||
else if(drawmethod == USER_DRAW_OVERLAP)
|
||||
else if (drawmethod == USER_DRAW_OVERLAP)
|
||||
wm_method_draw_overlap_all(C, win, 0);
|
||||
else if(drawmethod == USER_DRAW_OVERLAP_FLIP)
|
||||
else if (drawmethod == USER_DRAW_OVERLAP_FLIP)
|
||||
wm_method_draw_overlap_all(C, win, 1);
|
||||
else // if(drawmethod == USER_DRAW_TRIPLE)
|
||||
wm_method_draw_triple(C, win);
|
||||
@@ -796,13 +796,13 @@ void wm_draw_window_clear(wmWindow *win)
|
||||
ARegion *ar;
|
||||
int drawmethod= wm_automatic_draw_method(win);
|
||||
|
||||
if(drawmethod == USER_DRAW_TRIPLE)
|
||||
if (drawmethod == USER_DRAW_TRIPLE)
|
||||
wm_draw_triple_free(win);
|
||||
|
||||
/* clear screen swap flags */
|
||||
if(screen) {
|
||||
for(sa= screen->areabase.first; sa; sa= sa->next)
|
||||
for(ar=sa->regionbase.first; ar; ar= ar->next)
|
||||
if (screen) {
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next)
|
||||
for (ar=sa->regionbase.first; ar; ar= ar->next)
|
||||
ar->swap= WIN_NONE_OK;
|
||||
|
||||
screen->swap= WIN_NONE_OK;
|
||||
@@ -813,7 +813,7 @@ void wm_draw_region_clear(wmWindow *win, ARegion *ar)
|
||||
{
|
||||
int drawmethod= wm_automatic_draw_method(win);
|
||||
|
||||
if(ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP))
|
||||
if (ELEM(drawmethod, USER_DRAW_OVERLAP, USER_DRAW_OVERLAP_FLIP))
|
||||
wm_flush_regions_down(win->screen, &ar->winrct);
|
||||
|
||||
win->screen->do_draw= 1;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -138,11 +138,11 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
|
||||
|
||||
/* first wrap up running stuff */
|
||||
/* code copied from wm_init_exit.c */
|
||||
for(wm= wmlist->first; wm; wm= wm->id.next) {
|
||||
for (wm= wmlist->first; wm; wm= wm->id.next) {
|
||||
|
||||
WM_jobs_stop_all(wm);
|
||||
|
||||
for(win= wm->windows.first; win; win= win->next) {
|
||||
for (win= wm->windows.first; win; win= win->next) {
|
||||
|
||||
CTX_wm_window_set(C, win); /* needed by operator close callbacks */
|
||||
WM_event_remove_handlers(C, &win->handlers);
|
||||
@@ -158,13 +158,13 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
|
||||
|
||||
/* just had return; here from r12991, this code could just get removed?*/
|
||||
#if 0
|
||||
if(wm==NULL) return;
|
||||
if(G.fileflags & G_FILE_NO_UI) return;
|
||||
if (wm==NULL) return;
|
||||
if (G.fileflags & G_FILE_NO_UI) return;
|
||||
|
||||
/* we take apart the used screens from non-active window */
|
||||
for(win= wm->windows.first; win; win= win->next) {
|
||||
for (win= wm->windows.first; win; win= win->next) {
|
||||
BLI_strncpy(win->screenname, win->screen->id.name, MAX_ID_NAME);
|
||||
if(win!=wm->winactive) {
|
||||
if (win!=wm->winactive) {
|
||||
BLI_remlink(&G.main->screen, win->screen);
|
||||
//BLI_addtail(screenbase, win->screen);
|
||||
}
|
||||
@@ -185,8 +185,8 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
|
||||
wmWindow *oldwin, *win;
|
||||
|
||||
/* cases 1 and 2 */
|
||||
if(oldwmlist->first==NULL) {
|
||||
if(G.main->wm.first); /* nothing todo */
|
||||
if (oldwmlist->first==NULL) {
|
||||
if (G.main->wm.first); /* nothing todo */
|
||||
else
|
||||
wm_add_default(C);
|
||||
}
|
||||
@@ -194,18 +194,18 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
|
||||
/* cases 3 and 4 */
|
||||
|
||||
/* we've read file without wm..., keep current one entirely alive */
|
||||
if(G.main->wm.first==NULL) {
|
||||
if (G.main->wm.first==NULL) {
|
||||
bScreen *screen= NULL;
|
||||
|
||||
/* when loading without UI, no matching needed */
|
||||
if(!(G.fileflags & G_FILE_NO_UI) && (screen= CTX_wm_screen(C))) {
|
||||
if (!(G.fileflags & G_FILE_NO_UI) && (screen= CTX_wm_screen(C))) {
|
||||
|
||||
/* match oldwm to new dbase, only old files */
|
||||
for(wm= oldwmlist->first; wm; wm= wm->id.next) {
|
||||
for (wm= oldwmlist->first; wm; wm= wm->id.next) {
|
||||
|
||||
for(win= wm->windows.first; win; win= win->next) {
|
||||
for (win= wm->windows.first; win; win= win->next) {
|
||||
/* all windows get active screen from file */
|
||||
if(screen->winid==0)
|
||||
if (screen->winid==0)
|
||||
win->screen= screen;
|
||||
else
|
||||
win->screen= ED_screen_duplicate(win, screen);
|
||||
@@ -243,16 +243,16 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
|
||||
wm->winactive= NULL;
|
||||
|
||||
/* only first wm in list has ghostwins */
|
||||
for(win= wm->windows.first; win; win= win->next) {
|
||||
for(oldwin= oldwm->windows.first; oldwin; oldwin= oldwin->next) {
|
||||
for (win= wm->windows.first; win; win= win->next) {
|
||||
for (oldwin= oldwm->windows.first; oldwin; oldwin= oldwin->next) {
|
||||
|
||||
if(oldwin->winid == win->winid ) {
|
||||
if (oldwin->winid == win->winid ) {
|
||||
win->ghostwin= oldwin->ghostwin;
|
||||
win->active= oldwin->active;
|
||||
if(win->active)
|
||||
if (win->active)
|
||||
wm->winactive= win;
|
||||
|
||||
if(!G.background) /* file loading in background mode still calls this */
|
||||
if (!G.background) /* file loading in background mode still calls this */
|
||||
GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */
|
||||
|
||||
oldwin->ghostwin= NULL;
|
||||
@@ -281,12 +281,12 @@ static void wm_init_userdef(bContext *C)
|
||||
sound_init(CTX_data_main(C));
|
||||
|
||||
/* needed so loading a file from the command line respects user-pref [#26156] */
|
||||
if(U.flag & USER_FILENOUI) G.fileflags |= G_FILE_NO_UI;
|
||||
if (U.flag & USER_FILENOUI) G.fileflags |= G_FILE_NO_UI;
|
||||
else G.fileflags &= ~G_FILE_NO_UI;
|
||||
|
||||
/* set the python auto-execute setting from user prefs */
|
||||
/* enabled by default, unless explicitly enabled in the command line which overrides */
|
||||
if((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) {
|
||||
if ((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) {
|
||||
if ((U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0) G.f |= G_SCRIPT_AUTOEXEC;
|
||||
else G.f &= ~G_SCRIPT_AUTOEXEC;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name)
|
||||
else {
|
||||
//XXX waitcursor(1);
|
||||
#if 0 /* historic stuff - no longer used */
|
||||
if(is_foo_format(name)) {
|
||||
if (is_foo_format(name)) {
|
||||
read_foo(name);
|
||||
retval= BKE_READ_EXOTIC_OK_OTHER;
|
||||
}
|
||||
@@ -380,7 +380,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
|
||||
|
||||
/* this flag is initialized by the operator but overwritten on read.
|
||||
* need to re-enable it here else drivers + registered scripts wont work. */
|
||||
if(G.f != G_f) {
|
||||
if (G.f != G_f) {
|
||||
const int flags_keep= (G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF);
|
||||
G.f= (G.f & ~flags_keep) | (G_f & flags_keep);
|
||||
}
|
||||
@@ -391,14 +391,14 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
|
||||
|
||||
// XXX mainwindow_set_filename_to_title(G.main->name);
|
||||
|
||||
if(retval == BKE_READ_FILE_OK_USERPREFS) {
|
||||
if (retval == BKE_READ_FILE_OK_USERPREFS) {
|
||||
/* in case a userdef is read from regular .blend */
|
||||
wm_init_userdef(C);
|
||||
}
|
||||
|
||||
if (retval != BKE_READ_FILE_FAIL) {
|
||||
G.relbase_valid = 1;
|
||||
if(!G.background) /* assume automated tasks with background, don't write recent file list */
|
||||
if (!G.background) /* assume automated tasks with background, don't write recent file list */
|
||||
write_history();
|
||||
}
|
||||
|
||||
@@ -451,16 +451,16 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports)
|
||||
BKE_reset_undo();
|
||||
BKE_write_undo(C, "original"); /* save current state */
|
||||
}
|
||||
else if(retval == BKE_READ_EXOTIC_OK_OTHER)
|
||||
else if (retval == BKE_READ_EXOTIC_OK_OTHER)
|
||||
BKE_write_undo(C, "Import file");
|
||||
else if(retval == BKE_READ_EXOTIC_FAIL_OPEN) {
|
||||
else if (retval == BKE_READ_EXOTIC_FAIL_OPEN) {
|
||||
BKE_reportf(reports, RPT_ERROR, IFACE_("Can't read file: \"%s\", %s."), filepath,
|
||||
errno ? strerror(errno) : IFACE_("Unable to open the file"));
|
||||
}
|
||||
else if(retval == BKE_READ_EXOTIC_FAIL_FORMAT) {
|
||||
else if (retval == BKE_READ_EXOTIC_FAIL_FORMAT) {
|
||||
BKE_reportf(reports, RPT_ERROR, IFACE_("File format is not supported in file: \"%s\"."), filepath);
|
||||
}
|
||||
else if(retval == BKE_READ_EXOTIC_FAIL_PATH) {
|
||||
else if (retval == BKE_READ_EXOTIC_FAIL_PATH) {
|
||||
BKE_reportf(reports, RPT_ERROR, IFACE_("File path invalid: \"%s\"."), filepath);
|
||||
}
|
||||
else {
|
||||
@@ -489,7 +489,8 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
|
||||
char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL);
|
||||
if (cfgdir) {
|
||||
BLI_make_file_string(G.main->name, tstr, cfgdir, BLENDER_STARTUP_FILE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
tstr[0] = '\0';
|
||||
from_memory = 1;
|
||||
}
|
||||
@@ -504,12 +505,12 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
|
||||
if (!from_memory && BLI_exists(tstr)) {
|
||||
success = (BKE_read_file(C, tstr, NULL) != BKE_READ_FILE_FAIL);
|
||||
|
||||
if(U.themes.first==NULL) {
|
||||
if (U.themes.first==NULL) {
|
||||
printf("\nError: No valid "STRINGIFY(BLENDER_STARTUP_FILE)", fall back to built-in default.\n\n");
|
||||
success = 0;
|
||||
}
|
||||
}
|
||||
if(success==0) {
|
||||
if (success==0) {
|
||||
success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL);
|
||||
if (wmbase.first == NULL) wm_clear_default_size(C);
|
||||
|
||||
@@ -551,7 +552,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
|
||||
DAG_on_visible_update(CTX_data_main(C), TRUE);
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
if(CTX_py_init_get(C)) {
|
||||
if (CTX_py_init_get(C)) {
|
||||
/* sync addons, these may have changed from the defaults */
|
||||
BPY_string_exec(C, "__import__('addon_utils').reset_all()");
|
||||
|
||||
@@ -564,7 +565,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory
|
||||
WM_event_add_notifier(C, NC_WM|ND_FILEREAD, NULL);
|
||||
|
||||
/* in background mode the scene will stay NULL */
|
||||
if(!G.background) {
|
||||
if (!G.background) {
|
||||
CTX_wm_window_set(C, NULL); /* exits queues */
|
||||
}
|
||||
|
||||
@@ -619,14 +620,14 @@ static void write_history(void)
|
||||
|
||||
/* will be NULL in background mode */
|
||||
user_config_dir = BLI_get_folder_create(BLENDER_USER_CONFIG, NULL);
|
||||
if(!user_config_dir)
|
||||
if (!user_config_dir)
|
||||
return;
|
||||
|
||||
BLI_make_file_string("/", name, user_config_dir, BLENDER_HISTORY_FILE);
|
||||
|
||||
recent = G.recent_files.first;
|
||||
/* refresh recent-files.txt of recent opened files, when current file was changed */
|
||||
if(!(recent) || (BLI_path_cmp(recent->filepath, G.main->name)!=0)) {
|
||||
if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name)!=0)) {
|
||||
fp= BLI_fopen(name, "w");
|
||||
if (fp) {
|
||||
/* add current file to the beginning of list */
|
||||
@@ -638,7 +639,7 @@ static void write_history(void)
|
||||
recent = recent->next;
|
||||
i=1;
|
||||
/* write rest of recent opened files to recent-files.txt */
|
||||
while((i<U.recent_files) && (recent)){
|
||||
while ((i<U.recent_files) && (recent)) {
|
||||
/* this prevents to have duplicities in list */
|
||||
if (BLI_path_cmp(recent->filepath, G.main->name)!=0) {
|
||||
fprintf(fp, "%s\n", recent->filepath);
|
||||
@@ -670,7 +671,7 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt)
|
||||
*thumb_pt= NULL;
|
||||
|
||||
/* scene can be NULL if running a script at startup and calling the save operator */
|
||||
if(G.background || scene==NULL || scene->camera==NULL)
|
||||
if (G.background || scene==NULL || scene->camera==NULL)
|
||||
return NULL;
|
||||
|
||||
/* gets scaled to BLEN_THUMB_SIZE */
|
||||
@@ -678,7 +679,7 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt)
|
||||
BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2,
|
||||
IB_rect, OB_SOLID, FALSE, err_out);
|
||||
|
||||
if(ibuf) {
|
||||
if (ibuf) {
|
||||
float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp);
|
||||
|
||||
/* dirty oversampling */
|
||||
@@ -715,7 +716,7 @@ int write_crash_blend(void)
|
||||
|
||||
BLI_strncpy(path, G.main->name, sizeof(path));
|
||||
BLI_replace_extension(path, sizeof(path), "_crash.blend");
|
||||
if(BLO_write_file(G.main, path, fileflags, NULL, NULL)) {
|
||||
if (BLO_write_file(G.main, path, fileflags, NULL, NULL)) {
|
||||
printf("written: %s\n", path);
|
||||
return 1;
|
||||
}
|
||||
@@ -760,7 +761,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
|
||||
|
||||
/* blend file thumbnail */
|
||||
/* save before exit_editmode, otherwise derivedmeshes for shared data corrupt #27765) */
|
||||
if(U.flag & USER_SAVE_PREVIEWS) {
|
||||
if (U.flag & USER_SAVE_PREVIEWS) {
|
||||
ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb);
|
||||
}
|
||||
|
||||
@@ -781,21 +782,21 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
|
||||
fileflags |= G_FILE_HISTORY; /* write file history */
|
||||
|
||||
if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) {
|
||||
if(!copy) {
|
||||
if (!copy) {
|
||||
G.relbase_valid = 1;
|
||||
BLI_strncpy(G.main->name, filepath, sizeof(G.main->name)); /* is guaranteed current file */
|
||||
|
||||
G.save_over = 1; /* disable untitled.blend convention */
|
||||
}
|
||||
|
||||
if(fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS;
|
||||
if (fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS;
|
||||
else G.fileflags &= ~G_FILE_COMPRESS;
|
||||
|
||||
if(fileflags & G_FILE_AUTOPLAY) G.fileflags |= G_FILE_AUTOPLAY;
|
||||
if (fileflags & G_FILE_AUTOPLAY) G.fileflags |= G_FILE_AUTOPLAY;
|
||||
else G.fileflags &= ~G_FILE_AUTOPLAY;
|
||||
|
||||
/* prevent background mode scripts from clobbering history */
|
||||
if(!G.background) {
|
||||
if (!G.background) {
|
||||
write_history();
|
||||
}
|
||||
|
||||
@@ -807,11 +808,11 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
|
||||
IMB_freeImBuf(ibuf_thumb);
|
||||
}
|
||||
|
||||
if(thumb) MEM_freeN(thumb);
|
||||
if (thumb) MEM_freeN(thumb);
|
||||
}
|
||||
else {
|
||||
if(ibuf_thumb) IMB_freeImBuf(ibuf_thumb);
|
||||
if(thumb) MEM_freeN(thumb);
|
||||
if (ibuf_thumb) IMB_freeImBuf(ibuf_thumb);
|
||||
if (thumb) MEM_freeN(thumb);
|
||||
|
||||
WM_cursor_wait(0);
|
||||
return -1;
|
||||
@@ -831,7 +832,7 @@ int WM_write_homefile(bContext *C, wmOperator *op)
|
||||
int fileflags;
|
||||
|
||||
/* check current window and close it if temp */
|
||||
if(win->screen->temp)
|
||||
if (win->screen->temp)
|
||||
wm_window_close(C, wm, win);
|
||||
|
||||
/* update keymaps in user preferences */
|
||||
@@ -843,7 +844,7 @@ int WM_write_homefile(bContext *C, wmOperator *op)
|
||||
/* force save as regular blend file */
|
||||
fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY);
|
||||
|
||||
if(BLO_write_file(CTX_data_main(C), filepath, fileflags, op->reports, NULL) == 0) {
|
||||
if (BLO_write_file(CTX_data_main(C), filepath, fileflags, op->reports, NULL) == 0) {
|
||||
printf("fail\n");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -889,7 +890,7 @@ void WM_autosave_init(wmWindowManager *wm)
|
||||
{
|
||||
wm_autosave_timer_ended(wm);
|
||||
|
||||
if(U.flag & USER_AUTOSAVE)
|
||||
if (U.flag & USER_AUTOSAVE)
|
||||
wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, U.savetime*60.0);
|
||||
}
|
||||
|
||||
@@ -903,9 +904,9 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
|
||||
WM_event_remove_timer(wm, NULL, wm->autosavetimer);
|
||||
|
||||
/* if a modal operator is running, don't autosave, but try again in 10 seconds */
|
||||
for(win=wm->windows.first; win; win=win->next) {
|
||||
for(handler=win->modalhandlers.first; handler; handler=handler->next) {
|
||||
if(handler->op) {
|
||||
for (win=wm->windows.first; win; win=win->next) {
|
||||
for (handler=win->modalhandlers.first; handler; handler=handler->next) {
|
||||
if (handler->op) {
|
||||
wm->autosavetimer= WM_event_add_timer(wm, NULL, TIMERAUTOSAVE, 10.0);
|
||||
return;
|
||||
}
|
||||
@@ -926,7 +927,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w
|
||||
|
||||
void wm_autosave_timer_ended(wmWindowManager *wm)
|
||||
{
|
||||
if(wm->autosavetimer) {
|
||||
if (wm->autosavetimer) {
|
||||
WM_event_remove_timer(wm, NULL, wm->autosavetimer);
|
||||
wm->autosavetimer= NULL;
|
||||
}
|
||||
@@ -938,12 +939,12 @@ void wm_autosave_delete(void)
|
||||
|
||||
wm_autosave_location(filename);
|
||||
|
||||
if(BLI_exists(filename)) {
|
||||
if (BLI_exists(filename)) {
|
||||
char str[FILE_MAX];
|
||||
BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend");
|
||||
|
||||
/* if global undo; remove tempsave, otherwise rename */
|
||||
if(U.uiflag & USER_GLOBALUNDO) BLI_delete(filename, 0, 0);
|
||||
if (U.uiflag & USER_GLOBALUNDO) BLI_delete(filename, 0, 0);
|
||||
else BLI_rename(filename, str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,13 +81,14 @@ wmGesture *WM_gesture_new(bContext *C, wmEvent *event, int type)
|
||||
gesture->customdata= rect;
|
||||
rect->xmin = event->x - sx;
|
||||
rect->ymin = event->y - sy;
|
||||
if(type==WM_GESTURE_CIRCLE) {
|
||||
if (type==WM_GESTURE_CIRCLE) {
|
||||
#ifdef GESTURE_MEMORY
|
||||
rect->xmax = circle_select_size;
|
||||
#else
|
||||
rect->xmax = 25; // XXX temp
|
||||
#endif
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
rect->xmax = event->x - sx;
|
||||
rect->ymax = event->y - sy;
|
||||
}
|
||||
@@ -108,7 +109,7 @@ void WM_gesture_end(bContext *C, wmGesture *gesture)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
|
||||
if(win->tweak==gesture)
|
||||
if (win->tweak==gesture)
|
||||
win->tweak= NULL;
|
||||
BLI_remlink(&win->gesture, gesture);
|
||||
MEM_freeN(gesture->customdata);
|
||||
@@ -119,7 +120,7 @@ void WM_gestures_remove(bContext *C)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
|
||||
while(win->gesture.first)
|
||||
while (win->gesture.first)
|
||||
WM_gesture_end(C, win->gesture.first);
|
||||
}
|
||||
|
||||
@@ -127,32 +128,32 @@ void WM_gestures_remove(bContext *C)
|
||||
/* tweak and line gestures */
|
||||
int wm_gesture_evaluate(wmGesture *gesture)
|
||||
{
|
||||
if(gesture->type==WM_GESTURE_TWEAK) {
|
||||
if (gesture->type==WM_GESTURE_TWEAK) {
|
||||
rcti *rect= gesture->customdata;
|
||||
int dx= rect->xmax - rect->xmin;
|
||||
int dy= rect->ymax - rect->ymin;
|
||||
if(ABS(dx)+ABS(dy) > U.tweak_threshold) {
|
||||
if (ABS(dx)+ABS(dy) > U.tweak_threshold) {
|
||||
int theta= (int)floor(4.0f*atan2f((float)dy, (float)dx)/(float)M_PI + 0.5f);
|
||||
int val= EVT_GESTURE_W;
|
||||
|
||||
if(theta==0) val= EVT_GESTURE_E;
|
||||
else if(theta==1) val= EVT_GESTURE_NE;
|
||||
else if(theta==2) val= EVT_GESTURE_N;
|
||||
else if(theta==3) val= EVT_GESTURE_NW;
|
||||
else if(theta==-1) val= EVT_GESTURE_SE;
|
||||
else if(theta==-2) val= EVT_GESTURE_S;
|
||||
else if(theta==-3) val= EVT_GESTURE_SW;
|
||||
if (theta==0) val= EVT_GESTURE_E;
|
||||
else if (theta==1) val= EVT_GESTURE_NE;
|
||||
else if (theta==2) val= EVT_GESTURE_N;
|
||||
else if (theta==3) val= EVT_GESTURE_NW;
|
||||
else if (theta==-1) val= EVT_GESTURE_SE;
|
||||
else if (theta==-2) val= EVT_GESTURE_S;
|
||||
else if (theta==-3) val= EVT_GESTURE_SW;
|
||||
|
||||
#if 0
|
||||
/* debug */
|
||||
if(val==1) printf("tweak north\n");
|
||||
if(val==2) printf("tweak north-east\n");
|
||||
if(val==3) printf("tweak east\n");
|
||||
if(val==4) printf("tweak south-east\n");
|
||||
if(val==5) printf("tweak south\n");
|
||||
if(val==6) printf("tweak south-west\n");
|
||||
if(val==7) printf("tweak west\n");
|
||||
if(val==8) printf("tweak north-west\n");
|
||||
if (val==1) printf("tweak north\n");
|
||||
if (val==2) printf("tweak north-east\n");
|
||||
if (val==3) printf("tweak east\n");
|
||||
if (val==4) printf("tweak south-east\n");
|
||||
if (val==5) printf("tweak south\n");
|
||||
if (val==6) printf("tweak south-west\n");
|
||||
if (val==7) printf("tweak west\n");
|
||||
if (val==8) printf("tweak north-west\n");
|
||||
#endif
|
||||
return val;
|
||||
}
|
||||
@@ -250,7 +251,7 @@ static void draw_filled_lasso(wmGesture *gt)
|
||||
}
|
||||
|
||||
/* highly unlikely this will fail, but could crash if (gt->points == 0) */
|
||||
if(firstv) {
|
||||
if (firstv) {
|
||||
BLI_addfilledge(firstv, v);
|
||||
BLI_edgefill(0);
|
||||
|
||||
@@ -280,9 +281,9 @@ static void wm_gesture_draw_lasso(wmGesture *gt)
|
||||
glColor3ub(96, 96, 96);
|
||||
glLineStipple(1, 0xAAAA);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for(i=0; i<gt->points; i++, lasso+=2)
|
||||
for (i=0; i<gt->points; i++, lasso+=2)
|
||||
glVertex2sv(lasso);
|
||||
if(gt->type==WM_GESTURE_LASSO)
|
||||
if (gt->type==WM_GESTURE_LASSO)
|
||||
glVertex2sv((short *)gt->customdata);
|
||||
glEnd();
|
||||
|
||||
@@ -290,9 +291,9 @@ static void wm_gesture_draw_lasso(wmGesture *gt)
|
||||
glLineStipple(1, 0x5555);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
lasso= (short *)gt->customdata;
|
||||
for(i=0; i<gt->points; i++, lasso+=2)
|
||||
for (i=0; i<gt->points; i++, lasso+=2)
|
||||
glVertex2sv(lasso);
|
||||
if(gt->type==WM_GESTURE_LASSO)
|
||||
if (gt->type==WM_GESTURE_LASSO)
|
||||
glVertex2sv((short *)gt->customdata);
|
||||
glEnd();
|
||||
|
||||
@@ -322,27 +323,27 @@ void wm_gesture_draw(wmWindow *win)
|
||||
{
|
||||
wmGesture *gt= (wmGesture *)win->gesture.first;
|
||||
|
||||
for(; gt; gt= gt->next) {
|
||||
for (; gt; gt= gt->next) {
|
||||
/* all in subwindow space */
|
||||
wmSubWindowSet(win, gt->swinid);
|
||||
|
||||
if(gt->type==WM_GESTURE_RECT)
|
||||
if (gt->type==WM_GESTURE_RECT)
|
||||
wm_gesture_draw_rect(gt);
|
||||
// else if(gt->type==WM_GESTURE_TWEAK)
|
||||
// else if (gt->type==WM_GESTURE_TWEAK)
|
||||
// wm_gesture_draw_line(gt);
|
||||
else if(gt->type==WM_GESTURE_CIRCLE)
|
||||
else if (gt->type==WM_GESTURE_CIRCLE)
|
||||
wm_gesture_draw_circle(gt);
|
||||
else if(gt->type==WM_GESTURE_CROSS_RECT) {
|
||||
if(gt->mode==1)
|
||||
else if (gt->type==WM_GESTURE_CROSS_RECT) {
|
||||
if (gt->mode==1)
|
||||
wm_gesture_draw_rect(gt);
|
||||
else
|
||||
wm_gesture_draw_cross(win, gt);
|
||||
}
|
||||
else if(gt->type==WM_GESTURE_LINES)
|
||||
else if (gt->type==WM_GESTURE_LINES)
|
||||
wm_gesture_draw_lasso(gt);
|
||||
else if(gt->type==WM_GESTURE_LASSO)
|
||||
else if (gt->type==WM_GESTURE_LASSO)
|
||||
wm_gesture_draw_lasso(gt);
|
||||
else if(gt->type==WM_GESTURE_STRAIGHTLINE)
|
||||
else if (gt->type==WM_GESTURE_STRAIGHTLINE)
|
||||
wm_gesture_draw_line(gt);
|
||||
}
|
||||
}
|
||||
@@ -353,7 +354,7 @@ void wm_gesture_tag_redraw(bContext *C)
|
||||
bScreen *screen= CTX_wm_screen(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
|
||||
if(screen)
|
||||
if (screen)
|
||||
screen->do_draw_gesture= 1;
|
||||
|
||||
wm_tag_redraw_overlay(win, ar);
|
||||
|
||||
@@ -193,7 +193,7 @@ void WM_init(bContext *C, int argc, const char **argv)
|
||||
|
||||
/* allow a path of "", this is what happens when making a new file */
|
||||
#if 0
|
||||
if(G.main->name[0] == 0)
|
||||
if (G.main->name[0] == 0)
|
||||
BLI_make_file_string("/", G.main->name, BLI_getDefaultDocumentFolder(), "untitled.blend");
|
||||
#endif
|
||||
|
||||
@@ -202,11 +202,11 @@ void WM_init(bContext *C, int argc, const char **argv)
|
||||
|
||||
void WM_init_splash(bContext *C)
|
||||
{
|
||||
if((U.uiflag & USER_SPLASH_DISABLE) == 0) {
|
||||
if ((U.uiflag & USER_SPLASH_DISABLE) == 0) {
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmWindow *prevwin= CTX_wm_window(C);
|
||||
|
||||
if(wm->windows.first) {
|
||||
if (wm->windows.first) {
|
||||
CTX_wm_window_set(C, wm->windows.first);
|
||||
WM_operator_name_call(C, "WM_OT_splash", WM_OP_INVOKE_DEFAULT, NULL);
|
||||
CTX_wm_window_set(C, prevwin);
|
||||
@@ -233,7 +233,7 @@ int WM_init_game(bContext *C)
|
||||
win = wm->windows.first;
|
||||
|
||||
//first to get a valid window
|
||||
if(win)
|
||||
if (win)
|
||||
CTX_wm_window_set(C, win);
|
||||
|
||||
sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0);
|
||||
@@ -247,25 +247,25 @@ int WM_init_game(bContext *C)
|
||||
CTX_wm_region_set(C, ar);
|
||||
|
||||
/* disable quad view */
|
||||
if(ar->alignment == RGN_ALIGN_QSPLIT)
|
||||
if (ar->alignment == RGN_ALIGN_QSPLIT)
|
||||
WM_operator_name_call(C, "SCREEN_OT_region_quadview", WM_OP_EXEC_DEFAULT, NULL);
|
||||
|
||||
/* toolbox, properties panel and header are hidden */
|
||||
for(arhide=sa->regionbase.first; arhide; arhide=arhide->next) {
|
||||
if(arhide->regiontype != RGN_TYPE_WINDOW) {
|
||||
if(!(arhide->flag & RGN_FLAG_HIDDEN)) {
|
||||
for (arhide=sa->regionbase.first; arhide; arhide=arhide->next) {
|
||||
if (arhide->regiontype != RGN_TYPE_WINDOW) {
|
||||
if (!(arhide->flag & RGN_FLAG_HIDDEN)) {
|
||||
ED_region_toggle_hidden(C, arhide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* full screen the area */
|
||||
if(!sa->full) {
|
||||
if (!sa->full) {
|
||||
ED_screen_full_toggle(C, win, sa);
|
||||
}
|
||||
|
||||
/* Fullscreen */
|
||||
if((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) {
|
||||
if ((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) {
|
||||
WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", WM_OP_EXEC_DEFAULT, NULL);
|
||||
wm_get_screensize(&ar->winrct.xmax, &ar->winrct.ymax);
|
||||
ar->winx = ar->winrct.xmax + 1;
|
||||
@@ -308,7 +308,7 @@ static void free_openrecent(void)
|
||||
{
|
||||
struct RecentFile *recent;
|
||||
|
||||
for(recent = G.recent_files.first; recent; recent=recent->next)
|
||||
for (recent = G.recent_files.first; recent; recent=recent->next)
|
||||
MEM_freeN(recent->filepath);
|
||||
|
||||
BLI_freelistN(&(G.recent_files));
|
||||
@@ -335,11 +335,11 @@ void WM_exit_ext(bContext *C, const short do_python)
|
||||
/* first wrap up running stuff, we assume only the active WM is running */
|
||||
/* modal handlers are on window level freed, others too? */
|
||||
/* note; same code copied in wm_files.c */
|
||||
if(C && CTX_wm_manager(C)) {
|
||||
if (C && CTX_wm_manager(C)) {
|
||||
|
||||
WM_jobs_stop_all(CTX_wm_manager(C));
|
||||
|
||||
for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
|
||||
for (win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
|
||||
|
||||
CTX_wm_window_set(C, win); /* needed by operator close callbacks */
|
||||
WM_event_remove_handlers(C, &win->handlers);
|
||||
@@ -352,7 +352,7 @@ void WM_exit_ext(bContext *C, const short do_python)
|
||||
WM_menutype_free();
|
||||
|
||||
/* all non-screen and non-space stuff editors did, like editmode */
|
||||
if(C)
|
||||
if (C)
|
||||
ED_editors_exit(C);
|
||||
|
||||
// XXX
|
||||
@@ -368,7 +368,7 @@ void WM_exit_ext(bContext *C, const short do_python)
|
||||
|
||||
ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */
|
||||
|
||||
if(C && CTX_wm_manager(C))
|
||||
if (C && CTX_wm_manager(C))
|
||||
wm_free_reports(C); /* before free_blender! - since the ListBases get freed there */
|
||||
|
||||
seq_free_clipboard(); /* sequencer.c */
|
||||
@@ -399,7 +399,7 @@ void WM_exit_ext(bContext *C, const short do_python)
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
/* option not to close python so we can use 'atexit' */
|
||||
if(do_python) {
|
||||
if (do_python) {
|
||||
/* XXX - old note */
|
||||
/* before free_blender so py's gc happens while library still exists */
|
||||
/* needed at least for a rare sigsegv that can happen in pydrivers */
|
||||
@@ -438,7 +438,7 @@ void WM_exit_ext(bContext *C, const short do_python)
|
||||
|
||||
GHOST_DisposeSystemPaths();
|
||||
|
||||
if(MEM_get_memory_blocks_in_use()!=0) {
|
||||
if (MEM_get_memory_blocks_in_use()!=0) {
|
||||
printf("Error: Not freed memory blocks: %d\n", MEM_get_memory_blocks_in_use());
|
||||
MEM_printmemlist();
|
||||
}
|
||||
@@ -448,7 +448,7 @@ void WM_exit_ext(bContext *C, const short do_python)
|
||||
|
||||
#ifdef WIN32
|
||||
/* ask user to press enter when in debug mode */
|
||||
if(G.f & G_DEBUG) {
|
||||
if (G.f & G_DEBUG) {
|
||||
printf("press enter key to exit...\n\n");
|
||||
getchar();
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name)
|
||||
{
|
||||
wmJob *steve, *found=NULL;
|
||||
|
||||
for(steve= wm->jobs.first; steve; steve= steve->next)
|
||||
if(steve->owner==owner) {
|
||||
for (steve= wm->jobs.first; steve; steve= steve->next)
|
||||
if (steve->owner==owner) {
|
||||
found= steve;
|
||||
if (name && strcmp(steve->name, name)==0)
|
||||
return steve;
|
||||
@@ -155,7 +155,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *
|
||||
{
|
||||
wmJob *steve= wm_job_find(wm, owner, name);
|
||||
|
||||
if(steve==NULL) {
|
||||
if (steve==NULL) {
|
||||
steve= MEM_callocN(sizeof(wmJob), "new job");
|
||||
|
||||
BLI_addtail(&wm->jobs, steve);
|
||||
@@ -173,9 +173,9 @@ int WM_jobs_test(wmWindowManager *wm, void *owner)
|
||||
{
|
||||
wmJob *steve;
|
||||
|
||||
for(steve= wm->jobs.first; steve; steve= steve->next)
|
||||
if(steve->owner==owner)
|
||||
if(steve->running)
|
||||
for (steve= wm->jobs.first; steve; steve= steve->next)
|
||||
if (steve->owner==owner)
|
||||
if (steve->running)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -209,7 +209,8 @@ void* WM_jobs_get_customdata(wmJob * steve)
|
||||
{
|
||||
if (!steve->customdata) {
|
||||
return steve->run_customdata;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return steve->customdata;
|
||||
}
|
||||
}
|
||||
@@ -217,13 +218,13 @@ void* WM_jobs_get_customdata(wmJob * steve)
|
||||
void WM_jobs_customdata(wmJob *steve, void *customdata, void (*free)(void *))
|
||||
{
|
||||
/* pending job? just free */
|
||||
if(steve->customdata)
|
||||
if (steve->customdata)
|
||||
steve->free(steve->customdata);
|
||||
|
||||
steve->customdata= customdata;
|
||||
steve->free= free;
|
||||
|
||||
if(steve->running) {
|
||||
if (steve->running) {
|
||||
/* signal job to end */
|
||||
steve->stop= 1;
|
||||
}
|
||||
@@ -265,30 +266,30 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test)
|
||||
int suspend= 0;
|
||||
|
||||
/* job added with suspend flag, we wait 1 timer step before activating it */
|
||||
if(test->flag & WM_JOB_SUSPEND) {
|
||||
if (test->flag & WM_JOB_SUSPEND) {
|
||||
suspend= 1;
|
||||
test->flag &= ~WM_JOB_SUSPEND;
|
||||
}
|
||||
else {
|
||||
/* check other jobs */
|
||||
for(steve= wm->jobs.first; steve; steve= steve->next) {
|
||||
for (steve= wm->jobs.first; steve; steve= steve->next) {
|
||||
/* obvious case, no test needed */
|
||||
if(steve==test || !steve->running) continue;
|
||||
if (steve==test || !steve->running) continue;
|
||||
|
||||
/* if new job is not render, then check for same startjob */
|
||||
if(0==(test->flag & WM_JOB_EXCL_RENDER))
|
||||
if(steve->startjob!=test->startjob)
|
||||
if (0==(test->flag & WM_JOB_EXCL_RENDER))
|
||||
if (steve->startjob!=test->startjob)
|
||||
continue;
|
||||
|
||||
/* if new job is render, any render job should be stopped */
|
||||
if(test->flag & WM_JOB_EXCL_RENDER)
|
||||
if(0==(steve->flag & WM_JOB_EXCL_RENDER))
|
||||
if (test->flag & WM_JOB_EXCL_RENDER)
|
||||
if (0==(steve->flag & WM_JOB_EXCL_RENDER))
|
||||
continue;
|
||||
|
||||
suspend= 1;
|
||||
|
||||
/* if this job has higher priority, stop others */
|
||||
if(test->flag & WM_JOB_PRIORITY) {
|
||||
if (test->flag & WM_JOB_PRIORITY) {
|
||||
steve->stop= 1;
|
||||
// printf("job stopped: %s\n", steve->name);
|
||||
}
|
||||
@@ -304,18 +305,18 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test)
|
||||
/* if different owner starts existing startjob, it suspends itself */
|
||||
void WM_jobs_start(wmWindowManager *wm, wmJob *steve)
|
||||
{
|
||||
if(steve->running) {
|
||||
if (steve->running) {
|
||||
/* signal job to end and restart */
|
||||
steve->stop= 1;
|
||||
// printf("job started a running job, ending... %s\n", steve->name);
|
||||
}
|
||||
else {
|
||||
|
||||
if(steve->customdata && steve->startjob) {
|
||||
if (steve->customdata && steve->startjob) {
|
||||
|
||||
wm_jobs_test_suspend_stop(wm, steve);
|
||||
|
||||
if(steve->suspended==0) {
|
||||
if (steve->suspended==0) {
|
||||
/* copy to ensure proper free in end */
|
||||
steve->run_customdata= steve->customdata;
|
||||
steve->run_free= steve->free;
|
||||
@@ -323,7 +324,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve)
|
||||
steve->customdata= NULL;
|
||||
steve->running= 1;
|
||||
|
||||
if(steve->initjob)
|
||||
if (steve->initjob)
|
||||
steve->initjob(steve->run_customdata);
|
||||
|
||||
steve->stop= 0;
|
||||
@@ -337,7 +338,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve)
|
||||
}
|
||||
|
||||
/* restarted job has timer already */
|
||||
if(steve->wt==NULL)
|
||||
if (steve->wt==NULL)
|
||||
steve->wt= WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep);
|
||||
}
|
||||
else printf("job fails, not initialized\n");
|
||||
@@ -347,20 +348,20 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve)
|
||||
/* stop job, free data completely */
|
||||
static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *steve)
|
||||
{
|
||||
if(steve->running) {
|
||||
if (steve->running) {
|
||||
/* signal job to end */
|
||||
steve->stop= 1;
|
||||
BLI_end_threads(&steve->threads);
|
||||
|
||||
if(steve->endjob)
|
||||
if (steve->endjob)
|
||||
steve->endjob(steve->run_customdata);
|
||||
}
|
||||
|
||||
if(steve->wt)
|
||||
if (steve->wt)
|
||||
WM_event_remove_timer(wm, steve->win, steve->wt);
|
||||
if(steve->customdata)
|
||||
if (steve->customdata)
|
||||
steve->free(steve->customdata);
|
||||
if(steve->run_customdata)
|
||||
if (steve->run_customdata)
|
||||
steve->run_free(steve->run_customdata);
|
||||
|
||||
/* remove steve */
|
||||
@@ -373,7 +374,7 @@ void WM_jobs_stop_all(wmWindowManager *wm)
|
||||
{
|
||||
wmJob *steve;
|
||||
|
||||
while((steve= wm->jobs.first))
|
||||
while ((steve= wm->jobs.first))
|
||||
wm_jobs_kill_job(wm, steve);
|
||||
|
||||
}
|
||||
@@ -383,9 +384,9 @@ void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob)
|
||||
{
|
||||
wmJob *steve;
|
||||
|
||||
for(steve= wm->jobs.first; steve; steve= steve->next)
|
||||
if(steve->owner==owner || steve->startjob==startjob)
|
||||
if(steve->running)
|
||||
for (steve= wm->jobs.first; steve; steve= steve->next)
|
||||
if (steve->owner==owner || steve->startjob==startjob)
|
||||
if (steve->running)
|
||||
steve->stop= 1;
|
||||
}
|
||||
|
||||
@@ -395,12 +396,13 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, sho
|
||||
wmJob *steve;
|
||||
|
||||
steve= wm->jobs.first;
|
||||
while(steve) {
|
||||
if(steve->owner==owner || steve->startjob==startjob) {
|
||||
while (steve) {
|
||||
if (steve->owner==owner || steve->startjob==startjob) {
|
||||
wmJob* bill = steve;
|
||||
steve= steve->next;
|
||||
wm_jobs_kill_job(wm, bill);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
steve= steve->next;
|
||||
}
|
||||
}
|
||||
@@ -412,8 +414,8 @@ void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt)
|
||||
{
|
||||
wmJob *steve;
|
||||
|
||||
for(steve= wm->jobs.first; steve; steve= steve->next) {
|
||||
if(steve->wt==wt) {
|
||||
for (steve= wm->jobs.first; steve; steve= steve->next) {
|
||||
if (steve->wt==wt) {
|
||||
wm_jobs_kill_job(wm, steve);
|
||||
return;
|
||||
}
|
||||
@@ -428,19 +430,19 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
|
||||
float jobs_progress=0;
|
||||
|
||||
|
||||
for(; steve; steve= stevenext) {
|
||||
for (; steve; steve= stevenext) {
|
||||
stevenext= steve->next;
|
||||
|
||||
if(steve->wt==wt) {
|
||||
if (steve->wt==wt) {
|
||||
|
||||
/* running threads */
|
||||
if(steve->threads.first) {
|
||||
if (steve->threads.first) {
|
||||
|
||||
/* always call note and update when ready */
|
||||
if(steve->do_update || steve->ready) {
|
||||
if(steve->update)
|
||||
if (steve->do_update || steve->ready) {
|
||||
if (steve->update)
|
||||
steve->update(steve->run_customdata);
|
||||
if(steve->note)
|
||||
if (steve->note)
|
||||
WM_event_add_notifier(C, steve->note, NULL);
|
||||
|
||||
if (steve->flag & WM_JOB_PROGRESS)
|
||||
@@ -448,8 +450,8 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
|
||||
steve->do_update= 0;
|
||||
}
|
||||
|
||||
if(steve->ready) {
|
||||
if(steve->endjob)
|
||||
if (steve->ready) {
|
||||
if (steve->endjob)
|
||||
steve->endjob(steve->run_customdata);
|
||||
|
||||
/* free own data */
|
||||
@@ -463,13 +465,13 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
|
||||
steve->running= 0;
|
||||
BLI_end_threads(&steve->threads);
|
||||
|
||||
if(steve->endnote)
|
||||
if (steve->endnote)
|
||||
WM_event_add_notifier(C, steve->endnote, NULL);
|
||||
|
||||
WM_event_add_notifier(C, NC_WM|ND_JOB, NULL);
|
||||
|
||||
/* new job added for steve? */
|
||||
if(steve->customdata) {
|
||||
if (steve->customdata) {
|
||||
// printf("job restarted with new data %s\n", steve->name);
|
||||
WM_jobs_start(wm, steve);
|
||||
}
|
||||
@@ -481,18 +483,19 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
|
||||
BLI_remlink(&wm->jobs, steve);
|
||||
MEM_freeN(steve);
|
||||
}
|
||||
} else if (steve->flag & WM_JOB_PROGRESS) {
|
||||
}
|
||||
else if (steve->flag & WM_JOB_PROGRESS) {
|
||||
/* accumulate global progress for running jobs */
|
||||
jobs_progress++;
|
||||
total_progress += steve->progress;
|
||||
}
|
||||
}
|
||||
else if(steve->suspended) {
|
||||
else if (steve->suspended) {
|
||||
WM_jobs_start(wm, steve);
|
||||
}
|
||||
}
|
||||
else if(steve->threads.first && !steve->ready) {
|
||||
if(steve->flag & WM_JOB_PROGRESS) {
|
||||
else if (steve->threads.first && !steve->ready) {
|
||||
if (steve->flag & WM_JOB_PROGRESS) {
|
||||
/* accumulate global progress for running jobs */
|
||||
jobs_progress++;
|
||||
total_progress += steve->progress;
|
||||
@@ -501,12 +504,13 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
|
||||
}
|
||||
|
||||
/* on file load 'winactive' can be NULL, possibly it should not happen but for now do a NULL check - campbell */
|
||||
if(wm->winactive) {
|
||||
if (wm->winactive) {
|
||||
/* if there are running jobs, set the global progress indicator */
|
||||
if (jobs_progress > 0) {
|
||||
float progress = total_progress / (float)jobs_progress;
|
||||
WM_progress_set(wm->winactive, progress);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
WM_progress_clear(wm->winactive);
|
||||
}
|
||||
}
|
||||
@@ -516,8 +520,8 @@ int WM_jobs_has_running(wmWindowManager *wm)
|
||||
{
|
||||
wmJob *steve;
|
||||
|
||||
for(steve= wm->jobs.first; steve; steve= steve->next)
|
||||
if(steve->running)
|
||||
for (steve= wm->jobs.first; steve; steve= steve->next)
|
||||
if (steve->running)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -70,7 +70,7 @@ static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi)
|
||||
kmin->prev= kmin->next= NULL;
|
||||
kmin->flag &= ~KMI_UPDATE;
|
||||
|
||||
if(kmin->properties) {
|
||||
if (kmin->properties) {
|
||||
kmin->ptr= MEM_callocN(sizeof(PointerRNA), "UserKeyMapItemPtr");
|
||||
WM_operator_properties_create(kmin->ptr, kmin->idname);
|
||||
|
||||
@@ -84,7 +84,7 @@ static wmKeyMapItem *wm_keymap_item_copy(wmKeyMapItem *kmi)
|
||||
static void wm_keymap_item_free(wmKeyMapItem *kmi)
|
||||
{
|
||||
/* not kmi itself */
|
||||
if(kmi->ptr) {
|
||||
if (kmi->ptr) {
|
||||
WM_operator_properties_free(kmi->ptr);
|
||||
MEM_freeN(kmi->ptr);
|
||||
}
|
||||
@@ -98,14 +98,14 @@ static void wm_keymap_item_properties_set(wmKeyMapItem *kmi)
|
||||
|
||||
static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b)
|
||||
{
|
||||
if(strcmp(a->idname, b->idname) != 0)
|
||||
if (strcmp(a->idname, b->idname) != 0)
|
||||
return 0;
|
||||
|
||||
if(!((a->ptr==NULL && b->ptr==NULL) ||
|
||||
if (!((a->ptr==NULL && b->ptr==NULL) ||
|
||||
(a->ptr && b->ptr && IDP_EqualsProperties(a->ptr->data, b->ptr->data))))
|
||||
return 0;
|
||||
|
||||
if((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE))
|
||||
if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE))
|
||||
return 0;
|
||||
|
||||
return (a->propvalue == b->propvalue);
|
||||
@@ -144,9 +144,9 @@ static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi)
|
||||
wmKeyMapDiffItem *kmdin = MEM_dupallocN(kmdi);
|
||||
|
||||
kmdin->next = kmdin->prev = NULL;
|
||||
if(kmdi->add_item)
|
||||
if (kmdi->add_item)
|
||||
kmdin->add_item = wm_keymap_item_copy(kmdi->add_item);
|
||||
if(kmdi->remove_item)
|
||||
if (kmdi->remove_item)
|
||||
kmdin->remove_item = wm_keymap_item_copy(kmdi->remove_item);
|
||||
|
||||
return kmdin;
|
||||
@@ -154,11 +154,11 @@ static wmKeyMapDiffItem *wm_keymap_diff_item_copy(wmKeyMapDiffItem *kmdi)
|
||||
|
||||
static void wm_keymap_diff_item_free(wmKeyMapDiffItem *kmdi)
|
||||
{
|
||||
if(kmdi->remove_item) {
|
||||
if (kmdi->remove_item) {
|
||||
wm_keymap_item_free(kmdi->remove_item);
|
||||
MEM_freeN(kmdi->remove_item);
|
||||
}
|
||||
if(kmdi->add_item) {
|
||||
if (kmdi->add_item) {
|
||||
wm_keymap_item_free(kmdi->add_item);
|
||||
MEM_freeN(kmdi->add_item);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ void WM_keyconfig_free(wmKeyConfig *keyconf)
|
||||
{
|
||||
wmKeyMap *km;
|
||||
|
||||
while((km= keyconf->keymaps.first)) {
|
||||
while ((km= keyconf->keymaps.first)) {
|
||||
WM_keymap_free(km);
|
||||
BLI_freelinkN(&keyconf->keymaps, km);
|
||||
}
|
||||
@@ -217,8 +217,8 @@ static wmKeyConfig *wm_keyconfig_list_find(ListBase *lb, char *idname)
|
||||
{
|
||||
wmKeyConfig *kc;
|
||||
|
||||
for(kc= lb->first; kc; kc= kc->next)
|
||||
if(0==strncmp(idname, kc->idname, KMAP_MAX_NAME))
|
||||
for (kc= lb->first; kc; kc= kc->next)
|
||||
if (0==strncmp(idname, kc->idname, KMAP_MAX_NAME))
|
||||
return kc;
|
||||
|
||||
return NULL;
|
||||
@@ -230,7 +230,7 @@ static wmKeyConfig *WM_keyconfig_active(wmWindowManager *wm)
|
||||
|
||||
/* first try from preset */
|
||||
keyconf= wm_keyconfig_list_find(&wm->keyconfigs, U.keyconfigstr);
|
||||
if(keyconf)
|
||||
if (keyconf)
|
||||
return keyconf;
|
||||
|
||||
/* otherwise use default */
|
||||
@@ -275,12 +275,12 @@ static wmKeyMap *wm_keymap_copy(wmKeyMap *keymap)
|
||||
keymapn->items.first= keymapn->items.last= NULL;
|
||||
keymapn->flag &= ~(KEYMAP_UPDATE|KEYMAP_EXPANDED);
|
||||
|
||||
for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
|
||||
for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next) {
|
||||
kmdin= wm_keymap_diff_item_copy(kmdi);
|
||||
BLI_addtail(&keymapn->items, kmdin);
|
||||
}
|
||||
|
||||
for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
|
||||
for (kmi=keymap->items.first; kmi; kmi=kmi->next) {
|
||||
kmin= wm_keymap_item_copy(kmi);
|
||||
BLI_addtail(&keymapn->items, kmin);
|
||||
}
|
||||
@@ -293,10 +293,10 @@ void WM_keymap_free(wmKeyMap *keymap)
|
||||
wmKeyMapItem *kmi;
|
||||
wmKeyMapDiffItem *kmdi;
|
||||
|
||||
for(kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next)
|
||||
for (kmdi=keymap->diff_items.first; kmdi; kmdi=kmdi->next)
|
||||
wm_keymap_diff_item_free(kmdi);
|
||||
|
||||
for(kmi=keymap->items.first; kmi; kmi=kmi->next)
|
||||
for (kmi=keymap->items.first; kmi; kmi=kmi->next)
|
||||
wm_keymap_item_free(kmi);
|
||||
|
||||
BLI_freelistN(&keymap->diff_items);
|
||||
@@ -309,7 +309,7 @@ static void keymap_event_set(wmKeyMapItem *kmi, short type, short val, int modif
|
||||
kmi->val= val;
|
||||
kmi->keymodifier= keymodifier;
|
||||
|
||||
if(modifier == KM_ANY) {
|
||||
if (modifier == KM_ANY) {
|
||||
kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY;
|
||||
}
|
||||
else {
|
||||
@@ -325,7 +325,8 @@ static void keymap_item_set_id(wmKeyMap *keymap, wmKeyMapItem *kmi)
|
||||
keymap->kmi_id++;
|
||||
if ((keymap->flag & KEYMAP_USER) == 0) {
|
||||
kmi->id = keymap->kmi_id;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
kmi->id = -keymap->kmi_id; // User defined keymap entries have negative ids
|
||||
}
|
||||
}
|
||||
@@ -335,10 +336,10 @@ wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int ty
|
||||
{
|
||||
wmKeyMapItem *kmi;
|
||||
|
||||
for(kmi = keymap->items.first; kmi; kmi = kmi->next)
|
||||
if(strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0)
|
||||
for (kmi = keymap->items.first; kmi; kmi = kmi->next)
|
||||
if (strncmp(kmi->idname, idname, OP_MAX_TYPENAME)==0)
|
||||
break;
|
||||
if(kmi==NULL) {
|
||||
if (kmi==NULL) {
|
||||
kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry");
|
||||
|
||||
BLI_addtail(&keymap->items, kmi);
|
||||
@@ -380,8 +381,8 @@ wmKeyMapItem *WM_keymap_add_menu(wmKeyMap *keymap, const char *idname, int type,
|
||||
|
||||
void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
|
||||
{
|
||||
if(BLI_findindex(&keymap->items, kmi) != -1) {
|
||||
if(kmi->ptr) {
|
||||
if (BLI_findindex(&keymap->items, kmi) != -1) {
|
||||
if (kmi->ptr) {
|
||||
WM_operator_properties_free(kmi->ptr);
|
||||
MEM_freeN(kmi->ptr);
|
||||
}
|
||||
@@ -401,7 +402,7 @@ static void wm_keymap_addon_add(wmKeyMap *keymap, wmKeyMap *addonmap)
|
||||
{
|
||||
wmKeyMapItem *kmi, *kmin;
|
||||
|
||||
for(kmi=addonmap->items.first; kmi; kmi=kmi->next) {
|
||||
for (kmi=addonmap->items.first; kmi; kmi=kmi->next) {
|
||||
kmin = wm_keymap_item_copy(kmi);
|
||||
keymap_item_set_id(keymap, kmin);
|
||||
BLI_addhead(&keymap->items, kmin);
|
||||
@@ -412,8 +413,8 @@ static wmKeyMapItem *wm_keymap_find_item_equals(wmKeyMap *km, wmKeyMapItem *need
|
||||
{
|
||||
wmKeyMapItem *kmi;
|
||||
|
||||
for(kmi=km->items.first; kmi; kmi=kmi->next)
|
||||
if(wm_keymap_item_equals(kmi, needle))
|
||||
for (kmi=km->items.first; kmi; kmi=kmi->next)
|
||||
if (wm_keymap_item_equals(kmi, needle))
|
||||
return kmi;
|
||||
|
||||
return NULL;
|
||||
@@ -423,8 +424,8 @@ static wmKeyMapItem *wm_keymap_find_item_equals_result(wmKeyMap *km, wmKeyMapIte
|
||||
{
|
||||
wmKeyMapItem *kmi;
|
||||
|
||||
for(kmi=km->items.first; kmi; kmi=kmi->next)
|
||||
if(wm_keymap_item_equals_result(kmi, needle))
|
||||
for (kmi=km->items.first; kmi; kmi=kmi->next)
|
||||
if (wm_keymap_item_equals_result(kmi, needle))
|
||||
return kmi;
|
||||
|
||||
return NULL;
|
||||
@@ -435,16 +436,16 @@ static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km
|
||||
wmKeyMapItem *kmi, *to_kmi, *orig_kmi;
|
||||
wmKeyMapDiffItem *kmdi;
|
||||
|
||||
for(kmi=from_km->items.first; kmi; kmi=kmi->next) {
|
||||
for (kmi=from_km->items.first; kmi; kmi=kmi->next) {
|
||||
to_kmi = WM_keymap_item_find_id(to_km, kmi->id);
|
||||
|
||||
if(!to_kmi) {
|
||||
if (!to_kmi) {
|
||||
/* remove item */
|
||||
kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
|
||||
kmdi->remove_item = wm_keymap_item_copy(kmi);
|
||||
BLI_addtail(&diff_km->diff_items, kmdi);
|
||||
}
|
||||
else if(to_kmi && !wm_keymap_item_equals(kmi, to_kmi)) {
|
||||
else if (to_kmi && !wm_keymap_item_equals(kmi, to_kmi)) {
|
||||
/* replace item */
|
||||
kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
|
||||
kmdi->remove_item = wm_keymap_item_copy(kmi);
|
||||
@@ -453,21 +454,21 @@ static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km
|
||||
}
|
||||
|
||||
/* sync expanded flag back to original so we don't loose it on repatch */
|
||||
if(to_kmi) {
|
||||
if (to_kmi) {
|
||||
orig_kmi = WM_keymap_item_find_id(orig_km, kmi->id);
|
||||
|
||||
if(!orig_kmi)
|
||||
if (!orig_kmi)
|
||||
orig_kmi = wm_keymap_find_item_equals(addon_km, kmi);
|
||||
|
||||
if(orig_kmi) {
|
||||
if (orig_kmi) {
|
||||
orig_kmi->flag &= ~KMI_EXPANDED;
|
||||
orig_kmi->flag |= (to_kmi->flag & KMI_EXPANDED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(kmi=to_km->items.first; kmi; kmi=kmi->next) {
|
||||
if(kmi->id < 0) {
|
||||
for (kmi=to_km->items.first; kmi; kmi=kmi->next) {
|
||||
if (kmi->id < 0) {
|
||||
/* add item */
|
||||
kmdi = MEM_callocN(sizeof(wmKeyMapDiffItem), "wmKeyMapDiffItem");
|
||||
kmdi->add_item = wm_keymap_item_copy(kmi);
|
||||
@@ -481,23 +482,23 @@ static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km)
|
||||
wmKeyMapDiffItem *kmdi;
|
||||
wmKeyMapItem *kmi_remove, *kmi_add;
|
||||
|
||||
for(kmdi=diff_km->diff_items.first; kmdi; kmdi=kmdi->next) {
|
||||
for (kmdi=diff_km->diff_items.first; kmdi; kmdi=kmdi->next) {
|
||||
/* find item to remove */
|
||||
kmi_remove = NULL;
|
||||
if(kmdi->remove_item) {
|
||||
if (kmdi->remove_item) {
|
||||
kmi_remove = wm_keymap_find_item_equals(km, kmdi->remove_item);
|
||||
if(!kmi_remove)
|
||||
if (!kmi_remove)
|
||||
kmi_remove = wm_keymap_find_item_equals_result(km, kmdi->remove_item);
|
||||
}
|
||||
|
||||
/* add item */
|
||||
if(kmdi->add_item) {
|
||||
if (kmdi->add_item) {
|
||||
/* only if nothing to remove or item to remove found */
|
||||
if(!kmdi->remove_item || kmi_remove) {
|
||||
if (!kmdi->remove_item || kmi_remove) {
|
||||
kmi_add = wm_keymap_item_copy(kmdi->add_item);
|
||||
kmi_add->flag |= KMI_USER_MODIFIED;
|
||||
|
||||
if(kmi_remove) {
|
||||
if (kmi_remove) {
|
||||
kmi_add->flag &= ~KMI_EXPANDED;
|
||||
kmi_add->flag |= (kmi_remove->flag & KMI_EXPANDED);
|
||||
kmi_add->id = kmi_remove->id;
|
||||
@@ -511,7 +512,7 @@ static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km)
|
||||
}
|
||||
|
||||
/* remove item */
|
||||
if(kmi_remove) {
|
||||
if (kmi_remove) {
|
||||
wm_keymap_item_free(kmi_remove);
|
||||
BLI_freelinkN(&km->items, kmi_remove);
|
||||
}
|
||||
@@ -525,14 +526,14 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe
|
||||
|
||||
/* remove previous keymap in list, we will replace it */
|
||||
km = WM_keymap_list_find(lb, defaultmap->idname, defaultmap->spaceid, defaultmap->regionid);
|
||||
if(km) {
|
||||
if (km) {
|
||||
expanded = (km->flag & (KEYMAP_EXPANDED|KEYMAP_CHILDREN_EXPANDED));
|
||||
WM_keymap_free(km);
|
||||
BLI_freelinkN(lb, km);
|
||||
}
|
||||
|
||||
/* copy new keymap from an existing one */
|
||||
if(usermap && !(usermap->flag & KEYMAP_DIFF)) {
|
||||
if (usermap && !(usermap->flag & KEYMAP_DIFF)) {
|
||||
/* for compatibiltiy with old user preferences with non-diff
|
||||
* keymaps we override the original entirely */
|
||||
wmKeyMapItem *kmi, *orig_kmi;
|
||||
@@ -540,12 +541,12 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe
|
||||
km = wm_keymap_copy(usermap);
|
||||
|
||||
/* try to find corresponding id's for items */
|
||||
for(kmi=km->items.first; kmi; kmi=kmi->next) {
|
||||
for (kmi=km->items.first; kmi; kmi=kmi->next) {
|
||||
orig_kmi = wm_keymap_find_item_equals(defaultmap, kmi);
|
||||
if(!orig_kmi)
|
||||
if (!orig_kmi)
|
||||
orig_kmi = wm_keymap_find_item_equals_result(defaultmap, kmi);
|
||||
|
||||
if(orig_kmi)
|
||||
if (orig_kmi)
|
||||
kmi->id = orig_kmi->id;
|
||||
else
|
||||
kmi->id = -(km->kmi_id++);
|
||||
@@ -557,16 +558,16 @@ static wmKeyMap *wm_keymap_patch_update(ListBase *lb, wmKeyMap *defaultmap, wmKe
|
||||
km = wm_keymap_copy(defaultmap);
|
||||
|
||||
/* add addon keymap items */
|
||||
if(addonmap)
|
||||
if (addonmap)
|
||||
wm_keymap_addon_add(km, addonmap);
|
||||
|
||||
/* tag as being user edited */
|
||||
if(usermap)
|
||||
if (usermap)
|
||||
km->flag |= KEYMAP_USER_MODIFIED;
|
||||
km->flag |= KEYMAP_USER|expanded;
|
||||
|
||||
/* apply user changes of diff keymap */
|
||||
if(usermap && (usermap->flag & KEYMAP_DIFF))
|
||||
if (usermap && (usermap->flag & KEYMAP_DIFF))
|
||||
wm_keymap_patch(km, usermap);
|
||||
|
||||
/* add to list */
|
||||
@@ -582,14 +583,14 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap *
|
||||
/* create temporary default + addon keymap for diff */
|
||||
origmap = defaultmap;
|
||||
|
||||
if(addonmap) {
|
||||
if (addonmap) {
|
||||
defaultmap = wm_keymap_copy(defaultmap);
|
||||
wm_keymap_addon_add(defaultmap, addonmap);
|
||||
}
|
||||
|
||||
/* remove previous diff keymap in list, we will replace it */
|
||||
prevmap = WM_keymap_list_find(lb, km->idname, km->spaceid, km->regionid);
|
||||
if(prevmap) {
|
||||
if (prevmap) {
|
||||
WM_keymap_free(prevmap);
|
||||
BLI_freelinkN(lb, prevmap);
|
||||
}
|
||||
@@ -597,12 +598,12 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap *
|
||||
/* create diff keymap */
|
||||
diffmap= wm_keymap_new(km->idname, km->spaceid, km->regionid);
|
||||
diffmap->flag |= KEYMAP_DIFF;
|
||||
if(defaultmap->flag & KEYMAP_MODAL)
|
||||
if (defaultmap->flag & KEYMAP_MODAL)
|
||||
diffmap->flag |= KEYMAP_MODAL;
|
||||
wm_keymap_diff(diffmap, defaultmap, km, origmap, addonmap);
|
||||
|
||||
/* add to list if not empty */
|
||||
if(diffmap->diff_items.first) {
|
||||
if (diffmap->diff_items.first) {
|
||||
BLI_addtail(lb, diffmap);
|
||||
}
|
||||
else {
|
||||
@@ -611,7 +612,7 @@ static void wm_keymap_diff_update(ListBase *lb, wmKeyMap *defaultmap, wmKeyMap *
|
||||
}
|
||||
|
||||
/* free temporary default map */
|
||||
if(addonmap) {
|
||||
if (addonmap) {
|
||||
WM_keymap_free(defaultmap);
|
||||
MEM_freeN(defaultmap);
|
||||
}
|
||||
@@ -627,9 +628,9 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int
|
||||
{
|
||||
wmKeyMap *km;
|
||||
|
||||
for(km= lb->first; km; km= km->next)
|
||||
if(km->spaceid==spaceid && km->regionid==regionid)
|
||||
if(0==strncmp(idname, km->idname, KMAP_MAX_NAME))
|
||||
for (km= lb->first; km; km= km->next)
|
||||
if (km->spaceid==spaceid && km->regionid==regionid)
|
||||
if (0==strncmp(idname, km->idname, KMAP_MAX_NAME))
|
||||
return km;
|
||||
|
||||
return NULL;
|
||||
@@ -639,7 +640,7 @@ wmKeyMap *WM_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid,
|
||||
{
|
||||
wmKeyMap *km= WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
|
||||
|
||||
if(km==NULL) {
|
||||
if (km==NULL) {
|
||||
km= wm_keymap_new(idname, spaceid, regionid);
|
||||
BLI_addtail(&keyconf->keymaps, km);
|
||||
|
||||
@@ -666,12 +667,12 @@ wmKeyMap *WM_modalkeymap_add(wmKeyConfig *keyconf, const char *idname, EnumPrope
|
||||
km->flag |= KEYMAP_MODAL;
|
||||
km->modal_items= items;
|
||||
|
||||
if(!items) {
|
||||
if (!items) {
|
||||
/* init modal items from default config */
|
||||
wmWindowManager *wm = G.main->wm.first;
|
||||
wmKeyMap *defaultkm= WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, 0, 0);
|
||||
|
||||
if(defaultkm) {
|
||||
if (defaultkm) {
|
||||
km->modal_items = defaultkm->modal_items;
|
||||
km->poll = defaultkm->poll;
|
||||
}
|
||||
@@ -684,9 +685,9 @@ wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname)
|
||||
{
|
||||
wmKeyMap *km;
|
||||
|
||||
for(km= keyconf->keymaps.first; km; km= km->next)
|
||||
if(km->flag & KEYMAP_MODAL)
|
||||
if(0==strncmp(idname, km->idname, KMAP_MAX_NAME))
|
||||
for (km= keyconf->keymaps.first; km; km= km->next)
|
||||
if (km->flag & KEYMAP_MODAL)
|
||||
if (0==strncmp(idname, km->idname, KMAP_MAX_NAME))
|
||||
break;
|
||||
|
||||
return km;
|
||||
@@ -713,7 +714,7 @@ void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
|
||||
{
|
||||
wmOperatorType *ot= WM_operatortype_find(opname, 0);
|
||||
|
||||
if(ot)
|
||||
if (ot)
|
||||
ot->modalkeymap = km;
|
||||
else
|
||||
printf("error: modalkeymap_assign, unknown operator %s\n", opname);
|
||||
@@ -724,7 +725,7 @@ void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
|
||||
const char *WM_key_event_string(short type)
|
||||
{
|
||||
const char *name= NULL;
|
||||
if(RNA_enum_name(event_type_items, (int)type, &name))
|
||||
if (RNA_enum_name(event_type_items, (int)type, &name))
|
||||
return name;
|
||||
|
||||
return "";
|
||||
@@ -742,21 +743,22 @@ char *WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, int len)
|
||||
kmi->oskey == KM_ANY) {
|
||||
|
||||
strcat(buf, "Any ");
|
||||
} else {
|
||||
if(kmi->shift)
|
||||
}
|
||||
else {
|
||||
if (kmi->shift)
|
||||
strcat(buf, "Shift ");
|
||||
|
||||
if(kmi->ctrl)
|
||||
if (kmi->ctrl)
|
||||
strcat(buf, "Ctrl ");
|
||||
|
||||
if(kmi->alt)
|
||||
if (kmi->alt)
|
||||
strcat(buf, "Alt ");
|
||||
|
||||
if(kmi->oskey)
|
||||
if (kmi->oskey)
|
||||
strcat(buf, "Cmd ");
|
||||
}
|
||||
|
||||
if(kmi->keymodifier) {
|
||||
if (kmi->keymodifier) {
|
||||
strcat(buf, WM_key_event_string(kmi->keymodifier));
|
||||
strcat(buf, " ");
|
||||
}
|
||||
@@ -777,25 +779,25 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
|
||||
wmKeyMapItem *kmi;
|
||||
|
||||
/* find keymap item in handlers */
|
||||
for(handler=handlers->first; handler; handler=handler->next) {
|
||||
for (handler=handlers->first; handler; handler=handler->next) {
|
||||
keymap= WM_keymap_active(wm, handler->keymap);
|
||||
|
||||
if(keymap && (!keymap->poll || keymap->poll((bContext*)C))) {
|
||||
for(kmi=keymap->items.first; kmi; kmi=kmi->next) {
|
||||
if (keymap && (!keymap->poll || keymap->poll((bContext*)C))) {
|
||||
for (kmi=keymap->items.first; kmi; kmi=kmi->next) {
|
||||
|
||||
if(strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) {
|
||||
if (strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) {
|
||||
if (hotkey)
|
||||
if (!ISHOTKEY(kmi->type))
|
||||
continue;
|
||||
|
||||
if(compare_props) {
|
||||
if(kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) {
|
||||
if(keymap_r) *keymap_r= keymap;
|
||||
if (compare_props) {
|
||||
if (kmi->ptr && IDP_EqualsProperties(properties, kmi->ptr->data)) {
|
||||
if (keymap_r) *keymap_r= keymap;
|
||||
return kmi;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(keymap_r) *keymap_r= keymap;
|
||||
if (keymap_r) *keymap_r= keymap;
|
||||
return kmi;
|
||||
}
|
||||
}
|
||||
@@ -804,7 +806,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
|
||||
}
|
||||
|
||||
/* ensure un-initialized keymap is never used */
|
||||
if(keymap_r) *keymap_r= NULL;
|
||||
if (keymap_r) *keymap_r= NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -818,39 +820,39 @@ static wmKeyMapItem *wm_keymap_item_find_props(
|
||||
wmKeyMapItem *found= NULL;
|
||||
|
||||
/* look into multiple handler lists to find the item */
|
||||
if(win)
|
||||
if (win)
|
||||
found= wm_keymap_item_find_handlers(C, &win->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
||||
|
||||
|
||||
if(sa && found==NULL)
|
||||
if (sa && found==NULL)
|
||||
found= wm_keymap_item_find_handlers(C, &sa->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
||||
|
||||
if(found==NULL) {
|
||||
if(ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) {
|
||||
if(sa) {
|
||||
if (found==NULL) {
|
||||
if (ELEM(opcontext, WM_OP_EXEC_REGION_WIN, WM_OP_INVOKE_REGION_WIN)) {
|
||||
if (sa) {
|
||||
if (!(ar && ar->regiontype == RGN_TYPE_WINDOW))
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
|
||||
if(ar)
|
||||
if (ar)
|
||||
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
||||
}
|
||||
}
|
||||
else if(ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) {
|
||||
else if (ELEM(opcontext, WM_OP_EXEC_REGION_CHANNELS, WM_OP_INVOKE_REGION_CHANNELS)) {
|
||||
if (!(ar && ar->regiontype == RGN_TYPE_CHANNELS))
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_CHANNELS);
|
||||
|
||||
if(ar)
|
||||
if (ar)
|
||||
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
||||
}
|
||||
else if(ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) {
|
||||
else if (ELEM(opcontext, WM_OP_EXEC_REGION_PREVIEW, WM_OP_INVOKE_REGION_PREVIEW)) {
|
||||
if (!(ar && ar->regiontype == RGN_TYPE_PREVIEW))
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW);
|
||||
|
||||
if(ar)
|
||||
if (ar)
|
||||
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
||||
}
|
||||
else {
|
||||
if(ar)
|
||||
if (ar)
|
||||
found= wm_keymap_item_find_handlers(C, &ar->handlers, opname, opcontext, properties, compare_props, hotkey, keymap_r);
|
||||
}
|
||||
}
|
||||
@@ -864,7 +866,7 @@ static wmKeyMapItem *wm_keymap_item_find(
|
||||
{
|
||||
wmKeyMapItem *found= wm_keymap_item_find_props(C, opname, opcontext, properties, 1, hotkey, keymap_r);
|
||||
|
||||
if(!found && sloppy)
|
||||
if (!found && sloppy)
|
||||
found= wm_keymap_item_find_props(C, opname, opcontext, NULL, 0, hotkey, keymap_r);
|
||||
|
||||
return found;
|
||||
@@ -876,7 +878,7 @@ char *WM_key_event_operator_string(
|
||||
{
|
||||
wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, 0, sloppy, NULL);
|
||||
|
||||
if(kmi) {
|
||||
if (kmi) {
|
||||
WM_keymap_item_to_string(kmi, str, len);
|
||||
return str;
|
||||
}
|
||||
@@ -890,7 +892,7 @@ int WM_key_event_operator_id(
|
||||
{
|
||||
wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, hotkey, TRUE, keymap_r);
|
||||
|
||||
if(kmi)
|
||||
if (kmi)
|
||||
return kmi->id;
|
||||
else
|
||||
return 0;
|
||||
@@ -907,10 +909,10 @@ int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
|
||||
k1type = WM_userdef_event_map(k1->type);
|
||||
k2type = WM_userdef_event_map(k2->type);
|
||||
|
||||
if(k1type != KM_ANY && k2type != KM_ANY && k1type != k2type)
|
||||
if (k1type != KM_ANY && k2type != KM_ANY && k1type != k2type)
|
||||
return 0;
|
||||
|
||||
if(k1->val != KM_ANY && k2->val != KM_ANY) {
|
||||
if (k1->val != KM_ANY && k2->val != KM_ANY) {
|
||||
/* take click, press, release conflict into account */
|
||||
if (k1->val == KM_CLICK && ELEM3(k2->val, KM_PRESS, KM_RELEASE, KM_CLICK) == 0)
|
||||
return 0;
|
||||
@@ -920,19 +922,19 @@ int WM_keymap_item_compare(wmKeyMapItem *k1, wmKeyMapItem *k2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(k1->shift != KM_ANY && k2->shift != KM_ANY && k1->shift != k2->shift)
|
||||
if (k1->shift != KM_ANY && k2->shift != KM_ANY && k1->shift != k2->shift)
|
||||
return 0;
|
||||
|
||||
if(k1->ctrl != KM_ANY && k2->ctrl != KM_ANY && k1->ctrl != k2->ctrl)
|
||||
if (k1->ctrl != KM_ANY && k2->ctrl != KM_ANY && k1->ctrl != k2->ctrl)
|
||||
return 0;
|
||||
|
||||
if(k1->alt != KM_ANY && k2->alt != KM_ANY && k1->alt != k2->alt)
|
||||
if (k1->alt != KM_ANY && k2->alt != KM_ANY && k1->alt != k2->alt)
|
||||
return 0;
|
||||
|
||||
if(k1->oskey != KM_ANY && k2->oskey != KM_ANY && k1->oskey != k2->oskey)
|
||||
if (k1->oskey != KM_ANY && k2->oskey != KM_ANY && k1->oskey != k2->oskey)
|
||||
return 0;
|
||||
|
||||
if(k1->keymodifier != k2->keymodifier)
|
||||
if (k1->keymodifier != k2->keymodifier)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@@ -950,9 +952,9 @@ void WM_keyconfig_update_tag(wmKeyMap *km, wmKeyMapItem *kmi)
|
||||
/* quick tag to do delayed keymap updates */
|
||||
WM_KEYMAP_UPDATE= 1;
|
||||
|
||||
if(km)
|
||||
if (km)
|
||||
km->flag |= KEYMAP_UPDATE;
|
||||
if(kmi)
|
||||
if (kmi)
|
||||
kmi->flag |= KMI_UPDATE;
|
||||
}
|
||||
|
||||
@@ -964,7 +966,7 @@ static int wm_keymap_test_and_clear_update(wmKeyMap *km)
|
||||
update= (km->flag & KEYMAP_UPDATE);
|
||||
km->flag &= ~KEYMAP_UPDATE;
|
||||
|
||||
for(kmi=km->items.first; kmi; kmi=kmi->next) {
|
||||
for (kmi=km->items.first; kmi; kmi=kmi->next) {
|
||||
update= update || (kmi->flag & KMI_UPDATE);
|
||||
kmi->flag &= ~KMI_UPDATE;
|
||||
}
|
||||
@@ -978,7 +980,7 @@ static wmKeyMap *wm_keymap_preset(wmWindowManager *wm, wmKeyMap *km)
|
||||
wmKeyMap *keymap;
|
||||
|
||||
keymap= WM_keymap_list_find(&keyconf->keymaps, km->idname, km->spaceid, km->regionid);
|
||||
if(!keymap)
|
||||
if (!keymap)
|
||||
keymap= WM_keymap_list_find(&wm->defaultconf->keymaps, km->idname, km->spaceid, km->regionid);
|
||||
|
||||
return keymap;
|
||||
@@ -991,42 +993,42 @@ void WM_keyconfig_update(wmWindowManager *wm)
|
||||
wmKeyMapDiffItem *kmdi;
|
||||
int compat_update = 0;
|
||||
|
||||
if(G.background)
|
||||
if (G.background)
|
||||
return;
|
||||
if(!WM_KEYMAP_UPDATE)
|
||||
if (!WM_KEYMAP_UPDATE)
|
||||
return;
|
||||
|
||||
/* update operator properties for non-modal user keymaps */
|
||||
for(km=U.user_keymaps.first; km; km=km->next) {
|
||||
if((km->flag & KEYMAP_MODAL) == 0) {
|
||||
for(kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
|
||||
if(kmdi->add_item)
|
||||
for (km=U.user_keymaps.first; km; km=km->next) {
|
||||
if ((km->flag & KEYMAP_MODAL) == 0) {
|
||||
for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) {
|
||||
if (kmdi->add_item)
|
||||
wm_keymap_item_properties_set(kmdi->add_item);
|
||||
if(kmdi->remove_item)
|
||||
if (kmdi->remove_item)
|
||||
wm_keymap_item_properties_set(kmdi->remove_item);
|
||||
}
|
||||
|
||||
for(kmi=km->items.first; kmi; kmi=kmi->next)
|
||||
for (kmi=km->items.first; kmi; kmi=kmi->next)
|
||||
wm_keymap_item_properties_set(kmi);
|
||||
}
|
||||
}
|
||||
|
||||
/* update U.user_keymaps with user key configuration changes */
|
||||
for(km=wm->userconf->keymaps.first; km; km=km->next) {
|
||||
for (km=wm->userconf->keymaps.first; km; km=km->next) {
|
||||
/* only diff if the user keymap was modified */
|
||||
if(wm_keymap_test_and_clear_update(km)) {
|
||||
if (wm_keymap_test_and_clear_update(km)) {
|
||||
/* find keymaps */
|
||||
defaultmap= wm_keymap_preset(wm, km);
|
||||
addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
|
||||
|
||||
/* diff */
|
||||
if(defaultmap)
|
||||
if (defaultmap)
|
||||
wm_keymap_diff_update(&U.user_keymaps, defaultmap, addonmap, km);
|
||||
}
|
||||
}
|
||||
|
||||
/* create user key configuration from preset + addon + user preferences */
|
||||
for(km=wm->defaultconf->keymaps.first; km; km=km->next) {
|
||||
for (km=wm->defaultconf->keymaps.first; km; km=km->next) {
|
||||
/* find keymaps */
|
||||
defaultmap= wm_keymap_preset(wm, km);
|
||||
addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, km->idname, km->spaceid, km->regionid);
|
||||
@@ -1035,7 +1037,7 @@ void WM_keyconfig_update(wmWindowManager *wm)
|
||||
/* add */
|
||||
kmn= wm_keymap_patch_update(&wm->userconf->keymaps, defaultmap, addonmap, usermap);
|
||||
|
||||
if(kmn) {
|
||||
if (kmn) {
|
||||
kmn->modal_items= km->modal_items;
|
||||
kmn->poll= km->poll;
|
||||
}
|
||||
@@ -1046,7 +1048,7 @@ void WM_keyconfig_update(wmWindowManager *wm)
|
||||
|
||||
WM_KEYMAP_UPDATE= 0;
|
||||
|
||||
if(compat_update) {
|
||||
if (compat_update) {
|
||||
WM_keyconfig_update_tag(NULL, NULL);
|
||||
WM_keyconfig_update(wm);
|
||||
}
|
||||
@@ -1061,13 +1063,13 @@ wmKeyMap *WM_keymap_active(wmWindowManager *wm, wmKeyMap *keymap)
|
||||
{
|
||||
wmKeyMap *km;
|
||||
|
||||
if(!keymap)
|
||||
if (!keymap)
|
||||
return NULL;
|
||||
|
||||
/* first user defined keymaps */
|
||||
km= WM_keymap_list_find(&wm->userconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
||||
|
||||
if(km)
|
||||
if (km)
|
||||
return km;
|
||||
|
||||
return keymap;
|
||||
@@ -1082,14 +1084,14 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt
|
||||
wmKeyMap *defaultmap, *addonmap;
|
||||
wmKeyMapItem *orig;
|
||||
|
||||
if(!keymap)
|
||||
if (!keymap)
|
||||
return;
|
||||
|
||||
/* construct default keymap from preset + addons */
|
||||
defaultmap= wm_keymap_preset(wm, keymap);
|
||||
addonmap= WM_keymap_list_find(&wm->addonconf->keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
||||
|
||||
if(addonmap) {
|
||||
if (addonmap) {
|
||||
defaultmap = wm_keymap_copy(defaultmap);
|
||||
wm_keymap_addon_add(defaultmap, addonmap);
|
||||
}
|
||||
@@ -1097,15 +1099,15 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt
|
||||
/* find original item */
|
||||
orig = WM_keymap_item_find_id(defaultmap, kmi->id);
|
||||
|
||||
if(orig) {
|
||||
if (orig) {
|
||||
/* restore to original */
|
||||
if(strcmp(orig->idname, kmi->idname) != 0) {
|
||||
if (strcmp(orig->idname, kmi->idname) != 0) {
|
||||
BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname));
|
||||
WM_keymap_properties_reset(kmi, NULL);
|
||||
}
|
||||
|
||||
if (orig->properties) {
|
||||
if(kmi->properties) {
|
||||
if (kmi->properties) {
|
||||
IDP_FreeProperty(kmi->properties);
|
||||
MEM_freeN(kmi->properties);
|
||||
kmi->properties= NULL;
|
||||
@@ -1129,7 +1131,7 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt
|
||||
}
|
||||
|
||||
/* free temporary keymap */
|
||||
if(addonmap) {
|
||||
if (addonmap) {
|
||||
WM_keymap_free(defaultmap);
|
||||
MEM_freeN(defaultmap);
|
||||
}
|
||||
@@ -1143,7 +1145,7 @@ void WM_keymap_restore_to_default(wmKeyMap *keymap, bContext *C)
|
||||
/* remove keymap from U.user_keymaps and update */
|
||||
usermap= WM_keymap_list_find(&U.user_keymaps, keymap->idname, keymap->spaceid, keymap->regionid);
|
||||
|
||||
if(usermap) {
|
||||
if (usermap) {
|
||||
WM_keymap_free(usermap);
|
||||
BLI_freelinkN(&U.user_keymaps, usermap);
|
||||
|
||||
@@ -1204,7 +1206,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
km = WM_keymap_find_all(C, "Mesh", 0, 0);
|
||||
|
||||
/* some mesh operators are active in object mode too, like add-prim */
|
||||
if(km && km->poll && km->poll((bContext *)C)==0) {
|
||||
if (km && km->poll && km->poll((bContext *)C)==0) {
|
||||
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -1212,7 +1214,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
km = WM_keymap_find_all(C, "Curve", 0, 0);
|
||||
|
||||
/* some curve operators are active in object mode too, like add-prim */
|
||||
if(km && km->poll && km->poll((bContext *)C)==0) {
|
||||
if (km && km->poll && km->poll((bContext *)C)==0) {
|
||||
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -1236,7 +1238,7 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, const char *opname)
|
||||
km = WM_keymap_find_all(C, "Metaball", 0, 0);
|
||||
|
||||
/* some mball operators are active in object mode too, like add-prim */
|
||||
if(km && km->poll && km->poll((bContext *)C)==0) {
|
||||
if (km && km->poll && km->poll((bContext *)C)==0) {
|
||||
km = WM_keymap_find_all(C, "Object Mode", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -87,7 +87,7 @@ void wm_subwindows_free(wmWindow *win)
|
||||
{
|
||||
wmSubWindow *swin;
|
||||
|
||||
for(swin= win->subwindows.first; swin; swin= swin->next)
|
||||
for (swin= win->subwindows.first; swin; swin= swin->next)
|
||||
wm_subwindow_free(swin);
|
||||
|
||||
BLI_freelistN(&win->subwindows);
|
||||
@@ -96,7 +96,7 @@ void wm_subwindows_free(wmWindow *win)
|
||||
|
||||
int wm_subwindow_get(wmWindow *win)
|
||||
{
|
||||
if(win->curswin)
|
||||
if (win->curswin)
|
||||
return win->curswin->swinid;
|
||||
return 0;
|
||||
}
|
||||
@@ -105,8 +105,8 @@ static wmSubWindow *swin_from_swinid(wmWindow *win, int swinid)
|
||||
{
|
||||
wmSubWindow *swin;
|
||||
|
||||
for(swin= win->subwindows.first; swin; swin= swin->next)
|
||||
if(swin->swinid==swinid)
|
||||
for (swin= win->subwindows.first; swin; swin= swin->next)
|
||||
if (swin->swinid==swinid)
|
||||
break;
|
||||
return swin;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ void wm_subwindow_getsize(wmWindow *win, int swinid, int *x, int *y)
|
||||
{
|
||||
wmSubWindow *swin= swin_from_swinid(win, swinid);
|
||||
|
||||
if(swin) {
|
||||
if (swin) {
|
||||
*x= swin->winrct.xmax - swin->winrct.xmin + 1;
|
||||
*y= swin->winrct.ymax - swin->winrct.ymin + 1;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ void wm_subwindow_getorigin(wmWindow *win, int swinid, int *x, int *y)
|
||||
{
|
||||
wmSubWindow *swin= swin_from_swinid(win, swinid);
|
||||
|
||||
if(swin) {
|
||||
if (swin) {
|
||||
*x= swin->winrct.xmin;
|
||||
*y= swin->winrct.ymin;
|
||||
}
|
||||
@@ -135,9 +135,9 @@ void wm_subwindow_getmatrix(wmWindow *win, int swinid, float mat[][4])
|
||||
{
|
||||
wmSubWindow *swin= swin_from_swinid(win, swinid);
|
||||
|
||||
if(swin) {
|
||||
if (swin) {
|
||||
/* used by UI, should find a better way to get the matrix there */
|
||||
if(swinid == win->screen->mainwin) {
|
||||
if (swinid == win->screen->mainwin) {
|
||||
int width, height;
|
||||
|
||||
wm_subwindow_getsize(win, swin->swinid, &width, &height);
|
||||
@@ -156,14 +156,14 @@ int wm_subwindow_open(wmWindow *win, rcti *winrct)
|
||||
int width, height;
|
||||
int freewinid= 1;
|
||||
|
||||
for(swin= win->subwindows.first; swin; swin= swin->next)
|
||||
if(freewinid <= swin->swinid)
|
||||
for (swin= win->subwindows.first; swin; swin= swin->next)
|
||||
if (freewinid <= swin->swinid)
|
||||
freewinid= swin->swinid+1;
|
||||
|
||||
win->curswin= swin= MEM_callocN(sizeof(wmSubWindow), "swinopen");
|
||||
BLI_addtail(&win->subwindows, swin);
|
||||
|
||||
if(G.f & G_DEBUG) printf("swin %d added\n", freewinid);
|
||||
if (G.f & G_DEBUG) printf("swin %d added\n", freewinid);
|
||||
swin->swinid= freewinid;
|
||||
swin->winrct= *winrct;
|
||||
|
||||
@@ -201,7 +201,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, rcti *winrct)
|
||||
{
|
||||
wmSubWindow *swin= swin_from_swinid(win, swinid);
|
||||
|
||||
if(swin) {
|
||||
if (swin) {
|
||||
int width, height;
|
||||
|
||||
swin->winrct= *winrct;
|
||||
@@ -246,7 +246,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
|
||||
int width, height;
|
||||
_curswin= swin_from_swinid(win, swinid);
|
||||
|
||||
if(_curswin==NULL) {
|
||||
if (_curswin==NULL) {
|
||||
printf("wmSubWindowSet %d: doesn't exist\n", swinid);
|
||||
return;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, rcti *srct)
|
||||
height= _curswin->winrct.ymax - _curswin->winrct.ymin + 1;
|
||||
glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
|
||||
|
||||
if(srct) {
|
||||
if (srct) {
|
||||
width= srct->xmax - srct->xmin + 1;
|
||||
height= srct->ymax - srct->ymin + 1;
|
||||
glScissor(srct->xmin, srct->ymin, width, height);
|
||||
@@ -300,8 +300,8 @@ void wmOrtho(float x1, float x2, float y1, float y2, float n, float f)
|
||||
void wmOrtho2(float x1, float x2, float y1, float y2)
|
||||
{
|
||||
/* prevent opengl from generating errors */
|
||||
if(x1==x2) x2+=1.0f;
|
||||
if(y1==y2) y2+=1.0f;
|
||||
if (x1==x2) x2+=1.0f;
|
||||
if (y1==y2) y2+=1.0f;
|
||||
|
||||
wmOrtho(x1, x2, y1, y2, -100, 100);
|
||||
}
|
||||
|
||||
@@ -119,33 +119,33 @@ static void wm_window_check_position(rcti *rect)
|
||||
height -= 70;
|
||||
#endif
|
||||
|
||||
if(rect->xmin < 0) {
|
||||
if (rect->xmin < 0) {
|
||||
rect->xmax -= rect->xmin;
|
||||
rect->xmin = 0;
|
||||
}
|
||||
if(rect->ymin < 0) {
|
||||
if (rect->ymin < 0) {
|
||||
rect->ymax -= rect->ymin;
|
||||
rect->ymin = 0;
|
||||
}
|
||||
if(rect->xmax > width) {
|
||||
if (rect->xmax > width) {
|
||||
d= rect->xmax - width;
|
||||
rect->xmax -= d;
|
||||
rect->xmin -= d;
|
||||
}
|
||||
if(rect->ymax > height) {
|
||||
if (rect->ymax > height) {
|
||||
d= rect->ymax - height;
|
||||
rect->ymax -= d;
|
||||
rect->ymin -= d;
|
||||
}
|
||||
|
||||
if(rect->xmin < 0) rect->xmin = 0;
|
||||
if(rect->ymin < 0) rect->ymin = 0;
|
||||
if (rect->xmin < 0) rect->xmin = 0;
|
||||
if (rect->ymin < 0) rect->ymin = 0;
|
||||
}
|
||||
|
||||
|
||||
static void wm_ghostwindow_destroy(wmWindow *win)
|
||||
{
|
||||
if(win->ghostwin) {
|
||||
if (win->ghostwin) {
|
||||
GHOST_DisposeWindow(g_system, win->ghostwin);
|
||||
win->ghostwin= NULL;
|
||||
}
|
||||
@@ -158,11 +158,11 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
wmTimer *wt, *wtnext;
|
||||
|
||||
/* update context */
|
||||
if(C) {
|
||||
if (C) {
|
||||
WM_event_remove_handlers(C, &win->handlers);
|
||||
WM_event_remove_handlers(C, &win->modalhandlers);
|
||||
|
||||
if(CTX_wm_window(C)==win)
|
||||
if (CTX_wm_window(C)==win)
|
||||
CTX_wm_window_set(C, NULL);
|
||||
}
|
||||
|
||||
@@ -172,25 +172,25 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
wm->winactive= NULL;
|
||||
|
||||
/* end running jobs, a job end also removes its timer */
|
||||
for(wt= wm->timers.first; wt; wt= wtnext) {
|
||||
for (wt= wm->timers.first; wt; wt= wtnext) {
|
||||
wtnext= wt->next;
|
||||
if(wt->win==win && wt->event_type==TIMERJOBS)
|
||||
if (wt->win==win && wt->event_type==TIMERJOBS)
|
||||
wm_jobs_timer_ended(wm, wt);
|
||||
}
|
||||
|
||||
/* timer removing, need to call this api function */
|
||||
for(wt= wm->timers.first; wt; wt=wtnext) {
|
||||
for (wt= wm->timers.first; wt; wt=wtnext) {
|
||||
wtnext= wt->next;
|
||||
if(wt->win==win)
|
||||
if (wt->win==win)
|
||||
WM_event_remove_timer(wm, win, wt);
|
||||
}
|
||||
|
||||
if(win->eventstate) MEM_freeN(win->eventstate);
|
||||
if (win->eventstate) MEM_freeN(win->eventstate);
|
||||
|
||||
wm_event_free_all(win);
|
||||
wm_subwindows_free(win);
|
||||
|
||||
if(win->drawdata)
|
||||
if (win->drawdata)
|
||||
MEM_freeN(win->drawdata);
|
||||
|
||||
wm_ghostwindow_destroy(win);
|
||||
@@ -203,8 +203,8 @@ static int find_free_winid(wmWindowManager *wm)
|
||||
wmWindow *win;
|
||||
int id= 1;
|
||||
|
||||
for(win= wm->windows.first; win; win= win->next)
|
||||
if(id <= win->winid)
|
||||
for (win= wm->windows.first; win; win= win->next)
|
||||
if (id <= win->winid)
|
||||
id= win->winid+1;
|
||||
|
||||
return id;
|
||||
@@ -254,16 +254,16 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
bScreen *screen= win->screen;
|
||||
|
||||
/* first check if we have any non-temp remaining windows */
|
||||
if((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved){
|
||||
if(wm->windows.first) {
|
||||
for(tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next){
|
||||
if(tmpwin == win)
|
||||
if ((U.uiflag & USER_QUIT_PROMPT) && !wm->file_saved) {
|
||||
if (wm->windows.first) {
|
||||
for (tmpwin = wm->windows.first; tmpwin; tmpwin = tmpwin->next) {
|
||||
if (tmpwin == win)
|
||||
continue;
|
||||
if(tmpwin->screen->temp == 0)
|
||||
if (tmpwin->screen->temp == 0)
|
||||
break;
|
||||
}
|
||||
if(tmpwin == NULL){
|
||||
if(!GHOST_confirmQuit(win->ghostwin))
|
||||
if (tmpwin == NULL) {
|
||||
if (!GHOST_confirmQuit(win->ghostwin))
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -280,18 +280,18 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
wm_window_free(C, wm, win);
|
||||
|
||||
/* if temp screen, delete it after window free (it stops jobs that can access it) */
|
||||
if(screen->temp) {
|
||||
if (screen->temp) {
|
||||
Main *bmain= CTX_data_main(C);
|
||||
free_libblock(&bmain->screen, screen);
|
||||
}
|
||||
|
||||
/* check remaining windows */
|
||||
if(wm->windows.first) {
|
||||
for(win= wm->windows.first; win; win= win->next)
|
||||
if(win->screen->temp == 0)
|
||||
if (wm->windows.first) {
|
||||
for (win= wm->windows.first; win; win= win->next)
|
||||
if (win->screen->temp == 0)
|
||||
break;
|
||||
/* in this case we close all */
|
||||
if(win==NULL)
|
||||
if (win==NULL)
|
||||
WM_exit(C);
|
||||
}
|
||||
else
|
||||
@@ -301,15 +301,15 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
|
||||
void wm_window_title(wmWindowManager *wm, wmWindow *win)
|
||||
{
|
||||
/* handle the 'temp' window, only set title when not set before */
|
||||
if(win->screen && win->screen->temp) {
|
||||
if (win->screen && win->screen->temp) {
|
||||
char *title= GHOST_GetTitle(win->ghostwin);
|
||||
if(title==NULL || title[0]==0)
|
||||
if (title==NULL || title[0]==0)
|
||||
GHOST_SetTitle(win->ghostwin, "Blender");
|
||||
}
|
||||
else {
|
||||
|
||||
/* this is set to 1 if you don't have startup.blend open */
|
||||
if(G.save_over && G.main->name[0]) {
|
||||
if (G.save_over && G.main->name[0]) {
|
||||
char str[sizeof(G.main->name) + 12];
|
||||
BLI_snprintf(str, sizeof(str), "Blender%s [%s]", wm->file_saved ? "":"*", G.main->name);
|
||||
GHOST_SetTitle(win->ghostwin, str);
|
||||
@@ -323,7 +323,7 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
|
||||
GHOST_SetWindowModifiedState(win->ghostwin, (GHOST_TUns8)!wm->file_saved);
|
||||
|
||||
#if defined(__APPLE__) && !defined(GHOST_COCOA)
|
||||
if(wm->file_saved)
|
||||
if (wm->file_saved)
|
||||
GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateUnModified);
|
||||
else
|
||||
GHOST_SetWindowState(win->ghostwin, GHOST_kWindowStateModified);
|
||||
@@ -365,13 +365,13 @@ static void wm_window_add_ghostwindow(const char *title, wmWindow *win)
|
||||
win->ghostwin= ghostwin;
|
||||
GHOST_SetWindowUserData(ghostwin, win); /* pointer back */
|
||||
|
||||
if(win->eventstate==NULL)
|
||||
if (win->eventstate==NULL)
|
||||
win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state");
|
||||
|
||||
/* until screens get drawn, make it nice grey */
|
||||
glClearColor(.55, .55, .55, 0.0);
|
||||
/* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */
|
||||
if(!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
|
||||
if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ void wm_window_add_ghostwindows(wmWindowManager *wm)
|
||||
wm_window_add_ghostwindow("Blender", win);
|
||||
}
|
||||
/* happens after fileread */
|
||||
if(win->eventstate==NULL)
|
||||
if (win->eventstate==NULL)
|
||||
win->eventstate= MEM_callocN(sizeof(wmEvent), "window event state");
|
||||
|
||||
/* add keymap handlers (1 handler for all keys in map!) */
|
||||
@@ -488,12 +488,12 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
|
||||
wm_window_check_position(position);
|
||||
|
||||
/* test if we have a temp screen already */
|
||||
for(win= CTX_wm_manager(C)->windows.first; win; win= win->next)
|
||||
if(win->screen->temp)
|
||||
for (win= CTX_wm_manager(C)->windows.first; win; win= win->next)
|
||||
if (win->screen->temp)
|
||||
break;
|
||||
|
||||
/* add new window? */
|
||||
if(win==NULL) {
|
||||
if (win==NULL) {
|
||||
win= wm_window_new(C);
|
||||
|
||||
win->posx= position->xmin;
|
||||
@@ -503,13 +503,13 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
|
||||
win->sizex= position->xmax - position->xmin;
|
||||
win->sizey= position->ymax - position->ymin;
|
||||
|
||||
if(win->ghostwin) {
|
||||
if (win->ghostwin) {
|
||||
wm_window_set_size(win, win->sizex, win->sizey);
|
||||
wm_window_raise(win);
|
||||
}
|
||||
|
||||
/* add new screen? */
|
||||
if(win->screen==NULL)
|
||||
if (win->screen==NULL)
|
||||
win->screen= ED_screen_add(win, CTX_data_scene(C), "temp");
|
||||
win->screen->temp = 1;
|
||||
|
||||
@@ -521,7 +521,7 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
|
||||
sa= win->screen->areabase.first;
|
||||
CTX_wm_area_set(C, sa);
|
||||
|
||||
if(type==WM_WINDOW_RENDER) {
|
||||
if (type==WM_WINDOW_RENDER) {
|
||||
ED_area_newspace(C, sa, SPACE_IMAGE);
|
||||
}
|
||||
else {
|
||||
@@ -530,11 +530,11 @@ void WM_window_open_temp(bContext *C, rcti *position, int type)
|
||||
|
||||
ED_screen_set(C, win->screen);
|
||||
|
||||
if(sa->spacetype==SPACE_IMAGE)
|
||||
if (sa->spacetype==SPACE_IMAGE)
|
||||
GHOST_SetTitle(win->ghostwin, IFACE_("Blender Render"));
|
||||
else if(ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF))
|
||||
else if (ELEM(sa->spacetype, SPACE_OUTLINER, SPACE_USERPREF))
|
||||
GHOST_SetTitle(win->ghostwin, IFACE_("Blender User Preferences"));
|
||||
else if(sa->spacetype==SPACE_FILE)
|
||||
else if (sa->spacetype==SPACE_FILE)
|
||||
GHOST_SetTitle(win->ghostwin, IFACE_("Blender File View"));
|
||||
else
|
||||
GHOST_SetTitle(win->ghostwin, "Blender");
|
||||
@@ -561,11 +561,11 @@ int wm_window_fullscreen_toggle_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
wmWindow *window= CTX_wm_window(C);
|
||||
GHOST_TWindowState state;
|
||||
|
||||
if(G.background)
|
||||
if (G.background)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
state= GHOST_GetWindowState(window->ghostwin);
|
||||
if(state!=GHOST_kWindowStateFullScreen)
|
||||
if (state!=GHOST_kWindowStateFullScreen)
|
||||
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateFullScreen);
|
||||
else
|
||||
GHOST_SetWindowState(window->ghostwin, GHOST_kWindowStateNormal);
|
||||
@@ -625,7 +625,7 @@ void wm_window_make_drawable(bContext *C, wmWindow *win)
|
||||
// win->lmbut= 0; /* keeps hanging when mousepressed while other window opened */
|
||||
|
||||
wm->windrawable= win;
|
||||
if(G.f & G_DEBUG) printf("set drawable %d\n", win->winid);
|
||||
if (G.f & G_DEBUG) printf("set drawable %d\n", win->winid);
|
||||
GHOST_ActivateWindowDrawingContext(win->ghostwin);
|
||||
}
|
||||
}
|
||||
@@ -640,7 +640,8 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
|
||||
if (type == GHOST_kEventQuit) {
|
||||
WM_exit(C);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
GHOST_WindowHandle ghostwin= GHOST_GetEventWindow(evt);
|
||||
GHOST_TEventDataPtr data= GHOST_GetEventData(evt);
|
||||
wmWindow *win;
|
||||
@@ -650,12 +651,14 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
// what is it?
|
||||
puts("<!> event has no window");
|
||||
return 1;
|
||||
} else if (!GHOST_ValidWindow(g_system, ghostwin)) {
|
||||
}
|
||||
else if (!GHOST_ValidWindow(g_system, ghostwin)) {
|
||||
// XXX - should be checked, why are we getting an event here, and
|
||||
// what is it?
|
||||
puts("<!> event has invalid window");
|
||||
return 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
win= GHOST_GetWindowUserData(ghostwin);
|
||||
}
|
||||
|
||||
@@ -713,7 +716,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
break;
|
||||
}
|
||||
case GHOST_kEventWindowUpdate: {
|
||||
if(G.f & G_DEBUG) printf("ghost redraw\n");
|
||||
if (G.f & G_DEBUG) printf("ghost redraw\n");
|
||||
|
||||
wm_window_make_drawable(C, win);
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
@@ -727,7 +730,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
win->windowstate = state;
|
||||
|
||||
/* win32: gives undefined window size when minimized */
|
||||
if(state!=GHOST_kWindowStateMinimized) {
|
||||
if (state!=GHOST_kWindowStateMinimized) {
|
||||
GHOST_RectangleHandle client_rect;
|
||||
int l, t, r, b, scr_w, scr_h;
|
||||
int sizex, sizey, posx, posy;
|
||||
@@ -762,24 +765,24 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
win->posy= posy;
|
||||
|
||||
/* debug prints */
|
||||
if(0) {
|
||||
if (0) {
|
||||
state = GHOST_GetWindowState(win->ghostwin);
|
||||
|
||||
if(state==GHOST_kWindowStateNormal) {
|
||||
if(G.f & G_DEBUG) printf("window state: normal\n");
|
||||
if (state==GHOST_kWindowStateNormal) {
|
||||
if (G.f & G_DEBUG) printf("window state: normal\n");
|
||||
}
|
||||
else if(state==GHOST_kWindowStateMinimized) {
|
||||
if(G.f & G_DEBUG) printf("window state: minimized\n");
|
||||
else if (state==GHOST_kWindowStateMinimized) {
|
||||
if (G.f & G_DEBUG) printf("window state: minimized\n");
|
||||
}
|
||||
else if(state==GHOST_kWindowStateMaximized) {
|
||||
if(G.f & G_DEBUG) printf("window state: maximized\n");
|
||||
else if (state==GHOST_kWindowStateMaximized) {
|
||||
if (G.f & G_DEBUG) printf("window state: maximized\n");
|
||||
}
|
||||
else if(state==GHOST_kWindowStateFullScreen) {
|
||||
if(G.f & G_DEBUG) printf("window state: fullscreen\n");
|
||||
else if (state==GHOST_kWindowStateFullScreen) {
|
||||
if (G.f & G_DEBUG) printf("window state: fullscreen\n");
|
||||
}
|
||||
|
||||
if(type!=GHOST_kEventWindowSize) {
|
||||
if(G.f & G_DEBUG) {
|
||||
if (type!=GHOST_kEventWindowSize) {
|
||||
if (G.f & G_DEBUG) {
|
||||
printf("win move event pos %d %d size %d %d\n",
|
||||
win->posx, win->posy, win->sizex, win->sizey);
|
||||
}
|
||||
@@ -856,11 +859,11 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
|
||||
/* add drag data to wm for paths: */
|
||||
|
||||
if(ddd->dataType == GHOST_kDragnDropTypeFilenames) {
|
||||
if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
|
||||
GHOST_TStringArray *stra= ddd->data;
|
||||
int a, icon;
|
||||
|
||||
for(a=0; a<stra->count; a++) {
|
||||
for (a=0; a<stra->count; a++) {
|
||||
printf("drop file %s\n", stra->strings[a]);
|
||||
/* try to get icon type from extension */
|
||||
icon= ED_file_extension_icon((char *)stra->strings[a]);
|
||||
@@ -900,22 +903,22 @@ static int wm_window_timer(const bContext *C)
|
||||
double time= PIL_check_seconds_timer();
|
||||
int retval= 0;
|
||||
|
||||
for(wt= wm->timers.first; wt; wt= wtnext) {
|
||||
for (wt= wm->timers.first; wt; wt= wtnext) {
|
||||
wtnext= wt->next; /* in case timer gets removed */
|
||||
win= wt->win;
|
||||
|
||||
if(wt->sleep==0) {
|
||||
if(time > wt->ntime) {
|
||||
if (wt->sleep==0) {
|
||||
if (time > wt->ntime) {
|
||||
wt->delta= time - wt->ltime;
|
||||
wt->duration += wt->delta;
|
||||
wt->ltime= time;
|
||||
wt->ntime= wt->stime + wt->timestep*ceil(wt->duration/wt->timestep);
|
||||
|
||||
if(wt->event_type == TIMERJOBS)
|
||||
if (wt->event_type == TIMERJOBS)
|
||||
wm_jobs_timer(C, wm, wt);
|
||||
else if(wt->event_type == TIMERAUTOSAVE)
|
||||
else if (wt->event_type == TIMERAUTOSAVE)
|
||||
wm_autosave_timer(C, wm, wt);
|
||||
else if(win) {
|
||||
else if (win) {
|
||||
wmEvent event= *(win->eventstate);
|
||||
|
||||
event.type= wt->event_type;
|
||||
@@ -935,19 +938,19 @@ void wm_window_process_events(const bContext *C)
|
||||
{
|
||||
int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
|
||||
|
||||
if(hasevent)
|
||||
if (hasevent)
|
||||
GHOST_DispatchEvents(g_system);
|
||||
|
||||
hasevent |= wm_window_timer(C);
|
||||
|
||||
/* no event, we sleep 5 milliseconds */
|
||||
if(hasevent==0)
|
||||
if (hasevent==0)
|
||||
PIL_sleep_ms(5);
|
||||
}
|
||||
|
||||
void wm_window_process_events_nosleep(void)
|
||||
{
|
||||
if(GHOST_ProcessEvents(g_system, 0))
|
||||
if (GHOST_ProcessEvents(g_system, 0))
|
||||
GHOST_DispatchEvents(g_system);
|
||||
}
|
||||
|
||||
@@ -963,7 +966,7 @@ void wm_window_testbreak(void)
|
||||
if ((curtime-ltime)>.05) {
|
||||
int hasevent= GHOST_ProcessEvents(g_system, 0); /* 0 is no wait */
|
||||
|
||||
if(hasevent)
|
||||
if (hasevent)
|
||||
GHOST_DispatchEvents(g_system);
|
||||
|
||||
ltime= curtime;
|
||||
@@ -984,7 +987,7 @@ void wm_ghost_init(bContext *C)
|
||||
|
||||
void wm_ghost_exit(void)
|
||||
{
|
||||
if(g_system)
|
||||
if (g_system)
|
||||
GHOST_DisposeSystem(g_system);
|
||||
|
||||
g_system= NULL;
|
||||
@@ -997,11 +1000,11 @@ void WM_event_timer_sleep(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *t
|
||||
{
|
||||
wmTimer *wt;
|
||||
|
||||
for(wt= wm->timers.first; wt; wt= wt->next)
|
||||
if(wt==timer)
|
||||
for (wt= wm->timers.first; wt; wt= wt->next)
|
||||
if (wt==timer)
|
||||
break;
|
||||
|
||||
if(wt)
|
||||
if (wt)
|
||||
wt->sleep= dosleep;
|
||||
}
|
||||
|
||||
@@ -1026,15 +1029,15 @@ void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *
|
||||
wmTimer *wt;
|
||||
|
||||
/* extra security check */
|
||||
for(wt= wm->timers.first; wt; wt= wt->next)
|
||||
if(wt==timer)
|
||||
for (wt= wm->timers.first; wt; wt= wt->next)
|
||||
if (wt==timer)
|
||||
break;
|
||||
if(wt) {
|
||||
if(wm->reports.reporttimer == wt)
|
||||
if (wt) {
|
||||
if (wm->reports.reporttimer == wt)
|
||||
wm->reports.reporttimer= NULL;
|
||||
|
||||
BLI_remlink(&wm->timers, wt);
|
||||
if(wt->customdata)
|
||||
if (wt->customdata)
|
||||
MEM_freeN(wt->customdata);
|
||||
MEM_freeN(wt);
|
||||
}
|
||||
@@ -1046,18 +1049,18 @@ char *WM_clipboard_text_get(int selection)
|
||||
{
|
||||
char *p, *p2, *buf, *newbuf;
|
||||
|
||||
if(G.background)
|
||||
if (G.background)
|
||||
return NULL;
|
||||
|
||||
buf= (char*)GHOST_getClipboard(selection);
|
||||
if(!buf)
|
||||
if (!buf)
|
||||
return NULL;
|
||||
|
||||
/* always convert from \r\n to \n */
|
||||
newbuf= MEM_callocN(strlen(buf)+1, "WM_clipboard_text_get");
|
||||
|
||||
for(p= buf, p2= newbuf; *p; p++) {
|
||||
if(*p != '\r')
|
||||
for (p= buf, p2= newbuf; *p; p++) {
|
||||
if (*p != '\r')
|
||||
*(p2++)= *p;
|
||||
}
|
||||
*p2= '\0';
|
||||
@@ -1069,14 +1072,14 @@ char *WM_clipboard_text_get(int selection)
|
||||
|
||||
void WM_clipboard_text_set(char *buf, int selection)
|
||||
{
|
||||
if(!G.background) {
|
||||
if (!G.background) {
|
||||
#ifdef _WIN32
|
||||
/* do conversion from \n to \r\n on Windows */
|
||||
char *p, *p2, *newbuf;
|
||||
int newlen= 0;
|
||||
|
||||
for(p= buf; *p; p++) {
|
||||
if(*p == '\n')
|
||||
for (p= buf; *p; p++) {
|
||||
if (*p == '\n')
|
||||
newlen += 2;
|
||||
else
|
||||
newlen++;
|
||||
@@ -1084,8 +1087,8 @@ void WM_clipboard_text_set(char *buf, int selection)
|
||||
|
||||
newbuf= MEM_callocN(newlen+1, "WM_clipboard_text_set");
|
||||
|
||||
for(p= buf, p2= newbuf; *p; p++, p2++) {
|
||||
if(*p == '\n') {
|
||||
for (p= buf, p2= newbuf; *p; p++, p2++) {
|
||||
if (*p == '\n') {
|
||||
*(p2++)= '\r'; *p2= '\n';
|
||||
}
|
||||
else *p2= *p;
|
||||
|
||||
Reference in New Issue
Block a user