Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_view.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c64
1 files changed, 56 insertions, 8 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index f57d8a5ec1b..1a2e8932411 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -68,6 +68,9 @@
#include "BL_System.h"
#endif
+#include "RNA_access.h"
+#include "RNA_define.h"
+
#include "view3d_intern.h" // own include
/* use this call when executing an operator,
@@ -947,23 +950,29 @@ void project_short_noclip(ARegion *ar, const float vec[3], short adr[2])
}
}
-void project_float(ARegion *ar, const float vec[3], float adr[2])
+void apply_project_float(float persmat[4][4], int winx, int winy, const float vec[3], float adr[2])
{
- RegionView3D *rv3d= ar->regiondata;
float vec4[4];
-
+
copy_v3_v3(vec4, vec);
vec4[3]= 1.0;
adr[0]= IS_CLIPPED;
-
- mul_m4_v4(rv3d->persmat, vec4);
-
+
+ mul_m4_v4(persmat, vec4);
+
if(vec4[3] > (float)BL_NEAR_CLIP) {
- adr[0] = (float)(ar->winx/2.0f)+(ar->winx/2.0f)*vec4[0]/vec4[3];
- adr[1] = (float)(ar->winy/2.0f)+(ar->winy/2.0f)*vec4[1]/vec4[3];
+ adr[0] = (float)(winx/2.0f)+(winx/2.0f)*vec4[0]/vec4[3];
+ adr[1] = (float)(winy/2.0f)+(winy/2.0f)*vec4[1]/vec4[3];
}
}
+void project_float(ARegion *ar, const float vec[3], float adr[2])
+{
+ RegionView3D *rv3d= ar->regiondata;
+
+ apply_project_float(rv3d->persmat, ar->winx, ar->winy, vec, adr);
+}
+
void project_float_noclip(ARegion *ar, const float vec[3], float adr[2])
{
RegionView3D *rv3d= ar->regiondata;
@@ -1854,3 +1863,42 @@ float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3])
rv3d->persmat[2][3]*co[2])
) * rv3d->pixsize;
}
+
+/* view matrix properties utilities */
+
+void ED_view3d_operator_properties_viewmat(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_int(ot->srna, "region_width", 0, 0, INT_MAX, "Region Width", "", 0, INT_MAX);
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+
+ prop = RNA_def_int(ot->srna, "region_height", 0, 0, INT_MAX, "Region height", "", 0, INT_MAX);
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+
+ prop = RNA_def_float_matrix(ot->srna, "perspective_matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Perspective Matrix", 0.0f, 0.0f);
+ RNA_def_property_flag(prop, PROP_HIDDEN);
+}
+
+void ED_view3d_operator_properties_viewmat_set(bContext *C, wmOperator *op)
+{
+ ARegion *ar= CTX_wm_region(C);
+ RegionView3D *rv3d= ED_view3d_context_rv3d(C);
+
+ if(!RNA_struct_property_is_set(op->ptr, "region_width"))
+ RNA_int_set(op->ptr, "region_width", ar->winx);
+
+ if(!RNA_struct_property_is_set(op->ptr, "region_height"))
+ RNA_int_set(op->ptr, "region_height", ar->winy);
+
+ if(!RNA_struct_property_is_set(op->ptr, "perspective_matrix"))
+ RNA_float_set_array(op->ptr, "perspective_matrix", (float *)rv3d->persmat);
+}
+
+void ED_view3d_operator_properties_viewmat_get(wmOperator *op, int *winx, int *winy, float persmat[4][4])
+{
+ *winx = RNA_int_get(op->ptr, "region_width");
+ *winy = RNA_int_get(op->ptr, "region_height");
+
+ RNA_float_get_array(op->ptr, "perspective_matrix", (float *)persmat);
+}