Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_session.cpp
| Show First 20 Lines • Show All 1,157 Lines • ▼ Show 20 Lines | if (metadata.is_float) { | ||||
| /* Float images are already converted on the Blender side, | /* Float images are already converted on the Blender side, | ||||
| * no need to do anything in Cycles. */ | * no need to do anything in Cycles. */ | ||||
| metadata.colorspace = u_colorspace_raw; | metadata.colorspace = u_colorspace_raw; | ||||
| } | } | ||||
| } | } | ||||
| else if (b_id.is_a(&RNA_Object)) { | else if (b_id.is_a(&RNA_Object)) { | ||||
| /* smoke volume data */ | /* smoke volume data */ | ||||
| BL::Object b_ob(b_id); | BL::Object b_ob(b_id); | ||||
| BL::SmokeDomainSettings b_domain = object_smoke_domain_find(b_ob); | BL::MantaDomainSettings b_domain = object_manta_domain_find(b_ob); | ||||
| metadata.is_float = true; | metadata.is_float = true; | ||||
| metadata.depth = 1; | metadata.depth = 1; | ||||
| metadata.channels = 1; | metadata.channels = 1; | ||||
| if (!b_domain) | if (!b_domain) | ||||
| return; | return; | ||||
| if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY) || | if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY) || | ||||
| builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME) || | builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME) || | ||||
| builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT) || | builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT) || | ||||
| builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE)) | builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE)) | ||||
| metadata.channels = 1; | metadata.channels = 1; | ||||
| else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR)) | else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR)) | ||||
| metadata.channels = 4; | metadata.channels = 4; | ||||
| else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) | else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) | ||||
| metadata.channels = 3; | metadata.channels = 3; | ||||
| else | else | ||||
| return; | return; | ||||
| int3 resolution = get_int3(b_domain.domain_resolution()); | int3 resolution = get_int3(b_domain.domain_resolution()); | ||||
| int amplify = (b_domain.use_high_resolution()) ? b_domain.amplify() + 1 : 1; | int amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1; | ||||
| /* Velocity and heat data is always low-resolution. */ | /* Velocity and heat data is always low-resolution. */ | ||||
| if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) || | if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) || | ||||
| builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) { | builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) { | ||||
| amplify = 1; | amplify = 1; | ||||
| } | } | ||||
| metadata.width = resolution.x * amplify; | metadata.width = resolution.x * amplify; | ||||
| ▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | if (free_cache) { | ||||
| b_image.buffers_free(); | b_image.buffers_free(); | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| else if (b_id.is_a(&RNA_Object)) { | else if (b_id.is_a(&RNA_Object)) { | ||||
| /* smoke volume data */ | /* smoke volume data */ | ||||
| BL::Object b_ob(b_id); | BL::Object b_ob(b_id); | ||||
| BL::SmokeDomainSettings b_domain = object_smoke_domain_find(b_ob); | BL::MantaDomainSettings b_domain = object_manta_domain_find(b_ob); | ||||
| if (!b_domain) { | if (!b_domain) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| int3 resolution = get_int3(b_domain.domain_resolution()); | int3 resolution = get_int3(b_domain.domain_resolution()); | ||||
| int length, amplify = (b_domain.use_high_resolution()) ? b_domain.amplify() + 1 : 1; | int length, amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 1; | ||||
| /* Velocity and heat data is always low-resolution. */ | /* Velocity and heat data is always low-resolution. */ | ||||
| if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) || | if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY) || | ||||
| builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) { | builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) { | ||||
| amplify = 1; | amplify = 1; | ||||
| } | } | ||||
| const int width = resolution.x * amplify; | const int width = resolution.x * amplify; | ||||
| const int height = resolution.y * amplify; | const int height = resolution.y * amplify; | ||||
| const int depth = resolution.z * amplify; | const int depth = resolution.z * amplify; | ||||
| const size_t num_pixels = ((size_t)width) * height * depth; | const size_t num_pixels = ((size_t)width) * height * depth; | ||||
| if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY)) { | if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY)) { | ||||
| SmokeDomainSettings_density_grid_get_length(&b_domain.ptr, &length); | MantaDomainSettings_density_grid_get_length(&b_domain.ptr, &length); | ||||
| if (length == num_pixels) { | if (length == num_pixels) { | ||||
| SmokeDomainSettings_density_grid_get(&b_domain.ptr, pixels); | MantaDomainSettings_density_grid_get(&b_domain.ptr, pixels); | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME)) { | else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_FLAME)) { | ||||
| /* this is in range 0..1, and interpreted by the OpenGL smoke viewer | /* this is in range 0..1, and interpreted by the OpenGL smoke viewer | ||||
| * as 1500..3000 K with the first part faded to zero density */ | * as 1500..3000 K with the first part faded to zero density */ | ||||
| SmokeDomainSettings_flame_grid_get_length(&b_domain.ptr, &length); | MantaDomainSettings_flame_grid_get_length(&b_domain.ptr, &length); | ||||
| if (length == num_pixels) { | if (length == num_pixels) { | ||||
| SmokeDomainSettings_flame_grid_get(&b_domain.ptr, pixels); | MantaDomainSettings_flame_grid_get(&b_domain.ptr, pixels); | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR)) { | else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_COLOR)) { | ||||
| /* the RGB is "premultiplied" by density for better interpolation results */ | /* the RGB is "premultiplied" by density for better interpolation results */ | ||||
| SmokeDomainSettings_color_grid_get_length(&b_domain.ptr, &length); | MantaDomainSettings_color_grid_get_length(&b_domain.ptr, &length); | ||||
| if (length == num_pixels * 4) { | if (length == num_pixels * 4) { | ||||
| SmokeDomainSettings_color_grid_get(&b_domain.ptr, pixels); | MantaDomainSettings_color_grid_get(&b_domain.ptr, pixels); | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) { | else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_VELOCITY)) { | ||||
| SmokeDomainSettings_velocity_grid_get_length(&b_domain.ptr, &length); | MantaDomainSettings_velocity_grid_get_length(&b_domain.ptr, &length); | ||||
| if (length == num_pixels * 3) { | if (length == num_pixels * 3) { | ||||
| SmokeDomainSettings_velocity_grid_get(&b_domain.ptr, pixels); | MantaDomainSettings_velocity_grid_get(&b_domain.ptr, pixels); | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) { | else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_HEAT)) { | ||||
| SmokeDomainSettings_heat_grid_get_length(&b_domain.ptr, &length); | MantaDomainSettings_heat_grid_get_length(&b_domain.ptr, &length); | ||||
| if (length == num_pixels) { | if (length == num_pixels) { | ||||
| SmokeDomainSettings_heat_grid_get(&b_domain.ptr, pixels); | MantaDomainSettings_heat_grid_get(&b_domain.ptr, pixels); | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE)) { | else if (builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_TEMPERATURE)) { | ||||
| SmokeDomainSettings_temperature_grid_get_length(&b_domain.ptr, &length); | MantaDomainSettings_temperature_grid_get_length(&b_domain.ptr, &length); | ||||
| if (length == num_pixels) { | if (length == num_pixels) { | ||||
| SmokeDomainSettings_temperature_grid_get(&b_domain.ptr, pixels); | MantaDomainSettings_temperature_grid_get(&b_domain.ptr, pixels); | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| fprintf( | fprintf( | ||||
| stderr, "Cycles error: unknown volume attribute %s, skipping\n", builtin_name.c_str()); | stderr, "Cycles error: unknown volume attribute %s, skipping\n", builtin_name.c_str()); | ||||
| pixels[0] = 0.0f; | pixels[0] = 0.0f; | ||||
| return false; | return false; | ||||
| ▲ Show 20 Lines • Show All 101 Lines • Show Last 20 Lines | |||||