From ccf43fe6050c4cf986bd227ffbf25b7b02c077be Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 20 May 2020 16:53:28 +0200 Subject: [PATCH] Cycles: Fix rendering instanced smoke domain. The problem was that Cycles would store a pointer to an object in `DEGObjectIterData->templ_dupli_object`. This pointer was then accessed when the iterator was already freed. Reviewers: brecht Differential Revision: https://developer.blender.org/D7797 --- intern/cycles/blender/blender_volume.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/intern/cycles/blender/blender_volume.cpp b/intern/cycles/blender/blender_volume.cpp index 6254a1a1b24..4eed6be8c7c 100644 --- a/intern/cycles/blender/blender_volume.cpp +++ b/intern/cycles/blender/blender_volume.cpp @@ -34,15 +34,13 @@ CCL_NAMESPACE_BEGIN /* TODO: verify this is not loading unnecessary attributes. */ class BlenderSmokeLoader : public ImageLoader { public: - BlenderSmokeLoader(const BL::Object &b_ob, AttributeStandard attribute) - : b_ob(b_ob), attribute(attribute) + BlenderSmokeLoader(BL::Object &b_ob, AttributeStandard attribute) + : b_domain(object_fluid_gas_domain_find(b_ob)), b_mesh(b_ob.data()), attribute(attribute) { } bool load_metadata(ImageMetaData &metadata) override { - BL::FluidDomainSettings b_domain = object_fluid_gas_domain_find(b_ob); - if (!b_domain) { return false; } @@ -79,7 +77,6 @@ class BlenderSmokeLoader : public ImageLoader { /* 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 * well with a volume grid mapping of coordinates. */ - BL::Mesh b_mesh(b_ob.data()); float3 loc, size; mesh_texture_space(b_mesh, loc, size); metadata.transform_3d = transform_translate(-loc) * transform_scale(size); @@ -90,9 +87,6 @@ class BlenderSmokeLoader : public ImageLoader { 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) { return false; } @@ -179,10 +173,11 @@ class BlenderSmokeLoader : public ImageLoader { bool equals(const ImageLoader &other) const override { 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; };