Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_volume.cpp
| Show All 28 Lines | openvdb::GridBase::ConstPtr BKE_volume_grid_openvdb_for_read(const struct Volume *volume, | ||||
| struct VolumeGrid *grid); | struct VolumeGrid *grid); | ||||
| #endif | #endif | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* TODO: verify this is not loading unnecessary attributes. */ | /* TODO: verify this is not loading unnecessary attributes. */ | ||||
| class BlenderSmokeLoader : public ImageLoader { | class BlenderSmokeLoader : public ImageLoader { | ||||
| public: | public: | ||||
| BlenderSmokeLoader(const BL::Object &b_ob, AttributeStandard attribute) | BlenderSmokeLoader(BL::Object &b_ob, AttributeStandard attribute) | ||||
| : b_ob(b_ob), attribute(attribute) | : b_domain(object_fluid_gas_domain_find(b_ob)), b_mesh(b_ob.data()), attribute(attribute) | ||||
| { | { | ||||
| } | } | ||||
| bool load_metadata(ImageMetaData &metadata) override | bool load_metadata(ImageMetaData &metadata) override | ||||
| { | { | ||||
| BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob); | |||||
| if (!b_domain) { | if (!b_domain) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (attribute == ATTR_STD_VOLUME_DENSITY || attribute == ATTR_STD_VOLUME_FLAME || | if (attribute == ATTR_STD_VOLUME_DENSITY || attribute == ATTR_STD_VOLUME_FLAME || | ||||
| attribute == ATTR_STD_VOLUME_HEAT || attribute == ATTR_STD_VOLUME_TEMPERATURE) { | attribute == ATTR_STD_VOLUME_HEAT || attribute == ATTR_STD_VOLUME_TEMPERATURE) { | ||||
| metadata.type = IMAGE_DATA_TYPE_FLOAT; | metadata.type = IMAGE_DATA_TYPE_FLOAT; | ||||
| metadata.channels = 1; | metadata.channels = 1; | ||||
| Show All 20 Lines | bool load_metadata(ImageMetaData &metadata) override | ||||
| metadata.width = resolution.x * amplify; | metadata.width = resolution.x * amplify; | ||||
| metadata.height = resolution.y * amplify; | metadata.height = resolution.y * amplify; | ||||
| metadata.depth = resolution.z * amplify; | metadata.depth = resolution.z * amplify; | ||||
| /* Create a matrix to transform from object space to mesh texture space. | /* Create a matrix to transform from object space to mesh texture space. | ||||
| * This does not work with deformations but that can probably only be done | * This does not work with deformations but that can probably only be done | ||||
| * well with a volume grid mapping of coordinates. */ | * well with a volume grid mapping of coordinates. */ | ||||
| BL::Mesh b_mesh(b_ob.data()); | |||||
| float3 loc, size; | float3 loc, size; | ||||
| mesh_texture_space(b_mesh, loc, size); | mesh_texture_space(b_mesh, loc, size); | ||||
| metadata.transform_3d = transform_translate(-loc) * transform_scale(size); | metadata.transform_3d = transform_translate(-loc) * transform_scale(size); | ||||
| metadata.use_transform_3d = true; | metadata.use_transform_3d = true; | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool load_pixels(const ImageMetaData &, void *pixels, const size_t, const bool) override | bool load_pixels(const ImageMetaData &, void *pixels, const size_t, const bool) override | ||||
| { | { | ||||
| /* smoke volume data */ | |||||
| BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob); | |||||
| if (!b_domain) { | if (!b_domain) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| #ifdef WITH_FLUID | #ifdef WITH_FLUID | ||||
| int3 resolution = get_int3(b_domain.domain_resolution()); | int3 resolution = get_int3(b_domain.domain_resolution()); | ||||
| int length, amplify = (b_domain.use_noise()) ? b_domain.noise_scale() : 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. */ | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | #endif | ||||
| string name() const override | string name() const override | ||||
| { | { | ||||
| return Attribute::standard_name(attribute); | return Attribute::standard_name(attribute); | ||||
| } | } | ||||
| bool equals(const ImageLoader &other) const override | bool equals(const ImageLoader &other) const override | ||||
| { | { | ||||
| const BlenderSmokeLoader &other_loader = (const BlenderSmokeLoader &)other; | const BlenderSmokeLoader &other_loader = (const BlenderSmokeLoader &)other; | ||||
| return b_ob == other_loader.b_ob && attribute == other_loader.attribute; | return b_domain == other_loader.b_domain && attribute == other_loader.attribute; | ||||
| } | } | ||||
| BL::Object b_ob; | BL::FluidDomainSettings b_domain; | ||||
| BL::Mesh b_mesh; | |||||
| AttributeStandard attribute; | AttributeStandard attribute; | ||||
| }; | }; | ||||
| static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float frame) | static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float frame) | ||||
| { | { | ||||
| BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob); | BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob); | ||||
| if (!b_domain) { | if (!b_domain) { | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines | |||||