forked from blender/blender
Export volumes from object modifier (quick effect) #62
@ -304,7 +304,7 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext(GHOST_GPUSettings gpuS
|
|||||||
true,
|
true,
|
||||||
wnd,
|
wnd,
|
||||||
mHDC,
|
mHDC,
|
||||||
WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
|
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||||
4,
|
4,
|
||||||
minor,
|
minor,
|
||||||
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
(debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0),
|
||||||
|
@ -27,13 +27,15 @@ VolumeData::VolumeData(BlenderSceneDelegate *scene_delegate,
|
|||||||
|
|
||||||
void VolumeData::init()
|
void VolumeData::init()
|
||||||
{
|
{
|
||||||
ID_LOG(1, "");
|
field_descriptors_.clear();
|
||||||
|
|
||||||
Volume *volume = (Volume *)((Object *)this->id)->data;
|
Volume *volume = (Volume *)((Object *)this->id)->data;
|
||||||
Main *main = CTX_data_main(scene_delegate_->context);
|
Main *main = CTX_data_main(scene_delegate_->context);
|
||||||
if (!BKE_volume_load(volume, main)) {
|
if (!BKE_volume_load(volume, main)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
filepath_ = BKE_volume_grids_frame_filepath(volume);
|
filepath_ = BKE_volume_grids_frame_filepath(volume);
|
||||||
|
ID_LOG(1, "%s", filepath_.c_str());
|
||||||
|
|
||||||
if (volume->runtime.grids) {
|
if (volume->runtime.grids) {
|
||||||
const int num_grids = BKE_volume_num_grids(volume);
|
const int num_grids = BKE_volume_num_grids(volume);
|
||||||
@ -64,14 +66,14 @@ void VolumeData::insert()
|
|||||||
for (auto &desc : field_descriptors_) {
|
for (auto &desc : field_descriptors_) {
|
||||||
scene_delegate_->GetRenderIndex().InsertBprim(
|
scene_delegate_->GetRenderIndex().InsertBprim(
|
||||||
desc.fieldPrimType, scene_delegate_, desc.fieldId);
|
desc.fieldPrimType, scene_delegate_, desc.fieldId);
|
||||||
ID_LOG(1, "Volume field %s", desc.fieldId.GetText());
|
ID_LOG(2, "Volume field %s", desc.fieldId.GetText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeData::remove()
|
void VolumeData::remove()
|
||||||
{
|
{
|
||||||
for (auto &desc : field_descriptors_) {
|
for (auto &desc : field_descriptors_) {
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s", desc.fieldId.GetText());
|
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 2, "%s", desc.fieldId.GetText());
|
||||||
scene_delegate_->GetRenderIndex().RemoveBprim(desc.fieldPrimType, desc.fieldId);
|
scene_delegate_->GetRenderIndex().RemoveBprim(desc.fieldPrimType, desc.fieldId);
|
||||||
}
|
}
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s", prim_id.GetText());
|
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s", prim_id.GetText());
|
||||||
|
@ -39,10 +39,12 @@ bool VolumeModifierData::is_volume_modifier(Object *object)
|
|||||||
|
|
||||||
void VolumeModifierData::init()
|
void VolumeModifierData::init()
|
||||||
{
|
{
|
||||||
ID_LOG(1, "");
|
field_descriptors_.clear();
|
||||||
|
|
||||||
Object *object = (Object *)this->id;
|
Object *object = (Object *)this->id;
|
||||||
modifier_ = (FluidModifierData *)BKE_modifiers_findby_type(object, eModifierType_Fluid);
|
ModifierData *md = BKE_modifiers_findby_type(object, eModifierType_Fluid);
|
||||||
|
modifier_ = (FluidModifierData *)BKE_modifier_get_evaluated(
|
||||||
|
scene_delegate_->depsgraph, object, md);
|
||||||
|
|
||||||
if ((modifier_->domain->cache_data_format & FLUID_DOMAIN_FILE_OPENVDB) == 0) {
|
if ((modifier_->domain->cache_data_format & FLUID_DOMAIN_FILE_OPENVDB) == 0) {
|
||||||
CLOG_WARN(LOG_RENDER_HYDRA_SCENE,
|
CLOG_WARN(LOG_RENDER_HYDRA_SCENE,
|
||||||
@ -53,6 +55,7 @@ void VolumeModifierData::init()
|
|||||||
|
|
||||||
filepath_ = get_cached_file_path(modifier_->domain->cache_directory,
|
filepath_ = get_cached_file_path(modifier_->domain->cache_directory,
|
||||||
scene_delegate_->scene->r.cfra);
|
scene_delegate_->scene->r.cfra);
|
||||||
|
ID_LOG(1, "%s", filepath_.c_str());
|
||||||
|
|
||||||
for (auto &grid_name : pxr::grid_tokens_->allTokens) {
|
for (auto &grid_name : pxr::grid_tokens_->allTokens) {
|
||||||
field_descriptors_.emplace_back(grid_name,
|
field_descriptors_.emplace_back(grid_name,
|
||||||
@ -96,9 +99,10 @@ void VolumeModifierData::write_transform()
|
|||||||
Object *object = (Object *)this->id;
|
Object *object = (Object *)this->id;
|
||||||
|
|
||||||
/* set base scaling */
|
/* set base scaling */
|
||||||
transform = pxr::GfMatrix4d().SetScale(pxr::GfVec3d(1.0f / modifier_->domain->global_size[0],
|
transform = pxr::GfMatrix4d().SetScale(
|
||||||
1.0f / modifier_->domain->global_size[1],
|
pxr::GfVec3d(modifier_->domain->scale / modifier_->domain->global_size[0],
|
||||||
1.0f / modifier_->domain->global_size[2]));
|
modifier_->domain->scale / modifier_->domain->global_size[1],
|
||||||
|
modifier_->domain->scale / modifier_->domain->global_size[2]));
|
||||||
/* positioning to center */
|
/* positioning to center */
|
||||||
transform *= pxr::GfMatrix4d().SetTranslate(pxr::GfVec3d(-1, -1, -1));
|
transform *= pxr::GfMatrix4d().SetTranslate(pxr::GfVec3d(-1, -1, -1));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user