Cleanup: clang tidy

Use c++ headers; use nullptr; redundant `void` in parameter list;
inconsistent parameter name.
This commit is contained in:
Jacques Lucke 2021-12-27 18:18:37 +01:00
parent 1c9d8fcb47
commit 11ac276caa
Notes: blender-bot 2023-02-14 03:59:42 +01:00
Referenced by commit 53ed7ec7f2, Cleanup: clang-tidy
11 changed files with 314 additions and 293 deletions

View File

@ -276,7 +276,7 @@ static GPUShader *get_subdiv_shader(int shader_type, const char *defines)
/** Vertex formats used for data transfer from OpenSubdiv, and for data processing on our side.
* \{ */
static GPUVertFormat *get_uvs_format(void)
static GPUVertFormat *get_uvs_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
@ -286,7 +286,7 @@ static GPUVertFormat *get_uvs_format(void)
}
/* Vertex format for `OpenSubdiv::Osd::PatchArray`. */
static GPUVertFormat *get_patch_array_format(void)
static GPUVertFormat *get_patch_array_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
@ -301,7 +301,7 @@ static GPUVertFormat *get_patch_array_format(void)
}
/* Vertex format used for the `PatchTable::PatchHandle`. */
static GPUVertFormat *get_patch_handle_format(void)
static GPUVertFormat *get_patch_handle_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
@ -313,7 +313,7 @@ static GPUVertFormat *get_patch_handle_format(void)
}
/* Vertex format used for the quad-tree nodes of the PatchMap. */
static GPUVertFormat *get_quadtree_format(void)
static GPUVertFormat *get_quadtree_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
@ -324,7 +324,7 @@ static GPUVertFormat *get_quadtree_format(void)
/* Vertex format for `OpenSubdiv::Osd::PatchParam`, not really used, it is only for making sure
* that the #GPUVertBuf used to wrap the OpenSubdiv patch param buffer is valid. */
static GPUVertFormat *get_patch_param_format(void)
static GPUVertFormat *get_patch_param_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
@ -334,7 +334,7 @@ static GPUVertFormat *get_patch_param_format(void)
}
/* Vertex format for the patches' vertices index buffer. */
static GPUVertFormat *get_patch_index_format(void)
static GPUVertFormat *get_patch_index_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
@ -344,7 +344,7 @@ static GPUVertFormat *get_patch_index_format(void)
}
/* Vertex format for the OpenSubdiv vertex buffer. */
static GPUVertFormat *get_subdiv_vertex_format(void)
static GPUVertFormat *get_subdiv_vertex_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
@ -355,11 +355,11 @@ static GPUVertFormat *get_subdiv_vertex_format(void)
return &format;
}
typedef struct CompressedPatchCoord {
struct CompressedPatchCoord {
int ptex_face_index;
/* UV coordinate encoded as u << 16 | v, where u and v are quantized on 16-bits. */
unsigned int encoded_uv;
} CompressedPatchCoord;
};
MINLINE CompressedPatchCoord make_patch_coord(int ptex_face_index, float u, float v)
{
@ -371,7 +371,7 @@ MINLINE CompressedPatchCoord make_patch_coord(int ptex_face_index, float u, floa
}
/* Vertex format used for the #CompressedPatchCoord. */
static GPUVertFormat *get_blender_patch_coords_format(void)
static GPUVertFormat *get_blender_patch_coords_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
@ -382,7 +382,7 @@ static GPUVertFormat *get_blender_patch_coords_format(void)
return &format;
}
static GPUVertFormat *get_origindex_format(void)
static GPUVertFormat *get_origindex_format()
{
static GPUVertFormat format;
if (format.attr_len == 0) {
@ -677,7 +677,7 @@ static DRWSubdivCache *mesh_batch_cache_ensure_subdiv_cache(MeshBatchCache *mbc)
* reevaluations, as long as the topology does not change.
* \{ */
typedef struct DRWCacheBuildingContext {
struct DRWCacheBuildingContext {
const Mesh *coarse_mesh;
const SubdivToMeshSettings *settings;
@ -700,7 +700,7 @@ typedef struct DRWCacheBuildingContext {
* the shaders. */
int *v_origindex;
int *e_origindex;
} DRWCacheBuildingContext;
};
static bool draw_subdiv_topology_info_cb(const SubdivForeachContext *foreach_context,
const int num_vertices,
@ -1037,7 +1037,7 @@ static bool draw_subdiv_build_cache(DRWSubdivCache *cache,
* Common uniforms for the various shaders.
* \{ */
typedef struct DRWSubdivUboStorage {
struct DRWSubdivUboStorage {
/* Offsets in the buffers data where the source and destination data start. */
int src_offset;
int dst_offset;
@ -1073,7 +1073,7 @@ typedef struct DRWSubdivUboStorage {
* final vertex count, depending on which compute pass we do). This is used to early out in case
* of out of bond accesses as compute dispatch are of fixed size. */
uint total_dispatch_size;
} DRWSubdivUboStorage;
};
static_assert((sizeof(DRWSubdivUboStorage) % 16) == 0,
"DRWSubdivUboStorage is not padded to a multiple of the size of vec4");

View File

@ -182,7 +182,7 @@ void draw_subdiv_extract_pos_nor(const DRWSubdivCache *cache,
void draw_subdiv_interp_custom_data(const DRWSubdivCache *cache,
struct GPUVertBuf *src_data,
struct GPUVertBuf *dst_buffer,
struct GPUVertBuf *dst_data,
int dimensions,
int dst_offset);

View File

@ -109,7 +109,7 @@ static void mesh_render_data_vert_flag(const MeshRenderData *mr,
}
}
static GPUVertFormat *get_edit_data_format(void)
static GPUVertFormat *get_edit_data_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {

View File

@ -71,7 +71,7 @@ static void init_vcol_format(GPUVertFormat *format,
/* Vertex format for vertex colors, only used during the coarse data upload for the subdivision
* case. */
static GPUVertFormat *get_coarse_vcol_format(void)
static GPUVertFormat *get_coarse_vcol_format()
{
static GPUVertFormat format = {0};
if (format.attr_len == 0) {

View File

@ -21,9 +21,9 @@
* \ingroup edrend
*/
#include <math.h>
#include <stddef.h>
#include <string.h>
#include <cmath>
#include <cstddef>
#include <cstring>
#include "MEM_guardedalloc.h"
@ -83,7 +83,7 @@
/* Render Callbacks */
static int render_break(void *rjv);
typedef struct RenderJob {
struct RenderJob {
Main *main;
Scene *scene;
ViewLayer *single_layer;
@ -110,7 +110,7 @@ typedef struct RenderJob {
ColorManagedDisplaySettings display_settings;
bool supports_glsl_draw;
bool interface_locked;
} RenderJob;
};
/* called inside thread! */
static bool image_buffer_calc_tile_rect(const RenderResult *rr,
@ -122,11 +122,11 @@ static bool image_buffer_calc_tile_rect(const RenderResult *rr,
{
int tile_y, tile_height, tile_x, tile_width;
/* When `renrect` argument is not NULL, we only refresh scan-lines. */
/* When `renrect` argument is not nullptr, we only refresh scan-lines. */
if (renrect) {
/* if (tile_height == recty), rendering of layer is ready,
* we should not draw, other things happen... */
if (rr->renlay == NULL || renrect->ymax >= rr->recty) {
if (rr->renlay == nullptr || renrect->ymax >= rr->recty) {
return false;
}
@ -190,7 +190,7 @@ static void image_buffer_rect_update(RenderJob *rj,
const char *viewname)
{
Scene *scene = rj->scene;
const float *rectf = NULL;
const float *rectf = nullptr;
int linear_stride, linear_offset_x, linear_offset_y;
ColorManagedViewSettings *view_settings;
ColorManagedDisplaySettings *display_settings;
@ -231,12 +231,12 @@ static void image_buffer_rect_update(RenderJob *rj,
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
return;
}
if (rr->renlay == NULL) {
if (rr->renlay == nullptr) {
return;
}
rectf = RE_RenderLayerGetPass(rr->renlay, RE_PASSNAME_COMBINED, viewname);
}
if (rectf == NULL) {
if (rectf == nullptr) {
return;
}
@ -257,7 +257,7 @@ static void image_buffer_rect_update(RenderJob *rj,
IMB_partial_display_buffer_update(ibuf,
rectf,
NULL,
nullptr,
linear_stride,
linear_offset_x,
linear_offset_y,
@ -316,17 +316,17 @@ static int screen_render_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
RenderEngineType *re_type = RE_engines_find(scene->r.engine);
ViewLayer *active_layer = CTX_data_view_layer(C);
ViewLayer *single_layer = NULL;
ViewLayer *single_layer = nullptr;
Render *re;
Image *ima;
View3D *v3d = CTX_wm_view3d(C);
Main *mainp = CTX_data_main(C);
const bool is_animation = RNA_boolean_get(op->ptr, "animation");
const bool is_write_still = RNA_boolean_get(op->ptr, "write_still");
struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : nullptr;
/* Cannot do render if there is not this function. */
if (re_type->render == NULL) {
if (re_type->render == nullptr) {
return OPERATOR_CANCELLED;
}
@ -343,11 +343,11 @@ static int screen_render_exec(bContext *C, wmOperator *op)
G.is_break = false;
RE_draw_lock_cb(re, NULL, NULL);
RE_test_break_cb(re, NULL, render_break);
RE_draw_lock_cb(re, nullptr, nullptr);
RE_test_break_cb(re, nullptr, render_break);
ima = BKE_image_ensure_viewer(mainp, IMA_TYPE_R_RESULT, "Render Result");
BKE_image_signal(mainp, ima, NULL, IMA_SIGNAL_FREE);
BKE_image_signal(mainp, ima, nullptr, IMA_SIGNAL_FREE);
BKE_image_backup_render(scene, ima, true);
/* cleanup sequencer caches before starting user triggered render.
@ -372,7 +372,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
RE_RenderFrame(re, mainp, scene, single_layer, camera_override, scene->r.cfra, is_write_still);
}
RE_SetReports(re, NULL);
RE_SetReports(re, nullptr);
/* No redraw needed, we leave state as we entered it. */
ED_update_for_newframe(mainp, CTX_data_depsgraph_pointer(C));
@ -479,7 +479,7 @@ static void image_renderinfo_cb(void *rjv, RenderStats *rs)
if (rr) {
/* malloc OK here, stats_draw is not in tile threads */
if (rr->text == NULL) {
if (rr->text == nullptr) {
rr->text = static_cast<char *>(MEM_callocN(IMA_MAX_RENDER_TEXT, "rendertext"));
}
@ -512,13 +512,13 @@ static void render_progress_update(void *rjv, float progress)
static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr, ImageUser *iuser)
{
wmWindowManager *wm;
ScrArea *first_area = NULL, *matched_area = NULL;
ScrArea *first_area = nullptr, *matched_area = nullptr;
/* image window, compo node users */
for (wm = static_cast<wmWindowManager *>(rj->main->wm.first); wm && matched_area == NULL;
for (wm = static_cast<wmWindowManager *>(rj->main->wm.first); wm && matched_area == nullptr;
wm = static_cast<wmWindowManager *>(wm->id.next)) { /* only 1 wm */
wmWindow *win;
for (win = static_cast<wmWindow *>(wm->windows.first); win && matched_area == NULL;
for (win = static_cast<wmWindow *>(wm->windows.first); win && matched_area == nullptr;
win = win->next) {
const bScreen *screen = WM_window_get_active_screen(win);
@ -526,8 +526,8 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr,
if (area->spacetype == SPACE_IMAGE) {
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
/* area->spacedata might be empty when toggling full-screen mode. */
if (sima != NULL && sima->image == rj->image) {
if (first_area == NULL) {
if (sima != nullptr && sima->image == rj->image) {
if (first_area == nullptr) {
first_area = area;
}
if (area == rj->area) {
@ -540,7 +540,7 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr,
}
}
if (matched_area == NULL) {
if (matched_area == nullptr) {
matched_area = first_area;
}
@ -587,7 +587,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
return;
}
if (rr == NULL) {
if (rr == nullptr) {
return;
}
@ -660,7 +660,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
rj->write_still);
}
RE_SetReports(rj->re, NULL);
RE_SetReports(rj->re, nullptr);
}
static void render_image_restore_layer(RenderJob *rj)
@ -730,7 +730,7 @@ static void render_endjob(void *rjv)
if (rj->single_layer) {
BKE_ntree_update_tag_id_changed(rj->main, &rj->scene->id);
BKE_ntree_update_main(rj->main, NULL);
BKE_ntree_update_main(rj->main, nullptr);
WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene);
}
@ -740,7 +740,7 @@ static void render_endjob(void *rjv)
/* XXX render stability hack */
G.is_rendering = false;
WM_main_add_notifier(NC_SCENE | ND_RENDER_RESULT, NULL);
WM_main_add_notifier(NC_SCENE | ND_RENDER_RESULT, nullptr);
/* Partial render result will always update display buffer
* for first render layer only. This is nice because you'll
@ -897,7 +897,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *active_layer = CTX_data_view_layer(C);
ViewLayer *single_layer = NULL;
ViewLayer *single_layer = nullptr;
RenderEngineType *re_type = RE_engines_find(scene->r.engine);
Render *re;
wmJob *wm_job;
@ -906,13 +906,13 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
const bool is_animation = RNA_boolean_get(op->ptr, "animation");
const bool is_write_still = RNA_boolean_get(op->ptr, "write_still");
const bool use_viewport = RNA_boolean_get(op->ptr, "use_viewport");
View3D *v3d = use_viewport ? CTX_wm_view3d(C) : NULL;
struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;
View3D *v3d = use_viewport ? CTX_wm_view3d(C) : nullptr;
struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : nullptr;
const char *name;
ScrArea *area;
/* Cannot do render if there is not this function. */
if (re_type->render == NULL) {
if (re_type->render == nullptr) {
return OPERATOR_CANCELLED;
}
@ -1036,7 +1036,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
WM_JOB_TYPE_RENDER);
WM_jobs_customdata_set(wm_job, rj, render_freejob);
WM_jobs_timer(wm_job, 0.2, NC_SCENE | ND_RENDER_RESULT, 0);
WM_jobs_callbacks(wm_job, render_startjob, NULL, NULL, render_endjob);
WM_jobs_callbacks(wm_job, render_startjob, nullptr, nullptr, render_endjob);
if (RNA_struct_property_is_set(op->ptr, "layer")) {
WM_jobs_delay_start(wm_job, 0.2);
@ -1044,7 +1044,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
/* get a render result image, and make sure it is empty */
ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_R_RESULT, "Render Result");
BKE_image_signal(rj->main, ima, NULL, IMA_SIGNAL_FREE);
BKE_image_signal(rj->main, ima, nullptr, IMA_SIGNAL_FREE);
BKE_image_backup_render(rj->scene, ima, true);
rj->image = ima;
@ -1104,32 +1104,32 @@ void RENDER_OT_render(wmOperatorType *ot)
prop = RNA_def_boolean(ot->srna,
"animation",
0,
false,
"Animation",
"Render files from the animation range of this scene");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
RNA_def_boolean(
ot->srna,
"write_still",
0,
false,
"Write Image",
"Save rendered the image to the output path (used only when animation is disabled)");
prop = RNA_def_boolean(ot->srna,
"use_viewport",
0,
false,
"Use 3D Viewport",
"When inside a 3D viewport, use layers and camera of the viewport");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_string(ot->srna,
"layer",
NULL,
nullptr,
RE_MAXNAME,
"Render Layer",
"Single render layer to re-render (used only when animation is disabled)");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_string(ot->srna,
"scene",
NULL,
nullptr,
MAX_ID_NAME - 2,
"Scene",
"Scene to render, current scene if not specified");
@ -1145,7 +1145,7 @@ Scene *ED_render_job_get_scene(const bContext *C)
return rj->scene;
}
return NULL;
return nullptr;
}
Scene *ED_render_job_get_current_scene(const bContext *C)
@ -1155,7 +1155,7 @@ Scene *ED_render_job_get_current_scene(const bContext *C)
if (rj) {
return rj->current_scene;
}
return NULL;
return nullptr;
}
/* Motion blur curve preset */
@ -1186,7 +1186,7 @@ void RENDER_OT_shutter_curve_preset(wmOperatorType *ot)
{CURVE_PRESET_LINE, "LINE", 0, "Line", ""},
{CURVE_PRESET_ROUND, "ROUND", 0, "Round", ""},
{CURVE_PRESET_ROOT, "ROOT", 0, "Root", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
ot->name = "Shutter Curve Preset";

View File

@ -21,9 +21,9 @@
* \ingroup render
*/
#include <math.h>
#include <stddef.h>
#include <string.h>
#include <cmath>
#include <cstddef>
#include <cstring>
#include "MEM_guardedalloc.h"
@ -95,7 +95,7 @@
* For really highres renders it might fail still. */
#define MAX_SCHEDULED_FRAMES 8
typedef struct OGLRender {
struct OGLRender {
Main *bmain;
Render *re;
Scene *scene;
@ -159,7 +159,7 @@ typedef struct OGLRender {
#ifdef DEBUG_TIME
double time_start;
#endif
} OGLRender;
};
static bool screen_opengl_is_multiview(OGLRender *oglrender)
{
@ -167,12 +167,12 @@ static bool screen_opengl_is_multiview(OGLRender *oglrender)
RegionView3D *rv3d = oglrender->rv3d;
RenderData *rd = &oglrender->scene->r;
if ((rd == NULL) || ((v3d != NULL) && (rv3d == NULL))) {
if ((rd == nullptr) || ((v3d != nullptr) && (rv3d == nullptr))) {
return false;
}
return (rd->scemode & R_MULTIVIEW) &&
((v3d == NULL) || (rv3d->persp == RV3D_CAMOB && v3d->camera));
((v3d == nullptr) || (rv3d->persp == RV3D_CAMOB && v3d->camera));
}
static void screen_opengl_views_setup(OGLRender *oglrender)
@ -194,7 +194,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
/* we only have one view when multiview is off */
rv = static_cast<RenderView *>(rr->views.first);
if (rv == NULL) {
if (rv == nullptr) {
rv = MEM_cnew<RenderView>("new opengl render view");
BLI_addtail(&rr->views, rv);
}
@ -262,7 +262,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
rv = static_cast<RenderView *>(
BLI_findstring(&rr->views, srv->name, offsetof(SceneRenderView, name)));
if (rv == NULL) {
if (rv == nullptr) {
rv = MEM_cnew<RenderView>("new opengl render view");
BLI_strncpy(rv->name, srv->name, sizeof(rv->name));
BLI_addtail(&rr->views, rv);
@ -293,19 +293,19 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
ARegion *region = oglrender->region;
View3D *v3d = oglrender->v3d;
RegionView3D *rv3d = oglrender->rv3d;
Object *camera = NULL;
Object *camera = nullptr;
int sizex = oglrender->sizex;
int sizey = oglrender->sizey;
const short view_context = (v3d != NULL);
const short view_context = (v3d != nullptr);
bool draw_sky = (scene->r.alphamode == R_ADDSKY);
float *rectf = NULL;
uchar *rect = NULL;
float *rectf = nullptr;
uchar *rect = nullptr;
const char *viewname = RE_GetActiveRenderView(oglrender->re);
ImBuf *ibuf_result = NULL;
ImBuf *ibuf_result = nullptr;
if (oglrender->is_sequencer) {
SpaceSeq *sseq = oglrender->sseq;
struct bGPdata *gpd = (sseq && (sseq->flag & SEQ_PREVIEW_SHOW_GPENCIL)) ? sseq->gpd : NULL;
struct bGPdata *gpd = (sseq && (sseq->flag & SEQ_PREVIEW_SHOW_GPENCIL)) ? sseq->gpd : nullptr;
/* use pre-calculated ImBuf (avoids deadlock), see: */
ImBuf *ibuf = oglrender->seq_data.ibufs_arr[oglrender->view_id];
@ -320,7 +320,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
* TODO(sergey): In the case of output to float container (EXR)
* it actually makes sense to keep float buffer instead.
*/
if (out->rect_float != NULL) {
if (out->rect_float != nullptr) {
IMB_rect_from_float(out);
imb_freerectfloatImBuf(out);
}
@ -395,7 +395,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
else {
ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene,
NULL,
nullptr,
OB_SOLID,
scene->camera,
oglrender->sizex,
@ -423,9 +423,9 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
}
}
if (ibuf_result != NULL) {
if (ibuf_result != nullptr) {
if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW)) {
BKE_image_stamp_buf(scene, camera, NULL, rect, rectf, rr->rectx, rr->recty, 4);
BKE_image_stamp_buf(scene, camera, nullptr, rect, rectf, rr->rectx, rr->recty, 4);
}
RE_render_result_rect_from_ibuf(rr, &scene->r, ibuf_result, oglrender->view_id);
IMB_freeImBuf(ibuf_result);
@ -448,7 +448,7 @@ static void screen_opengl_render_write(OGLRender *oglrender)
&scene->r.im_format,
(scene->r.scemode & R_EXTENSION) != 0,
false,
NULL);
nullptr);
/* write images as individual images or stereo */
BKE_render_result_stamp_info(scene, scene->camera, rr, false);
@ -534,7 +534,7 @@ static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
static void gather_frames_to_render_for_adt(const OGLRender *oglrender, const AnimData *adt)
{
if (adt == NULL || adt->action == NULL) {
if (adt == nullptr || adt->action == nullptr) {
return;
}
@ -543,7 +543,7 @@ static void gather_frames_to_render_for_adt(const OGLRender *oglrender, const An
int frame_end = PEFRA;
LISTBASE_FOREACH (FCurve *, fcu, &adt->action->curves) {
if (fcu->driver != NULL || fcu->fpt != NULL) {
if (fcu->driver != nullptr || fcu->fpt != nullptr) {
/* Drivers have values for any point in time, so to get "the keyed frames" they are
* useless. Same for baked FCurves, they also have keys for every frame, which is not
* useful for rendering the keyed subset of the frames. */
@ -572,7 +572,7 @@ static void gather_frames_to_render_for_adt(const OGLRender *oglrender, const An
static void gather_frames_to_render_for_grease_pencil(const OGLRender *oglrender,
const bGPdata *gp)
{
if (gp == NULL) {
if (gp == nullptr) {
return;
}
@ -593,7 +593,7 @@ static void gather_frames_to_render_for_grease_pencil(const OGLRender *oglrender
static int gather_frames_to_render_for_id(LibraryIDLinkCallbackData *cb_data)
{
ID **id_p = cb_data->id_pointer;
if (*id_p == NULL) {
if (*id_p == nullptr) {
return IDWALK_RET_NOP;
}
ID *id = *id_p;
@ -703,7 +703,7 @@ static void gather_frames_to_render(bContext *C, OGLRender *oglrender)
/* Gather the frames from linked data-blocks (materials, shape-keys, etc.). */
BKE_library_foreach_ID_link(
NULL, id, gather_frames_to_render_for_id, oglrender, IDWALK_RECURSE);
nullptr, id, gather_frames_to_render_for_id, oglrender, IDWALK_RECURSE);
}
CTX_DATA_END;
}
@ -751,7 +751,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
is_view_context = false;
}
if (!is_view_context && scene->camera == NULL) {
if (!is_view_context && scene->camera == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Scene has no camera");
return false;
}
@ -837,13 +837,14 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
/* create image and image user */
oglrender->ima = BKE_image_ensure_viewer(oglrender->bmain, IMA_TYPE_R_RESULT, "Render Result");
BKE_image_signal(oglrender->bmain, oglrender->ima, NULL, IMA_SIGNAL_FREE);
BKE_image_signal(oglrender->bmain, oglrender->ima, nullptr, IMA_SIGNAL_FREE);
BKE_image_backup_render(oglrender->scene, oglrender->ima, true);
oglrender->iuser.scene = scene;
/* create render result */
RE_InitState(oglrender->re, NULL, &scene->r, &scene->view_layers, NULL, sizex, sizey, NULL);
RE_InitState(
oglrender->re, nullptr, &scene->r, &scene->view_layers, nullptr, sizex, sizey, nullptr);
/* create render views */
screen_opengl_views_setup(oglrender);
@ -853,8 +854,8 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
oglrender->win = win;
oglrender->totvideos = 0;
oglrender->mh = NULL;
oglrender->movie_ctx_arr = NULL;
oglrender->mh = nullptr;
oglrender->movie_ctx_arr = nullptr;
if (is_animation) {
if (is_render_keyed_only) {
@ -871,7 +872,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
BLI_spin_init(&oglrender->reports_lock);
}
else {
oglrender->task_pool = NULL;
oglrender->task_pool = nullptr;
}
oglrender->num_scheduled_frames = 0;
BLI_mutex_init(&oglrender->task_mutex);
@ -988,7 +989,7 @@ static bool screen_opengl_render_anim_init(bContext *C, wmOperator *op)
&scene->r, oglrender->sizex, oglrender->sizey, &width, &height);
oglrender->mh = BKE_movie_handle_get(scene->r.im_format.imtype);
if (oglrender->mh == NULL) {
if (oglrender->mh == nullptr) {
BKE_report(oglrender->reports, RPT_ERROR, "Movie format unsupported");
screen_opengl_render_end(C, oglrender);
return false;
@ -1023,10 +1024,10 @@ static bool screen_opengl_render_anim_init(bContext *C, wmOperator *op)
return true;
}
typedef struct WriteTaskData {
struct WriteTaskData {
RenderResult *rr;
Scene tmp_scene;
} WriteTaskData;
};
static void write_result_func(TaskPool *__restrict pool, void *task_data_v)
{
@ -1079,17 +1080,17 @@ static void write_result_func(TaskPool *__restrict pool, void *task_data_v)
&scene->r.im_format,
(scene->r.scemode & R_EXTENSION) != 0,
true,
NULL);
nullptr);
BKE_render_result_stamp_info(scene, scene->camera, rr, false);
ok = RE_WriteRenderViewsImage(NULL, rr, scene, true, name);
ok = RE_WriteRenderViewsImage(nullptr, rr, scene, true, name);
if (!ok) {
BKE_reportf(&reports, RPT_ERROR, "Write error: cannot save %s", name);
}
}
if (reports.list.first != NULL) {
if (reports.list.first != nullptr) {
BLI_spin_lock(&oglrender->reports_lock);
for (Report *report = static_cast<Report *>(reports.list.first); report != NULL;
for (Report *report = static_cast<Report *>(reports.list.first); report != nullptr;
report = report->next) {
BKE_report(oglrender->reports, static_cast<eReportType>(report->type), report->message);
}
@ -1121,7 +1122,7 @@ static bool schedule_write_result(OGLRender *oglrender, RenderResult *rr)
BLI_condition_wait(&oglrender->task_condition, &oglrender->task_mutex);
}
BLI_mutex_unlock(&oglrender->task_mutex);
BLI_task_pool_push(oglrender->task_pool, write_result_func, task_data, true, NULL);
BLI_task_pool_push(oglrender->task_pool, write_result_func, task_data, true, nullptr);
return true;
}
@ -1132,7 +1133,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
Depsgraph *depsgraph = oglrender->depsgraph;
char name[FILE_MAX];
bool ok = false;
const bool view_context = (oglrender->v3d != NULL);
const bool view_context = (oglrender->v3d != nullptr);
bool is_movie;
RenderResult *rr;
@ -1155,7 +1156,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
&scene->r.im_format,
(scene->r.scemode & R_EXTENSION) != 0,
true,
NULL);
nullptr);
if ((scene->r.mode & R_NO_OVERWRITE) && BLI_exists(name)) {
BLI_spin_lock(&oglrender->reports_lock);
@ -1184,7 +1185,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
BKE_scene_camera_switch_update(scene);
}
if (oglrender->render_frames == NULL ||
if (oglrender->render_frames == nullptr ||
BLI_BITMAP_TEST_BOOL(oglrender->render_frames, CFRA - PSFRA)) {
/* render into offscreen buffer */
screen_opengl_render_apply(C, oglrender);
@ -1207,10 +1208,10 @@ finally: /* Step the frame and bail early if needed */
/* stop at the end or on error */
if (CFRA >= PEFRA || !ok) {
screen_opengl_render_end(C, static_cast<OGLRender *>(op->customdata));
return 0;
return false;
}
return 1;
return true;
}
static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent *event)
@ -1321,7 +1322,7 @@ static char *screen_opengl_render_description(struct bContext *UNUSED(C),
struct PointerRNA *ptr)
{
if (!RNA_boolean_get(ptr, "animation")) {
return NULL;
return nullptr;
}
if (RNA_boolean_get(ptr, "render_keyed_only")) {
@ -1353,32 +1354,32 @@ void RENDER_OT_opengl(wmOperatorType *ot)
prop = RNA_def_boolean(ot->srna,
"animation",
0,
false,
"Animation",
"Render files from the animation range of this scene");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna,
"render_keyed_only",
0,
false,
"Render Keyframes Only",
"Render only those frames where selected objects have a key in their "
"animation data. Only used when rendering animation");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(
ot->srna, "sequencer", 0, "Sequencer", "Render using the sequencer's OpenGL display");
ot->srna, "sequencer", false, "Sequencer", "Render using the sequencer's OpenGL display");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(
ot->srna,
"write_still",
0,
false,
"Write Image",
"Save rendered the image to the output path (used only when animation is disabled)");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(ot->srna,
"view_context",
1,
true,
"View Context",
"Use the current 3D view for rendering, else use scene settings");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);

View File

@ -23,9 +23,9 @@
/* global includes */
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <cstdlib>
#include <cstring>
#ifndef WIN32
# include <unistd.h>
@ -116,7 +116,7 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect);
/** \name Local Structs
* \{ */
typedef struct ShaderPreview {
struct ShaderPreview {
/* from wmJob */
void *owner;
short *stop, *do_update;
@ -142,26 +142,27 @@ typedef struct ShaderPreview {
Main *bmain;
Main *pr_main;
} ShaderPreview;
};
typedef struct IconPreviewSize {
struct IconPreviewSize {
struct IconPreviewSize *next, *prev;
int sizex, sizey;
uint *rect;
} IconPreviewSize;
};
typedef struct IconPreview {
struct IconPreview {
Main *bmain;
Depsgraph *depsgraph; /* May be NULL (see #WM_OT_previews_ensure). */
Depsgraph *depsgraph; /* May be nullptr (see #WM_OT_previews_ensure). */
Scene *scene;
void *owner;
ID *id, *id_copy; /* May be NULL! (see ICON_TYPE_PREVIEW case in #ui_icon_ensure_deferred()) */
ID *id,
*id_copy; /* May be nullptr! (see ICON_TYPE_PREVIEW case in #ui_icon_ensure_deferred()) */
ListBase sizes;
/* May be NULL, is used for rendering IDs that require some other object for it to be applied on
* before the ID can be represented as an image, for example when rendering an Action. */
/* May be nullptr, is used for rendering IDs that require some other object for it to be applied
* on before the ID can be represented as an image, for example when rendering an Action. */
struct Object *active_object;
} IconPreview;
};
/** \} */
@ -169,18 +170,18 @@ typedef struct IconPreview {
/** \name Preview for Buttons
* \{ */
static Main *G_pr_main = NULL;
static Main *G_pr_main_grease_pencil = NULL;
static Main *G_pr_main = nullptr;
static Main *G_pr_main_grease_pencil = nullptr;
#ifndef WITH_HEADLESS
static Main *load_main_from_memory(const void *blend, int blend_size)
{
const int fileflags = G.fileflags;
Main *bmain = NULL;
Main *bmain = nullptr;
BlendFileData *bfd;
G.fileflags |= G_FILE_NO_UI;
bfd = BLO_read_from_memory(blend, blend_size, BLO_READ_SKIP_NONE, NULL);
bfd = BLO_read_from_memory(blend, blend_size, BLO_READ_SKIP_NONE, nullptr);
if (bfd) {
bmain = bfd->main;
@ -230,8 +231,8 @@ void ED_preview_free_dbase(void)
static Scene *preview_get_scene(Main *pr_main)
{
if (pr_main == NULL) {
return NULL;
if (pr_main == nullptr) {
return nullptr;
}
return static_cast<Scene *>(pr_main->scenes.first);
@ -350,16 +351,16 @@ static void set_preview_visibility(Main *pr_main,
static World *preview_get_localized_world(ShaderPreview *sp, World *world)
{
if (world == NULL) {
return NULL;
if (world == nullptr) {
return nullptr;
}
if (sp->worldcopy != NULL) {
if (sp->worldcopy != nullptr) {
return sp->worldcopy;
}
ID *id_copy = BKE_id_copy_ex(NULL,
ID *id_copy = BKE_id_copy_ex(nullptr,
&world->id,
NULL,
nullptr,
LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE |
LIB_ID_COPY_NO_ANIMDATA);
sp->worldcopy = (World *)id_copy;
@ -369,9 +370,9 @@ static World *preview_get_localized_world(ShaderPreview *sp, World *world)
static ID *duplicate_ids(ID *id, const bool allow_failure)
{
if (id == NULL) {
if (id == nullptr) {
/* Non-ID preview render. */
return NULL;
return nullptr;
}
switch (GS(id->name)) {
@ -381,20 +382,23 @@ static ID *duplicate_ids(ID *id, const bool allow_failure)
case ID_LA:
case ID_WO: {
BLI_assert(BKE_previewimg_id_supports_jobs(id));
ID *id_copy = BKE_id_copy_ex(
NULL, id, NULL, LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_NO_ANIMDATA);
ID *id_copy = BKE_id_copy_ex(nullptr,
id,
nullptr,
LIB_ID_CREATE_LOCAL | LIB_ID_COPY_LOCALIZE |
LIB_ID_COPY_NO_ANIMDATA);
return id_copy;
}
/* These support threading, but don't need duplicating. */
case ID_IM:
case ID_BR:
BLI_assert(BKE_previewimg_id_supports_jobs(id));
return NULL;
return nullptr;
default:
if (!allow_failure) {
BLI_assert_msg(0, "ID type preview not supported.");
}
return NULL;
return nullptr;
}
}
@ -421,13 +425,13 @@ static World *preview_get_world(Main *pr_main,
const ID_Type id_type,
const ePreviewRenderMethod pr_method)
{
World *result = NULL;
World *result = nullptr;
const char *world_name = preview_world_name(sce, id_type, pr_method);
result = static_cast<World *>(
BLI_findstring(&pr_main->worlds, world_name, offsetof(ID, name) + 2));
/* No world found return first world. */
if (result == NULL) {
if (result == nullptr) {
result = static_cast<World *>(pr_main->worlds.first);
}
@ -457,7 +461,7 @@ static World *preview_prepare_world(Main *pr_main,
}
/* call this with a pointer to initialize preview scene */
/* call this with NULL to restore assigned ID pointers in preview scene */
/* call this with nullptr to restore assigned ID pointers in preview scene */
static Scene *preview_prepare_scene(
Main *bmain, Scene *scene, ID *id, int id_type, ShaderPreview *sp)
{
@ -503,13 +507,13 @@ static Scene *preview_prepare_scene(
}
if (id_type == ID_MA) {
Material *mat = NULL, *origmat = (Material *)id;
Material *mat = nullptr, *origmat = (Material *)id;
if (origmat) {
/* work on a copy */
BLI_assert(sp->id_copy != NULL);
BLI_assert(sp->id_copy != nullptr);
mat = sp->matcopy = (Material *)sp->id_copy;
sp->id_copy = NULL;
sp->id_copy = nullptr;
BLI_addtail(&pr_main->materials, mat);
/* Use current scene world for lighting. */
@ -559,23 +563,23 @@ static Scene *preview_prepare_scene(
}
}
else if (id_type == ID_TE) {
Tex *tex = NULL, *origtex = (Tex *)id;
Tex *tex = nullptr, *origtex = (Tex *)id;
if (origtex) {
BLI_assert(sp->id_copy != NULL);
BLI_assert(sp->id_copy != nullptr);
tex = sp->texcopy = (Tex *)sp->id_copy;
sp->id_copy = NULL;
sp->id_copy = nullptr;
BLI_addtail(&pr_main->textures, tex);
}
}
else if (id_type == ID_LA) {
Light *la = NULL, *origla = (Light *)id;
Light *la = nullptr, *origla = (Light *)id;
/* work on a copy */
if (origla) {
BLI_assert(sp->id_copy != NULL);
BLI_assert(sp->id_copy != nullptr);
la = sp->lampcopy = (Light *)sp->id_copy;
sp->id_copy = NULL;
sp->id_copy = nullptr;
BLI_addtail(&pr_main->lights, la);
}
@ -598,12 +602,12 @@ static Scene *preview_prepare_scene(
}
}
else if (id_type == ID_WO) {
World *wrld = NULL, *origwrld = (World *)id;
World *wrld = nullptr, *origwrld = (World *)id;
if (origwrld) {
BLI_assert(sp->id_copy != NULL);
BLI_assert(sp->id_copy != nullptr);
wrld = sp->worldcopy = (World *)sp->id_copy;
sp->id_copy = NULL;
sp->id_copy = nullptr;
BLI_addtail(&pr_main->worlds, wrld);
}
@ -614,7 +618,7 @@ static Scene *preview_prepare_scene(
return sce;
}
return NULL;
return nullptr;
}
/* new UI convention: draw is in pixel space already. */
@ -651,7 +655,7 @@ static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect
/* test if something rendered ok */
re = RE_GetRender(name);
if (re == NULL) {
if (re == nullptr) {
return false;
}
@ -663,7 +667,7 @@ static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect
}
else {
/* possible the job clears the views but we're still drawing T45496 */
rv = NULL;
rv = nullptr;
}
if (rv && rv->rectf) {
@ -683,12 +687,21 @@ static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect
RE_AcquiredResultGet32(re, &rres, (uint *)rect_byte, 0);
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTex(
&state, fx, fy, rres.rectx, rres.recty, GPU_RGBA8, false, rect_byte, 1.0f, 1.0f, NULL);
immDrawPixelsTex(&state,
fx,
fy,
rres.rectx,
rres.recty,
GPU_RGBA8,
false,
rect_byte,
1.0f,
1.0f,
nullptr);
MEM_freeN(rect_byte);
ok = 1;
ok = true;
}
}
}
@ -733,10 +746,10 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
/* start a new preview render job if signaled through sbuts->preview,
* if no render result was found and no preview render job is running,
* or if the job is running and the size of preview changed */
if ((sbuts != NULL && sbuts->preview) ||
if ((sbuts != nullptr && sbuts->preview) ||
(!ok && !WM_jobs_test(wm, area, WM_JOB_TYPE_RENDER_PREVIEW)) ||
(sp && (abs(sp->sizex - newx) >= 2 || abs(sp->sizey - newy) > 2))) {
if (sbuts != NULL) {
if (sbuts != nullptr) {
sbuts->preview = 0;
}
ED_preview_shader_job(C, area, id, parent, slot, newx, newy, PR_BUTS_RENDER);
@ -804,7 +817,7 @@ static Scene *object_preview_scene_create(const struct ObjectPreviewData *previe
Depsgraph *depsgraph = DEG_graph_new(
preview_data->pr_main, scene, view_layer, DAG_EVAL_VIEWPORT);
BLI_assert(preview_data->object != NULL);
BLI_assert(preview_data->object != nullptr);
BLI_addtail(&preview_data->pr_main->objects, preview_data->object);
BKE_collection_object_add(preview_data->pr_main, scene->master_collection, preview_data->object);
@ -852,7 +865,7 @@ static void object_preview_render(IconPreview *preview, IconPreviewSize *preview
Scene *scene = object_preview_scene_create(&preview_data, &depsgraph);
/* Ownership is now ours. */
preview->id_copy = NULL;
preview->id_copy = nullptr;
U.pixelsize = 2.0f;
@ -872,8 +885,8 @@ static void object_preview_render(IconPreview *preview, IconPreviewSize *preview
IB_rect,
V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS,
R_ALPHAPREMUL,
NULL,
NULL,
nullptr,
nullptr,
err_out);
/* TODO: color-management? */
@ -897,15 +910,15 @@ static void object_preview_render(IconPreview *preview, IconPreviewSize *preview
static struct PoseBackup *action_preview_render_prepare(IconPreview *preview)
{
Object *object = preview->active_object;
if (object == NULL) {
if (object == nullptr) {
WM_report(RPT_WARNING, "No active object, unable to apply the Action before rendering");
return NULL;
return nullptr;
}
if (object->pose == NULL) {
if (object->pose == nullptr) {
WM_reportf(RPT_WARNING,
"Object %s has no pose, unable to apply the Action before rendering",
object->id.name + 2);
return NULL;
return nullptr;
}
/* Create a backup of the current pose. */
@ -926,7 +939,7 @@ static struct PoseBackup *action_preview_render_prepare(IconPreview *preview)
static void action_preview_render_cleanup(IconPreview *preview, struct PoseBackup *pose_backup)
{
if (pose_backup == NULL) {
if (pose_backup == nullptr) {
return;
}
ED_pose_backup_restore(pose_backup);
@ -946,7 +959,7 @@ static void action_preview_render(IconPreview *preview, IconPreviewSize *preview
/* Not all code paths that lead to this function actually provide a depsgraph.
* The "Refresh Asset Preview" button (ED_OT_lib_id_generate_preview) does,
* but WM_OT_previews_ensure does not. */
BLI_assert(depsgraph != NULL);
BLI_assert(depsgraph != nullptr);
BLI_assert(preview->scene == DEG_get_input_scene(depsgraph));
/* Apply the pose before getting the evaluated scene, so that the new pose is evaluated. */
@ -954,7 +967,7 @@ static void action_preview_render(IconPreview *preview, IconPreviewSize *preview
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *camera_eval = scene_eval->camera;
if (camera_eval == NULL) {
if (camera_eval == nullptr) {
printf("Scene has no camera, unable to render preview of %s without it.\n",
preview->id->name + 2);
return;
@ -963,7 +976,7 @@ static void action_preview_render(IconPreview *preview, IconPreviewSize *preview
/* This renders with the Workbench engine settings stored on the Scene. */
ImBuf *ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene_eval,
NULL,
nullptr,
OB_SOLID,
camera_eval,
preview_sized->sizex,
@ -971,8 +984,8 @@ static void action_preview_render(IconPreview *preview, IconPreviewSize *preview
IB_rect,
V3D_OFSDRAW_NONE,
R_ADDSKY,
NULL,
NULL,
nullptr,
nullptr,
err_out);
action_preview_render_cleanup(preview, pose_backup);
@ -1024,7 +1037,7 @@ static void shader_preview_texture(ShaderPreview *sp, Tex *tex, Scene *sce, Rend
/* This is needed otherwise no RenderResult is created. */
sce->r.scemode &= ~R_BUTS_PREVIEW;
RE_InitState(re, NULL, &sce->r, &sce->view_layers, NULL, width, height, NULL);
RE_InitState(re, nullptr, &sce->r, &sce->view_layers, nullptr, width, height, nullptr);
RE_SetScene(re, sce);
/* Create buffer in empty RenderView created in the init step. */
@ -1104,7 +1117,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
/* get the stuff from the builtin preview dbase */
sce = preview_prepare_scene(sp->bmain, sp->scene, id, idtype, sp);
if (sce == NULL) {
if (sce == nullptr) {
return;
}
@ -1117,7 +1130,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
re = RE_GetRender(name);
/* full refreshed render from first tile */
if (re == NULL) {
if (re == nullptr) {
re = RE_NewRender(name);
}
@ -1167,7 +1180,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
}
/* unassign the pointers, reset vars */
preview_prepare_scene(sp->bmain, sp->scene, NULL, GS(id->name), sp);
preview_prepare_scene(sp->bmain, sp->scene, nullptr, GS(id->name), sp);
/* XXX bad exception, end-exec is not being called in render, because it uses local main. */
#if 0
@ -1215,15 +1228,15 @@ static void shader_preview_free(void *customdata)
{
ShaderPreview *sp = static_cast<ShaderPreview *>(customdata);
Main *pr_main = sp->pr_main;
ID *main_id_copy = NULL;
ID *sub_id_copy = NULL;
ID *main_id_copy = nullptr;
ID *sub_id_copy = nullptr;
if (sp->matcopy) {
main_id_copy = (ID *)sp->matcopy;
BLI_remlink(&pr_main->materials, sp->matcopy);
}
if (sp->texcopy) {
BLI_assert(main_id_copy == NULL);
BLI_assert(main_id_copy == nullptr);
main_id_copy = (ID *)sp->texcopy;
BLI_remlink(&pr_main->textures, sp->texcopy);
}
@ -1238,7 +1251,7 @@ static void shader_preview_free(void *customdata)
BLI_remlink(&pr_main->worlds, sp->worldcopy);
}
if (sp->lampcopy) {
BLI_assert(main_id_copy == NULL);
BLI_assert(main_id_copy == nullptr);
main_id_copy = (ID *)sp->lampcopy;
BLI_remlink(&pr_main->lights, sp->lampcopy);
}
@ -1280,7 +1293,7 @@ static ImBuf *icon_preview_imbuf_from_brush(Brush *brush)
BLI_path_abs(path, ID_BLEND_PATH_FROM_GLOBAL(&brush->id));
/* Use default color-spaces for brushes. */
brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
brush->icon_imbuf = IMB_loadiffname(path, flags, nullptr);
/* otherwise lets try to find it in other directories */
if (!(brush->icon_imbuf)) {
@ -1291,7 +1304,7 @@ static ImBuf *icon_preview_imbuf_from_brush(Brush *brush)
if (path[0]) {
/* Use default color spaces. */
brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
brush->icon_imbuf = IMB_loadiffname(path, flags, nullptr);
}
}
@ -1317,7 +1330,7 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect)
short ex, ey, dx, dy;
/* paranoia test */
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
if (ibuf == nullptr || (ibuf->rect == nullptr && ibuf->rect_float == nullptr)) {
return;
}
@ -1347,7 +1360,7 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect)
IMB_scalefastImBuf(ima, ex, ey);
/* if needed, convert to 32 bits */
if (ima->rect == NULL) {
if (ima->rect == nullptr) {
IMB_rect_from_float(ima);
}
@ -1400,15 +1413,15 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
ID *id = sp->id;
short idtype = GS(id->name);
BLI_assert(id != NULL);
BLI_assert(id != nullptr);
if (idtype == ID_IM) {
Image *ima = (Image *)id;
ImBuf *ibuf = NULL;
ImBuf *ibuf = nullptr;
ImageUser iuser;
BKE_imageuser_default(&iuser);
if (ima == NULL) {
if (ima == nullptr) {
return;
}
@ -1419,9 +1432,9 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
/* 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_acquire_ibuf(ima, &iuser, NULL);
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
BKE_image_release_ibuf(ima, ibuf, NULL);
ibuf = BKE_image_acquire_ibuf(ima, &iuser, nullptr);
if (ibuf == nullptr || (ibuf->rect == nullptr && ibuf->rect_float == nullptr)) {
BKE_image_release_ibuf(ima, ibuf, nullptr);
return;
}
@ -1429,7 +1442,7 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat
*do_update = true;
BKE_image_release_ibuf(ima, ibuf, NULL);
BKE_image_release_ibuf(ima, ibuf, nullptr);
}
else if (idtype == ID_BR) {
Brush *br = (Brush *)id;
@ -1510,7 +1523,7 @@ static void other_id_types_preview_render(IconPreview *ip,
sp->id_copy = ip->id_copy;
sp->bmain = ip->bmain;
sp->own_id_copy = false;
Material *ma = NULL;
Material *ma = nullptr;
if (sp->pr_method == PR_ICON_RENDER) {
BLI_assert(ip->id);
@ -1520,7 +1533,7 @@ static void other_id_types_preview_render(IconPreview *ip,
ma = (Material *)ip->id;
}
if ((ma == NULL) || (ma->gp_style == NULL)) {
if ((ma == nullptr) || (ma->gp_style == nullptr)) {
sp->pr_main = G_pr_main;
}
else {
@ -1580,7 +1593,7 @@ static void icon_preview_startjob_all_sizes(void *customdata,
* they can skip this test. */
/* TODO: Decouple the ID-type-specific render functions from this function, so that it's not
* necessary to know here what happens inside lower-level functions. */
const bool use_solid_render_mode = (ip->id != NULL) && ELEM(GS(ip->id->name), ID_OB, ID_AC);
const bool use_solid_render_mode = (ip->id != nullptr) && ELEM(GS(ip->id->name), ID_OB, ID_AC);
if (!use_solid_render_mode && preview_method_is_render(pr_method) &&
!check_engine_supports_preview(ip->scene)) {
continue;
@ -1593,7 +1606,7 @@ static void icon_preview_startjob_all_sizes(void *customdata,
}
#endif
if (ip->id != NULL) {
if (ip->id != nullptr) {
switch (GS(ip->id->name)) {
case ID_OB:
if (object_preview_is_type_supported((Object *)ip->id)) {
@ -1606,7 +1619,7 @@ static void icon_preview_startjob_all_sizes(void *customdata,
action_preview_render(ip, cur_size);
continue;
default:
/* Fall through to the same code as the `ip->id == NULL` case. */
/* Fall through to the same code as the `ip->id == nullptr` case. */
break;
}
}
@ -1654,7 +1667,7 @@ static void icon_preview_endjob(void *customdata)
for (i = 0; i < NUM_ICON_SIZES; i++) {
if (prv_img->gputexture[i]) {
GPU_texture_free(prv_img->gputexture[i]);
prv_img->gputexture[i] = NULL;
prv_img->gputexture[i] = nullptr;
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ip->id);
}
}
@ -1692,20 +1705,20 @@ static void icon_preview_free(void *customdata)
bool ED_preview_id_is_supported(const ID *id)
{
if (id == NULL) {
if (id == nullptr) {
return false;
}
if (GS(id->name) == ID_OB) {
return object_preview_is_type_supported((const Object *)id);
}
return BKE_previewimg_id_get_p(id) != NULL;
return BKE_previewimg_id_get_p(id) != nullptr;
}
void ED_preview_icon_render(
const bContext *C, Scene *scene, ID *id, uint *rect, int sizex, int sizey)
{
IconPreview ip = {NULL};
IconPreview ip = {nullptr};
short stop = false, update = false;
float progress = 0.0f;
@ -1728,7 +1741,7 @@ void ED_preview_icon_render(
icon_preview_endjob(&ip);
BLI_freelistN(&ip.sizes);
if (ip.id_copy != NULL) {
if (ip.id_copy != nullptr) {
preview_id_copy_free(ip.id_copy);
}
}
@ -1784,7 +1797,8 @@ void ED_preview_icon_job(
* Particularly important for heavy scenes and Eevee using OpenGL that blocks
* the user interface drawing. */
WM_jobs_delay_start(wm_job, (delay) ? 2.0 : 0.0);
WM_jobs_callbacks(wm_job, icon_preview_startjob_all_sizes, NULL, NULL, icon_preview_endjob);
WM_jobs_callbacks(
wm_job, icon_preview_startjob_all_sizes, nullptr, nullptr, icon_preview_endjob);
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
@ -1835,7 +1849,7 @@ void ED_preview_shader_job(const bContext *C,
sp->parent = parent;
sp->slot = slot;
sp->bmain = CTX_data_main(C);
Material *ma = NULL;
Material *ma = nullptr;
/* hardcoded preview .blend for Eevee + Cycles, this should be solved
* once with custom preview .blend path for external engines */
@ -1845,7 +1859,7 @@ void ED_preview_shader_job(const bContext *C,
ma = (Material *)id;
}
if ((ma == NULL) || (ma->gp_style == NULL)) {
if ((ma == nullptr) || (ma->gp_style == nullptr)) {
sp->pr_main = G_pr_main;
}
else {
@ -1862,7 +1876,7 @@ void ED_preview_shader_job(const bContext *C,
/* setup job */
WM_jobs_customdata_set(wm_job, sp, shader_preview_free);
WM_jobs_timer(wm_job, 0.1, NC_MATERIAL, NC_MATERIAL);
WM_jobs_callbacks(wm_job, common_preview_startjob, NULL, shader_preview_updatejob, NULL);
WM_jobs_callbacks(wm_job, common_preview_startjob, nullptr, shader_preview_updatejob, nullptr);
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
@ -1872,17 +1886,17 @@ void ED_preview_kill_jobs(wmWindowManager *wm, Main *UNUSED(bmain))
if (wm) {
/* This is called to stop all preview jobs before scene data changes, to
* avoid invalid memory access. */
WM_jobs_kill(wm, NULL, common_preview_startjob);
WM_jobs_kill(wm, NULL, icon_preview_startjob_all_sizes);
WM_jobs_kill(wm, nullptr, common_preview_startjob);
WM_jobs_kill(wm, nullptr, icon_preview_startjob_all_sizes);
}
}
typedef struct PreviewRestartQueueEntry {
struct PreviewRestartQueueEntry {
struct PreviewRestartQueueEntry *next, *prev;
enum eIconSizes size;
ID *id;
} PreviewRestartQueueEntry;
};
static ListBase /* #PreviewRestartQueueEntry */ G_restart_previews_queue;
@ -1912,7 +1926,7 @@ void ED_preview_restart_queue_work(const bContext *C)
}
BKE_previewimg_clear_single(preview, queue_entry->size);
UI_icon_render_id(C, NULL, queue_entry->id, queue_entry->size, true);
UI_icon_render_id(C, nullptr, queue_entry->id, queue_entry->size, true);
BLI_freelinkN(&G_restart_previews_queue, queue_entry);
}

View File

@ -20,8 +20,8 @@
* \ingroup edrend
*/
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
@ -188,8 +188,8 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
ED_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
ED_paint_proj_mesh_data_check(scene, ob, nullptr, nullptr, nullptr, nullptr);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, nullptr);
}
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
@ -238,8 +238,8 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op)
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
ED_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
ED_paint_proj_mesh_data_check(scene, ob, nullptr, nullptr, nullptr, nullptr);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, nullptr);
}
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@ -277,7 +277,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
bool changed_multi = false;
Object *obact = CTX_data_active_object(C);
const Material *mat_active = obact ? BKE_object_material_get(obact, obact->actcol) : NULL;
const Material *mat_active = obact ? BKE_object_material_get(obact, obact->actcol) : nullptr;
uint objects_len = 0;
Object **objects = object_array_for_shading_edit_mode_enabled(C, &objects_len);
@ -384,7 +384,7 @@ static int material_slot_de_select(bContext *C, bool select)
{
bool changed_multi = false;
Object *obact = CTX_data_active_object(C);
const Material *mat_active = obact ? BKE_object_material_get(obact, obact->actcol) : NULL;
const Material *mat_active = obact ? BKE_object_material_get(obact, obact->actcol) : nullptr;
uint objects_len = 0;
Object **objects = object_array_for_shading_edit_mode_enabled(C, &objects_len);
@ -644,7 +644,7 @@ void OBJECT_OT_material_slot_move(wmOperatorType *ot)
static const EnumPropertyItem material_slot_move[] = {
{1, "UP", 0, "Up", ""},
{-1, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@ -716,8 +716,8 @@ static int material_slot_remove_unused_exec(bContext *C, wmOperator *op)
if (ob_active->mode & OB_MODE_TEXTURE_PAINT) {
Scene *scene = CTX_data_scene(C);
ED_paint_proj_mesh_data_check(scene, ob_active, NULL, NULL, NULL, NULL);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
ED_paint_proj_mesh_data_check(scene, ob_active, nullptr, nullptr, nullptr, nullptr);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, nullptr);
}
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_active);
@ -760,17 +760,17 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
Object *ob = static_cast<Object *>((prop && RNA_struct_is_a(ptr.type, &RNA_Object)) ? ptr.data :
NULL);
nullptr);
/* add or copy material */
if (ma) {
Material *new_ma = (Material *)BKE_id_copy_ex(
bmain, &ma->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
bmain, &ma->id, nullptr, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
ma = new_ma;
}
else {
const char *name = DATA_("Material");
if (!(ob != NULL && ob->type == OB_GPENCIL)) {
if (!(ob != nullptr && ob->type == OB_GPENCIL)) {
ma = BKE_material_add(bmain, name);
}
else {
@ -781,10 +781,10 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
}
if (prop) {
if (ob != NULL) {
if (ob != nullptr) {
/* Add slot follows user-preferences for creating new slots,
* RNA pointer assignment doesn't, see: T60014. */
if (BKE_object_material_get_p(ob, ob->actcol) == NULL) {
if (BKE_object_material_get_p(ob, ob->actcol) == nullptr) {
BKE_object_material_slot_add(bmain, ob);
}
}
@ -794,7 +794,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
id_us_min(&ma->id);
RNA_id_pointer_create(&ma->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
RNA_property_update(C, &ptr, prop);
}
@ -848,7 +848,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
id_us_min(&tex->id);
RNA_id_pointer_create(&tex->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
RNA_property_update(C, &ptr, prop);
}
@ -887,7 +887,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
/* add or copy world */
if (wo) {
World *new_wo = (World *)BKE_id_copy_ex(
bmain, &wo->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
bmain, &wo->id, nullptr, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS);
wo = new_wo;
}
else {
@ -905,7 +905,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
id_us_min(&wo->id);
RNA_id_pointer_create(&wo->id, &idptr);
RNA_property_pointer_set(&ptr, prop, idptr, NULL);
RNA_property_pointer_set(&ptr, prop, idptr, nullptr);
RNA_property_update(C, &ptr, prop);
}
@ -963,7 +963,7 @@ void SCENE_OT_view_layer_add(wmOperatorType *ot)
0,
"Blank",
"Add a new view layer with all collections disabled"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@ -1000,7 +1000,7 @@ static int view_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
if (!ED_scene_view_layer_delete(bmain, scene, view_layer, NULL)) {
if (!ED_scene_view_layer_delete(bmain, scene, view_layer, nullptr)) {
return OPERATOR_CANCELLED;
}
@ -1044,7 +1044,7 @@ static int view_layer_add_aov_exec(bContext *C, wmOperator *UNUSED(op))
BKE_view_layer_verify_aov(engine, scene, view_layer);
}
RE_engine_free(engine);
engine = NULL;
engine = nullptr;
}
if (scene->nodetree) {
@ -1083,7 +1083,7 @@ static int view_layer_remove_aov_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
if (view_layer->active_aov == NULL) {
if (view_layer->active_aov == nullptr) {
return OPERATOR_FINISHED;
}
@ -1096,7 +1096,7 @@ static int view_layer_remove_aov_exec(bContext *C, wmOperator *UNUSED(op))
BKE_view_layer_verify_aov(engine, scene, view_layer);
}
RE_engine_free(engine);
engine = NULL;
engine = nullptr;
}
if (scene->nodetree) {
@ -1138,7 +1138,7 @@ enum {
static void light_cache_bake_tag_cache(Scene *scene, wmOperator *op)
{
if (scene->eevee.light_cache_data != NULL) {
if (scene->eevee.light_cache_data != nullptr) {
int subset = RNA_enum_get(op->ptr, "subset");
switch (subset) {
case LIGHTCACHE_SUBSET_ALL:
@ -1264,7 +1264,7 @@ void SCENE_OT_light_cache_bake(wmOperatorType *ot)
0,
"Cubemaps Only",
"Try to only bake reflection cubemaps if irradiance grids are up to date"},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@ -1320,7 +1320,7 @@ static int light_cache_free_exec(bContext *C, wmOperator *UNUSED(op))
}
EEVEE_lightcache_free(scene->eevee.light_cache_data);
scene->eevee.light_cache_data = NULL;
scene->eevee.light_cache_data = nullptr;
EEVEE_lightcache_info_update(&scene->eevee);
@ -1361,7 +1361,7 @@ static int render_view_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
BKE_scene_add_render_view(scene, NULL);
BKE_scene_add_render_view(scene, nullptr);
scene->r.actview = BLI_listbase_count(&scene->r.views) - 1;
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
@ -1450,7 +1450,7 @@ static bool freestyle_active_module_poll(bContext *C)
PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
FreestyleModuleConfig *module = static_cast<FreestyleModuleConfig *>(ptr.data);
return module != NULL;
return module != nullptr;
}
static int freestyle_module_add_exec(bContext *C, wmOperator *UNUSED(op))
@ -1542,7 +1542,7 @@ void SCENE_OT_freestyle_module_move(wmOperatorType *ot)
static const EnumPropertyItem direction_items[] = {
{-1, "UP", 0, "Up", ""},
{1, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@ -1578,7 +1578,7 @@ static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
BKE_freestyle_lineset_add(bmain, &view_layer->freestyle_config, NULL);
BKE_freestyle_lineset_add(bmain, &view_layer->freestyle_config, nullptr);
DEG_id_tag_update(&scene->id, 0);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
@ -1614,7 +1614,7 @@ static bool freestyle_active_lineset_poll(bContext *C)
return false;
}
return BKE_freestyle_lineset_get_active(&view_layer->freestyle_config) != NULL;
return BKE_freestyle_lineset_get_active(&view_layer->freestyle_config) != nullptr;
}
static int freestyle_lineset_copy_exec(bContext *C, wmOperator *UNUSED(op))
@ -1734,7 +1734,7 @@ void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot)
static const EnumPropertyItem direction_items[] = {
{-1, "UP", 0, "Up", ""},
{1, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@ -1818,7 +1818,7 @@ static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
if (BKE_linestyle_color_modifier_add(lineset->linestyle, NULL, type) == NULL) {
if (BKE_linestyle_color_modifier_add(lineset->linestyle, nullptr, type) == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type");
return OPERATOR_CANCELLED;
}
@ -1865,7 +1865,7 @@ static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
if (BKE_linestyle_alpha_modifier_add(lineset->linestyle, NULL, type) == NULL) {
if (BKE_linestyle_alpha_modifier_add(lineset->linestyle, nullptr, type) == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type");
return OPERATOR_CANCELLED;
}
@ -1912,7 +1912,7 @@ static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
if (BKE_linestyle_thickness_modifier_add(lineset->linestyle, NULL, type) == NULL) {
if (BKE_linestyle_thickness_modifier_add(lineset->linestyle, nullptr, type) == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type");
return OPERATOR_CANCELLED;
}
@ -1959,7 +1959,7 @@ static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
if (BKE_linestyle_geometry_modifier_add(lineset->linestyle, NULL, type) == NULL) {
if (BKE_linestyle_geometry_modifier_add(lineset->linestyle, nullptr, type) == nullptr) {
BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type");
return OPERATOR_CANCELLED;
}
@ -2170,7 +2170,7 @@ void SCENE_OT_freestyle_modifier_move(wmOperatorType *ot)
static const EnumPropertyItem direction_items[] = {
{-1, "UP", 0, "Up", ""},
{1, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@ -2256,9 +2256,12 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op)
mtex_ar[act] = mtex_ar[act - 1];
mtex_ar[act - 1] = mtexswap;
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act - 1, -1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act - 1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
BKE_animdata_fix_paths_rename(
id, adt, nullptr, "texture_slots", nullptr, nullptr, act - 1, -1, false);
BKE_animdata_fix_paths_rename(
id, adt, nullptr, "texture_slots", nullptr, nullptr, act, act - 1, false);
BKE_animdata_fix_paths_rename(
id, adt, nullptr, "texture_slots", nullptr, nullptr, -1, act, false);
set_active_mtex(id, act - 1);
}
@ -2269,9 +2272,12 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op)
mtex_ar[act] = mtex_ar[act + 1];
mtex_ar[act + 1] = mtexswap;
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act + 1, -1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act + 1, 0);
BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
BKE_animdata_fix_paths_rename(
id, adt, nullptr, "texture_slots", nullptr, nullptr, act + 1, -1, false);
BKE_animdata_fix_paths_rename(
id, adt, nullptr, "texture_slots", nullptr, nullptr, act, act + 1, false);
BKE_animdata_fix_paths_rename(
id, adt, nullptr, "texture_slots", nullptr, nullptr, -1, act, false);
set_active_mtex(id, act + 1);
}
@ -2289,7 +2295,7 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot)
static const EnumPropertyItem slot_move[] = {
{-1, "UP", 0, "Up", ""},
{1, "DOWN", 0, "Down", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
/* identifiers */
@ -2318,7 +2324,7 @@ static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = static_cast<Material *>(
CTX_data_pointer_get_type(C, "material", &RNA_Material).data);
if (ma == NULL) {
if (ma == nullptr) {
return OPERATOR_CANCELLED;
}
@ -2353,7 +2359,7 @@ static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
Material *ma = static_cast<Material *>(
CTX_data_pointer_get_type(C, "material", &RNA_Material).data);
if (ma == NULL) {
if (ma == nullptr) {
return OPERATOR_CANCELLED;
}
@ -2395,7 +2401,7 @@ void ED_render_clear_mtex_copybuf(void)
static void copy_mtex_copybuf(ID *id)
{
MTex **mtex = NULL;
MTex **mtex = nullptr;
switch (GS(id->name)) {
case ID_PA:
@ -2419,9 +2425,9 @@ static void copy_mtex_copybuf(ID *id)
static void paste_mtex_copybuf(ID *id)
{
MTex **mtex = NULL;
MTex **mtex = nullptr;
if (mtexcopied == 0 || mtexcopybuf.tex == NULL) {
if (mtexcopied == 0 || mtexcopybuf.tex == nullptr) {
return;
}
@ -2438,7 +2444,7 @@ static void paste_mtex_copybuf(ID *id)
}
if (mtex) {
if (*mtex == NULL) {
if (*mtex == nullptr) {
*mtex = MEM_new<MTex>("mtex copy");
}
else if ((*mtex)->tex) {
@ -2461,7 +2467,7 @@ static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op))
{
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
if (id == NULL) {
if (id == nullptr) {
/* copying empty slot */
ED_render_clear_mtex_copybuf();
return OPERATOR_CANCELLED;
@ -2476,7 +2482,7 @@ static bool copy_mtex_poll(bContext *C)
{
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
return (id != NULL);
return (id != nullptr);
}
void TEXTURE_OT_slot_copy(wmOperatorType *ot)
@ -2505,7 +2511,7 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
{
ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
if (id == NULL) {
if (id == nullptr) {
Material *ma = static_cast<Material *>(
CTX_data_pointer_get_type(C, "material", &RNA_Material).data);
Light *la = static_cast<Light *>(CTX_data_pointer_get_type(C, "light", &RNA_Light).data);
@ -2531,14 +2537,14 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
id = &linestyle->id;
}
if (id == NULL) {
if (id == nullptr) {
return OPERATOR_CANCELLED;
}
}
paste_mtex_copybuf(id);
WM_event_add_notifier(C, NC_TEXTURE | ND_SHADING_LINKS, NULL);
WM_event_add_notifier(C, NC_TEXTURE | ND_SHADING_LINKS, nullptr);
return OPERATOR_FINISHED;
}

View File

@ -20,8 +20,8 @@
* \ingroup edrend
*/
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <cstring>
#include "DNA_cachefile_types.h"
#include "DNA_light_types.h"
@ -62,7 +62,7 @@
#include "WM_api.h"
#include <stdio.h>
#include <cstdio>
/* -------------------------------------------------------------------- */
/** \name Render Engines
@ -111,7 +111,7 @@ void ED_render_view3d_update(Depsgraph *depsgraph,
else {
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
if (updated) {
DRWUpdateContext drw_context = {0};
DRWUpdateContext drw_context = {nullptr};
drw_context.bmain = bmain;
drw_context.depsgraph = depsgraph;
drw_context.scene = scene;
@ -189,9 +189,9 @@ void ED_render_engine_changed(Main *bmain, const bool update_scene_data)
ED_render_engine_area_exit(bmain, area);
}
}
RE_FreePersistentData(NULL);
RE_FreePersistentData(nullptr);
/* Inform all render engines and draw managers. */
DEGEditorUpdateContext update_ctx = {NULL};
DEGEditorUpdateContext update_ctx = {nullptr};
update_ctx.bmain = bmain;
for (Scene *scene = static_cast<Scene *>(bmain->scenes.first); scene;
scene = static_cast<Scene *>(scene->id.next)) {
@ -309,7 +309,7 @@ static void scene_changed(Main *bmain, Scene *scene)
ob = static_cast<Object *>(ob->id.next)) {
if (ob->mode & OB_MODE_TEXTURE_PAINT) {
BKE_texpaint_slots_refresh_object(scene, ob);
ED_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
ED_paint_proj_mesh_data_check(scene, ob, nullptr, nullptr, nullptr, nullptr);
}
}
}

View File

@ -21,8 +21,8 @@
* \ingroup edrend
*/
#include <stddef.h>
#include <string.h>
#include <cstddef>
#include <cstring>
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
@ -59,7 +59,7 @@
static ScrArea *biggest_non_image_area(bContext *C)
{
bScreen *screen = CTX_wm_screen(C);
ScrArea *area, *big = NULL;
ScrArea *area, *big = nullptr;
int size, maxsize = 0, bwmaxsize = 0;
short foundwin = 0;
@ -86,7 +86,7 @@ static ScrArea *biggest_non_image_area(bContext *C)
static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow **win)
{
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *area = NULL;
ScrArea *area = nullptr;
SpaceImage *sima;
/* find an imagewindow showing render result */
@ -136,13 +136,13 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindow *win = NULL;
ScrArea *area = NULL;
wmWindow *win = nullptr;
ScrArea *area = nullptr;
SpaceImage *sima;
bool area_was_image = false;
if (U.render_display_type == USER_RENDER_DISPLAY_NONE) {
return NULL;
return nullptr;
}
if (U.render_display_type == USER_RENDER_DISPLAY_WINDOW) {
@ -168,9 +168,9 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
true,
false,
true,
WIN_ALIGN_LOCATION_CENTER) == NULL) {
WIN_ALIGN_LOCATION_CENTER) == nullptr) {
BKE_report(reports, RPT_ERROR, "Failed to open window!");
return NULL;
return nullptr;
}
area = CTX_wm_area(C);
@ -185,7 +185,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
/* If the active screen is already in full-screen mode, skip this and
* unset the area, so that the full-screen area is just changed later. */
if (area && area->full) {
area = NULL;
area = nullptr;
}
else {
if (area && area->spacetype == SPACE_IMAGE) {
@ -199,7 +199,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
if (!area) {
area = find_area_showing_r_result(C, scene, &win);
if (area == NULL) {
if (area == nullptr) {
area = find_area_image_empty(C);
}
@ -208,7 +208,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports)
wm_window_raise(win);
}
if (area == NULL) {
if (area == nullptr) {
/* find largest open non-image area */
area = biggest_non_image_area(C);
if (area) {

View File

@ -416,7 +416,7 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain,
}
nodeSetActive(ntree, output_material);
BKE_ntree_update_main_tree(bmain, ntree, NULL);
BKE_ntree_update_main_tree(bmain, ntree, nullptr);
return ma;
}