[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15501] branches/apricot: svn merge -r15491:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/ blender

Campbell Barton ideasman42 at gmail.com
Wed Jul 9 14:51:54 CEST 2008


Revision: 15501
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15501
Author:   campbellbarton
Date:     2008-07-09 14:51:53 +0200 (Wed, 09 Jul 2008)

Log Message:
-----------
svn  merge  -r15491:HEAD https://svn.blender.org/svnroot/bf-blender/trunk/blender

Modified Paths:
--------------
    branches/apricot/source/blender/imbuf/intern/openexr/openexr_api.cpp
    branches/apricot/source/blender/nodes/intern/CMP_nodes/CMP_gamma.c
    branches/apricot/source/gameengine/Ketsji/KX_GameObject.cpp
    branches/apricot/source/gameengine/Ketsji/KX_GameObject.h
    branches/apricot/source/gameengine/Ketsji/KX_TouchEventManager.cpp
    branches/apricot/tools/Blender.py

Modified: branches/apricot/source/blender/imbuf/intern/openexr/openexr_api.cpp
===================================================================
--- branches/apricot/source/blender/imbuf/intern/openexr/openexr_api.cpp	2008-07-09 10:51:03 UTC (rev 15500)
+++ branches/apricot/source/blender/imbuf/intern/openexr/openexr_api.cpp	2008-07-09 12:51:53 UTC (rev 15501)
@@ -842,7 +842,7 @@
 } RGBA;
 
 
-#if 0
+/* debug only */
 static void exr_print_filecontents(InputFile *file)
 {
 	const ChannelList &channels = file->header().channels();
@@ -853,8 +853,29 @@
 		printf("OpenEXR-load: Found channel %s of type %d\n", i.name(), channel.type);
 	}
 }
-#endif
 
+/* for non-multilayer, map  R G B A channel names to something that's in this file */
+static const char *exr_rgba_channelname(InputFile *file, const char *chan)
+{
+	const ChannelList &channels = file->header().channels();
+	
+	for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i)
+	{
+		const Channel &channel = i.channel();
+		const char *str= i.name();
+		int len= strlen(str);
+		if(len) {
+			if(strcasecmp(chan, str+len-1)==0) {
+				printf("name %s\n", str);
+				return str;
+			}
+		}
+	}
+	return chan;
+}
+
+
+
 static int exr_has_zbuffer(InputFile *file)
 {
 	const ChannelList &channels = file->header().channels();
@@ -896,7 +917,8 @@
 		//printf("OpenEXR-load: image data window %d %d %d %d\n", 
 		//	   dw.min.x, dw.min.y, dw.max.x, dw.max.y);
 
-		// exr_print_filecontents(file);
+		if(0) // debug
+			exr_print_filecontents(file);
 		
 		is_multi= exr_is_renderresult(file);
 		
@@ -935,11 +957,15 @@
 					/* but, since we read y-flipped (negative y stride) we move to last scanline */
 					first+= 4*(height-1)*width;
 					
-					frameBuffer.insert ("R", Slice (FLOAT,  (char *) first, xstride, ystride));
-					frameBuffer.insert ("G", Slice (FLOAT,  (char *) (first+1), xstride, ystride));
-					frameBuffer.insert ("B", Slice (FLOAT,  (char *) (first+2), xstride, ystride));
-																			/* 1.0 is fill value */
-					frameBuffer.insert ("A", Slice (FLOAT,  (char *) (first+3), xstride, ystride, 1, 1, 1.0f));
+					frameBuffer.insert ( exr_rgba_channelname(file, "R"), 
+										Slice (FLOAT,  (char *) first, xstride, ystride));
+					frameBuffer.insert ( exr_rgba_channelname(file, "G"), 
+										Slice (FLOAT,  (char *) (first+1), xstride, ystride));
+					frameBuffer.insert ( exr_rgba_channelname(file, "B"), 
+										Slice (FLOAT,  (char *) (first+2), xstride, ystride));
+																			
+					frameBuffer.insert ( exr_rgba_channelname(file, "A"), 
+										Slice (FLOAT,  (char *) (first+3), xstride, ystride, 1, 1, 1.0f)); /* 1.0 is fill value */
 
 					if(exr_has_zbuffer(file)) 
 					{

Modified: branches/apricot/source/blender/nodes/intern/CMP_nodes/CMP_gamma.c
===================================================================
--- branches/apricot/source/blender/nodes/intern/CMP_nodes/CMP_gamma.c	2008-07-09 10:51:03 UTC (rev 15500)
+++ branches/apricot/source/blender/nodes/intern/CMP_nodes/CMP_gamma.c	2008-07-09 12:51:53 UTC (rev 15501)
@@ -47,7 +47,7 @@
 	int i=0;
 	for(i=0; i<3; i++) {
 		/* check for negative to avoid nan's */
-		out[i] = (in[0] > 0.0f)? pow(in[i],fac[0]): in[0];
+		out[i] = (in[i] > 0.0f)? pow(in[i],fac[0]): in[i];
 	}
 	out[3] = in[3];
 }

Modified: branches/apricot/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- branches/apricot/source/gameengine/Ketsji/KX_GameObject.cpp	2008-07-09 10:51:03 UTC (rev 15500)
+++ branches/apricot/source/gameengine/Ketsji/KX_GameObject.cpp	2008-07-09 12:51:53 UTC (rev 15501)
@@ -572,7 +572,7 @@
 	m_objectColor = rgbavec;
 }
 
-void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis)
+void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
 {
 	MT_Matrix3x3 orimat;
 	MT_Vector3 vect,ori,z,x,y;
@@ -585,6 +585,11 @@
 		cout << "alignAxisToVect() Error: Null vector!\n";
 		return;
 	}
+	
+	if (fac<=0.0) {
+		return;
+	}
+	
 	// normalize
 	vect /= len;
 	orimat = GetSGNode()->GetWorldOrientation();
@@ -594,7 +599,14 @@
 			ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis
 			if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector paralell to the pivot?
 				ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot!
-			x = vect; 
+			if (fac == 1.0) {
+				x = vect;
+			} else {
+				x = (vect * fac) + ((orimat * MT_Vector3(1.0, 0.0, 0.0)) * (1-fac));
+				len = x.length();
+				if (MT_fuzzyZero(len)) x = vect;
+				else x /= len;
+			}
 			y = ori.cross(x);
 			z = x.cross(y);
 			break;
@@ -602,7 +614,14 @@
 			ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]);
 			if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
 				ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]);
-			y = vect;
+			if (fac == 1.0) {
+				y = vect;
+			} else {
+				y = (vect * fac) + ((orimat * MT_Vector3(0.0, 1.0, 0.0)) * (1-fac));
+				len = y.length();
+				if (MT_fuzzyZero(len)) y = vect;
+				else y /= len;
+			}
 			z = ori.cross(y);
 			x = y.cross(z);
 			break;
@@ -610,7 +629,14 @@
 			ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]);
 			if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
 				ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]);
-			z = vect;
+			if (fac == 1.0) {
+				z = vect;
+			} else {
+				z = (vect * fac) + ((orimat * MT_Vector3(0.0, 0.0, 1.0)) * (1-fac));
+				len = z.length();
+				if (MT_fuzzyZero(len)) z = vect;
+				else z /= len;
+			}
 			x = ori.cross(z);
 			y = z.cross(x);
 			break;
@@ -1386,13 +1412,14 @@
 {
 	PyObject* pyvect;
 	int axis = 2; //z axis is the default
+	float fac = 1.0;
 	
-	if (PyArg_ParseTuple(args,"O|i",&pyvect,&axis))
+	if (PyArg_ParseTuple(args,"O|if",&pyvect,&axis, &fac))
 	{
 		MT_Vector3 vect;
 		if (PyVecTo(pyvect, vect))
 		{
-			AlignAxisToVect(vect,axis);				
+			AlignAxisToVect(vect,axis,fac);
 			Py_RETURN_NONE;
 		}
 	}

Modified: branches/apricot/source/gameengine/Ketsji/KX_GameObject.h
===================================================================
--- branches/apricot/source/gameengine/Ketsji/KX_GameObject.h	2008-07-09 10:51:03 UTC (rev 15500)
+++ branches/apricot/source/gameengine/Ketsji/KX_GameObject.h	2008-07-09 12:51:53 UTC (rev 15501)
@@ -278,7 +278,8 @@
 		void 
 	AlignAxisToVect(
 		const MT_Vector3& vect,
-		int axis = 2 
+		int axis = 2,
+		float fac = 1.0
 	);
 
 	/** 

Modified: branches/apricot/source/gameengine/Ketsji/KX_TouchEventManager.cpp
===================================================================
--- branches/apricot/source/gameengine/Ketsji/KX_TouchEventManager.cpp	2008-07-09 10:51:03 UTC (rev 15500)
+++ branches/apricot/source/gameengine/Ketsji/KX_TouchEventManager.cpp	2008-07-09 12:51:53 UTC (rev 15501)
@@ -137,14 +137,18 @@
 //			KX_GameObject* gameOb1 = ctrl1->getClientInfo();
 
 			KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo *>(ctrl1->getNewClientInfo());
-	
 			list<SCA_ISensor*>::iterator sit;
-			for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit)
-				static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).first, (*cit).second, NULL);
-		
+			if (client_info) {
+				for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
+					static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).first, (*cit).second, NULL);
+				}
+			}
 			client_info = static_cast<KX_ClientObjectInfo *>((*cit).second->getNewClientInfo());
-			for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit)
-				static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).second, (*cit).first, NULL);
+			if (client_info) {
+				for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
+					static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).second, (*cit).first, NULL);
+				}
+			}
 		}
 			
 		m_newCollisions.clear();

Modified: branches/apricot/tools/Blender.py
===================================================================
--- branches/apricot/tools/Blender.py	2008-07-09 10:51:03 UTC (rev 15500)
+++ branches/apricot/tools/Blender.py	2008-07-09 12:51:53 UTC (rev 15501)
@@ -69,10 +69,10 @@
         dict[libtype][priority] = libname
 
 # libtype and priority can both be lists, for defining lib in multiple places
-def add_lib_to_dict(dict = None, libtype = None, libname = None, priority = 100):
+def add_lib_to_dict(env, dict = None, libtype = None, libname = None, priority = 100):
     if not dict or not libtype or not libname:
         print "Passed wrong arg"
-        Exit()
+        env.Exit()
 
     if type(libtype) is str and type(priority) is int:
         internal_lib_to_dict(dict, libtype, libname, priority)
@@ -82,10 +82,10 @@
                 internal_lib_to_dict(dict, lt, libname, p)
         else:
             print "libtype and priority lists are unequal in length"
-            Exit()
+            env.Exit()
     else:
         print "Wrong type combinations for libtype and priority. Only str and int or list and list"
-        Exit()
+        env.Exit()
 
 def create_blender_liblist(lenv = None, libtype = None):
     if not lenv or not libtype:
@@ -93,11 +93,9 @@
 
     lst = []
     if libtype in possible_types:
-        sortlist = []
-        for k,v in libs[libtype].iteritems():
-            sortlist.append(k)
-        sortlist.sort()
         curlib = libs[libtype]
+        sortlist = curlib.keys()
+        sortlist.sort()
         for sk in sortlist:
             v = curlib[sk]
             lst.append('#' + root_build_dir + 'lib/'+lenv['LIBPREFIX'] + v + lenv['LIBSUFFIX'])
@@ -175,11 +173,10 @@
     for t in possible_types:
         print bc.OKGREEN+"\t"+t+bc.ENDC
         new_priority = 0
-        sortlist = []
-        for k,v in libs[t].iteritems():
-            sortlist.append(k)
-        sortlist.sort()
         curlib = libs[t]
+        sortlist = curlib.keys()
+        sortlist.sort()
+
         for sk in sortlist:
             v = curlib[sk]
             #for p,v in sorted(libs[t].iteritems()):
@@ -368,7 +365,7 @@
         global libs
         if not self or not libname or not source:
             print bc.FAIL+'Cannot continue.  Missing argument for BlenderRes '+libname+bc.ENDC
-            Exit()
+            self.Exit()
         if self['OURPLATFORM'] not in ('win32-vc','win32-mingw','linuxcross'):

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list