diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2016-07-13 19:27:54 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2016-07-13 19:27:54 +0300 |
commit | c88dcfbdf13c34bef8bf0c1660ea71b396f75521 (patch) | |
tree | 142fd7a9d45245daec47bf237e415748c48e0163 /source/blender/editors/space_view3d | |
parent | a7a07c1e67fa2a4638a6e4c7f67a055f0c1c9a28 (diff) |
Fix crash when adding a strands modifier and the fiber vertex/edge buffer is NULL.
The NULL buffer pointer is expected, just needs a sanity check.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/drawstrands.c | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/source/blender/editors/space_view3d/drawstrands.c b/source/blender/editors/space_view3d/drawstrands.c index 531a2e15248..35ae1602f1c 100644 --- a/source/blender/editors/space_view3d/drawstrands.c +++ b/source/blender/editors/space_view3d/drawstrands.c @@ -153,17 +153,19 @@ void draw_strands(Scene *scene, View3D *UNUSED(v3d), RegionView3D *rv3d, } } else { - struct GPUAttrib *attrib; - int num_attrib; - GPU_strand_shader_get_fiber_attributes(shader, &attrib, &num_attrib); - - int elemsize = GPU_attrib_element_size(attrib, num_attrib); - GPU_interleaved_attrib_setup(buffer->fiber_points, attrib, num_attrib, elemsize, false); - - GPU_buffer_draw_elements(buffer->fiber_edges, GL_LINES, 0, - buffer->fiber_totedges * 2); - - GPU_interleaved_attrib_unbind(); + if (buffer->fiber_points && buffer->fiber_edges) { + struct GPUAttrib *attrib; + int num_attrib; + GPU_strand_shader_get_fiber_attributes(shader, &attrib, &num_attrib); + + int elemsize = GPU_attrib_element_size(attrib, num_attrib); + GPU_interleaved_attrib_setup(buffer->fiber_points, attrib, num_attrib, elemsize, false); + + GPU_buffer_draw_elements(buffer->fiber_edges, GL_LINES, 0, + buffer->fiber_totedges * 2); + + GPU_interleaved_attrib_unbind(); + } } GPU_strands_buffer_unbind(); @@ -535,17 +537,19 @@ void draw_strands_edit(Scene *scene, View3D *UNUSED(v3d), RegionView3D *rv3d, } } else { - struct GPUAttrib *attrib; - int num_attrib; - GPU_strand_shader_get_fiber_attributes(shader, &attrib, &num_attrib); - - int elemsize = GPU_attrib_element_size(attrib, num_attrib); - GPU_interleaved_attrib_setup(buffer->fiber_points, attrib, num_attrib, elemsize, false); - - GPU_buffer_draw_elements(buffer->fiber_edges, GL_LINES, 0, - buffer->fiber_totedges * 2); - - GPU_interleaved_attrib_unbind(); + if (buffer->fiber_points && buffer->fiber_edges) { + struct GPUAttrib *attrib; + int num_attrib; + GPU_strand_shader_get_fiber_attributes(shader, &attrib, &num_attrib); + + int elemsize = GPU_attrib_element_size(attrib, num_attrib); + GPU_interleaved_attrib_setup(buffer->fiber_points, attrib, num_attrib, elemsize, false); + + GPU_buffer_draw_elements(buffer->fiber_edges, GL_LINES, 0, + buffer->fiber_totedges * 2); + + GPU_interleaved_attrib_unbind(); + } } GPU_strands_buffer_unbind(); |