62 const size_t width = resolution.
x * amplify;
63 const size_t height = resolution.
y * amplify;
64 const size_t depth = resolution.
z * amplify;
72 if (!
get_voxels(width, height, depth, channels, voxels)) {
91 voxels.resize(width * height * depth * channels);
94 FluidDomainSettings_density_grid_get_length(&
b_domain.ptr, &
length);
95 if (
length == voxels.size()) {
96 FluidDomainSettings_density_grid_get(&
b_domain.ptr, voxels.data());
103 FluidDomainSettings_flame_grid_get_length(&
b_domain.ptr, &
length);
104 if (
length == voxels.size()) {
105 FluidDomainSettings_flame_grid_get(&
b_domain.ptr, voxels.data());
111 FluidDomainSettings_color_grid_get_length(&
b_domain.ptr, &
length);
112 if (
length == voxels.size()) {
113 FluidDomainSettings_color_grid_get(&
b_domain.ptr, voxels.data());
118 FluidDomainSettings_velocity_grid_get_length(&
b_domain.ptr, &
length);
119 if (
length == voxels.size()) {
120 FluidDomainSettings_velocity_grid_get(&
b_domain.ptr, voxels.data());
126 if (
length == voxels.size()) {
127 FluidDomainSettings_heat_grid_get(&
b_domain.ptr, voxels.data());
132 FluidDomainSettings_temperature_grid_get_length(&
b_domain.ptr, &
length);
133 if (
length == voxels.size()) {
134 FluidDomainSettings_temperature_grid_get(&
b_domain.ptr, voxels.data());
144 LOG_ERROR <<
"Unexpected smoke volume resolution, skipping";
182 float velocity_scale = b_domain.velocity_scale();
185 const float motion_scale = (need_motion) ?
187 (b_scene.render().fps() / b_scene.render().fps_base()) :
190 velocity_scale *= motion_scale;
192 volume->set_velocity_scale(velocity_scale);
202 const Interval<int> frame_interval = {b_domain.cache_frame_start(), b_domain.cache_frame_end()};
210 const float clipping = b_domain.clipping();
214 if (!frame_interval.
contains(frame)) {
233 BL::VolumeRender::precision_enum precision_,
237 b_volume.grids.load(b_data.ptr.data);
240 for (BL::VolumeGrid &b_volume_grid :
b_volume.grids) {
241 if (b_volume_grid.name() == grid_name) {
242 const auto *grid_data = static_cast<const blender::bke::VolumeGridData *>(
243 b_volume_grid.ptr.data);
244 grid_data->add_user();
245 volume_grid = blender::bke::GVolumeGrid{grid_data};
246 grid = volume_grid->grid_ptr(tree_access_token);
252 switch (precision_) {
253 case BL::VolumeRender::precision_FULL:
256 case BL::VolumeRender::precision_HALF:
260 case BL::VolumeRender::precision_VARIABLE:
272 blender::bke::GVolumeGrid volume_grid;
273 blender::bke::VolumeTreeAccessToken tree_access_token;
284 b_volume.grids.load(b_data.ptr.data);
286 BL::VolumeRender b_render(b_volume.render());
288 volume->set_step_size(b_render.step_size());
289 volume->set_object_space((b_render.space() == BL::VolumeRender::space_OBJECT));
292 if (b_volume.velocity_unit() == BL::Volume::velocity_unit_SECOND) {
295 const float motion_scale = (need_motion) ?
297 (b_scene.render().fps() / b_scene.render().fps_base()) :
300 velocity_scale *= motion_scale;
303 volume->set_velocity_scale(velocity_scale);
306 for (BL::VolumeGrid &b_grid : b_volume.grids) {
307 const ustring
name = ustring(b_grid.name());
326 name == b_volume.velocity_grid())
331 name == b_volume.velocity_x_grid())
336 name == b_volume.velocity_y_grid())
341 name == b_volume.velocity_z_grid())
354 b_data, b_volume,
name.string(), b_render.precision(), b_render.clipping());
356 params.frame = b_volume.grids.frame();
367 if (view_layer.use_volumes) {
static void sync_smoke_volume(BL::Scene &b_scene, Scene *scene, BObjectInfo &b_ob_info, Volume *volume, const float frame)
static void sync_volume_object(BL::BlendData &b_data, BL::Scene &b_scene, BObjectInfo &b_ob_info, Scene *scene, Volume *volume)
Attribute * add(ustring name, const TypeDesc type, AttributeElement element)
void load_grid() override
string name() const override
bool get_voxels(const size_t width, const size_t height, const size_t depth, const int channels, vector< float > &voxels)
BlenderSmokeLoader(BL::Object &b_ob, AttributeStandard attribute, const float clipping)
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_, const float clipping)
void tag_update(Scene *scene, bool rebuild)
bool need_attribute(Scene *scene, AttributeStandard std)
void grid_from_dense_voxels(const size_t width, const size_t height, const size_t depth, const int channels, const float *voxels, Transform transform_3d)
VDBImageLoader(const string &grid_name, const float clipping=0.001f)
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
float length(VecOp< float, D >) RET
@ 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
static const char * standard_name(AttributeStandard std)
ImageHandle & data_voxel()
bool is_real_object_data() const
ccl_device_inline_method bool contains(T value) const
unique_ptr< ImageManager > image_manager
float motion_shutter_time()
void merge_grids(const Scene *scene)
void clear(bool preserve_shaders=false) override