Export volumes from object modifier (quick effect) #62

Merged
Bogdan Nagirniak merged 28 commits from BLEN-448 into hydra-render 2023-07-20 23:49:25 +02:00
2 changed files with 16 additions and 25 deletions
Showing only changes of commit 475c609b95 - Show all commits

View File

@ -304,7 +304,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GPUSettings gpuS
true,
wnd,
mHDC,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
4,
minor,
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),

View File

@ -65,34 +65,25 @@ void VolumeModifierData::init()
void VolumeModifierData::write_transform()
{
Object *object = (Object *)this->id;
Mesh *mesh = BKE_object_to_mesh(nullptr, object, false);
pxr::GfMatrix4d fixed_transform = pxr::GfMatrix4d(1.0f).SetScale(0.5) *
pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(0.5));
double det = fixed_transform.GetDeterminant();
pxr::GfMatrix4d inversed = fixed_transform.GetInverse(&det);
float scale[3] = {0.5f, 0.5f, 0.5f};
if (object->scale[0] != 0.0f) {
scale[0] = 0.5f / object->scale[0];
/* set base scaling */
float scale[3];
for (int i = 0; i < 3; ++i) {
scale[i] = (object->scale[i] != 0.0f) ? 1.0f / object->scale[i] : 1.0f;
}
if (object->scale[1] != 0.0f) {
scale[1] = 0.5f / object->scale[1];
}
if (object->scale[2] != 0.0f) {
scale[2] = 0.5f / object->scale[2];
}
pxr::GfMatrix4d scale_matrix = pxr::GfMatrix4d(1.0f).SetScale(
pxr::GfVec3d(scale[0], scale[1], scale[2]));
pxr::GfMatrix4d texture_trans = pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(
mesh->texspace_location[0], mesh->texspace_location[1], mesh->texspace_location[2]));
pxr::GfMatrix4d texture_scale = pxr::GfMatrix4d(1.0f).SetScale(
pxr::GfVec3d(mesh->texspace_size[0], mesh->texspace_size[1], mesh->texspace_size[2]));
transform = pxr::GfMatrix4d().SetScale(pxr::GfVec3d(scale));
transform = scale_matrix * inversed * texture_scale * texture_trans *
gf_matrix_from_transform(object->object_to_world);
/* positioning to center */
transform *= pxr::GfMatrix4d().SetTranslate(pxr::GfVec3d(-1, -1, -1));
BKE_object_to_mesh_clear(object);
/* including texspace transform */
float texspace_loc[3] = {0.0f, 0.0f, 0.0f}, texspace_scale[3] = {1.0f, 1.0f, 1.0f};
BKE_mesh_texspace_get((Mesh *)object->data, texspace_loc, texspace_scale);
transform *= pxr::GfMatrix4d(1.0f).SetScale(pxr::GfVec3d(texspace_scale)) *
pxr::GfMatrix4d(1.0f).SetTranslate(pxr::GfVec3d(texspace_loc));
/* */
transform *= gf_matrix_from_transform(object->object_to_world);
}
std::string VolumeModifierData::get_cached_file_path(std::string directory, int frame)