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>2012-03-30 02:42:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-30 02:42:32 +0400
commit8ec4371ff1d2e36970b0823e4b6f4a7edc25d89e (patch)
treeb5dc27892836de2732a0c863443459a64e120248 /source/blender/editors/render
parent2722320ca6aaa468917f5dbcf6faf621bf28c763 (diff)
style cleanup: render
Diffstat (limited to 'source/blender/editors/render')
-rw-r--r--source/blender/editors/render/render_internal.c244
-rw-r--r--source/blender/editors/render/render_opengl.c212
-rw-r--r--source/blender/editors/render/render_preview.c420
-rw-r--r--source/blender/editors/render/render_shading.c291
-rw-r--r--source/blender/editors/render/render_update.c98
-rw-r--r--source/blender/editors/render/render_view.c110
6 files changed, 688 insertions, 687 deletions
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 465a2e37269..97fd80fc946 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -76,7 +76,7 @@
/* called inside thread! */
void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volatile rcti *renrect)
{
- float *rectf= NULL;
+ float *rectf = NULL;
int ymin, ymax, xmin, xmax;
int rymin, rxmin, predivide, profile_from;
unsigned char *rectc;
@@ -84,72 +84,72 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat
/* if renrect argument, we only refresh scanlines */
if (renrect) {
/* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */
- if (rr->renlay==NULL || renrect->ymax>=rr->recty)
+ if (rr->renlay == NULL || renrect->ymax >= rr->recty)
return;
/* xmin here is first subrect x coord, xmax defines subrect width */
xmin = renrect->xmin + rr->crop;
xmax = renrect->xmax - xmin + rr->crop;
- if (xmax<2)
+ if (xmax < 2)
return;
- ymin= renrect->ymin + rr->crop;
- ymax= renrect->ymax - ymin + rr->crop;
- if (ymax<2)
+ ymin = renrect->ymin + rr->crop;
+ ymax = renrect->ymax - ymin + rr->crop;
+ if (ymax < 2)
return;
renrect->ymin = renrect->ymax;
}
else {
xmin = ymin = rr->crop;
- xmax = rr->rectx - 2*rr->crop;
- ymax = rr->recty - 2*rr->crop;
+ xmax = rr->rectx - 2 * rr->crop;
+ ymax = rr->recty - 2 * rr->crop;
}
/* xmin ymin is in tile coords. transform to ibuf */
- rxmin= rr->tilerect.xmin + xmin;
+ rxmin = rr->tilerect.xmin + xmin;
if (rxmin >= ibuf->x) return;
- rymin= rr->tilerect.ymin + ymin;
+ rymin = rr->tilerect.ymin + ymin;
if (rymin >= ibuf->y) return;
if (rxmin + xmax > ibuf->x)
- xmax= ibuf->x - rxmin;
+ xmax = ibuf->x - rxmin;
if (rymin + ymax > ibuf->y)
- ymax= ibuf->y - rymin;
+ ymax = ibuf->y - rymin;
if (xmax < 1 || ymax < 1) return;
/* find current float rect for display, first case is after composite... still weak */
if (rr->rectf)
- rectf= rr->rectf;
+ rectf = rr->rectf;
else {
if (rr->rect32)
return;
else {
- if (rr->renlay==NULL || rr->renlay->rectf==NULL) return;
- rectf= rr->renlay->rectf;
+ if (rr->renlay == NULL || rr->renlay->rectf == NULL) return;
+ rectf = rr->renlay->rectf;
}
}
- if (rectf==NULL) return;
+ if (rectf == NULL) return;
- if (ibuf->rect==NULL)
+ if (ibuf->rect == NULL)
imb_addrectImBuf(ibuf);
- rectf+= 4*(rr->rectx*ymin + xmin);
- rectc= (unsigned char*)(ibuf->rect + ibuf->x*rymin + rxmin);
+ rectf += 4 * (rr->rectx * ymin + xmin);
+ rectc = (unsigned char *)(ibuf->rect + ibuf->x * rymin + rxmin);
if (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
- profile_from= IB_PROFILE_LINEAR_RGB;
- predivide= (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
+ profile_from = IB_PROFILE_LINEAR_RGB;
+ predivide = (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
}
else {
- profile_from= IB_PROFILE_SRGB;
- predivide= 0;
+ profile_from = IB_PROFILE_SRGB;
+ predivide = 0;
}
IMB_buffer_byte_from_float(rectc, rectf,
- 4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
- xmax, ymax, ibuf->x, rr->rectx);
+ 4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide,
+ xmax, ymax, ibuf->x, rr->rectx);
}
/* ****************************** render invoking ***************** */
@@ -162,14 +162,14 @@ static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **s
/* single layer re-render */
if (RNA_struct_property_is_set(op->ptr, "scene")) {
Scene *scn;
- char scene_name[MAX_ID_NAME-2];
+ char scene_name[MAX_ID_NAME - 2];
RNA_string_get(op->ptr, "scene", scene_name);
scn = (Scene *)BLI_findstring(&mainp->scene, scene_name, offsetof(ID, name) + 2);
if (scn) {
/* camera switch wont have updated */
- scn->r.cfra= (*scene)->r.cfra;
+ scn->r.cfra = (*scene)->r.cfra;
scene_camera_switch_update(scn);
*scene = scn;
@@ -191,16 +191,16 @@ static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **s
/* executes blocking render */
static int screen_render_exec(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
- SceneRenderLayer *srl= NULL;
+ Scene *scene = CTX_data_scene(C);
+ SceneRenderLayer *srl = NULL;
Render *re;
Image *ima;
- View3D *v3d= CTX_wm_view3d(C);
- Main *mainp= CTX_data_main(C);
+ View3D *v3d = CTX_wm_view3d(C);
+ Main *mainp = CTX_data_main(C);
unsigned int lay;
- const short is_animation= RNA_boolean_get(op->ptr, "animation");
- const short is_write_still= RNA_boolean_get(op->ptr, "write_still");
- struct Object *camera_override= v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
+ const short is_animation = RNA_boolean_get(op->ptr, "animation");
+ const short is_write_still = RNA_boolean_get(op->ptr, "write_still");
+ struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
/* custom scene and single layer re-render */
screen_render_scene_layer_set(op, mainp, &scene, &srl);
@@ -210,20 +210,20 @@ static int screen_render_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- re= RE_NewRender(scene->id.name);
- lay= (v3d)? v3d->lay: scene->lay;
+ re = RE_NewRender(scene->id.name);
+ lay = (v3d) ? v3d->lay : scene->lay;
- G.afbreek= 0;
- RE_test_break_cb(re, NULL, (int (*)(void *)) blender_test_break);
+ G.afbreek = 0;
+ RE_test_break_cb(re, NULL, (int (*)(void *))blender_test_break);
- ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+ ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
BKE_image_backup_render(scene, ima);
/* cleanup sequencer caches before starting user triggered render.
- * otherwise, invalidated cache entries can make their way into
- * the output rendering. We can't put that into RE_BlenderFrame,
- * since sequence rendering can call that recursively... (peter) */
+ * otherwise, invalidated cache entries can make their way into
+ * the output rendering. We can't put that into RE_BlenderFrame,
+ * since sequence rendering can call that recursively... (peter) */
seq_stripelem_cache_cleanup();
RE_SetReports(re, op->reports);
@@ -238,7 +238,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
// no redraw needed, we leave state as we entered it
ED_update_for_newframe(mainp, scene, CTX_wm_screen(C), 1);
- WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
return OPERATOR_FINISHED;
}
@@ -262,7 +262,7 @@ typedef struct RenderJob {
static void render_freejob(void *rjv)
{
- RenderJob *rj= rjv;
+ RenderJob *rj = rjv;
MEM_freeN(rj);
}
@@ -270,53 +270,53 @@ static void render_freejob(void *rjv)
/* str is IMA_MAX_RENDER_TEXT in size */
static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
{
- char info_time_str[32]; // used to be extern to header_info.c
+ char info_time_str[32]; // used to be extern to header_info.c
uintptr_t mem_in_use, mmap_in_use, peak_memory;
float megs_used_memory, mmap_used_memory, megs_peak_memory;
- char *spos= str;
+ char *spos = str;
- mem_in_use= MEM_get_memory_in_use();
- mmap_in_use= MEM_get_mapped_memory_in_use();
+ mem_in_use = MEM_get_memory_in_use();
+ mmap_in_use = MEM_get_mapped_memory_in_use();
peak_memory = MEM_get_peak_memory();
- megs_used_memory= (mem_in_use-mmap_in_use)/(1024.0*1024.0);
- mmap_used_memory= (mmap_in_use)/(1024.0*1024.0);
- megs_peak_memory = (peak_memory)/(1024.0*1024.0);
+ megs_used_memory = (mem_in_use - mmap_in_use) / (1024.0 * 1024.0);
+ mmap_used_memory = (mmap_in_use) / (1024.0 * 1024.0);
+ megs_peak_memory = (peak_memory) / (1024.0 * 1024.0);
if (scene->lay & 0xFF000000)
- spos+= sprintf(spos, "Localview | ");
+ spos += sprintf(spos, "Localview | ");
else if (scene->r.scemode & R_SINGLE_LAYER)
- spos+= sprintf(spos, "Single Layer | ");
+ spos += sprintf(spos, "Single Layer | ");
if (rs->statstr) {
- spos+= sprintf(spos, "%s ", rs->statstr);
+ spos += sprintf(spos, "%s ", rs->statstr);
}
else {
- spos+= sprintf(spos, "Fra:%d ", (scene->r.cfra));
- if (rs->totvert) spos+= sprintf(spos, "Ve:%d ", rs->totvert);
- if (rs->totface) spos+= sprintf(spos, "Fa:%d ", rs->totface);
- if (rs->tothalo) spos+= sprintf(spos, "Ha:%d ", rs->tothalo);
- if (rs->totstrand) spos+= sprintf(spos, "St:%d ", rs->totstrand);
- if (rs->totlamp) spos+= sprintf(spos, "La:%d ", rs->totlamp);
- spos+= sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory);
+ spos += sprintf(spos, "Fra:%d ", (scene->r.cfra));
+ if (rs->totvert) spos += sprintf(spos, "Ve:%d ", rs->totvert);
+ if (rs->totface) spos += sprintf(spos, "Fa:%d ", rs->totface);
+ if (rs->tothalo) spos += sprintf(spos, "Ha:%d ", rs->tothalo);
+ if (rs->totstrand) spos += sprintf(spos, "St:%d ", rs->totstrand);
+ if (rs->totlamp) spos += sprintf(spos, "La:%d ", rs->totlamp);
+ spos += sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory);
if (rs->curfield)
- spos+= sprintf(spos, "Field %d ", rs->curfield);
+ spos += sprintf(spos, "Field %d ", rs->curfield);
if (rs->curblur)
- spos+= sprintf(spos, "Blur %d ", rs->curblur);
+ spos += sprintf(spos, "Blur %d ", rs->curblur);
}
BLI_timestr(rs->lastframetime, info_time_str);
- spos+= sprintf(spos, "Time:%s ", info_time_str);
+ spos += sprintf(spos, "Time:%s ", info_time_str);
if (rs->curfsa)
- spos+= sprintf(spos, "| Full Sample %d ", rs->curfsa);
+ spos += sprintf(spos, "| Full Sample %d ", rs->curfsa);
if (rs->infostr && rs->infostr[0])
- spos+= sprintf(spos, "| %s ", rs->infostr);
+ spos += sprintf(spos, "| %s ", rs->infostr);
/* very weak... but 512 characters is quite safe */
- if (spos >= str+IMA_MAX_RENDER_TEXT)
+ if (spos >= str + IMA_MAX_RENDER_TEXT)
if (G.f & G_DEBUG)
printf("WARNING! renderwin text beyond limit \n");
@@ -324,15 +324,15 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str)
static void image_renderinfo_cb(void *rjv, RenderStats *rs)
{
- RenderJob *rj= rjv;
+ RenderJob *rj = rjv;
RenderResult *rr;
- rr= RE_AcquireResultRead(rj->re);
+ rr = RE_AcquireResultRead(rj->re);
if (rr) {
/* malloc OK here, stats_draw is not in tile threads */
- if (rr->text==NULL)
- rr->text= MEM_callocN(IMA_MAX_RENDER_TEXT, "rendertext");
+ if (rr->text == NULL)
+ rr->text = MEM_callocN(IMA_MAX_RENDER_TEXT, "rendertext");
make_renderinfo_string(rs, rj->scene, rr->text);
}
@@ -340,26 +340,26 @@ static void image_renderinfo_cb(void *rjv, RenderStats *rs)
RE_ReleaseResult(rj->re);
/* make jobs timer to send notifier */
- *(rj->do_update)= 1;
+ *(rj->do_update) = 1;
}
static void render_progress_update(void *rjv, float progress)
{
- RenderJob *rj= rjv;
+ RenderJob *rj = rjv;
if (rj->progress && *rj->progress != progress) {
*rj->progress = progress;
/* make jobs timer to send notifier */
- *(rj->do_update)= 1;
+ *(rj->do_update) = 1;
}
}
static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect)
{
- RenderJob *rj= rjv;
- Image *ima= rj->image;
+ RenderJob *rj = rjv;
+ Image *ima = rj->image;
ImBuf *ibuf;
void *lock;
@@ -367,23 +367,23 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
if (ima->render_slot != ima->last_render_slot)
return;
- ibuf= BKE_image_acquire_ibuf(ima, &rj->iuser, &lock);
+ ibuf = BKE_image_acquire_ibuf(ima, &rj->iuser, &lock);
if (ibuf) {
image_buffer_rect_update(rj->scene, rr, ibuf, renrect);
/* make jobs timer to send notifier */
- *(rj->do_update)= 1;
+ *(rj->do_update) = 1;
}
BKE_image_release_ibuf(ima, lock);
}
static void render_startjob(void *rjv, short *stop, short *do_update, float *progress)
{
- RenderJob *rj= rjv;
+ RenderJob *rj = rjv;
- rj->stop= stop;
- rj->do_update= do_update;
- rj->progress= progress;
+ rj->stop = stop;
+ rj->do_update = do_update;
+ rj->progress = progress;
RE_SetReports(rj->re, rj->reports);
@@ -397,7 +397,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
static void render_endjob(void *rjv)
{
- RenderJob *rj= rjv;
+ RenderJob *rj = rjv;
/* this render may be used again by the sequencer without the active 'Render' where the callbacks
* would be re-assigned. assign dummy callbacks to avoid referencing freed renderjobs bug [#24508] */
@@ -418,7 +418,7 @@ static void render_endjob(void *rjv)
if (rj->srl) {
nodeUpdateID(rj->scene->nodetree, &rj->scene->id);
- WM_main_add_notifier(NC_NODE|NA_EDITED, rj->scene);
+ WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene);
}
/* XXX render stability hack */
@@ -429,7 +429,7 @@ static void render_endjob(void *rjv)
/* called by render, check job 'stop' value or the global */
static int render_breakjob(void *rjv)
{
- RenderJob *rj= rjv;
+ RenderJob *rj = rjv;
if (G.afbreek)
return 1;
@@ -450,8 +450,8 @@ static void render_drawlock(void *UNUSED(rjv), int lock)
static int screen_render_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
/* no running blender, remove handler and pass through */
- if (0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) {
- return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
+ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) {
+ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
}
/* running render */
@@ -468,18 +468,18 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
/* new render clears all callbacks */
Main *mainp;
- Scene *scene= CTX_data_scene(C);
- SceneRenderLayer *srl=NULL;
- bScreen *screen= CTX_wm_screen(C);
- View3D *v3d= CTX_wm_view3d(C);
+ Scene *scene = CTX_data_scene(C);
+ SceneRenderLayer *srl = NULL;
+ bScreen *screen = CTX_wm_screen(C);
+ View3D *v3d = CTX_wm_view3d(C);
Render *re;
wmJob *steve;
RenderJob *rj;
Image *ima;
int jobflag;
- const short is_animation= RNA_boolean_get(op->ptr, "animation");
- const short is_write_still= RNA_boolean_get(op->ptr, "write_still");
- struct Object *camera_override= v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
+ const short is_animation = RNA_boolean_get(op->ptr, "animation");
+ const short is_write_still = RNA_boolean_get(op->ptr, "write_still");
+ struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
const char *name;
/* only one render job at a time */
@@ -501,10 +501,10 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* get main */
if (G.rt == 101) {
/* thread-safety experiment, copy main from the undo buffer */
- mainp= BKE_undo_get_main(&scene);
+ mainp = BKE_undo_get_main(&scene);
}
else
- mainp= CTX_data_main(C);
+ mainp = CTX_data_main(C);
/* cancel animation playback */
if (screen->animtimer)
@@ -517,13 +517,13 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
multires_force_render_update(CTX_data_active_object(C));
/* cleanup sequencer caches before starting user triggered render.
- * otherwise, invalidated cache entries can make their way into
- * the output rendering. We can't put that into RE_BlenderFrame,
- * since sequence rendering can call that recursively... (peter) */
+ * otherwise, invalidated cache entries can make their way into
+ * the output rendering. We can't put that into RE_BlenderFrame,
+ * since sequence rendering can call that recursively... (peter) */
seq_stripelem_cache_cleanup();
/* get editmode results */
- ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
+ ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
// store spare
// get view3d layer, local layer, make this nice api call to render
@@ -532,7 +532,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* ensure at least 1 area shows result */
render_view_open(C, event->x, event->y);
- jobflag= WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY|WM_JOB_PROGRESS;
+ jobflag = WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS;
/* custom scene and single layer re-render */
screen_render_scene_layer_set(op, mainp, &scene, &srl);
@@ -541,49 +541,49 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
jobflag |= WM_JOB_SUSPEND;
/* job custom data */
- rj= MEM_callocN(sizeof(RenderJob), "render job");
- rj->main= mainp;
- rj->scene= scene;
- rj->win= CTX_wm_window(C);
+ rj = MEM_callocN(sizeof(RenderJob), "render job");
+ rj->main = mainp;
+ rj->scene = scene;
+ rj->win = CTX_wm_window(C);
rj->srl = srl;
rj->camera_override = camera_override;
- rj->lay = (v3d)? v3d->lay: scene->lay;
- rj->anim= is_animation;
- rj->write_still= is_write_still && !is_animation;
- rj->iuser.scene= scene;
- rj->iuser.ok= 1;
- rj->reports= op->reports;
+ rj->lay = (v3d) ? v3d->lay : scene->lay;
+ rj->anim = is_animation;
+ rj->write_still = is_write_still && !is_animation;
+ rj->iuser.scene = scene;
+ rj->iuser.ok = 1;
+ rj->reports = op->reports;
/* setup job */
- if (RE_seq_render_active(scene, &scene->r)) name= "Sequence Render";
- else name= "Render";
+ if (RE_seq_render_active(scene, &scene->r)) name = "Sequence Render";
+ else name = "Render";
- steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag);
+ steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag);
WM_jobs_customdata(steve, rj, render_freejob);
- WM_jobs_timer(steve, 0.2, NC_SCENE|ND_RENDER_RESULT, 0);
+ WM_jobs_timer(steve, 0.2, NC_SCENE | ND_RENDER_RESULT, 0);
WM_jobs_callbacks(steve, render_startjob, NULL, NULL, render_endjob);
/* get a render result image, and make sure it is empty */
- ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+ ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
BKE_image_backup_render(rj->scene, ima);
- rj->image= ima;
+ rj->image = ima;
/* setup new render */
- re= RE_NewRender(scene->id.name);
+ re = RE_NewRender(scene->id.name);
RE_test_break_cb(re, rj, render_breakjob);
RE_draw_lock_cb(re, rj, render_drawlock);
RE_display_draw_cb(re, rj, image_rect_update);
RE_stats_draw_cb(re, rj, image_renderinfo_cb);
RE_progress_cb(re, rj, render_progress_update);
- rj->re= re;
- G.afbreek= 0;
+ rj->re = re;
+ G.afbreek = 0;
WM_jobs_start(CTX_wm_manager(C), steve);
WM_cursor_wait(0);
- WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
/* we set G.rendering here already instead of only in the job, this ensure
* main loop or other scene updates are disabled in time, since they may
@@ -614,6 +614,6 @@ void RENDER_OT_render(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "animation", 0, "Animation", "Render files from the animation range of this scene");
RNA_def_boolean(ot->srna, "write_still", 0, "Write Image", "Save rendered the image to the output path (used only when animation is disabled)");
RNA_def_string(ot->srna, "layer", "", RE_MAXNAME, "Render Layer", "Single render layer to re-render (used only when animation is disabled)");
- RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene", "Scene to render, current scene if not specified");
+ RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME - 2, "Scene", "Scene to render, current scene if not specified");
}
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 26996893ae5..45983347a12 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -114,28 +114,28 @@ static unsigned int screen_opengl_layers(OGLRender *oglrender)
static void screen_opengl_render_apply(OGLRender *oglrender)
{
- Scene *scene= oglrender->scene;
- ARegion *ar= oglrender->ar;
- View3D *v3d= oglrender->v3d;
- RegionView3D *rv3d= oglrender->rv3d;
+ Scene *scene = oglrender->scene;
+ ARegion *ar = oglrender->ar;
+ View3D *v3d = oglrender->v3d;
+ RegionView3D *rv3d = oglrender->rv3d;
RenderResult *rr;
- Object *camera= NULL;
+ Object *camera = NULL;
ImBuf *ibuf;
void *lock;
float winmat[4][4];
- int sizex= oglrender->sizex;
- int sizey= oglrender->sizey;
- const short view_context= (v3d != NULL);
+ int sizex = oglrender->sizex;
+ int sizey = oglrender->sizey;
+ const short view_context = (v3d != NULL);
- rr= RE_AcquireResultRead(oglrender->re);
+ rr = RE_AcquireResultRead(oglrender->re);
if (view_context) {
GPU_offscreen_bind(oglrender->ofs); /* bind */
/* render 3d view */
- if (rv3d->persp==RV3D_CAMOB && v3d->camera) {
+ if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
/*int is_ortho= scene->r.mode & R_ORTHO;*/
- camera= v3d->camera;
+ camera = v3d->camera;
RE_GetCameraWindow(oglrender->re, camera, scene->r.cfra, winmat);
}
@@ -143,9 +143,9 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
rctf viewplane;
float clipsta, clipend;
- int is_ortho= ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend);
+ int is_ortho = ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend);
if (is_ortho) orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend);
- else perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
+ else perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
}
if ((scene->r.mode & R_OSA) == 0) {
@@ -156,8 +156,8 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
/* simple accumulation, less hassle then FSAA FBO's */
static float jit_ofs[32][2];
float winmat_jitter[4][4];
- float *accum_buffer= MEM_mallocN(sizex * sizey * sizeof(float) * 4, "accum1");
- float *accum_tmp= MEM_mallocN(sizex * sizey * sizeof(float) * 4, "accum2");
+ float *accum_buffer = MEM_mallocN(sizex * sizey * sizeof(float) * 4, "accum1");
+ float *accum_tmp = MEM_mallocN(sizex * sizey * sizeof(float) * 4, "accum2");
int j;
BLI_initjit(jit_ofs[0], scene->r.osa);
@@ -167,7 +167,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_buffer);
/* skip the first sample */
- for (j=1; j < scene->r.osa; j++) {
+ for (j = 1; j < scene->r.osa; j++) {
copy_m4_m4(winmat_jitter, winmat);
window_translate_m4(winmat_jitter, rv3d->persmat,
(jit_ofs[j][0] * 2.0f) / sizex,
@@ -175,10 +175,10 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter, TRUE);
GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_tmp);
- add_vn_vn(accum_buffer, accum_tmp, sizex*sizey*sizeof(float));
+ add_vn_vn(accum_buffer, accum_tmp, sizex * sizey * sizeof(float));
}
- mul_vn_vn_fl(rr->rectf, accum_buffer, sizex*sizey*sizeof(float), 1.0f / scene->r.osa);
+ mul_vn_vn_fl(rr->rectf, accum_buffer, sizex * sizey * sizeof(float), 1.0f / scene->r.osa);
MEM_freeN(accum_buffer);
MEM_freeN(accum_tmp);
@@ -188,9 +188,9 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
}
else {
/* shouldnt suddenly give errors mid-render but possible */
- char err_out[256]= "unknown";
- ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, TRUE, err_out);
- camera= scene->camera;
+ char err_out[256] = "unknown";
+ ImBuf *ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, TRUE, err_out);
+ camera = scene->camera;
if (ibuf_view) {
memcpy(rr->rectf, ibuf_view->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
@@ -215,17 +215,17 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
* float buffer. */
if (oglrender->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) {
- int predivide= 0; /* no alpha */
+ int predivide = 0; /* no alpha */
IMB_buffer_float_from_float(rr->rectf, rr->rectf,
- 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, predivide,
- oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
+ 4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, predivide,
+ oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
}
RE_ReleaseResult(oglrender->re);
/* update byte from float buffer */
- ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
+ ibuf = BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
if (ibuf) {
image_buffer_rect_update(scene, rr, ibuf, NULL);
@@ -239,9 +239,9 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
}
BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, FALSE);
- ok= BKE_write_ibuf_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */
- if (ok) printf("OpenGL Render written to '%s'\n", name);
- else printf("OpenGL Render failed to write '%s'\n", name);
+ ok = BKE_write_ibuf_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */
+ if (ok) printf("OpenGL Render written to '%s'\n", name);
+ else printf("OpenGL Render failed to write '%s'\n", name);
}
}
@@ -251,17 +251,17 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
static int screen_opengl_render_init(bContext *C, wmOperator *op)
{
/* new render clears all callbacks */
- Scene *scene= CTX_data_scene(C);
- ScrArea *prevsa= CTX_wm_area(C);
- ARegion *prevar= CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ ScrArea *prevsa = CTX_wm_area(C);
+ ARegion *prevar = CTX_wm_region(C);
RenderResult *rr;
GPUOffScreen *ofs;
OGLRender *oglrender;
int sizex, sizey;
- short is_view_context= RNA_boolean_get(op->ptr, "view_context");
- const short is_animation= RNA_boolean_get(op->ptr, "animation");
- const short is_write_still= RNA_boolean_get(op->ptr, "write_still");
- char err_out[256]= "unknown";
+ short is_view_context = RNA_boolean_get(op->ptr, "view_context");
+ const short is_animation = RNA_boolean_get(op->ptr, "animation");
+ const short is_write_still = RNA_boolean_get(op->ptr, "write_still");
+ char err_out[256] = "unknown";
if (G.background) {
BKE_report(op->reports, RPT_ERROR, "Can't use OpenGL render in background mode (no opengl context)");
@@ -279,7 +279,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
if (WM_jobs_test(CTX_wm_manager(C), scene))
return 0;
- if (!is_view_context && scene->camera==NULL) {
+ if (!is_view_context && scene->camera == NULL) {
BKE_report(op->reports, RPT_ERROR, "Scene has no camera");
return 0;
}
@@ -296,11 +296,11 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
WM_cursor_wait(1);
/* create offscreen buffer */
- sizex= (scene->r.size*scene->r.xsch)/100;
- sizey= (scene->r.size*scene->r.ysch)/100;
+ sizex = (scene->r.size * scene->r.xsch) / 100;
+ sizey = (scene->r.size * scene->r.ysch) / 100;
/* corrects render size with actual size, not every card supports non-power-of-two dimensions */
- ofs= GPU_offscreen_create(sizex, sizey, err_out);
+ ofs = GPU_offscreen_create(sizex, sizey, err_out);
if (!ofs) {
BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer, %s", err_out);
@@ -308,27 +308,27 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
}
/* allocate opengl render */
- oglrender= MEM_callocN(sizeof(OGLRender), "OGLRender");
- op->customdata= oglrender;
+ oglrender = MEM_callocN(sizeof(OGLRender), "OGLRender");
+ op->customdata = oglrender;
- oglrender->ofs= ofs;
- oglrender->sizex= sizex;
- oglrender->sizey= sizey;
- oglrender->bmain= CTX_data_main(C);
- oglrender->scene= scene;
- oglrender->cfrao= scene->r.cfra;
+ oglrender->ofs = ofs;
+ oglrender->sizex = sizex;
+ oglrender->sizey = sizey;
+ oglrender->bmain = CTX_data_main(C);
+ oglrender->scene = scene;
+ oglrender->cfrao = scene->r.cfra;
- oglrender->write_still= is_write_still && !is_animation;
+ oglrender->write_still = is_write_still && !is_animation;
oglrender->obcenter_dia_back = U.obcenter_dia;
U.obcenter_dia = 0;
- oglrender->prevsa= prevsa;
- oglrender->prevar= prevar;
+ oglrender->prevsa = prevsa;
+ oglrender->prevar = prevar;
if (is_view_context) {
ED_view3d_context_user_region(C, &oglrender->v3d, &oglrender->ar); /* so quad view renders camera */
- oglrender->rv3d= oglrender->ar->regiondata;
+ oglrender->rv3d = oglrender->ar->regiondata;
/* MUST be cleared on exit */
oglrender->scene->customdata_mask_modal = (ED_view3d_datamask(oglrender->scene, oglrender->v3d) |
@@ -341,22 +341,22 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
}
/* create render */
- oglrender->re= RE_NewRender(scene->id.name);
+ oglrender->re = RE_NewRender(scene->id.name);
/* create image and image user */
- oglrender->ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+ oglrender->ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
BKE_image_signal(oglrender->ima, NULL, IMA_SIGNAL_FREE);
BKE_image_backup_render(oglrender->scene, oglrender->ima);
- oglrender->iuser.scene= scene;
- oglrender->iuser.ok= 1;
+ oglrender->iuser.scene = scene;
+ oglrender->iuser.ok = 1;
/* create render result */
RE_InitState(oglrender->re, NULL, &scene->r, NULL, sizex, sizey, NULL);
- rr= RE_AcquireResultWrite(oglrender->re);
- if (rr->rectf==NULL)
- rr->rectf= MEM_callocN(sizeof(float)*4*sizex*sizey, "screen_opengl_render_init rect");
+ rr = RE_AcquireResultWrite(oglrender->re);
+ if (rr->rectf == NULL)
+ rr->rectf = MEM_callocN(sizeof(float) * 4 * sizex * sizey, "screen_opengl_render_init rect");
RE_ReleaseResult(oglrender->re);
return 1;
@@ -364,8 +364,8 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= oglrender->scene;
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = oglrender->scene;
if (oglrender->mh) {
if (BKE_imtype_is_movie(scene->r.im_format.imtype))
@@ -373,20 +373,20 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
}
if (oglrender->timer) { /* exec will not have a timer */
- scene->r.cfra= oglrender->cfrao;
+ scene->r.cfra = oglrender->cfrao;
scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender));
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), oglrender->timer);
}
WM_cursor_wait(0);
- WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, oglrender->scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, oglrender->scene);
U.obcenter_dia = oglrender->obcenter_dia_back;
GPU_offscreen_free(oglrender->ofs);
- oglrender->scene->customdata_mask_modal= 0;
+ oglrender->scene->customdata_mask_modal = 0;
CTX_wm_area_set(C, oglrender->prevsa);
CTX_wm_region_set(C, oglrender->prevar);
@@ -408,11 +408,11 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op)
OGLRender *oglrender;
Scene *scene;
- oglrender= op->customdata;
- scene= oglrender->scene;
+ oglrender = op->customdata;
+ scene = oglrender->scene;
- oglrender->reports= op->reports;
- oglrender->mh= BKE_get_movie_handle(scene->r.im_format.imtype);
+ oglrender->reports = op->reports;
+ oglrender->mh = BKE_get_movie_handle(scene->r.im_format.imtype);
if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
if (!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) {
screen_opengl_render_end(C, oglrender);
@@ -420,31 +420,31 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op)
}
}
- oglrender->cfrao= scene->r.cfra;
- oglrender->nfra= PSFRA;
- scene->r.cfra= PSFRA;
+ oglrender->cfrao = scene->r.cfra;
+ oglrender->nfra = PSFRA;
+ scene->r.cfra = PSFRA;
return 1;
}
static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
- OGLRender *oglrender= op->customdata;
- Scene *scene= oglrender->scene;
+ Main *bmain = CTX_data_main(C);
+ OGLRender *oglrender = op->customdata;
+ Scene *scene = oglrender->scene;
ImBuf *ibuf;
void *lock;
char name[FILE_MAX];
- int ok= 0;
- const short view_context= (oglrender->v3d != NULL);
- Object *camera= NULL;
+ int ok = 0;
+ const short view_context = (oglrender->v3d != NULL);
+ Object *camera = NULL;
/* update animated image textures for gpu, etc,
* call before scene_update_for_newframe so modifiers with textuers don't lag 1 frame */
ED_image_update_frame(bmain, scene->r.cfra);
/* go to next frame */
- while (CFRA<oglrender->nfra) {
- unsigned int lay= screen_opengl_layers(oglrender);
+ while (CFRA < oglrender->nfra) {
+ unsigned int lay = screen_opengl_layers(oglrender);
if (lay & 0xFF000000)
lay &= 0xFF000000;
@@ -456,50 +456,50 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender));
if (view_context) {
- if (oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) {
+ if (oglrender->rv3d->persp == RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) {
/* since scene_update_for_newframe() is used rather
* then ED_update_for_newframe() the camera needs to be set */
if (scene_camera_switch_update(scene)) {
- oglrender->v3d->camera= scene->camera;
+ oglrender->v3d->camera = scene->camera;
}
- camera= oglrender->v3d->camera;
+ camera = oglrender->v3d->camera;
}
}
else {
scene_camera_switch_update(scene);
- camera= scene->camera;
+ camera = scene->camera;
}
/* render into offscreen buffer */
screen_opengl_render_apply(oglrender);
/* save to disk */
- ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
+ ibuf = BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
if (ibuf) {
/* color -> greyscale */
/* editing directly would alter the render view */
if (scene->r.im_format.planes == R_IMF_PLANES_BW) {
- ImBuf *ibuf_bw= IMB_dupImBuf(ibuf);
+ ImBuf *ibuf_bw = IMB_dupImBuf(ibuf);
IMB_color_to_bw(ibuf_bw);
// IMB_freeImBuf(ibuf); /* owned by the image */
- ibuf= ibuf_bw;
+ ibuf = ibuf_bw;
}
else {
/* this is lightweight & doesnt re-alloc the buffers, only do this
* to save the correct bit depth since the image is always RGBA */
- ImBuf *ibuf_cpy= IMB_allocImBuf(ibuf->x, ibuf->y, scene->r.im_format.planes, 0);
- ibuf_cpy->rect= ibuf->rect;
- ibuf_cpy->rect_float= ibuf->rect_float;
- ibuf_cpy->zbuf_float= ibuf->zbuf_float;
- ibuf= ibuf_cpy;
+ ImBuf *ibuf_cpy = IMB_allocImBuf(ibuf->x, ibuf->y, scene->r.im_format.planes, 0);
+ ibuf_cpy->rect = ibuf->rect;
+ ibuf_cpy->rect_float = ibuf->rect_float;
+ ibuf_cpy->zbuf_float = ibuf->zbuf_float;
+ ibuf = ibuf_cpy;
}
if (BKE_imtype_is_movie(scene->r.im_format.imtype)) {
- ok= oglrender->mh->append_movie(&scene->r, SFRA, CFRA, (int*)ibuf->rect,
- oglrender->sizex, oglrender->sizey, oglrender->reports);
+ ok = oglrender->mh->append_movie(&scene->r, SFRA, CFRA, (int *)ibuf->rect,
+ oglrender->sizex, oglrender->sizey, oglrender->reports);
if (ok) {
printf("Append frame %d", scene->r.cfra);
BKE_reportf(op->reports, RPT_INFO, "Appended frame: %d", scene->r.cfra);
@@ -507,9 +507,9 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
}
else {
BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE);
- ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format);
+ ok = BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format);
- if (ok==0) {
+ if (ok == 0) {
printf("Write error: cannot save %s\n", name);
BKE_reportf(op->reports, RPT_ERROR, "Write error: cannot save %s", name);
}
@@ -544,11 +544,11 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- OGLRender *oglrender= op->customdata;
- int anim= RNA_boolean_get(op->ptr, "animation");
+ OGLRender *oglrender = op->customdata;
+ int anim = RNA_boolean_get(op->ptr, "animation");
int ret;
- switch(event->type) {
+ switch (event->type) {
case ESCKEY:
/* cancel */
screen_opengl_render_end(C, op->customdata);
@@ -563,7 +563,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *even
}
/* run first because screen_opengl_render_anim_step can free oglrender */
- WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, oglrender->scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, oglrender->scene);
if (anim == 0) {
screen_opengl_render_apply(op->customdata);
@@ -571,7 +571,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *even
return OPERATOR_FINISHED;
}
else
- ret= screen_opengl_render_anim_step(C, op);
+ ret = screen_opengl_render_anim_step(C, op);
/* stop at the end or on error */
if (ret == 0) {
@@ -584,7 +584,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *even
static int screen_opengl_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
OGLRender *oglrender;
- int anim= RNA_boolean_get(op->ptr, "animation");
+ int anim = RNA_boolean_get(op->ptr, "animation");
if (!screen_opengl_render_init(C, op))
return OPERATOR_CANCELLED;
@@ -594,11 +594,11 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, wmEvent *eve
return OPERATOR_CANCELLED;
}
- oglrender= op->customdata;
+ oglrender = op->customdata;
render_view_open(C, event->x, event->y);
WM_event_add_modal_handler(C, op);
- oglrender->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
+ oglrender->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
return OPERATOR_RUNNING_MODAL;
}
@@ -606,7 +606,7 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, wmEvent *eve
/* executes blocking render */
static int screen_opengl_render_exec(bContext *C, wmOperator *op)
{
- const short is_animation= RNA_boolean_get(op->ptr, "animation");
+ const short is_animation = RNA_boolean_get(op->ptr, "animation");
if (!screen_opengl_render_init(C, op))
return OPERATOR_CANCELLED;
@@ -619,19 +619,19 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
else {
- int ret= 1;
+ int ret = 1;
if (!screen_opengl_render_anim_initialize(C, op))
return OPERATOR_CANCELLED;
while (ret) {
- ret= screen_opengl_render_anim_step(C, op);
+ ret = screen_opengl_render_anim_step(C, op);
}
}
// no redraw needed, we leave state as we entered it
// ED_update_for_newframe(C, 1);
- WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, CTX_data_scene(C));
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, CTX_data_scene(C));
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 9ba961302f1..27e1486c4f3 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -100,9 +100,9 @@
#include "render_intern.h"
-ImBuf* get_brush_icon(Brush *brush)
+ImBuf *get_brush_icon(Brush *brush)
{
- static const int flags = IB_rect|IB_multilayer|IB_metadata;
+ static const int flags = IB_rect | IB_multilayer | IB_metadata;
char path[FILE_MAX];
char *folder;
@@ -116,16 +116,16 @@ ImBuf* get_brush_icon(Brush *brush)
BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
BLI_path_abs(path, G.main->name);
- brush->icon_imbuf= IMB_loadiffname(path, flags);
+ brush->icon_imbuf = IMB_loadiffname(path, flags);
// otherwise lets try to find it in other directories
if (!(brush->icon_imbuf)) {
- folder= BLI_get_folder(BLENDER_DATAFILES, "brushicons");
+ folder = BLI_get_folder(BLENDER_DATAFILES, "brushicons");
BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath);
if (path[0])
- brush->icon_imbuf= IMB_loadiffname(path, flags);
+ brush->icon_imbuf = IMB_loadiffname(path, flags);
}
if (brush->icon_imbuf)
@@ -156,7 +156,7 @@ typedef struct ShaderPreview {
Lamp *lampcopy;
World *worldcopy;
- float col[4]; /* active object color */
+ float col[4]; /* active object color */
int sizex, sizey;
unsigned int *pr_rect;
@@ -179,7 +179,7 @@ typedef struct IconPreview {
/* *************************** Preview for buttons *********************** */
-static Main *pr_main= NULL;
+static Main *pr_main = NULL;
void ED_preview_init_dbase(void)
{
@@ -187,16 +187,16 @@ void ED_preview_init_dbase(void)
BlendFileData *bfd;
extern int datatoc_preview_blend_size;
extern char datatoc_preview_blend[];
- const int fileflags= G.fileflags;
+ const int fileflags = G.fileflags;
G.fileflags |= G_FILE_NO_UI;
- bfd= BLO_read_from_memory(datatoc_preview_blend, datatoc_preview_blend_size, NULL);
+ bfd = BLO_read_from_memory(datatoc_preview_blend, datatoc_preview_blend_size, NULL);
if (bfd) {
- pr_main= bfd->main;
+ pr_main = bfd->main;
MEM_freeN(bfd);
}
- G.fileflags= fileflags;
+ G.fileflags = fileflags;
#endif
}
@@ -212,18 +212,18 @@ static int preview_mat_has_sss(Material *mat, bNodeTree *ntree)
if (mat->sss_flag & MA_DIFF_SSS)
return 1;
if (mat->nodetree)
- if ( preview_mat_has_sss(NULL, mat->nodetree))
+ if (preview_mat_has_sss(NULL, mat->nodetree))
return 1;
}
else if (ntree) {
bNode *node;
- for (node= ntree->nodes.first; node; node= node->next) {
- if (node->type==NODE_GROUP && node->id) {
- if ( preview_mat_has_sss(NULL, (bNodeTree *)node->id))
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == NODE_GROUP && node->id) {
+ if (preview_mat_has_sss(NULL, (bNodeTree *)node->id))
return 1;
}
else if (node->id && ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) {
- mat= (Material *)node->id;
+ mat = (Material *)node->id;
if (mat->sss_flag & MA_DIFF_SSS)
return 1;
}
@@ -239,55 +239,55 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
Scene *sce;
Base *base;
- if (pr_main==NULL) return NULL;
+ if (pr_main == NULL) return NULL;
- sce= pr_main->scene.first;
+ sce = pr_main->scene.first;
if (sce) {
/* this flag tells render to not execute depsgraph or ipos etc */
sce->r.scemode |= R_PREVIEWBUTS;
/* set world always back, is used now */
- sce->world= pr_main->world.first;
+ sce->world = pr_main->world.first;
/* now: exposure copy */
if (scene->world) {
- sce->world->exp= scene->world->exp;
- sce->world->range= scene->world->range;
+ sce->world->exp = scene->world->exp;
+ sce->world->range = scene->world->range;
}
sce->r.color_mgt_flag = scene->r.color_mgt_flag;
/* prevent overhead for small renders and icons (32) */
if (id && sp->sizex < 40)
- sce->r.xparts= sce->r.yparts= 1;
+ sce->r.xparts = sce->r.yparts = 1;
else
- sce->r.xparts= sce->r.yparts= 4;
+ sce->r.xparts = sce->r.yparts = 4;
/* exception: don't color manage texture previews or icons */
- if ((id && sp->pr_method==PR_ICON_RENDER) || id_type == ID_TE)
+ if ((id && sp->pr_method == PR_ICON_RENDER) || id_type == ID_TE)
sce->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT;
- if ((id && sp->pr_method==PR_ICON_RENDER) && id_type != ID_WO)
- sce->r.alphamode= R_ALPHAPREMUL;
+ if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO)
+ sce->r.alphamode = R_ALPHAPREMUL;
else
- sce->r.alphamode= R_ADDSKY;
+ sce->r.alphamode = R_ADDSKY;
- sce->r.cfra= scene->r.cfra;
+ sce->r.cfra = scene->r.cfra;
BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine));
- if (id_type==ID_MA) {
- Material *mat= NULL, *origmat= (Material *)id;
+ if (id_type == ID_MA) {
+ Material *mat = NULL, *origmat = (Material *)id;
if (origmat) {
/* work on a copy */
- mat= localize_material(origmat);
- sp->matcopy= mat;
+ mat = localize_material(origmat);
+ sp->matcopy = mat;
BLI_addtail(&pr_main->mat, mat);
- init_render_material(mat, 0, NULL); /* call that retrieves mode_l */
+ init_render_material(mat, 0, NULL); /* call that retrieves mode_l */
end_render_material(mat);
/* un-useful option */
- if (sp->pr_method==PR_ICON_RENDER)
+ if (sp->pr_method == PR_ICON_RENDER)
mat->shade_flag &= ~MA_OBCOLOR;
/* turn on raytracing if needed */
@@ -304,9 +304,9 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
/* this only works in a specific case where the preview.blend contains
* an object starting with 'c' which has a material linked to it (not the obdata)
* and that material has a fake shadow texture in the active texture slot */
- for (base= sce->base.first; base; base= base->next) {
- if (base->object->id.name[2]=='c') {
- Material *shadmat= give_current_material(base->object, base->object->actcol);
+ for (base = sce->base.first; base; base = base->next) {
+ if (base->object->id.name[2] == 'c') {
+ Material *shadmat = give_current_material(base->object, base->object->actcol);
if (shadmat) {
if (mat->mode & MA_SHADBUF) shadmat->septex = 0;
else shadmat->septex |= 1;
@@ -317,10 +317,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
/* turn off bounce lights for volume,
* doesn't make much visual difference and slows it down too */
if (mat->material_type == MA_TYPE_VOLUME) {
- for (base= sce->base.first; base; base= base->next) {
+ for (base = sce->base.first; base; base = base->next) {
if (base->object->type == OB_LAMP) {
/* if doesn't match 'Lamp.002' --> main key light */
- if ( strcmp(base->object->id.name+2, "Lamp.002") != 0 ) {
+ if (strcmp(base->object->id.name + 2, "Lamp.002") != 0) {
base->object->restrictflag |= OB_RESTRICT_RENDER;
}
}
@@ -328,17 +328,17 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
}
- if (sp->pr_method==PR_ICON_RENDER) {
+ if (sp->pr_method == PR_ICON_RENDER) {
if (mat->material_type == MA_TYPE_HALO) {
- sce->lay= 1<<MA_FLAT;
+ sce->lay = 1 << MA_FLAT;
}
else {
- sce->lay= 1<<MA_SPHERE_A;
+ sce->lay = 1 << MA_SPHERE_A;
}
}
else {
- sce->lay= 1<<mat->pr_type;
- if (mat->nodetree && sp->pr_method==PR_NODE_RENDER) {
+ sce->lay = 1 << mat->pr_type;
+ if (mat->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
ntreeInitPreview(mat->nodetree, sp->sizex, sp->sizey);
ntreeInitPreview(origmat->nodetree, sp->sizex, sp->sizey);
@@ -346,22 +346,22 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
}
}
else {
- sce->r.mode &= ~(R_OSA|R_RAYTRACE|R_SSS);
+ sce->r.mode &= ~(R_OSA | R_RAYTRACE | R_SSS);
}
- for (base= sce->base.first; base; base= base->next) {
- if (base->object->id.name[2]=='p') {
+ for (base = sce->base.first; base; base = base->next) {
+ if (base->object->id.name[2] == 'p') {
/* copy over object color, in case material uses it */
copy_v4_v4(base->object->col, sp->col);
if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) {
/* don't use assign_material, it changed mat->id.us, which shows in the UI */
- Material ***matar= give_matarar(base->object);
- int actcol= MAX2(base->object->actcol > 0, 1) - 1;
+ Material ***matar = give_matarar(base->object);
+ int actcol = MAX2(base->object->actcol > 0, 1) - 1;
if (matar && actcol < base->object->totcol)
- (*matar)[actcol]= mat;
+ (*matar)[actcol] = mat;
}
else if (base->object->type == OB_LAMP) {
base->object->restrictflag &= ~OB_RESTRICT_RENDER;
@@ -369,92 +369,92 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
}
}
}
- else if (id_type==ID_TE) {
- Tex *tex= NULL, *origtex= (Tex *)id;
+ else if (id_type == ID_TE) {
+ Tex *tex = NULL, *origtex = (Tex *)id;
if (origtex) {
- tex= localize_texture(origtex);
- sp->texcopy= tex;
+ tex = localize_texture(origtex);
+ sp->texcopy = tex;
BLI_addtail(&pr_main->tex, tex);
}
- sce->lay= 1<<MA_TEXTURE;
+ sce->lay = 1 << MA_TEXTURE;
- for (base= sce->base.first; base; base= base->next) {
- if (base->object->id.name[2]=='t') {
- Material *mat= give_current_material(base->object, base->object->actcol);
+ for (base = sce->base.first; base; base = base->next) {
+ if (base->object->id.name[2] == 't') {
+ Material *mat = give_current_material(base->object, base->object->actcol);
if (mat && mat->mtex[0]) {
- mat->mtex[0]->tex= tex;
+ mat->mtex[0]->tex = tex;
if (tex && sp->slot)
mat->mtex[0]->which_output = sp->slot->which_output;
/* show alpha in this case */
- if (tex==NULL || (tex->flag & TEX_PRV_ALPHA)) {
+ if (tex == NULL || (tex->flag & TEX_PRV_ALPHA)) {
mat->mtex[0]->mapto |= MAP_ALPHA;
- mat->alpha= 0.0f;
+ mat->alpha = 0.0f;
}
else {
mat->mtex[0]->mapto &= ~MAP_ALPHA;
- mat->alpha= 1.0f;
+ mat->alpha = 1.0f;
}
}
}
}
- if (tex && tex->nodetree && sp->pr_method==PR_NODE_RENDER) {
+ if (tex && tex->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
ntreeInitPreview(origtex->nodetree, sp->sizex, sp->sizey);
ntreeInitPreview(tex->nodetree, sp->sizex, sp->sizey);
}
}
- else if (id_type==ID_LA) {
- Lamp *la= NULL, *origla= (Lamp *)id;
+ else if (id_type == ID_LA) {
+ Lamp *la = NULL, *origla = (Lamp *)id;
/* work on a copy */
if (origla) {
- la= localize_lamp(origla);
- sp->lampcopy= la;
+ la = localize_lamp(origla);
+ sp->lampcopy = la;
BLI_addtail(&pr_main->lamp, la);
}
- if (la && la->type==LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) {
- sce->lay= 1<<MA_ATMOS;
- sce->world= scene->world;
- sce->camera= (Object *)BLI_findstring(&pr_main->object, "CameraAtmo", offsetof(ID, name)+2);
+ if (la && la->type == LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) {
+ sce->lay = 1 << MA_ATMOS;
+ sce->world = scene->world;
+ sce->camera = (Object *)BLI_findstring(&pr_main->object, "CameraAtmo", offsetof(ID, name) + 2);
}
else {
- sce->lay= 1<<MA_LAMP;
- sce->world= NULL;
- sce->camera= (Object *)BLI_findstring(&pr_main->object, "Camera", offsetof(ID, name)+2);
+ sce->lay = 1 << MA_LAMP;
+ sce->world = NULL;
+ sce->camera = (Object *)BLI_findstring(&pr_main->object, "Camera", offsetof(ID, name) + 2);
}
sce->r.mode &= ~R_SHADOW;
- for (base= sce->base.first; base; base= base->next) {
- if (base->object->id.name[2]=='p') {
- if (base->object->type==OB_LAMP)
- base->object->data= la;
+ for (base = sce->base.first; base; base = base->next) {
+ if (base->object->id.name[2] == 'p') {
+ if (base->object->type == OB_LAMP)
+ base->object->data = la;
}
}
- if (la && la->nodetree && sp->pr_method==PR_NODE_RENDER) {
+ if (la && la->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
ntreeInitPreview(origla->nodetree, sp->sizex, sp->sizey);
ntreeInitPreview(la->nodetree, sp->sizex, sp->sizey);
}
}
- else if (id_type==ID_WO) {
- World *wrld= NULL, *origwrld= (World *)id;
+ else if (id_type == ID_WO) {
+ World *wrld = NULL, *origwrld = (World *)id;
if (origwrld) {
- wrld= localize_world(origwrld);
- sp->worldcopy= wrld;
+ wrld = localize_world(origwrld);
+ sp->worldcopy = wrld;
BLI_addtail(&pr_main->world, wrld);
}
- sce->lay= 1<<MA_SKY;
- sce->world= wrld;
+ sce->lay = 1 << MA_SKY;
+ sce->world = wrld;
- if (wrld && wrld->nodetree && sp->pr_method==PR_NODE_RENDER) {
+ if (wrld && wrld->nodetree && sp->pr_method == PR_NODE_RENDER) {
/* two previews, they get copied by wmJob */
ntreeInitPreview(wrld->nodetree, sp->sizex, sp->sizey);
ntreeInitPreview(origwrld->nodetree, sp->sizex, sp->sizey);
@@ -474,8 +474,8 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
Render *re;
RenderResult rres;
char name[32];
- int do_gamma_correct=0, do_predivide=0;
- int offx=0, newx= rect->xmax-rect->xmin, newy= rect->ymax-rect->ymin;
+ int do_gamma_correct = 0, do_predivide = 0;
+ int offx = 0, newx = rect->xmax - rect->xmin, newy = rect->ymax - rect->ymin;
if (id && GS(id->name) != ID_TE) {
/* exception: don't color manage texture previews - show the raw values */
@@ -490,38 +490,38 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
if (split) {
if (first) {
- offx= 0;
- newx= newx/2;
+ offx = 0;
+ newx = newx / 2;
}
else {
- offx= newx/2;
- newx= newx - newx/2;
+ offx = newx / 2;
+ newx = newx - newx / 2;
}
}
- re= RE_GetRender(name);
+ re = RE_GetRender(name);
RE_AcquireResultImage(re, &rres);
if (rres.rectf) {
- if (ABS(rres.rectx-newx)<2 && ABS(rres.recty-newy)<2) {
+ if (ABS(rres.rectx - newx) < 2 && ABS(rres.recty - newy) < 2) {
newrect->xmax = MAX2(newrect->xmax, rect->xmin + rres.rectx + offx);
newrect->ymax = MAX2(newrect->ymax, rect->ymin + rres.recty);
if (rres.rectx && rres.recty) {
/* temporary conversion to byte for drawing */
- float fx= rect->xmin + offx;
- float fy= rect->ymin;
- int profile_from= (do_gamma_correct)? IB_PROFILE_LINEAR_RGB: IB_PROFILE_SRGB;
- int dither= 0;
+ float fx = rect->xmin + offx;
+ float fy = rect->ymin;
+ int profile_from = (do_gamma_correct) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB;
+ int dither = 0;
unsigned char *rect_byte;
- rect_byte= MEM_mallocN(rres.rectx*rres.recty*sizeof(int), "ed_preview_draw_rect");
+ rect_byte = MEM_mallocN(rres.rectx * rres.recty * sizeof(int), "ed_preview_draw_rect");
IMB_buffer_byte_from_float(rect_byte, rres.rectf,
- 4, dither, IB_PROFILE_SRGB, profile_from, do_predivide,
- rres.rectx, rres.recty, rres.rectx, rres.rectx);
+ 4, dither, IB_PROFILE_SRGB, profile_from, do_predivide,
+ rres.rectx, rres.recty, rres.rectx, rres.rectx);
glaDrawPixelsSafe(fx, fy, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect_byte);
@@ -540,15 +540,15 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int
void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect)
{
if (idp) {
- ScrArea *sa= CTX_wm_area(C);
+ ScrArea *sa = CTX_wm_area(C);
Scene *sce = CTX_data_scene(C);
ID *id = (ID *)idp;
- ID *parent= (ID *)parentp;
- MTex *slot= (MTex *)slotp;
- SpaceButs *sbuts= sa->spacedata.first;
+ ID *parent = (ID *)parentp;
+ MTex *slot = (MTex *)slotp;
+ SpaceButs *sbuts = sa->spacedata.first;
rcti newrect;
int ok;
- int newx= rect->xmax-rect->xmin, newy= rect->ymax-rect->ymin;
+ int newx = rect->xmax - rect->xmin, newy = rect->ymax - rect->ymin;
newrect.xmin = rect->xmin;
newrect.xmax = rect->xmin;
@@ -563,15 +563,15 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
ok = ed_preview_draw_rect(sa, sce, id, 0, 0, rect, &newrect);
if (ok)
- *rect= newrect;
+ *rect = newrect;
/* check for spacetype... */
- if (sbuts->spacetype==SPACE_BUTS && sbuts->preview) {
- sbuts->preview= 0;
- ok= 0;
+ if (sbuts->spacetype == SPACE_BUTS && sbuts->preview) {
+ sbuts->preview = 0;
+ ok = 0;
}
- if (ok==0) {
+ if (ok == 0) {
ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER);
}
}
@@ -582,15 +582,15 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
/* inside thread, called by renderer, sets job update value */
static void shader_preview_draw(void *spv, RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect))
{
- ShaderPreview *sp= spv;
+ ShaderPreview *sp = spv;
- *(sp->do_update)= 1;
+ *(sp->do_update) = 1;
}
/* called by renderer, checks job value */
static int shader_preview_break(void *spv)
{
- ShaderPreview *sp= spv;
+ ShaderPreview *sp = spv;
return *(sp->stop);
}
@@ -598,30 +598,30 @@ static int shader_preview_break(void *spv)
/* outside thread, called before redraw notifiers, it moves finished preview over */
static void shader_preview_updatejob(void *spv)
{
- ShaderPreview *sp= spv;
+ ShaderPreview *sp = spv;
if (sp->id) {
- if (sp->pr_method==PR_NODE_RENDER) {
- if ( GS(sp->id->name) == ID_MA) {
- Material *mat= (Material *)sp->id;
+ if (sp->pr_method == PR_NODE_RENDER) {
+ if (GS(sp->id->name) == ID_MA) {
+ Material *mat = (Material *)sp->id;
if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree)
ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree);
}
- else if ( GS(sp->id->name) == ID_TE) {
- Tex *tex= (Tex *)sp->id;
+ else if (GS(sp->id->name) == ID_TE) {
+ Tex *tex = (Tex *)sp->id;
if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree)
ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree);
}
- else if ( GS(sp->id->name) == ID_WO) {
- World *wrld= (World *)sp->id;
+ else if (GS(sp->id->name) == ID_WO) {
+ World *wrld = (World *)sp->id;
if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree)
ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree);
}
- else if ( GS(sp->id->name) == ID_LA) {
- Lamp *la= (Lamp *)sp->id;
+ else if (GS(sp->id->name) == ID_LA) {
+ Lamp *la = (Lamp *)sp->id;
if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree)
ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree);
@@ -635,50 +635,50 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
Render *re;
Scene *sce;
float oldlens;
- short idtype= GS(id->name);
+ short idtype = GS(id->name);
char name[32];
int sizex;
/* get the stuff from the builtin preview dbase */
- sce= preview_prepare_scene(sp->scene, id, idtype, sp); // XXX sizex
- if (sce==NULL) return;
+ sce = preview_prepare_scene(sp->scene, id, idtype, sp); // XXX sizex
+ if (sce == NULL) return;
if (!split || first) sprintf(name, "Preview %p", sp->owner);
else sprintf(name, "SecondPreview %p", sp->owner);
- re= RE_GetRender(name);
+ re = RE_GetRender(name);
/* full refreshed render from first tile */
- if (re==NULL)
- re= RE_NewRender(name);
+ if (re == NULL)
+ re = RE_NewRender(name);
/* sce->r gets copied in RE_InitState! */
- sce->r.scemode &= ~(R_MATNODE_PREVIEW|R_TEXNODE_PREVIEW);
+ sce->r.scemode &= ~(R_MATNODE_PREVIEW | R_TEXNODE_PREVIEW);
sce->r.scemode &= ~R_NO_IMAGE_LOAD;
- if (sp->pr_method==PR_ICON_RENDER) {
+ if (sp->pr_method == PR_ICON_RENDER) {
sce->r.scemode |= R_NO_IMAGE_LOAD;
sce->r.mode |= R_OSA;
}
- else if (sp->pr_method==PR_NODE_RENDER) {
+ else if (sp->pr_method == PR_NODE_RENDER) {
if (idtype == ID_MA) sce->r.scemode |= R_MATNODE_PREVIEW;
else if (idtype == ID_TE) sce->r.scemode |= R_TEXNODE_PREVIEW;
sce->r.mode &= ~R_OSA;
}
- else { /* PR_BUTS_RENDER */
+ else { /* PR_BUTS_RENDER */
sce->r.mode |= R_OSA;
}
/* in case of split preview, use border render */
if (split) {
- if (first) sizex= sp->sizex/2;
- else sizex= sp->sizex - sp->sizex/2;
+ if (first) sizex = sp->sizex / 2;
+ else sizex = sp->sizex - sp->sizex / 2;
}
- else sizex= sp->sizex;
+ else sizex = sp->sizex;
/* allocates or re-uses render result */
- sce->r.xsch= sizex;
- sce->r.ysch= sp->sizey;
- sce->r.size= 100;
+ sce->r.xsch = sizex;
+ sce->r.ysch = sp->sizey;
+ sce->r.size = 100;
/* callbacs are cleared on GetRender() */
if (ELEM(sp->pr_method, PR_BUTS_RENDER, PR_NODE_RENDER)) {
@@ -688,17 +688,17 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
RE_test_break_cb(re, sp, shader_preview_break);
/* lens adjust */
- oldlens= ((Camera *)sce->camera->data)->lens;
+ oldlens = ((Camera *)sce->camera->data)->lens;
if (sizex > sp->sizey)
- ((Camera *)sce->camera->data)->lens *= (float)sp->sizey/(float)sizex;
+ ((Camera *)sce->camera->data)->lens *= (float)sp->sizey / (float)sizex;
/* entire cycle for render engine */
RE_PreviewRender(re, pr_main, sce);
- ((Camera *)sce->camera->data)->lens= oldlens;
+ ((Camera *)sce->camera->data)->lens = oldlens;
/* handle results */
- if (sp->pr_method==PR_ICON_RENDER) {
+ if (sp->pr_method == PR_ICON_RENDER) {
// char *rct= (char *)(sp->pr_rect + 32*16 + 16);
if (sp->pr_rect)
@@ -726,10 +726,10 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* runs inside thread for material and icons */
static void shader_preview_startjob(void *customdata, short *stop, short *do_update)
{
- ShaderPreview *sp= customdata;
+ ShaderPreview *sp = customdata;
- sp->stop= stop;
- sp->do_update= do_update;
+ sp->stop = stop;
+ sp->do_update = do_update;
if (sp->parent) {
shader_preview_render(sp, sp->id, 1, 1);
@@ -738,12 +738,12 @@ static void shader_preview_startjob(void *customdata, short *stop, short *do_upd
else
shader_preview_render(sp, sp->id, 0, 0);
- *do_update= 1;
+ *do_update = 1;
}
static void shader_preview_free(void *customdata)
{
- ShaderPreview *sp= customdata;
+ ShaderPreview *sp = customdata;
if (sp->matcopy) {
struct IDProperty *properties;
@@ -756,14 +756,14 @@ static void shader_preview_free(void *customdata)
BLI_remlink(&pr_main->mat, sp->matcopy);
/* free_material decrements texture, prevent this. hack alert! */
- for (a=0; a<MAX_MTEX; a++) {
- MTex *mtex= sp->matcopy->mtex[a];
- if (mtex && mtex->tex) mtex->tex= NULL;
+ for (a = 0; a < MAX_MTEX; a++) {
+ MTex *mtex = sp->matcopy->mtex[a];
+ if (mtex && mtex->tex) mtex->tex = NULL;
}
free_material(sp->matcopy);
- properties= IDP_GetProperties((ID *)sp->matcopy, FALSE);
+ properties = IDP_GetProperties((ID *)sp->matcopy, FALSE);
if (properties) {
IDP_FreeProperty(properties);
MEM_freeN(properties);
@@ -779,7 +779,7 @@ static void shader_preview_free(void *customdata)
BLI_remlink(&pr_main->tex, sp->texcopy);
free_texture(sp->texcopy);
- properties= IDP_GetProperties((ID *)sp->texcopy, FALSE);
+ properties = IDP_GetProperties((ID *)sp->texcopy, FALSE);
if (properties) {
IDP_FreeProperty(properties);
MEM_freeN(properties);
@@ -795,7 +795,7 @@ static void shader_preview_free(void *customdata)
BLI_remlink(&pr_main->world, sp->worldcopy);
free_world(sp->worldcopy);
- properties= IDP_GetProperties((ID *)sp->worldcopy, FALSE);
+ properties = IDP_GetProperties((ID *)sp->worldcopy, FALSE);
if (properties) {
IDP_FreeProperty(properties);
MEM_freeN(properties);
@@ -811,7 +811,7 @@ static void shader_preview_free(void *customdata)
BLI_remlink(&pr_main->lamp, sp->lampcopy);
free_lamp(sp->lampcopy);
- properties= IDP_GetProperties((ID *)sp->lampcopy, FALSE);
+ properties = IDP_GetProperties((ID *)sp->lampcopy, FALSE);
if (properties) {
IDP_FreeProperty(properties);
MEM_freeN(properties);
@@ -832,7 +832,7 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
short ex, ey, dx, dy;
/* paranoia test */
- if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL))
+ if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL))
return;
/* waste of cpu cyles... but the imbuf API has no other way to scale fast (ton) */
@@ -843,10 +843,10 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
if (ima->x > ima->y) {
scaledx = (float)w;
- scaledy = ( (float)ima->y/(float)ima->x )*(float)w;
+ scaledy = ( (float)ima->y / (float)ima->x) * (float)w;
}
else {
- scaledx = ( (float)ima->x/(float)ima->y )*(float)h;
+ scaledx = ( (float)ima->x / (float)ima->y) * (float)h;
scaledy = (float)h;
}
@@ -859,15 +859,15 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
IMB_scalefastImBuf(ima, ex, ey);
/* if needed, convert to 32 bits */
- if (ima->rect==NULL)
+ if (ima->rect == NULL)
IMB_rect_from_float(ima);
srect = ima->rect;
drect = rect;
- drect+= dy*w+dx;
- for (;ey > 0; ey--) {
- memcpy(drect,srect, ex * sizeof(int));
+ drect += dy * w + dx;
+ for (; ey > 0; ey--) {
+ memcpy(drect, srect, ex * sizeof(int));
drect += w;
srect += ima->x;
}
@@ -877,55 +877,55 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned
static void set_alpha(char *cp, int sizex, int sizey, char alpha)
{
- int a, size= sizex*sizey;
+ int a, size = sizex * sizey;
- for (a=0; a<size; a++, cp+=4)
- cp[3]= alpha;
+ for (a = 0; a < size; a++, cp += 4)
+ cp[3] = alpha;
}
static void icon_preview_startjob(void *customdata, short *stop, short *do_update)
{
- ShaderPreview *sp= customdata;
- ID *id= sp->id;
- short idtype= GS(id->name);
+ ShaderPreview *sp = customdata;
+ ID *id = sp->id;
+ short idtype = GS(id->name);
if (idtype == ID_IM) {
- Image *ima= (Image*)id;
- ImBuf *ibuf= NULL;
- ImageUser iuser= {NULL};
+ Image *ima = (Image *)id;
+ ImBuf *ibuf = NULL;
+ ImageUser iuser = {NULL};
/* ima->ok is zero when Image cannot load */
- if (ima==NULL || ima->ok==0)
+ if (ima == NULL || ima->ok == 0)
return;
/* setup dummy image user */
- iuser.ok= iuser.framenr= 1;
- iuser.scene= sp->scene;
+ iuser.ok = iuser.framenr = 1;
+ iuser.scene = sp->scene;
/* elubie: this needs to be changed: here image is always loaded if not
* already there. Very expensive for large images. Need to find a way to
* only get existing ibuf */
ibuf = BKE_image_get_ibuf(ima, &iuser);
- if (ibuf==NULL || ibuf->rect==NULL)
+ if (ibuf == NULL || ibuf->rect == NULL)
return;
icon_copy_rect(ibuf, sp->sizex, sp->sizey, sp->pr_rect);
- *do_update= 1;
+ *do_update = 1;
}
else if (idtype == ID_BR) {
- Brush *br= (Brush*)id;
+ Brush *br = (Brush *)id;
- br->icon_imbuf= get_brush_icon(br);
+ br->icon_imbuf = get_brush_icon(br);
- memset(sp->pr_rect, 0x888888, sp->sizex*sp->sizey*sizeof(unsigned int));
+ memset(sp->pr_rect, 0x888888, sp->sizex * sp->sizey * sizeof(unsigned int));
if (!(br->icon_imbuf) || !(br->icon_imbuf->rect))
return;
icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect);
- *do_update= 1;
+ *do_update = 1;
}
else {
/* re-use shader job */
@@ -934,13 +934,13 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
/* world is rendered with alpha=0, so it wasn't displayed
* this could be render option for sky to, for later */
if (idtype == ID_WO) {
- set_alpha((char*)sp->pr_rect, sp->sizex, sp->sizey, 255);
+ set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);
}
else if (idtype == ID_MA) {
- Material* ma = (Material*)id;
+ Material *ma = (Material *)id;
if (ma->material_type == MA_TYPE_HALO)
- set_alpha((char*)sp->pr_rect, sp->sizex, sp->sizey, 255);
+ set_alpha((char *)sp->pr_rect, sp->sizex, sp->sizey, 255);
}
}
}
@@ -950,7 +950,7 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
static void common_preview_startjob(void *customdata, short *stop, short *do_update, float *UNUSED(progress))
{
- ShaderPreview *sp= customdata;
+ ShaderPreview *sp = customdata;
if (sp->pr_method == PR_ICON_RENDER)
icon_preview_startjob(customdata, stop, do_update);
@@ -992,12 +992,12 @@ static void icon_preview_startjob_all_sizes(void *customdata, short *stop, short
memset(&sp, 0, sizeof(ShaderPreview));
/* construct shader preview from image size and previewcustomdata */
- sp.scene= ip->scene;
- sp.owner= ip->owner;
- sp.sizex= cur_size->sizex;
- sp.sizey= cur_size->sizey;
- sp.pr_method= PR_ICON_RENDER;
- sp.pr_rect= cur_size->rect;
+ sp.scene = ip->scene;
+ sp.owner = ip->owner;
+ sp.sizex = cur_size->sizex;
+ sp.sizey = cur_size->sizey;
+ sp.pr_method = PR_ICON_RENDER;
+ sp.pr_rect = cur_size->rect;
sp.id = ip->id;
common_preview_startjob(&sp, stop, do_update, progress);
@@ -1011,7 +1011,7 @@ static void icon_preview_endjob(void *customdata)
IconPreview *ip = customdata;
if (ip->id && GS(ip->id->name) == ID_BR)
- WM_main_add_notifier(NC_BRUSH|NA_EDITED, ip->id);
+ WM_main_add_notifier(NC_BRUSH | NA_EDITED, ip->id);
}
static void icon_preview_free(void *customdata)
@@ -1028,19 +1028,19 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
IconPreview *ip, *old_ip;
/* suspended start means it starts after 1 timer step, see WM_jobs_timer below */
- steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER|WM_JOB_SUSPEND);
+ steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER | WM_JOB_SUSPEND);
- ip= MEM_callocN(sizeof(IconPreview), "icon preview");
+ ip = MEM_callocN(sizeof(IconPreview), "icon preview");
/* render all resolutions from suspended job too */
- old_ip= WM_jobs_get_customdata(steve);
+ old_ip = WM_jobs_get_customdata(steve);
if (old_ip)
BLI_movelisttolist(&ip->sizes, &old_ip->sizes);
/* customdata for preview thread */
- ip->scene= CTX_data_scene(C);
- ip->owner= id;
- ip->id= id;
+ ip->scene = CTX_data_scene(C);
+ ip->owner = id;
+ ip->id = id;
icon_preview_add_size(ip, rect, sizex, sizey);
@@ -1054,24 +1054,24 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey, int method)
{
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
wmJob *steve;
ShaderPreview *sp;
- steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Shader Preview", WM_JOB_EXCL_RENDER);
- sp= MEM_callocN(sizeof(ShaderPreview), "shader preview");
+ steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Shader Preview", WM_JOB_EXCL_RENDER);
+ sp = MEM_callocN(sizeof(ShaderPreview), "shader preview");
/* customdata for preview thread */
- sp->scene= CTX_data_scene(C);
- sp->owner= owner;
- sp->sizex= sizex;
- sp->sizey= sizey;
- sp->pr_method= method;
+ sp->scene = CTX_data_scene(C);
+ sp->owner = owner;
+ sp->sizex = sizex;
+ sp->sizey = sizey;
+ sp->pr_method = method;
sp->id = id;
- sp->parent= parent;
- sp->slot= slot;
+ sp->parent = parent;
+ sp->slot = slot;
if (ob && ob->totcol) copy_v4_v4(sp->col, ob->col);
- else sp->col[0]= sp->col[1]= sp->col[2]= sp->col[3]= 1.0f;
+ else sp->col[0] = sp->col[1] = sp->col[2] = sp->col[3] = 1.0f;
/* setup job */
WM_jobs_customdata(steve, sp, shader_preview_free);
@@ -1083,7 +1083,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
void ED_preview_kill_jobs(const struct bContext *C)
{
- wmWindowManager *wm= CTX_wm_manager(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
if (wm)
WM_jobs_kill(wm, NULL, common_preview_startjob);
}
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 260817d743f..6e2a83c13bb 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -87,20 +87,20 @@
#include "RE_pipeline.h"
-#include "render_intern.h" // own include
+#include "render_intern.h" // own include
/********************** material slot operators *********************/
static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= ED_object_context(C);
+ Object *ob = ED_object_context(C);
if (!ob)
return OPERATOR_CANCELLED;
object_add_material_slot(ob);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
- WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
return OPERATOR_FINISHED;
}
@@ -117,12 +117,12 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int material_slot_remove_exec(bContext *C, wmOperator *op)
{
- Object *ob= ED_object_context(C);
+ Object *ob = ED_object_context(C);
if (!ob)
return OPERATOR_CANCELLED;
@@ -135,8 +135,8 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
object_remove_material_slot(ob);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
- WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
return OPERATOR_FINISHED;
}
@@ -153,52 +153,53 @@ void OBJECT_OT_material_slot_remove(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= ED_object_context(C);
+ Object *ob = ED_object_context(C);
if (!ob)
return OPERATOR_CANCELLED;
- if (ob && ob->actcol>0) {
+ if (ob && ob->actcol > 0) {
if (ob->type == OB_MESH) {
BMEditMesh *em = BMEdit_FromObject(ob);
BMFace *efa;
BMIter iter;
if (em) {
- BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
+ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL)
+ {
if (BM_elem_flag_test(efa, BM_ELEM_SELECT))
- efa->mat_nr= ob->actcol-1;
+ efa->mat_nr = ob->actcol - 1;
}
}
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Nurb *nu;
- ListBase *nurbs= curve_editnurbs((Curve*)ob->data);
+ ListBase *nurbs = curve_editnurbs((Curve *)ob->data);
if (nurbs) {
- for (nu= nurbs->first; nu; nu= nu->next)
+ for (nu = nurbs->first; nu; nu = nu->next)
if (isNurbsel(nu))
- nu->mat_nr= nu->charidx= ob->actcol-1;
+ nu->mat_nr = nu->charidx = ob->actcol - 1;
}
}
else if (ob->type == OB_FONT) {
- EditFont *ef= ((Curve*)ob->data)->editfont;
+ EditFont *ef = ((Curve *)ob->data)->editfont;
int i, selstart, selend;
if (ef && BKE_font_getselection(ob, &selstart, &selend)) {
- for (i=selstart; i<=selend; i++)
+ for (i = selstart; i <= selend; i++)
ef->textbufinfo[i].mat_nr = ob->actcol;
}
}
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
+ WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
return OPERATOR_FINISHED;
}
@@ -215,7 +216,7 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int material_slot_de_select(bContext *C, int select)
@@ -229,24 +230,24 @@ static int material_slot_de_select(bContext *C, int select)
BMEditMesh *em = BMEdit_FromObject(ob);
if (em) {
- EDBM_deselect_by_material(em, ob->actcol-1, select);
+ EDBM_deselect_by_material(em, ob->actcol - 1, select);
}
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
- ListBase *nurbs= curve_editnurbs((Curve*)ob->data);
+ ListBase *nurbs = curve_editnurbs((Curve *)ob->data);
Nurb *nu;
BPoint *bp;
BezTriple *bezt;
int a;
if (nurbs) {
- for (nu= nurbs->first; nu; nu=nu->next) {
- if (nu->mat_nr==ob->actcol-1) {
+ for (nu = nurbs->first; nu; nu = nu->next) {
+ if (nu->mat_nr == ob->actcol - 1) {
if (nu->bezt) {
- a= nu->pntsu;
- bezt= nu->bezt;
+ a = nu->pntsu;
+ bezt = nu->bezt;
while (a--) {
- if (bezt->hide==0) {
+ if (bezt->hide == 0) {
if (select) {
bezt->f1 |= SELECT;
bezt->f2 |= SELECT;
@@ -262,10 +263,10 @@ static int material_slot_de_select(bContext *C, int select)
}
}
else if (nu->bp) {
- a= nu->pntsu*nu->pntsv;
- bp= nu->bp;
+ a = nu->pntsu * nu->pntsv;
+ bp = nu->bp;
while (a--) {
- if (bp->hide==0) {
+ if (bp->hide == 0) {
if (select) bp->f1 |= SELECT;
else bp->f1 &= ~SELECT;
}
@@ -277,7 +278,7 @@ static int material_slot_de_select(bContext *C, int select)
}
}
- WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
+ WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
return OPERATOR_FINISHED;
}
@@ -298,7 +299,7 @@ void OBJECT_OT_material_slot_select(wmOperatorType *ot)
ot->exec = material_slot_select_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int material_slot_deselect_exec(bContext *C, wmOperator *UNUSED(op))
@@ -317,26 +318,26 @@ void OBJECT_OT_material_slot_deselect(wmOperatorType *ot)
ot->exec = material_slot_deselect_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= ED_object_context(C);
+ Object *ob = ED_object_context(C);
Material ***matar;
- if (!ob || !(matar= give_matarar(ob)))
+ if (!ob || !(matar = give_matarar(ob)))
return OPERATOR_CANCELLED;
- CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
+ CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) {
if (ob != ob_iter && give_matarar(ob_iter)) {
if (ob->data != ob_iter->data)
assign_matarar(ob_iter, matar, ob->totcol);
- if (ob_iter->totcol==ob->totcol) {
- ob_iter->actcol= ob->actcol;
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter);
+ if (ob_iter->totcol == ob->totcol) {
+ ob_iter->actcol = ob->actcol;
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_iter);
}
}
}
@@ -357,28 +358,28 @@ void OBJECT_OT_material_slot_copy(wmOperatorType *ot)
ot->exec = material_slot_copy_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************** new material operator *********************/
static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene= CTX_data_scene(C);
- Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+ Scene *scene = CTX_data_scene(C);
+ Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
PointerRNA ptr, idptr;
PropertyRNA *prop;
/* add or copy material */
if (ma) {
- ma= copy_material(ma);
+ ma = copy_material(ma);
}
else {
- ma= add_material("Material");
+ ma = add_material("Material");
if (scene_use_new_shading_nodes(scene)) {
ED_node_shader_default(scene, &ma->id);
- ma->use_nodes= 1;
+ ma->use_nodes = 1;
}
}
@@ -395,7 +396,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
RNA_property_update(C, &ptr, prop);
}
- WM_event_add_notifier(C, NC_MATERIAL|NA_ADDED, ma);
+ WM_event_add_notifier(C, NC_MATERIAL | NA_ADDED, ma);
return OPERATOR_FINISHED;
}
@@ -411,22 +412,22 @@ void MATERIAL_OT_new(wmOperatorType *ot)
ot->exec = new_material_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************** new texture operator *********************/
static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
{
- Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+ Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
PointerRNA ptr, idptr;
PropertyRNA *prop;
/* add or copy texture */
if (tex)
- tex= copy_texture(tex);
+ tex = copy_texture(tex);
else
- tex= add_texture("Texture");
+ tex = add_texture("Texture");
/* hook into UI */
uiIDContextProperty(C, &ptr, &prop);
@@ -441,7 +442,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
RNA_property_update(C, &ptr, prop);
}
- WM_event_add_notifier(C, NC_TEXTURE|NA_ADDED, tex);
+ WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, tex);
return OPERATOR_FINISHED;
}
@@ -457,28 +458,28 @@ void TEXTURE_OT_new(wmOperatorType *ot)
ot->exec = new_texture_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************** new world operator *********************/
static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene= CTX_data_scene(C);
- World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data;
+ Scene *scene = CTX_data_scene(C);
+ World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
PointerRNA ptr, idptr;
PropertyRNA *prop;
/* add or copy world */
if (wo) {
- wo= copy_world(wo);
+ wo = copy_world(wo);
}
else {
- wo= add_world("World");
+ wo = add_world("World");
if (scene_use_new_shading_nodes(scene)) {
ED_node_shader_default(scene, &wo->id);
- wo->use_nodes= 1;
+ wo->use_nodes = 1;
}
}
@@ -495,7 +496,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
RNA_property_update(C, &ptr, prop);
}
- WM_event_add_notifier(C, NC_WORLD|NA_ADDED, wo);
+ WM_event_add_notifier(C, NC_WORLD | NA_ADDED, wo);
return OPERATOR_FINISHED;
}
@@ -511,19 +512,19 @@ void WORLD_OT_new(wmOperatorType *ot)
ot->exec = new_world_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************** render layer operators *********************/
static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
scene_add_render_layer(scene, NULL);
- scene->r.actlay= BLI_countlist(&scene->r.layers) - 1;
+ scene->r.actlay = BLI_countlist(&scene->r.layers) - 1;
- WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
return OPERATOR_FINISHED;
}
@@ -539,7 +540,7 @@ void SCENE_OT_render_layer_add(wmOperatorType *ot)
ot->exec = render_layer_add_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
@@ -550,7 +551,7 @@ static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
if (!scene_remove_render_layer(CTX_data_main(C), scene, rl))
return OPERATOR_CANCELLED;
- WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
return OPERATOR_FINISHED;
}
@@ -566,63 +567,63 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot)
ot->exec = render_layer_remove_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int texture_slot_move(bContext *C, wmOperator *op)
{
- ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+ ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
if (id) {
MTex **mtex_ar, *mtexswap;
short act;
- int type= RNA_enum_get(op->ptr, "type");
- struct AnimData *adt= BKE_animdata_from_id(id);
+ int type = RNA_enum_get(op->ptr, "type");
+ struct AnimData *adt = BKE_animdata_from_id(id);
give_active_mtex(id, &mtex_ar, &act);
if (type == -1) { /* Up */
if (act > 0) {
mtexswap = mtex_ar[act];
- mtex_ar[act] = mtex_ar[act-1];
- mtex_ar[act-1] = mtexswap;
+ mtex_ar[act] = mtex_ar[act - 1];
+ mtex_ar[act - 1] = mtexswap;
- BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act-1, -1, 0);
- BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act, act-1, 0);
+ BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act - 1, -1, 0);
+ BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act, act - 1, 0);
BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, -1, act, 0);
- if (GS(id->name)==ID_MA) {
- Material *ma= (Material *)id;
- int mtexuse = ma->septex & (1<<act);
- ma->septex &= ~(1<<act);
- ma->septex |= (ma->septex & (1<<(act-1))) << 1;
- ma->septex &= ~(1<<(act-1));
+ if (GS(id->name) == ID_MA) {
+ Material *ma = (Material *)id;
+ int mtexuse = ma->septex & (1 << act);
+ ma->septex &= ~(1 << act);
+ ma->septex |= (ma->septex & (1 << (act - 1))) << 1;
+ ma->septex &= ~(1 << (act - 1));
ma->septex |= mtexuse >> 1;
}
- set_active_mtex(id, act-1);
+ set_active_mtex(id, act - 1);
}
}
else { /* Down */
- if (act < MAX_MTEX-1) {
+ if (act < MAX_MTEX - 1) {
mtexswap = mtex_ar[act];
- mtex_ar[act] = mtex_ar[act+1];
- mtex_ar[act+1] = mtexswap;
+ mtex_ar[act] = mtex_ar[act + 1];
+ mtex_ar[act + 1] = mtexswap;
- BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act+1, -1, 0);
- BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act, act+1, 0);
+ BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act + 1, -1, 0);
+ BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act, act + 1, 0);
BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, -1, act, 0);
- if (GS(id->name)==ID_MA) {
- Material *ma= (Material *)id;
- int mtexuse = ma->septex & (1<<act);
- ma->septex &= ~(1<<act);
- ma->septex |= (ma->septex & (1<<(act+1))) >> 1;
- ma->septex &= ~(1<<(act+1));
+ if (GS(id->name) == ID_MA) {
+ Material *ma = (Material *)id;
+ int mtexuse = ma->septex & (1 << act);
+ ma->septex &= ~(1 << act);
+ ma->septex |= (ma->septex & (1 << (act + 1))) >> 1;
+ ma->septex &= ~(1 << (act + 1));
ma->septex |= mtexuse << 1;
}
- set_active_mtex(id, act+1);
+ set_active_mtex(id, act + 1);
}
}
@@ -650,7 +651,7 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot)
ot->exec = texture_slot_move;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
}
@@ -662,8 +663,8 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot)
static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, const char imtype)
{
float layout[12];
- if ( RNA_struct_find_property(op->ptr, "layout") )
- RNA_float_get_array(op->ptr, "layout",layout);
+ if (RNA_struct_find_property(op->ptr, "layout") )
+ RNA_float_get_array(op->ptr, "layout", layout);
else
memcpy(layout, default_envmap_layout, sizeof(layout));
@@ -678,7 +679,7 @@ static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, co
static int envmap_save_exec(bContext *C, wmOperator *op)
{
- Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+ Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
Scene *scene = CTX_data_scene(C);
//int imtype = RNA_enum_get(op->ptr, "file_type");
char imtype = scene->r.im_format.imtype;
@@ -717,13 +718,13 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event
static int envmap_save_poll(bContext *C)
{
- Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+ Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
if (!tex)
return 0;
if (!tex->env || !tex->env->ok)
return 0;
- if (tex->env->cube[1]==NULL)
+ if (tex->env->cube[1] == NULL)
return 0;
return 1;
@@ -746,32 +747,32 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER; /* no undo since this doesnt modify the env-map */
/* properties */
- prop= RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] (use -1 to skip a face)", 0.0f, 0.0f);
+ prop = RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] (use -1 to skip a face)", 0.0f, 0.0f);
RNA_def_property_flag(prop, PROP_HIDDEN);
- WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
+ WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
}
static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
- Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+ Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
BKE_free_envmapdata(tex->env);
- WM_event_add_notifier(C, NC_TEXTURE|NA_EDITED, tex);
+ WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
return OPERATOR_FINISHED;
}
static int envmap_clear_poll(bContext *C)
{
- Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
+ Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data;
if (!tex)
return 0;
if (!tex->env || !tex->env->ok)
return 0;
- if (tex->env->cube[1]==NULL)
+ if (tex->env->cube[1] == NULL)
return 0;
return 1;
@@ -789,7 +790,7 @@ void TEXTURE_OT_envmap_clear(wmOperatorType *ot)
ot->poll = envmap_clear_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int envmap_clear_all_exec(bContext *C, wmOperator *UNUSED(op))
@@ -797,11 +798,11 @@ static int envmap_clear_all_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
Tex *tex;
- for (tex=bmain->tex.first; tex; tex=tex->id.next)
+ for (tex = bmain->tex.first; tex; tex = tex->id.next)
if (tex->env)
BKE_free_envmapdata(tex->env);
- WM_event_add_notifier(C, NC_TEXTURE|NA_EDITED, tex);
+ WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
return OPERATOR_FINISHED;
}
@@ -818,7 +819,7 @@ void TEXTURE_OT_envmap_clear_all(wmOperatorType *ot)
ot->poll = envmap_clear_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************** material operators *********************/
@@ -826,9 +827,9 @@ void TEXTURE_OT_envmap_clear_all(wmOperatorType *ot)
/* material copy/paste */
static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
{
- Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+ Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
- if (ma==NULL)
+ if (ma == NULL)
return OPERATOR_CANCELLED;
copy_matcopybuf(ma);
@@ -852,14 +853,14 @@ void MATERIAL_OT_copy(wmOperatorType *ot)
static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
{
- Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+ Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
- if (ma==NULL)
+ if (ma == NULL)
return OPERATOR_CANCELLED;
paste_matcopybuf(ma);
- WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, ma);
+ WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_DRAW, ma);
return OPERATOR_FINISHED;
}
@@ -875,69 +876,69 @@ void MATERIAL_OT_paste(wmOperatorType *ot)
ot->exec = paste_material_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static short mtexcopied=0; /* must be reset on file load */
+static short mtexcopied = 0; /* must be reset on file load */
static MTex mtexcopybuf;
void ED_render_clear_mtex_copybuf(void)
-{ /* use for file reload */
- mtexcopied= 0;
+{ /* use for file reload */
+ mtexcopied = 0;
}
static void copy_mtex_copybuf(ID *id)
{
- MTex **mtex= NULL;
+ MTex **mtex = NULL;
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_MA:
- mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
+ mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
break;
case ID_LA:
- mtex= &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
+ mtex = &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
// la->mtex[(int)la->texact] // TODO
break;
case ID_WO:
- mtex= &(((World *)id)->mtex[(int)((World *)id)->texact]);
+ mtex = &(((World *)id)->mtex[(int)((World *)id)->texact]);
// mtex= wrld->mtex[(int)wrld->texact]; // TODO
break;
case ID_PA:
- mtex= &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
+ mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
break;
}
if (mtex && *mtex) {
memcpy(&mtexcopybuf, *mtex, sizeof(MTex));
- mtexcopied= 1;
+ mtexcopied = 1;
}
else {
- mtexcopied= 0;
+ mtexcopied = 0;
}
}
static void paste_mtex_copybuf(ID *id)
{
- MTex **mtex= NULL;
+ MTex **mtex = NULL;
- if (mtexcopied == 0 || mtexcopybuf.tex==NULL)
+ if (mtexcopied == 0 || mtexcopybuf.tex == NULL)
return;
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_MA:
- mtex= &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
+ mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]);
break;
case ID_LA:
- mtex= &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
+ mtex = &(((Lamp *)id)->mtex[(int)((Lamp *)id)->texact]);
// la->mtex[(int)la->texact] // TODO
break;
case ID_WO:
- mtex= &(((World *)id)->mtex[(int)((World *)id)->texact]);
+ mtex = &(((World *)id)->mtex[(int)((World *)id)->texact]);
// mtex= wrld->mtex[(int)wrld->texact]; // TODO
break;
case ID_PA:
- mtex= &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
+ mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
break;
default:
BLI_assert("invalid id type");
@@ -945,8 +946,8 @@ static void paste_mtex_copybuf(ID *id)
}
if (mtex) {
- if (*mtex==NULL) {
- *mtex= MEM_mallocN(sizeof(MTex), "mtex copy");
+ if (*mtex == NULL) {
+ *mtex = MEM_mallocN(sizeof(MTex), "mtex copy");
}
else if ((*mtex)->tex) {
(*mtex)->tex->id.us--;
@@ -961,9 +962,9 @@ static void paste_mtex_copybuf(ID *id)
static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op))
{
- ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+ ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
- if (id==NULL) {
+ if (id == NULL) {
/* copying empty slot */
ED_render_clear_mtex_copybuf();
return OPERATOR_CANCELLED;
@@ -976,7 +977,7 @@ static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op))
static int copy_mtex_poll(bContext *C)
{
- ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+ ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
return (id != NULL);
}
@@ -998,13 +999,13 @@ void TEXTURE_OT_slot_copy(wmOperatorType *ot)
static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
{
- ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
+ ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data;
- if (id==NULL) {
- Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
- Lamp *la= CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data;
- World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data;
- ParticleSystem *psys= CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
+ if (id == NULL) {
+ Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
+ Lamp *la = CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data;
+ World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
+ ParticleSystem *psys = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
if (ma)
id = &ma->id;
@@ -1015,13 +1016,13 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
else if (psys)
id = &psys->part->id;
- if (id==NULL)
+ if (id == NULL)
return OPERATOR_CANCELLED;
}
paste_mtex_copybuf(id);
- WM_event_add_notifier(C, NC_TEXTURE|ND_SHADING_DRAW, NULL);
+ WM_event_add_notifier(C, NC_TEXTURE | ND_SHADING_DRAW, NULL);
return OPERATOR_FINISHED;
}
@@ -1037,6 +1038,6 @@ void TEXTURE_OT_slot_paste(wmOperatorType *ot)
ot->exec = paste_mtex_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 72b29c56811..b56a295864b 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -62,7 +62,7 @@
#include "ED_node.h"
#include "ED_render.h"
-#include "render_intern.h" // own include
+#include "render_intern.h" // own include
/***************************** Render Engines ********************************/
@@ -80,26 +80,26 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated)
if (!BLI_thread_is_main())
return;
- C= CTX_create();
+ C = CTX_create();
CTX_data_main_set(C, bmain);
CTX_data_scene_set(C, scene);
CTX_wm_manager_set(C, bmain->wm.first);
- for (sc=bmain->screen.first; sc; sc=sc->id.next) {
- for (sa=sc->areabase.first; sa; sa=sa->next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
if (sa->spacetype != SPACE_VIEW3D)
continue;
- for (ar=sa->regionbase.first; ar; ar=ar->next) {
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
RegionView3D *rv3d;
RenderEngine *engine;
if (ar->regiontype != RGN_TYPE_WINDOW)
continue;
- rv3d= ar->regiondata;
- engine= rv3d->render_engine;
+ rv3d = ar->regiondata;
+ engine = rv3d->render_engine;
if (engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) {
CTX_wm_screen_set(C, sc);
@@ -123,22 +123,22 @@ void ED_render_engine_changed(Main *bmain)
ScrArea *sa;
ARegion *ar;
- for (sc=bmain->screen.first; sc; sc=sc->id.next) {
- for (sa=sc->areabase.first; sa; sa=sa->next) {
+ for (sc = bmain->screen.first; sc; sc = sc->id.next) {
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
if (sa->spacetype != SPACE_VIEW3D)
continue;
- for (ar=sa->regionbase.first; ar; ar=ar->next) {
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
RegionView3D *rv3d;
if (ar->regiontype != RGN_TYPE_WINDOW)
continue;
- rv3d= ar->regiondata;
+ rv3d = ar->regiondata;
if (rv3d->render_engine) {
RE_engine_free(rv3d->render_engine);
- rv3d->render_engine= NULL;
+ rv3d->render_engine = NULL;
}
}
}
@@ -146,9 +146,9 @@ void ED_render_engine_changed(Main *bmain)
}
/***************************** Updates ***********************************
- * ED_render_id_flush_update gets called from DAG_id_tag_update, to do *
- * editor level updates when the ID changes. when these ID blocks are in *
- * the dependency graph, we can get rid of the manual dependency checks */
+* ED_render_id_flush_update gets called from DAG_id_tag_update, to do *
+* editor level updates when the ID changes. when these ID blocks are in *
+* the dependency graph, we can get rid of the manual dependency checks */
static int mtex_use_tex(MTex **mtex, int tot, Tex *tex)
{
@@ -157,7 +157,7 @@ static int mtex_use_tex(MTex **mtex, int tot, Tex *tex)
if (!mtex)
return 0;
- for (a=0; a<tot; a++)
+ for (a = 0; a < tot; a++)
if (mtex[a] && mtex[a]->tex == tex)
return 1;
@@ -168,16 +168,16 @@ static int nodes_use_tex(bNodeTree *ntree, Tex *tex)
{
bNode *node;
- for (node=ntree->nodes.first; node; node= node->next) {
+ for (node = ntree->nodes.first; node; node = node->next) {
if (node->id) {
- if (node->id == (ID*)tex) {
+ if (node->id == (ID *)tex) {
return 1;
}
else if (GS(node->id->name) == ID_MA) {
- if (mtex_use_tex(((Material*)node->id)->mtex, MAX_MTEX, tex))
+ if (mtex_use_tex(((Material *)node->id)->mtex, MAX_MTEX, tex))
return 1;
}
- else if (node->type==NODE_GROUP) {
+ else if (node->type == NODE_GROUP) {
if (nodes_use_tex((bNodeTree *)node->id, tex))
return 1;
}
@@ -191,12 +191,12 @@ static int nodes_use_material(bNodeTree *ntree, Material *ma)
{
bNode *node;
- for (node=ntree->nodes.first; node; node= node->next) {
+ for (node = ntree->nodes.first; node; node = node->next) {
if (node->id) {
- if (node->id == (ID*)ma) {
+ if (node->id == (ID *)ma) {
return 1;
}
- else if (node->type==NODE_GROUP) {
+ else if (node->type == NODE_GROUP) {
if (nodes_use_material((bNodeTree *)node->id, ma))
return 1;
}
@@ -218,8 +218,8 @@ static void material_changed(Main *bmain, Material *ma)
GPU_material_free(ma);
/* find node materials using this */
- for (parent=bmain->mat.first; parent; parent=parent->id.next) {
- if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma));
+ for (parent = bmain->mat.first; parent; parent = parent->id.next) {
+ if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) ;
else continue;
BKE_icon_changed(BKE_icon_getid(&parent->id));
@@ -241,9 +241,9 @@ static void texture_changed(Main *bmain, Tex *tex)
BKE_icon_changed(BKE_icon_getid(&tex->id));
/* find materials */
- for (ma=bmain->mat.first; ma; ma=ma->id.next) {
- if (mtex_use_tex(ma->mtex, MAX_MTEX, tex));
- else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex));
+ for (ma = bmain->mat.first; ma; ma = ma->id.next) {
+ if (mtex_use_tex(ma->mtex, MAX_MTEX, tex)) ;
+ else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)) ;
else continue;
BKE_icon_changed(BKE_icon_getid(&ma->id));
@@ -253,27 +253,27 @@ static void texture_changed(Main *bmain, Tex *tex)
}
/* find lamps */
- for (la=bmain->lamp.first; la; la=la->id.next) {
- if (mtex_use_tex(la->mtex, MAX_MTEX, tex));
- else if (la->nodetree && nodes_use_tex(la->nodetree, tex));
+ for (la = bmain->lamp.first; la; la = la->id.next) {
+ if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) ;
+ else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) ;
else continue;
BKE_icon_changed(BKE_icon_getid(&la->id));
}
/* find worlds */
- for (wo=bmain->world.first; wo; wo=wo->id.next) {
- if (mtex_use_tex(wo->mtex, MAX_MTEX, tex));
- else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex));
+ for (wo = bmain->world.first; wo; wo = wo->id.next) {
+ if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)) ;
+ else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)) ;
else continue;
BKE_icon_changed(BKE_icon_getid(&wo->id));
}
/* find compositing nodes */
- for (scene=bmain->scene.first; scene; scene=scene->id.next) {
+ for (scene = bmain->scene.first; scene; scene = scene->id.next) {
if (scene->use_nodes && scene->nodetree) {
- for (node=scene->nodetree->nodes.first; node; node=node->next) {
+ for (node = scene->nodetree->nodes.first; node; node = node->next) {
if (node->id == &tex->id)
ED_node_changed_update(&scene->id, node);
}
@@ -290,11 +290,11 @@ static void lamp_changed(Main *bmain, Lamp *la)
BKE_icon_changed(BKE_icon_getid(&la->id));
/* glsl */
- for (ob=bmain->object.first; ob; ob=ob->id.next)
+ for (ob = bmain->object.first; ob; ob = ob->id.next)
if (ob->data == la && ob->gpulamp.first)
GPU_lamp_free(ob);
- for (ma=bmain->mat.first; ma; ma=ma->id.next)
+ for (ma = bmain->mat.first; ma; ma = ma->id.next)
if (ma->gpumaterial.first)
GPU_material_free(ma);
}
@@ -307,7 +307,7 @@ static void world_changed(Main *bmain, World *wo)
BKE_icon_changed(BKE_icon_getid(&wo->id));
/* glsl */
- for (ma=bmain->mat.first; ma; ma=ma->id.next)
+ for (ma = bmain->mat.first; ma; ma = ma->id.next)
if (ma->gpumaterial.first)
GPU_material_free(ma);
}
@@ -320,7 +320,7 @@ static void image_changed(Main *bmain, Image *ima)
BKE_icon_changed(BKE_icon_getid(&ima->id));
/* textures */
- for (tex=bmain->tex.first; tex; tex=tex->id.next)
+ for (tex = bmain->tex.first; tex; tex = tex->id.next)
if (tex->ima == ima)
texture_changed(bmain, tex);
}
@@ -331,35 +331,35 @@ static void scene_changed(Main *bmain, Scene *UNUSED(scene))
Material *ma;
/* glsl */
- for (ob=bmain->object.first; ob; ob=ob->id.next)
+ for (ob = bmain->object.first; ob; ob = ob->id.next)
if (ob->gpulamp.first)
GPU_lamp_free(ob);
- for (ma=bmain->mat.first; ma; ma=ma->id.next)
+ for (ma = bmain->mat.first; ma; ma = ma->id.next)
if (ma->gpumaterial.first)
GPU_material_free(ma);
}
void ED_render_id_flush_update(Main *bmain, ID *id)
{
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_MA:
- material_changed(bmain, (Material*)id);
+ material_changed(bmain, (Material *)id);
break;
case ID_TE:
- texture_changed(bmain, (Tex*)id);
+ texture_changed(bmain, (Tex *)id);
break;
case ID_WO:
- world_changed(bmain, (World*)id);
+ world_changed(bmain, (World *)id);
break;
case ID_LA:
- lamp_changed(bmain, (Lamp*)id);
+ lamp_changed(bmain, (Lamp *)id);
break;
case ID_IM:
- image_changed(bmain, (Image*)id);
+ image_changed(bmain, (Image *)id);
break;
case ID_SCE:
- scene_changed(bmain, (Scene*)id);
+ scene_changed(bmain, (Scene *)id);
break;
default:
break;
diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c
index 31b53fcabe1..0d902722183 100644
--- a/source/blender/editors/render/render_view.c
+++ b/source/blender/editors/render/render_view.c
@@ -61,24 +61,24 @@
/* would use BKE_screen_find_big_area(...) but this is too specific */
static ScrArea *biggest_non_image_area(bContext *C)
{
- bScreen *sc= CTX_wm_screen(C);
- ScrArea *sa, *big= NULL;
- int size, maxsize= 0, bwmaxsize= 0;
- short foundwin= 0;
+ bScreen *sc = CTX_wm_screen(C);
+ ScrArea *sa, *big = NULL;
+ int size, maxsize = 0, bwmaxsize = 0;
+ short foundwin = 0;
- for (sa= sc->areabase.first; sa; sa= sa->next) {
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
if (sa->winx > 30 && sa->winy > 30) {
- size= sa->winx*sa->winy;
+ size = sa->winx * sa->winy;
if (sa->spacetype == SPACE_BUTS) {
if (foundwin == 0 && size > bwmaxsize) {
- bwmaxsize= size;
- big= sa;
+ bwmaxsize = size;
+ big = sa;
}
}
else if (sa->spacetype != SPACE_IMAGE && size > maxsize) {
- maxsize= size;
- big= sa;
- foundwin= 1;
+ maxsize = size;
+ big = sa;
+ foundwin = 1;
}
}
}
@@ -88,16 +88,16 @@ static ScrArea *biggest_non_image_area(bContext *C)
static ScrArea *find_area_showing_r_result(bContext *C, wmWindow **win)
{
- wmWindowManager *wm= CTX_wm_manager(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *sa = NULL;
SpaceImage *sima;
/* find an imagewindow showing render result */
- for (*win=wm->windows.first; *win; *win= (*win)->next) {
- for (sa= (*win)->screen->areabase.first; sa; sa= sa->next) {
- if (sa->spacetype==SPACE_IMAGE) {
- sima= sa->spacedata.first;
- if (sima->image && sima->image->type==IMA_TYPE_R_RESULT)
+ for (*win = wm->windows.first; *win; *win = (*win)->next) {
+ for (sa = (*win)->screen->areabase.first; sa; sa = sa->next) {
+ if (sa->spacetype == SPACE_IMAGE) {
+ sima = sa->spacedata.first;
+ if (sima->image && sima->image->type == IMA_TYPE_R_RESULT)
break;
}
}
@@ -110,14 +110,14 @@ static ScrArea *find_area_showing_r_result(bContext *C, wmWindow **win)
static ScrArea *find_area_image_empty(bContext *C)
{
- bScreen *sc= CTX_wm_screen(C);
+ bScreen *sc = CTX_wm_screen(C);
ScrArea *sa;
SpaceImage *sima;
/* find an imagewindow showing render result */
- for (sa=sc->areabase.first; sa; sa= sa->next) {
- if (sa->spacetype==SPACE_IMAGE) {
- sima= sa->spacedata.first;
+ for (sa = sc->areabase.first; sa; sa = sa->next) {
+ if (sa->spacetype == SPACE_IMAGE) {
+ sima = sa->spacedata.first;
if (!sima->image)
break;
}
@@ -131,70 +131,70 @@ static ScrArea *find_area_image_empty(bContext *C)
/* new window uses x,y to set position */
void render_view_open(bContext *C, int mx, int my)
{
- wmWindow *win= CTX_wm_window(C);
- Scene *scene= CTX_data_scene(C);
- ScrArea *sa= NULL;
+ wmWindow *win = CTX_wm_window(C);
+ Scene *scene = CTX_data_scene(C);
+ ScrArea *sa = NULL;
SpaceImage *sima;
- int area_was_image=0;
+ int area_was_image = 0;
- if (scene->r.displaymode==R_OUTPUT_NONE)
+ if (scene->r.displaymode == R_OUTPUT_NONE)
return;
- if (scene->r.displaymode==R_OUTPUT_WINDOW) {
+ if (scene->r.displaymode == R_OUTPUT_WINDOW) {
rcti rect;
int sizex, sizey;
- sizex= 10 + (scene->r.xsch*scene->r.size)/100;
- sizey= 40 + (scene->r.ysch*scene->r.size)/100;
+ sizex = 10 + (scene->r.xsch * scene->r.size) / 100;
+ sizey = 40 + (scene->r.ysch * scene->r.size) / 100;
/* arbitrary... miniature image window views don't make much sense */
- if (sizex < 320) sizex= 320;
- if (sizey < 256) sizey= 256;
+ if (sizex < 320) sizex = 320;
+ if (sizey < 256) sizey = 256;
/* XXX some magic to calculate postition */
- rect.xmin = mx + win->posx - sizex/2;
- rect.ymin = my + win->posy - sizey/2;
+ rect.xmin = mx + win->posx - sizex / 2;
+ rect.ymin = my + win->posy - sizey / 2;
rect.xmax = rect.xmin + sizex;
rect.ymax = rect.ymin + sizey;
/* changes context! */
WM_window_open_temp(C, &rect, WM_WINDOW_RENDER);
- sa= CTX_wm_area(C);
+ sa = CTX_wm_area(C);
}
- else if (scene->r.displaymode==R_OUTPUT_SCREEN) {
+ else if (scene->r.displaymode == R_OUTPUT_SCREEN) {
if (CTX_wm_area(C) && CTX_wm_area(C)->spacetype == SPACE_IMAGE)
area_was_image = 1;
/* this function returns with changed context */
- sa= ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
+ sa = ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE);
}
if (!sa) {
- sa= find_area_showing_r_result(C, &win);
- if (sa==NULL)
- sa= find_area_image_empty(C);
+ sa = find_area_showing_r_result(C, &win);
+ if (sa == NULL)
+ sa = find_area_image_empty(C);
/* if area found in other window, we make that one show in front */
- if (win && win!=CTX_wm_window(C))
+ if (win && win != CTX_wm_window(C))
wm_window_raise(win);
- if (sa==NULL) {
+ if (sa == NULL) {
/* find largest open non-image area */
- sa= biggest_non_image_area(C);
+ sa = biggest_non_image_area(C);
if (sa) {
ED_area_newspace(C, sa, SPACE_IMAGE);
- sima= sa->spacedata.first;
+ sima = sa->spacedata.first;
/* makes ESC go back to prev space */
sima->flag |= SI_PREVSPACE;
}
else {
/* use any area of decent size */
- sa= BKE_screen_find_big_area(CTX_wm_screen(C), -1, 0);
- if (sa->spacetype!=SPACE_IMAGE) {
+ sa = BKE_screen_find_big_area(CTX_wm_screen(C), -1, 0);
+ if (sa->spacetype != SPACE_IMAGE) {
// XXX newspace(sa, SPACE_IMAGE);
- sima= sa->spacedata.first;
+ sima = sa->spacedata.first;
/* makes ESC go back to prev space */
sima->flag |= SI_PREVSPACE;
@@ -202,10 +202,10 @@ void render_view_open(bContext *C, int mx, int my)
}
}
}
- sima= sa->spacedata.first;
+ sima = sa->spacedata.first;
/* get the correct image, and scale it */
- sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+ sima->image = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
/* if we're rendering to full screen, set appropriate hints on image editor
@@ -229,9 +229,9 @@ void render_view_open(bContext *C, int mx, int my)
static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op))
{
- wmWindow *win= CTX_wm_window(C);
- ScrArea *sa= CTX_wm_area(C);
- SpaceImage *sima= sa->spacedata.first;
+ wmWindow *win = CTX_wm_window(C);
+ ScrArea *sa = CTX_wm_area(C);
+ SpaceImage *sima = sa->spacedata.first;
/* test if we have a temp screen in front */
if (CTX_wm_window(C)->screen->temp) {
@@ -284,11 +284,11 @@ static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent
}
else {
wmWindow *win, *winshow;
- ScrArea *sa= find_area_showing_r_result(C, &winshow);
+ ScrArea *sa = find_area_showing_r_result(C, &winshow);
/* is there another window showing result? */
- for (win= CTX_wm_manager(C)->windows.first; win; win= win->next) {
- if (win->screen->temp || (win==winshow && winshow!=wincur)) {
+ for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) {
+ if (win->screen->temp || (win == winshow && winshow != wincur)) {
wm_window_raise(win);
return OPERATOR_FINISHED;
}
@@ -298,7 +298,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent
if (sa) {
/* but don't close it when rendering */
if (!G.rendering) {
- SpaceImage *sima= sa->spacedata.first;
+ SpaceImage *sima = sa->spacedata.first;
if (sima->flag & SI_PREVSPACE) {
sima->flag &= ~SI_PREVSPACE;