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
path: root/intern
diff options
context:
space:
mode:
authorCharles Flèche <charlesf>2022-04-11 15:22:13 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-04-11 15:24:59 +0300
commitb6eb7dae59aa3150abba467b1f12517c5bac8246 (patch)
treeba5d08661ea1cd2ff414f3e2356d21e1f13205a5 /intern
parentcda33345865a2705e0cbe24448865b2bdfc7ead6 (diff)
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
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/scene/mesh.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/intern/cycles/scene/mesh.cpp b/intern/cycles/scene/mesh.cpp
index 05024a7790e..b5c0d9d92fb 100644
--- a/intern/cycles/scene/mesh.cpp
+++ b/intern/cycles/scene/mesh.cpp
@@ -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;