本文整理汇总了C++中CTX_wm_region_view3d函数的典型用法代码示例。如果您正苦于以下问题:C++ CTX_wm_region_view3d函数的具体用法?C++ CTX_wm_region_view3d怎么用?C++ CTX_wm_region_view3d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CTX_wm_region_view3d函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:bitfusionio,项目名称:blender,代码行数:31,代码来源:editmesh_inset.c
示例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);
}
开发者ID:jinjoh,项目名称:NOOR,代码行数:34,代码来源:object_add.c
示例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;
}
开发者ID:dfelinto,项目名称:blender,代码行数:25,代码来源:paint_curve.c
示例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;
}
开发者ID:wisaac407,项目名称:blender,代码行数:35,代码来源:editmesh_bevel.c
示例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;
}
开发者ID:dfelinto,项目名称:blender,代码行数:29,代码来源:interface_eyedropper_depth.c
示例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();
}
}
开发者ID:dfelinto,项目名称:blender,代码行数:59,代码来源:transform_constraints.c
示例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;
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:54,代码来源:render_internal.c
示例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();
}
}
开发者ID:YasirArafath,项目名称:blender-git,代码行数:54,代码来源:transform_constraints.c
示例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;
}
开发者ID:GeniaPenksik,项目名称:blender,代码行数:52,代码来源:render_internal.c
示例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();
}
}
开发者ID:GeniaPenksik,项目名称:blender,代码行数:52,代码来源:transform_constraints.c
示例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;
}
开发者ID:dfelinto,项目名称:blender,代码行数:45,代码来源:interface_eyedropper_depth.c
示例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;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:44,代码来源:editmesh_bisect.c
示例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();
}
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:44,代码来源:transform_constraints.c
示例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;
}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:41,代码来源:armature_add.c
示例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;
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:40,代码来源:render_internal.c
示例16: depthdropper_init
static int depthdropper_init(bContext *C, wmOperator *op)
{
DepthDropper *ddr;
int index_dummy;
SpaceType *st;
ARegionType *art;
st = BKE_spacetype_from_id(SPACE_VIEW3D);
art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW);
op->customdata = ddr = MEM_callocN(sizeof(DepthDropper), "DepthDropper");
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 *)v3d->camera->data)->lib == NULL)) {
RNA_id_pointer_create(v3d->camera->data, &ddr->ptr);
ddr->prop = RNA_struct_find_property(&ddr->ptr, "dof_distance");
}
}
}
if ((ddr->ptr.data == NULL) ||
(ddr->prop == NULL) ||
(RNA_property_editable(&ddr->ptr, ddr->prop) == false) ||
(RNA_property_type(ddr->prop) != PROP_FLOAT))
{
return false;
}
ddr->art = art;
ddr->draw_handle_pixel = ED_region_draw_cb_activate(art, depthdropper_draw_cb, ddr, REGION_DRAW_POST_PIXEL);
return true;
}
开发者ID:DrangPo,项目名称:blender,代码行数:40,代码来源:interface_eyedropper.c
示例17: render_view3d_do
static void render_view3d_do(RenderEngine *engine, const bContext *C)
{
wmJob *wm_job;
RenderPreview *rp;
Scene *scene = CTX_data_scene(C);
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;
/* 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 = START_RESOLUTION_DIVIDER;
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;
}
开发者ID:sonyomega,项目名称:blender-git,代码行数:39,代码来源:render_internal.c
示例18: edbm_bevel_invoke
static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
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_MEDIAN, 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;
}
/* 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;
/* since we are affecting untransformed object but seeing in transformed space,
* compensate for that */
opdata->scale[OFFSET_VALUE] /= opdata->max_obj_scale;
edbm_bevel_calc_initial_length(op, event, false);
edbm_bevel_update_header(C, op);
if (!edbm_bevel_calc(op)) {
edbm_bevel_cancel(C, op);
ED_workspace_status_text(C, NULL);
return OPERATOR_CANCELLED;
}
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
开发者ID:dfelinto,项目名称:blender,代码行数:39,代码来源:editmesh_bevel.c
示例19: walk_invoke
/****** walk operator ******/
static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
WalkInfo *walk;
if (rv3d->viewlock & RV3D_LOCKED)
return OPERATOR_CANCELLED;
walk = MEM_callocN(sizeof(WalkInfo), "NavigationWalkOperation");
op->customdata = walk;
if (initWalkInfo(C, walk, op) == false) {
MEM_freeN(op->customdata);
return OPERATOR_CANCELLED;
}
walkEvent(C, op, walk, event);
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
开发者ID:Bforartists,项目名称:Bforartists,代码行数:24,代码来源:view3d_walk.c
示例20: StartKetsjiShell
extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *cam_frame, int always_use_expand_framing)
{
/* context values */
struct wmWindowManager *wm= CTX_wm_manager(C);
struct wmWindow *win= CTX_wm_window(C);
struct Scene *startscene= CTX_data_scene(C);
struct Main* maggie1= CTX_data_main(C);
RAS_Rect area_rect;
area_rect.SetLeft(cam_frame->xmin);
area_rect.SetBottom(cam_frame->ymin);
area_rect.SetRight(cam_frame->xmax);
area_rect.SetTop(cam_frame->ymax);
int exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
Main* blenderdata = maggie1;
char* startscenename = startscene->id.name+2;
char pathname[FILE_MAXDIR+FILE_MAXFILE], oldsce[FILE_MAXDIR+FILE_MAXFILE];
STR_String exitstring = "";
BlendFileData *bfd= NULL;
BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
BLI_strncpy(oldsce, G.main->name, sizeof(oldsce));
#ifdef WITH_PYTHON
resetGamePythonPath(); // need this so running a second time wont use an old blendfiles path
setGamePythonPath(G.main->name);
// Acquire Python's GIL (global interpreter lock)
// so we can safely run Python code and API calls
PyGILState_STATE gilstate = PyGILState_Ensure();
PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */
#endif
bgl::InitExtensions(true);
// VBO code for derived mesh is not compatible with BGE (couldn't find why), so disable
int disableVBO = (U.gameflags & USER_DISABLE_VBO);
U.gameflags |= USER_DISABLE_VBO;
// Globals to be carried on over blender files
GlobalSettings gs;
gs.matmode= startscene->gm.matmode;
gs.glslflag= startscene->gm.flag;
do
{
View3D *v3d= CTX_wm_view3d(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
// get some preferences
SYS_SystemHandle syshandle = SYS_GetSystem();
bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0);
bool usefixed = (SYS_GetCommandLineInt(syshandle, "fixedtime", 0) != 0);
bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
bool animation_record = (SYS_GetCommandLineInt(syshandle, "animation_record", 0) != 0);
bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0) && GPU_display_list_support();
#ifdef WITH_PYTHON
bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);
#endif
// bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0);
bool mouse_state = (startscene->gm.flag & GAME_SHOW_MOUSE) != 0;
bool restrictAnimFPS = (startscene->gm.flag & GAME_RESTRICT_ANIM_UPDATES) != 0;
short drawtype = v3d->drawtype;
/* we do not support material mode in game engine, force change to texture mode */
if (drawtype == OB_MATERIAL) drawtype = OB_TEXTURE;
if (animation_record) usefixed= false; /* override since you don't want to run full-speed for sim recording */
// create the canvas and rasterizer
RAS_ICanvas* canvas = new KX_BlenderCanvas(wm, win, area_rect, ar);
// default mouse state set on render panel
if (mouse_state)
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
else
canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
// Setup vsync
int previous_vsync = 0;
canvas->GetSwapInterval(previous_vsync);
if (startscene->gm.vsync == VSYNC_ADAPTIVE)
canvas->SetSwapInterval(-1);
else
canvas->SetSwapInterval((startscene->gm.vsync == VSYNC_ON) ? 1 : 0);
RAS_IRasterizer* rasterizer = NULL;
//Don't use displaylists with VBOs
//If auto starts using VBOs, make sure to check for that here
if (displaylists && startscene->gm.raster_storage != RAS_STORE_VBO)
rasterizer = new RAS_ListRasterizer(canvas, true, startscene->gm.raster_storage);
else
rasterizer = new RAS_OpenGLRasterizer(canvas, startscene->gm.raster_storage);
RAS_IRasterizer::MipmapOption mipmapval = rasterizer->GetMipmapping();
//.........这里部分代码省略.........
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:101,代码来源:BL_KetsjiEmbedStart.cpp
注:本文中的CTX_wm_region_view3d函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论