61 metadata.
width = resolution.
x * amplify;
62 metadata.
height = resolution.
y * amplify;
63 metadata.
depth = resolution.
z * amplify;
88 const int width = resolution.
x * amplify;
89 const int height = resolution.
y * amplify;
90 const int depth = resolution.
z * amplify;
91 const size_t num_pixels = ((size_t)width) * height * depth;
93 float *fpixels = (
float *)pixels;
96 FluidDomainSettings_density_grid_get_length(&
b_domain.ptr, &length);
97 if (length == num_pixels) {
98 FluidDomainSettings_density_grid_get(&
b_domain.ptr, fpixels);
105 FluidDomainSettings_flame_grid_get_length(&
b_domain.ptr, &length);
106 if (length == num_pixels) {
107 FluidDomainSettings_flame_grid_get(&
b_domain.ptr, fpixels);
113 FluidDomainSettings_color_grid_get_length(&
b_domain.ptr, &length);
114 if (length == num_pixels * 4) {
115 FluidDomainSettings_color_grid_get(&
b_domain.ptr, fpixels);
120 FluidDomainSettings_velocity_grid_get_length(&
b_domain.ptr, &length);
121 if (length == num_pixels * 3) {
122 FluidDomainSettings_velocity_grid_get(&
b_domain.ptr, fpixels);
127 FluidDomainSettings_heat_grid_get_length(&
b_domain.ptr, &length);
128 if (length == num_pixels) {
129 FluidDomainSettings_heat_grid_get(&
b_domain.ptr, fpixels);
134 FluidDomainSettings_temperature_grid_get_length(&
b_domain.ptr, &length);
135 if (length == num_pixels) {
136 FluidDomainSettings_temperature_grid_get(&
b_domain.ptr, fpixels);
142 "Cycles error: unknown volume attribute %s, skipping\n",
150 fprintf(stderr,
"Cycles error: unexpected smoke volume resolution, skipping\n");
181 float velocity_scale = b_domain.velocity_scale();
184 const float motion_scale = (need_motion) ?
185 scene->motion_shutter_time() /
186 (b_scene.render().fps() / b_scene.render().fps_base()) :
189 velocity_scale *= motion_scale;
191 volume->set_velocity_scale(velocity_scale);
203 if (!volume->need_attribute(scene, std)) {
207 volume->set_clipping(b_domain.clipping());
224 BL::VolumeRender::precision_enum precision_)
227 b_volume.grids.load(b_data.ptr.data);
230 for (BL::VolumeGrid &b_volume_grid :
b_volume.grids) {
232 const auto *grid_data =
static_cast<const blender::bke::VolumeGridData *
>(
233 b_volume_grid.ptr.data);
234 grid_data->add_user();
235 volume_grid = blender::bke::GVolumeGrid{grid_data};
236 grid = volume_grid->grid_ptr(tree_access_token);
242 switch (precision_) {
243 case BL::VolumeRender::precision_FULL:
246 case BL::VolumeRender::precision_HALF:
250 case BL::VolumeRender::precision_VARIABLE:
262 blender::bke::GVolumeGrid volume_grid;
263 blender::bke::VolumeTreeAccessToken tree_access_token;
274 b_volume.grids.load(b_data.ptr.data);
276 BL::VolumeRender b_render(b_volume.render());
278 volume->set_clipping(b_render.clipping());
279 volume->set_step_size(b_render.step_size());
280 volume->set_object_space((b_render.space() == BL::VolumeRender::space_OBJECT));
282 float velocity_scale = b_volume.velocity_scale();
283 if (b_volume.velocity_unit() == BL::Volume::velocity_unit_SECOND) {
286 const float motion_scale = (need_motion) ?
287 scene->motion_shutter_time() /
288 (b_scene.render().fps() / b_scene.render().fps_base()) :
291 velocity_scale *= motion_scale;
294 volume->set_velocity_scale(velocity_scale);
297 for (BL::VolumeGrid &b_grid : b_volume.grids) {
298 ustring name = ustring(b_grid.name());
317 name == b_volume.velocity_grid())
322 name == b_volume.velocity_x_grid())
327 name == b_volume.velocity_y_grid())
332 name == b_volume.velocity_z_grid())
337 if ((std !=
ATTR_STD_NONE && volume->need_attribute(scene, std)) ||
338 volume->need_attribute(scene, name))
341 volume->attributes.
add(std) :
345 b_data, b_volume, name.string(), b_render.precision());
347 params.frame = b_volume.grids.frame();
349 attr->
data_voxel() = scene->image_manager->add_image(loader,
params,
false);
358 if (view_layer.use_volumes) {
371 volume->tag_update(scene,
true);
static void sync_smoke_volume(BL::Scene &b_scene, Scene *scene, BObjectInfo &b_ob_info, Volume *volume, float frame)
static void sync_volume_object(BL::BlendData &b_data, BL::Scene &b_scene, BObjectInfo &b_ob_info, Scene *scene, Volume *volume)
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
static const char * standard_name(AttributeStandard std)
ImageHandle & data_voxel()
bool load_pixels(const ImageMetaData &, void *pixels, const size_t, const bool) override
string name() const override
bool load_metadata(const ImageDeviceFeatures &, ImageMetaData &metadata) override
BlenderSmokeLoader(BL::Object &b_ob, AttributeStandard attribute)
BL::FluidDomainSettings b_domain
bool equals(const ImageLoader &other) const override
AttributeStandard attribute
BlenderVolumeLoader(BL::BlendData &b_data, BL::Volume &b_volume, const string &grid_name, BL::VolumeRender::precision_enum precision_)
static void mesh_texture_space(const ::Mesh &b_mesh, float3 &loc, float3 &size)
static bool object_need_motion_attribute(BObjectInfo &b_ob_info, Scene *scene)
static int3 get_int3(const BL::Array< int, 3 > &array)
static BL::FluidDomainSettings object_fluid_gas_domain_find(BL::Object &b_ob)
#define CCL_NAMESPACE_END
@ ATTR_STD_VOLUME_VELOCITY_Y
@ ATTR_STD_VOLUME_TEMPERATURE
@ ATTR_STD_VOLUME_VELOCITY_Z
@ ATTR_STD_VOLUME_DENSITY
@ ATTR_STD_VOLUME_VELOCITY
@ ATTR_STD_VOLUME_VELOCITY_X
bool is_real_object_data() const