[Bf-extensions-cvs] [95fae4c] master: Fix for vertex weighting of samples: the coordinate spaces of sample location and vertex locations have to be consistent.

Lukas Tönne noreply at git.blender.org
Tue Dec 16 11:52:04 CET 2014


Commit: 95fae4c30c9bab12eb4d14c71ee01a090419cc2b
Author: Lukas Tönne
Date:   Tue Dec 16 11:50:24 2014 +0100
Branches: master
https://developer.blender.org/rBAC95fae4c30c9bab12eb4d14c71ee01a090419cc2b

Fix for vertex weighting of samples: the coordinate spaces of sample
location and vertex locations have to be consistent.

When these vectors are in different spaces there is usually a large
offset between them, leading to very uniform weights and interpolation
always in the center of a face.

===================================================================

M	object_physics_meadow/blob.py

===================================================================

diff --git a/object_physics_meadow/blob.py b/object_physics_meadow/blob.py
index 0a918d8..6b23115 100644
--- a/object_physics_meadow/blob.py
+++ b/object_physics_meadow/blob.py
@@ -239,6 +239,8 @@ def make_blobs(context, gridob, groundob, samples2D, display_radius):
     blob_group_clear(context)
     blobs = []
     
+    imat = groundob.matrix_world.inverted()
+
     blobtree = KDTree(len(gridob.data.vertices))
     for i, v in enumerate(gridob.data.vertices):
         co = gridob.matrix_world * v.co
@@ -256,7 +258,7 @@ def make_blobs(context, gridob, groundob, samples2D, display_radius):
         mverts = groundob.data.vertices
         for xy in samples2D:
             progress.progress_add(1)
-            
+
             # note: use only 2D coordinates for weighting, z component should be 0
             index = assign_blob(blobtree, (xy[0], xy[1], 0.0), nor)
             if index < 0:
@@ -273,7 +275,8 @@ def make_blobs(context, gridob, groundob, samples2D, display_radius):
             # calculate barycentric vertex weights on the poly
             poly = mpolys[spoly]
             sverts = list(poly.vertices)
-            sweights = poly_3d_calc(tuple(mverts[i].co for i in sverts), sloc)
+            # note: coordinate space has to be consistent, use sloc in object space
+            sweights = poly_3d_calc(tuple(mverts[i].co for i in sverts), imat * sloc)
 
             blob.add_sample(sloc, snor, spoly, sverts, sweights)



More information about the Bf-extensions-cvs mailing list