forked from blender/blender
Implement GetDoubleSided and GetCullStyle for BlenderSceneDelegate #38
@ -23,6 +23,7 @@ extern struct CLG_LogRef *LOG_RENDER_HYDRA_SCENE; /* BSD - Blender Scene Delegat
|
||||
class BlenderSceneDelegate : public pxr::HdSceneDelegate {
|
||||
friend ObjectData; /* has access to instances */
|
||||
friend MeshData; /* has access to materials */
|
||||
friend MaterialData; /* has access to objects and instancers */
|
||||
|
||||
public:
|
||||
enum class EngineType { VIEWPORT = 1, FINAL, PREVIEW };
|
||||
|
@ -227,6 +227,13 @@ void InstancerData::update_as_parent()
|
||||
prim_id, pxr::HdChangeTracker::AllDirty);
|
||||
}
|
||||
|
||||
void InstancerData::update_double_sided(MaterialData *mat_data)
|
||||
{
|
||||
for (auto &it : mesh_instances_) {
|
||||
it.second.data->update_double_sided(mat_data);
|
||||
}
|
||||
}
|
||||
|
||||
pxr::SdfPath InstancerData::object_prim_id(Object *object) const
|
||||
{
|
||||
/* Making id of object in form like <prefix>_<pointer in 16 hex digits format> */
|
||||
|
@ -43,6 +43,7 @@ class InstancerData : public ObjectData {
|
||||
void check_remove(std::set<std::string> &available_objects);
|
||||
void available_materials(std::set<pxr::SdfPath> &paths) const;
|
||||
void update_as_parent();
|
||||
void update_double_sided(MaterialData *mat_data);
|
||||
|
||||
private:
|
||||
pxr::SdfPath object_prim_id(Object *object) const;
|
||||
|
@ -125,7 +125,15 @@ void MaterialData::update()
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkSprimDirty(prim_id,
|
||||
pxr::HdMaterial::AllDirty);
|
||||
if (prev_double_sided != double_sided) {
|
||||
|
||||
for (auto &it : scene_delegate_->objects_) {
|
||||
MeshData *m_data = dynamic_cast<MeshData *>(it.second.get());
|
||||
if (m_data) {
|
||||
m_data->update_double_sided(this);
|
||||
}
|
||||
}
|
||||
for (auto &it : scene_delegate_->instancers_) {
|
||||
it.second->update_double_sided(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@ bool MeshData::update_visibility()
|
||||
{
|
||||
bool ret = ObjectData::update_visibility();
|
||||
if (ret) {
|
||||
ID_LOG(2, "");
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkRprimDirty(
|
||||
prim_id, pxr::HdChangeTracker::DirtyVisibility);
|
||||
}
|
||||
@ -172,6 +173,15 @@ bool MeshData::double_sided() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void MeshData::update_double_sided(MaterialData *mat_data)
|
||||
{
|
||||
if (mat_data_ == mat_data) {
|
||||
ID_LOG(2, "");
|
||||
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkRprimDirty(
|
||||
prim_id, pxr::HdChangeTracker::DirtyDoubleSided);
|
||||
}
|
||||
}
|
||||
|
||||
void MeshData::write_mesh(Mesh *mesh)
|
||||
{
|
||||
face_vertex_counts_.clear();
|
||||
|
@ -29,6 +29,7 @@ class MeshData : public ObjectData {
|
||||
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const;
|
||||
pxr::SdfPath material_id() const;
|
||||
bool double_sided() const;
|
||||
void update_double_sided(MaterialData *mat_data);
|
||||
|
||||
pxr::HdCullStyle cull_style = pxr::HdCullStyleBackUnlessDoubleSided;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user