[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32606] trunk/blender/source/blender/ blenloader: Fix [#21294] Bad object drawing and crash when rendering

Nathan Letwory nathan at letworyinteractive.com
Wed Oct 20 00:17:34 CEST 2010


Revision: 32606
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32606
Author:   jesterking
Date:     2010-10-20 00:17:34 +0200 (Wed, 20 Oct 2010)

Log Message:
-----------
Fix [#21294] Bad object drawing and crash when rendering
Reported and patched by Shane Ambler.

Took the opportunity to silence warnings in readfile.c. For Windows in SCons I enabled /WX
for blenloader. This means that all enabled warnings will throw errors from now on.

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/SConscript
    trunk/blender/source/blender/blenloader/intern/readfile.c

Modified: trunk/blender/source/blender/blenloader/SConscript
===================================================================
--- trunk/blender/source/blender/blenloader/SConscript	2010-10-19 18:59:15 UTC (rev 32605)
+++ trunk/blender/source/blender/blenloader/SConscript	2010-10-19 22:17:34 UTC (rev 32606)
@@ -11,4 +11,7 @@
 
 defs = []
 
-env.BlenderLib ( 'bf_blenloader', sources, Split(incs), defs, libtype=['core','player'], priority = [167,30] )
+if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
+    env.BlenderLib ( 'bf_blenloader', sources, Split(incs), defs, libtype=['core','player'], priority = [167,30], cc_compileflags=['/WX'] )
+else:
+    env.BlenderLib ( 'bf_blenloader', sources, Split(incs), defs, libtype=['core','player'], priority = [167,30] )

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2010-10-19 18:59:15 UTC (rev 32605)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2010-10-19 22:17:34 UTC (rev 32606)
@@ -831,8 +831,8 @@
 
 static int fd_read_from_memory(FileData *filedata, void *buffer, unsigned int size)
 {
-		// don't read more bytes then there are available in the buffer
-	int readsize = MIN2(size, filedata->buffersize - filedata->seek);
+	// don't read more bytes then there are available in the buffer
+	int readsize = (int)MIN2(size, (unsigned int)(filedata->buffersize - filedata->seek));
 
 	memcpy(buffer, filedata->buffer + filedata->seek, readsize);
 	filedata->seek += readsize;
@@ -3252,10 +3252,21 @@
 
 		for(i = 0; i < count; ++i) {
 			mdisps[i].disps = newdataadr(fd, mdisps[i].disps);
+
+			if( (fd->flags & FD_FLAGS_SWITCH_ENDIAN) && (mdisps[i].disps) ) {
+				/* DNA_struct_switch_endian doesn't do endian swap for (*disps)[] */
+				/* this does swap for data written at write_mdisps() - readfile.c */
+				int x;
+				float *tmpdisps= *mdisps[i].disps;
+				for(x=0;x<mdisps[i].totdisp*3;x++) {
+					SWITCH_INT(*tmpdisps);
+					tmpdisps++;
+				}
+			}
 			if(!external && !mdisps[i].disps)
 				mdisps[i].totdisp = 0;
 		}
-	}       
+	}
 }
 
 static void direct_link_customdata(FileData *fd, CustomData *data, int count)
@@ -6505,23 +6516,23 @@
 	for	(con=lb->first; con; con=con->next) {
 		if(con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) {
 			bRigidBodyJointConstraint *data = con->data;
-			data->axX *= M_PI/180.0;
-			data->axY *= M_PI/180.0;
-			data->axZ *= M_PI/180.0;
+			data->axX *= (float)(M_PI/180.0);
+			data->axY *= (float)(M_PI/180.0);
+			data->axZ *= (float)(M_PI/180.0);
 		}
 		else if(con->type==CONSTRAINT_TYPE_KINEMATIC) {
 			bKinematicConstraint *data = con->data;
-			data->poleangle *= M_PI/180.0;
+			data->poleangle *= (float)(M_PI/180.0);
 		}
 		else if(con->type==CONSTRAINT_TYPE_ROTLIMIT) {
 			bRotLimitConstraint *data = con->data;
 
-			data->xmin *= M_PI/180.0;
-			data->xmax *= M_PI/180.0;
-			data->ymin *= M_PI/180.0;
-			data->ymax *= M_PI/180.0;
-			data->zmin *= M_PI/180.0;
-			data->zmax *= M_PI/180.0;
+			data->xmin *= (float)(M_PI/180.0);
+			data->xmax *= (float)(M_PI/180.0);
+			data->ymin *= (float)(M_PI/180.0);
+			data->ymax *= (float)(M_PI/180.0);
+			data->zmin *= (float)(M_PI/180.0);
+			data->zmax *= (float)(M_PI/180.0);
 		}
 	}
 }
@@ -9546,7 +9557,7 @@
 		/* Adjustments needed after Bullets update */
 		for(ob = main->object.first; ob; ob= ob->id.next) {
 			ob->damping *= 0.635f;
-			ob->rdamping = 0.1 + (0.8f * ob->rdamping);
+			ob->rdamping = 0.1f + (0.8f * ob->rdamping);
 		}
 	}
 	
@@ -9626,8 +9637,7 @@
 							seq->strip->proxy->size
 								= sce->r.size;
 						} else {
-							seq->strip->proxy->size
-								= 25.0;
+							seq->strip->proxy->size = 25;
 						}
 						seq->strip->proxy->quality =90;
 					}
@@ -10077,14 +10087,14 @@
 		
 		for(sce= main->scene.first; sce; sce= sce->id.next)
 		{
-			if(sce->audio.main == 0.0)
-				sce->audio.main = 1.0;
+			if(sce->audio.main == 0.0f)
+				sce->audio.main = 1.0f;
 
 			sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate;
 			sce->r.ffcodecdata.audio_volume = sce->audio.main;
-			sce->audio.distance_model = 2.0;
-			sce->audio.doppler_factor = 1.0;
-			sce->audio.speed_of_sound = 343.3;
+			sce->audio.distance_model = 2;
+			sce->audio.doppler_factor = 1.0f;
+			sce->audio.speed_of_sound = 343.3f;
 		}
 
 		/* Add default gravity to scenes */
@@ -10110,11 +10120,11 @@
 				for(md= ob->modifiers.first; md; md= md->next) {
 					ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
 					if(clmd)
-						clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2]/-9.81;
+						clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2]/-9.81f;
 				}
 
 				if(ob->soft)
-					ob->soft->effector_weights->global_gravity = ob->soft->grav/9.81;
+					ob->soft->effector_weights->global_gravity = ob->soft->grav/9.81f;
 			}
 
 			/* Normal wind shape is plane */
@@ -10499,7 +10509,7 @@
 		
 		/* game engine changes */
 		for(sce = main->scene.first; sce; sce = sce->id.next) {
-			sce->gm.eyeseparation = 0.10;
+			sce->gm.eyeseparation = 0.10f;
 		}
 		
 		/* anim viz changes */
@@ -10604,12 +10614,12 @@
 
 			if (ob->pose) {
 				for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
-					pchan->limitmin[0] *= M_PI/180.0;
-					pchan->limitmin[1] *= M_PI/180.0;
-					pchan->limitmin[2] *= M_PI/180.0;
-					pchan->limitmax[0] *= M_PI/180.0;
-					pchan->limitmax[1] *= M_PI/180.0;
-					pchan->limitmax[2] *= M_PI/180.0;
+					pchan->limitmin[0] *= (float)(M_PI/180.0);
+					pchan->limitmin[1] *= (float)(M_PI/180.0);
+					pchan->limitmin[2] *= (float)(M_PI/180.0);
+					pchan->limitmax[0] *= (float)(M_PI/180.0);
+					pchan->limitmax[1] *= (float)(M_PI/180.0);
+					pchan->limitmax[2] *= (float)(M_PI/180.0);
 
 					do_version_constraints_radians_degrees_250(&pchan->constraints);
 				}
@@ -10708,7 +10718,7 @@
 			int a;
 
 			for(a=0; a<PE_TOT_BRUSH; a++)
-				pset->brush[a].strength /= 100.0;
+				pset->brush[a].strength /= 100.0f;
 		}
 
 		for(ma = main->mat.first; ma; ma=ma->id.next)
@@ -10989,7 +10999,7 @@
 
 			// bad radius
 			if (brush->unprojected_radius == 0)
-				brush->unprojected_radius = 0.125;
+				brush->unprojected_radius = 0.125f;
 
 			// unusable size
 			if (brush->size == 0)
@@ -11031,18 +11041,18 @@
 					brush->add_col[1] == 0 &&
 					brush->add_col[2] == 0)
 				{
-					brush->add_col[0] = 1.00;
-					brush->add_col[1] = 0.39;
-					brush->add_col[2] = 0.39;
+					brush->add_col[0] = 1.00f;
+					brush->add_col[1] = 0.39f;
+					brush->add_col[2] = 0.39f;
 				}
 
 				if (brush->sub_col[0] == 0 &&
 					brush->sub_col[1] == 0 &&
 					brush->sub_col[2] == 0)
 				{
-					brush->sub_col[0] = 0.39;
-					brush->sub_col[1] = 0.39;
-					brush->sub_col[2] = 1.00;
+					brush->sub_col[0] = 0.39f;
+					brush->sub_col[1] = 0.39f;
+					brush->sub_col[2] = 1.00f;
 				}
 			}
 		}





More information about the Bf-blender-cvs mailing list