Question. GeometryAttributes container size

Is it possible to set attributes container to be static size and linear, not float (to disable layout optimisation)? It makes it difficult for me to work with the attributes directly. And it is impossible to change the values with PEX operator.
I try to work with uvs, but setPolygonAttribute method in loop is working ultra slow than I set values directly in PEX. An array of attribute values is compressed and non-linear. Is that done to optimize memory usage?
It would be better to set attributes container static (optional) and make setPolygonAttribute threadsafe.

Let's say NO to Autodesk®Fabric®


  • AlexanderMAlexanderM Posts: 132 ✭✭
    edited December 2016

    I also can not change the size of the container (GeometryAttributes.resize(polygonSize(0)+polygonSize(1)+...+polygonSize(n)). Fabric do not allow to do it externally. How to use this method?

    I will describe briefly my situation. I have a many custom arrays of values, they have correct the topological order. I want to set the values to geometry directly, but that geometry attributes arrays have less sizes(optimisation?) and I can not directly assign it

    Let's say NO to Autodesk®Fabric®

  • AlexanderMAlexanderM Posts: 132 ✭✭
    edited December 2016

    I'm trying to build a key-array to handle directly to attribute values. But somehow the "getPolygonAttributeIndex" and the "setPolygonAttribute" methods give different results(look at two code examples). Before calculation of the uvs attribute I created the custom attribute and I set a unique Integer values (0,1,2,3...)using "setPolygonAttribute" way, it's forced rescaling of container to maximum size.
    And then I test two different approaches, I was expecting the same results, but there is no :

    Integer attrIndices[];//key array attrIndices.resize(polySizesSum); Integer iterator=0; for(Integer i=0;i<outMesh.polygonCount();i++) { for(Integer k=0;k<outMesh.getPolygonSize(i);k++) { attrIndices[iterator]=outMesh.getPolygonAttributeIndex(i,k);//I fill the key array iterator++; } } for(Integer i=0;i<uvsArray.size();i++) { uvsAttr.values[i]=uvsArray[attrIndices[i]];//directly set the values to attribute }


    Integer iterator=0; Ref<Vec2Attribute> uvsAttrRef=uvsAttr; for(Integer i=0;i<outMesh.polygonCount();i++) { for(Integer k=0;k<outMesh.getPolygonSize(i);k++) { outMesh.setPolygonAttribute(i,k, uvsAttrRef, uvsArray[iterator]); iterator++; } }

    Am I doing something wrong, or these two methods work differently?

    So I found a place where I made a mistake in first code example.
    uvsAttr.values[attrIndices[i]]=uvsArray[i];//directly set the values to attribute

    Let's say NO to Autodesk®Fabric®

  • jcgagnonjcgagnon Fabric Employee Posts: 122 Fabric Employee


    In order to gain an average of 5X of the attribute memory size, the PolygonMesh maintains some sharing information on behalf of the stored attributes. The setPolygonAttribute method will perform unsharing as required, trying to keep attribute rows as shared as possible (this aligns well with drawing requirements). When you set the values directly in the UVs, the PolygonMesh internal sharing information isn't updated accordingly; the attribute indices won't change to reflect the changes. This is why the methods to set attribute values should always go through the PolygonMesh. If no sharing change is done, you can still get/set the values in the attribute vector directly.

    Currently, there is no method to force an unsharing of all the attributes such that every value is unique. However, a workaround for this can be to create a "dummy" UInt32Attribute, and set different values for all polygon corners. After this, each polygon corner will be mapped to a unique attribute index (although not in polygon order since we garantee that point P corresponds to at least attribute index P). After this, you can then use safely your mapping in PEX.

    Jerome Couture-Gagnon

  • AlexanderMAlexanderM Posts: 132 ✭✭

    Hi Jerome
    Thanks for the reply. This workaround helps me

    Let's say NO to Autodesk®Fabric®

Sign In or Register to comment.