forked from blender/blender
Export volumes from object modifier (quick effect) #62
@ -58,6 +58,8 @@ void VolumeData::init()
|
||||
{
|
||||
init_from_volume();
|
||||
}
|
||||
write_transform();
|
||||
write_materials();
|
||||
}
|
||||
|
||||
void VolumeData::insert()
|
||||
@ -98,13 +100,6 @@ void VolumeData::update()
|
||||
}
|
||||
if (id->recalc & ID_RECALC_TRANSFORM) {
|
||||
write_transform();
|
||||
if (is_volume_modifier(object)) {
|
||||
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
|
||||
transform *= pxr::GfMatrix4d(1.0).SetTranslate(pxr::GfVec3d(mesh->texspace_location[0] - 1,
|
||||
mesh->texspace_location[1] - 1,
|
||||
mesh->texspace_location[2] - 1));
|
||||
BKE_object_to_mesh_clear(object);
|
||||
}
|
||||
bits |= pxr::HdChangeTracker::DirtyTransform;
|
||||
}
|
||||
|
||||
@ -204,51 +199,6 @@ void VolumeData::init_from_modifier() {
|
||||
Object *object = (Object *)this->id;
|
||||
FluidModifierData *volume_modifier = (FluidModifierData *)BKE_modifiers_findby_type(
|
||||
object, eModifierType_Fluid);
|
||||
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
|
||||
write_transform();
|
||||
|
||||
float dims[3];
|
||||
BKE_object_dimensions_get(object, dims);
|
||||
|
||||
double x = 0.0;
|
||||
double y = 0.0;
|
||||
double z = 0.0;
|
||||
|
||||
//if (mesh->texspace_size[0] != 1.0) {
|
||||
// x += mesh->texspace_size[0] * mesh->texspace_location[0] / 4;
|
||||
//}
|
||||
//if (mesh->texspace_size[1] != 1.0) {
|
||||
// y += mesh->texspace_size[1] * mesh->texspace_location[1] / 4;
|
||||
//}
|
||||
//if (mesh->texspace_size[2] != 1.0) {
|
||||
// z += mesh->texspace_size[2] * mesh->texspace_location[2] / 4;
|
||||
//}
|
||||
if (mesh->texspace_size[0] != 1.0) {
|
||||
x = mesh->texspace_size[0] * dims[0] * mesh->texspace_location[0] / 2;
|
||||
}
|
||||
if (mesh->texspace_size[1] != 1.0) {
|
||||
y = mesh->texspace_size[1] * dims[1] * mesh->texspace_location[1] / 2;
|
||||
}
|
||||
if (mesh->texspace_size[2] != 1.0) {
|
||||
z = mesh->texspace_size[2] * dims[2] * mesh->texspace_location[2] / 2;
|
||||
}
|
||||
//pxr::GfMatrix4d loc = pxr::GfMatrix4d(1.0).SetTranslate(pxr::GfVec3d(mesh->texspace_location) - pxr::GfVec3d(x, y, z));
|
||||
pxr::GfMatrix4d loc = pxr::GfMatrix4d(1.0).SetTranslate(
|
||||
pxr::GfVec3d(mesh->texspace_location) - pxr::GfVec3d(1.0 * mesh->texspace_size[0],
|
||||
1.0 * mesh->texspace_size[1],
|
||||
1.0 * mesh->texspace_size[2]));
|
||||
pxr::GfMatrix4d size = pxr::GfMatrix4d(1.0).SetScale(pxr::GfVec3d(mesh->texspace_size));
|
||||
pxr::GfMatrix4d trans = pxr::GfMatrix4d(1.0).SetTranslate(pxr::GfVec3d(-x, -y, -z));
|
||||
//transform *= loc * size * trans;
|
||||
|
||||
|
||||
pxr::GfMatrix4d scale = pxr::GfMatrix4d(1.0).SetScale(pxr::GfVec3d(
|
||||
dims[0] / object->scale[0] / 2, dims[1] / object->scale[1] / 2, dims[2] / object->scale[2] / 2));
|
||||
|
||||
transform = transform * size * loc; // * trans;// * size;
|
||||
|
||||
|
||||
BKE_object_to_mesh_clear(object);
|
||||
filepath_ = get_cached_file_path(volume_modifier->domain->cache_directory,
|
||||
scene_delegate_->scene->r.cfra);
|
||||
for (auto &grid_name : supported_grids) {
|
||||
@ -256,7 +206,6 @@ void VolumeData::init_from_modifier() {
|
||||
pxr::UsdVolImagingTokens->openvdbAsset,
|
||||
prim_id.AppendElementString("VF_" + grid_name.GetString()));
|
||||
}
|
||||
write_materials();
|
||||
}
|
||||
|
||||
void VolumeData::init_from_volume()
|
||||
@ -282,8 +231,6 @@ void VolumeData::init_from_volume()
|
||||
}
|
||||
}
|
||||
BKE_volume_unload(volume);
|
||||
write_transform();
|
||||
write_materials();
|
||||
}
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
Loading…
Reference in New Issue
Block a user