[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15040] branches/soc-2008-unclezeiv: svn merge -r 14985:15038 https://svn.blender.org/svnroot/bf-blender/trunk/ blender

Davide Vercelli davide.vercelli at gmail.com
Thu May 29 03:08:12 CEST 2008


Revision: 15040
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15040
Author:   unclezeiv
Date:     2008-05-29 03:08:10 +0200 (Thu, 29 May 2008)

Log Message:
-----------
svn merge -r 14985:15038 https://svn.blender.org/svnroot/bf-blender/trunk/blender

Modified Paths:
--------------
    branches/soc-2008-unclezeiv/release/scripts/uv_seams_from_islands.py
    branches/soc-2008-unclezeiv/release/scripts/uvcalc_lightmap.py
    branches/soc-2008-unclezeiv/source/blender/blenkernel/intern/modifier.c
    branches/soc-2008-unclezeiv/source/blender/blenkernel/intern/object.c
    branches/soc-2008-unclezeiv/source/blender/python/api2_2x/Object.c
    branches/soc-2008-unclezeiv/source/blender/python/api2_2x/doc/Object.py
    branches/soc-2008-unclezeiv/source/blender/python/api2_2x/sceneRender.c
    branches/soc-2008-unclezeiv/source/blender/render/intern/source/envmap.c
    branches/soc-2008-unclezeiv/source/blender/render/intern/source/pipeline.c
    branches/soc-2008-unclezeiv/source/blender/render/intern/source/rayshade.c
    branches/soc-2008-unclezeiv/source/blender/src/drawobject.c
    branches/soc-2008-unclezeiv/source/blender/src/drawview.c
    branches/soc-2008-unclezeiv/source/blender/src/editnode.c
    branches/soc-2008-unclezeiv/source/blender/src/interface.c
    branches/soc-2008-unclezeiv/source/blender/src/meshtools.c
    branches/soc-2008-unclezeiv/source/blender/src/poseobject.c
    branches/soc-2008-unclezeiv/source/blender/src/toets.c

Removed Paths:
-------------
    branches/soc-2008-unclezeiv/release/scripts/uv_from_adjacent.py

Deleted: branches/soc-2008-unclezeiv/release/scripts/uv_from_adjacent.py
===================================================================
--- branches/soc-2008-unclezeiv/release/scripts/uv_from_adjacent.py	2008-05-29 01:04:12 UTC (rev 15039)
+++ branches/soc-2008-unclezeiv/release/scripts/uv_from_adjacent.py	2008-05-29 01:08:10 UTC (rev 15040)
@@ -1,129 +0,0 @@
-#!BPY
-"""
-Name: 'UVs from unselected adjacent'
-Blender: 242
-Group: 'UVCalculation'
-Tooltip: 'Assign UVs to selected faces from surrounding unselected faces.'
-"""
-__author__ = "Campbell Barton"
-__url__ = ("blender", "blenderartists.org")
-__version__ = "1.0 2006/02/07"
-
-__bpydoc__ = """\
-This script sets the UV mapping and image of selected faces from adjacent unselected faces.
-
-Use this script in face select mode for texturing between textured faces.
-"""
-
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# Script copyright (C) Campbell J Barton
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-#
-# ***** END GPL LICENCE BLOCK *****
-# --------------------------------------------------------------------------
-
-
-from Blender import *
-import bpy
-
-def mostUsedImage(imageList): # Returns the image most used in the list.
-	if not imageList:
-		return None
-	elif len(imageList) < 3:
-		return imageList[0]
-	
-	# 3+ Images, Get the most used image for surrounding faces.
-	imageCount = {}
-	for image in imageList:
-		if image:
-			image_key= image.name
-		else:
-			image_key = None
-		
-		try:
-			imageCount[image_key]['imageCount'] +=1 # an extra user of this image
-		except:
-			imageCount[image_key] = {'imageCount':1, 'blenderImage':image} # start with 1 user.
-	
-	# Now a list of tuples, (imageName, {imageCount, image})
-	imageCount = imageCount.items()
-	
-	try:	imageCount.sort(key=lambda a: a[1])
-	except:	imageCount.sort(lambda a,b: cmp(a[1], b[1]))
-	
-	
-	return imageCount[-1][1]['blenderImage']	
-
-
-def main():
-	sce = bpy.data.scenes.active
-	ob = sce.objects.active
-	
-	if ob == None or ob.type != 'Mesh':
-		Draw.PupMenu('ERROR: No mesh object in face select mode.')
-		return
-	me = ob.getData(mesh=1)
-	
-	if not me.faceUV:
-		Draw.PupMenu('ERROR: No mesh object in face select mode.')
-		return
-	
-	selfaces = [f for f in me.faces if f.sel]
-	unselfaces = [f for f in me.faces if not f.sel]
-	
-	
-	# Gather per Vert UV and Image, store in vertUvAverage
-	vertUvAverage = [[[],[]] for i in xrange(len(me.verts))]
-	
-	for f in unselfaces: # Unselected faces only.
-		fuv = f.uv
-		for i,v in enumerate(f):
-			vertUvAverage[v.index][0].append(fuv[i])
-			vertUvAverage[v.index][1].append(f.image)
-			
-	# Average per vectex UV coords
-	for vertUvData in vertUvAverage:
-		uvList = vertUvData[0]
-		if uvList:
-			# Convert from a list of vectors into 1 vector.
-			vertUvData[0] = reduce(lambda a,b: a+b, uvList, Mathutils.Vector(0,0)) * (1.0/len(uvList))
-		else:
-			vertUvData[0] = None
-	
-	# Assign to selected faces
-	TEX_FLAG = Mesh.FaceModes['TEX']
-	for f in selfaces:
-		uvlist = []
-		imageList = []
-		for i,v in enumerate(f):
-			uv, vImages = vertUvAverage[v.index]
-			uvlist.append( uv )
-			imageList.extend(vImages)
-		
-		if None not in uvlist:			
-			# all the faces images used by this faces vert. some faces will be added twice but thats ok.
-			# Get the most used image and assign to the face.
-			image = mostUsedImage(imageList) 
-			f.uv = uvlist
-			
-			if image:
-				f.image = image
-				f.mode |= TEX_FLAG
-	Window.RedrawAll()
-	
-if __name__ == '__main__':
-	main()
\ No newline at end of file

Modified: branches/soc-2008-unclezeiv/release/scripts/uv_seams_from_islands.py
===================================================================
--- branches/soc-2008-unclezeiv/release/scripts/uv_seams_from_islands.py	2008-05-29 01:04:12 UTC (rev 15039)
+++ branches/soc-2008-unclezeiv/release/scripts/uv_seams_from_islands.py	2008-05-29 01:08:10 UTC (rev 15040)
@@ -1,12 +1,31 @@
 #!BPY
 """
 Name: 'Seams from Islands'
-Blender: 243
+Blender: 246
 Group: 'UV'
 Tooltip: 'Add seams onto the mesh at the bounds of UV islands'
 """
 
-# Add a licence here if you wish to re-distribute, we recommend the GPL
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# Script copyright (C) Campbell Barton
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# ***** END GPL LICENCE BLOCK *****
+# --------------------------------------------------------------------------
 
 from Blender import Scene, Mesh, Window, sys
 import BPyMessages
@@ -37,8 +56,11 @@
 	# add seams
 	SEAM = Mesh.EdgeFlags.SEAM
 	for ed in me.edges:
-		if len(set(edge_uvs[ed.key])) > 1:
-			ed.flag |= SEAM
+		try: # the edge might not be in a face
+			if len(set(edge_uvs[ed.key])) > 1:
+				ed.flag |= SEAM
+		except:
+			pass
 
 def main():
 	

Modified: branches/soc-2008-unclezeiv/release/scripts/uvcalc_lightmap.py
===================================================================
--- branches/soc-2008-unclezeiv/release/scripts/uvcalc_lightmap.py	2008-05-29 01:04:12 UTC (rev 15039)
+++ branches/soc-2008-unclezeiv/release/scripts/uvcalc_lightmap.py	2008-05-29 01:08:10 UTC (rev 15040)
@@ -41,6 +41,12 @@
 
 from math import sqrt
 
+def AngleBetweenVecs(a1,a2):
+	try:
+		return Mathutils.AngleBetweenVecs(a1,a2)
+	except:
+		return 180.0
+
 class prettyface(object):
 	__slots__ = 'uv', 'width', 'height', 'children', 'xoff', 'yoff', 'has_parent', 'rot'
 	def __init__(self, data):
@@ -148,9 +154,9 @@
 		if len(uv) == 2:
 			# match the order of angle sizes of the 3d verts with the UV angles and rotate.
 			def get_tri_angles(v1,v2,v3):
-				a1= Mathutils.AngleBetweenVecs(v2-v1,v3-v1)
-				a2= Mathutils.AngleBetweenVecs(v1-v2,v3-v2)
-				a3 = 180 - (a1+a2) #a3= Mathutils.AngleBetweenVecs(v2-v3,v1-v3)
+				a1= AngleBetweenVecs(v2-v1,v3-v1)
+				a2= AngleBetweenVecs(v1-v2,v3-v2)
+				a3 = 180 - (a1+a2) #a3= AngleBetweenVecs(v2-v3,v1-v3)
 				
 				
 				return [(a1,0),(a2,1),(a3,2)]
@@ -237,8 +243,17 @@
 			face_groups.append(faces)
 		
 		if PREF_NEW_UVLAYER:
-			me.addUVLayer('lightmap')
-			me.activeUVLayer = 'lightmap'
+			uvname_org = uvname = 'lightmap'
+			uvnames = me.getUVLayerNames()
+			i = 1
+			while uvname in uvnames:
+				uvname = '%s.%03d' % (uvname_org, i)
+				i+=1
+			
+			me.addUVLayer(uvname)
+			me.activeUVLayer = uvname
+			
+			del uvnames, uvname_org, uvname
 	
 	for face_sel in face_groups:
 		print "\nStarting unwrap"
@@ -402,11 +417,14 @@
 		# ...limiting this is needed or you end up with bug unused texture spaces
 		# ...however if its too high, boxpacking is way too slow for high poly meshes.
 		float_to_int_factor = lengths_to_ints[0][0]
-		max_int_dimension = int(((side_len / float_to_int_factor)) / PREF_BOX_DIV)
+		if float_to_int_factor > 0:
+			max_int_dimension = int(((side_len / float_to_int_factor)) / PREF_BOX_DIV)
+			ok = True
+		else:
+			max_int_dimension = 0.0 # wont be used
+			ok = False
 		
-		
 		# RECURSIVE prettyface grouping
-		ok = True
 		while ok:
 			ok = False
 			

Modified: branches/soc-2008-unclezeiv/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/blenkernel/intern/modifier.c	2008-05-29 01:04:12 UTC (rev 15039)
+++ branches/soc-2008-unclezeiv/source/blender/blenkernel/intern/modifier.c	2008-05-29 01:08:10 UTC (rev 15040)
@@ -6485,12 +6485,14 @@
 	MFace *mf=0;
 	MVert *dupvert=0;
 	ParticleSettings *part=psmd->psys->part;
-	ParticleData *pa, *pars=psmd->psys->particles;
+	ParticleData *pa=NULL, *pars=psmd->psys->particles;
 	ParticleKey state;
+	EdgeHash *vertpahash;
+	EdgeHashIterator *ehi;
 	float *vertco=0, imat[4][4];
 	float loc0[3], nor[3];
 	float timestep, cfra;
-	int *facepa=emd->facepa, *vertpa=0;
+	int *facepa=emd->facepa;
 	int totdup=0,totvert=0,totface=0,totpart=0;
 	int i, j, v, mindex=0;
 
@@ -6505,34 +6507,36 @@
 	else
 		cfra=bsystem_time(ob,(float)G.scene->r.cfra,0.0);
 
-	/* table for vertice <-> particle relations (row totpart+1 is for yet unexploded verts) */
-	vertpa = MEM_callocN(sizeof(int)*(totpart+1)*totvert, "explode_vertpatab");
-	for(i=0; i<(totpart+1)*totvert; i++)
-		vertpa[i] = -1;
+	/* hash table for vertice <-> particle relations */
+	vertpahash= BLI_edgehash_new();
 
 	for (i=0; i<totface; i++) {
+		/* 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)
-			mindex = totpart*totvert;
+			mindex = totvert+totpart;
 		else 
-			mindex = facepa[i]*totvert;
+			mindex = totvert+facepa[i];
 
 		mf=CDDM_get_face(dm,i);
 
-		/*set face vertices to exist in particle group*/
-		vertpa[mindex+mf->v1] = 1;
-		vertpa[mindex+mf->v2] = 1;
-		vertpa[mindex+mf->v3] = 1;
+		/* set face vertices to exist in particle group */
+		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)
-			vertpa[mindex+mf->v4] = 1;
+			BLI_edgehash_insert(vertpahash, mf->v4, mindex, NULL);
 	}
 
-	/*make new vertice indexes & count total vertices after duplication*/
-	for(i=0; i<(totpart+1)*totvert; i++){
-		if(vertpa[i] != -1)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list