Fix cycles crash when voxel attributes changed
This could happen e.g. when changing smoke type from flow to domain or connecting a volume shader with to a domain without an actual flow type around. Fixes T58569, T68359 Reviewers: brecht Maniphest Tasks: T58569, T68359 Differential Revision: https://developer.blender.org/D5478
This commit is contained in:
		@@ -1091,6 +1091,17 @@ bool Mesh::has_true_displacement() const
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Mesh::has_voxel_attributes() const
 | 
			
		||||
{
 | 
			
		||||
  foreach (const Attribute &attr, attributes.attributes) {
 | 
			
		||||
    if (attr.element == ATTR_ELEMENT_VOXEL) {
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float Mesh::motion_time(int step) const
 | 
			
		||||
{
 | 
			
		||||
  return (motion_steps > 1) ? 2.0f * step / (motion_steps - 1) - 1.0f : 0.0f;
 | 
			
		||||
@@ -2020,15 +2031,7 @@ void MeshManager::device_update_preprocess(Device *device, Scene *scene, Progres
 | 
			
		||||
 | 
			
		||||
    if (need_update && mesh->has_volume) {
 | 
			
		||||
      /* Create volume meshes if there is voxel data. */
 | 
			
		||||
      bool has_voxel_attributes = false;
 | 
			
		||||
 | 
			
		||||
      foreach (Attribute &attr, mesh->attributes.attributes) {
 | 
			
		||||
        if (attr.element == ATTR_ELEMENT_VOXEL) {
 | 
			
		||||
          has_voxel_attributes = true;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (has_voxel_attributes) {
 | 
			
		||||
      if (mesh->has_voxel_attributes()) {
 | 
			
		||||
        if (!volume_images_updated) {
 | 
			
		||||
          progress.set_status("Updating Meshes Volume Bounds");
 | 
			
		||||
          device_update_volume_images(device, scene, progress);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user