rna property RegionView3d.perspective - ORTHO/PERSP/CAMERA

useful for setting the camera view from python
This commit is contained in:
Campbell Barton
2010-05-18 21:01:22 +00:00
parent 8ca3de6d63
commit ff9bd252e8

View File

@@ -338,6 +338,30 @@ static void rna_RegionView3D_quadview_update(Main *main, Scene *scene, PointerRN
ED_view3d_quadview_update(sa, ar);
}
static void rna_RegionView3D_prespective_set(PointerRNA *ptr, const int value)
{
RegionView3D *rv3d= (RegionView3D *)(ptr->data);
if(value==RV3D_CAMOB) {
bScreen *sc= (bScreen*)ptr->id.data;
Scene *scene= (Scene *)sc->scene;
ScrArea *sa;
ARegion *ar;
View3D *v3d;
rna_area_region_from_regiondata(ptr, &sa, &ar);
v3d = sa->spacedata.first; // XXX, could be not the first!
if(v3d->camera==NULL) {
if(scene->camera==NULL)
return; /* cant set camera */
v3d->camera= scene->camera;
}
}
rv3d->persp= value;
}
/* Space Image Editor */
static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr)
@@ -921,7 +945,13 @@ static void rna_def_space_view3d(BlenderRNA *brna)
{V3D_CENTROID, "MEDIAN_POINT", ICON_ROTATECENTER, "Median Point", ""},
{V3D_ACTIVE, "ACTIVE_ELEMENT", ICON_ROTACTIVE, "Active Element", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem rv3d_persp_items[] = {
{RV3D_PERSP, "PERSP", 0, "Perspective", ""},
{RV3D_ORTHO, "ORTHO", 0, "Orthographic", ""},
{RV3D_CAMOB, "CAMERA", 0, "Camera", ""},
{0, NULL, 0, NULL, NULL}};
srna= RNA_def_struct(brna, "SpaceView3D", "Space");
RNA_def_struct_sdna(srna, "View3D");
RNA_def_struct_ui_text(srna, "3D View Space", "3D View space data");
@@ -1168,6 +1198,13 @@ static void rna_def_space_view3d(BlenderRNA *brna)
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_ui_text(prop, "View Matrix", "Current view matrix of the 3D region");
prop= RNA_def_property(srna, "perspective", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "persp");
RNA_def_property_enum_items(prop, rv3d_persp_items);
RNA_def_property_enum_funcs(prop, NULL, "rna_RegionView3D_prespective_set", NULL);
RNA_def_property_ui_text(prop, "Perspective", "View Perspective");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
}
static void rna_def_space_buttons(BlenderRNA *brna)