forked from blender/blender
Refactor code after PR #57 #67
@ -42,15 +42,15 @@ void MeshData::init()
|
||||
|
||||
void MeshData::insert()
|
||||
{
|
||||
/* Empty, because insertion of rprims happen in write_submeshes() */
|
||||
ID_LOGN(1, "");
|
||||
update_prims();
|
||||
}
|
||||
|
||||
void MeshData::remove()
|
||||
{
|
||||
for (int i = 0; i < submeshes_.size(); ++i) {
|
||||
scene_delegate_->GetRenderIndex().RemoveRprim(submesh_prim_id(i));
|
||||
ID_LOG(1, "%d", i);
|
||||
}
|
||||
ID_LOG(1, "");
|
||||
submeshes_.clear();
|
||||
update_prims();
|
||||
}
|
||||
|
||||
void MeshData::update()
|
||||
@ -58,6 +58,7 @@ void MeshData::update()
|
||||
Object *object = (Object *)id;
|
||||
if ((id->recalc & ID_RECALC_GEOMETRY) || (((ID *)object->data)->recalc & ID_RECALC_GEOMETRY)) {
|
||||
init();
|
||||
update_prims();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -228,7 +229,6 @@ const MeshData::SubMesh &MeshData::submesh(pxr::SdfPath const &id) const
|
||||
|
||||
void MeshData::write_submeshes(Mesh *mesh)
|
||||
{
|
||||
int sub_meshes_prev_count = submeshes_.size();
|
||||
submeshes_.clear();
|
||||
vertices_.clear();
|
||||
|
||||
@ -291,13 +291,15 @@ void MeshData::write_submeshes(Mesh *mesh)
|
||||
vertices_.push_back(pxr::GfVec3f(v.x, v.y, v.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Update prims in render index */
|
||||
void MeshData::update_prims()
|
||||
{
|
||||
auto &render_index = scene_delegate_->GetRenderIndex();
|
||||
int i;
|
||||
for (i = 0; i < submeshes_.size(); ++i) {
|
||||
pxr::SdfPath p = submesh_prim_id(i);
|
||||
if (i < sub_meshes_prev_count) {
|
||||
if (i < submeshes_count_) {
|
||||
render_index.GetChangeTracker().MarkRprimDirty(p, pxr::HdChangeTracker::AllDirty);
|
||||
ID_LOGN(1, "Update %d", i);
|
||||
}
|
||||
@ -306,10 +308,11 @@ void MeshData::write_submeshes(Mesh *mesh)
|
||||
ID_LOGN(1, "Insert %d", i);
|
||||
}
|
||||
}
|
||||
for (; i < sub_meshes_prev_count; ++i) {
|
||||
for (; i < submeshes_count_; ++i) {
|
||||
render_index.RemoveRprim(submesh_prim_id(i));
|
||||
ID_LOG(1, "Remove %d", i);
|
||||
}
|
||||
submeshes_count_ = submeshes_.size();
|
||||
}
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -51,9 +51,11 @@ class MeshData : public ObjectData {
|
||||
pxr::SdfPath submesh_prim_id(int index) const;
|
||||
const SubMesh &submesh(pxr::SdfPath const &id) const;
|
||||
void write_submeshes(Mesh *mesh);
|
||||
void update_prims();
|
||||
|
||||
pxr::VtVec3fArray vertices_;
|
||||
std::vector<SubMesh> submeshes_;
|
||||
int submeshes_count_ = 0;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
Loading…
Reference in New Issue
Block a user