Export curves #46

Merged
Bogdan Nagirniak merged 7 commits from BLEN-364 into hydra-render 2023-05-29 11:45:41 +02:00
4 changed files with 11 additions and 16 deletions
Showing only changes of commit e45389b1c1 - Show all commits

View File

@ -26,7 +26,7 @@ class Engine;
class BlenderSceneDelegate : public pxr::HdSceneDelegate {
friend ObjectData; /* has access to instances */
friend CurvesData; /* has access to curves */
friend CurvesData; /* has access to materials */
friend MeshData; /* has access to materials */
friend MaterialData; /* has access to objects and instancers */

View File

@ -156,18 +156,16 @@ void CurvesData::write_curves(Curves *curves)
vertices_.reserve(curves->geometry.curve_num);
for (int i = 0; i < curves->geometry.curve_num; i++) {
const int first_point_index = *(curves->geometry.curve_offsets + i);
const int num_points = *(curves->geometry.curve_offsets + i + 1) - first_point_index;
int first_point_index = *(curves->geometry.curve_offsets + i);
int num_points = *(curves->geometry.curve_offsets + i + 1) - first_point_index;
curve_vertex_counts_.push_back(num_points);
/* Set radius similar to Cycles if isn't set */
float radius = radii ? radii[i] : 0.01f;
widths_.push_back(radius);
widths_.push_back(radii ? radii[i] : 0.01f);
for (int j = 0; j < num_points; j++) {
const int index = first_point_index + j;
vertices_.push_back(
pxr::GfVec3f(positions[index][0], positions[index][1], positions[index][2]));
int ind = first_point_index + j;
vertices_.push_back(pxr::GfVec3f(positions[ind][0], positions[ind][1], positions[ind][2]));
}
}
@ -180,9 +178,10 @@ void CurvesData::write_uv_maps(Curves *curves)
const float(*uvs)[2] = (const float(*)[2])CustomData_get_layer_named(
&curves->geometry.curve_data, CD_PROP_FLOAT2, "surface_uv_coordinate");
for (int i = 0; i < curves->geometry.curve_num; i++) {
uvs_.push_back(pxr::GfVec2f(uvs[i][0], uvs[i][1]));
if (uvs) {
for (int i = 0; i < curves->geometry.curve_num; i++) {
uvs_.push_back(pxr::GfVec2f(uvs[i][0], uvs[i][1]));
}
}
}

View File

@ -39,7 +39,7 @@ class CurvesData : public ObjectData {
pxr::VtIntArray curve_vertex_counts_;
pxr::VtVec3fArray vertices_;
pxr::VtVec2fArray uvs_;
pxr::VtFloatArray width_;
pxr::VtFloatArray widths_;
MaterialData *mat_data_ = nullptr;
};

View File

@ -65,10 +65,6 @@ void MaterialData::update()
if (m_data) {
m_data->update_double_sided(this);
}
CurvesData *c_data = dynamic_cast<CurvesData *>(it.second.get());
if (c_data) {
c_data->update_double_sided(this);
}
}
for (auto &it : scene_delegate_->instancers_) {
it.second->update_double_sided(this);