Cleanup: Add more const correctness to some functions

These are functions that are used by eevee-rewrite which has more strict
const correctness.
This commit is contained in:
2022-01-27 14:59:09 +01:00
parent 78f29c0467
commit 6f1ab97c53
8 changed files with 18 additions and 14 deletions

View File

@@ -46,7 +46,7 @@ void *BKE_camera_add(struct Main *bmain, const char *name);
/**
* Get the camera's DOF value, takes the DOF object into account.
*/
float BKE_camera_object_dof_distance(struct Object *ob);
float BKE_camera_object_dof_distance(const struct Object *ob);
int BKE_camera_sensor_fit(int sensor_fit, float sizex, float sizey);
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y);

View File

@@ -218,7 +218,7 @@ void *BKE_camera_add(Main *bmain, const char *name)
return cam;
}
float BKE_camera_object_dof_distance(Object *ob)
float BKE_camera_object_dof_distance(const Object *ob)
{
Camera *cam = (Camera *)ob->data;
if (ob->type != OB_CAMERA) {

View File

@@ -293,7 +293,9 @@ DRWShaderLibrary *DRW_shader_library_create(void);
/**
* \warning Each library must be added after all its dependencies.
*/
void DRW_shader_library_add_file(DRWShaderLibrary *lib, char *lib_code, const char *lib_name);
void DRW_shader_library_add_file(DRWShaderLibrary *lib,
const char *lib_code,
const char *lib_name);
#define DRW_SHADER_LIB_ADD(lib, lib_name) \
DRW_shader_library_add_file(lib, datatoc_##lib_name##_glsl, STRINGIFY(lib_name) ".glsl")
@@ -696,7 +698,7 @@ const DRWView *DRW_view_default_get(void);
/**
* MUST only be called once per render and only in render mode. Sets default view.
*/
void DRW_view_default_set(DRWView *view);
void DRW_view_default_set(const DRWView *view);
/**
* \warning Only use in render AND only if you are going to set view_default again.
*/
@@ -704,7 +706,7 @@ void DRW_view_reset(void);
/**
* Set active view for rendering.
*/
void DRW_view_set_active(DRWView *view);
void DRW_view_set_active(const DRWView *view);
const DRWView *DRW_view_get_active(void);
/**

View File

@@ -1904,7 +1904,7 @@ void DRW_view_reset(void)
DST.view_previous = NULL;
}
void DRW_view_default_set(DRWView *view)
void DRW_view_default_set(const DRWView *view)
{
BLI_assert(DST.view_default == NULL);
DST.view_default = view;

View File

@@ -354,7 +354,7 @@ static bool draw_call_is_culled(const DRWResourceHandle *handle, DRWView *view)
return (culling->mask & view->culling_mask) != 0;
}
void DRW_view_set_active(DRWView *view)
void DRW_view_set_active(const DRWView *view)
{
DST.view_active = (view) ? view : DST.view_default;
}

View File

@@ -629,7 +629,7 @@ static uint32_t drw_shader_dependencies_get(const DRWShaderLibrary *lib, const c
return deps;
}
void DRW_shader_library_add_file(DRWShaderLibrary *lib, char *lib_code, const char *lib_name)
void DRW_shader_library_add_file(DRWShaderLibrary *lib, const char *lib_code, const char *lib_name)
{
int index = -1;
for (int i = 0; i < MAX_LIB; i++) {

View File

@@ -454,12 +454,14 @@ struct RenderPass *RE_pass_find_by_type(volatile struct RenderLayer *rl,
#define RE_BAKE_DISPLACEMENT 1
#define RE_BAKE_AO 2
void RE_GetCameraWindow(struct Render *re, struct Object *camera, float mat[4][4]);
void RE_GetCameraWindow(struct Render *re, const struct Object *camera, float mat[4][4]);
/**
* Must be called after #RE_GetCameraWindow(), does not change `re->winmat`.
*/
void RE_GetCameraWindowWithOverscan(struct Render *re, float overscan, float r_winmat[4][4]);
void RE_GetCameraModelMatrix(struct Render *re, struct Object *camera, float r_modelmat[4][4]);
void RE_GetCameraWindowWithOverscan(const struct Render *re, float overscan, float r_winmat[4][4]);
void RE_GetCameraModelMatrix(const struct Render *re,
const struct Object *camera,
float r_modelmat[4][4]);
struct Scene *RE_GetScene(struct Render *re);
void RE_SetScene(struct Render *re, struct Scene *sce);

View File

@@ -194,13 +194,13 @@ void RE_SetCamera(Render *re, Object *cam_ob)
re->viewplane = params.viewplane;
}
void RE_GetCameraWindow(struct Render *re, struct Object *camera, float r_winmat[4][4])
void RE_GetCameraWindow(struct Render *re, const struct Object *camera, float r_winmat[4][4])
{
RE_SetCamera(re, camera);
copy_m4_m4(r_winmat, re->winmat);
}
void RE_GetCameraWindowWithOverscan(struct Render *re, float overscan, float r_winmat[4][4])
void RE_GetCameraWindowWithOverscan(const struct Render *re, float overscan, float r_winmat[4][4])
{
CameraParams params;
params.is_ortho = re->winmat[3][3] != 0.0f;
@@ -218,7 +218,7 @@ void RE_GetCameraWindowWithOverscan(struct Render *re, float overscan, float r_w
copy_m4_m4(r_winmat, params.winmat);
}
void RE_GetCameraModelMatrix(Render *re, struct Object *camera, float r_modelmat[4][4])
void RE_GetCameraModelMatrix(const Render *re, const struct Object *camera, float r_modelmat[4][4])
{
BKE_camera_multiview_model_matrix(&re->r, camera, re->viewname, r_modelmat);
}