[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50750] trunk/blender/source/blender/ blenkernel/intern/constraint.c: Small fix for Follow Track constraint
Sergey Sharybin
sergey.vfx at gmail.com
Wed Sep 19 19:19:30 CEST 2012
Revision: 50750
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50750
Author: nazgul
Date: 2012-09-19 17:19:30 +0000 (Wed, 19 Sep 2012)
Log Message:
-----------
Small fix for Follow Track constraint
Use object_get_derived_final() function instead of accessing to object's
derived final directly.
The same happens for shrinkwrap constraint and it should deal better in
cases when depth object is in edit mode. In other cases should be no
functional changes.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/constraint.c
Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c 2012-09-19 17:14:43 UTC (rev 50749)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c 2012-09-19 17:19:30 UTC (rev 50750)
@@ -4054,32 +4054,36 @@
copy_v3_v3(cob->matrix[3], disp);
}
- if (data->depth_ob && data->depth_ob->derivedFinal) {
+ if (data->depth_ob) {
Object *depth_ob = data->depth_ob;
- BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
- BVHTreeRayHit hit;
- float ray_start[3], ray_end[3], ray_nor[3], imat[4][4];
- int result;
+ DerivedMesh *target = object_get_derived_final(depth_ob);
+ if (target) {
+ BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh;
+ BVHTreeRayHit hit;
+ float ray_start[3], ray_end[3], ray_nor[3], imat[4][4];
+ int result;
- invert_m4_m4(imat, depth_ob->obmat);
+ invert_m4_m4(imat, depth_ob->obmat);
- mul_v3_m4v3(ray_start, imat, camob->obmat[3]);
- mul_v3_m4v3(ray_end, imat, cob->matrix[3]);
+ mul_v3_m4v3(ray_start, imat, camob->obmat[3]);
+ mul_v3_m4v3(ray_end, imat, cob->matrix[3]);
- sub_v3_v3v3(ray_nor, ray_end, ray_start);
+ sub_v3_v3v3(ray_nor, ray_end, ray_start);
- bvhtree_from_mesh_faces(&treeData, depth_ob->derivedFinal, 0.0f, 4, 6);
+ bvhtree_from_mesh_faces(&treeData, target, 0.0f, 4, 6);
- hit.dist = FLT_MAX;
- hit.index = -1;
+ hit.dist = FLT_MAX;
+ hit.index = -1;
- result = BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData);
+ result = BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData);
- if (result != -1) {
- mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co);
+ if (result != -1) {
+ mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co);
+ }
+
+ free_bvhtree_from_mesh(&treeData);
+ target->release(target);
}
-
- free_bvhtree_from_mesh(&treeData);
}
}
}
More information about the Bf-blender-cvs
mailing list