forked from blender/blender
Implement GetDoubleSided and GetCullStyle for BlenderSceneDelegate #38
@ -122,6 +122,18 @@ bool BlenderSceneDelegate::GetVisible(pxr::SdfPath const &id)
|
||||
return object_data(id)->visible;
|
||||
}
|
||||
|
||||
bool BlenderSceneDelegate::GetDoubleSided(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
return mesh_data(id)->double_sided();
|
||||
}
|
||||
|
||||
pxr::HdCullStyle BlenderSceneDelegate::GetCullStyle(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
return mesh_data(id)->cull_style;
|
||||
}
|
||||
|
||||
pxr::SdfPath BlenderSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", prim_id.GetText());
|
||||
|
@ -43,6 +43,8 @@ class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
||||
pxr::SdfPath GetMaterialId(pxr::SdfPath const &rprim_id) override;
|
||||
pxr::VtValue GetMaterialResource(pxr::SdfPath const &material_id) override;
|
||||
bool GetVisible(pxr::SdfPath const &id) override;
|
||||
bool GetDoubleSided(pxr::SdfPath const &id) override;
|
||||
pxr::HdCullStyle GetCullStyle(pxr::SdfPath const &id) override;
|
||||
pxr::SdfPath GetInstancerId(pxr::SdfPath const &prim_id) override;
|
||||
pxr::SdfPathVector GetInstancerPrototypes(pxr::SdfPath const &instancer_id) override;
|
||||
pxr::VtIntArray GetInstanceIndices(pxr::SdfPath const &instancer_id,
|
||||
|
@ -30,7 +30,7 @@ MaterialData::MaterialData(BlenderSceneDelegate *scene_delegate,
|
||||
void MaterialData::init()
|
||||
{
|
||||
ID_LOG(2, "");
|
||||
|
||||
double_sided = (((Material *)id)->blend_flag & MA_BL_CULL_BACKFACE) == 0;
|
||||
material_network_map_ = pxr::VtValue();
|
||||
|
||||
/* Call of python function hydra.export_mtlx() */
|
||||
@ -120,9 +120,13 @@ void MaterialData::remove()
|
||||
void MaterialData::update()
|
||||
{
|
||||
ID_LOG(2, "");
|
||||
bool prev_double_sided = double_sided;
|
||||
init();
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkSprimDirty(prim_id,
|
||||
pxr::HdMaterial::AllDirty);
|
||||
if (prev_double_sided != double_sided) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pxr::VtValue MaterialData::get_data(pxr::TfToken const &key) const
|
||||
|
@ -27,6 +27,8 @@ class MaterialData : public IdData {
|
||||
pxr::VtValue get_data(pxr::TfToken const &key) const override;
|
||||
pxr::VtValue get_material_resource() const;
|
||||
|
||||
bool double_sided = true;
|
||||
|
||||
private:
|
||||
pxr::SdfAssetPath mtlx_path_;
|
||||
pxr::VtValue material_network_map_;
|
||||
|
@ -74,7 +74,7 @@ void MeshData::update()
|
||||
else {
|
||||
if (id->recalc & ID_RECALC_SHADING) {
|
||||
write_material();
|
||||
bits |= pxr::HdChangeTracker::DirtyMaterialId;
|
||||
bits |= pxr::HdChangeTracker::DirtyMaterialId | pxr::HdChangeTracker::DirtyDoubleSided;
|
||||
}
|
||||
if (id->recalc & ID_RECALC_TRANSFORM) {
|
||||
write_transform();
|
||||
@ -164,6 +164,14 @@ pxr::SdfPath MeshData::material_id() const
|
||||
return mat_data_->prim_id;
|
||||
}
|
||||
|
||||
bool MeshData::double_sided() const
|
||||
{
|
||||
if (mat_data_) {
|
||||
return mat_data_->double_sided;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MeshData::write_mesh(Mesh *mesh)
|
||||
{
|
||||
face_vertex_counts_.clear();
|
||||
|
@ -28,6 +28,9 @@ class MeshData : public ObjectData {
|
||||
pxr::HdMeshTopology mesh_topology() const;
|
||||
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const;
|
||||
pxr::SdfPath material_id() const;
|
||||
bool double_sided() const;
|
||||
|
||||
pxr::HdCullStyle cull_style = pxr::HdCullStyleBackUnlessDoubleSided;
|
||||
|
||||
private:
|
||||
void write_mesh(Mesh *mesh);
|
||||
|
Loading…
Reference in New Issue
Block a user