From 00d04e1924e0247d79b1ef1913e8ae384583b515 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Apr 2013 17:49:13 +0000 Subject: rna api function scene.ray_cast now returns the object and its matrix (incase its a dupli). --- source/blender/makesrna/intern/rna_scene_api.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source/blender/makesrna/intern/rna_scene_api.c') diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 9d920ff2519..1f4622ff7f4 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -91,8 +91,9 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name rd->scemode & R_EXTENSION, TRUE); } -static void rna_Scene_ray_cast(Scene *scene, ReportList *reports, float ray_start[3], float ray_end[3], - float r_location[3], float r_normal[3], int *r_success) +static void rna_Scene_ray_cast(Scene *scene, float ray_start[3], float ray_end[3], + int *r_success, Object **r_ob, float r_obmat[16], + float r_location[3], float r_normal[3]) { float dummy_dist_px = 0; float ray_nor[3]; @@ -102,12 +103,14 @@ static void rna_Scene_ray_cast(Scene *scene, ReportList *reports, float ray_star ray_dist = normalize_v3(ray_nor); if (snapObjectsRayEx(scene, NULL, NULL, NULL, NULL, SCE_SNAP_MODE_FACE, + r_ob, (float(*)[4])r_obmat, ray_start, ray_nor, &ray_dist, NULL, &dummy_dist_px, r_location, r_normal, SNAP_ALL)) { *r_success = true; } else { + unit_m4((float(*)[4])r_obmat); zero_v3(r_location); zero_v3(r_normal); @@ -170,7 +173,6 @@ void RNA_api_scene(StructRNA *srna) /* Ray Cast */ func = RNA_def_function(srna, "ray_cast", "rna_Scene_ray_cast"); RNA_def_function_ui_description(func, "Cast a ray onto in object space"); - RNA_def_function_flag(func, FUNC_USE_REPORTS); /* ray start and end */ parm = RNA_def_float_vector(func, "start", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); @@ -179,6 +181,12 @@ void RNA_api_scene(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED); /* return location and normal */ + parm = RNA_def_boolean(func, "result", 0, "", ""); + RNA_def_function_output(func, parm); + parm = RNA_def_pointer(func, "object", "Object", "", "Ray cast object"); + RNA_def_function_output(func, parm); + parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f); + RNA_def_function_output(func, parm); parm = RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The hit location of this ray cast", -1e4, 1e4); RNA_def_property_flag(parm, PROP_THICK_WRAP); @@ -188,9 +196,6 @@ void RNA_api_scene(StructRNA *srna) RNA_def_property_flag(parm, PROP_THICK_WRAP); RNA_def_function_output(func, parm); - parm = RNA_def_boolean(func, "result", 0, "", ""); - RNA_def_function_output(func, parm); - #ifdef WITH_COLLADA /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ func = RNA_def_function(srna, "collada_export", "rna_Scene_collada_export"); -- cgit v1.2.3