How to get all information of a single point? When should I use mapped_index?
- Dominant language
- C++
- Stars
- 7.5k
- Forks
- 1.1k
- Avg merge
- 47m
- Merged PRs (30d)
- 1
Description
Firstly I thought, when I add attributes with `identity_mapping=true`, the i-th attribute is corresponding to i-th point, codes like:
```Cpp
GeometryAttribute va;
va.Init(GeometryAttribute::POSITION, nullptr, 3, DT_FLOAT32, false,
sizeof(float) * 3, 0);
auto pos_att_id_ = mesh.AddAttribute(va, true, vertexCount);
va.Init(GeometryAttribute::GENERIC, nullptr, 1, DT_INT32, false,
sizeof(int32_t) * 1, 0);
auto generic_att_id_ = mesh.AddAttribute(va, true, vertexCount);
// add other attributes and then fill them.
```
But I got broken triangles:
```Cpp
auto &face = mesh.face(draco::FaceIndex(id)); // here the index is wrong
auto posAttr = mesh.GetNamedAttribute(draco::GeometryAttribute::POSITION);
for (auto i = 0; i < 3; ++i) {
pIndices[i] = posAttr->mapped_index(face[i]).value(); // here get the correct index
}
```
Then I did a test:
```Cpp
for(auto i = 0;i < vertexCount;++i)
{
mesh.attribute(pos_att_id_)
->SetAttributeValue(AttributeValueIndex(i), &points[i]);
mesh.attribute(generic_att_id_)
->SetAttributeValue(AttributeValueIndex(i), &i);
}
// encode and decode...
for (auto i = 0;i < vertexCount;++i)
{
int index;
decGenericAttr->ConvertValue(AttributeValueIndex(i), &index);
float pos[3];
decPosAttr->ConvertValue(AttributeValueIndex(i), pos);
// here the value of pos is corresponding to the index-th point before encode
}
```
It seems only the value of face need `mapped_index` ? In general, when should I use `mapped_index`/`GetMappedValue` ?
Contributor guide
Assessment
This issue has not been assessed yet.