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:
authorCampbell Barton <ideasman42@gmail.com>2011-04-25 07:02:26 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-25 07:02:26 +0400
commitbdbf0abe600b6e2608d93b6c27ec7ff9d474b743 (patch)
treed95d8accd8e252dc964a2937203b43ffd55343d0
parent262eec84cd8911dcdae2fe9415a94f68a039282b (diff)
rna api
- allow RegionView3D.view_matrix to be set. - RegionView3D.view_rotation was inverted. - add C function view3d_settings_from_mat() note, intentionally removed NULL checks, double checked this is ok with callers.
-rw-r--r--source/blender/editors/include/ED_view3d.h6
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c29
-rw-r--r--source/blender/makesrna/intern/rna_space.c29
4 files changed, 48 insertions, 20 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index a3e99e6358e..6729295e07d 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -183,5 +183,11 @@ int ED_view3d_lock(struct RegionView3D *rv3d);
unsigned int ED_view3d_datamask(struct Scene *scene, struct View3D *v3d);
unsigned int ED_viewedit_datamask(struct bScreen *screen);
+
+/* assigning view matrix */
+void view3d_settings_from_mat(float mat[][4], float *ofs, float *quat, float *dist);
+void view3d_settings_from_ob(struct Object *ob, float *ofs, float *quat, float *dist, float *lens);
+int view3d_is_ortho(struct View3D *v3d, struct RegionView3D *rv3d);
+
#endif /* ED_VIEW3D_H */
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 12ad01e3977..a3b9188ab81 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -147,10 +147,6 @@ void VIEW3D_OT_select_circle(struct wmOperatorType *ot);
void VIEW3D_OT_select_border(struct wmOperatorType *ot);
void VIEW3D_OT_select_lasso(struct wmOperatorType *ot);
-/* view3d_view.c */
-void view3d_settings_from_ob(struct Object *ob, float *ofs, float *quat, float *dist, float *lens);
-int view3d_is_ortho(View3D *v3d, RegionView3D *rv3d);
-
void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
void VIEW3D_OT_setcameratoview(struct wmOperatorType *ot);
void VIEW3D_OT_object_as_camera(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 6dae0938f54..46e1dd2d7cc 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -106,9 +106,7 @@ float *give_cursor(Scene *scene, View3D *v3d)
/* Gets the lens and clipping values from a camera of lamp type object */
static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, float *clipend)
-{
- if (!ob) return;
-
+{
if(ob->type==OB_LAMP ) {
Lamp *la = ob->data;
if (lens) {
@@ -137,39 +135,42 @@ static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, f
*
* The dist is not modified for this function, if NULL its assimed zero
* */
-void view3d_settings_from_ob(Object *ob, float *ofs, float *quat, float *dist, float *lens)
+void view3d_settings_from_mat(float mat[][4], float *ofs, float *quat, float *dist)
{
- if (!ob) return;
-
/* Offset */
if (ofs)
- negate_v3_v3(ofs, ob->obmat[3]);
+ negate_v3_v3(ofs, mat[3]);
/* Quat */
if (quat) {
float imat[4][4];
- invert_m4_m4(imat, ob->obmat);
+ invert_m4_m4(imat, mat);
mat4_to_quat(quat, imat);
}
if (dist) {
- float tquat[4];
+ float nmat[3][3];
float vec[3];
vec[0]= 0.0f;
vec[1]= 0.0f;
vec[2]= -(*dist);
- mat4_to_quat(tquat, ob->obmat);
-
- mul_qt_v3(tquat, vec);
+ copy_m3_m4(nmat, mat);
+ normalize_m3(nmat);
+ mul_m3_v3(nmat, vec);;
sub_v3_v3(ofs, vec);
}
+}
- /* Lens */
- if (lens)
+void view3d_settings_from_ob(Object *ob, float *ofs, float *quat, float *dist, float *lens)
+{
+ view3d_settings_from_mat(ob->obmat, ofs, quat, dist);
+
+ if (lens) {
object_lens_clip_settings(ob, lens, NULL, NULL);
+ }
}
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index b5b980aca5b..6fad664943d 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -384,6 +384,25 @@ static void rna_RegionView3D_view_location_set(PointerRNA *ptr, const float *val
negate_v3_v3(rv3d->ofs, values);
}
+static void rna_RegionView3D_view_rotation_get(PointerRNA *ptr, float *values)
+{
+ RegionView3D *rv3d= (RegionView3D *)(ptr->data);
+ invert_qt_qt(values, rv3d->viewquat);
+}
+
+static void rna_RegionView3D_view_rotation_set(PointerRNA *ptr, const float *values)
+{
+ RegionView3D *rv3d= (RegionView3D *)(ptr->data);
+ invert_qt_qt(rv3d->viewquat, values);
+}
+
+static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *values)
+{
+ RegionView3D *rv3d= (RegionView3D *)(ptr->data);
+ negate_v3_v3(rv3d->ofs, values);
+ view3d_settings_from_mat((float (*)[4])values, rv3d->ofs, rv3d->viewquat, &rv3d->dist);
+}
+
/* Space Image Editor */
static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr)
@@ -1361,9 +1380,10 @@ static void rna_def_space_view3d(BlenderRNA *brna)
prop= RNA_def_property(srna, "view_matrix", PROP_FLOAT, PROP_MATRIX);
RNA_def_property_float_sdna(prop, NULL, "viewmat");
- RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX: for now, it's too risky for users to do this
RNA_def_property_multi_array(prop, 2, matrix_dimsize);
+ RNA_def_property_float_funcs(prop, NULL, "rna_RegionView3D_view_matrix_set", NULL);
RNA_def_property_ui_text(prop, "View Matrix", "Current view matrix of the 3D region");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
prop= RNA_def_property(srna, "view_perspective", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "persp");
@@ -1382,8 +1402,13 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
RNA_def_property_update(prop, NC_WINDOW, NULL);
- prop= RNA_def_property(srna, "view_rotation", PROP_FLOAT, PROP_QUATERNION);
+ prop= RNA_def_property(srna, "view_rotation", PROP_FLOAT, PROP_QUATERNION); // cant use because its inverted
+#if 0
RNA_def_property_float_sdna(prop, NULL, "viewquat");
+#else
+ RNA_def_property_array(prop, 4);
+ RNA_def_property_float_funcs(prop, "rna_RegionView3D_view_rotation_get", "rna_RegionView3D_view_rotation_set", NULL);
+#endif
RNA_def_property_ui_text(prop, "View Rotation", "Rotation in quaternions (keep normalized)");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);