[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [843] branches/ivygen/ivy_functions.py: some cleanup
Florian Meyer
florianfelix at web.de
Thu Jul 22 17:55:34 CEST 2010
Revision: 843
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=843
Author: testscreenings
Date: 2010-07-22 17:55:34 +0200 (Thu, 22 Jul 2010)
Log Message:
-----------
some cleanup
Modified Paths:
--------------
branches/ivygen/ivy_functions.py
Modified: branches/ivygen/ivy_functions.py
===================================================================
--- branches/ivygen/ivy_functions.py 2010-07-22 12:41:23 UTC (rev 842)
+++ branches/ivygen/ivy_functions.py 2010-07-22 15:55:34 UTC (rev 843)
@@ -237,33 +237,42 @@
def adhesion2(old_pos, ob, data, props):
targetBoundingSphere = data[0]
- #print('cursor', old_pos)
minimum_dist = targetBoundingSphere[1] * props.ivyMaxAdhesionDist
- distance = None
+ distances = []
+
+ adhesionVector = mathutils.Vector((0,0,0))
+ #print('minimum_dist', minimum_dist)
for i, face in enumerate(ob.data.faces):
n = face.normal
c = face.center + ob.location
- plane_dist = (n.dot(old_pos) +
- ( -n.x*c.x -
- -n.y*c.y -
- -n.z*c.z))
- print('plane_dist', plane_dist)
+ plane_dist = (n.dot(c - old_pos))
+ #print('plane_dist', plane_dist)
# up to here this works
# plane_dist is the distance to the plane defined by the face.center and face.normal
pointOnPlane = old_pos - n * plane_dist
- print('pointOnPlane', pointOnPlane)
+ #print('pointOnPlane', pointOnPlane)
# now find the closest distance to the poly
# test if pointOnPlane is already inside the poligon
# else get closest point on the closest edge
-
- if isInside(ob, face, pointOnPlane):
- if plane_dist < minimum_dist:
- distances.append(plane_dist)
- if plane_dist y distances.sort()[0]:
- adhesionVector = mathutils.Vector((old_pos - pointOnPlane))
-
+ if plane_dist < minimum_dist:
+ if isInside(ob, face, pointOnPlane):
+ #print('isInside')
+ #print('plane_dist', plane_dist)
+ if not distances:
+ distances.append(positive(plane_dist))
+ #print('distances [0]', distances[0])
+ if plane_dist < distances[0]:
+ distances.append(positive(plane_dist))
+ distances.sort()
+ #print('shortest', distances[0])
+ adhesionVector = mathutils.Vector((old_pos - pointOnPlane)).normalize()
+
+ #else:
+ #print('is Outside')
+ #print('distance', distances[0])
+ #print('\nADHESION', adhesionVector)
return adhesionVector
'''
print('\n______________')
More information about the Bf-extensions-cvs
mailing list