[Bf-extensions-cvs] [339f934] master: Fix for failing ray cast projection onto flat ground surfaces.

Lukas Tönne noreply at git.blender.org
Tue Dec 9 10:56:08 CET 2014


Commit: 339f934e9d623dbc50a21477917f301840f03565
Author: Lukas Tönne
Date:   Tue Dec 9 10:53:44 2014 +0100
Branches: master
https://developer.blender.org/rBAC339f934e9d623dbc50a21477917f301840f03565

Fix for failing ray cast projection onto flat ground surfaces.

This was failing because the ray_cast object method assumes that the
ray is limited by its end point. For a flat mesh this end point
coincides exactly with the mesh faces (using the bounding box limit),
so all the rays are rejected. Adding an offset to the ray length solves
this issue (although it should possibly be fixed in the API with an
optional parameter).

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

M	object_physics_meadow/duplimesh.py

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

diff --git a/object_physics_meadow/duplimesh.py b/object_physics_meadow/duplimesh.py
index f7694ec..2bf9fed 100644
--- a/object_physics_meadow/duplimesh.py
+++ b/object_physics_meadow/duplimesh.py
@@ -25,8 +25,8 @@ def project_on_ground(groundob, co):
     groundmat4 = groundob.matrix_world
     groundmat3 = groundmat4.to_3x3()
     
-    zmin = min(p[2] for p in groundob.bound_box)
-    zmax = max(p[2] for p in groundob.bound_box)
+    zmin = min(p[2] for p in groundob.bound_box) - 1.0
+    zmax = max(p[2] for p in groundob.bound_box) + 1.0
     
     ray_start = (co[0], co[1], zmax)
     ray_end = (co[0], co[1], zmin)



More information about the Bf-extensions-cvs mailing list