本文整理汇总了C++中CTX_wm_region_view3d函数的典型用法代码示例。如果您正苦于以下问题:C++ CTX_wm_region_view3d函数的具体用法?C++ CTX_wm_region_view3d怎么用?C++ CTX_wm_region_view3d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CTX_wm_region_view3d函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: edbm_inset_invoke
static int edbm_inset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
InsetData *opdata;
float mlen[2];
float center_3d[3];
if (!edbm_inset_init(C, op, true)) {
return OPERATOR_CANCELLED;
}
opdata = op->customdata;
/* initialize mouse values */
if (!calculateTransformCenter(C, V3D_CENTROID, center_3d, opdata->mcenter)) {
/* in this case the tool will likely do nothing,
* ideally this will never happen and should be checked for above */
opdata->mcenter[0] = opdata->mcenter[1] = 0;
}
mlen[0] = opdata->mcenter[0] - event->mval[0];
mlen[1] = opdata->mcenter[1] - event->mval[1];
opdata->initial_length = len_v2(mlen);
opdata->pixel_size = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
edbm_inset_calc(op);
edbm_inset_update_header(op, C);
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
示例2: ED_object_base_init_from_view
void ED_object_base_init_from_view(bContext *C, Base *base)
{
View3D *v3d= CTX_wm_view3d(C);
Scene *scene= CTX_data_scene(C);
Object *ob= base->object;
if (scene==NULL)
return;
if (v3d==NULL) {
base->lay = scene->lay;
VECCOPY(ob->loc, scene->cursor);
}
else {
if (v3d->localvd) {
base->lay= ob->lay= v3d->layact | v3d->lay;
VECCOPY(ob->loc, v3d->cursor);
}
else {
base->lay= ob->lay= v3d->layact;
VECCOPY(ob->loc, scene->cursor);
}
if (U.flag & USER_ADD_VIEWALIGNED) {
RegionView3D *rv3d = CTX_wm_region_view3d(C);
if(rv3d) {
rv3d->viewquat[0]= -rv3d->viewquat[0];
QuatToEul(rv3d->viewquat, ob->rot);
rv3d->viewquat[0]= -rv3d->viewquat[0];
}
}
}
where_is_object(scene, ob);
}
示例3: paint_curve_poll
bool paint_curve_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
Paint *p;
RegionView3D *rv3d = CTX_wm_region_view3d(C);
SpaceImage *sima;
if (rv3d && !(ob && ((ob->mode & OB_MODE_ALL_PAINT) != 0))) {
return false;
}
sima = CTX_wm_space_image(C);
if (sima && sima->mode != SI_MODE_PAINT) {
return false;
}
p = BKE_paint_get_active_from_context(C);
if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) {
return true;
}
return false;
}
示例4: edbm_bevel_invoke
static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
/* TODO make modal keymap (see fly mode) */
RegionView3D *rv3d = CTX_wm_region_view3d(C);
BevelData *opdata;
float center_3d[3];
if (!edbm_bevel_init(C, op, true)) {
return OPERATOR_CANCELLED;
}
opdata = op->customdata;
/* initialize mouse values */
if (!calculateTransformCenter(C, V3D_AROUND_CENTER_MEAN, center_3d, opdata->mcenter)) {
/* in this case the tool will likely do nothing,
* ideally this will never happen and should be checked for above */
opdata->mcenter[0] = opdata->mcenter[1] = 0;
}
edbm_bevel_calc_initial_length(op, event, false);
/* for OFFSET_VALUE only, the scale is the size of a pixel under the mouse in 3d space */
opdata->scale[OFFSET_VALUE] = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
edbm_bevel_update_header(C, op);
if (!edbm_bevel_calc(op)) {
edbm_bevel_cancel(C, op);
return OPERATOR_CANCELLED;
}
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
示例5: depthdropper_poll
static bool depthdropper_poll(bContext *C)
{
PointerRNA ptr;
PropertyRNA *prop;
int index_dummy;
uiBut *but;
/* check if there's an active button taking depth value */
if ((CTX_wm_window(C) != NULL) &&
(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) &&
(but->type == UI_BTYPE_NUM) && (prop != NULL)) {
if ((RNA_property_type(prop) == PROP_FLOAT) &&
(RNA_property_subtype(prop) & PROP_UNIT_LENGTH) &&
(RNA_property_array_check(prop) == false)) {
return 1;
}
}
else {
RegionView3D *rv3d = CTX_wm_region_view3d(C);
if (rv3d && rv3d->persp == RV3D_CAMOB) {
View3D *v3d = CTX_wm_view3d(C);
if (v3d->camera && v3d->camera->data && !ID_IS_LINKED(v3d->camera->data)) {
return 1;
}
}
}
return 0;
}
示例6: drawPropCircle
/* called from drawview.c, as an extra per-window draw option */
void drawPropCircle(const struct bContext *C, TransInfo *t)
{
if (t->flag & T_PROP_EDIT) {
RegionView3D *rv3d = CTX_wm_region_view3d(C);
float tmat[4][4], imat[4][4];
int depth_test_enabled;
if (t->spacetype == SPACE_VIEW3D && rv3d != NULL) {
copy_m4_m4(tmat, rv3d->viewmat);
invert_m4_m4(imat, tmat);
}
else {
unit_m4(tmat);
unit_m4(imat);
}
GPU_matrix_push();
if (t->spacetype == SPACE_VIEW3D) {
/* pass */
}
else if (t->spacetype == SPACE_IMAGE) {
GPU_matrix_scale_2f(1.0f / t->aspect[0], 1.0f / t->aspect[1]);
}
else if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_ACTION)) {
/* only scale y */
rcti *mask = &t->ar->v2d.mask;
rctf *datamask = &t->ar->v2d.cur;
float xsize = BLI_rctf_size_x(datamask);
float ysize = BLI_rctf_size_y(datamask);
float xmask = BLI_rcti_size_x(mask);
float ymask = BLI_rcti_size_y(mask);
GPU_matrix_scale_2f(1.0f, (ysize / xsize) * (xmask / ymask));
}
depth_test_enabled = GPU_depth_test_enabled();
if (depth_test_enabled) {
GPU_depth_test(false);
}
uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
immUniformThemeColor(TH_GRID);
set_inverted_drawing(1);
imm_drawcircball(t->center_global, t->prop_size, imat, pos);
set_inverted_drawing(0);
immUnbindProgram();
if (depth_test_enabled) {
GPU_depth_test(true);
}
GPU_matrix_pop();
}
}
示例7: render_view3d_changed
static int render_view3d_changed(RenderEngine *engine, const bContext *C)
{
ARegion *ar = CTX_wm_region(C);
Render *re;
int update = 0;
char name[32];
sprintf(name, "View3dPreview %p", (void *)ar);
re = RE_GetRender(name);
if (re) {
RegionView3D *rv3d = CTX_wm_region_view3d(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
rctf viewplane, viewplane1;
rcti disprect, disprect1;
float mat[4][4];
float clipsta, clipend;
bool orth;
if (engine->update_flag & RE_ENGINE_UPDATE_MA)
update |= PR_UPDATE_MATERIAL;
if (engine->update_flag & RE_ENGINE_UPDATE_OTHER)
update |= PR_UPDATE_MATERIAL;
engine->update_flag = 0;
if (engine->resolution_x != ar->winx || engine->resolution_y != ar->winy)
update |= PR_UPDATE_RENDERSIZE;
RE_GetView(re, mat);
if (compare_m4m4(mat, rv3d->viewmat, 0.00001f) == 0) {
update |= PR_UPDATE_VIEW;
}
render_view3d_get_rects(ar, v3d, rv3d, &viewplane, engine, &clipsta, &clipend, NULL, &orth);
RE_GetViewPlane(re, &viewplane1, &disprect1);
if (BLI_rctf_compare(&viewplane, &viewplane1, 0.00001f) == 0)
update |= PR_UPDATE_VIEW;
render_view3d_disprect(scene, ar, v3d, rv3d, &disprect);
if (BLI_rcti_compare(&disprect, &disprect1) == 0)
update |= PR_UPDATE_RENDERSIZE;
if (update)
engine->flag |= RE_ENGINE_DO_UPDATE;
//if (update)
// printf("changed ma %d res %d view %d\n", update & PR_UPDATE_MATERIAL, update & PR_UPDATE_RENDERSIZE, update & PR_UPDATE_VIEW);
}
return update;
}
示例8: drawPropCircle
/* called from drawview.c, as an extra per-window draw option */
void drawPropCircle(const struct bContext *C, TransInfo *t)
{
if (t->flag & T_PROP_EDIT) {
RegionView3D *rv3d = CTX_wm_region_view3d(C);
float tmat[4][4], imat[4][4];
float center[3];
int depth_test_enabled;
UI_ThemeColor(TH_GRID);
if (t->spacetype == SPACE_VIEW3D && rv3d != NULL) {
copy_m4_m4(tmat, rv3d->viewmat);
invert_m4_m4(imat, tmat);
}
else {
unit_m4(tmat);
unit_m4(imat);
}
glPushMatrix();
copy_v3_v3(center, t->center);
if ((t->spacetype == SPACE_VIEW3D) && t->obedit) {
mul_m4_v3(t->obedit->obmat, center); /* because t->center is in local space */
}
else if (t->spacetype == SPACE_IMAGE) {
float aspx, aspy;
if (t->options & CTX_MASK) {
/* untested - mask aspect is TODO */
ED_space_image_get_aspect(t->sa->spacedata.first, &aspx, &aspy);
}
else {
ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
}
glScalef(1.0f / aspx, 1.0f / aspy, 1.0);
}
depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
if (depth_test_enabled)
glDisable(GL_DEPTH_TEST);
set_inverted_drawing(1);
drawcircball(GL_LINE_LOOP, center, t->prop_size, imat);
set_inverted_drawing(0);
if (depth_test_enabled)
glEnable(GL_DEPTH_TEST);
glPopMatrix();
}
}
示例9: render_view3d_do
static void render_view3d_do(RenderEngine *engine, const bContext *C)
{
wmJob *wm_job;
RenderPreview *rp;
Scene *scene = CTX_data_scene(C);
ARegion *ar = CTX_wm_region(C);
int width = ar->winx, height = ar->winy;
int divider = 1;
int resolution_threshold = scene->r.preview_start_resolution *
scene->r.preview_start_resolution;
if (CTX_wm_window(C) == NULL)
return;
if (!render_view3d_flag_changed(engine, C))
return;
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), CTX_wm_region(C), "Render Preview",
WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW);
rp = MEM_callocN(sizeof(RenderPreview), "render preview");
rp->job = wm_job;
while (width * height > resolution_threshold) {
width = max_ii(1, width / 2);
height = max_ii(1, height / 2);
divider *= 2;
}
/* customdata for preview thread */
rp->scene = scene;
rp->engine = engine;
rp->sa = CTX_wm_area(C);
rp->ar = CTX_wm_region(C);
rp->v3d = rp->sa->spacedata.first;
rp->rv3d = CTX_wm_region_view3d(C);
rp->bmain = CTX_data_main(C);
rp->resolution_divider = divider;
rp->start_resolution_divider = divider;
rp->has_freestyle = (scene->r.mode & R_EDGE_FRS) != 0;
copy_m4_m4(rp->viewmat, rp->rv3d->viewmat);
/* clear info text */
engine->text[0] = '\0';
/* setup job */
WM_jobs_customdata_set(wm_job, rp, render_view3d_free);
WM_jobs_timer(wm_job, 0.1, NC_SPACE | ND_SPACE_VIEW3D, NC_SPACE | ND_SPACE_VIEW3D);
WM_jobs_callbacks(wm_job, render_view3d_startjob, NULL, NULL, NULL);
WM_jobs_start(CTX_wm_manager(C), wm_job);
engine->flag &= ~RE_ENGINE_DO_UPDATE;
}
示例10: drawPropCircle
/* called from drawview.c, as an extra per-window draw option */
void drawPropCircle(const struct bContext *C, TransInfo *t)
{
if (t->flag & T_PROP_EDIT) {
RegionView3D *rv3d = CTX_wm_region_view3d(C);
float tmat[4][4], imat[4][4];
int depth_test_enabled;
UI_ThemeColor(TH_GRID);
if (t->spacetype == SPACE_VIEW3D && rv3d != NULL) {
copy_m4_m4(tmat, rv3d->viewmat);
invert_m4_m4(imat, tmat);
}
else {
unit_m4(tmat);
unit_m4(imat);
}
glPushMatrix();
if (t->spacetype == SPACE_VIEW3D) {
/* pass */
}
else if (t->spacetype == SPACE_IMAGE) {
glScalef(1.0f / t->aspect[0], 1.0f / t->aspect[1], 1.0f);
}
else if (ELEM(t->spacetype, SPACE_IPO, SPACE_ACTION)) {
/* only scale y */
rcti *mask = &t->ar->v2d.mask;
rctf *datamask = &t->ar->v2d.cur;
float xsize = BLI_rctf_size_x(datamask);
float ysize = BLI_rctf_size_y(datamask);
float xmask = BLI_rcti_size_x(mask);
float ymask = BLI_rcti_size_y(mask);
glScalef(1.0f, (ysize / xsize) * (xmask / ymask), 1.0f);
}
depth_test_enabled = glIsEnabled(GL_DEPTH_TEST);
if (depth_test_enabled)
glDisable(GL_DEPTH_TEST);
set_inverted_drawing(1);
drawcircball(GL_LINE_LOOP, t->center_global, t->prop_size, imat);
set_inverted_drawing(0);
if (depth_test_enabled)
glEnable(GL_DEPTH_TEST);
glPopMatrix();
}
}
示例11: depthdropper_init
static int depthdropper_init(bContext *C, wmOperator *op)
{
int index_dummy;
SpaceType *st;
ARegionType *art;
st = BKE_spacetype_from_id(SPACE_VIEW3D);
art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW);
DepthDropper *ddr = MEM_callocN(sizeof(DepthDropper), __func__);
uiBut *but = UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &index_dummy);
/* fallback to the active camera's dof */
if (ddr->prop == NULL) {
RegionView3D *rv3d = CTX_wm_region_view3d(C);
if (rv3d && rv3d->persp == RV3D_CAMOB) {
View3D *v3d = CTX_wm_view3d(C);
if (v3d->camera && v3d->camera->data && !ID_IS_LINKED(v3d->camera->data)) {
RNA_id_pointer_create(v3d->camera->data, &ddr->ptr);
ddr->prop = RNA_struct_find_property(&ddr->ptr, "dof_distance");
ddr->is_undo = true;
}
}
}
else {
ddr->is_undo = UI_but_flag_is_set(but, UI_BUT_UNDO);
}
if ((ddr->ptr.data == NULL) || (ddr->prop == NULL) ||
(RNA_property_editable(&ddr->ptr, ddr->prop) == false) ||
(RNA_property_type(ddr->prop) != PROP_FLOAT)) {
MEM_freeN(ddr);
return false;
}
op->customdata = ddr;
ddr->art = art;
ddr->draw_handle_pixel = ED_region_draw_cb_activate(
art, depthdropper_draw_cb, ddr, REGION_DRAW_POST_PIXEL);
ddr->init_depth = RNA_property_float_get(&ddr->ptr, ddr->prop);
return true;
}
示例12: mesh_bisect_invoke
static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BKE_editmesh_from_object(obedit);
int ret;
if (em->bm->totedgesel == 0) {
BKE_report(op->reports, RPT_ERROR, "Selected edges/faces required");
return OPERATOR_CANCELLED;
}
/* if the properties are set or there is no rv3d,
* skip model and exec immediately */
if ((CTX_wm_region_view3d(C) == NULL) ||
(RNA_struct_property_is_set(op->ptr, "plane_co") &&
RNA_struct_property_is_set(op->ptr, "plane_no")))
{
return mesh_bisect_exec(C, op);
}
ret = WM_gesture_straightline_invoke(C, op, event);
if (ret & OPERATOR_RUNNING_MODAL) {
View3D *v3d = CTX_wm_view3d(C);
wmGesture *gesture = op->customdata;
BisectData *opdata;
opdata = MEM_mallocN(sizeof(BisectData), "inset_operator_data");
opdata->mesh_backup = EDBM_redo_state_store(em);
opdata->is_first = true;
gesture->userdata = opdata;
/* misc other vars */
G.moving = G_TRANSFORM_EDIT;
opdata->twtype = v3d->twtype;
v3d->twtype = 0;
/* initialize modal callout */
ED_area_headerprint(CTX_wm_area(C), IFACE_("LMB: Click and drag to draw cut line"));
}
return ret;
}
示例13: drawPropCircle
/* called from drawview.c, as an extra per-window draw option */
void drawPropCircle(const struct bContext *C, TransInfo *t)
{
if (t->flag & T_PROP_EDIT) {
RegionView3D *rv3d = CTX_wm_region_view3d(C);
float tmat[4][4], imat[4][4];
float center[3];
UI_ThemeColor(TH_GRID);
if(t->spacetype == SPACE_VIEW3D && rv3d != NULL)
{
copy_m4_m4(tmat, rv3d->viewmat);
invert_m4_m4(imat, tmat);
}
else
{
unit_m4(tmat);
unit_m4(imat);
}
glPushMatrix();
VECCOPY(center, t->center);
if((t->spacetype == SPACE_VIEW3D) && t->obedit)
{
mul_m4_v3(t->obedit->obmat, center); /* because t->center is in local space */
}
else if(t->spacetype == SPACE_IMAGE)
{
float aspx, aspy;
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
glScalef(1.0f/aspx, 1.0f/aspy, 1.0);
}
set_inverted_drawing(1);
drawcircball(GL_LINE_LOOP, center, t->prop_size, imat);
set_inverted_drawing(0);
glPopMatrix();
}
}
示例14: armature_bone_primitive_add_exec
static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
Object *obedit = CTX_data_edit_object(C);
EditBone *bone;
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
char name[MAXBONENAME];
RNA_string_get(op->ptr, "name", name);
copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C)));
/* Get inverse point for head and orientation for tail */
invert_m4_m4(obedit->imat, obedit->obmat);
mul_m4_v3(obedit->imat, curs);
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
copy_m3_m4(obmat, rv3d->viewmat);
else unit_m3(obmat);
copy_m3_m4(viewmat, obedit->obmat);
mul_m3_m3m3(totmat, obmat, viewmat);
invert_m3_m3(imat, totmat);
ED_armature_deselect_all(obedit);
/* Create a bone */
bone = ED_armature_edit_bone_add(obedit->data, name);
copy_v3_v3(bone->head, curs);
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
else
add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
示例15: render_view3d_do
static void render_view3d_do(RenderEngine *engine, const bContext *C, int keep_data)
{
wmJob *wm_job;
RenderPreview *rp;
Scene *scene = CTX_data_scene(C);
if (CTX_wm_window(C) == NULL) {
engine->flag |= RE_ENGINE_DO_UPDATE;
return;
}
wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), CTX_wm_region(C), "Render Preview",
WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW);
rp = MEM_callocN(sizeof(RenderPreview), "render preview");
/* customdata for preview thread */
rp->scene = scene;
rp->engine = engine;
rp->sa = CTX_wm_area(C);
rp->ar = CTX_wm_region(C);
rp->v3d = rp->sa->spacedata.first;
rp->rv3d = CTX_wm_region_view3d(C);
rp->bmain = CTX_data_main(C);
rp->keep_data = keep_data;
copy_m4_m4(rp->viewmat, rp->rv3d->viewmat);
/* dont alloc in threads */
if (engine->text == NULL)
engine->text = MEM_callocN(IMA_MAX_RENDER_TEXT, "rendertext");
/* setup job */
WM_jobs_customdata_set(wm_job, rp, render_view3d_free);
WM_jobs_timer(wm_job, 0.1, NC_SPACE | ND_SPACE_VIEW3D, NC_SPACE | ND_SPACE_VIEW3D);
WM_jobs_callbacks(wm_job, render_view3d_startjob, NULL, NULL, NULL);
WM_jobs_start(CTX_wm_manager(C), wm_job);
engine->flag &= ~RE_ENGINE_DO_UPDATE;
}