void curvemapping_set_defaults(CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy) { int a; float clipminx, clipminy, clipmaxx, clipmaxy; cumap->flag = CUMA_DO_CLIP; if (tot == 4) cumap->cur = 3; /* rhms, hack for 'col' curve? */ clipminx = min_ff(minx, maxx); clipminy = min_ff(miny, maxy); clipmaxx = max_ff(minx, maxx); clipmaxy = max_ff(miny, maxy); BLI_rctf_init(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); cumap->clipr = cumap->curr; cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; cumap->bwmul[0] = cumap->bwmul[1] = cumap->bwmul[2] = 1.0f; for (a = 0; a < tot; a++) { cumap->cm[a].flag = CUMA_EXTEND_EXTRAPOLATE; cumap->cm[a].totpoint = 2; cumap->cm[a].curve = MEM_callocN(2 * sizeof(CurveMapPoint), "curve points"); cumap->cm[a].curve[0].x = minx; cumap->cm[a].curve[0].y = miny; cumap->cm[a].curve[1].x = maxx; cumap->cm[a].curve[1].y = maxy; } cumap->changed_timestamp = 0; }
void *KeyingScreenOperation::initializeTileData(rcti *rect) { TileData *tile_data; TriangulationData *triangulation; int triangles_allocated = 0; int chunk_size = 20; int i; rctf rect_float; if (this->m_movieClip == NULL) return NULL; if (!this->m_cachedTriangulation) { lockMutex(); if (this->m_cachedTriangulation == NULL) { this->m_cachedTriangulation = buildVoronoiTriangulation(); } unlockMutex(); } triangulation = this->m_cachedTriangulation; if (!triangulation) return NULL; BLI_rctf_init(&rect_float, rect->xmin, rect->xmax, rect->ymin, rect->ymax); tile_data = (TileData *) MEM_callocN(sizeof(TileData), "keying screen tile data"); for (i = 0; i < triangulation->triangles_total; i++) { bool ok = BLI_rctf_isect(&rect_float, &triangulation->triangles_AABB[i], NULL); if (ok) { tile_data->triangles_total++; if (tile_data->triangles_total > triangles_allocated) { if (!tile_data->triangles) { tile_data->triangles = (int *) MEM_mallocN(sizeof(int) * chunk_size, "keying screen tile triangles chunk"); } else { tile_data->triangles = (int *) MEM_reallocN(tile_data->triangles, sizeof(int) * (triangles_allocated + chunk_size)); } triangles_allocated += chunk_size; } tile_data->triangles[tile_data->triangles_total - 1] = i; } } return tile_data; }
static void layer_bucket_init_dummy(MaskRasterLayer *layer) { layer->face_tot = 0; layer->face_coords = NULL; layer->face_array = NULL; layer->buckets_x = 0; layer->buckets_y = 0; layer->buckets_xy_scalar[0] = 0.0f; layer->buckets_xy_scalar[1] = 0.0f; layer->buckets_face = NULL; BLI_rctf_init(&layer->bounds, -1.0f, -1.0f, -1.0f, -1.0f); }
/* nothing drawn here, we use it to store values */ static void preview_cb(ScrArea *sa, struct uiBlock *block) { SpaceImage *sima = sa->spacedata.first; rctf dispf; rcti *disprect = &G.scene->r.disprect; int winx = (G.scene->r.size * G.scene->r.xsch) / 100; int winy = (G.scene->r.size * G.scene->r.ysch) / 100; int mval[2]; if (G.scene->r.mode & R_BORDER) { winx *= BLI_rcti_size_x(&G.scene->r.border); winy *= BLI_rctf_size_y(&G.scene->r.border); } /* while dragging we need to update the rects, otherwise it doesn't end with correct one */ BLI_rctf_init(&dispf, 15.0f, BLI_rcti_size_x(&block->rect) - 15.0f, 15.0f, (BLI_rctf_size_y(&block->rect)) - 15.0f); ui_graphics_to_window_rct(sa->win, &dispf, disprect); /* correction for gla draw */ BLI_rcti_translate(disprect, -curarea->winrct.xmin, -curarea->winrct.ymin); calc_image_view(sima, 'p'); // printf("winrct %d %d %d %d\n", disprect->xmin, disprect->ymin, disprect->xmax, disprect->ymax); /* map to image space coordinates */ mval[0] = disprect->xmin; mval[1] = disprect->ymin; areamouseco_to_ipoco(v2d, mval, &dispf.xmin, &dispf.ymin); mval[0] = disprect->xmax; mval[1] = disprect->ymax; areamouseco_to_ipoco(v2d, mval, &dispf.xmax, &dispf.ymax); /* map to render coordinates */ disprect->xmin = dispf.xmin; disprect->xmax = dispf.xmax; disprect->ymin = dispf.ymin; disprect->ymax = dispf.ymax; CLAMP(disprect->xmin, 0, winx); CLAMP(disprect->xmax, 0, winx); CLAMP(disprect->ymin, 0, winy); CLAMP(disprect->ymax, 0, winy); // printf("drawrct %d %d %d %d\n", disprect->xmin, disprect->ymin, disprect->xmax, disprect->ymax); }
static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, ImBuf *ibuf, int width, int height, float zoomx, float zoomy) { MovieClip *clip = ED_space_clip_get_clip(sc); int filter = GL_LINEAR; int x, y; /* find window pixel coordinates of origin */ UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); /* checkerboard for case alpha */ if (ibuf->planes == 32) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); fdrawcheckerboard(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y); } /* non-scaled proxy shouldn't use filtering */ if ((clip->flag & MCLIP_USE_PROXY) == 0 || ELEM(sc->user.render_size, MCLIP_PROXY_RENDER_SIZE_FULL, MCLIP_PROXY_RENDER_SIZE_100)) { filter = GL_NEAREST; } /* set zoom */ glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); glaDrawImBuf_glsl_ctx(C, ibuf, x, y, filter); /* reset zoom */ glPixelZoom(1.0f, 1.0f); if (sc->flag & SC_SHOW_METADATA) { rctf frame; BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y); ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx * width / ibuf->x, zoomy * height / ibuf->y); } if (ibuf->planes == 32) glDisable(GL_BLEND); }
/** * Translate any popup regions (so we can drag them). */ void ui_popup_translate(ARegion *ar, const int mdiff[2]) { uiBlock *block; BLI_rcti_translate(&ar->winrct, UNPACK2(mdiff)); ED_region_update_rect(ar); ED_region_tag_redraw(ar); /* update blocks */ for (block = ar->uiblocks.first; block; block = block->next) { uiPopupBlockHandle *handle = block->handle; /* Make empty, will be initialized on next use, see T60608. */ BLI_rctf_init(&handle->prev_block_rect, 0, 0, 0, 0); uiSafetyRct *saferct; for (saferct = block->saferct.first; saferct; saferct = saferct->next) { BLI_rctf_translate(&saferct->parent, UNPACK2(mdiff)); BLI_rctf_translate(&saferct->safety, UNPACK2(mdiff)); } } }
/* reads full rect, converts indices */ uint *ED_view3d_select_id_read(int xmin, int ymin, int xmax, int ymax, uint *r_buf_len) { if (UNLIKELY((xmin > xmax) || (ymin > ymax))) { return NULL; } const rcti rect = { .xmin = xmin, .xmax = xmax + 1, .ymin = ymin, .ymax = ymax + 1, }; uint buf_len; uint *buf = ED_view3d_select_id_read_rect(&rect, &buf_len); if (r_buf_len) { *r_buf_len = buf_len; } return buf; } /* ************************************************************* */ static void view3d_stereo_bgpic_setup(Scene *scene, View3D *v3d, Image *ima, ImageUser *iuser) { if (BKE_image_is_stereo(ima)) { iuser->flag |= IMA_SHOW_STEREO; if ((scene->r.scemode & R_MULTIVIEW) == 0) { iuser->multiview_eye = STEREO_LEFT_ID; } else if (v3d->stereo3d_camera != STEREO_3D_ID) { /* show only left or right camera */ iuser->multiview_eye = v3d->stereo3d_camera; } BKE_image_multiview_index(ima, iuser); } else { iuser->flag &= ~IMA_SHOW_STEREO; } } static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View3D *v3d, const bool do_foreground, const bool do_camera_frame) { RegionView3D *rv3d = ar->regiondata; int fg_flag = do_foreground ? CAM_BGIMG_FLAG_FOREGROUND : 0; if (v3d->camera == NULL || v3d->camera->type != OB_CAMERA) { return; } Camera *cam = v3d->camera->data; for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) { if ((bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != fg_flag) { continue; } { float image_aspect[2]; float x1, y1, x2, y2, centx, centy; void *lock; Image *ima = NULL; /* disable individual images */ if ((bgpic->flag & CAM_BGIMG_FLAG_DISABLED)) { continue; } ImBuf *ibuf = NULL; ImBuf *freeibuf = NULL; ImBuf *releaseibuf = NULL; if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) { ima = bgpic->ima; if (ima == NULL) { continue; } ImageUser iuser = bgpic->iuser; iuser.scene = scene; /* Needed for render results. */ BKE_image_user_frame_calc(&iuser, (int)DEG_get_ctime(depsgraph)); if (ima->source == IMA_SRC_SEQUENCE && !(iuser.flag & IMA_USER_FRAME_IN_RANGE)) { ibuf = NULL; /* frame is out of range, dont show */ } else { view3d_stereo_bgpic_setup(scene, v3d, ima, &iuser); ibuf = BKE_image_acquire_ibuf(ima, &iuser, &lock); releaseibuf = ibuf; } image_aspect[0] = ima->aspx; image_aspect[1] = ima->aspy; } else if (bgpic->source == CAM_BGIMG_SOURCE_MOVIE) { /* TODO: skip drawing when out of frame range (as image sequences do above) */ MovieClip *clip = NULL; if (bgpic->flag & CAM_BGIMG_FLAG_CAMERACLIP) { if (scene->camera) { clip = BKE_object_movieclip_get(scene, scene->camera, true); } } else { clip = bgpic->clip; } if (clip == NULL) { continue; } BKE_movieclip_user_set_frame(&bgpic->cuser, (int)DEG_get_ctime(depsgraph)); ibuf = BKE_movieclip_get_ibuf(clip, &bgpic->cuser); image_aspect[0] = clip->aspx; image_aspect[1] = clip->aspy; /* working with ibuf from image and clip has got different workflow now. * ibuf acquired from clip is referenced by cache system and should * be dereferenced after usage. */ freeibuf = ibuf; } else { /* perhaps when loading future files... */ BLI_assert(0); copy_v2_fl(image_aspect, 1.0f); } if (ibuf == NULL) { continue; } if ((ibuf->rect == NULL && ibuf->rect_float == NULL) || ibuf->channels != 4) { /* invalid image format */ if (freeibuf) { IMB_freeImBuf(freeibuf); } if (releaseibuf) { BKE_image_release_ibuf(ima, releaseibuf, lock); } continue; } if (ibuf->rect == NULL) { IMB_rect_from_float(ibuf); } BLI_assert(rv3d->persp == RV3D_CAMOB); { if (do_camera_frame) { rctf vb; ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false); x1 = vb.xmin; y1 = vb.ymin; x2 = vb.xmax; y2 = vb.ymax; } else { x1 = ar->winrct.xmin; y1 = ar->winrct.ymin; x2 = ar->winrct.xmax; y2 = ar->winrct.ymax; } /* apply offset last - camera offset is different to offset in blender units */ /* so this has some sane way of working - this matches camera's shift _exactly_ */ { const float max_dim = max_ff(x2 - x1, y2 - y1); const float xof_scale = bgpic->offset[0] * max_dim; const float yof_scale = bgpic->offset[1] * max_dim; x1 += xof_scale; y1 += yof_scale; x2 += xof_scale; y2 += yof_scale; } centx = (x1 + x2) * 0.5f; centy = (y1 + y2) * 0.5f; /* aspect correction */ if (bgpic->flag & CAM_BGIMG_FLAG_CAMERA_ASPECT) { /* apply aspect from clip */ const float w_src = ibuf->x * image_aspect[0]; const float h_src = ibuf->y * image_aspect[1]; /* destination aspect is already applied from the camera frame */ const float w_dst = x1 - x2; const float h_dst = y1 - y2; const float asp_src = w_src / h_src; const float asp_dst = w_dst / h_dst; if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) { if ((asp_src > asp_dst) == ((bgpic->flag & CAM_BGIMG_FLAG_CAMERA_CROP) != 0)) { /* fit X */ const float div = asp_src / asp_dst; x1 = ((x1 - centx) * div) + centx; x2 = ((x2 - centx) * div) + centx; } else { /* fit Y */ const float div = asp_dst / asp_src; y1 = ((y1 - centy) * div) + centy; y2 = ((y2 - centy) * div) + centy; } } } } /* complete clip? */ rctf clip_rect; BLI_rctf_init(&clip_rect, x1, x2, y1, y2); if (bgpic->rotation) { BLI_rctf_rotate_expand(&clip_rect, &clip_rect, bgpic->rotation); } if (clip_rect.xmax < 0 || clip_rect.ymax < 0 || clip_rect.xmin > ar->winx || clip_rect.ymin > ar->winy) { if (freeibuf) { IMB_freeImBuf(freeibuf); } if (releaseibuf) { BKE_image_release_ibuf(ima, releaseibuf, lock); } continue; } float zoomx = (x2 - x1) / ibuf->x; float zoomy = (y2 - y1) / ibuf->y; /* For some reason; zoom-levels down refuses to use GL_ALPHA_SCALE. */ if (zoomx < 1.0f || zoomy < 1.0f) { float tzoom = min_ff(zoomx, zoomy); int mip = 0; if ((ibuf->userflags & IB_MIPMAP_INVALID) != 0) { IMB_remakemipmap(ibuf, 0); ibuf->userflags &= ~IB_MIPMAP_INVALID; } else if (ibuf->mipmap[0] == NULL) { IMB_makemipmap(ibuf, 0); } while (tzoom < 1.0f && mip < 8 && ibuf->mipmap[mip]) { tzoom *= 2.0f; zoomx *= 2.0f; zoomy *= 2.0f; mip++; } if (mip > 0) { ibuf = ibuf->mipmap[mip - 1]; } } GPU_depth_test(!do_foreground); glDepthMask(GL_FALSE); GPU_blend(true); GPU_blend_set_func_separate( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_matrix_push_projection(); GPU_matrix_push(); ED_region_pixelspace(ar); GPU_matrix_translate_2f(centx, centy); GPU_matrix_scale_1f(bgpic->scale); GPU_matrix_rotate_2d(RAD2DEGF(-bgpic->rotation)); if (bgpic->flag & CAM_BGIMG_FLAG_FLIP_X) { zoomx *= -1.0f; x1 = x2; } if (bgpic->flag & CAM_BGIMG_FLAG_FLIP_Y) { zoomy *= -1.0f; y1 = y2; } float col[4] = {1.0f, 1.0f, 1.0f, bgpic->alpha}; IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); immDrawPixelsTex(&state, x1 - centx, y1 - centy, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect, zoomx, zoomy, col); GPU_matrix_pop_projection(); GPU_matrix_pop(); GPU_blend(false); glDepthMask(GL_TRUE); GPU_depth_test(true); if (freeibuf) { IMB_freeImBuf(freeibuf); } if (releaseibuf) { BKE_image_release_ibuf(ima, releaseibuf, lock); } } } }
static Scene *scene_add(Main *bmain, const char *name) { Scene *sce; ParticleEditSettings *pset; int a; const char *colorspace_name; sce = BKE_libblock_alloc(&bmain->scene, ID_SCE, name); sce->lay = sce->layact = 1; sce->r.mode = R_GAMMA | R_OSA | R_SHADOW | R_SSS | R_ENVMAP | R_RAYTRACE; sce->r.cfra = 1; sce->r.sfra = 1; sce->r.efra = 250; sce->r.frame_step = 1; sce->r.xsch = 1920; sce->r.ysch = 1080; sce->r.xasp = 1; sce->r.yasp = 1; sce->r.tilex = 256; sce->r.tiley = 256; sce->r.mblur_samples = 1; sce->r.filtertype = R_FILTER_MITCH; sce->r.size = 50; sce->r.im_format.planes = R_IMF_PLANES_RGB; sce->r.im_format.imtype = R_IMF_IMTYPE_PNG; sce->r.im_format.depth = R_IMF_CHAN_DEPTH_8; sce->r.im_format.quality = 90; sce->r.im_format.compress = 90; sce->r.displaymode = R_OUTPUT_AREA; sce->r.framapto = 100; sce->r.images = 100; sce->r.framelen = 1.0; sce->r.blurfac = 0.5; sce->r.frs_sec = 24; sce->r.frs_sec_base = 1; sce->r.edgeint = 10; sce->r.ocres = 128; /* OCIO_TODO: for forwards compatibility only, so if no tonecurve are used, * images would look in the same way as in current blender * * perhaps at some point should be completely deprecated? */ sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT; sce->r.gauss = 1.0; /* deprecated but keep for upwards compat */ sce->r.postgamma = 1.0; sce->r.posthue = 0.0; sce->r.postsat = 1.0; sce->r.bake_mode = 1; /* prevent to include render stuff here */ sce->r.bake_filter = 2; sce->r.bake_osa = 5; sce->r.bake_flag = R_BAKE_CLEAR; sce->r.bake_normal_space = R_BAKE_SPACE_TANGENT; sce->r.bake_samples = 256; sce->r.bake_biasdist = 0.001; sce->r.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION; sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME; sce->r.stamp_font_id = 12; sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f; sce->r.fg_stamp[3] = 1.0f; sce->r.bg_stamp[0] = sce->r.bg_stamp[1] = sce->r.bg_stamp[2] = 0.0f; sce->r.bg_stamp[3] = 0.25f; sce->r.raytrace_options = R_RAYTRACE_USE_INSTANCES; sce->r.seq_prev_type = OB_SOLID; sce->r.seq_rend_type = OB_SOLID; sce->r.seq_flag = R_SEQ_GL_PREV; sce->r.threads = 1; sce->r.simplify_subsurf = 6; sce->r.simplify_particles = 1.0f; sce->r.simplify_shadowsamples = 16; sce->r.simplify_aosss = 1.0f; sce->r.border.xmin = 0.0f; sce->r.border.ymin = 0.0f; sce->r.border.xmax = 1.0f; sce->r.border.ymax = 1.0f; sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); sce->toolsettings->cornertype = 1; sce->toolsettings->degr = 90; sce->toolsettings->step = 9; sce->toolsettings->turn = 1; sce->toolsettings->extr_offs = 1; sce->toolsettings->doublimit = 0.001; sce->toolsettings->segments = 32; sce->toolsettings->rings = 32; sce->toolsettings->vertices = 32; sce->toolsettings->uvcalc_radius = 1.0f; sce->toolsettings->uvcalc_cubesize = 1.0f; sce->toolsettings->uvcalc_mapdir = 1; sce->toolsettings->uvcalc_mapalign = 1; sce->toolsettings->uvcalc_margin = 0.001f; sce->toolsettings->unwrapper = 1; sce->toolsettings->select_thresh = 0.01f; sce->toolsettings->jointrilimit = 0.8f; sce->toolsettings->selectmode = SCE_SELECT_VERTEX; sce->toolsettings->uv_selectmode = UV_SELECT_VERTEX; sce->toolsettings->normalsize = 0.1; sce->toolsettings->autokey_mode = U.autokey_mode; sce->toolsettings->skgen_resolution = 100; sce->toolsettings->skgen_threshold_internal = 0.01f; sce->toolsettings->skgen_threshold_external = 0.01f; sce->toolsettings->skgen_angle_limit = 45.0f; sce->toolsettings->skgen_length_ratio = 1.3f; sce->toolsettings->skgen_length_limit = 1.5f; sce->toolsettings->skgen_correlation_limit = 0.98f; sce->toolsettings->skgen_symmetry_limit = 0.1f; sce->toolsettings->skgen_postpro = SKGEN_SMOOTH; sce->toolsettings->skgen_postpro_passes = 1; sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL | SKGEN_FILTER_EXTERNAL | SKGEN_FILTER_SMART | SKGEN_HARMONIC | SKGEN_SUB_CORRELATION | SKGEN_STICK_TO_EMBEDDING; sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION; sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; sce->toolsettings->proportional_size = 1.0f; sce->physics_settings.gravity[0] = 0.0f; sce->physics_settings.gravity[1] = 0.0f; sce->physics_settings.gravity[2] = -9.81f; sce->physics_settings.flag = PHYS_GLOBAL_GRAVITY; sce->unit.scale_length = 1.0f; pset = &sce->toolsettings->particle; pset->flag = PE_KEEP_LENGTHS | PE_LOCK_FIRST | PE_DEFLECT_EMITTER | PE_AUTO_VELOCITY; pset->emitterdist = 0.25f; pset->totrekey = 5; pset->totaddkey = 5; pset->brushtype = PE_BRUSH_NONE; pset->draw_step = 2; pset->fade_frames = 2; pset->selectmode = SCE_SELECT_PATH; for (a = 0; a < PE_TOT_BRUSH; a++) { pset->brush[a].strength = 0.5; pset->brush[a].size = 50; pset->brush[a].step = 10; pset->brush[a].count = 10; } pset->brush[PE_BRUSH_CUT].strength = 100; sce->r.ffcodecdata.audio_mixrate = 44100; sce->r.ffcodecdata.audio_volume = 1.0f; sce->r.ffcodecdata.audio_bitrate = 192; sce->r.ffcodecdata.audio_channels = 2; BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine)); sce->audio.distance_model = 2.0f; sce->audio.doppler_factor = 1.0f; sce->audio.speed_of_sound = 343.3f; sce->audio.volume = 1.0f; BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic)); BLI_rctf_init(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); sce->r.osa = 8; /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ BKE_scene_add_render_layer(sce, NULL); /* game data */ sce->gm.stereoflag = STEREO_NOSTEREO; sce->gm.stereomode = STEREO_ANAGLYPH; sce->gm.eyeseparation = 0.10; sce->gm.dome.angle = 180; sce->gm.dome.mode = DOME_FISHEYE; sce->gm.dome.res = 4; sce->gm.dome.resbuf = 1.0f; sce->gm.dome.tilt = 0; sce->gm.xplay = 640; sce->gm.yplay = 480; sce->gm.freqplay = 60; sce->gm.depth = 32; sce->gm.gravity = 9.8f; sce->gm.physicsEngine = WOPHY_BULLET; sce->gm.mode = 32; //XXX ugly harcoding, still not sure we should drop mode. 32 == 1 << 5 == use_occlusion_culling sce->gm.occlusionRes = 128; sce->gm.ticrate = 60; sce->gm.maxlogicstep = 5; sce->gm.physubstep = 1; sce->gm.maxphystep = 5; sce->gm.lineardeactthreshold = 0.8f; sce->gm.angulardeactthreshold = 1.0f; sce->gm.deactivationtime = 0.0f; sce->gm.flag = GAME_DISPLAY_LISTS; sce->gm.matmode = GAME_MAT_MULTITEX; sce->gm.obstacleSimulation = OBSTSIMULATION_NONE; sce->gm.levelHeight = 2.f; sce->gm.recastData.cellsize = 0.3f; sce->gm.recastData.cellheight = 0.2f; sce->gm.recastData.agentmaxslope = M_PI / 2; sce->gm.recastData.agentmaxclimb = 0.9f; sce->gm.recastData.agentheight = 2.0f; sce->gm.recastData.agentradius = 0.6f; sce->gm.recastData.edgemaxlen = 12.0f; sce->gm.recastData.edgemaxerror = 1.3f; sce->gm.recastData.regionminsize = 8.f; sce->gm.recastData.regionmergesize = 20.f; sce->gm.recastData.vertsperpoly = 6; sce->gm.recastData.detailsampledist = 6.0f; sce->gm.recastData.detailsamplemaxerror = 1.0f; sce->gm.exitkey = 218; // Blender key code for ESC sound_create_scene(sce); /* color management */ colorspace_name = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_SEQUENCER); BKE_color_managed_display_settings_init(&sce->display_settings); BKE_color_managed_view_settings_init(&sce->view_settings); BLI_strncpy(sce->sequencer_colorspace_settings.name, colorspace_name, sizeof(sce->sequencer_colorspace_settings.name)); return sce; }
void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d = &ar->v2d; size_t items; /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): * - this is done to allow the channel list to be scrollable, but must be done here * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ int height = NLACHANNEL_TOT_HEIGHT(ac, items); v2d->tot.ymin = -height; /* need to do a view-sync here, so that the keys area doesn't jump around * (it must copy this) */ UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); /* draw channels */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; float ymax = NLACHANNEL_FIRST_TOP(ac); for (ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++) { float ymin = ymax - NLACHANNEL_HEIGHT(snla); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, ymin, ymax, channel_index); } } } { /* second pass: UI widgets */ uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; float ymax = NLACHANNEL_FIRST_TOP(ac); /* set blending again, as may not be set in previous step */ GPU_blend_set_func_separate( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); /* loop through channels, and set up drawing depending on their type */ for (ale = anim_data.first; ale; ale = ale->next, ymax -= NLACHANNEL_STEP(snla), channel_index++) { float ymin = ymax - NLACHANNEL_HEIGHT(snla); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymax, v2d->cur.ymin, v2d->cur.ymax)) { /* draw all channels using standard channel-drawing API */ rctf channel_rect; BLI_rctf_init(&channel_rect, 0, v2d->cur.xmax, ymin, ymax); ANIM_channel_draw_widgets(C, ac, ale, block, &channel_rect, channel_index); } } UI_block_end(C, block); UI_block_draw(C, block); GPU_blend(false); } /* free temporary channels */ ANIM_animdata_freelist(&anim_data); }