1
1

Fix Cycles missing nullptr check in case mesh has no shader

Did not affect Blender, but could happen with other integrations.

Differential Revision: https://developer.blender.org/D14538
This commit is contained in:
Charles Flèche
2022-04-11 14:22:13 +02:00
committed by Brecht Van Lommel
parent cda3334586
commit b6eb7dae59

View File

@@ -690,12 +690,16 @@ void Mesh::pack_shaders(Scene *scene, uint *tri_shader)
bool last_smooth = false;
size_t triangles_size = num_triangles();
int *shader_ptr = shader.data();
const int *shader_ptr = shader.data();
const bool *smooth_ptr = smooth.data();
for (size_t i = 0; i < triangles_size; i++) {
if (shader_ptr[i] != last_shader || last_smooth != smooth[i]) {
last_shader = shader_ptr[i];
last_smooth = smooth[i];
const int new_shader = shader_ptr ? shader_ptr[i] : INT_MAX;
const bool new_smooth = smooth_ptr ? smooth_ptr[i] : false;
if (new_shader != last_shader || last_smooth != new_smooth) {
last_shader = new_shader;
last_smooth = new_smooth;
Shader *shader = (last_shader < used_shaders.size()) ?
static_cast<Shader *>(used_shaders[last_shader]) :
scene->default_surface;