Fix #134366: object.closest_point_on_mesh always returns no result
Introduced in 024d7d12e2
Pull Request: https://projects.blender.org/blender/blender/pulls/134377
This commit is contained in:
@@ -699,13 +699,14 @@ static void rna_Object_closest_point_on_mesh(Object *ob,
|
||||
copy_v3_v3(r_normal, nearest.no);
|
||||
*r_index = mesh_corner_tri_to_face_index(mesh_eval, nearest.index);
|
||||
}
|
||||
else {
|
||||
*r_success = false;
|
||||
|
||||
zero_v3(r_location);
|
||||
zero_v3(r_normal);
|
||||
*r_index = -1;
|
||||
}
|
||||
}
|
||||
|
||||
*r_success = false;
|
||||
|
||||
zero_v3(r_location);
|
||||
zero_v3(r_normal);
|
||||
*r_index = -1;
|
||||
}
|
||||
|
||||
static bool rna_Object_is_modified(Object *ob, Scene *scene, int settings)
|
||||
|
||||
@@ -358,6 +358,11 @@ add_blender_test(
|
||||
--run-all-tests
|
||||
)
|
||||
|
||||
add_blender_test(
|
||||
object_api
|
||||
--python ${TEST_PYTHON_DIR}/bl_object.py
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# MODIFIERS TESTS
|
||||
add_blender_test(
|
||||
|
||||
21
tests/python/bl_object.py
Normal file
21
tests/python/bl_object.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import unittest
|
||||
|
||||
import bpy
|
||||
from mathutils import Vector
|
||||
|
||||
|
||||
class TestObjectApi(unittest.TestCase):
|
||||
def test_closest_point_on_mesh_of_default_cube(self):
|
||||
bpy.ops.object.select_all(action='SELECT')
|
||||
bpy.ops.object.delete(use_global=False)
|
||||
bpy.ops.outliner.orphans_purge()
|
||||
bpy.ops.mesh.primitive_cube_add()
|
||||
ret_val = bpy.context.scene.objects[0].closest_point_on_mesh(Vector((0.0, 0.0, 2.0)))
|
||||
self.assertTrue(ret_val[0])
|
||||
self.assertEqual(ret_val[1], Vector((0.0, 0.0, 1.0)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user